xieruidong 2 years ago
parent
commit
8c78bc41bc

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

@@ -139,7 +139,9 @@ class Orders extends Model
 
 
 
+    public static function whenPaySuccess($params){
 
+    }
     protected static function init()
     {
         self::beforeInsert(function (self $orders){

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

@@ -16,15 +16,16 @@ class Payment extends Model
         'params'=>'json',
     ];
 
-    public static function pay(User $user,$pay_type,$amount,$class,$func,$params,$body="订单付款"){
+    public static function pay(User $user,$pay_type,$amount,$class,$func,$payment_id,$body="订单付款",$payment_type='order'){
         $payment=self::create([
             'pay_type'=>$pay_type,
             'class'=>$class,
             'method'=>$func,
-            'params'=>$params,
             'order_no'=>order_no(),
             'amount'=>$amount,
             'user_id'=>$user['id'],
+            'payment_type'=>$payment_type,
+            'payment_id'=>$payment_id,
         ]);
 
         $service=new OrderPayService();

+ 49 - 0
application/common/service/OrderPaySuccService.php

@@ -0,0 +1,49 @@
+<?php
+namespace app\common\service;
+
+use addons\epay\library\Service;
+use app\common\model\Orders;
+use app\common\model\Payment;
+use fast\Arr;
+use think\App;
+
+class OrderPaySuccService{
+    /** @var Payment */
+    protected $payment;
+    protected $methods=[
+        Orders::PT_QYWY=>'companyBank',
+        Orders::PT_WX=>'wechat',
+        Orders::PT_ZFB=>'alipay',
+        Orders::PT_YL=>'bankUnion',
+        Orders::PT_DF=>'otherUser',
+        Orders::PT_OFF=>'offline',
+    ];
+
+    /**
+     * @param Payment $payment
+     */
+    public function setPayment(Payment $payment): void
+    {
+        $this->payment = $payment;
+    }
+   public function companyBank(){}
+   public function wechat(){
+
+   }
+   public function notifyUrl(){
+        return request()->root(true)."/index/payment/notify/order_no/".$this->payment->order_no;
+   }
+    public function returnUrl(){
+        return request()->root(true);
+    }
+   public function alipay(){
+
+   }
+   public function bankUnion(){}
+   public function otherUser(){}
+   public function offline(){}
+   public function process(){
+        $method=Arr::get($this->methods,$this->payment->pay_type);
+        return App::invokeMethod([$this,$method]);
+   }
+}