From 5719c542eb2386031b49d471b9607be2e1948294 Mon Sep 17 00:00:00 2001 From: chuan <2154243450@qq.com> Date: Mon, 16 Jun 2025 21:55:55 +0800 Subject: [PATCH] up --- app/admin/service/RechargeService.php | 1 + app/home/controller/Pay.php | 18 +- app/home/route/app.php | 42 +-- app/home/service/PayService.php | 463 +++++++++++++++----------- app/model/RechargeApplyModel.php | 2 +- 5 files changed, 300 insertions(+), 226 deletions(-) diff --git a/app/admin/service/RechargeService.php b/app/admin/service/RechargeService.php index 56b7523f..a05f22df 100644 --- a/app/admin/service/RechargeService.php +++ b/app/admin/service/RechargeService.php @@ -146,6 +146,7 @@ class RechargeService extends AdminBaseService $result = $this->updateUserAsset($info['user_id'], $info['account_type'], 1, $info['market_amount'], 0, $info['order_no']); if ($result['status'] == 200) { RechargeApplyModel::where('id', $info['id'])->update([ + 'real_amount' => $param['real_amount'] ?? 0, // 实际到账金额,审核时候运营人员手动输入的 'is_check' => 1, 'status' => 1, 'deal_time' => date('Y-m-d H:i:s') diff --git a/app/home/controller/Pay.php b/app/home/controller/Pay.php index 1d432de8..3a8d51d1 100644 --- a/app/home/controller/Pay.php +++ b/app/home/controller/Pay.php @@ -39,6 +39,8 @@ class Pay extends HomeBaseController */ public function rechargeApply(Request $request): Json { + $data['recharge_type'] = $request->post('recharge_type', 0); // 支付方式:1-数字币方式充值; 2-支付码方式充值(以前叫银行卡); + $data['payment_code_config_log_id'] = $request->post('payment_code_config_log_id', 0); // 如果是支付码方式充值,需要上传该参数,payment_code_config表的主键ID $data['user_id'] = $request->userId; $data['account_type'] = $request->post('account_type'); $data['country'] = $request->post('country'); @@ -48,7 +50,7 @@ class Pay extends HomeBaseController $data['file_id'] = $request->post('file_id', 0); $data['product'] = $request->post('product', ''); $data['extra'] = $request->post('extra', ''); - $data['amount_range'] = $request->post('amount_range', ""); // 支付的金额范围 + $result = (new PayService())->insertRechargeApply($data); return json($result); } @@ -60,6 +62,20 @@ class Pay extends HomeBaseController return json($result); } + // 创建用户的支付码配置下单记录 + public function AddUserPaymentCodeLog() + { + $result = (new PayService())->AddUserPaymentCodeLog($this->request->userId, $this->request->post()); + return json($result); + } + + // 前端通过轮询查询最近一次提交的充值范围订单记录 + public function GetLatestUserPaymentCodeLog() + { + $result = (new PayService())->GetLatestUserPaymentCodeLog($this->request->userId, $this->request->post()); + return json($result); + } + // 获取用户的支付码配置下单记录 public function getUserPaymentCodeLog() { diff --git a/app/home/route/app.php b/app/home/route/app.php index d8c1d9f7..35350985 100644 --- a/app/home/route/app.php +++ b/app/home/route/app.php @@ -41,13 +41,18 @@ Route::group('/',function (){ Route::post('/forget_sms', 'Login/resetPasswordBySms'); // 手机号密码登陆 Route::post('/phone_login', 'Login/phoneLogin'); - // 获取配置 Route::post('/get_config', 'Upload/getConfig'); Route::post('/get_config_by_key', 'Config/getConfigByKey'); // 获取指定keyd的配置 })->middleware(\app\home\middleware\RepeatOperateMiddleware::class); + Route::post('test', 'News/testApi'); + Route::post('get_ip', 'Login/getIP'); + Route::get('get_news', 'News/index'); + + Route::post('video/blocked_word_list', 'Video/blockedWordList'); //获取屏蔽词列表 + // Pusher推送通知 Route::get('notice/generate_token', 'Notice/generateToken'); // 生成Beams身份验证令牌,该令牌有效期24小时 @@ -121,7 +126,6 @@ Route::group('/',function (){ Route::post('starpay_notify', 'Pay/starPayNotify')->name('starpay_notify'); //充值通知接口 Route::post('starpay_ApplyNotify', 'Pay/ClickPayApplyNotify')->name('starpay_appNotify'); //充值通知接口 - Route::post('payment_test', 'Pay/test'); Route::post('bank_list', 'Pay/BankList'); @@ -129,6 +133,14 @@ Route::group('/',function (){ // 上传图片 Route::post('upload_header', 'Upload/uploadHeaderImage'); + // 美股申购列表 不需要登陆 + Route::post('pre_stock/index', 'PreStock/index'); + Route::post('pre_stock/stock_detail', 'PreStock/stockDetail'); + + //基金 + Route::post('fund/index', 'Fund/index'); + Route::post('auto_login', 'Login/autoLogin'); + // 需要登陆的操作 Route::group('/',function (){ // 需要防止重复操作的路由 @@ -177,18 +189,13 @@ Route::group('/',function (){ // 绑定手机号 Route::post('user/bind_phone', 'User/bindPhone'); Route::post('user/update_phone', 'User/updatePhone'); - // 新增实名认证 Route::post('user_verify/add', 'UserVerify/add'); - - + Route::post('user_verify/detail', 'UserVerify/detail'); })->middleware(\app\home\middleware\RepeatOperateMiddleware::class); Route::post('notice/pusher_log', 'Notice/pusherLog'); - // 新增实名认证 - Route::post('user_verify/detail', 'UserVerify/detail'); - // 获取时间 Route::post('user/get_time', 'User/getTime'); // 获取用户基础信息 @@ -211,6 +218,8 @@ Route::group('/',function (){ Route::post('payment_list', 'Pay/payChannel'); //获取充值渠道 Route::post('user_recharge', 'Pay/rechargeApply')->middleware(\app\home\middleware\RepeatOperateMiddleware::class); // 用户提交充值订单 Route::get('get_payment_code_list', 'Pay/getPaymentCodeList'); // 获取支付码配置列表 + Route::post('add_user_payment_code_log', 'Pay/AddUserPaymentCodeLog'); // 创建用户在支付码配置方式下充值订单记录 + Route::post('get_latest_user_payment_code_log', 'Pay/GetLatestUserPaymentCodeLog'); // 前端轮询查询一条用户最近提交的充值范围订单 Route::post('get_user_payment_code_log', 'Pay/getUserPaymentCodeLog'); // 获取用户在支付码配置方式下充值订单记录 Route::post('user_assets', 'Wallet/getAllAssets'); // 获取用户所有资产列表数据 @@ -258,7 +267,6 @@ Route::group('/',function (){ Route::post('apply_test_money', 'User/applyTestMoney'); - // 股票申购 Route::post('pre_stock/order', 'PreStock/order')->middleware(\app\home\middleware\RepeatOperateMiddleware::class); // 新股下单 防止重复操作 Route::post('pre_stock/post_pay', 'PreStock/postPay')->middleware(\app\home\middleware\RepeatOperateMiddleware::class); // 新股下单后支付 - 订单支付 @@ -288,25 +296,9 @@ Route::group('/',function (){ // 视频点播相关 Route::post('video/video_on_demand_list', 'Video/videoOnDemandList'); // 获取视频点播列表 Route::post('video/video_on_demand_detail', 'Video/videoOnDemandDetail'); // 获取某个点播配置详情 - Route::post('video/blocked_word_list', 'Video/blockedWordList'); //获取屏蔽词列表 Route::post('stock/stock_analysis', 'Stock/stockAnalysis'); // 股票分析 - - })->middleware(\app\home\middleware\AuthMiddleware::class); - // 美股申购列表 不需要登陆 - Route::post('pre_stock/index', 'PreStock/index'); - Route::post('pre_stock/stock_detail', 'PreStock/stockDetail'); - - //基金 - Route::post('fund/index', 'Fund/index'); - Route::post('auto_login', 'Login/autoLogin'); - - Route::post('get_ip', 'Login/getIP'); - Route::get('get_news', 'News/index'); - Route::post('test', 'News/testApi'); - Route::post('test_api', 'Document/informationArticleList'); - })->allowCrossDomain($header); diff --git a/app/home/service/PayService.php b/app/home/service/PayService.php index 1695e7fc..67d961dc 100644 --- a/app/home/service/PayService.php +++ b/app/home/service/PayService.php @@ -7,11 +7,7 @@ use app\model\PaymentCodeLogModel; use app\model\PaymentListModel; use app\model\RechargeApplyModel; use app\model\StockMarketModel; -use app\model\UserModel; -use app\model\UserWithdrawalModel; -use app\model\WalletListModel; use think\facade\Db; -use think\facade\Log; /** * 处理团队佣金业务 @@ -38,230 +34,254 @@ class PayService extends BaseHomeService } /** - * 用户充值申请入库1 + * 用户充值申请入库 * @param array $data * @return array */ public function insertRechargeApply(array $data): array { - $channel = PaymentListModel::getPaymentInfo([ - 'id' => $data['recharge_channel'] - ]); - - if (empty($channel)) { - return $this->toData('100110', 'The system is busy. Please try again later.1', []); + // 判断支付方式,目前只有两种方式:1-支付码方式充值; 2-数字币方式充值 + if (!in_array($data['recharge_type'], [1, 2])) { + return $this->toData('500', 'Parameter recharge_type is incorrect'); } - if (empty($data['country'])) { - return $this->toData('100120', 'The system is busy. Please try again later.2', []); + // 必要参数检测 + if (!isset($data['account_type'])) { + return $this->toData('500', 'Parameter account_type is incorrect'); } - if (empty($data['recharge_num']) || $data['recharge_num'] <= 0) { - return $this->toData('100130', 'The system is busy. Please try again later.3', []); + + // 生成订单号 + $data['order_no'] = $this->generateOrderNumber(); + + // 2-支付码方式充值 + if ($data['recharge_type'] == 2) { + // 如果是支付码方式充值,需要上传该参数,该参数值是payment_code_config表的主键ID + if (empty($data['payment_code_config_log_id'])) { + return $this->toData('500', 'Parameter payment_code_config_id is messing'); + } + // 创建订单 + $orderData = RechargeApplyModel::create([ + 'user_id' => $data['user_id'], + 'account_type' => $data['account_type'], + 'recharge_type' => $data['recharge_type'], + 'recharge_num' => $data['recharge_num'], + 'status' => 0, + 'order_no' => $data['order_no'], + 'create_time' => date('Y-m-d H:i:s'), + 'update_time' => date('Y-m-d H:i:s'), + 'is_online' => 1, + 'is_check' => 0, + 'real_amount' => 0, + ]); + // 修改支付码预下单记录表,将实际充值的订单号关联到用户充值上一步的预下单记录中 + PaymentCodeLogModel::where('id', $data['payment_code_config_log_id'])->update([ + 'recharge_apply_id' => $orderData->id, + 'recharge_amount' => $data['recharge_num'] + ]); + return $this->toData('0', 'successful'); } - if($channel['type']==9){ - //1USD=1USDT - $currency_rate = 1; - if($data['product']=='TRC20Buy'){ - switch ($data['extra']){ - case 'GBP': - $gpx_rate=StockMarketModel::where('stock_market_type',14)->value('rate'); - $currency_rate=$gpx_rate/100; - break; - case "EUR": - $eur_rate=StockMarketModel::where('stock_market_type',15)->value('rate'); - $currency_rate=$eur_rate*1; - break; + + // 1-数字币方式充值 + if ($data['recharge_type'] == 1) { + $channel = PaymentListModel::getPaymentInfo([ + 'id' => $data['recharge_channel'] + ]); + if (empty($channel)) { + return $this->toData('500', 'channel error'); + } + if (empty($data['recharge_num']) || $data['recharge_num'] <= 0) { + return $this->toData('100130', 'recharge_num error'); + } + if($channel['type']==9){ + $currency_rate = 1; + if($data['product']=='TRC20Buy'){ + switch ($data['extra']){ + case 'GBP': + $gpx_rate=StockMarketModel::where('stock_market_type',14)->value('rate'); + $currency_rate=$gpx_rate/100; + break; + case "EUR": + $eur_rate=StockMarketModel::where('stock_market_type',15)->value('rate'); + $currency_rate=$eur_rate*1; + break; + } } + }else{ + $currency_rate = $channel['exchange_rate']; } - }else{ - $currency_rate = $channel['exchange_rate']; - } - //$currency_rate=(new StockMarketModel)->getRate(4); - if ($data['account_type'] > 2 && ($data['account_type'] != 8)) { - $market_rate = (new StockMarketModel)->getRate($data['account_type']); - } else { - $market_rate = 1; - } - $market_amount = $data['recharge_num'] * $market_rate; - $market_amount = round($market_amount, 2); - if ($channel['pay_type'] == 1) { - $fee = $data['recharge_num'] * $currency_rate * $channel['service_rate']; - $server_fee = $market_amount * $channel['service_rate']; - } else { - $fee = $currency_rate * $channel['service_rate']; - $server_fee = $market_rate * $channel['service_rate']; - } - $total_amount = $data['recharge_num'] * $currency_rate + $fee; - $total_amount = round($total_amount, 2); + if ($data['account_type'] > 2 && ($data['account_type'] != 8)) { + $market_rate = (new StockMarketModel)->getRate($data['account_type']); + } else { + $market_rate = 1; + } + $market_amount = $data['recharge_num'] * $market_rate; + $market_amount = round($market_amount, 2); - if ($data['is_online'] == 1 && $total_amount > 100000) { - return $this->toData('101900', 'Online payment scope: 100 - 100000'); - } - $data['service_fee'] = $server_fee;//手续费用 - $data['market_amount'] = $market_amount; //换算的市场金额 - $data['total_amount'] = $total_amount; //要支付的渠道货币金额 - $data['currency_rate'] = $currency_rate; - if ($channel['channel_type'] == 'Bank') { - $data['recharge_type'] = 2; - // p2新增,如果是银行卡充值需要添加支付码配置的充值记录 - if (empty($data['amount_range'])) { - return $this->toData('500', '缺少充值金额范围参数'); + if ($channel['pay_type'] == 1) { + $fee = $data['recharge_num'] * $currency_rate * $channel['service_rate']; + $server_fee = $market_amount * $channel['service_rate']; + } else { + $fee = $currency_rate * $channel['service_rate']; + $server_fee = $market_rate * $channel['service_rate']; } - } else { - $data['recharge_type'] = 1; - } + $total_amount = $data['recharge_num'] * $currency_rate + $fee; + $total_amount = round($total_amount, 2); - $data['order_no'] = $this->generateOrderNumber(); + if ($data['is_online'] == 1 && $total_amount > 100000) { + return $this->toData('101900', 'Online payment scope: 100 - 100000'); + } - $order_id = RechargeApplyModel::InsertUserRecharge($data); - if ($order_id) { - // p2新增功能,如果是银行卡充值,添加支付码充值记录 + $data['service_fee'] = $server_fee;//手续费用 + $data['market_amount'] = $market_amount; //换算的市场金额 + $data['total_amount'] = $total_amount; //要支付的渠道货币金额 + $data['currency_rate'] = $currency_rate; if ($channel['channel_type'] == 'Bank') { - Db::table("bot_payment_code_log")->insert([ - 'recharge_apply_id' => $order_id, - 'user_id' => $data['user_id'], - 'amount_range' => $data['amount_range'], - 'recharge_amount' => $data['recharge_num'], - 'payment_status' => 0, - ]); + $data['recharge_type'] = 2; + } else { + $data['recharge_type'] = 1; } - switch ($channel['type']) { - case 2: - $result = (new IndPayService())->indPay($data['order_no'], $data['total_amount']); - if ($result['status'] == 'SUCCESS') { - RechargeApplyModel::where('order_no', $data['order_no'])->update([ - 'order_idx' => $result['order_no'], - 'pay_url' => $result['order_data'], - ]); - return $this->toData(0, 'Request successful.', [ - 'type' => 'bank_pay', - 'pay_url' => $result['order_data'], - 'order_no' => $result['mer_order_no'], - ]); - } else { - return $this->toData('100900', 'The system is busy. Please try again later.4', [$result['err_msg'], $result['err_code']]); - } - break; - case 3: - $result = (new MoPayService())->create_order($data['order_no'], $data['total_amount']); - if ($result['status'] == 'SUCCESS') { - RechargeApplyModel::where('order_no', $data['order_no'])->update([ - 'pay_url' => $result['data']['pay_url'], - ]); - return $this->toData(0, 'Request successful.', [ - 'type' => 'bank_pay', - 'pay_url' => $result['data']['pay_url'], - 'order_no' => $data['order_no'], - ]); - } else { - return $this->toData('100600', 'The system is busy. Please try again later.5', [$result['err_msg'], $result['err_code']]); - } - break; - case 4: - $result = (new HTPayService())->qrPay($data['order_no'], round($data['total_amount'])); - if ($result['status'] == 1) { - RechargeApplyModel::where('order_no', $data['order_no'])->update([ - 'order_idx' => $result['orderNo'], - 'pay_url' => $result['payUrl'], - 'total_amount' => $result['oriAmount'] - ]); - return $this->toData(0, 'Request successful.', [ - 'type' => 'bank_pay', - 'pay_url' => $result['payUrl'], - 'order_no' => $data['order_no'], - ]); + $order_id = RechargeApplyModel::InsertUserRecharge($data); + if ($order_id) { + switch ($channel['type']) { + case 2: + $result = (new IndPayService())->indPay($data['order_no'], $data['total_amount']); + if ($result['status'] == 'SUCCESS') { + RechargeApplyModel::where('order_no', $data['order_no'])->update([ + 'order_idx' => $result['order_no'], + 'pay_url' => $result['order_data'], + ]); + return $this->toData(0, 'Request successful.', [ + 'type' => 'bank_pay', + 'pay_url' => $result['order_data'], + 'order_no' => $result['mer_order_no'], + ]); + } else { + return $this->toData('100900', 'The system is busy. Please try again later.4', [$result['err_msg'], $result['err_code']]); + } + break; + case 3: + $result = (new MoPayService())->create_order($data['order_no'], $data['total_amount']); + if ($result['status'] == 'SUCCESS') { + RechargeApplyModel::where('order_no', $data['order_no'])->update([ + 'pay_url' => $result['data']['pay_url'], + ]); + return $this->toData(0, 'Request successful.', [ + 'type' => 'bank_pay', + 'pay_url' => $result['data']['pay_url'], + 'order_no' => $data['order_no'], + ]); + } else { + return $this->toData('100600', 'The system is busy. Please try again later.5', [$result['err_msg'], $result['err_code']]); + } + break; + case 4: + $result = (new HTPayService())->qrPay($data['order_no'], round($data['total_amount'])); + if ($result['status'] == 1) { + RechargeApplyModel::where('order_no', $data['order_no'])->update([ + 'order_idx' => $result['orderNo'], + 'pay_url' => $result['payUrl'], + 'total_amount' => $result['oriAmount'] + ]); + return $this->toData(0, 'Request successful.', [ + 'type' => 'bank_pay', + 'pay_url' => $result['payUrl'], + 'order_no' => $data['order_no'], + ]); - } else { - return $this->toData('101900', 'The system is busy. Please try again later.6', [$result['status'], $result['message']]); - } - break; - case 5: - $result = (new XdPayService())->create_order($data['order_no'], $data['total_amount']); - if ($result['code'] == 200) { - RechargeApplyModel::where('order_no', $data['order_no'])->update([ - 'pay_url' => $result['data']['url'], - ]); - return $this->toData(0, 'Request successful.', [ - 'type' => 'bank_pay', - 'pay_url' => $result['data']['url'], - 'order_no' => $data['order_no'], - ]); - } else { - return $this->toData('101900', 'The system is busy. Please try again later.7', [$result['code'], $result['msg']]); - } - break; - case 6: - $result = (new QeaePayService())->create_order($data['order_no'], $data['total_amount']); - if ($result['respCode'] == 'SUCCESS') { - RechargeApplyModel::where('order_no', $data['order_no'])->update([ - 'pay_url' => $result['payInfo'], - ]); - return $this->toData(0, 'Request successful.', [ - 'type' => 'bank_pay', - 'pay_url' => $result['payInfo'], - 'order_no' => $data['order_no'], - ]); - } else { - return $this->toData('101900', 'The system is busy. Please try again later.8', [$result['respCode'], $result['tradeMsg']]); - } - break; - case 7: - $result = (new NicePayService())->create_order($data['order_no'], $data['total_amount']); - if ($result['err'] == 0 && !empty($result)) { - RechargeApplyModel::where('order_no', $data['order_no'])->update([ - 'pay_url' => $result['url'], - ]); - return $this->toData(0, 'Request successful.', [ - 'type' => 'bank_pay', - 'pay_url' => $result['url'], - 'order_no' => $data['order_no'], - ]); - } else { - return $this->toData('101900', 'The system is busy. Please try again later.9', [$result['err'], $result['err_msg']]); - } - break; - case 8: - $result = (new ClickPayService())->create_order($data['order_no'], $data['total_amount']); - if (strtoupper($result['platRespCode']) == 'SUCCESS') { - RechargeApplyModel::where('order_no', $data['order_no'])->update([ - 'order_idx' => $result['platOrderNum'], - ]); - return $this->toData(0, 'Request successful.', [ - 'type' => 'bank_pay', - 'pay_url' => $result['payData'], - 'order_no' => $data['order_no'], - ]); - } else { - return $this->toData('101900', 'The system is busy. Please try again later.10'); - } - break; - case 9: - if(in_array(trim($data['product']),['TRC20H5','TRC20Buy'])){ - $result = (new StarPayService())->create_order($data['order_no'], $data['total_amount'],$data['product'],$data['extra']); + } else { + return $this->toData('101900', 'The system is busy. Please try again later.6', [$result['status'], $result['message']]); + } + break; + case 5: + $result = (new XdPayService())->create_order($data['order_no'], $data['total_amount']); if ($result['code'] == 200) { - $respon=json_decode($result['params'],true); RechargeApplyModel::where('order_no', $data['order_no'])->update([ - 'pay_url' => $respon['payurl'], + 'pay_url' => $result['data']['url'], ]); return $this->toData(0, 'Request successful.', [ 'type' => 'bank_pay', - 'pay_url' => $respon['payurl'], + 'pay_url' => $result['data']['url'], 'order_no' => $data['order_no'], ]); } else { - return $this->toData('100600', 'The system is busy. Please try again later.5', $result); + return $this->toData('101900', 'The system is busy. Please try again later.7', [$result['code'], $result['msg']]); } - }else{ - return $this->toData('102000', 'The system is busy. Please try again later.20'); - } - break; - default: - return $this->toData(0, 'Request successful.', []); - break; + break; + case 6: + $result = (new QeaePayService())->create_order($data['order_no'], $data['total_amount']); + if ($result['respCode'] == 'SUCCESS') { + RechargeApplyModel::where('order_no', $data['order_no'])->update([ + 'pay_url' => $result['payInfo'], + ]); + return $this->toData(0, 'Request successful.', [ + 'type' => 'bank_pay', + 'pay_url' => $result['payInfo'], + 'order_no' => $data['order_no'], + ]); + } else { + return $this->toData('101900', 'The system is busy. Please try again later.8', [$result['respCode'], $result['tradeMsg']]); + } + break; + case 7: + $result = (new NicePayService())->create_order($data['order_no'], $data['total_amount']); + if ($result['err'] == 0 && !empty($result)) { + RechargeApplyModel::where('order_no', $data['order_no'])->update([ + 'pay_url' => $result['url'], + ]); + return $this->toData(0, 'Request successful.', [ + 'type' => 'bank_pay', + 'pay_url' => $result['url'], + 'order_no' => $data['order_no'], + ]); + } else { + return $this->toData('101900', 'The system is busy. Please try again later.9', [$result['err'], $result['err_msg']]); + } + break; + case 8: + $result = (new ClickPayService())->create_order($data['order_no'], $data['total_amount']); + if (strtoupper($result['platRespCode']) == 'SUCCESS') { + RechargeApplyModel::where('order_no', $data['order_no'])->update([ + 'order_idx' => $result['platOrderNum'], + ]); + return $this->toData(0, 'Request successful.', [ + 'type' => 'bank_pay', + 'pay_url' => $result['payData'], + 'order_no' => $data['order_no'], + ]); + } else { + return $this->toData('101900', 'The system is busy. Please try again later.10'); + } + break; + case 9: + if(in_array(trim($data['product']),['TRC20H5','TRC20Buy'])){ + $result = (new StarPayService())->create_order($data['order_no'], $data['total_amount'],$data['product'],$data['extra']); + if ($result['code'] == 200) { + $respon=json_decode($result['params'],true); + RechargeApplyModel::where('order_no', $data['order_no'])->update([ + 'pay_url' => $respon['payurl'], + ]); + return $this->toData(0, 'Request successful.', [ + 'type' => 'bank_pay', + 'pay_url' => $respon['payurl'], + 'order_no' => $data['order_no'], + ]); + } else { + return $this->toData('100600', 'The system is busy. Please try again later.5', $result); + } + }else{ + return $this->toData('102000', 'The system is busy. Please try again later.20'); + } + break; + default: + return $this->toData(0, 'Request successful.', []); + } + } else { + return $this->toData(500, lang('system_busy')); } - } else { - return $this->toData(500, lang('system_busy')); } + + // 没有匹配到支付方式,异常错误 + return $this->toData('500', 'system_busy'); } // 获取支付码配置列表 @@ -275,6 +295,51 @@ class PayService extends BaseHomeService } } + // 创建用户支付码配置下单记录 + public function AddUserPaymentCodeLog($userID, $param) + { + try { + if (empty($param['amount_range'])) { + return $this->toData('400', '参错错误'); + } + Db::table("bot_payment_code_log")->insert([ + 'recharge_apply_id' => 0, + 'user_id' => $userID, + 'amount_range' => $param['amount_range'], + 'payment_status' => 0, + ]); + return $this->toData('0', 'SUCCESS', []); + } catch (\Exception $e) { + return $this->toData(500, lang('system_busy'), [$e->getMessage(), $e->getTrace()]); + } + } + + // 前端通过轮询查询用户最近一次提交的冲值范围订单信息‘ + public function GetLatestUserPaymentCodeLog($userID, $param) + { + try { + if (empty($param['amount_range'])) { + return $this->toData('400', '参错错误'); + } + $info = PaymentCodeLogModel::where(['user_id'=>$userID,'amount_range'=>$param['amount_range']])->order("id", "desc")->find(); + if (empty($info)) { + return $this->toData('500', '数据不存在'); + } + $info = $info->toArray(); + $info['qr_code'] = ''; + if (!empty($info['payment_code_config_id'])) { + $paymentCodeConfig = PaymentCodeConfigModel::where(['id'=>$info['payment_code_config_id']])->find(); + if (!empty($paymentCodeConfig)) { + $info['qr_code'] = $paymentCodeConfig->qr_code; + } + } + + return $this->toData('0', 'SUCCESS', $info); + } catch (\Exception $e) { + return $this->toData(500, lang('system_busy'), [$e->getMessage(), $e->getTrace()]); + } + } + // 获取用户的支付码配置下单记录 public function getUserPaymentCodeLog($userID, $param) { diff --git a/app/model/RechargeApplyModel.php b/app/model/RechargeApplyModel.php index 9a795353..c591a5ca 100644 --- a/app/model/RechargeApplyModel.php +++ b/app/model/RechargeApplyModel.php @@ -44,7 +44,7 @@ class RechargeApplyModel extends BaseModel $data['page_size']=10; } $count= self::where($where)->count(); - $list = self::where($where)->field('account_type,market_amount as recharge_num,status,order_no,recharge_type,recharge_channel,service_fee,create_time') + $list = self::where($where)->field('account_type,market_amount as recharge_num,status,order_no,recharge_type,recharge_channel,service_fee,create_time,real_amount') ->order('id desc')->page($data['page'],$data['page_size'])->select(); if(empty($list)){ return [];