| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- namespace app\admin\controller\box;
- use app\common\model\BoxMidHandleModel;
- use app\admin\traits\Curd;
- use app\common\controller\AdminController;
- use app\common\model\ShopGoodsModel;
- use app\common\model\ThirddataLogModel;
- use app\common\model\ThirddataModel;
- use think\App;
- use think\facade\Db;
- /**
- * Class Admin
- * @package app\admin\controller\system
- * @ControllerAnnotation(title="盲盒开奖")
- */
- class HandleBoxAction extends AdminController
- {
- use Curd;
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->model = new BoxMidHandleModel();
- }
- /**
- * @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);
- }
- 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']
- ]);
- }
- // 把记录表改变状态
- Db::name('box_record')->where('id', '>', 0)->save([
- 'status'=>2
- ]);
- }
- }
- }
- }
|