xieruidong 2 年之前
父节点
当前提交
c6c46cb8b1

+ 3 - 2
application/common/model/Orders.php

@@ -16,7 +16,7 @@ class Orders extends Model
     ];
 
     #未支付过期时间
-    const EXP_PAY=30;
+    const EXP_PAY=1800;
     #待收货过期时间
     const EXP_REC=30*86400;
 
@@ -117,6 +117,7 @@ class Orders extends Model
             'whenPaySuccess',
             $this['id'],
             "订单【{$this['order_no']}】付款",
+            $this->getTable(),
         );
     }
     public static function makePayed(Payment $payment){
@@ -194,7 +195,7 @@ class Orders extends Model
             #优惠总金额
             $orders['amount_discount']=bcAddAll($orders['amount_coupon']??0,$orders['amount_coupon_kill']);
             #过期时间
-            $orders['continue_expire_time']=time()+60*self::EXP_PAY;
+            $orders['continue_expire_time']=time()+self::EXP_PAY;
         });
         self::beforeUpdate(function (self $order){
             $data=$order->getChangedData();

+ 11 - 1
application/common/model/Payment.php

@@ -31,6 +31,7 @@ class Payment extends Model
         $service=new OrderPayService();
         $service->setPayment($payment);
         $service->setBody($body);
+        $service->setExpire($payment->getExpire());
         return $service->pay();
     }
     public function user(){
@@ -41,9 +42,18 @@ class Payment extends Model
         $this['pay_time']=time();
         $this->save();
         switch ($this['payment_type']){
-            case 'orders':
+            case (new Orders)->getTable():
                 Orders::makePayed($this['payment_id']);
                 break;
         }
     }
+
+    public function getExpire(){
+        switch ($this['payment_type']){
+            case (new Orders)->getTable():
+                return time()+Orders::EXP_PAY-60;
+            default:
+                return time()+3600;
+        }
+    }
 }

+ 12 - 0
application/common/service/OrderPayService.php

@@ -12,6 +12,7 @@ class OrderPayService{
     protected $payment;
     /** @var string */
     protected $body;
+    protected $expire=null;
     public static $methods=[
         Orders::PT_QYWY=>'companyBank',
         Orders::PT_WX=>'wechat',
@@ -22,6 +23,13 @@ class OrderPayService{
     ];
 
     /**
+     * @param null $expire
+     */
+    public function setExpire($expire): void
+    {
+        $this->expire = $expire;
+    }
+    /**
      * @param Payment $payment
      */
     public function setPayment(Payment $payment): void
@@ -62,6 +70,8 @@ class OrderPayService{
             $this->notifyUrl(),
             $this->returnUrl(),
             'scan',
+            '',
+            $this->expire,
         );
 
         $str=$payData['code_url'];
@@ -84,6 +94,8 @@ class OrderPayService{
            $this->notifyUrl(),
            $this->returnUrl(),
            'scan',
+           '',
+           $this->expire,
        );
 
        $str=$payData['qr_code'];