|
|
@@ -131,20 +131,32 @@ class OrderController extends BaseController
|
|
|
//$sendCost = isset($respond['fee']) ? $respond['fee'] : 0;
|
|
|
}
|
|
|
$post['sendCost'] = $sendCost;
|
|
|
-
|
|
|
- $prePrice = stringUtil::calcAdd($sendCost, $totalGoodsPrice);
|
|
|
-
|
|
|
- //来源 0微信 1支付宝 2小程序 3朋友圈 4美团
|
|
|
- $sourceType = $this->isWx ? 0 : 1;
|
|
|
- if (httpUtil::isMiniProgram()) {
|
|
|
- $sourceType = 2;
|
|
|
+ $currentPrice = stringUtil::calcAdd($sendCost, $totalGoodsPrice);
|
|
|
+ $post['prePrice'] = $currentPrice;
|
|
|
+ if (isset($post['modifyPrice'])) {
|
|
|
+ //商家打折,修改金额
|
|
|
+ $modifyPrice = $post['modifyPrice'] ?? 0;
|
|
|
+ if ($modifyPrice > $currentPrice) {
|
|
|
+ util::fail('实收金额大于订单总金额');
|
|
|
+ }
|
|
|
+ if ($modifyPrice < $currentPrice) {
|
|
|
+ $post['discountAmount'] = bcsub($currentPrice, $modifyPrice, 2);
|
|
|
+ $post['discountType'] = dict::getDict('discountType', 'discount');
|
|
|
+ $currentPrice = $modifyPrice;
|
|
|
+ }
|
|
|
}
|
|
|
- $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
|
|
|
- $actPrice = $discountData['price'];
|
|
|
- $post['discountType'] = $discountData['discountType'];
|
|
|
- $post['discountAmount'] = $discountData['discountAmount'];
|
|
|
- $post['prePrice'] = $prePrice;
|
|
|
- $post['actPrice'] = $actPrice;
|
|
|
+ $post['actPrice'] = $currentPrice;
|
|
|
+ $post['realPrice'] = $currentPrice;
|
|
|
+ //来源 0微信 1支付宝 2小程序 3朋友圈 4美团
|
|
|
+// $sourceType = $this->isWx ? 0 : 1;
|
|
|
+// if (httpUtil::isMiniProgram()) {
|
|
|
+// $sourceType = 2;
|
|
|
+// }
|
|
|
+ //会员优惠价
|
|
|
+// $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
|
|
|
+// $actPrice = $discountData['price'];
|
|
|
+// $post['discountType'] = $discountData['discountType'];
|
|
|
+// $post['discountAmount'] = $discountData['discountAmount'];
|
|
|
$order = OrderClass::addOrder($post);
|
|
|
$orderId = $order['id'];
|
|
|
$orderSn = $order['orderSn'];
|
|
|
@@ -161,15 +173,33 @@ class OrderController extends BaseController
|
|
|
if (empty($product)) {
|
|
|
util::fail('请选择花材');
|
|
|
}
|
|
|
- $actPrice = $post['packingFee'] ?? 0; //包装费
|
|
|
+ $currentPrice = $post['packingFee'] ?? 0; //包装费
|
|
|
$orderProduct = [];
|
|
|
$productInfo = ProductClass::formatProductInfo($product);
|
|
|
- $actPrice = bcadd($actPrice, $productInfo['price'], 2);
|
|
|
+ $currentPrice = bcadd($currentPrice, $productInfo['price'], 2);
|
|
|
+ $sendCost = isset($post['sendCost']) && is_numeric($post['sendCost']) ? $post['sendCost'] : 0;
|
|
|
+ $post['sendCost'] = $sendCost;
|
|
|
+ $currentPrice = bcadd($currentPrice, $sendCost, 2);
|
|
|
+ $post['prePrice'] = $currentPrice;
|
|
|
+ if (isset($post['modifyPrice'])) {
|
|
|
+ //商家打折,修改金额
|
|
|
+ $modifyPrice = $post['modifyPrice'] ?? 0;
|
|
|
+ if ($modifyPrice > $currentPrice) {
|
|
|
+ util::fail('实收金额大于订单总金额');
|
|
|
+ }
|
|
|
+ if ($modifyPrice < $currentPrice) {
|
|
|
+ $post['discountAmount'] = bcsub($currentPrice, $modifyPrice, 2);
|
|
|
+ $post['discountType'] = dict::getDict('discountType', 'discount');
|
|
|
+ $currentPrice = $modifyPrice;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $post['actPrice'] = $currentPrice;
|
|
|
+ $post['realPrice'] = $currentPrice;
|
|
|
+
|
|
|
foreach ($product as $key => $val) {
|
|
|
$productId = $val['productId'];
|
|
|
$bigNum = $val['bigNum'];
|
|
|
$smallNum = $val['smallNum'];
|
|
|
-
|
|
|
$orderProduct[] = [
|
|
|
'productId' => $productId,
|
|
|
'bigNum' => $bigNum,
|
|
|
@@ -179,9 +209,6 @@ class OrderController extends BaseController
|
|
|
ProductClass::decreaseStock($productId, $bigNum, $smallNum);
|
|
|
}
|
|
|
|
|
|
- $post['prePrice'] = $actPrice;
|
|
|
- $post['actPrice'] = $actPrice;
|
|
|
- $post['sendCost'] = isset($post['sendCost']) && is_numeric($post['sendCost']) ? $post['sendCost'] : 0;
|
|
|
$order = OrderClass::addOrder($post);
|
|
|
$orderId = $order['id'];
|
|
|
$orderSn = $order['orderSn'];
|
|
|
@@ -194,7 +221,7 @@ class OrderController extends BaseController
|
|
|
$payWay = $post['payWay'] ?? dict::getDict('payWay', 'wxPay');
|
|
|
OrderClass::staffKdPay($payWay, $orderSn);
|
|
|
|
|
|
- util::success(['orderSn' => $orderSn, 'totalPrice' => $actPrice, 'couponId' => $couponId, 'orderId' => $orderId]);
|
|
|
+ util::success(['orderSn' => $orderSn, 'totalPrice' => $currentPrice, 'couponId' => $couponId, 'orderId' => $orderId]);
|
|
|
}
|
|
|
|
|
|
//下单要用到的相关信息 ssh 2019.12.6
|