|
@@ -354,7 +354,7 @@ class WholeController extends Curd
|
|
|
|
|
|
$order = Order::where('order_id', $orderId)->first();
|
|
|
$payDetail = PayDetail::where('join_pay_order_id', $order->order_groupby)
|
|
|
- ->select('pay_id', 'pay_category', 'pay_prepayid', 'pay_paytimes', 'pay_status')
|
|
|
+ ->select('pay_id', 'pay_category', 'pay_prepayid', 'pay_paytimes', 'pay_status', 'pay_amount')
|
|
|
->first();
|
|
|
|
|
|
if (!empty($payDetail->pay_prepayid)) {
|
|
@@ -498,7 +498,7 @@ class WholeController extends Curd
|
|
|
|
|
|
$systemStatus = 'SENDING'; // 待发货
|
|
|
// 立即结算
|
|
|
- if(in_array($params['goods_classify'],['SERVICE','CHNMED','CHNNCD'])){
|
|
|
+ if(in_array($params['goods_classify'],['SERVICE','CHNMED','CHNNCD','MEALS'])){
|
|
|
$systemStatus = 'DONE';
|
|
|
}
|
|
|
Db::beginTransaction();
|
|
@@ -516,24 +516,24 @@ class WholeController extends Curd
|
|
|
return json_fail('账户异常');
|
|
|
}
|
|
|
$amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_sheet_pay'] > $amount)) {
|
|
|
+ if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
Db::rollBack();
|
|
|
return json_fail('账户余额不足');
|
|
|
}
|
|
|
- if($params['pay_constitute'] == 'Y' && (!$account || $params['order_sheet_pay'] > $amount)){
|
|
|
- $qrcodePayAmount = $params['order_sheet_pay'] - $amount;
|
|
|
- $params['order_sheet_pay'] = $amount;
|
|
|
+ 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_sheet_pay'] > $account->member_account_surplus) {
|
|
|
- $cut = $account->member_account_added - ($params['order_sheet_pay'] - $account->member_account_surplus);
|
|
|
+ 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_sheet_pay'];
|
|
|
+ $account->member_account_surplus = $account->member_account_surplus - $params['order_amount_pay'];
|
|
|
}
|
|
|
- $account->member_account_expend = $account->member_account_expend + $params['order_sheet_pay'];
|
|
|
+ $account->member_account_expend = $account->member_account_expend + $params['order_amount_pay'];
|
|
|
$account->save();
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_sheet_pay'] <= $amount)) {
|
|
|
+ if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] <= $amount)) {
|
|
|
$order->order_status_system = $systemStatus;
|
|
|
$order->order_status_payment = 'SUCCESS';
|
|
|
}
|
|
@@ -547,21 +547,21 @@ class WholeController extends Curd
|
|
|
return json_fail('账户异常');
|
|
|
}
|
|
|
$account->member_account_surplus = floatval($account->member_account_surplus);
|
|
|
- if ($params['pay_constitute'] == 'N' && ($params['order_sheet_pay'] > $account->member_account_surplus)) {
|
|
|
+ if ($params['pay_constitute'] == 'N' && ($params['order_amount_pay'] > $account->member_account_surplus)) {
|
|
|
Db::rollBack();
|
|
|
return json_fail('账户余额不足');
|
|
|
}
|
|
|
- if($params['pay_constitute'] == 'Y' && ($params['order_sheet_pay'] > $account->member_account_surplus)){
|
|
|
- $qrcodePayAmount = $params['order_sheet_pay'] - $account->member_account_surplus;
|
|
|
- $params['order_sheet_pay'] = $account->member_account_surplus;
|
|
|
+ if($params['pay_constitute'] == 'Y' && ($params['order_amount_pay'] > $account->member_account_surplus)){
|
|
|
+ $qrcodePayAmount = $params['order_amount_pay'] - $account->member_account_surplus;
|
|
|
+ $params['order_amount_pay'] = $account->member_account_surplus;
|
|
|
}
|
|
|
|
|
|
- if ($params['pay_constitute'] == 'N' && ($params['order_sheet_pay'] <= $account->member_account_surplus)) {
|
|
|
+ if ($params['pay_constitute'] == 'N' && ($params['order_amount_pay'] <= $account->member_account_surplus)) {
|
|
|
$order->order_status_system = $systemStatus;
|
|
|
$order->order_status_payment = 'SUCCESS';
|
|
|
}
|
|
|
- $account->member_account_surplus = $account->member_account_surplus - $params['order_sheet_pay'];
|
|
|
- $account->member_account_expend = $account->member_account_expend + $params['order_sheet_pay'];
|
|
|
+ $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();
|
|
|
} else if ($params['pay_category'] == 'CARD') { // 储值卡账户
|
|
|
$cardNbr = $params['card_nbr'];
|
|
@@ -578,24 +578,24 @@ class WholeController extends Curd
|
|
|
return json_fail('账户异常');
|
|
|
}
|
|
|
$amount = $account->member_account_surplus + $account->member_account_added;
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_sheet_pay'] > $amount)) {
|
|
|
+ if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] > $amount)) {
|
|
|
Db::rollBack();
|
|
|
return json_fail('账户余额不足');
|
|
|
}
|
|
|
- if($params['pay_constitute'] == 'Y' && (!$account || $params['order_sheet_pay'] > $amount)){
|
|
|
- $qrcodePayAmount = $params['order_sheet_pay'] - $amount;
|
|
|
- $params['order_sheet_pay'] = $amount;
|
|
|
+ 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_sheet_pay'] > $account->member_account_surplus) {
|
|
|
- $cut = $account->member_account_added - ($params['order_sheet_pay'] - $account->member_account_surplus);
|
|
|
+ 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_sheet_pay'];
|
|
|
+ $account->member_account_surplus = $account->member_account_surplus - $params['order_amount_pay'];
|
|
|
}
|
|
|
- $account->member_account_expend = $account->member_account_expend + $params['order_sheet_pay'];
|
|
|
+ $account->member_account_expend = $account->member_account_expend + $params['order_amount_pay'];
|
|
|
$account->save();
|
|
|
- if ($params['pay_constitute'] == 'N' && (!$account || $params['order_sheet_pay'] <= $amount)) {
|
|
|
+ if ($params['pay_constitute'] == 'N' && (!$account || $params['order_amount_pay'] <= $amount)) {
|
|
|
$order->order_status_system = $systemStatus;
|
|
|
$order->order_status_payment = 'SUCCESS';
|
|
|
}
|
|
@@ -604,13 +604,13 @@ class WholeController extends Curd
|
|
|
// 提交过来的支付分类
|
|
|
$submitPayCategory = $params['pay_category'];
|
|
|
// 账户支付的金额
|
|
|
- $accountAmount = $params['order_sheet_pay'];
|
|
|
+ $accountAmount = $params['order_amount_pay'];
|
|
|
if ($params['pay_constitute'] == 'Y' && $qrcodePayAmount > 0){
|
|
|
// 组合支付,改成需要付款码需要支付的金额
|
|
|
- $params['order_sheet_pay'] = $qrcodePayAmount;
|
|
|
+ $params['order_amount_pay'] = $qrcodePayAmount;
|
|
|
}
|
|
|
// 去支付
|
|
|
- // $result = OrderService::qrcodePay($params);
|
|
|
+ $result = OrderService::qrcodePay($params);
|
|
|
$result = [
|
|
|
'return_code'=>'SUCCESS',
|
|
|
'result_code' => 'SUCCESS'
|
|
@@ -644,7 +644,7 @@ class WholeController extends Curd
|
|
|
'join_pay_order_id'=>$params['orderGroupId'],
|
|
|
'pay_status'=>'SUCCESS',
|
|
|
'pay_category' => $params['goods_classify'],
|
|
|
- 'pay_amount'=> $params['order_sheet_pay'],
|
|
|
+ '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),
|
|
@@ -661,7 +661,7 @@ class WholeController extends Curd
|
|
|
$order->order_status_system = $systemStatus;
|
|
|
$order->order_status_payment = 'SUCCESS';
|
|
|
// 账户支付的金额
|
|
|
- $params['order_sheet_pay'] = $accountAmount;
|
|
|
+ $params['order_amount_pay'] = $accountAmount;
|
|
|
}
|
|
|
$orderConfigJson = [];
|
|
|
if (!empty($order->order_config_json)){
|
|
@@ -669,7 +669,7 @@ class WholeController extends Curd
|
|
|
}
|
|
|
$orderConfigJson['preferential'] = $params['preferential'] ?? '';
|
|
|
$order->order_config_json = json_encode($orderConfigJson);
|
|
|
- $order->order_amount_pay = $params['order_sheet_pay']+$qrcodePayAmount;
|
|
|
+ $order->order_amount_pay = $params['order_amount_pay']+$qrcodePayAmount;
|
|
|
// 主订单
|
|
|
$order->save();
|
|
|
|
|
@@ -677,12 +677,11 @@ class WholeController extends Curd
|
|
|
if ($order->order_status_payment == 'SUCCESS'){
|
|
|
OrderSheet::where('join_sheet_order_id',$params['order_id'])->update([
|
|
|
'order_sheet_status'=>$systemStatus,
|
|
|
- 'order_sheet_pay'=>$params['order_sheet_pay']+$qrcodePayAmount
|
|
|
]);
|
|
|
}
|
|
|
// payDetail
|
|
|
$payData = [
|
|
|
- 'pay_amount'=>$params['order_sheet_pay']
|
|
|
+ 'pay_amount'=>$params['order_amount_pay']
|
|
|
];
|
|
|
if ($order->order_status_payment == 'SUCCESS'){
|
|
|
$payData['pay_paytimes'] = date('Y-m-d H:i:s');
|
|
@@ -757,6 +756,11 @@ class WholeController extends Curd
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
+ // 打小票
|
|
|
+ $voteData = [
|
|
|
+ ''
|
|
|
+ ];
|
|
|
+ http_post(getenv('VOTE_MENU_URL'),'');
|
|
|
|
|
|
Db::commit();
|
|
|
|
|
@@ -834,24 +838,23 @@ class WholeController extends Curd
|
|
|
{
|
|
|
$params = $request->post();
|
|
|
|
|
|
- // 余额、福利、储值卡 验证短信
|
|
|
- if ($params['pay_constitute'] == 'N' && in_array($params['pay_category'],['CASH','CARD','WELFARE'])){
|
|
|
- $code = $params['sms_code'];
|
|
|
- if (!$code){
|
|
|
- return json_fail("验证码错误,请重新输入");
|
|
|
- }
|
|
|
- $member = Member::find($params['join_order_member_id']);
|
|
|
- $mobile = $member->member_mobile;
|
|
|
- $key = "SMS:CODE:ORDER_PAY:" . $mobile;
|
|
|
- $redisCode = Redis::get($key);
|
|
|
- if ($redisCode != $code && $code != '123456') {
|
|
|
- return json_fail("验证码错误,请重新输入");
|
|
|
- }
|
|
|
- Redis::del($key);
|
|
|
- }
|
|
|
-
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
+ // 余额、福利、储值卡 验证短信
|
|
|
+ if ($params['settlement_now'] == 'Y' && $params['pay_constitute'] == 'N' && in_array($params['pay_category'],['CASH','CARD','WELFARE'])){
|
|
|
+ $code = $params['sms_code'];
|
|
|
+ if (!$code){
|
|
|
+ return json_fail("验证码错误,请重新输入");
|
|
|
+ }
|
|
|
+ $member = Member::find($params['join_order_member_id']);
|
|
|
+ $mobile = $member->member_mobile;
|
|
|
+ $key = "SMS:CODE:ORDER_PAY:" . $mobile;
|
|
|
+ $redisCode = Redis::get($key);
|
|
|
+ if ($redisCode != $code && $code != '123456') {
|
|
|
+ return json_fail("验证码错误,请重新输入");
|
|
|
+ }
|
|
|
+ Redis::del($key);
|
|
|
+ }
|
|
|
$qrcodePayAmount = 0;
|
|
|
if (empty($params['join_order_member_id']) && !empty($params['mobile'])){
|
|
|
if (Member::where('member_mobile',$params['mobile'])->exists()){
|
|
@@ -1223,21 +1226,26 @@ class WholeController extends Curd
|
|
|
public function insertSheet($params)
|
|
|
{
|
|
|
try {
|
|
|
- $data = [
|
|
|
- 'join_sheet_member_id' => $params['join_order_member_id'],
|
|
|
- 'join_sheet_order_id' => $params['orderId'],
|
|
|
- 'join_sheet_goods_id' => $params['join_sheet_goods_id'],
|
|
|
- 'join_sheet_goods_sku_id' => $params['join_sheet_goods_sku_id'],
|
|
|
- 'order_sheet_status' => 'DONE',
|
|
|
- 'order_sheet_category' => 'NORMAL',
|
|
|
- 'order_sheet_num' => $params['order_sheet_num'],
|
|
|
- 'order_sheet_price' => $params['order_sheet_price'],
|
|
|
- 'order_sheet_amount' => $params['order_sheet_amount'],
|
|
|
- 'order_sheet_pay' => $params['order_sheet_pay'],
|
|
|
- 'order_sheet_remark' => $params['order_remark'] ?? '',
|
|
|
- 'order_sheet_addtimes' => time()
|
|
|
- ];
|
|
|
- return OrderSheet::insertGetId($data);
|
|
|
+ foreach($params['goodsContentList'] as $goods){
|
|
|
+ $price = floatval($goods['goods_sales_price']);
|
|
|
+ $data = [
|
|
|
+ 'join_sheet_member_id' => $params['join_order_member_id'],
|
|
|
+ 'join_sheet_order_id' => $params['orderId'],
|
|
|
+ 'join_sheet_goods_id' => $goods['goods_id'],
|
|
|
+ 'join_sheet_goods_sku_id' => $goods['sku_id'],
|
|
|
+ 'order_sheet_status' => $params['settlement_now'] == 'Y' ? 'DONE' : 'PAYING',
|
|
|
+ 'order_sheet_category' => 'NORMAL',
|
|
|
+ 'order_sheet_num' => $goods['nbr'],
|
|
|
+ 'order_sheet_price' => $goods['goods_sales_price'],
|
|
|
+ 'order_sheet_amount' => $price * $goods['nbr'],
|
|
|
+ 'order_sheet_pay' => $price * $goods['nbr'],
|
|
|
+ 'order_sheet_remark' => $params['order_remark'] ?? '',
|
|
|
+ 'order_sheet_addtimes' => time()
|
|
|
+ ];
|
|
|
+
|
|
|
+ OrderSheet::insertGetId($data);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
} catch (\Exception $e) {
|
|
|
throw new BusinessException('订单创建失败');
|
|
|
}
|