diff --git a/application/admin/controller/Content.php b/application/admin/controller/Content.php index bb56cdc..03a87de 100644 --- a/application/admin/controller/Content.php +++ b/application/admin/controller/Content.php @@ -68,5 +68,12 @@ class Content extends Backend $this->view->assign("statusList", $this->model->getStatusList()); return $this->view->fetch(); } + public function change(){ + $id = $this->request->post('ids'); + $info = $this->model->get($id); + $info->is_hot = $info['is_hot']?0:1; + if($info->save()); return $this->success("操作成功"); + return $this->error("操作失败"); + } } diff --git a/application/admin/model/Content.php b/application/admin/model/Content.php index 9c3b578..b97c37d 100644 --- a/application/admin/model/Content.php +++ b/application/admin/model/Content.php @@ -31,7 +31,11 @@ class Content extends Model 'is_pay', 'type_tag', ]; - + protected static function init() + { + + } + public function getStatusList() { return ['0' => __('审核中'),'1' => __('审核通过'),'-1' => __('审核驳回')]; @@ -42,8 +46,19 @@ class Content extends Model $type = ContentType::get($data['content_type_id']); return $type->is_pay; } + protected function setMainPhoneAttr($value) + { + $value = $this->maskPhoneNumber($value); + return $value; + } + protected function setMainCardnoAttr($value) + { + $value = $this->maskPhoneNumber($value); + return $value; + } public function getMoneyAttr($value, $data) { + //查询当前所属类型的费用 $type = ContentType::get($data['content_type_id']); if($type->is_pay){ @@ -56,11 +71,7 @@ class Content extends Model { //查询当前所属类型的费用 $type = ContentType::get($data['content_type_id']); - if($type->is_pay){ - return $type['tag']; - }else{ - return ''; - } + return $type['tag']; } // 查询当前用户是否已经付过费 public function getlist($where, $order, $offset, $limit,$uid=0){ @@ -131,6 +142,8 @@ class Content extends Model $order = Order::where(['content_id'=>$item['id'],'user_id'=>$uid,'status'=>1])->find(); $item['payed'] = $order||$item['user_id']==$uid?1:0; $item['content_tag'] = json_decode($item['content_tag'],true); + $item['main_phone'] = $this->maskPhoneNumber($item['main_phone']); + $item['main_cardno'] = $this->maskPhoneNumber($item['main_cardno']); }); $result = array("total" => $list->total(), "rows" => $list->items(),"sql"=>$this->fetchSql()); return $result; @@ -142,4 +155,15 @@ class Content extends Model $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } + + public function maskPhoneNumber($idNumber) { + // 假设身份证号码是18位,手机号码是11位,位于第11至第21位 + if (strlen($idNumber) == 11) { + return substr_replace($idNumber, '****', 3, 4); + }elseif(strlen($idNumber) == 18){ + return substr_replace($idNumber, '****', 14, 4); + }else{ + return $idNumber; + } + } } diff --git a/application/admin/model/Order.php b/application/admin/model/Order.php index dca0064..c1f8d14 100644 --- a/application/admin/model/Order.php +++ b/application/admin/model/Order.php @@ -33,12 +33,20 @@ class Order extends Model $order = empty($order)?['o.createtime'=>"desc"]:$order; $list = $this->field("o.id,o.user_id,o.createtime,order_no,title,o.money,paytime,content_id,ispay,user_money,system_money,o.status,type,f.user_id as fabu_user_id,f.title")->alias('o')->join('fa_content f','f.id = o.content_id','LEFT') ->where($where) - ->where('ispay',1) ->paginate($limit); // ->paginate(['page'=> $offset?? 1,'list_rows' => $limit]); $result = array("total" => $list->total(), "rows" => $list->items(),"sql"=>$this->fetchSql()); return $result; } + public function getlistapi($where, $order, $offset, $limit,$sort){ + $order = empty($order)?['o.createtime'=>"desc"]:$order; + $list = $this->field("o.id,o.user_id,o.createtime,order_no,title,o.money,paytime,content_id,ispay,user_money,system_money,o.status,type,f.user_id as fabu_user_id,f.title")->alias('o')->join('fa_content f','f.id = o.content_id','LEFT') + ->where($where) + // ->paginate($limit); + ->paginate(['page'=> $offset?? 1,'list_rows' => $limit]); + $result = array("total" => $list->total(), "rows" => $list->items(),"sql"=>$this->fetchSql()); + return $result; + } // 查询当前用户是否已经付过费 public function yungudong($where, $order, $offset, $limit,$sort,$type){ $order = empty($order)?['o.createtime'=>"desc"]:$order; diff --git a/application/admin/model/content/Pinglun.php b/application/admin/model/content/Pinglun.php index 9a52b22..8c8d7a3 100644 --- a/application/admin/model/content/Pinglun.php +++ b/application/admin/model/content/Pinglun.php @@ -59,7 +59,4 @@ class Pinglun extends Model return empty($user)?'用户已注销':$user['nickname']; } - - - } diff --git a/application/admin/model/system/Fankui.php b/application/admin/model/system/Fankui.php index cfa4d4d..2a78206 100644 --- a/application/admin/model/system/Fankui.php +++ b/application/admin/model/system/Fankui.php @@ -26,8 +26,15 @@ class Fankui extends Model // 追加属性 protected $append = [ - + 'nickname' ]; + public function getNicknameAttr($value, $data) + { + //查询用户信息 + $user = \app\admin\model\User::get($data['user_id']); + + return empty($user)?'':$user['nickname']; + } public function getlist($where, $order, $offset, $limit){ $list = $this->where($where) ->order($order) diff --git a/application/api/controller/Content.php b/application/api/controller/Content.php index 409a3dd..eaf8f36 100644 --- a/application/api/controller/Content.php +++ b/application/api/controller/Content.php @@ -57,6 +57,7 @@ class Content extends Api $offset = $data['offset']; $limit = $data['limit']; $list = $this->model->getlist($where, $order, $offset, $limit,$uid); + $list['showinfo'] = $list['total']&&$list['total']<=2?$list['rows']:[$list['rows'][0],$list['rows'][1]]; return $this->success('获取成功',$list); } return $this->error("非法请求"); diff --git a/application/api/controller/User.php b/application/api/controller/User.php index f08b82b..a5b0bc0 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -499,7 +499,7 @@ class User extends Api $order = ['o.createtime'=>'desc']; $offset = $data['offset']; $limit = $data['limit']; - $list = $Order->getlist($where, $order, $offset, $limit); + $list = $Order->getlistapi($where, $order, $offset, $limit,[]); foreach($list['rows'] as $k=>&$v){ $v['title'] = $v['type']==2?'开通云股东':$v['title']; } diff --git a/public.rar b/public.rar new file mode 100644 index 0000000..777bd47 Binary files /dev/null and b/public.rar differ diff --git a/public/assets/js/backend/content.js b/public/assets/js/backend/content.js index 4496712..5342562 100644 --- a/public/assets/js/backend/content.js +++ b/public/assets/js/backend/content.js @@ -35,6 +35,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'main_realname', title: __('Main_realname'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'main_phone', title: __('Main_phone'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'main_cardno', title: __('Main_cardno'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'is_hot', title: __('是否热门'), operate: false, formatter: Controller.api.formatter.custom}, // {field: 'main_qq', title: __('Main_qq'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, // {field: 'main_wechat', title: __('Main_wechat'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'main_address', title: __('Main_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, @@ -199,7 +200,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); - } + }, + formatter: {//渲染的方法 + custom: function (value, row, index) { + //添加上btn-change可以自定义请求的URL进行数据处理 + return ''; + }, + }, } }; return Controller;