ShopOrderJob.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * 会员订单相关队列
  4. */
  5. namespace jobs;
  6. use app\common\model\ShopOrderModel;
  7. use think\facade\Db;
  8. class ShopOrderJob extends BaseJob
  9. {
  10. protected $model = null;
  11. public function __construct (ShopOrderModel $model)
  12. {
  13. $this->model = $model;
  14. }
  15. public function ShopOrderExpired ($data)
  16. {
  17. Db::startTrans();
  18. try {
  19. // foreach ($data as $k => $v) {
  20. $order_info = Db::name('shop_order')->where('order_sn', $data)->find();
  21. if ($order_info && $order_info['status'] == 0){
  22. Db::name('shop_order')->where('order_sn', $data)->save(['status'=>3]);
  23. }
  24. // $this->model::where(['order_sn' => array_column($data, 'order_sn'), 'status' => 0])->save(['status' => 3,'updated_time' => $nowTime]);
  25. // if (!$this->model::where(['order_sn' => $v['order_sn']])->value('status')) {
  26. // foreach ($v['order_data'] as $kk => $vv) {
  27. // Db::name('shop_goods_spec')->where(['goods_spec_id' => $vv['spec_data']['goods_spec_id']])->inc('stock', $vv['num'])->update();
  28. // }
  29. // }
  30. // }
  31. // $nowTime = date('Y-m-d H:i:s', time());
  32. // $this->model::where(['order_sn' => array_column($data, 'order_sn'), 'status' => 0])->save(['status' => 3,'updated_time' => $nowTime]);
  33. Db::commit();
  34. }catch (\Exception $e){
  35. Db::rollback();
  36. sr_log('aaa');
  37. return true;
  38. }
  39. return true;
  40. }
  41. }