xieruidong 2 лет назад
Родитель
Сommit
c4b550ad9f
1 измененных файлов с 7 добавлено и 4 удалено
  1. 7 4
      application/common/model/UserTax.php

+ 7 - 4
application/common/model/UserTax.php

@@ -13,10 +13,13 @@ class UserTax extends Model
 
     public static function fromOrder(Orders $orders){
         if($orders['tax']){
-            self::create([
-                'user_id'=>$orders['user_id'],
-                'tax'=>$orders['tax'],
-            ]);
+            $has=self::where('user_id',$orders['user_id'])->where('tax',json_encode($orders['tax'],JSON_UNESCAPED_UNICODE))->find();
+            if(!$has) {
+                self::create([
+                    'user_id' => $orders['user_id'],
+                    'tax' => $orders['tax'],
+                ]);
+            }
         }
     }
 }