Browse Source

一些功能

Kirin 4 years ago
parent
commit
2d0138995d
1 changed files with 17 additions and 1 deletions
  1. 17 1
      app/models/store/StoreExchange.php

+ 17 - 1
app/models/store/StoreExchange.php

@@ -206,11 +206,27 @@ class StoreExchange extends BaseModel
 
     public static function createOrder($order)
     {
+        $res = true;
         $carts = StoreOrderCartInfo::where('oid', $order['id'])->where('cart_id', 'in', $order['cart_id'])
             ->select();
         foreach ($carts as $cart) {
             $info = $cart['cart_info'];
-            StoreEx
+            for ($i = 0; $i < $cart['cart_info']['cart_num']; $i++) {
+                $res = $res && StoreExchangeOrder::create([
+                        'order_id' => $order['order_id'],
+                        'uid' => $order['uid'],
+                        'pay_price' => isset($info['productInfo']['attrInfo']) ? $info['productInfo']['attrInfo']['price'] : $info['productInfo']['price'],
+                        'add_time' => time(),
+                        'status' => 0,
+                        'verify_code' => self::createCode(),
+                        'store_id' => $order['store_id'],
+                        'deposit' => isset($info['productInfo']['attrInfo']) ? $info['productInfo']['attrInfo']['deposit'] : $info['productInfo']['deposit'],
+                        'exchange_id' => $order['exchange_id'],
+                        'cart_id' => $cart['cart_id'],
+                        'oid' => $order['id'],
+                    ]);
+            }
         }
+        return $res;
     }
 }