|
@@ -685,7 +685,7 @@ class PackagesController extends Curd
|
|
|
|
|
|
$params['order_config_json'] = json_encode($orderConfigJson);
|
|
$params['order_config_json'] = json_encode($orderConfigJson);
|
|
// 写入订单
|
|
// 写入订单
|
|
- $this->insertMain($params, $premises);
|
|
|
|
|
|
+ $this->insertMain($params);
|
|
|
|
|
|
Db::commit();
|
|
Db::commit();
|
|
|
|
|
|
@@ -728,7 +728,6 @@ class PackagesController extends Curd
|
|
public function insertConstitute(Request $request): Response
|
|
public function insertConstitute(Request $request): Response
|
|
{
|
|
{
|
|
$params = $request->post();
|
|
$params = $request->post();
|
|
- // 判断餐品是否连带着服务或实体
|
|
|
|
$goodsClassifys = array_unique(array_column($params['goodsContentList'], 'goods_classify'));
|
|
$goodsClassifys = array_unique(array_column($params['goodsContentList'], 'goods_classify'));
|
|
$premises = [];
|
|
$premises = [];
|
|
if (!empty($params['dept_premises_id'])) {
|
|
if (!empty($params['dept_premises_id'])) {
|
|
@@ -819,16 +818,13 @@ class PackagesController extends Curd
|
|
$systemStatus = 'SENDING'; // 待发货
|
|
$systemStatus = 'SENDING'; // 待发货
|
|
// 立即结算
|
|
// 立即结算
|
|
if ($params['settlement_now'] == 'Y') {
|
|
if ($params['settlement_now'] == 'Y') {
|
|
- if (in_array($params['goods_classify'], ['MEALS', 'VIP'])) {
|
|
|
|
- $params['order_is_complete'] = 'Y';
|
|
|
|
- $systemStatus = 'DONE';
|
|
|
|
- }
|
|
|
|
if (in_array($params['goods_classify'], ['SERVICE', 'CHNMED', 'CHNNCD', 'PACKAGE']) && $params['delivery'] == 'ARRIVAL') {
|
|
if (in_array($params['goods_classify'], ['SERVICE', 'CHNMED', 'CHNNCD', 'PACKAGE']) && $params['delivery'] == 'ARRIVAL') {
|
|
$params['order_is_complete'] = 'N';
|
|
$params['order_is_complete'] = 'N';
|
|
$systemStatus = "WAITING";
|
|
$systemStatus = "WAITING";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$params['pay_detail_item'] = [];
|
|
$params['pay_detail_item'] = [];
|
|
|
|
+ $wxAndAliPayStatus = 'Y';
|
|
if (!empty($params['pay_category_constitute']) && in_array('OFFLINE', $params['pay_category_constitute'])) { // 线下支付
|
|
if (!empty($params['pay_category_constitute']) && in_array('OFFLINE', $params['pay_category_constitute'])) { // 线下支付
|
|
$params['order_status_system'] = $systemStatus;
|
|
$params['order_status_system'] = $systemStatus;
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
@@ -874,25 +870,31 @@ class PackagesController extends Curd
|
|
if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
throw new BusinessException("账户余额不足");
|
|
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->save();
|
|
|
|
|
|
+// 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->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_system'] = $systemStatus;
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
|
|
|
|
// 生成支付记录
|
|
// 生成支付记录
|
|
-// OrderService::createPayDetail($params);
|
|
|
|
$params['pay_detail_item'][] = $params;
|
|
$params['pay_detail_item'][] = $params;
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
|
|
|
|
@@ -919,27 +921,32 @@ class PackagesController extends Curd
|
|
if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
throw new BusinessException("储值卡账户余额不足");
|
|
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->save();
|
|
|
|
-
|
|
|
|
|
|
+// 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->save();
|
|
|
|
+ // 储值卡账户扣款数据
|
|
|
|
+ $params['waitToPayAccount']['card'] = [
|
|
|
|
+ 'group_id' => $params['orderGroupId'],
|
|
|
|
+ 'member_id' => $params['join_order_member_id'],
|
|
|
|
+ 'amount' => $constituteList['CARD'],
|
|
|
|
+ 'nbr' => $params['join_order_member_id'] . '-CARD'
|
|
|
|
+ ];
|
|
|
|
|
|
$params['order_status_system'] = $systemStatus;
|
|
$params['order_status_system'] = $systemStatus;
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
// 生成支付记录
|
|
// 生成支付记录
|
|
$params['pay_detail_item'][] = $params;
|
|
$params['pay_detail_item'][] = $params;
|
|
-// OrderService::createPayDetail($params);
|
|
|
|
|
|
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
}
|
|
}
|
|
@@ -960,6 +967,8 @@ class PackagesController extends Curd
|
|
if (in_array($prefix, [10, 11, 12, 13, 14, 15])) {
|
|
if (in_array($prefix, [10, 11, 12, 13, 14, 15])) {
|
|
$params['pay_category'] = 'WXPAY';
|
|
$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')) {
|
|
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_system'] = 'PAYING';
|
|
$params['order_status_payment'] = 'PENDING';
|
|
$params['order_status_payment'] = 'PENDING';
|
|
$params['order_is_complete'] = 'N';
|
|
$params['order_is_complete'] = 'N';
|
|
@@ -972,6 +981,8 @@ class PackagesController extends Curd
|
|
} else if (in_array($prefix, [25, 26, 27, 28, 29, 30])) {
|
|
} else if (in_array($prefix, [25, 26, 27, 28, 29, 30])) {
|
|
$params['pay_category'] = 'ALIPAY';
|
|
$params['pay_category'] = 'ALIPAY';
|
|
if ((!isset($result['code']) || $result['code'] != '10000') || (empty($result['trade_status']) || $result['trade_status'] != 'TRADE_SUCCESS')) {
|
|
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_system'] = 'PAYING';
|
|
$params['order_status_payment'] = 'PENDING';
|
|
$params['order_status_payment'] = 'PENDING';
|
|
$params['order_is_complete'] = 'N';
|
|
$params['order_is_complete'] = 'N';
|
|
@@ -1000,7 +1011,7 @@ class PackagesController extends Curd
|
|
}
|
|
}
|
|
$params['order_config_json'] = json_encode($orderConfigJson);
|
|
$params['order_config_json'] = json_encode($orderConfigJson);
|
|
// 写入订单
|
|
// 写入订单
|
|
- $this->insertMain($params, $premises);
|
|
|
|
|
|
+ $this->insertMain($params, $wxAndAliPayStatus);
|
|
|
|
|
|
Db::commit();
|
|
Db::commit();
|
|
|
|
|
|
@@ -1018,20 +1029,18 @@ class PackagesController extends Curd
|
|
}
|
|
}
|
|
$this->changeOrderCouponStatus($couponUseJson, 'WAITING');
|
|
$this->changeOrderCouponStatus($couponUseJson, 'WAITING');
|
|
|
|
|
|
- return json_throw(2001, '支付异常', ['order_id' => $params['orderId']]);
|
|
|
|
|
|
+ return json_throw(2001, '支付异常', ['order_id' => $params['orderId'], 'group_id' => $params['orderGroupId']]);
|
|
}
|
|
}
|
|
_syslog("订单", "创建订单成功");
|
|
_syslog("订单", "创建订单成功");
|
|
return json_success('创建订单成功');
|
|
return json_success('创建订单成功');
|
|
} catch (BusinessException $e) {
|
|
} catch (BusinessException $e) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
dump($e->getMessage());
|
|
dump($e->getMessage());
|
|
- dump($e->getTrace());
|
|
|
|
_syslog("订单", $e->getMessage());
|
|
_syslog("订单", $e->getMessage());
|
|
return json_fail($e->getMessage());
|
|
return json_fail($e->getMessage());
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
dump($e->getMessage());
|
|
dump($e->getMessage());
|
|
- dump($e->getTrace());
|
|
|
|
_syslog("订单", "创建订单失败");
|
|
_syslog("订单", "创建订单失败");
|
|
return json_fail('创建订单失败');
|
|
return json_fail('创建订单失败');
|
|
}
|
|
}
|
|
@@ -1426,7 +1435,7 @@ class PackagesController extends Curd
|
|
}
|
|
}
|
|
$payData['join_pay_member_id'] = $params['join_order_member_id'];
|
|
$payData['join_pay_member_id'] = $params['join_order_member_id'];
|
|
$payData['join_pay_order_id'] = $order->order_groupby;
|
|
$payData['join_pay_order_id'] = $order->order_groupby;
|
|
- $payData['pay_status'] = $payData['pay_status'] == 'SUCCESS' ? $payData['pay_status'] : 'WAITING';
|
|
|
|
|
|
+ $payData['pay_status'] = !empty($payData['pay_status']) && $payData['pay_status'] == 'SUCCESS' ? $payData['pay_status'] : 'WAITING';
|
|
$payData['pay_category'] = $params['goods_classify'] ?? '';
|
|
$payData['pay_category'] = $params['goods_classify'] ?? '';
|
|
$payData['pay_paytimes'] = date('Y-m-d H:i:s');
|
|
$payData['pay_paytimes'] = date('Y-m-d H:i:s');
|
|
$payData['pay_json_request'] = json_encode($params); // {"pay-result": "支付成功", "result-datetime": "2024-07-29 18:38:21"}
|
|
$payData['pay_json_request'] = json_encode($params); // {"pay-result": "支付成功", "result-datetime": "2024-07-29 18:38:21"}
|
|
@@ -1516,9 +1525,9 @@ class PackagesController extends Curd
|
|
// 会员升级
|
|
// 会员升级
|
|
Event::dispatch('order_pay.member_level.up', $params['join_order_member_id']);
|
|
Event::dispatch('order_pay.member_level.up', $params['join_order_member_id']);
|
|
}
|
|
}
|
|
- if($order->order_status_payment == 'SUCCESS'){
|
|
|
|
|
|
+ if ($order->order_status_payment == 'SUCCESS') {
|
|
// 上级提成
|
|
// 上级提成
|
|
- Event::dispatch('commission.order',$params);
|
|
|
|
|
|
+ Event::dispatch('commission.order', $params);
|
|
}
|
|
}
|
|
|
|
|
|
// 打小票
|
|
// 打小票
|
|
@@ -1553,7 +1562,7 @@ class PackagesController extends Curd
|
|
$this->changeOrderCouponStatus($couponUseJson, 'WAITING');
|
|
$this->changeOrderCouponStatus($couponUseJson, 'WAITING');
|
|
}
|
|
}
|
|
|
|
|
|
- return json_throw(2001, '支付异常', ['order_id' => $params['orderId']]);
|
|
|
|
|
|
+ return json_throw(2001, '支付异常', ['order_id' => $params['orderId'], 'group_id' => $params['orderGroupId']]);
|
|
}
|
|
}
|
|
_syslog("订单", "订单支付成功");
|
|
_syslog("订单", "订单支付成功");
|
|
return json_success('支付成功');
|
|
return json_success('支付成功');
|
|
@@ -1679,7 +1688,11 @@ class PackagesController extends Curd
|
|
if (sprintf("%.2f", $params['order_amount_pay']) != sprintf("%.2f", $constituteAmount)) {
|
|
if (sprintf("%.2f", $params['order_amount_pay']) != sprintf("%.2f", $constituteAmount)) {
|
|
throw new BusinessException('组合支付金额与应付金额不一致');
|
|
throw new BusinessException('组合支付金额与应付金额不一致');
|
|
}
|
|
}
|
|
- $params['pay_detail_item'] = [];
|
|
|
|
|
|
+
|
|
|
|
+ $wxAndAliPayStatus = 'Y';
|
|
|
|
+ $waitToPayAccount = [];
|
|
|
|
+ // 清除订单的支付记录,重建
|
|
|
|
+ PayDetail::whereJsonContains('join_pay_object_json->order_id', $params['orderId'])->delete();
|
|
if (!empty($params['pay_category_constitute']) && in_array('OFFLINE', $params['pay_category_constitute'])) { //线下付款
|
|
if (!empty($params['pay_category_constitute']) && in_array('OFFLINE', $params['pay_category_constitute'])) { //线下付款
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_payment = 'SUCCESS';
|
|
$order->order_status_payment = 'SUCCESS';
|
|
@@ -1689,9 +1702,9 @@ class PackagesController extends Curd
|
|
if (isset($constituteList['OFFLINE'])) {
|
|
if (isset($constituteList['OFFLINE'])) {
|
|
$params['order_amount_pay'] = $constituteList['OFFLINE'];
|
|
$params['order_amount_pay'] = $constituteList['OFFLINE'];
|
|
// 生成支付记录
|
|
// 生成支付记录
|
|
- OrderService::createPayConstituteDetail($params, $payDetail);
|
|
|
|
|
|
+ $params['order_status_payment'] = 'PENDING';
|
|
|
|
+ OrderService::createProductPayConstituteDetail($params);
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
- $params['pay_detail_item'][] = $params;
|
|
|
|
}
|
|
}
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
}
|
|
}
|
|
@@ -1704,9 +1717,9 @@ class PackagesController extends Curd
|
|
if (isset($constituteList['MONEY'])) {
|
|
if (isset($constituteList['MONEY'])) {
|
|
$params['order_amount_pay'] = $constituteList['MONEY'];
|
|
$params['order_amount_pay'] = $constituteList['MONEY'];
|
|
// 生成支付记录
|
|
// 生成支付记录
|
|
- OrderService::createPayConstituteDetail($params, $payDetail);
|
|
|
|
|
|
+ $params['order_status_payment'] = 'PENDING';
|
|
|
|
+ OrderService::createProductPayConstituteDetail($params, $payDetail);
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
- $params['pay_detail_item'][] = $params;
|
|
|
|
}
|
|
}
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
}
|
|
}
|
|
@@ -1726,23 +1739,17 @@ class PackagesController extends Curd
|
|
if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
throw new BusinessException('账户余额不足');
|
|
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->save();
|
|
|
|
|
|
+ // 余额账户扣款数据
|
|
|
|
+ $waitToPayAccount['cash'] = [
|
|
|
|
+ 'group_id' => $params['orderGroupId'],
|
|
|
|
+ 'member_id' => $params['join_order_member_id'],
|
|
|
|
+ 'amount' => $constituteList['CASH'],
|
|
|
|
+ 'nbr' => $params['join_order_member_id'] . '-CASH'
|
|
|
|
+ ];
|
|
// 生成支付记录
|
|
// 生成支付记录
|
|
- OrderService::createPayConstituteDetail($params, $payDetail);
|
|
|
|
|
|
+ $params['order_status_payment'] = 'PENDING';
|
|
|
|
+ OrderService::createProductPayConstituteDetail($params);
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
- $params['pay_detail_item'][] = $params;
|
|
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_payment = 'SUCCESS';
|
|
$order->order_status_payment = 'SUCCESS';
|
|
@@ -1769,23 +1776,17 @@ class PackagesController extends Curd
|
|
if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
throw new BusinessException('账户余额不足');
|
|
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->save();
|
|
|
|
|
|
+ // 储值卡账户扣款数据
|
|
|
|
+ $waitToPayAccount['card'] = [
|
|
|
|
+ 'group_id' => $params['orderGroupId'],
|
|
|
|
+ 'member_id' => $params['join_order_member_id'],
|
|
|
|
+ 'amount' => $constituteList['CARD'],
|
|
|
|
+ 'nbr' => $params['join_order_member_id'] . '-CARD'
|
|
|
|
+ ];
|
|
// 生成支付记录
|
|
// 生成支付记录
|
|
- OrderService::createPayConstituteDetail($params, $payDetail);
|
|
|
|
|
|
+ $params['order_status_payment'] = 'PENDING';
|
|
|
|
+ OrderService::createProductPayConstituteDetail($params);
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
$params['order_status_payment'] = 'SUCCESS';
|
|
- $params['pay_detail_item'][] = $params;
|
|
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_payment = 'SUCCESS';
|
|
$order->order_status_payment = 'SUCCESS';
|
|
@@ -1804,26 +1805,30 @@ class PackagesController extends Curd
|
|
if (in_array($prefix, [10, 11, 12, 13, 14, 15])) {
|
|
if (in_array($prefix, [10, 11, 12, 13, 14, 15])) {
|
|
$params['pay_category'] = 'WXPAY';
|
|
$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')) {
|
|
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_system = 'PAYING';
|
|
$order->order_status_payment = 'PENDING';
|
|
$order->order_status_payment = 'PENDING';
|
|
$order->order_is_complete = 'N';
|
|
$order->order_is_complete = 'N';
|
|
-// Db::rollBack();
|
|
|
|
-// return json_fail('支付失败');
|
|
|
|
|
|
+ $params['order_status_payment'] = 'PAYING';
|
|
} else {
|
|
} else {
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_payment = 'SUCCESS';
|
|
$order->order_status_payment = 'SUCCESS';
|
|
|
|
+ $params['order_status_payment'] = 'SUCCESS';
|
|
}
|
|
}
|
|
} else if (in_array($prefix, [25, 26, 27, 28, 29, 30])) {
|
|
} else if (in_array($prefix, [25, 26, 27, 28, 29, 30])) {
|
|
$params['pay_category'] = 'ALIPAY';
|
|
$params['pay_category'] = 'ALIPAY';
|
|
if ((!isset($result['code']) || $result['code'] != '10000') || (empty($result['trade_status']) || $result['trade_status'] != 'TRADE_SUCCESS')) {
|
|
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_system = 'PAYING';
|
|
$order->order_status_payment = 'PENDING';
|
|
$order->order_status_payment = 'PENDING';
|
|
$order->order_is_complete = 'N';
|
|
$order->order_is_complete = 'N';
|
|
-// Db::rollBack();
|
|
|
|
-// return json_fail('支付失败');
|
|
|
|
|
|
+ $params['order_status_payment'] = 'PAYING';
|
|
} else {
|
|
} else {
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_system = $systemStatus;
|
|
$order->order_status_payment = 'SUCCESS';
|
|
$order->order_status_payment = 'SUCCESS';
|
|
|
|
+ $params['order_status_payment'] = 'SUCCESS';
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
throw new BusinessException('付款码无效');
|
|
throw new BusinessException('付款码无效');
|
|
@@ -1831,7 +1836,7 @@ class PackagesController extends Curd
|
|
}
|
|
}
|
|
|
|
|
|
// 生成支付记录
|
|
// 生成支付记录
|
|
- OrderService::createPayConstituteDetail($params, $payDetail);
|
|
|
|
|
|
+ OrderService::createProductPayConstituteDetail($params);
|
|
// 账户支付的金额
|
|
// 账户支付的金额
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
$params['order_amount_pay'] = $orderAmountPay;
|
|
}
|
|
}
|
|
@@ -1840,9 +1845,6 @@ class PackagesController extends Curd
|
|
$orderConfigJson = json_decode($order->order_config_json, true);
|
|
$orderConfigJson = json_decode($order->order_config_json, true);
|
|
}
|
|
}
|
|
$orderConfigJson['preferential'] = $params['preferential'] ?? '';
|
|
$orderConfigJson['preferential'] = $params['preferential'] ?? '';
|
|
- if (isset($orderConfigJson['tableid']) && !empty($orderConfigJson['tableid'])) {
|
|
|
|
- SysDept::where('dept_id', $orderConfigJson['tableid'])->where('dept_category', '桌台')->update(['dept_status' => 'ACTIVED']);
|
|
|
|
- }
|
|
|
|
$order->order_config_json = json_encode($orderConfigJson);
|
|
$order->order_config_json = json_encode($orderConfigJson);
|
|
$order->order_amount_pay = $params['order_amount_pay'];
|
|
$order->order_amount_pay = $params['order_amount_pay'];
|
|
|
|
|
|
@@ -1854,34 +1856,25 @@ class PackagesController extends Curd
|
|
'order_sheet_status' => $systemStatus,
|
|
'order_sheet_status' => $systemStatus,
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
- // 清除paydetail 中的未支付记录
|
|
|
|
- PayDetail::where('join_pay_order_id', $params['orderGroupId'])
|
|
|
|
- ->whereJsonContains('join_pay_object_json->order_id', $params['order_id'])
|
|
|
|
- ->where('pay_status', '<>', 'SUCCESS')
|
|
|
|
- ->delete();
|
|
|
|
-
|
|
|
|
- $writeOffDate = [];
|
|
|
|
- $applyData = [];
|
|
|
|
- // 有预约单,状态已完成
|
|
|
|
- $appointment = Appointment::where('join_appointment_order_id', $params['order_id'])->first();
|
|
|
|
- if ($order->order_status_payment == 'SUCCESS' && $appointment) {
|
|
|
|
- $writeOffDate = OrderService::generateWriteOffData($params);
|
|
|
|
- $applyData = OrderService::generateAppointmentApplyData($params);
|
|
|
|
|
|
|
|
- $appointment->appointment_status = 'DONE';
|
|
|
|
- $appointment->appointment_done_datetime = date('Y-m-d H:i:s');
|
|
|
|
- $appointment->appointment_done_json = json_encode($writeOffDate);
|
|
|
|
- if (empty($appointment->appointment_apply_datetime)) {
|
|
|
|
- $appointment->appointment_apply_datetime = date('Y-m-d H:i:s');
|
|
|
|
- }
|
|
|
|
- if (empty($appointment->appointment_apply_json)) {
|
|
|
|
- $appointment->appointment_apply_json = json_encode($applyData);
|
|
|
|
- }
|
|
|
|
- if (empty($appointment->appointment_datetime)) {
|
|
|
|
- $appointment->appointment_datetime = date('Y-m-d');
|
|
|
|
|
|
+ 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 + $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();
|
|
}
|
|
}
|
|
-
|
|
|
|
- $appointment->save();
|
|
|
|
}
|
|
}
|
|
// 买单个服务
|
|
// 买单个服务
|
|
if ($order->order_status_payment == 'SUCCESS' && empty($appointment)) {
|
|
if ($order->order_status_payment == 'SUCCESS' && empty($appointment)) {
|
|
@@ -1939,9 +1932,9 @@ class PackagesController extends Curd
|
|
// 会员升级
|
|
// 会员升级
|
|
Event::dispatch('order_pay.member_level.up', $params['join_order_member_id']);
|
|
Event::dispatch('order_pay.member_level.up', $params['join_order_member_id']);
|
|
}
|
|
}
|
|
- if($order->order_status_payment == 'SUCCESS'){
|
|
|
|
|
|
+ if ($order->order_status_payment == 'SUCCESS') {
|
|
// 上级提成
|
|
// 上级提成
|
|
- Event::dispatch('commission.order',$params);
|
|
|
|
|
|
+ Event::dispatch('commission.order', $params);
|
|
}
|
|
}
|
|
|
|
|
|
// 打小票
|
|
// 打小票
|
|
@@ -1977,7 +1970,7 @@ class PackagesController extends Curd
|
|
// 清除支付记录,恢复账户金额
|
|
// 清除支付记录,恢复账户金额
|
|
// $this->restoreAccount($params['pay_detail_item']);
|
|
// $this->restoreAccount($params['pay_detail_item']);
|
|
|
|
|
|
- return json_throw(2001, '支付异常', ['order_id' => $params['orderId']]);
|
|
|
|
|
|
+ return json_throw(2001, '支付异常', ['order_id' => $params['orderId'], 'group_id' => $params['orderGroupId']]);
|
|
}
|
|
}
|
|
_syslog("订单", "订单支付成功");
|
|
_syslog("订单", "订单支付成功");
|
|
return json_success('支付成功');
|
|
return json_success('支付成功');
|
|
@@ -1997,7 +1990,7 @@ class PackagesController extends Curd
|
|
if (in_array($item['pay_category'], ['MONEY', 'OFFLINE', 'OFFLINE_ALIPAY', 'OFFLINE_WXPAY'])) {
|
|
if (in_array($item['pay_category'], ['MONEY', 'OFFLINE', 'OFFLINE_ALIPAY', 'OFFLINE_WXPAY'])) {
|
|
$prepayId = $item['pay_category'];
|
|
$prepayId = $item['pay_category'];
|
|
}
|
|
}
|
|
- if (strpos($item['pay_category'],'CASH') !== false || strpos($item['pay_category'],'CARD') !== false || strpos($item['pay_category'],'WELFARE') !== false || strpos($item['pay_category'],'VIP') !== false){
|
|
|
|
|
|
+ if (strpos($item['pay_category'], 'CASH') !== false || strpos($item['pay_category'], 'CARD') !== false || strpos($item['pay_category'], 'WELFARE') !== false || strpos($item['pay_category'], 'VIP') !== false) {
|
|
$prepayId = $item['pay_category'];
|
|
$prepayId = $item['pay_category'];
|
|
$account = MemberAccount::where('member_account_nbr', $prepayId)->first();
|
|
$account = MemberAccount::where('member_account_nbr', $prepayId)->first();
|
|
$account->member_account_expend = $account->member_account_expend - $item['order_amount_pay'];
|
|
$account->member_account_expend = $account->member_account_expend - $item['order_amount_pay'];
|
|
@@ -2008,7 +2001,7 @@ class PackagesController extends Curd
|
|
if (!empty($prepayId)) {
|
|
if (!empty($prepayId)) {
|
|
PayDetail::where('pay_prepayid', $prepayId)
|
|
PayDetail::where('pay_prepayid', $prepayId)
|
|
->where('join_pay_order_id', $item['orderGroupId'])
|
|
->where('join_pay_order_id', $item['orderGroupId'])
|
|
- ->whereJsonContains('join_pay_object_json->order_id',$item['orderId'])
|
|
|
|
|
|
+ ->whereJsonContains('join_pay_object_json->order_id', $item['orderId'])
|
|
->update(['pay_status' => 'WAITING']);
|
|
->update(['pay_status' => 'WAITING']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2023,7 +2016,7 @@ class PackagesController extends Curd
|
|
* @return void
|
|
* @return void
|
|
* @throws BusinessException
|
|
* @throws BusinessException
|
|
*/
|
|
*/
|
|
- public function insertMain($params, $premises)
|
|
|
|
|
|
+ public function insertMain($params, $wxAndAliPayStatus = 'Y')
|
|
{
|
|
{
|
|
try {
|
|
try {
|
|
if (empty($params['order_extend_json'])) {
|
|
if (empty($params['order_extend_json'])) {
|
|
@@ -2033,6 +2026,12 @@ class PackagesController extends Curd
|
|
$params['order_extend_json'] = json_decode($params['order_extend_json'], true);
|
|
$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'] ?? '';
|
|
$params['order_extend_json']['referee'] = $params['referee'] ?? '';
|
|
foreach ($params['goodsContentList'] as $goods) {
|
|
foreach ($params['goodsContentList'] as $goods) {
|
|
@@ -2080,10 +2079,9 @@ class PackagesController extends Curd
|
|
|
|
|
|
$this->insertExpressOne($params, $orderId);
|
|
$this->insertExpressOne($params, $orderId);
|
|
// 写到权益里
|
|
// 写到权益里
|
|
- $this->insertBenefitOne($params, $goods, $orderId);
|
|
|
|
-
|
|
|
|
- // 打小票
|
|
|
|
-// $this->printerTicket($params, $premises, $orderId);
|
|
|
|
|
|
+ if ($params['order_status_payment'] == 'SUCCESS') {
|
|
|
|
+ $this->insertBenefitOne($params, $goods, $orderId);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
dump($e->getMessage() . '|' . $e->getLine());
|
|
dump($e->getMessage() . '|' . $e->getLine());
|
|
@@ -2091,6 +2089,35 @@ class PackagesController extends Curd
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @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("账户扣款失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @Desc 打小票
|
|
* @Desc 打小票
|
|
* @Author Gorden
|
|
* @Author Gorden
|
|
@@ -2390,7 +2417,7 @@ class PackagesController extends Curd
|
|
$data = [
|
|
$data = [
|
|
'join_pay_member_id' => $item['join_order_member_id'],
|
|
'join_pay_member_id' => $item['join_order_member_id'],
|
|
'join_pay_order_id' => $item['orderGroupId'],
|
|
'join_pay_order_id' => $item['orderGroupId'],
|
|
- 'pay_status' => $item['settlement_now'] == 'Y' && $item['order_status_payment'] == 'SUCCESS' ? 'SUCCESS' : 'WAITING',
|
|
|
|
|
|
+ 'pay_status' => $params['settlement_now'] == 'Y' && $params['order_status_payment'] == 'SUCCESS' ? 'SUCCESS' : 'WAITING',
|
|
'pay_category' => $goods['goods_classify'],
|
|
'pay_category' => $goods['goods_classify'],
|
|
'pay_amount' => round(($amountPay / $params['order_amount_pay']) * $item['order_amount_pay'], 2),
|
|
'pay_amount' => round(($amountPay / $params['order_amount_pay']) * $item['order_amount_pay'], 2),
|
|
'pay_prepayid' => $item['pay_category'],
|
|
'pay_prepayid' => $item['pay_category'],
|