|
@@ -407,13 +407,16 @@ class PurchaseClass extends BaseClass
|
|
|
$sjId = $data['sjId'] ?? 0;
|
|
$sjId = $data['sjId'] ?? 0;
|
|
|
$mainId = $data['mainId'] ?? 0;
|
|
$mainId = $data['mainId'] ?? 0;
|
|
|
$ghsId = $data['ghsId'] ?? 0;
|
|
$ghsId = $data['ghsId'] ?? 0;
|
|
|
- //花店真实向批发店采购花材,因为拿的供货商的ID,所以则需要转化;虚拟采购用的自己的ID所以不需要转化
|
|
|
|
|
|
|
+
|
|
|
if ($live == 1) {
|
|
if ($live == 1) {
|
|
|
|
|
+ //花店真实向批发店采购花材,因为拿的供货商的ID,所以需要转化花店的id
|
|
|
$productList = ProductClass::toggleProductList($productList, $shopId, $sjId, $mainId);
|
|
$productList = ProductClass::toggleProductList($productList, $shopId, $sjId, $mainId);
|
|
|
|
|
+ $ghsProductData = self::getProductMapData($productList, "ghsProductId");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //虚拟采购用的自己的ID所以不需要转化
|
|
|
|
|
+ $ghsProductData = [];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- $productData = self::getProductMapData($productList, "productId");
|
|
|
|
|
- $hdProductData = self::getProductMapData($productList, "hdProductId");
|
|
|
|
|
|
|
+ $hdProductData = self::getProductMapData($productList, "productId");
|
|
|
|
|
|
|
|
$giveLevel = $ghs['giveLevel'] ?? 0;
|
|
$giveLevel = $ghs['giveLevel'] ?? 0;
|
|
|
$priceMap = CustomClass::$levelPriceKeyMap;
|
|
$priceMap = CustomClass::$levelPriceKeyMap;
|
|
@@ -431,8 +434,13 @@ class PurchaseClass extends BaseClass
|
|
|
$bigNum += $product['bigNum'] ?? 0;
|
|
$bigNum += $product['bigNum'] ?? 0;
|
|
|
$smallNum += $product['smallNum'] ?? 0;
|
|
$smallNum += $product['smallNum'] ?? 0;
|
|
|
$productList[$key]['orderSn'] = $orderSn;
|
|
$productList[$key]['orderSn'] = $orderSn;
|
|
|
- $productId = $product['productId'];
|
|
|
|
|
- $hdProductId = $product['hdProductId'];
|
|
|
|
|
|
|
+ if ($live == 1) {
|
|
|
|
|
+ $ghsProductId = $product['ghsProductId'];
|
|
|
|
|
+ $hdProductId = $product['productId'];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $hdProductId = $product['productId'] ?? 0;
|
|
|
|
|
+ $ghsProductId = 0;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$unitWeight = $hdProductData[$hdProductId]['weight'] ?? 0;
|
|
$unitWeight = $hdProductData[$hdProductId]['weight'] ?? 0;
|
|
|
$variety = $hdProductData[$hdProductId]['variety'] ?? 0;
|
|
$variety = $hdProductData[$hdProductId]['variety'] ?? 0;
|
|
@@ -448,40 +456,50 @@ class PurchaseClass extends BaseClass
|
|
|
$currentWeight = bcmul($weight, $itemNum, 2);
|
|
$currentWeight = bcmul($weight, $itemNum, 2);
|
|
|
$totalWeight = bcadd($currentWeight, $totalWeight, 2);
|
|
$totalWeight = bcadd($currentWeight, $totalWeight, 2);
|
|
|
|
|
|
|
|
- //供货商开单改价,这个价格优先级最高
|
|
|
|
|
- $changePrice = isset($product['userPrice']) && $product['userPrice'] > 0 ? $product['userPrice'] : 0;
|
|
|
|
|
|
|
+ //1、供货商开单改价 2、花店向虚拟供货商采购录入价格
|
|
|
|
|
+ $userPrice = isset($product['userPrice']) && $product['userPrice'] > 0 ? $product['userPrice'] : 0;
|
|
|
|
|
+ $currentGhsProduct = $ghsProductData[$ghsProductId] ?? [];
|
|
|
|
|
+
|
|
|
|
|
+ if (!empty($currentGhsProduct) && $userPrice > 0) {
|
|
|
|
|
+ util::fail('商城下单暂不支持小单位');
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- $currentProduct = $productData[$productId] ?? [];
|
|
|
|
|
- $price = ProductClass::getFinalPrice($currentProduct, $giveLevel, $priceMap, $addPriceMap, $changePrice);
|
|
|
|
|
- $bigPrice = $price;
|
|
|
|
|
|
|
+ if (!empty($currentGhsProduct)) {
|
|
|
|
|
+ //用批发店的花材名称
|
|
|
|
|
+ $itemName = $currentGhsProduct['name'] ?? '';
|
|
|
|
|
+ $cover = $currentGhsProduct['cover'] ?? '';
|
|
|
|
|
+ //用批发店花材的价格
|
|
|
|
|
+ $price = ProductClass::getFinalPrice($currentGhsProduct, $giveLevel, $priceMap, $addPriceMap, $userPrice);
|
|
|
|
|
+ $thisPrice = $price;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $currentHdProduct = $hdProductData[$hdProductId] ?? [];
|
|
|
|
|
+ if (empty($currentHdProduct)) {
|
|
|
|
|
+ util::fail('花材有问题哦');
|
|
|
|
|
+ }
|
|
|
|
|
+ $itemName = $currentHdProduct['name'] ?? '';
|
|
|
|
|
+ $cover = $currentHdProduct['cover'] ?? '';
|
|
|
|
|
+ $price = $userPrice;
|
|
|
|
|
+ $thisPrice = $userPrice;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if ($currentSmallNum > 0) {
|
|
if ($currentSmallNum > 0) {
|
|
|
- //如果是小单位数量,则传过来的就是小单位价格,无需转换
|
|
|
|
|
- if (empty($changePrice)) {
|
|
|
|
|
- $ghsRatio = $currentProduct['ratio'] ?? 0;
|
|
|
|
|
- $ghsSmallRatio = $currentProduct['smallRatio'] ?? 1;
|
|
|
|
|
- $price = bcdiv($price, $ghsRatio, 2);
|
|
|
|
|
- $price = bcmul($price, $ghsSmallRatio, 2);
|
|
|
|
|
- }
|
|
|
|
|
$productTotalPrice = bcmul($currentSmallNum, $price, 2);
|
|
$productTotalPrice = bcmul($currentSmallNum, $price, 2);
|
|
|
} else {
|
|
} else {
|
|
|
$productTotalPrice = bcmul($currentBigNum, $price, 2);
|
|
$productTotalPrice = bcmul($currentBigNum, $price, 2);
|
|
|
}
|
|
}
|
|
|
- //用批发店的花材名称
|
|
|
|
|
- $itemName = $currentProduct['name'] ?? '';
|
|
|
|
|
- $cover = $currentProduct['cover'] ?? '';
|
|
|
|
|
|
|
+
|
|
|
$itemInfo = [
|
|
$itemInfo = [
|
|
|
- 'itemName' => $itemName,//花材名称
|
|
|
|
|
- 'itemCover' => $cover,//花材图片
|
|
|
|
|
- 'bigNum' => $product['bigNum'] ?? 0,//采购数量(大单位)
|
|
|
|
|
- 'smallNum' => $product['smallNum'] ?? 0,//采购数量(小单位)
|
|
|
|
|
- 'bigNumStock' => $stockFormat['bigNum'],// 当时库存大单位数
|
|
|
|
|
- 'smallNumStock' => $stockFormat['smallNum'],//当时库存 小单位数
|
|
|
|
|
- 'itemUnit' => $ratio ? 2 : 1,//单位
|
|
|
|
|
- 'ratio' => $ratio,// 比例
|
|
|
|
|
- 'rank' => $rank,// 花材级别
|
|
|
|
|
- 'bigUnit' => $hdProductData[$hdProductId]['bigUnit'],//大单位名称 扎
|
|
|
|
|
- 'smallUnit' => $hdProductData[$hdProductId]['smallUnit'],//小单位名称 支
|
|
|
|
|
|
|
+ 'itemName' => $itemName,
|
|
|
|
|
+ 'itemCover' => $cover,
|
|
|
|
|
+ 'bigNum' => $product['bigNum'] ?? 0,
|
|
|
|
|
+ 'smallNum' => $product['smallNum'] ?? 0,
|
|
|
|
|
+ 'bigNumStock' => $stockFormat['bigNum'],
|
|
|
|
|
+ 'smallNumStock' => $stockFormat['smallNum'],
|
|
|
|
|
+ 'itemUnit' => $ratio ? 2 : 1,
|
|
|
|
|
+ 'ratio' => $ratio,
|
|
|
|
|
+ 'rank' => $rank,
|
|
|
|
|
+ 'bigUnit' => $hdProductData[$hdProductId]['bigUnit'],
|
|
|
|
|
+ 'smallUnit' => $hdProductData[$hdProductId]['smallUnit'],
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
$productList[$key]['itemInfo'] = json_encode($itemInfo);
|
|
$productList[$key]['itemInfo'] = json_encode($itemInfo);
|
|
@@ -491,13 +509,13 @@ class PurchaseClass extends BaseClass
|
|
|
$productList[$key]['itemNum'] = $itemNum;
|
|
$productList[$key]['itemNum'] = $itemNum;
|
|
|
$productList[$key]['bigNum'] = $product['bigNum'] ?? 0;
|
|
$productList[$key]['bigNum'] = $product['bigNum'] ?? 0;
|
|
|
$productList[$key]['smallNum'] = $product['smallNum'] ?? 0;
|
|
$productList[$key]['smallNum'] = $product['smallNum'] ?? 0;
|
|
|
- $productList[$key]['price'] = $bigPrice;
|
|
|
|
|
|
|
+ $productList[$key]['price'] = $thisPrice;
|
|
|
$productList[$key]['ratio'] = $ratio;
|
|
$productList[$key]['ratio'] = $ratio;
|
|
|
$productList[$key]['unitWeight'] = $unitWeight;
|
|
$productList[$key]['unitWeight'] = $unitWeight;
|
|
|
$productList[$key]['totalPrice'] = $productTotalPrice;
|
|
$productList[$key]['totalPrice'] = $productTotalPrice;
|
|
|
$productList[$key]['preTotalPrice'] = $productTotalPrice;
|
|
$productList[$key]['preTotalPrice'] = $productTotalPrice;
|
|
|
$productList[$key]['productId'] = $hdProductId;
|
|
$productList[$key]['productId'] = $hdProductId;
|
|
|
- $productList[$key]['ghsProductId'] = $productId;
|
|
|
|
|
|
|
+ $productList[$key]['ghsProductId'] = $ghsProductId;
|
|
|
$productList[$key]['smallPrice'] = $price;
|
|
$productList[$key]['smallPrice'] = $price;
|
|
|
$productList[$key]['mainId'] = $mainId;
|
|
$productList[$key]['mainId'] = $mainId;
|
|
|
$productList[$key]['ghsId'] = $ghsId;
|
|
$productList[$key]['ghsId'] = $ghsId;
|
|
@@ -583,6 +601,7 @@ class PurchaseClass extends BaseClass
|
|
|
$data['bigNum'] = $bigNum;
|
|
$data['bigNum'] = $bigNum;
|
|
|
$data['smallNum'] = $smallNum;
|
|
$data['smallNum'] = $smallNum;
|
|
|
$data['discount'] = 1;
|
|
$data['discount'] = 1;
|
|
|
|
|
+ $data['status'] = self::STATUS_UN_PAY;
|
|
|
|
|
|
|
|
//采购单有效期
|
|
//采购单有效期
|
|
|
$currentTime = time();
|
|
$currentTime = time();
|