|
|
@@ -536,6 +536,8 @@ class ProductClass extends BaseClass
|
|
|
|
|
|
//下单时计算商品的价格 linqh 2021.1.28
|
|
|
//itemInfo : [{"classId":5,"productId":3,"bigNum":1,"smallNum":2},{"classId":5,"productId":4,"bigNum":1,"smallNum":5}]
|
|
|
+ //2021.7.26增加前端传的价格 (小程序有传,但pc端不穿)
|
|
|
+ //itemInfo :[{"classId":5,"productId":3,"bigNum":1,"smallNum":2,"price":0}]
|
|
|
//返回 [{"productId":3,"price":2.1}]
|
|
|
public static function formatProductInfo(array $itemInfo)
|
|
|
{
|
|
|
@@ -560,13 +562,28 @@ class ProductClass extends BaseClass
|
|
|
$itemNum = self::mergeItemNum($v['bigNum'], $v['smallNum'], $ratio);
|
|
|
//售卖价格
|
|
|
$itemPrice = $productData[$productId]['price'] ?? 0;
|
|
|
+ $userPrice = 0; //用户传的价格
|
|
|
+ if(isset($v['price'])){
|
|
|
+ if($v['price'] <= 0){
|
|
|
+ util::fail('花材价格不能小于0');
|
|
|
+ }
|
|
|
+ $userPrice = $v['price'];
|
|
|
+ }else{
|
|
|
+ //按原来的计算方法,合计价格
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//合计价格
|
|
|
$price = bcmul($itemNum, $itemPrice, 2);
|
|
|
$tmp = [];
|
|
|
$tmp['productId'] = $productId;
|
|
|
$tmp['price'] = $price;
|
|
|
|
|
|
- $totalPrice = bcadd($totalPrice, $price, 2);
|
|
|
+ if($userPrice > 0 ){
|
|
|
+ $totalPrice = bcadd($totalPrice, $userPrice, 2);
|
|
|
+ }else{
|
|
|
+ $totalPrice = bcadd($totalPrice, $price, 2);
|
|
|
+ }
|
|
|
|
|
|
$tmp['name'] = $productData[$productId]['name'] ?? '';
|
|
|
$tmp['smallUnit'] = $productData[$productId]['smallUnit']??'支';
|
|
|
@@ -579,6 +596,7 @@ class ProductClass extends BaseClass
|
|
|
$tmp['num'] = $itemNum;
|
|
|
$tmp['bigNum'] = $v['bigNum'];
|
|
|
$tmp['smallNum'] = $v['smallNum'];
|
|
|
+ $tmp['userPrice'] = $userPrice;
|
|
|
|
|
|
$totalBigNum += $v['bigNum'];
|
|
|
$totalSmallNum += $v['smallNum'];
|