|
|
@@ -3,6 +3,7 @@
|
|
|
namespace bizHd\purchase\classes;
|
|
|
|
|
|
use biz\ghs\classes\GhsClass;
|
|
|
+use biz\shop\models\Shop;
|
|
|
use bizGhs\admin\classes\AdminClass;
|
|
|
use bizGhs\order\traits\OrderTrait;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
@@ -60,9 +61,9 @@ class PurchaseClass extends BaseClass
|
|
|
//传过滤的productId 是供货商的,需要转换为零售端(hd)的productId
|
|
|
//补充了hdProductId
|
|
|
//[{"productId":"113","bigNum":1,"smallNum":0,"classId":"-2","hdProductId":1}]
|
|
|
- $hdShopId = $data['shopId'] ?? 0;
|
|
|
- $hdSjId = $data['merchantId'] ?? 0;
|
|
|
- $productList = ProductClass::toggleProductList($productList, $hdShopId, $hdSjId);
|
|
|
+ $shopId = $data['shopId'] ?? 0;
|
|
|
+ $sjId = $data['merchantId'] ?? 0;
|
|
|
+ $productList = ProductClass::toggleProductList($productList, $shopId, $sjId);
|
|
|
|
|
|
$productData = self::getProductMapData($productList, "productId");
|
|
|
$hdProductData = self::getProductMapData($productList, "hdProductId");
|
|
|
@@ -131,6 +132,15 @@ class PurchaseClass extends BaseClass
|
|
|
util::fail('请选择花材');
|
|
|
}
|
|
|
PurchaseItemClass::batchAdd($productList);
|
|
|
+
|
|
|
+ $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
|
|
|
+ if (empty($shop)) {
|
|
|
+ util::fail('没有找到门店');
|
|
|
+ }
|
|
|
+ $shop->totalPurchaseOrder += 1;
|
|
|
+ $shop->cgUnPay += 1;
|
|
|
+ $shop->save();
|
|
|
+
|
|
|
return $respond;
|
|
|
}
|
|
|
|
|
|
@@ -214,6 +224,16 @@ class PurchaseClass extends BaseClass
|
|
|
// foreach ($purchaseItem as $v) {
|
|
|
// ProductClass::addStockByItemNum($v['ghsProductId'], $v['itemNum']);
|
|
|
// }
|
|
|
+
|
|
|
+ $shopId = $purchase->shopId;
|
|
|
+ $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
|
|
|
+ if (empty($shop)) {
|
|
|
+ util::fail('没有找到门店');
|
|
|
+ }
|
|
|
+ $shop->cgUnPay -= 1;
|
|
|
+ $shop->cgCancel += 1;
|
|
|
+ $shop->save();
|
|
|
+
|
|
|
return $purchase;
|
|
|
}
|
|
|
|
|
|
@@ -265,6 +285,15 @@ class PurchaseClass extends BaseClass
|
|
|
$purchase->status = self::STATUS_COMPLETE;
|
|
|
$purchase->save();
|
|
|
|
|
|
+ $shopId = $purchase->shopId;
|
|
|
+ $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
|
|
|
+ if (empty($shop)) {
|
|
|
+ util::fail('没有找到门店');
|
|
|
+ }
|
|
|
+ $shop->cgSending -= 1;
|
|
|
+ $shop->cgFinish += 1;
|
|
|
+ $shop->save();
|
|
|
+
|
|
|
/********订单完成后加库存 linqh 2021-05-10*********/
|
|
|
$orderSn = $purchase->orderSn;
|
|
|
$purchaseItem = PurchaseItemClass::getAllByCondition(['orderSn' => $orderSn], null, "*");
|
|
|
@@ -282,6 +311,15 @@ class PurchaseClass extends BaseClass
|
|
|
}
|
|
|
$purchase->status = PurchaseClass::STATUS_SENDING;
|
|
|
$purchase->save();
|
|
|
+
|
|
|
+ $shopId = $purchase->shopId;
|
|
|
+ $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
|
|
|
+ if (empty($shop)) {
|
|
|
+ util::fail('没有找到门店');
|
|
|
+ }
|
|
|
+ $shop->cgUnSend -= 1;
|
|
|
+ $shop->cgSending += 1;
|
|
|
+ $shop->save();
|
|
|
}
|
|
|
|
|
|
}
|