AutoOpenBoxAction.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\api\command;
  4. use AlibabaCloud\SDK\OSS\OSS\SelectObjectRequest\body\selectRequest;
  5. use app\api\services\ThirdPayServices;
  6. use app\api\services\UserServices;
  7. use app\common\model\BoxMidHandleModel;
  8. use app\common\model\BoxModel;
  9. use app\common\model\CouponAreaModel;
  10. use app\common\model\CouponPlanLogModel;
  11. use app\common\model\CouponPlanModel;
  12. use app\common\model\ShopGoodsModel;
  13. use app\common\model\UserModel;
  14. use PhpOffice\PhpSpreadsheet\IOFactory;
  15. use think\console\Command;
  16. use think\console\Input;
  17. use think\console\Output;
  18. use think\db\Where;
  19. use think\Exception;
  20. use think\facade\Db;
  21. class AutoOpenBoxAction extends Command
  22. {
  23. protected function configure()
  24. {
  25. // 用户自动拆袋
  26. $this->setName('auto_open_box_action')
  27. ->setDescription('the auto_open_box_action command');
  28. }
  29. protected function execute(Input $input, Output $output)
  30. {
  31. Db::startTrans();
  32. try {
  33. $list = Db::name('box_mid_handle')->where('status', 1)->field('uid')->group('uid')->select();
  34. $model = new BoxMidHandleModel();
  35. foreach ($list as $key=>$val){
  36. $user_info = Db::name('user')->where('id', $val['uid'])->find();
  37. $model->openBoxOnline($val['uid'], [], $user_info);
  38. }
  39. Db::commit();
  40. }catch (\Exception $e){
  41. Db::rollback();
  42. return 22;
  43. }
  44. return 22;
  45. }
  46. }