model = new BoxRecordModel(); } use Curd; /** * @NodeAnotation(title="福袋预约记录") */ public function index() { if ($this->request->isAjax()) { if (input('selectFields')) { return $this->selectList(); } list($page, $limit, $where) = $this->buildTableParames(); $isMatch = $this->request->get('match', 0); if ($isMatch) { $where['is_set_match'] = 1; $where['box10'] = 1; } $list = BoxRecordService::make()->getCatchList($where, $limit); $data = [ 'code' => 0, 'msg' => '获取成功', 'count' => isset($list['total']) ? $list['total'] : 0, 'data' => isset($list['data']) ? $list['data'] : [], ]; return json($data); } $totalNum = BoxRecordModel::where('id', '>', 0)->sum('num'); $totalCurnum = BoxRecordModel::where('id', '>', 0) ->where('status', 1) ->where('create_time', '>=', date('Y-m-d')) ->sum('num'); $this->assign('cur_info', [ 'total_num' => $totalNum, 'total_money' => $totalNum * env('boxsetting.ONE_BOX_PRICE'), 'total_curnum' => $totalCurnum, 'total_curmoney' => $totalCurnum * env('boxsetting.ONE_BOX_PRICE'), ]); return $this->fetch(); } /** * @NodeAnotation(title="手动干预福袋开奖") */ public function beforeopen($id) { if ($this->request->isPost()) { $data = $this->request->post(); $result = BoxRecordService::make()->setBoxMatch($id, $data); if ($result === true) { $this->success('设置成功'); } else { $this->error($result ? $result : '设置失败'); } } $info = $this->model->where('id', $id)->find(); $this->assign('data', $info); return $this->fetch(); } /** * @NodeAnotation(title="系统自动前置开奖结果") */ public function beforehandle() { if ($this->request->isAjax()) { if (input('selectFields')) { return $this->selectList(); } list($page, $limit, $where) = $this->buildTableParames(); $model = new BoxMidHandleModel(); $count = $list = $model ->alias('m') ->leftJoin('user u', 'u.id = r.uid') ->field('r.*,u.mobile') ->order('r.num 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') ->order('r.num desc') ->page($page, $limit) ->select()->toArray(); $data = [ 'code' => 0, 'msg' => '', 'count' => $count, 'data' => $list, ]; return json($data); } return $this->fetch(); } /** * 设置匹配 * @param $id * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function setting($id) { if ($this->request->isAjax()) { $data = $this->request->post(); $result = BoxRecordService::make()->setBoxMatch($id, $data); if ($result === true) { $this->success('设置成功'); } else { $this->error($result ? $result : '设置失败'); } } $this->assign('id', $id); return $this->fetch(); } /** * 手动开奖 * @param $id * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function openBox() { $data = $this->request->post(); $ids = isset($data['id']) ? $data['id'] : []; $result = BoxRecordService::make()->openBox($ids, $data); if (is_array($result)) { $this->success($result['msg'], $result['data'], '', 10); } else { $this->error($result ? $result : '开奖失败'); } } }