model = new BoxMidHandleModel(); } use Curd; /** * @NodeAnotation(title="系统自动前置开奖结果") */ public function index(){ if ($this->request->isAjax()) { if (input('selectFields')) { return $this->selectList(); } list($page, $limit, $where) = $this->buildTableParames(); $count = $this->model ->alias('r') ->leftJoin('user u', 'u.id = r.uid') ->field('r.*,u.mobile,u.total_null_box,u.total_free,u.total_income') ->order('r.box_type desc') ->page($page, $limit) ->count(); $list = $this->model ->alias('r') ->leftJoin('user u', 'u.id = r.uid') ->field('r.*,u.mobile,u.total_null_box,u.total_free,u.total_income,u.total_appoint_count,u.box10,u.box20,u.box30,u.box40') ->order('r.box_type desc') ->page($page, $limit) ->select()->toArray(); $data = [ 'code' => 0, 'msg' => '', 'count' => $count, 'data' => $list, ]; return json($data); } // // if (!Db::name('box_mid_handle')->where('id', '>', 0)->find()){ // $redis = new \think\cache\driver\Redis(); // $redis->connect('127.0.0.1', 6379); //// has_handle_mapping 是否在进行队列跑数据 0 没有 1 有 // if ($redis->get('has_handle_mapping') == 0){ // Queue::instance()->log('确定手动执行匹配福袋')->do('SystemHandleBox')->job(SystemMiddleOpenBox::class)->push([1]); // $redis->set('has_handle_mapping',1); // return $this->fetch(); // } // // // } return $this->fetch(); } public function updateUserBox(){ $list = Db::name('box_record')->where('status', 1)->select()->toArray(); $model = new ShopGoodsModel(); foreach ($list as $key=>$val){ for ($i = 0; $i < $val['num']; $i++){ $box_type = rand(0, 4); if ($box_type > 0){ $goods = $model ->where('box_type', $box_type*10) // ->field('goods_id,box_type,goods_img,price,goods_name') ->paginate(1) ->toArray(); Db::name('box_mid_handle')->insert([ 'status'=>1, 'h_sn'=>createdHandleOrderSn(), 'uid'=>$val['uid'], 'rid'=>$val['id'], 'goods_id'=>$goods['data'][0]['goods_id'], 'create_time'=>sr_getcurtime(time()), 'box_type'=>$box_type*10, 'goods_price'=>$goods['data'][0]['price'] ]); } // if ($box_type == 0){ // // // } // // 空盒 原路返回 // if ($val['pay_type'] == 1){ // edit_user_score(2, $val['uid'], env('boxsetting.ONE_BOX_PRICE')); // } // if ($val['pay_type'] == 2){ // edit_user_money(3, $val['uid'], env('boxsetting.ONE_BOX_PRICE')); // } // 把记录表改变状态 Db::name('box_record')->where('id', '>', 0)->save([ 'status'=>2 ]); } } } }