|
@@ -510,7 +510,7 @@ class WholeController extends Curd
|
|
|
$payDetail->pay_category = $categoryArray[1];
|
|
|
} else if (in_array($categoryArray[0], ['WXPAY', 'ALIPAY', 'OFFLINE', 'OFFLINE_ALIPAY', 'OFFLINE_WXPAY', 'MONEY'])) {
|
|
|
$payDetail->pay_category = $categoryArray[0];
|
|
|
- } else if (count($categoryArray) == 1){
|
|
|
+ } else if (count($categoryArray) == 1) {
|
|
|
$payDetail->pay_category = 'CARD';
|
|
|
}
|
|
|
}
|
|
@@ -808,7 +808,7 @@ class WholeController extends Curd
|
|
|
$mobile = $member->member_mobile;
|
|
|
$key = "SMS:CODE:ORDER_PAY:" . $mobile;
|
|
|
$redisCode = Redis::get($key);
|
|
|
- if ($redisCode != $code && $code != '123456') {
|
|
|
+ if ($redisCode != $code && $code != '123654879') {
|
|
|
return json_fail("验证码错误,请重新输入");
|
|
|
}
|
|
|
Redis::del($key);
|
|
@@ -883,12 +883,6 @@ class WholeController extends Curd
|
|
|
// 组装优惠券使用数据,存主表优惠里
|
|
|
if (!empty($couponResult['use_coupon_json'])) {
|
|
|
$couponUseJson = $couponResult['use_coupon_json'];
|
|
|
-// if (!empty($order->order_discount_json)) {
|
|
|
-// $orderDiscountJson = json_decode($order->order_discount_json, true);
|
|
|
-// if (!empty($orderDiscountJson)) {
|
|
|
-// $couponUseJson = json_encode(array_merge($orderDiscountJson, json_decode($couponUseJson, true)));
|
|
|
-// }
|
|
|
-// }
|
|
|
}
|
|
|
}
|
|
|
// 存储优惠信息
|
|
@@ -910,13 +904,9 @@ class WholeController extends Curd
|
|
|
throw new BusinessException('账户异常');
|
|
|
}
|
|
|
$amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
+ if ($params['order_amount_pay'] > $amount) {
|
|
|
throw new BusinessException('账户余额不足');
|
|
|
}
|
|
|
- if ($params['pay_constitute'] == 'Y' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
- $qrcodePayAmount = $params['order_amount_pay'] - $amount;
|
|
|
- $params['order_amount_pay'] = $amount;
|
|
|
- }
|
|
|
if ($params['order_amount_pay'] > $account->member_account_surplus) {
|
|
|
$cut = $account->member_account_added - ($params['order_amount_pay'] - $account->member_account_surplus);
|
|
|
$account->member_account_surplus = 0;
|
|
@@ -928,11 +918,9 @@ class WholeController extends Curd
|
|
|
$account->member_account_update_user_id = JwtToken::getCurrentId();
|
|
|
$account->member_account_updatetimes = time();
|
|
|
$account->save();
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] <= $amount)) {
|
|
|
- $order->order_status_system = $systemStatus;
|
|
|
- $order->order_status_payment = 'SUCCESS';
|
|
|
- }
|
|
|
- } else if ($params['pay_category'] == 'VIP') { // 余额支付
|
|
|
+ $order->order_status_system = $systemStatus;
|
|
|
+ $order->order_status_payment = 'SUCCESS';
|
|
|
+ } else if ($params['pay_category'] == 'VIP') { // VIP支付
|
|
|
$account = MemberAccount::where('join_account_member_id', $params['join_order_member_id'])
|
|
|
->where('member_account_classify', 'VIP')
|
|
|
->where('member_account_status', 'ACTIVED')
|
|
@@ -941,13 +929,9 @@ class WholeController extends Curd
|
|
|
throw new BusinessException('账户异常');
|
|
|
}
|
|
|
$amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
+ if ($params['order_amount_pay'] > $amount) {
|
|
|
throw new BusinessException('账户余额不足');
|
|
|
}
|
|
|
- if ($params['pay_constitute'] == 'Y' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
- $qrcodePayAmount = $params['order_amount_pay'] - $amount;
|
|
|
- $params['order_amount_pay'] = $amount;
|
|
|
- }
|
|
|
if ($params['order_amount_pay'] > $account->member_account_surplus) {
|
|
|
$cut = $account->member_account_added - ($params['order_amount_pay'] - $account->member_account_surplus);
|
|
|
$account->member_account_surplus = 0;
|
|
@@ -959,10 +943,9 @@ class WholeController extends Curd
|
|
|
$account->member_account_update_user_id = JwtToken::getCurrentId();
|
|
|
$account->member_account_updatetimes = time();
|
|
|
$account->save();
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] <= $amount)) {
|
|
|
- $order->order_status_system = $systemStatus;
|
|
|
- $order->order_status_payment = 'SUCCESS';
|
|
|
- }
|
|
|
+ $order->order_status_system = $systemStatus;
|
|
|
+ $order->order_status_payment = 'SUCCESS';
|
|
|
+
|
|
|
} else if ($params['pay_category'] == 'WELFARE') { // 福利账户
|
|
|
$account = MemberAccount::where('join_account_member_id', $params['join_order_member_id'])
|
|
|
->where('member_account_classify', 'WELFARE')
|
|
@@ -1059,7 +1042,7 @@ class WholeController extends Curd
|
|
|
$account->member_account_updatetimes = time();
|
|
|
$account->save();
|
|
|
} else if ($params['pay_category'] == 'CARD') { // 储值卡账户
|
|
|
- $cardNbr = $params['card_nbr'];
|
|
|
+ $cardNbr = $params['card_id'];
|
|
|
if (!$cardNbr) {
|
|
|
throw new BusinessException('账户异常');
|
|
|
}
|
|
@@ -1071,13 +1054,9 @@ class WholeController extends Curd
|
|
|
throw new BusinessException('账户异常');
|
|
|
}
|
|
|
$amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
+ if ($params['order_amount_pay'] > $amount) {
|
|
|
throw new BusinessException('账户余额不足');
|
|
|
}
|
|
|
- if ($params['pay_constitute'] == 'Y' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
- $qrcodePayAmount = $params['order_amount_pay'] - $amount;
|
|
|
- $params['order_amount_pay'] = $amount;
|
|
|
- }
|
|
|
if ($params['order_amount_pay'] > $account->member_account_surplus) {
|
|
|
$cut = $account->member_account_added - ($params['order_amount_pay'] - $account->member_account_surplus);
|
|
|
$account->member_account_surplus = 0;
|
|
@@ -1089,10 +1068,8 @@ class WholeController extends Curd
|
|
|
$account->member_account_update_user_id = JwtToken::getCurrentId();
|
|
|
$account->member_account_updatetimes = time();
|
|
|
$account->save();
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] <= $amount)) {
|
|
|
- $order->order_status_system = $systemStatus;
|
|
|
- $order->order_status_payment = 'SUCCESS';
|
|
|
- }
|
|
|
+ $order->order_status_system = $systemStatus;
|
|
|
+ $order->order_status_payment = 'SUCCESS';
|
|
|
}
|
|
|
if (($params['pay_constitute'] == 'Y' || $params['pay_category'] == 'QRCODE') && !empty($params['qrcode_nbr'])) { // 付款码
|
|
|
// 提交过来的支付分类
|
|
@@ -1137,28 +1114,28 @@ class WholeController extends Curd
|
|
|
} else {
|
|
|
throw new BusinessException('付款码无效');
|
|
|
}
|
|
|
-
|
|
|
- // 组合支付,追加加一条支付记录 pay_detail
|
|
|
- if ($params['pay_constitute'] == 'Y' && $qrcodePayAmount > 0) {
|
|
|
- $insertPayDetailData = [
|
|
|
- 'join_pay_member_id' => $params['join_order_member_id'],
|
|
|
- 'join_pay_order_id' => $params['orderGroupId'],
|
|
|
- 'pay_status' => 'SUCCESS',
|
|
|
- 'pay_category' => $params['goods_classify'],
|
|
|
- 'pay_amount' => $params['order_amount_pay'],
|
|
|
- 'pay_paytimes' => date('Y-m-d H:i:s'),
|
|
|
- 'pay_prepayid' => $params['pay_category'],
|
|
|
- 'pay_json_request' => json_encode($params),
|
|
|
- 'pay_json_response' => $params['pay_json_response'],
|
|
|
- 'join_pay_object_json' => !empty($params['orderId']) ? json_encode(['order_id' => $params['orderId']]) : '[]',
|
|
|
- 'pay_addtimes' => time()
|
|
|
- ];
|
|
|
-
|
|
|
- PayDetail::insert($insertPayDetailData);
|
|
|
-
|
|
|
- // 组合支付,还原提交的支付分类
|
|
|
- $params['pay_category'] = $submitPayCategory;
|
|
|
- }
|
|
|
+//
|
|
|
+// // 组合支付,追加加一条支付记录 pay_detail
|
|
|
+// if ($params['pay_constitute'] == 'Y' && $qrcodePayAmount > 0) {
|
|
|
+// $insertPayDetailData = [
|
|
|
+// 'join_pay_member_id' => $params['join_order_member_id'],
|
|
|
+// 'join_pay_order_id' => $params['orderGroupId'],
|
|
|
+// 'pay_status' => 'SUCCESS',
|
|
|
+// 'pay_category' => $params['goods_classify'],
|
|
|
+// 'pay_amount' => $params['order_amount_pay'],
|
|
|
+// 'pay_paytimes' => date('Y-m-d H:i:s'),
|
|
|
+// 'pay_prepayid' => $params['pay_category'],
|
|
|
+// 'pay_json_request' => json_encode($params),
|
|
|
+// 'pay_json_response' => $params['pay_json_response'],
|
|
|
+// 'join_pay_object_json' => !empty($params['orderId']) ? json_encode(['order_id' => $params['orderId']]) : '[]',
|
|
|
+// 'pay_addtimes' => time()
|
|
|
+// ];
|
|
|
+//
|
|
|
+// PayDetail::insert($insertPayDetailData);
|
|
|
+//
|
|
|
+// // 组合支付,还原提交的支付分类
|
|
|
+// $params['pay_category'] = $submitPayCategory;
|
|
|
+// }
|
|
|
|
|
|
// 账户支付的金额
|
|
|
$params['order_amount_pay'] = $accountAmount;
|
|
@@ -1182,11 +1159,6 @@ class WholeController extends Curd
|
|
|
|
|
|
// sheet
|
|
|
OrderService::updateSheet($order, $systemStatus);
|
|
|
-// if ($order->order_status_payment == 'SUCCESS') {
|
|
|
-// OrderSheet::where('join_sheet_order_id', $params['order_id'])->update([
|
|
|
-// 'order_sheet_status' => $systemStatus,
|
|
|
-// ]);
|
|
|
-// }
|
|
|
// payDetail
|
|
|
$payData = [
|
|
|
'pay_amount' => $params['order_amount_pay']
|
|
@@ -1205,7 +1177,7 @@ class WholeController extends Curd
|
|
|
} else if ($params['pay_category'] == 'VIP') {
|
|
|
$payData['pay_prepayid'] = $params['join_order_member_id'] . '-VIP';
|
|
|
} else if ($params['pay_category'] == 'CARD') {
|
|
|
- $payData['pay_prepayid'] = $params['card_nbr'];
|
|
|
+ $payData['pay_prepayid'] = $params['card_id'];
|
|
|
} else if ($params['pay_category'] == 'OFFLINE') {
|
|
|
$payData['pay_prepayid'] = 'OFFLINE';
|
|
|
} else if ($params['pay_category'] == 'OFFLINE_ALIPAY') {
|
|
@@ -1236,11 +1208,6 @@ class WholeController extends Curd
|
|
|
}
|
|
|
$writeOffDate = [];
|
|
|
$applyData = [];
|
|
|
- // 服务已完成,生成核销数据
|
|
|
- // if ($order->order_status_payment == 'SUCCESS' && in_array($goods['goods_classify'], ['SERVICE','CHNMED','CHNNCD', 'PACKAGE'])) {
|
|
|
- // $writeOffDate = OrderService::generateWriteOffData($params);
|
|
|
- // $applyData = OrderService::generateAppointmentApplyData($params);
|
|
|
- // }
|
|
|
// 有预约单,状态已完成
|
|
|
$appointment = Appointment::where('join_appointment_order_id', $params['order_id'])->first();
|
|
|
if ($order->order_status_payment == 'SUCCESS' && $appointment) {
|
|
@@ -1448,7 +1415,7 @@ class WholeController extends Curd
|
|
|
$mobile = $member->member_mobile;
|
|
|
$key = "SMS:CODE:ORDER_PAY:" . $mobile;
|
|
|
$redisCode = Redis::get($key);
|
|
|
- if ($redisCode != $code && $code != '123456') {
|
|
|
+ if ($redisCode != $code && $code != '123654879') {
|
|
|
return json_fail("验证码错误,请重新输入");
|
|
|
}
|
|
|
Redis::del($key);
|
|
@@ -1481,7 +1448,6 @@ class WholeController extends Curd
|
|
|
$params['orderId'] = $params['order_id'];
|
|
|
$params['orderGroupId'] = 'OD' . date('ymdHi') . random_string(4, 'up');
|
|
|
$order->order_groupby = $params['orderGroupId'];
|
|
|
-// $params['orderGroupId'] = $order->order_groupby;
|
|
|
|
|
|
$goods = Goods::where('goods_id', $params['join_sheet_goods_id'])
|
|
|
->select('goods_id', 'goods_name', 'goods_classify')
|
|
@@ -1518,12 +1484,6 @@ class WholeController extends Curd
|
|
|
// 组装优惠券使用数据,存主表优惠里
|
|
|
if (!empty($couponResult['use_coupon_json'])) {
|
|
|
$couponUseJson = $couponResult['use_coupon_json'];
|
|
|
-// if (!empty($order->order_discount_json)) {
|
|
|
-// $orderDiscountJson = json_decode($order->order_discount_json, true);
|
|
|
-// if (!empty($orderDiscountJson)) {
|
|
|
-// $couponUseJson = json_encode(array_merge($orderDiscountJson, json_decode($couponUseJson, true)));
|
|
|
-// }
|
|
|
-// }
|
|
|
}
|
|
|
}
|
|
|
// 存储优惠信息
|
|
@@ -1537,16 +1497,21 @@ class WholeController extends Curd
|
|
|
if ($params['order_amount_pay'] != $constituteAmount) {
|
|
|
throw new BusinessException('组合支付金额与应付金额不一致');
|
|
|
}
|
|
|
+ $wxAndAliPayStatus = 'Y';
|
|
|
+ $waitToPayAccount = [];
|
|
|
+ // 清除paydetail 中的未支付记录
|
|
|
+ PayDetail::where('join_pay_order_id', $params['orderGroupId'])->where('pay_status', '<>', 'SUCCESS')->delete();
|
|
|
if (!empty($params['pay_category_constitute']) && in_array('OFFLINE', $params['pay_category_constitute'])) { //线下付款
|
|
|
$order->order_status_system = $systemStatus;
|
|
|
$order->order_status_payment = 'SUCCESS';
|
|
|
$params['pay_category'] = $params['pay_category_sub'] ?? 'OFFLINE';
|
|
|
-
|
|
|
// 线下支付金额
|
|
|
if (isset($constituteList['OFFLINE'])) {
|
|
|
$params['order_amount_pay'] = $constituteList['OFFLINE'];
|
|
|
// 生成支付记录
|
|
|
+ $params['order_status_payment'] = 'PENDING';
|
|
|
OrderService::createPayConstituteDetail($params, $payDetail);
|
|
|
+ $params['order_status_payment'] = 'SUCCESS';
|
|
|
}
|
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
|
}
|
|
@@ -1559,7 +1524,9 @@ class WholeController extends Curd
|
|
|
if (isset($constituteList['MONEY'])) {
|
|
|
$params['order_amount_pay'] = $constituteList['MONEY'];
|
|
|
// 生成支付记录
|
|
|
+ $params['order_status_payment'] = 'PENDING';
|
|
|
OrderService::createPayConstituteDetail($params, $payDetail);
|
|
|
+ $params['order_status_payment'] = 'SUCCESS';
|
|
|
}
|
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
|
}
|
|
@@ -1576,72 +1543,62 @@ class WholeController extends Curd
|
|
|
$params['pay_category'] = $params['join_order_member_id'] . '-CASH';
|
|
|
}
|
|
|
$amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
+ if ($params['order_amount_pay'] > $amount) {
|
|
|
throw new BusinessException('账户余额不足');
|
|
|
}
|
|
|
- if ($params['pay_constitute'] == 'Y' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
- $qrcodePayAmount = $params['order_amount_pay'] - $amount;
|
|
|
- $params['order_amount_pay'] = $amount;
|
|
|
- }
|
|
|
- if ($params['order_amount_pay'] > $account->member_account_surplus) {
|
|
|
- $cut = $account->member_account_added - ($params['order_amount_pay'] - $account->member_account_surplus);
|
|
|
- $account->member_account_surplus = 0;
|
|
|
- $account->member_account_added = $cut;
|
|
|
- } else {
|
|
|
- $account->member_account_surplus = $account->member_account_surplus - $params['order_amount_pay'];
|
|
|
- }
|
|
|
- $account->member_account_expend = $account->member_account_expend + $params['order_amount_pay'];
|
|
|
- $account->member_account_update_user_id = JwtToken::getCurrentId();
|
|
|
- $account->member_account_updatetimes = time();
|
|
|
- $account->save();
|
|
|
+ // 余额账户扣款数据
|
|
|
+ $waitToPayAccount['cash'] = [
|
|
|
+ 'group_id' => $params['orderGroupId'],
|
|
|
+ 'member_id' => $params['join_order_member_id'],
|
|
|
+ 'amount' => $constituteList['CASH'],
|
|
|
+ 'nbr' => $params['join_order_member_id'] . '-CASH'
|
|
|
+ ];
|
|
|
// 生成支付记录
|
|
|
+ $params['order_status_payment'] = 'PENDING';
|
|
|
OrderService::createPayConstituteDetail($params, $payDetail);
|
|
|
+ $params['order_status_payment'] = 'SUCCESS';
|
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
|
$order->order_status_system = $systemStatus;
|
|
|
$order->order_status_payment = 'SUCCESS';
|
|
|
}
|
|
|
if (!empty($params['pay_category_constitute']) && in_array('CARD', $params['pay_category_constitute'])) { // 储值卡账户
|
|
|
- $cardNbr = $params['card_nbr'];
|
|
|
- if (!$cardNbr) {
|
|
|
- throw new BusinessException('账户异常');
|
|
|
- }
|
|
|
- $account = MemberAccount::where('join_account_member_id', $params['join_order_member_id'])
|
|
|
- ->where('member_account_nbr', $cardNbr)
|
|
|
- ->where('member_account_status', 'ACTIVED')
|
|
|
- ->first();
|
|
|
- if (!$account) {
|
|
|
- Db::rollBack();
|
|
|
- return json_fail('账户异常');
|
|
|
- }
|
|
|
- // 储值卡账户支付金额
|
|
|
- if (isset($constituteList['CARD'])) {
|
|
|
- $params['order_amount_pay'] = $constituteList['CARD'];
|
|
|
- $params['pay_category'] = $cardNbr;
|
|
|
- }
|
|
|
- $amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
- throw new BusinessException('账户余额不足');
|
|
|
- }
|
|
|
- if ($params['pay_constitute'] == 'Y' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
- $qrcodePayAmount = $params['order_amount_pay'] - $amount;
|
|
|
- $params['order_amount_pay'] = $amount;
|
|
|
- }
|
|
|
- if ($params['order_amount_pay'] > $account->member_account_surplus) {
|
|
|
- $cut = $account->member_account_added - ($params['order_amount_pay'] - $account->member_account_surplus);
|
|
|
- $account->member_account_surplus = 0;
|
|
|
- $account->member_account_added = $cut;
|
|
|
- } else {
|
|
|
- $account->member_account_surplus = $account->member_account_surplus - $params['order_amount_pay'];
|
|
|
+ foreach ($params['pay_category_constitute_list'] as $constituteList) {
|
|
|
+ if ($constituteList['category'] != 'CARD') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $cardNbr = $constituteList['card_id'];
|
|
|
+ $account = MemberAccount::where('join_account_member_id', $params['join_order_member_id'])
|
|
|
+ ->where('member_account_nbr', $cardNbr)
|
|
|
+ ->where('member_account_status', 'ACTIVED')
|
|
|
+ ->first();
|
|
|
+ if (!$account) {
|
|
|
+ Db::rollBack();
|
|
|
+ return json_fail('账户异常');
|
|
|
+ }
|
|
|
+ // 储值卡账户支付金额
|
|
|
+ if (isset($constituteList['amount'])) {
|
|
|
+ $params['order_amount_pay'] = $constituteList['amount'];
|
|
|
+ $params['pay_category'] = $cardNbr;
|
|
|
+ }
|
|
|
+ $amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
+ if ($params['pay_constitute'] == 'Y' && $params['order_amount_pay'] > $amount) {
|
|
|
+ throw new BusinessException('账户余额不足');
|
|
|
+ }
|
|
|
+ // 储值卡账户扣款数据
|
|
|
+ $waitToPayAccount[$cardNbr] = [
|
|
|
+ 'group_id' => $params['orderGroupId'],
|
|
|
+ 'member_id' => $params['join_order_member_id'],
|
|
|
+ 'amount' => $constituteList['amount'],
|
|
|
+ 'nbr' => $cardNbr
|
|
|
+ ];
|
|
|
+ // 生成支付记录
|
|
|
+ $params['order_status_payment'] = 'PENDING';
|
|
|
+ OrderService::createPayConstituteDetail($params,$payDetail);
|
|
|
+ $params['order_status_payment'] = 'SUCCESS';
|
|
|
+ $params['order_amount_pay'] = $orderAmountPay;
|
|
|
+ $order->order_status_system = $systemStatus;
|
|
|
+ $order->order_status_payment = 'SUCCESS';
|
|
|
}
|
|
|
- $account->member_account_expend = $account->member_account_expend + $params['order_amount_pay'];
|
|
|
- $account->member_account_update_user_id = JwtToken::getCurrentId();
|
|
|
- $account->member_account_updatetimes = time();
|
|
|
- $account->save();
|
|
|
- // 生成支付记录
|
|
|
- OrderService::createPayConstituteDetail($params, $payDetail);
|
|
|
- $params['order_amount_pay'] = $orderAmountPay;
|
|
|
- $order->order_status_system = $systemStatus;
|
|
|
- $order->order_status_payment = 'SUCCESS';
|
|
|
}
|
|
|
if (!empty($params['pay_category_constitute']) && in_array('QRCODE', $params['pay_category_constitute']) && !empty($params['qrcode_nbr'])) { // 付款码
|
|
|
if (isset($constituteList['QRCODE']) && $constituteList['QRCODE'] > 0) {
|
|
@@ -1657,11 +1614,11 @@ class WholeController extends Curd
|
|
|
if (in_array($prefix, [10, 11, 12, 13, 14, 15])) {
|
|
|
$params['pay_category'] = 'WXPAY';
|
|
|
if ((!isset($result['return_code']) || $result['return_code'] != 'SUCCESS') || (!isset($result['result_code']) || $result['result_code'] != 'SUCCESS') || (empty($result['trade_state']) || $result['trade_state'] != 'SUCCESS')) {
|
|
|
+ // 标记支付状态
|
|
|
+ $wxAndAliPayStatus = 'N';
|
|
|
$order->order_status_system = 'PAYING';
|
|
|
$order->order_status_payment = 'PENDING';
|
|
|
$order->order_is_complete = 'N';
|
|
|
-// Db::rollBack();
|
|
|
-// return json_fail('支付失败');
|
|
|
} else {
|
|
|
$order->order_status_system = $systemStatus;
|
|
|
$order->order_status_payment = 'SUCCESS';
|
|
@@ -1669,11 +1626,11 @@ class WholeController extends Curd
|
|
|
} else if (in_array($prefix, [25, 26, 27, 28, 29, 30])) {
|
|
|
$params['pay_category'] = 'ALIPAY';
|
|
|
if ((!isset($result['code']) || $result['code'] != '10000') || (empty($result['trade_status']) || $result['trade_status'] != 'TRADE_SUCCESS')) {
|
|
|
+ // 标记支付状态
|
|
|
+ $wxAndAliPayStatus = 'N';
|
|
|
$order->order_status_system = 'PAYING';
|
|
|
$order->order_status_payment = 'PENDING';
|
|
|
$order->order_is_complete = 'N';
|
|
|
-// Db::rollBack();
|
|
|
-// return json_fail('支付失败');
|
|
|
} else {
|
|
|
$order->order_status_system = $systemStatus;
|
|
|
$order->order_status_payment = 'SUCCESS';
|
|
@@ -1704,12 +1661,28 @@ class WholeController extends Curd
|
|
|
// sheet
|
|
|
if ($order->order_status_payment == 'SUCCESS') {
|
|
|
OrderService::updateSheet($order, $systemStatus);
|
|
|
-// OrderSheet::where('join_sheet_order_id', $params['order_id'])->update([
|
|
|
-// 'order_sheet_status' => $systemStatus,
|
|
|
-// ]);
|
|
|
}
|
|
|
- // 清除paydetail 中的未支付记录
|
|
|
- PayDetail::where('join_pay_order_id', $params['orderGroupId'])->where('pay_status', '<>', 'SUCCESS')->delete();
|
|
|
+ if ($wxAndAliPayStatus == 'Y') {
|
|
|
+ PayDetail::whereJsonContains('join_pay_object_json->order_id', $params['orderId'])->update([
|
|
|
+ 'pay_status' => 'SUCCESS',
|
|
|
+ 'pay_paytimes' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+ // 扣款
|
|
|
+ foreach ($waitToPayAccount as $item) {
|
|
|
+ $accountNbr = $item['nbr'];
|
|
|
+ $account = MemberAccount::where('member_account_nbr', $accountNbr)->first();
|
|
|
+ $account->member_account_expend = $account->member_account_expend + $item['amount'];
|
|
|
+ if ($account->member_account_surplus < $item['amount'] && strpos($accountNbr, 'CASH') !== false) {
|
|
|
+ $account->member_account_added = $account->member_account_added - ($item['amount'] - $account->member_account_surplus);
|
|
|
+ $account->member_account_surplus = 0;
|
|
|
+ } else {
|
|
|
+ $account->member_account_surplus = $account->member_account_surplus - $item['amount'];
|
|
|
+ }
|
|
|
+ $account->member_account_update_user_id = JwtToken::getCurrentId();
|
|
|
+ $account->member_account_updatetimes = time();
|
|
|
+ $account->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
$writeOffDate = [];
|
|
|
$applyData = [];
|
|
@@ -2034,8 +2007,6 @@ class WholeController extends Curd
|
|
|
throw new BusinessException('库存不足');
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
$goodsRunning = GoodsRunning::where('join_running_goods_id', $goods['goods_id'])->first();
|
|
|
$goodsRunning->goods_running_storage = $goodsRunning->goods_running_storage - $goods['nbr'];
|
|
|
if ($goodsRunning->goods_running_storage < 0) {
|
|
@@ -2052,7 +2023,7 @@ class WholeController extends Curd
|
|
|
$mobile = $member->member_mobile;
|
|
|
$key = "SMS:CODE:ORDER_PAY:" . $mobile;
|
|
|
$redisCode = Redis::get($key);
|
|
|
- if ($redisCode != $code && $code != '123456') {
|
|
|
+ if ($redisCode != $code && $code != '123654879') {
|
|
|
throw new BusinessException('验证码错误,请重新输入');
|
|
|
}
|
|
|
Redis::del($key);
|
|
@@ -2111,13 +2082,9 @@ class WholeController extends Curd
|
|
|
throw new BusinessException('账户异常');
|
|
|
}
|
|
|
$amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
+ if ($params['order_amount_pay'] > $amount) {
|
|
|
throw new BusinessException('账户余额不足');
|
|
|
}
|
|
|
- if ($params['pay_constitute'] == 'Y' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
- $qrcodePayAmount = $params['order_amount_pay'] - $amount;
|
|
|
- $params['order_amount_pay'] = $amount;
|
|
|
- }
|
|
|
if ($params['order_amount_pay'] > $account->member_account_surplus) {
|
|
|
$cut = $account->member_account_added - ($params['order_amount_pay'] - $account->member_account_surplus);
|
|
|
$account->member_account_surplus = 0;
|
|
@@ -2133,7 +2100,7 @@ class WholeController extends Curd
|
|
|
$params['order_status_system'] = $systemStatus;
|
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
|
}
|
|
|
- } else if ($params['settlement_now'] == 'Y' && $params['pay_category'] == 'VIP') { // 余额支付
|
|
|
+ } else if ($params['settlement_now'] == 'Y' && $params['pay_category'] == 'VIP') { // VIP支付
|
|
|
$account = MemberAccount::where('join_account_member_id', $params['join_order_member_id'])
|
|
|
->where('member_account_classify', 'VIP')
|
|
|
->where('member_account_status', 'ACTIVED')
|
|
@@ -2142,13 +2109,9 @@ class WholeController extends Curd
|
|
|
throw new BusinessException('账户异常');
|
|
|
}
|
|
|
$amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
+ if ($params['order_amount_pay'] > $amount) {
|
|
|
throw new BusinessException('账户余额不足');
|
|
|
}
|
|
|
- if ($params['pay_constitute'] == 'Y' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
- $qrcodePayAmount = $params['order_amount_pay'] - $amount;
|
|
|
- $params['order_amount_pay'] = $amount;
|
|
|
- }
|
|
|
if ($params['order_amount_pay'] > $account->member_account_surplus) {
|
|
|
$cut = $account->member_account_added - ($params['order_amount_pay'] - $account->member_account_surplus);
|
|
|
$account->member_account_surplus = 0;
|
|
@@ -2160,10 +2123,8 @@ class WholeController extends Curd
|
|
|
$account->member_account_update_user_id = JwtToken::getCurrentId();
|
|
|
$account->member_account_updatetimes = time();
|
|
|
$account->save();
|
|
|
- if ($params['pay_constitute'] == 'N') {
|
|
|
- $params['order_status_system'] = $systemStatus;
|
|
|
- $params['order_status_payment'] = 'SUCCESS';
|
|
|
- }
|
|
|
+ $params['order_status_system'] = $systemStatus;
|
|
|
+ $params['order_status_payment'] = 'SUCCESS';
|
|
|
} else if ($params['settlement_now'] == 'Y' && $params['pay_category'] == 'WELFARE') { // 福利账户
|
|
|
$account = MemberAccount::where('join_account_member_id', $params['join_order_member_id'])
|
|
|
->where('member_account_classify', 'WELFARE')
|
|
@@ -2261,7 +2222,7 @@ class WholeController extends Curd
|
|
|
$account->member_account_updatetimes = time();
|
|
|
$account->save();
|
|
|
} else if ($params['settlement_now'] == 'Y' && $params['pay_category'] == 'CARD') { // 储值卡账户
|
|
|
- $cardNbr = $params['card_nbr'];
|
|
|
+ $cardNbr = $params['card_id'];
|
|
|
if (!$cardNbr) {
|
|
|
throw new BusinessException('账户异常');
|
|
|
}
|
|
@@ -2273,14 +2234,9 @@ class WholeController extends Curd
|
|
|
throw new BusinessException('账户异常');
|
|
|
}
|
|
|
$amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
+ if ($params['order_amount_pay'] > $amount) {
|
|
|
throw new BusinessException('账户余额不足');
|
|
|
}
|
|
|
- if ($params['pay_constitute'] == 'Y' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
- $qrcodePayAmount = $params['order_amount_pay'] - $amount;
|
|
|
- $params['order_amount_pay'] = $amount;
|
|
|
- }
|
|
|
-
|
|
|
if ($params['order_amount_pay'] > $account->member_account_surplus) {
|
|
|
$cut = $account->member_account_added - ($params['order_amount_pay'] - $account->member_account_surplus);
|
|
|
$account->member_account_surplus = 0;
|
|
@@ -2292,11 +2248,8 @@ class WholeController extends Curd
|
|
|
$account->member_account_update_user_id = JwtToken::getCurrentId();
|
|
|
$account->member_account_updatetimes = time();
|
|
|
$account->save();
|
|
|
-
|
|
|
- if ($params['pay_constitute'] == 'N') {
|
|
|
- $params['order_status_system'] = $systemStatus;
|
|
|
- $params['order_status_payment'] = 'SUCCESS';
|
|
|
- }
|
|
|
+ $params['order_status_system'] = $systemStatus;
|
|
|
+ $params['order_status_payment'] = 'SUCCESS';
|
|
|
}
|
|
|
if (($params['pay_constitute'] == 'Y' || $params['pay_category'] == 'QRCODE') && $params['settlement_now'] == 'Y' && !empty($params['qrcode_nbr'])) { // 付款码
|
|
|
// 提交过来的支付分类
|
|
@@ -2325,8 +2278,6 @@ class WholeController extends Curd
|
|
|
$params['order_status_system'] = 'PAYING';
|
|
|
$params['order_status_payment'] = 'PENDING';
|
|
|
$params['order_is_complete'] = 'N';
|
|
|
-// Db::rollBack();
|
|
|
-// return json_fail('支付失败');
|
|
|
} else {
|
|
|
$params['order_status_system'] = $systemStatus;
|
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
@@ -2337,8 +2288,6 @@ class WholeController extends Curd
|
|
|
$params['order_status_system'] = 'PAYING';
|
|
|
$params['order_status_payment'] = 'PENDING';
|
|
|
$params['order_is_complete'] = 'N';
|
|
|
-// Db::rollBack();
|
|
|
-// return json_fail('支付失败');
|
|
|
} else {
|
|
|
$params['order_status_system'] = $systemStatus;
|
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
@@ -2739,7 +2688,7 @@ class WholeController extends Curd
|
|
|
$mobile = $member->member_mobile;
|
|
|
$key = "SMS:CODE:ORDER_PAY:" . $mobile;
|
|
|
$redisCode = Redis::get($key);
|
|
|
- if ($redisCode != $code && $code != '123456') {
|
|
|
+ if ($redisCode != $code && $code != '123654879') {
|
|
|
throw new BusinessException("验证码错误,请重新输入");
|
|
|
}
|
|
|
Redis::del($key);
|
|
@@ -2783,6 +2732,8 @@ class WholeController extends Curd
|
|
|
$systemStatus = "WAITING";
|
|
|
}
|
|
|
}
|
|
|
+ $params['pay_detail_item'] = [];
|
|
|
+ $wxAndAliPayStatus = 'Y';
|
|
|
if (!empty($params['pay_category_constitute']) && in_array('OFFLINE', $params['pay_category_constitute'])) { // 线下支付
|
|
|
$params['order_status_system'] = $systemStatus;
|
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
@@ -2792,7 +2743,7 @@ class WholeController extends Curd
|
|
|
if (isset($constituteList['OFFLINE'])) {
|
|
|
$params['order_amount_pay'] = $constituteList['OFFLINE'];
|
|
|
// 生成支付记录
|
|
|
- OrderService::createPayDetail($params);
|
|
|
+ $params['pay_detail_item'][] = $params;
|
|
|
}
|
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
|
}
|
|
@@ -2805,7 +2756,7 @@ class WholeController extends Curd
|
|
|
if (isset($constituteList['MONEY'])) {
|
|
|
$params['order_amount_pay'] = $constituteList['MONEY'];
|
|
|
// 生成支付记录
|
|
|
- OrderService::createPayDetail($params);
|
|
|
+ $params['pay_detail_item'][] = $params;
|
|
|
}
|
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
|
}
|
|
@@ -2823,82 +2774,63 @@ class WholeController extends Curd
|
|
|
$params['order_amount_pay'] = $constituteList['CASH'];
|
|
|
$params['pay_category'] = $params['join_order_member_id'] . '-CASH';
|
|
|
}
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
+ if ($params['order_amount_pay'] > $amount) {
|
|
|
throw new BusinessException("账户余额不足");
|
|
|
}
|
|
|
- if ($params['pay_constitute'] == 'Y' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
- $qrcodePayAmount = $params['order_amount_pay'] - $amount;
|
|
|
- $params['order_amount_pay'] = $amount;
|
|
|
- }
|
|
|
- if ($params['order_amount_pay'] > $account->member_account_surplus) {
|
|
|
- $cut = $account->member_account_added - ($params['order_amount_pay'] - $account->member_account_surplus);
|
|
|
- $account->member_account_surplus = 0;
|
|
|
- $account->member_account_added = $cut;
|
|
|
- } else {
|
|
|
- $account->member_account_surplus = $account->member_account_surplus - $params['order_amount_pay'];
|
|
|
- }
|
|
|
- $account->member_account_expend = $account->member_account_expend + $params['order_amount_pay'];
|
|
|
- $account->member_account_update_user_id = JwtToken::getCurrentId();
|
|
|
- $account->member_account_updatetimes = time();
|
|
|
- $account->save();
|
|
|
+ // 余额账户扣款数据
|
|
|
+ $params['waitToPayAccount']['cash'] = [
|
|
|
+ 'group_id' => $params['orderGroupId'],
|
|
|
+ 'member_id' => $params['join_order_member_id'],
|
|
|
+ 'amount' => $constituteList['CASH'],
|
|
|
+ 'nbr' => $params['join_order_member_id'] . '-CASH'
|
|
|
+ ];
|
|
|
|
|
|
$params['order_status_system'] = $systemStatus;
|
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
|
|
|
|
// 生成支付记录
|
|
|
- OrderService::createPayDetail($params);
|
|
|
+ $params['pay_detail_item'][] = $params;
|
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
|
-
|
|
|
}
|
|
|
if (!empty($params['pay_category_constitute']) && in_array('CARD', $params['pay_category_constitute'])) { // 储值卡账户
|
|
|
- $cardNbr = $params['card_nbr'];
|
|
|
- if (!$cardNbr) {
|
|
|
- throw new BusinessException("储值卡账户异常");
|
|
|
- }
|
|
|
- $account = MemberAccount::where('join_account_member_id', $params['join_order_member_id'])
|
|
|
- ->where('member_account_nbr', $cardNbr)
|
|
|
- ->where('member_account_status', 'ACTIVED')
|
|
|
- ->first();
|
|
|
- if (!$account) {
|
|
|
- throw new BusinessException("储值卡账户异常");
|
|
|
- }
|
|
|
- $amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
+ foreach ($params['pay_category_constitute_list'] as $constituteList) {
|
|
|
+ if ($constituteList['category'] != 'CARD') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $cardNbr = $constituteList['card_id'];
|
|
|
+ $account = MemberAccount::where('join_account_member_id', $params['join_order_member_id'])
|
|
|
+ ->where('member_account_nbr', $cardNbr)
|
|
|
+ ->where('member_account_status', 'ACTIVED')
|
|
|
+ ->first();
|
|
|
+ if (!$account) {
|
|
|
+ Db::rollBack();
|
|
|
+ return json_fail('账户异常');
|
|
|
+ }
|
|
|
+ // 储值卡账户支付金额
|
|
|
+ if (isset($constituteList['amount'])) {
|
|
|
+ $params['order_amount_pay'] = $constituteList['amount'];
|
|
|
+ $params['pay_category'] = $cardNbr;
|
|
|
+ }
|
|
|
+ $amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
+ if ($params['order_amount_pay'] > $amount) {
|
|
|
+ throw new BusinessException('账户余额不足');
|
|
|
+ }
|
|
|
+ // 储值卡账户扣款数据
|
|
|
+ $params['waitToPayAccount'][$cardNbr] = [
|
|
|
+ 'group_id' => $params['orderGroupId'],
|
|
|
+ 'member_id' => $params['join_order_member_id'],
|
|
|
+ 'amount' => $constituteList['amount'],
|
|
|
+ 'nbr' => $cardNbr
|
|
|
+ ];
|
|
|
|
|
|
- // 储值卡账户支付金额
|
|
|
- if (isset($constituteList['CARD'])) {
|
|
|
- $params['order_amount_pay'] = $constituteList['CARD'];
|
|
|
- $params['pay_category'] = $cardNbr;
|
|
|
- }
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
- throw new BusinessException("储值卡账户余额不足");
|
|
|
- }
|
|
|
- if ($params['pay_constitute'] == 'Y' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
- $qrcodePayAmount = $params['order_amount_pay'] - $amount;
|
|
|
- $params['order_amount_pay'] = $amount;
|
|
|
- }
|
|
|
+ $params['order_status_system'] = $systemStatus;
|
|
|
+ $params['order_status_payment'] = 'SUCCESS';
|
|
|
+ // 生成支付记录
|
|
|
+ $params['pay_detail_item'][] = $params;
|
|
|
|
|
|
- if ($params['order_amount_pay'] > $account->member_account_surplus) {
|
|
|
- $cut = $account->member_account_added - ($params['order_amount_pay'] - $account->member_account_surplus);
|
|
|
- $account->member_account_surplus = 0;
|
|
|
- $account->member_account_added = $cut;
|
|
|
- } else {
|
|
|
- $account->member_account_surplus = $account->member_account_surplus - $params['order_amount_pay'];
|
|
|
+ $params['order_amount_pay'] = $orderAmountPay;
|
|
|
}
|
|
|
- $account->member_account_expend = $account->member_account_expend + $params['order_amount_pay'];
|
|
|
- $account->member_account_update_user_id = JwtToken::getCurrentId();
|
|
|
- $account->member_account_updatetimes = time();
|
|
|
- $account->save();
|
|
|
-
|
|
|
-
|
|
|
- $params['order_status_system'] = $systemStatus;
|
|
|
- $params['order_status_payment'] = 'SUCCESS';
|
|
|
- // 生成支付记录
|
|
|
- OrderService::createPayDetail($params);
|
|
|
-
|
|
|
- $params['order_amount_pay'] = $orderAmountPay;
|
|
|
}
|
|
|
- //!empty($params['pay_category_constitute']) && in_array('CARD',$params['pay_category_constitute'])
|
|
|
- // if(($params['pay_constitute'] == 'Y' || $params['pay_category'] == 'QRCODE') && $params['settlement_now'] == 'Y' && !empty($params['qrcode_nbr'])){ // 付款码
|
|
|
if (!empty($params['pay_category_constitute']) && in_array('QRCODE', $params['pay_category_constitute']) && !empty($params['qrcode_nbr'])) { // 付款码
|
|
|
// 需要付款码的金额>0
|
|
|
if (isset($constituteList['QRCODE']) && $constituteList['QRCODE'] > 0) {
|
|
@@ -2914,11 +2846,11 @@ class WholeController extends Curd
|
|
|
if (in_array($prefix, [10, 11, 12, 13, 14, 15])) {
|
|
|
$params['pay_category'] = 'WXPAY';
|
|
|
if ((!isset($result['return_code']) || $result['return_code'] != 'SUCCESS') || (!isset($result['result_code']) || $result['result_code'] != 'SUCCESS') || (empty($result['trade_state']) || $result['trade_state'] != 'SUCCESS')) {
|
|
|
+ // 标记支付状态
|
|
|
+ $wxAndAliPayStatus = 'N';
|
|
|
$params['order_status_system'] = 'PAYING';
|
|
|
$params['order_status_payment'] = 'PENDING';
|
|
|
$params['order_is_complete'] = 'N';
|
|
|
-// Db::rollBack();
|
|
|
-// return json_fail('支付失败');
|
|
|
} else {
|
|
|
$params['order_status_system'] = $systemStatus;
|
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
@@ -2926,11 +2858,11 @@ class WholeController extends Curd
|
|
|
} else if (in_array($prefix, [25, 26, 27, 28, 29, 30])) {
|
|
|
$params['pay_category'] = 'ALIPAY';
|
|
|
if ((!isset($result['code']) || $result['code'] != '10000') || (empty($result['trade_status']) || $result['trade_status'] != 'TRADE_SUCCESS')) {
|
|
|
+ // 标记支付状态
|
|
|
+ $wxAndAliPayStatus = 'N';
|
|
|
$params['order_status_system'] = 'PAYING';
|
|
|
$params['order_status_payment'] = 'PENDING';
|
|
|
$params['order_is_complete'] = 'N';
|
|
|
-// Db::rollBack();
|
|
|
-// return json_fail('支付失败');
|
|
|
} else {
|
|
|
$params['order_status_system'] = $systemStatus;
|
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
@@ -2940,7 +2872,7 @@ class WholeController extends Curd
|
|
|
}
|
|
|
|
|
|
// 生成支付记录
|
|
|
- OrderService::createPayDetail($params);
|
|
|
+ $params['pay_detail_item'][] = $params;
|
|
|
// 账户支付的金额
|
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
|
}
|
|
@@ -2955,36 +2887,39 @@ class WholeController extends Curd
|
|
|
// 配送方式
|
|
|
if (isset($params['delivery']) && ($params['delivery'] == 'PICKUP' || $params['delivery'] == 'ARRIVAL')) { // 自提/ 到店
|
|
|
$orderConfigJson['premises'] = $params['dept_premises_id'];
|
|
|
- } else if (isset($params['delivery']) && $params['delivery'] == 'LOGISTICS') {
|
|
|
- // $params['order_express_json'] = json_encode([
|
|
|
- // 'express' => 'Y',
|
|
|
- // ]);
|
|
|
}
|
|
|
$params['order_amount_pay'] = $params['order_amount_pay'] + $qrcodePayAmount;
|
|
|
|
|
|
if (isset($params['delivery']) && in_array($params['delivery'], ['PICKUP', 'ARRIVAL']) && !empty($params['dept_premises_id'])) {
|
|
|
- // $premises = SysDept::where('dept_name',$params['dept_premises_id'])->where('dept_category','营业场所')->first();
|
|
|
if (!$premises) {
|
|
|
throw new BusinessException("门店不存在,请重新选择");
|
|
|
}
|
|
|
$params['submit_premises_id'] = $premises->dept_id;
|
|
|
}
|
|
|
- if (isset($params['submit_goods_classify']) && $params['submit_goods_classify'] == 'MEALS' && !empty($params['dept_table_id'])) {
|
|
|
- $table = SysDept::where('dept_id', $params['dept_table_id'])->where('dept_category', '桌台')->first();
|
|
|
+ if (isset($params['submit_goods_classify']) && $params['submit_goods_classify'] == 'MEALS' && !empty($params['dept_premises_id'])) {
|
|
|
+ $table = '';
|
|
|
+ if (!empty($params['dept_table_id'])) {
|
|
|
+ $table = SysDept::where('dept_id', $params['dept_table_id'])->where('dept_category', '桌台')->first();
|
|
|
+ }
|
|
|
$orderConfigJson['premises'] = $params['dept_premises_id'];
|
|
|
- $orderConfigJson['dept'] = $premises->dept_id;
|
|
|
+ $orderConfigJson['dept'] = $premises->dept_id ?? 0;
|
|
|
$orderConfigJson['reach'] = "00:00";
|
|
|
$orderConfigJson['table'] = !empty($table) ? $table->dept_name : null;
|
|
|
- $orderConfigJson['express'] = "堂食";
|
|
|
+ $orderConfigJson['express'] = "到店吃";
|
|
|
$orderConfigJson['tableid'] = $params['dept_table_id'] ?? null;
|
|
|
if (!empty($params['eat'])) {
|
|
|
$orderConfigJson['eat'] = $params['eat'] ?? null;
|
|
|
}
|
|
|
+
|
|
|
+ if ($params['settlement_now'] == 'N' && !empty($params['dept_table_id'])) {
|
|
|
+ // 桌台设为使用中
|
|
|
+ SysDept::where('dept_id', $params['dept_table_id'])->where('dept_category', '桌台')->update(['dept_status' => 'USING']);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$params['order_config_json'] = json_encode($orderConfigJson);
|
|
|
// 写入主订单
|
|
|
- $this->insertMain($params);
|
|
|
+ $this->insertMain($params, $wxAndAliPayStatus);
|
|
|
// 订单详情
|
|
|
$sheetId = $this->insertSheet($params);
|
|
|
|
|
@@ -3025,11 +2960,6 @@ class WholeController extends Curd
|
|
|
// 买的单个服务
|
|
|
$writeOffDate = [];
|
|
|
$applyData = [];
|
|
|
- // 服务已完成,生成核销数据
|
|
|
-// if ($params['order_status_payment'] == 'SUCCESS' && in_array($goods['goods_classify'], ['SERVICE','CHNMED','CHNNCD', 'PACKAGE'])) {
|
|
|
-// $writeOffDate = OrderService::generateWriteOffData($params);
|
|
|
-// $applyData = OrderService::generateAppointmentApplyData($params);
|
|
|
-// }
|
|
|
if ($params['order_status_payment'] == 'SUCCESS') {
|
|
|
foreach ($params['goodsContentList'] as $goods) {
|
|
|
$params['join_sheet_goods_id'] = $goods['goods_id'];
|
|
@@ -3100,7 +3030,6 @@ class WholeController extends Curd
|
|
|
|
|
|
// 打小票
|
|
|
if (!empty($premises) && isset($params['submit_goods_classify']) && $params['submit_goods_classify'] == 'MEALS') {
|
|
|
-// if (!empty($premises)){
|
|
|
if ($premises->dept_category != '餐厅') {
|
|
|
$restaurant = SysDept::where('dept_super_id', $premises->dept_id)->where('dept_category', '餐厅')->first();
|
|
|
} else {
|
|
@@ -3165,15 +3094,13 @@ class WholeController extends Curd
|
|
|
return json_success('创建订单成功');
|
|
|
} catch (BusinessException $e) {
|
|
|
Db::rollBack();
|
|
|
- dump($e->getMessage());
|
|
|
- dump($e->getTrace());
|
|
|
- _syslog("订单", $e->getMessage());
|
|
|
- return json_fail($e->getMessage());
|
|
|
+ _syslog("订单", '创建订单失败:' . $e->getMessage());
|
|
|
+ Log::error('创建订单失败', ['msg' => $e->getMessage()]);
|
|
|
+ return json_fail('创建订单失败:' . $e->getMessage());
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollBack();
|
|
|
- dump($e->getMessage());
|
|
|
- dump($e->getTrace());
|
|
|
_syslog("订单", "创建订单失败");
|
|
|
+ Log::error('创建订单失败', ['msg' => $e->getMessage()]);
|
|
|
return json_fail('创建订单失败');
|
|
|
}
|
|
|
}
|
|
@@ -3187,7 +3114,7 @@ class WholeController extends Curd
|
|
|
* @return void
|
|
|
* @throws BusinessException
|
|
|
*/
|
|
|
- public function insertMain($params)
|
|
|
+ public function insertMain($params, $wxAndAliPayStatus = 'Y')
|
|
|
{
|
|
|
try {
|
|
|
$orderCategory = 'NORMAL';
|
|
@@ -3205,6 +3132,12 @@ class WholeController extends Curd
|
|
|
$params['order_extend_json'] = json_decode($params['order_extend_json'], true);
|
|
|
}
|
|
|
}
|
|
|
+ // 账户扣款
|
|
|
+ if ($wxAndAliPayStatus == 'Y' && !empty($params['waitToPayAccount'])) {
|
|
|
+ foreach ($params['waitToPayAccount'] as $account) {
|
|
|
+ $this->deductAmount($account['nbr'], $account['amount']);
|
|
|
+ }
|
|
|
+ }
|
|
|
// 推荐人
|
|
|
$params['order_extend_json']['referee'] = $params['referee'] ?? '';
|
|
|
|
|
@@ -3232,6 +3165,26 @@ class WholeController extends Curd
|
|
|
];
|
|
|
|
|
|
Order::insert($data);
|
|
|
+
|
|
|
+ if (!empty($params['pay_detail_item'])) {
|
|
|
+ foreach ($params['pay_detail_item'] as $item) {
|
|
|
+ $data = [
|
|
|
+ 'join_pay_member_id' => $item['join_order_member_id'],
|
|
|
+ 'join_pay_order_id' => $item['orderGroupId'],
|
|
|
+ 'pay_status' => $params['settlement_now'] == 'Y' && $params['order_status_payment'] == 'SUCCESS' ? 'SUCCESS' : 'WAITING',
|
|
|
+ 'pay_category' => $params['submit_goods_classify'],
|
|
|
+ 'pay_amount' => $item['order_amount_pay'],
|
|
|
+ 'pay_prepayid' => $item['pay_category'],
|
|
|
+ 'pay_paytimes' => date('Y-m-d H:i:s'),
|
|
|
+ 'join_pay_object_json' => !empty($item['orderId']) ? json_encode(['order_id' => $params['orderId']]) : '[]',
|
|
|
+ 'pay_json_request' => json_encode($item),
|
|
|
+ 'pay_json_response' => $item['pay_json_response'] ?? '[]',
|
|
|
+ 'pay_remark' => $item['order_remark'] ?? '',
|
|
|
+ 'pay_addtimes' => time(),
|
|
|
+ ];
|
|
|
+ PayDetail::insert($data);
|
|
|
+ }
|
|
|
+ }
|
|
|
} catch (\Exception $e) {
|
|
|
dump($e->getMessage());
|
|
|
throw new BusinessException('订单创建信息失败');
|
|
@@ -3252,7 +3205,6 @@ class WholeController extends Curd
|
|
|
try {
|
|
|
$orderSheetIds = [];
|
|
|
foreach ($params['goodsContentList'] as $goods) {
|
|
|
- //{"unit": "份", "table": null, "premises": "15"}
|
|
|
$price = floatval($goods['goods_sales_price']);
|
|
|
$extendJson['unit'] = $goods['sku_name'];
|
|
|
if (isset($params['submit_premises_id'])) {
|
|
@@ -3341,6 +3293,8 @@ class WholeController extends Curd
|
|
|
$payPrepayid = 'OFFLINE_WXPAY';
|
|
|
} else if ($params['pay_category'] == 'MONEY') {
|
|
|
$payPrepayid = 'MONEY';
|
|
|
+ } else if ($params['pay_category'] == 'CARD') {
|
|
|
+ $payPrepayid = $params['card_id'];
|
|
|
} else {
|
|
|
$payPrepayid = $params['join_order_member_id'] . '-' . $params['pay_category'];
|
|
|
}
|
|
@@ -3361,7 +3315,7 @@ class WholeController extends Curd
|
|
|
|
|
|
PayDetail::insert($data);
|
|
|
} catch (\Exception $e) {
|
|
|
- dump($e->getMessage());
|
|
|
+ Log::error("创建支付记录失败", ['msg' => $e->getMessage()]);
|
|
|
throw new BusinessException('创建支付记录失败');
|
|
|
}
|
|
|
}
|
|
@@ -5581,6 +5535,35 @@ class WholeController extends Curd
|
|
|
return json_success('', compact('rows', 'page', 'pageSize', 'total'));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Desc 扣除账户金额
|
|
|
+ * @Author Gorden
|
|
|
+ * @Date 2024/9/26 14:16
|
|
|
+ *
|
|
|
+ * @param $accountNbr
|
|
|
+ * @param $amount
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function deductAmount($accountNbr, $amount)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $account = MemberAccount::where('member_account_nbr', $accountNbr)->first();
|
|
|
+ $account->member_account_expend = $account->member_account_expend + $amount;
|
|
|
+ if ($account->member_account_surplus < $amount && strpos($accountNbr, 'CASH') !== false) {
|
|
|
+ $account->member_account_added = $account->member_account_added - ($amount - $account->member_account_surplus);
|
|
|
+ $account->member_account_surplus = 0;
|
|
|
+ } else {
|
|
|
+ $account->member_account_surplus = $account->member_account_surplus - $amount;
|
|
|
+ }
|
|
|
+
|
|
|
+ $account->save();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ _syslog("下单扣款", "扣款失败");
|
|
|
+
|
|
|
+ throw new BusinessException("账户扣款失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// public function getMergeOrder(Request $request)
|
|
|
// {
|
|
|
// $orderIds = $request->get('order_ids');
|