Browse Source

咖啡档位选择兼容

咖啡列表查询丰富
Tree 2 days ago
parent
commit
d38d3deba9

+ 72 - 5
app/Http/Controllers/Admin/RechargeController.php

@@ -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)
     {
 

+ 0 - 21
app/Services/PayMentService.php

@@ -111,27 +111,6 @@ class PayMentService
      */
     public static function getServiceByPayMethod($method, $payAmt,$pay_method)
     {
-//        $except_configKeys=[$except_channelName];
-//        $switch = Redis::get("recharge_config_switch_{$channel}");
-//        if ($channel && $switch) {
-//            $services = DB::connection('write')
-//                          ->table('QPPlatformDB.dbo.ChannelOpenRecharge')
-//                          ->join(
-//                              'agent.dbo.admin_configs',
-//                              'admin_configs.id',
-//                              '=',
-//                              'ChannelOpenRecharge.ConfigID'
-//                          )
-//                          ->where('admin_configs.new_pay_type', $method)
-//                          ->whereNotIn('admin_configs.config_key',$except_configKeys)
-//                          ->where('admin_configs.type', 'pay')
-//                          ->where('admin_configs.status', 1)
-//                          ->where('ChannelOpenRecharge.Status', 1)
-//                          ->where('ChannelOpenRecharge.Channel', $channel)
-//                          ->where('ChannelOpenRecharge.Sort', '>', 0)
-//                          ->selectRaw('admin_configs.config_key, ChannelOpenRecharge.Sort as sort')
-//                          ->get();
-//        }
         $services = DB::table('agent.dbo.admin_configs')->where([
             'new_pay_type' => $method,
             'type' => 'pay',

+ 32 - 12
resources/views/admin/recharge/list.blade.php

@@ -52,6 +52,9 @@
                                             <option value="3" @if ($recharge_type == 3) selected
 
                                                 @endif>{{ __('auto.未支付') }}
+                                            <option value="9" @if ($recharge_type == 9) selected
+
+                                                @endif>{{ __('auto.退款') }}
                                             </option>
                                         </select>&nbsp;
 
@@ -65,17 +68,6 @@
 
                                         </select>
 
-                                        <span style="padding-left: 10px">{{ __('auto.选择创建时间:') }}</span>
-                                        <select class="form-control" name="date" style="color: black">
-                                            <option value="">{{ __('auto.选择时间') }}</option>
-                                            @foreach($dates as $key=>$val)
-                                                <option value="{{$key}}" @if ($key == $date)
-                                                selected
-                                                    @endif>{{$val}}</option>
-                                            @endforeach
-
-                                        </select>&nbsp;&nbsp;
-
                                         <span style="padding-left: 10px">{{ __('auto.咖啡渠道:') }}</span>
                                         <select class="form-control" name="type" value="{{$type}}" style="color: black">
                                             <option value="">{{ __('auto.选择类别') }}</option>
@@ -83,6 +75,14 @@
                                                 <option value="{{$v}}" @if($v==$type) selected @endif>{{$v}}</option>
                                             @endforeach
                                         </select>
+                                        
+                                        <span style="padding-left: 10px">支付渠道:</span>
+                                        <select class="form-control" name="payMethod" value="{{$payMethod}}" style="color: black">
+                                            <option value="">{{ __('auto.选择类别') }}</option>
+                                            @foreach($payMethods as $methodValue => $methodName)
+                                                <option value="{{$methodValue}}" @if($methodValue == $payMethod) selected @endif>{{$methodName}}</option>
+                                            @endforeach
+                                        </select>
                                     </div>
                                     <div class="form-group">
                                         <span style="padding-left: 10px">{{ __('auto.选择支付时间') }}({{ __('auto.当地') }}):</span>
@@ -139,7 +139,7 @@
                                         <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                                         <a href="?isEmpty=1"
                                            class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>&nbsp;&nbsp;
-                                        <a href="?excel=1&start_time={{$start_time}}&end_time={{$end_time}}&recharge_type={{$recharge_type}}&UserID={{$UserID}}&type={{$type}}&order={{$order}}&date={{$date}}&create_start_time={{$create_start_time}}&create_end_time={{$create_end_time}}&isEmpty=1"
+                                        <a href="?excel=1&start_time={{$start_time}}&end_time={{$end_time}}&recharge_type={{$recharge_type}}&UserID={{$UserID}}&type={{$type}}&order={{$order}}&date={{$date}}&create_start_time={{$create_start_time}}&create_end_time={{$create_end_time}}&isEmpty=1&source={{$source}}&chargeMoney={{$chargeMoney}}&payMethod={{$payMethod}}"
                                            class="btn btn-sm btn-gradient-light btn-icon-text">{{ __('auto.导出') }}</a>
                                     </div>
                                 </div>
@@ -236,6 +236,8 @@
                                         <td>
                                             @if ($v->pay_status  == 1)
                                                 <span style="color: #0b2e13">{{ __('auto.已到账') }}</span>
+                                            @elseif($v->pay_status == 9)
+                                                <span style="color: #ff9800">{{ __('auto.退款') }}</span>
                                             @elseif($v->pay_status == 0)
                                                 <span>{{ __('auto.未支付') }}</span>
                                             @else
@@ -252,6 +254,11 @@
                                                         onclick="supplement({{$v->id}})">{{ __('auto.补单') }}
                                                 </button>
                                             @endif
+                                            @if (in_array(session('admin')->roles[0]->id,[1,12])&&$v->pay_status == 1)
+                                                <button type="button" class="btn-sm btn-warning"
+                                                        onclick="setRefund({{$v->id}})">{{ __('auto.标记退款') }}
+                                                </button>
+                                            @endif
                                         </td>
                                         <td contentEditable="true"
                                             onblur="remarks(this,{{$v->id}})">{{$v->ar_remarks}}</td>
@@ -281,6 +288,7 @@
     'register_end_time' => $register_end_time,
     'source' => $source,
     'chargeMoney' => $chargeMoney,
+    'payMethod' => $payMethod,
     'amountSort' => $amountSort
 
     ])->total() }}</b>
@@ -311,6 +319,7 @@
             'register_end_time' :'{{$register_end_time}}',
             'source' : '{{$source}}',
             'chargeMoney' : '{{$chargeMoney}}',
+            'payMethod' : '{{$payMethod}}',
         }
 
         function start_times(id) {
@@ -400,6 +409,17 @@
             });
         }
 
+        function setRefund(id) {
+            myConfirm("{{ __('auto.操作不可逆,是否继续') }}?", function () {
+                myRequest("/admin/recharge/refund/" + id, "post", {}, function (res) {
+                    layer.msg(res.msg)
+                    setTimeout(function () {
+                        window.location.reload();
+                    }, 1500)
+                });
+            });
+        }
+
 
         $(function () {
             cutStr(50);

+ 2 - 0
routes/web.php

@@ -232,6 +232,8 @@ Route::group([
 
         /*补单*/
         $route->post('/recharge/supplement/{id}', 'Admin\RechargeController@supplement');
+        // 充值订单退款
+        $route->post('/recharge/refund/{id}', 'Admin\RechargeController@refund');
         $route->get('/recharge/first_charge', 'Admin\RechargeController@firstCharge');
         $route->get('/recharge/first_charge_status', 'Admin\RechargeController@firstChargeStatus');
         $route->any('/recharge/poll', 'Admin\RechargeController@poll');