|
@@ -21,7 +21,7 @@ use Yansongda\Pay\Pay; |
|
@@ -21,7 +21,7 @@ use Yansongda\Pay\Pay; |
21
|
*/
|
21
|
*/
|
22
|
class Order extends Api
|
22
|
class Order extends Api
|
23
|
{
|
23
|
{
|
24
|
- protected $noNeedLogin = ['friendPay','commentOrderDetail','pay'];
|
24
|
+ protected $noNeedLogin = ['friendPay','commentOrderDetail','pay','cancelOrderAction'];
|
25
|
protected $noNeedRight = ['*'];
|
25
|
protected $noNeedRight = ['*'];
|
26
|
|
26
|
|
27
|
/**
|
27
|
/**
|
|
@@ -534,6 +534,9 @@ class Order extends Api |
|
@@ -534,6 +534,9 @@ class Order extends Api |
534
|
->delete();
|
534
|
->delete();
|
535
|
// 如果使用了优惠券,就把优惠券状态变为已使用
|
535
|
// 如果使用了优惠券,就把优惠券状态变为已使用
|
536
|
UserCoupon::where('id',$coupon_id)->update(['status'=>'1']);
|
536
|
UserCoupon::where('id',$coupon_id)->update(['status'=>'1']);
|
|
|
537
|
+ // 待支付自动关闭
|
|
|
538
|
+ $close_minue = 15;
|
|
|
539
|
+ \think\Queue::later(($close_minue * 60), '\app\api\job\OrderAutoOper@autoClose', ['order_id' => $ordermodel->id], 'temporaryfood');
|
537
|
Db::commit();
|
540
|
Db::commit();
|
538
|
}catch (PDOException $e){
|
541
|
}catch (PDOException $e){
|
539
|
Db::rollback();
|
542
|
Db::rollback();
|
|
@@ -651,10 +654,25 @@ class Order extends Api |
|
@@ -651,10 +654,25 @@ class Order extends Api |
651
|
{
|
654
|
{
|
652
|
$order_id = $this->request->post('id');
|
655
|
$order_id = $this->request->post('id');
|
653
|
if (!is_numeric($order_id)) $this->error('参数不合法');
|
656
|
if (!is_numeric($order_id)) $this->error('参数不合法');
|
654
|
-
|
|
|
655
|
$model = new \app\api\model\Order();
|
657
|
$model = new \app\api\model\Order();
|
656
|
$order = $model->where('id',$order_id)->find();
|
658
|
$order = $model->where('id',$order_id)->find();
|
657
|
- if ($order['freight_status'] == 20) $this->error('订单已发货无法取消');
|
659
|
+ empty($order) && $this->error('订单不存在');
|
|
|
660
|
+
|
|
|
661
|
+ $res = $this->cancelOrderAction($order);
|
|
|
662
|
+ $res['code'] == 0 && $this->error($res['msg']);
|
|
|
663
|
+
|
|
|
664
|
+ $this->success('取消成功');
|
|
|
665
|
+ }
|
|
|
666
|
+
|
|
|
667
|
+ /**
|
|
|
668
|
+ * 取消订单操作
|
|
|
669
|
+ * @ApiInternal
|
|
|
670
|
+ */
|
|
|
671
|
+ public function cancelOrderAction($order)
|
|
|
672
|
+ {
|
|
|
673
|
+ if($order['freight_status'] == '20'){
|
|
|
674
|
+ return ['code' => 0,'msg' => '订单已发货无法取消'];
|
|
|
675
|
+ }
|
658
|
$goodsmodel = new \app\api\model\OrderGoods();
|
676
|
$goodsmodel = new \app\api\model\OrderGoods();
|
659
|
$skumodel = new \app\api\model\GoodsSpec();
|
677
|
$skumodel = new \app\api\model\GoodsSpec();
|
660
|
|
678
|
|
|
@@ -704,9 +722,9 @@ class Order extends Api |
|
@@ -704,9 +722,9 @@ class Order extends Api |
704
|
Db::commit();
|
722
|
Db::commit();
|
705
|
}catch (PDOException $e){
|
723
|
}catch (PDOException $e){
|
706
|
Db::rollback();
|
724
|
Db::rollback();
|
707
|
- $this->error($e->getMessage());
|
725
|
+ return ['code' => 0,'msg' => $e->getMessage()];
|
708
|
}
|
726
|
}
|
709
|
- $this->success('取消成功');
|
727
|
+ return ['code' => 1,'msg' => '取消成功'];
|
710
|
}
|
728
|
}
|
711
|
|
729
|
|
712
|
/**
|
730
|
/**
|