| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?php
- namespace app\admin\controller\box;
- use app\admin\model\SystemAdmin;
- use app\common\model\BoxMidHandleModel;
- use app\common\model\BoxModel;
- use app\common\model\BoxRecordModel;
- use app\common\model\CouponAreaModel;
- use app\common\model\CouponPlanModel;
- use app\common\model\ShopCategory;
- 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 Darabonba\GatewaySpi\Models\InterceptorContext\request;
- use EasyAdmin\annotation\ControllerAnnotation;
- use EasyAdmin\annotation\NodeAnotation;
- use jobs\SystemMiddleOpenBox;
- use think\App;
- use utils\Queue;
- use think\facade\Db;
- use think\Model;
- /**
- * Class Admin
- * @package app\admin\controller\system
- * @ControllerAnnotation(title="盲盒开奖")
- */
- class HandleBoxAction extends AdminController
- {
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->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
- ]);
- }
- }
- }
- }
|