title = '作品列表'; $this->source_arr = ['','购买','兑换','邀请','赠送']; if(input('hash_str')){ $detail = Db::table('goods_collect')->where('hash_str',input('hash_str'))->find(); $id = $detail['id']; $original_id =$detail['original_id']; if($original_id > 0){ $query = $this->_query($this->table) ->alias('c') ->field('c.*,m.name as user_name,m.headimg,m.phone') ->join('store_member m','m.id = c.user_id','LEFT') ->where('original_id|c.id',$original_id) ->order('c.id asc')->page(); }else{ $query = $this->_query($this->table) ->alias('c') ->field('c.*,m.name as user_name,m.headimg,m.phone') ->join('store_member m','m.id = c.user_id','LEFT') ->where('c.id',$id) ->order('c.id asc')->page(); } }else{ $where = []; $where[]= ['c.status','=',1]; if(input('goods_name')) $where[]= ['c.goods_name','like','%'.input('goods_name').'%']; if(input('user_name')) $where[]= ['m.name','like','%'.input('user_name').'%']; if(input('phone')) $where[]= ['m.phone','like','%'.input('phone').'%']; $query = $this->_query($this->table) ->alias('c') ->field('c.*,m.name as user_name,m.headimg,m.phone') ->join('store_member m','m.id = c.user_id','LEFT') ->where($where); $query->order('c.id desc')->page(); } } /** * 数据列表处理 * @auth true * @menu true * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ protected function _index_page_filter(&$data) { foreach ($data as $k=>&$v){ } } //删除货主 public function remove() { $this->_save($this->table, ['status' => '3']); } public function edit(){ $this->title = '编辑'; $this->_form($this->table, 'form'); } protected function _form_filter(&$data){ if($this->request->isPost() && $this->request->action() == 'integral') { if($data['id']) { if($data['int_type'] == 6) { update_user_integral($data['id'],$data['int_num'],$data['int_type'],'后台增加'); }else{ update_user_integral($data['id'],$data['int_num'] * -1,$data['int_type'],'后台扣减'); } } } if($this->request->isPost() && $this->request->action() == 'send') { if($data['id']) { $send_num = intval($data['send_num']); $coupon_id = $data['coupon_id']; if($send_num > 0){ $coupon_info = Db::table('store_coupon_config')->find($coupon_id); $low_day = $coupon_info['low_day']; $coupon_data = []; for ($c = 1 ;$c <= $send_num ;$c++) { $coupon_data[]= [ 'user_id' => $data['id'], 'low_day' =>$coupon_info['low_day'], 'lid' =>$coupon_id, 'money' =>$coupon_info['amount'], 'type' =>1, 'create_at'=> date('Y-m-d H:i:s'), 'past_at' => date('Y-m-d H:i:s',strtotime("+$low_day days")) ]; } Db::table('user_coupon_list')->insertAll($coupon_data); } } } if($this->request->isPost() && $this->request->action() == 'crystal'){ if($data['id']) { $change_crystal = intval($data['change_crystal']); $change_type = $data['int_type']; $mul = $change_type == 12 ? 1:-1; $msg = $change_type == 12 ? '后台充值':'后台扣减'; $user_info = Db::table('store_member')->find($data['id']); $data['crystal'] = $user_info['crystal'] + $change_crystal*$mul; if( $data['crystal'] <0 || $data['crystal_cash']<0 ) $this->error('扣减数据数量有误!'); if($change_crystal) crystal_log($data['id'],$change_crystal*$mul,$msg.'(元石)',$change_type); } } } }