This commit is contained in:
liu 2024-06-05 13:37:25 +08:00
parent 2a489b6270
commit 01f4d97494
3 changed files with 12 additions and 17 deletions

View File

@ -37,6 +37,10 @@ class PayController extends BaseApiController
PayNotifyLogic::handle('wechat_common', $ciphertext['out_trade_no'], $ciphertext); PayNotifyLogic::handle('wechat_common', $ciphertext['out_trade_no'], $ciphertext);
$app->wechat->success(); $app->wechat->success();
break; break;
case 'recharge':
PayNotifyLogic::handle('recharge', $ciphertext['out_trade_no'], $ciphertext);
$app->wechat->success();
break;
} }
} }
} }

View File

@ -72,7 +72,7 @@ class UserController extends BaseApiController
$params['channel_type'] = $this->userInfo['terminal']; $params['channel_type'] = $this->userInfo['terminal'];
$order = UserLogic::recharge($params); $order = UserLogic::recharge($params);
$redirectUrl = $params['redirect'] ?? '/pages/payment/payment'; $redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
$result = PaymentLogic::pay(PayEnum::WECHAT_PAY, 'StoreOrder', $order, $this->userInfo['terminal'], $redirectUrl); $result = PaymentLogic::pay(PayEnum::WECHAT_PAY, 'recharge', $order, $this->userInfo['terminal'], $redirectUrl);
if (PaymentLogic::hasError()) { if (PaymentLogic::hasError()) {
return $this->fail(PaymentLogic::getError(), $params); return $this->fail(PaymentLogic::getError(), $params);
} }

View File

@ -8,6 +8,7 @@ use app\common\model\pay\PayNotify;
use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\store_finance_flow\StoreFinanceFlow;
use app\common\model\store_order\StoreOrder; use app\common\model\store_order\StoreOrder;
use app\common\model\user\User; use app\common\model\user\User;
use app\common\model\user\UserRecharge;
use app\common\service\PushService; use app\common\service\PushService;
use support\Log; use support\Log;
use think\facade\Db; use think\facade\Db;
@ -107,26 +108,16 @@ class PayNotifyLogic extends BaseLogic
} }
public static function store_order($orderSn, $extra = []) public static function recharge($orderSn, $extra = [])
{ {
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty(); $order = UserRecharge::where('order_id', $orderSn)->findOrEmpty();
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) { if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
return true; return true;
} }
if ($order->pay_type != 10) { $order->price = bcdiv($extra['amount']['payer_total'], 100, 2);
$order->pay_price = bcdiv($extra['amount']['payer_total'], 100, 2); $order->paid = 1;
$order->paid = 1; $order->pay_time = time();
$order->pay_time = time(); $order->save();
$order->status = 1;
$order->save();
} else {
$extra['transaction_id'] = time();
}
if ($order->pay_type == 9) {
$order->status = 2;
}
self::afterPay($order);
return true; return true;
} }