|
@@ -601,6 +601,56 @@ class StoreProduct extends BaseModel
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public static function getStoreProductPrice(array $cartId)
|
|
|
+ {
|
|
|
+ $cartInfo = StoreOrderCartInfo::whereIn('cart_id', $cartId)->column('cart_info');
|
|
|
+ $oneBrokerage = [];
|
|
|
+ $twoBrokerage = [];
|
|
|
+ $sumProductPriceBrokerage = [];
|
|
|
+ $sumProductPrice = [];
|
|
|
+ foreach ($cartInfo as $value) {
|
|
|
+ $product = json_decode($value, true);
|
|
|
+ $cartNum = $product['cart_num'] ?? 0;
|
|
|
+ if (isset($product['productInfo']) && ($product['productInfo']['store_id'] ?? 0) > 0) {
|
|
|
+ $productInfo = $product['productInfo'];
|
|
|
+
|
|
|
+ $sumProductPrice[$productInfo['store_id']] = bcadd($sumProductPrice[$productInfo['store_id']] ?? 0, bcmul($cartNum, ($productInfo['attrInfo']['price'] ?? $product['price']) ?? 0, 2), 2);
|
|
|
+ if (isset($productInfo['is_sub']) && $productInfo['is_sub'] == 1) {
|
|
|
+ $oneBrokerage[$productInfo['store_id']] = bcadd($oneBrokerage[$productInfo['store_id']] ?? 0, bcmul($cartNum, $productInfo['attrInfo']['brokerage'] ?? 0, 2), 2);
|
|
|
+ $twoBrokerage[$productInfo['store_id']] = bcadd($oneBrokerage[$productInfo['store_id']] ?? 0, bcmul($cartNum, $productInfo['attrInfo']['brokerage_two'] ?? 0, 2), 2);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if (isset($productInfo['attrInfo'])) {
|
|
|
+ $sumProductPrice = bcadd($sumProductPrice, bcmul($cartNum, $productInfo['attrInfo']['price'] ?? 0, 2), 2);
|
|
|
+ } else {
|
|
|
+ $sumProductPriceBrokerage[$productInfo['store_id']] = bcadd($sumProductPriceBrokerage[$productInfo['store_id']] ?? 0, bcmul($cartNum, ($productInfo['attrInfo']['price'] ?? $product['price']) ?? 0, 2), 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($sumProductPrice as $k => $v) {
|
|
|
+ $sumProductPrice[$k] = bcsub($sumProductPrice[$k], $oneBrokerage[$k], 2);
|
|
|
+ $sumProductPrice[$k] = bcsub($sumProductPrice[$k], $twoBrokerage[$k], 2);
|
|
|
+ $storeBrokerageRatio = sys_config('store_brokerage_ratio');
|
|
|
+
|
|
|
+ if ($storeBrokerageRatio > 0) {
|
|
|
+ $brokerageRatio = bcdiv($storeBrokerageRatio, 100, 2);
|
|
|
+ $brokeragePrice = bcmul($sumProductPriceBrokerage[$k], $brokerageRatio, 2);
|
|
|
+ $sumProductPrice[$k] = bcsub($sumProductPrice[$k], $brokeragePrice, 2);
|
|
|
+ }
|
|
|
+ $storeBrokerageTwo = sys_config('store_brokerage_two');
|
|
|
+
|
|
|
+ if ($storeBrokerageTwo > 0) {
|
|
|
+ $brokerageRatio = bcdiv($storeBrokerageTwo, 100, 2);
|
|
|
+ $brokeragePrice = bcmul($sumProductPriceBrokerage[$k], $brokerageRatio, 2);
|
|
|
+ $sumProductPrice[$k] = bcsub($sumProductPrice[$k], $brokeragePrice, 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $sumProductPrice;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 获取商品在此时段活动优先类型
|
|
|
*/
|