|
|
@@ -18,6 +18,7 @@ use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
+use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
class RechargeController extends Controller
|
|
|
{
|
|
|
@@ -41,7 +42,7 @@ class RechargeController extends Controller
|
|
|
$isEmpty = $request->isEmpty ?: 0;
|
|
|
$source = $request->source;
|
|
|
$chargeMoney = $request->chargeMoney ?: '';
|
|
|
-
|
|
|
+ $payMethod = (int)$request->input('payMethod', 0);
|
|
|
$amountSort = $request->amountSort ?: '';
|
|
|
|
|
|
$type_list = DB::table('agent.dbo.admin_configs')->where('type', 'pay')
|
|
|
@@ -72,6 +73,7 @@ class RechargeController extends Controller
|
|
|
!empty($userid) && $where[] = ['ai.GameID', '=', $userid];
|
|
|
!empty($order_sn) && $where[] = ['o.order_sn', $order_sn];
|
|
|
!empty($type) && $where[] = ['o.payment_code', $type];
|
|
|
+ !empty($payMethod) && $where[] = ['o.order_title', '=', $payMethod];
|
|
|
if(!empty($Channel) || $Channel === '0') {
|
|
|
$where[] = ['ai.Channel', $Channel];
|
|
|
}else if(count($adminChannels)<5){
|
|
|
@@ -94,16 +96,23 @@ class RechargeController extends Controller
|
|
|
|
|
|
// 支付状态
|
|
|
switch ($recharge_type) {
|
|
|
+ // 已到账
|
|
|
case 1:
|
|
|
$where[] = ['o.pay_status', '=', 1];
|
|
|
-
|
|
|
break;
|
|
|
+ // 咖啡失败(排除退款等特殊状态)
|
|
|
case 2:
|
|
|
- $where[] = ['o.pay_status', '>', 1];
|
|
|
+ $where[] = ['o.pay_status', '>=', 2];
|
|
|
+ $where[] = ['o.pay_status', '<>', 9];
|
|
|
break;
|
|
|
+ // 未支付
|
|
|
case 3:
|
|
|
$where[] = ['o.pay_status', '=', 0];
|
|
|
break;
|
|
|
+ // 退款
|
|
|
+ case 9:
|
|
|
+ $where[] = ['o.pay_status', '=', 9];
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
// 日期筛选
|
|
|
@@ -202,6 +211,8 @@ class RechargeController extends Controller
|
|
|
$val->pay_status = '已到账';
|
|
|
} elseif ($val->pay_status == 0) {
|
|
|
$val->pay_status = '未支付';
|
|
|
+ } elseif ($val->pay_status == 9) {
|
|
|
+ $val->pay_status = '退款';
|
|
|
} else {
|
|
|
$val->pay_status = '充值出错';
|
|
|
}
|
|
|
@@ -266,8 +277,17 @@ class RechargeController extends Controller
|
|
|
'401' => '转盘活动充值',
|
|
|
'402' => '圣诞活动',
|
|
|
];
|
|
|
- // 充值金额 10,50,100,200,300.500,800,1000,2000,5000,10000,20000,50000,80000,100000
|
|
|
- $chargeMoneyList = [10,20, 50, 100, 200, 500, 1000, 5000, 10000, 30000];
|
|
|
+ // 充值档位金额从充值档位配置中动态获取,并加缓存(直接使用档位原始金额)
|
|
|
+ $chargeMoneyList = Cache::remember('recharge_charge_money_list1', 600, function () {
|
|
|
+ return DB::connection('write')
|
|
|
+ ->table('agent.dbo.recharge_gear')
|
|
|
+ ->where('status', 1)
|
|
|
+ ->where('first_pay', 0)
|
|
|
+ ->groupBy('money')
|
|
|
+ ->orderBy('money')
|
|
|
+ ->pluck('money')
|
|
|
+ ->toArray();
|
|
|
+ });
|
|
|
$admin = session('admin');
|
|
|
$viewAll=1;
|
|
|
if(!in_array($admin->roles[0]->id,[1,12,2010,2011])){
|
|
|
@@ -303,6 +323,7 @@ class RechargeController extends Controller
|
|
|
'chargeMoney' => $chargeMoney,
|
|
|
'amountSort' => $amountSort,
|
|
|
'request' => $request,
|
|
|
+ 'payMethod' => $payMethod,
|
|
|
'payMethods' => [
|
|
|
1 => 'cashapp',
|
|
|
2 => 'paypal',
|
|
|
@@ -739,6 +760,52 @@ class RechargeController extends Controller
|
|
|
}
|
|
|
|
|
|
|
|
|
+ // 标记订单为退款状态
|
|
|
+ public function refund(Request $request, $id)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $admin = $request->session()->get('admin');
|
|
|
+ $roleId = $admin->roles[0]->id ?? 0;
|
|
|
+ // 仅管理员角色允许操作(与补单权限保持一致)
|
|
|
+ if (!in_array($roleId, [1, 12])) {
|
|
|
+ return apiReturnFail('无权限执行该操作');
|
|
|
+ }
|
|
|
+
|
|
|
+ $order = DB::connection('write')->table('agent.dbo.order')->where('id', $id)->lockForUpdate()->first();
|
|
|
+ if (!$order) {
|
|
|
+ return apiReturnFail('订单不存在!');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($order->pay_status == 9) {
|
|
|
+ return apiReturnFail('订单已为退款状态');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($order->pay_status != 1) {
|
|
|
+ return apiReturnFail('仅已到账订单可设置为退款状态');
|
|
|
+ }
|
|
|
+
|
|
|
+ $now = date('Y-m-d H:i:s');
|
|
|
+ $updated = DB::connection('write')->table('agent.dbo.order')
|
|
|
+ ->where('id', $id)
|
|
|
+ ->update([
|
|
|
+ 'pay_status' => 9,
|
|
|
+ 'updated_at' => $now,
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($updated === false) {
|
|
|
+ return apiReturnFail('设置退款状态失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ $admin_id = $admin->id;
|
|
|
+ (new AccountsRecordLogic())->create_record($id, $order->pay_status, 9, '', $admin_id, 2);
|
|
|
+
|
|
|
+ return apiReturnSuc();
|
|
|
+ } catch (\Exception $exception) {
|
|
|
+ return apiReturnFail($exception->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public function search($orderId)
|
|
|
{
|
|
|
|