xieruidong há 2 anos atrás
pai
commit
519575ef69

+ 1 - 4
application/common/model/Orders.php

@@ -233,10 +233,7 @@ class Orders extends Model
             $orders['continue_expire_time']=time()+self::EXP_PAY;
             #添加发票
             if($orders['tax']) {
-                UserTax::create([
-                    'user_id' => $orders['user_id'],
-                    'tax' => $orders['tax']
-                ]);
+                UserTax::fromOrder($orders);
             }
         });
         self::beforeUpdate(function (self $order){

+ 9 - 0
application/common/model/UserTax.php

@@ -10,4 +10,13 @@ class UserTax extends Model
     protected $type=[
         'tax'=>'json',
     ];
+
+    public static function fromOrder(Orders $orders){
+        if($orders['tax']){
+            self::create([
+                'user_id'=>$orders['user_id'],
+                'tax'=>$orders['tax'],
+            ]);
+        }
+    }
 }