|
|
@@ -73,6 +73,8 @@ class PurchaseClass extends BaseClass
|
|
|
$productData = self::getProductMapData($productList, "productId");
|
|
|
$hdProductData = self::getProductMapData($productList, "hdProductId");
|
|
|
|
|
|
+ $giveDiscount = $ghs['giveDiscount'] ?? 1;
|
|
|
+
|
|
|
//计算价格= 各个productId的price*num(bigNum,smallNum) + sendCost(配送费)
|
|
|
$bigNum = 0; //总共多少扎
|
|
|
$smallNum = 0; //总共多少支
|
|
|
@@ -100,10 +102,15 @@ class PurchaseClass extends BaseClass
|
|
|
$price = $discountPrice;
|
|
|
}
|
|
|
|
|
|
+ if ($giveDiscount < 1 && $giveDiscount > 0) {
|
|
|
+ $price = bcmul($price, $giveDiscount, 2);
|
|
|
+ }
|
|
|
+
|
|
|
//花材原价
|
|
|
$productPrePrice = bcmul($itemNum, $price, 2); //采购总价
|
|
|
$productTotalPrice = $productPrePrice;
|
|
|
- //花材改价
|
|
|
+
|
|
|
+ //供应商开单时修改价格
|
|
|
if (isset($product['userPrice']) && $product['userPrice'] > 0) {
|
|
|
$price = $product['userPrice'];
|
|
|
$productTotalPrice = bcmul($itemNum, $price, 2);
|
|
|
@@ -143,7 +150,7 @@ class PurchaseClass extends BaseClass
|
|
|
$sendCost = $data['sendCost'] ?? 0.00;
|
|
|
$prePrice = bcadd($prePrice, $sendCost, 2);
|
|
|
$actPrice = $prePrice;
|
|
|
- $realPrice = $prePrice;
|
|
|
+ $realPrice = $actPrice;
|
|
|
|
|
|
if (isset($data['modifyPrice'])) {
|
|
|
//商家打折,修改金额
|
|
|
@@ -159,20 +166,10 @@ class PurchaseClass extends BaseClass
|
|
|
}
|
|
|
} else {
|
|
|
|
|
|
- if (isset($ghs['giveDiscount']) && $ghs['giveDiscount'] < 1 && $ghs['giveDiscount'] > 0) {
|
|
|
- $data['discountType'] = dict::getDict('discountType', 'discount');
|
|
|
- $give = bcsub(1, $ghs['giveDiscount'], 2);
|
|
|
- $discountAmount = bcmul($prePrice, $give, 2);
|
|
|
- $data['discountAmount'] = $discountAmount;
|
|
|
- $actPrice = bcsub($prePrice, $discountAmount, 2);
|
|
|
- $realPrice = $actPrice;
|
|
|
- $data['discount'] = $ghs['giveDiscount'];
|
|
|
- }
|
|
|
-
|
|
|
//验证优惠券
|
|
|
- $couponId = isset($data['couponId']) ? $data['couponId'] : 0;
|
|
|
- if (!empty($couponId)) {
|
|
|
- $coupon = ShopCouponClass::getLockById($couponId);
|
|
|
+ $hbId = isset($data['hbId']) ? $data['hbId'] : 0;
|
|
|
+ if (!empty($hbId)) {
|
|
|
+ $coupon = ShopCouponClass::getLockById($hbId);
|
|
|
ShopCouponClass::valid($coupon, $data['shopId']);
|
|
|
if ($coupon->miniCost != 0 && $coupon->miniCost > $prePrice) {
|
|
|
util::fail('达到最低消费才能使用优惠券');
|
|
|
@@ -182,11 +179,14 @@ class PurchaseClass extends BaseClass
|
|
|
}
|
|
|
$coupon->take = ShopCouponClass::TAKE_HAS;
|
|
|
$coupon->save();
|
|
|
- $realPrice = bcsub($actPrice, $coupon->amount, 2);
|
|
|
- $data['discountType'] = dict::getDict('discountType', 'usePtCoupon');
|
|
|
+ $data['discountType'] = dict::getDict('discountType', 'hb');
|
|
|
$data['discountAmount'] = $coupon->amount;
|
|
|
+ $data['hbId'] = $hbId;
|
|
|
+
|
|
|
+ $actPrice = bcsub($prePrice, $coupon->amount, 2);
|
|
|
+ $realPrice = $actPrice;
|
|
|
+
|
|
|
}
|
|
|
- $data['couponId'] = $couponId;
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -195,6 +195,9 @@ class PurchaseClass extends BaseClass
|
|
|
$data['realPrice'] = $realPrice;
|
|
|
$data['bigNum'] = $bigNum;
|
|
|
$data['smallNum'] = $smallNum;
|
|
|
+
|
|
|
+ $data['discount'] = $giveDiscount;
|
|
|
+
|
|
|
//采购单有效期
|
|
|
$validTime = dict::getDict('sale_purchase_order_valid');
|
|
|
$current = time() + $validTime;
|
|
|
@@ -338,9 +341,9 @@ class PurchaseClass extends BaseClass
|
|
|
}
|
|
|
} else {
|
|
|
//验证优惠券
|
|
|
- $couponId = isset($data['couponId']) ? $data['couponId'] : 0;
|
|
|
- if (!empty($couponId)) {
|
|
|
- $coupon = ShopCouponClass::getLockById($couponId);
|
|
|
+ $hbId = isset($data['hbId']) ? $data['hbId'] : 0;
|
|
|
+ if (!empty($hbId)) {
|
|
|
+ $coupon = ShopCouponClass::getLockById($hbId);
|
|
|
ShopCouponClass::valid($coupon, $data['shopId']);
|
|
|
if ($coupon->miniCost != 0 && $coupon->miniCost > $prePrice) {
|
|
|
util::fail('达到最低消费才能使用优惠券');
|
|
|
@@ -353,8 +356,9 @@ class PurchaseClass extends BaseClass
|
|
|
$realPrice = bcsub($actPrice, $coupon->amount, 2);
|
|
|
$data['discountType'] = dict::getDict('discountType', 'usePtCoupon');
|
|
|
$data['discountAmount'] = $coupon->amount;
|
|
|
+ $data['hbId'] = $hbId;
|
|
|
}
|
|
|
- $data['couponId'] = $couponId;
|
|
|
+
|
|
|
}
|
|
|
$data['prePrice'] = $prePrice;
|
|
|
$data['actPrice'] = $actPrice;
|