|
@@ -767,6 +767,7 @@ class WholeController extends Curd
|
|
|
if ($order->order_status_system != 'PAYING') {
|
|
|
return json_fail('订单不是可支付状态');
|
|
|
}
|
|
|
+
|
|
|
if (!empty($order->order_config_json)) {
|
|
|
$orderConfigJson = json_decode($order->order_config_json, true);
|
|
|
if (isset($orderConfigJson['premises'])) {
|
|
@@ -794,6 +795,9 @@ class WholeController extends Curd
|
|
|
}
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
+ // 存储优惠信息
|
|
|
+ $order->order_discount_json = json_encode($this->discountRecord($order->order_discount_json, $params));
|
|
|
+
|
|
|
// 组合支付时,付款码应收金额
|
|
|
$qrcodePayAmount = 0;
|
|
|
if ($params['pay_category'] == 'OFFLINE') {
|
|
@@ -1047,9 +1051,6 @@ class WholeController extends Curd
|
|
|
if ($order->order_status_payment == 'SUCCESS' && $params['goods_classify'] == 'VIP') {
|
|
|
$order->order_is_complete = 'Y';
|
|
|
}
|
|
|
- // 存储优惠信息
|
|
|
-
|
|
|
-
|
|
|
// 主订单
|
|
|
$order->save();
|
|
|
|
|
@@ -1197,6 +1198,11 @@ class WholeController extends Curd
|
|
|
}
|
|
|
_syslog("订单", "订单支付成功");
|
|
|
return json_success('支付成功');
|
|
|
+ }catch (BusinessException $e){
|
|
|
+ dump($e->getMessage());
|
|
|
+ Db::rollBack();
|
|
|
+ _syslog("订单", "订单支付失败:".$e->getMessage());
|
|
|
+ return json_fail("支付失败:".$e->getMessage());
|
|
|
} catch (\Exception $e) {
|
|
|
dump($e->getMessage());
|
|
|
Db::rollBack();
|
|
@@ -1211,14 +1217,44 @@ class WholeController extends Curd
|
|
|
if (!empty($orderDiscountJson)) {
|
|
|
$json = json_decode($orderDiscountJson, true);
|
|
|
}
|
|
|
- $orderDiscountAmount = 0;
|
|
|
-
|
|
|
- $data = [
|
|
|
- 'coupon_id'=>$params['coupon_id'] ?? null,
|
|
|
- 'coupon_value' =>''
|
|
|
- ];
|
|
|
+ $couponClassify = '';
|
|
|
+ $couponClassifyDesc = '';
|
|
|
+ try {
|
|
|
+ if ($params['preferential'] == 'wipe') {
|
|
|
+ if (intval($params['order_amount_total'] / 10) * 10 != $params['order_amount_pay']) {
|
|
|
+ throw new BusinessException("抹零后实际支付金额错误");
|
|
|
+ }
|
|
|
+ $params['order_discount_amount'] = $params['order_amount_total'] - $params['order_amount_pay'];
|
|
|
+ $couponClassifyDesc = $couponClassify = '抹零';
|
|
|
+ } else if ($params['preferential'] == 'custom') {
|
|
|
+ if ($params['order_amount_total'] - $params['order_discount_amount'] != $params['order_amount_pay']) {
|
|
|
+ throw new BusinessException("自定义优惠金额后实际支付金额错误");
|
|
|
+ }
|
|
|
+ $couponClassifyDesc = $couponClassify = '自定义优惠金额';
|
|
|
+ } else if (intval($params['preferential']) < 100 && intval($params['preferential']) >= 50) {
|
|
|
+ if (($params['order_amount_total'] * intval($params['preferential'])) / 100 !== $params['order_amount_pay']) {
|
|
|
+ throw new BusinessException("折扣后实际支付金额错误");
|
|
|
+ }
|
|
|
+ $couponClassify = '折扣';
|
|
|
+ $couponClassifyDesc = $params['preferential'] . '折';
|
|
|
+ $params['order_discount_amount'] = $params['order_amount_total'] - $params['order_amount_pay'];
|
|
|
+ }
|
|
|
+ $json[date('Y-m-d H:i:s')] = [
|
|
|
+ 'coupon_id' => $params['coupon_id'] ?? null,
|
|
|
+ 'coupon_value' => $params['order_discount_amount'] ?? '',
|
|
|
+ 'coupon_classify' => $couponClassify,
|
|
|
+ 'coupon_detail_id' => $couponClassifyDesc,
|
|
|
+ 'coupon_classify_en' => $params['preferential']
|
|
|
+ ];
|
|
|
+ return $json;
|
|
|
+ }catch (BusinessException $e){
|
|
|
+ throw new BusinessException($e->getMessage());
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ throw new BusinessException("优惠数据错误");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 组合支付
|
|
|
*/
|
|
@@ -1283,6 +1319,8 @@ class WholeController extends Curd
|
|
|
$payDetail = PayDetail::where('join_pay_order_id', $order->order_groupby)->first();
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
+ // 存储优惠信息
|
|
|
+ $order->order_discount_json = json_encode($this->discountRecord($order->order_discount_json, $params));
|
|
|
$orderAmountPay = $params['order_amount_pay'];
|
|
|
$constituteList = array_column($params['pay_category_constitute_list'], 'amount', 'category');// 验证金额
|
|
|
$constituteAmount = 0;
|
|
@@ -1652,6 +1690,8 @@ class WholeController extends Curd
|
|
|
$params['goods_classify'] = $goodsClassifys[0];
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
+ // 存储优惠信息
|
|
|
+ $params['order_discount_json'] = json_encode($this->discountRecord([], $params));
|
|
|
// 验证库存
|
|
|
foreach ($params['goodsContentList'] as $goods) {
|
|
|
// 减库存,规格和总库存
|
|
@@ -2214,6 +2254,8 @@ class WholeController extends Curd
|
|
|
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
+ // 存储优惠信息
|
|
|
+ $params['order_discount_json'] = json_encode($this->discountRecord([], $params));
|
|
|
$orderAmountPay = $params['order_amount_pay'];
|
|
|
$constituteList = array_column($params['pay_category_constitute_list'], 'amount', 'category');
|
|
|
// 验证金额
|
|
@@ -2713,6 +2755,7 @@ class WholeController extends Curd
|
|
|
'order_status_storage' => $params['order_status_storage'],
|
|
|
'order_platform' => $params['order_platform'],
|
|
|
'order_remark' => $params['order_remark'] ?? '',
|
|
|
+ 'order_discount_json' => $params['order_discount_json'],
|
|
|
'order_config_json' => $params['order_config_json'] ?? '[]',
|
|
|
'order_express_json' => $params['order_express_json'] ?? '[]',
|
|
|
'order_extend_json' => $params['order_extend_json'] ? json_encode($params['order_extend_json']) : '[]',
|