优化支付逻辑,增加现金支付方式,修复支付状态判断
This commit is contained in:
parent
f9fa105be6
commit
adab9b2702
@ -155,6 +155,11 @@ class RetailOrderController extends BaseApiController
|
|||||||
return $this->success('余额支付成功');
|
return $this->success('余额支付成功');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PayEnum::CASH_PAY:
|
||||||
|
//现金支付
|
||||||
|
PayNotifyLogic::handle('cash_pay', $order['number']);
|
||||||
|
return $this->success('余额支付成功');
|
||||||
|
break;
|
||||||
case PayEnum::WECHAT_PAY:
|
case PayEnum::WECHAT_PAY:
|
||||||
//微信支付
|
//微信支付
|
||||||
$redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
|
$redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
|
||||||
|
@ -102,6 +102,9 @@ class OrderLogic extends BaseLogic
|
|||||||
if($params['pay_type']==PayEnum::WECHAT_PAY_BARCODE){
|
if($params['pay_type']==PayEnum::WECHAT_PAY_BARCODE){
|
||||||
$_order['source']=1;
|
$_order['source']=1;
|
||||||
}
|
}
|
||||||
|
if($params['pay_type']==PayEnum::CASH_PAY){
|
||||||
|
$_order['money']=$_order['total'];
|
||||||
|
}
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$order = Cashierclass::create($_order);
|
$order = Cashierclass::create($_order);
|
||||||
|
@ -30,6 +30,7 @@ class PayEnum
|
|||||||
* @ALIPAY_QRCODE 支付宝二维码
|
* @ALIPAY_QRCODE 支付宝二维码
|
||||||
* @GOODS_FIRST_PAYMENT_LATER 先货后款
|
* @GOODS_FIRST_PAYMENT_LATER 先货后款
|
||||||
* @CORPORATE_TRANSFER 对公转账
|
* @CORPORATE_TRANSFER 对公转账
|
||||||
|
* @CASH_PAY 现金支付
|
||||||
*/
|
*/
|
||||||
const BALANCE_PAY = 3;
|
const BALANCE_PAY = 3;
|
||||||
const WECHAT_PAY = 1;
|
const WECHAT_PAY = 1;
|
||||||
@ -47,6 +48,7 @@ class PayEnum
|
|||||||
const ALIPAY_QRCODE = 14;
|
const ALIPAY_QRCODE = 14;
|
||||||
const GOODS_FIRST_PAYMENT_LATER = 15;
|
const GOODS_FIRST_PAYMENT_LATER = 15;
|
||||||
const CORPORATE_TRANSFER = 16;
|
const CORPORATE_TRANSFER = 16;
|
||||||
|
const CASH_PAY = 17;
|
||||||
|
|
||||||
//支付状态
|
//支付状态
|
||||||
const UNPAID = 0; //未支付
|
const UNPAID = 0; //未支付
|
||||||
|
@ -202,4 +202,40 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
// ];
|
// ];
|
||||||
(new FinancialRecord())->saveAll($record);
|
(new FinancialRecord())->saveAll($record);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 现金支付
|
||||||
|
*/
|
||||||
|
public static function cash_pay($orderSn)
|
||||||
|
{
|
||||||
|
$order = Cashierclass::where('number', $orderSn)->findOrEmpty();
|
||||||
|
|
||||||
|
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$order->paid = 1;
|
||||||
|
$order->status = 2;
|
||||||
|
$order->save();
|
||||||
|
if ($order['cart_id']) {
|
||||||
|
if (!is_array($order['cart_id'])) {
|
||||||
|
$cart_arr = explode(',', $order['cart_id']);
|
||||||
|
Cart::whereIn('cart_id', $cart_arr)->update(['is_pay' => 1]);
|
||||||
|
} else {
|
||||||
|
Cart::whereIn('cart_id', $order['cart_id'])->update(['is_pay' => 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//商户获得流水
|
||||||
|
$record[] = [
|
||||||
|
'financial_record_sn' => time(),
|
||||||
|
'order_id' => $order['id'],
|
||||||
|
'number_sn' => $order['number'],
|
||||||
|
'user_id' => $order['uid'],
|
||||||
|
'financial_type' => OrderEnum::CASHIER_CASH_ORDER_PAY,
|
||||||
|
'financial_pm' => OrderEnum::INCOME,
|
||||||
|
'number' => $order['actual'],
|
||||||
|
'status' => 1,
|
||||||
|
'type' => OrderEnum::MERCHANT,
|
||||||
|
'mer_id' => $order['merchant'],
|
||||||
|
];
|
||||||
|
(new FinancialRecord())->saveAll($record);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user