title = '转赠列表'; $where = []; $where[] = ['i.status','in','2,3']; // $where[]= ['c.status','=',1]; //if(input('goods_name')) $where[]= ['c.goods_name','like','%'.input('goods_name').'%']; if(input('name')) $where[]= ['m.name|c.name','like','%'.input('name').'%']; if(input('phone')) $where[]= ['m.phone|c.phone','like','%'.input('phone').'%']; if(input('order_num')) $where[]= ['i.order_no','like','%'.input('order_num').'%']; $query = $this->_query($this->table) ->alias('i') ->field('i.*,m.name as from_name,m.phone as from_phone,m.headimg as from_headimg,c.name as to_name,c.phone as to_phone,c.headimg as to_headimg') ->join('store_member m','m.id = i.mid') ->join('store_member c','c.id = i.to_mid'); if(!empty($where)) $query->where($where); if(input('coll_name')){ $ids = Db::name('store_collection')->whereLike('name','%'.input('coll_name').'%')->column('id'); $query->whereIn('c_id',$ids); } $query->dateBetween('over_time')->order('i.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){ $v['pro_info'] = json_decode($v['pro_info'],true); } } //删除货主 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); } } } }