RechargeController.php 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\AdminConfig;
  4. use App\Facade\TableName;
  5. use App\Http\Controllers\Controller;
  6. use App\Http\helper\NumConfig;
  7. use App\Http\logic\admin\AccountsRecordLogic;
  8. use App\Http\logic\admin\RechargeLogic;
  9. use App\Jobs\ClearCache;
  10. use App\Models\Order;
  11. use App\Models\Platform\MonthCard;
  12. use App\Services\OrderServices;
  13. use App\Services\PayMentService;
  14. use App\Game\Services\OuroGameService;
  15. use Carbon\Carbon;
  16. use Illuminate\Http\Request;
  17. use Illuminate\Support\Facades\DB;
  18. use Illuminate\Support\Facades\Log;
  19. use Illuminate\Support\Facades\Validator;
  20. use Illuminate\Support\Facades\Cache;
  21. class RechargeController extends Controller
  22. {
  23. //充值查询
  24. public function rechargeList(Request $request, $history = false)
  25. {
  26. $excel = $request->get('excel');
  27. $start_time = $request->input('start_time');
  28. $end_time = $request->input('end_time');
  29. $create_start_time = $request->input('create_start_time');
  30. $create_end_time = $request->input('create_end_time');
  31. $register_start_time = $request->input('register_start_time');
  32. $register_end_time = $request->input('register_end_time');
  33. $order = $request->post('order');
  34. $type = $request->post('type', '');
  35. $order_sn = $request->post('order_sn') ?? "";
  36. $userid = (int)$request->UserID ?: "";
  37. $recharge_type = (int)$request->recharge_type ?: "";
  38. $date = $request->date ?: '';
  39. $Channel = $request->Channel;
  40. $isEmpty = $request->isEmpty ?: 0;
  41. $source = $request->source;
  42. $chargeMoney = $request->chargeMoney ?: '';
  43. $payMethod = (int)$request->input('payMethod', 0);
  44. $amountSort = $request->amountSort ?: '';
  45. // 操作人筛选:空=全部,0=无操作人,正整数=指定管理员 id
  46. $operator_admin_id = $request->input('operator_admin_id', '');
  47. $type_list = DB::table('agent.dbo.admin_configs')->where('type', 'pay')
  48. ->pluck('name');
  49. // $type_list[] = 'TestPay';
  50. $table = 'order as o';
  51. if ($history) {
  52. $table = 'order_back as o';
  53. }
  54. $build_sql = DB::connection('write')->table($table)
  55. ->leftjoin('order_goods as og', 'og.order_id', '=', 'o.id')
  56. ->leftjoin('goods as g', 'og.goods_id', '=', 'g.id')
  57. ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai', 'o.user_id', '=', 'ai.UserID')
  58. ->leftJoin('QPTreasureDB.dbo.GameScoreInfo as ascore', 'o.user_id', '=', 'ascore.UserID')
  59. ->leftJoin('QPAccountsDB.dbo.AccountPhone as aphone', 'o.user_id', '=', 'aphone.UserID')
  60. ->leftJoin('QPAccountsDB.dbo.AccountsRecord as ar', function ($join) {
  61. $join->on('o.id', '=', 'ar.RecordID');
  62. $join->where('ar.type', 2);
  63. })
  64. ->leftJoin('agent.dbo.admin_users as au', 'ar.admin_id', '=', 'au.id');
  65. $where = [];
  66. $adminChannels=session('admin_channels');
  67. !empty($userid) && $where[] = ['ai.GameID', '=', $userid];
  68. !empty($order_sn) && $where[] = ['o.order_sn', $order_sn];
  69. !empty($type) && $where[] = ['o.payment_code', $type];
  70. !empty($payMethod) && $where[] = ['o.order_title', '=', $payMethod];
  71. if(!empty($Channel) || $Channel === '0') {
  72. $where[] = ['ai.Channel', $Channel];
  73. }else if(count($adminChannels)<5){
  74. $where[] = [function ($where) use ($adminChannels) {
  75. $where->whereIn('ai.Channel', $adminChannels);
  76. }];
  77. }
  78. // 充值来源
  79. if (!empty($source)) {
  80. if ($source == -1) {
  81. $where[] = ['o.GiftsID', '=', 0];
  82. } else {
  83. $where[] = ['o.GiftsID', '=', $source];
  84. }
  85. }
  86. // 充值档位筛选
  87. !empty($chargeMoney) && $where[] = ['amount', '=', ($chargeMoney * NumConfig::NUM_VALUE)];
  88. // 支付状态
  89. switch ($recharge_type) {
  90. // 已到账
  91. case 1:
  92. $where[] = ['o.pay_status', '=', 1];
  93. break;
  94. // 咖啡失败(排除退款等特殊状态)
  95. case 2:
  96. $where[] = ['o.pay_status', '>=', 2];
  97. $where[] = ['o.pay_status', '<>', 9];
  98. break;
  99. // 未支付
  100. case 3:
  101. $where[] = ['o.pay_status', '=', 0];
  102. break;
  103. // 退款
  104. case 9:
  105. $where[] = ['o.pay_status', '=', 9];
  106. break;
  107. }
  108. // 日期筛选
  109. if (!empty($date)) {
  110. switch ($date) {
  111. case 2:
  112. $create_start_time = date('Y-m-d 00:00:00');
  113. $create_end_time = date('Y-m-d 23:59:59');
  114. break;
  115. case 3:
  116. $create_start_time = date("Y-m-d 00:00:00", strtotime("-1 day"));
  117. $create_end_time = date("Y-m-d 23:59:59", strtotime("-1 day"));
  118. break;
  119. case 4:
  120. //当前日期
  121. $sdefaultDate = date("Y-m-d 00:00:00");
  122. //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期
  123. $first = 1;
  124. //获取当前周的第几天 周日是 0 周一到周六是 1 - 6
  125. $w = date('w', strtotime($sdefaultDate));
  126. $create_start_time = date('Y-m-d 00:00:00', strtotime("$sdefaultDate -" . ($w ? $w - $first : 6) . ' days'));
  127. $create_end_time = date('Y-m-d 23:59:59', strtotime("$start_time +6 days"));
  128. break;
  129. case 5:
  130. $create_start_time = date("Y-m-01 00:00:00");
  131. $create_end_time = date("Y-m-t 23:59:59");
  132. break;
  133. }
  134. }
  135. if ($isEmpty == 0) {
  136. empty($create_start_time) && $create_start_time = date('Y-m-d 00:00:00');
  137. empty($create_end_time) && $create_end_time = date('Y-m-d 23:59:59');
  138. } elseif ($isEmpty == 2) {
  139. empty($start_time) && $start_time = date('Y-m-d 00:00:00');
  140. empty($end_time) && $end_time = date('Y-m-d 23:59:59');
  141. }
  142. !empty($start_time) && $where[] = ['o.pay_at', '>=', date('Y-m-d H:i:s', strtotime($start_time))];
  143. !empty($end_time) && $where[] = ['o.pay_at', '<=', date('Y-m-d H:i:s', strtotime($end_time))];
  144. !empty($create_start_time) && $where[] = ['o.created_at', '>=', date('Y-m-d H:i:s', strtotime($create_start_time))];
  145. !empty($create_end_time) && $where[] = ['o.created_at', '<=', date('Y-m-d H:i:s', strtotime($create_end_time))];
  146. !empty($register_start_time) && $where[] = ['ai.RegisterDate', '>=', date('Y-m-d H:i:s', strtotime($register_start_time))];
  147. !empty($register_end_time) && $where[] = ['ai.RegisterDate', '<=', date('Y-m-d H:i:s', strtotime($register_end_time))];
  148. if ($request->start_time_cn) {
  149. $time = Carbon::createFromTimestamp(strtotime($request->start_time_cn));
  150. $where[] = ['o.pay_at', '>=', $time->subHours(11)->format('Y-m-d H:i:s')];
  151. }
  152. if ($request->end_time_cn) {
  153. $time = Carbon::createFromTimestamp(strtotime($request->end_time_cn));
  154. $where[] = ['o.pay_at', '<=', $time->subHours(11)->format('Y-m-d H:i:s')];
  155. }
  156. // 操作人(补单等)筛选:与列表相同的 AccountsRecord 关联
  157. if ($operator_admin_id !== '' && $operator_admin_id !== null) {
  158. if ((string)$operator_admin_id === '0') {
  159. $where[] = [function ($q) {
  160. $q->whereNull('ar.admin_id');
  161. }];
  162. } elseif (ctype_digit((string)$operator_admin_id) && (int)$operator_admin_id > 0) {
  163. $where[] = ['ar.admin_id', '=', (int)$operator_admin_id];
  164. }
  165. }
  166. $order ? $orderby = 'g.price desc' : $orderby = 'sum(o.amount) desc';
  167. $operatorFilterActive = $operator_admin_id !== '' && $operator_admin_id !== null
  168. && ((string)$operator_admin_id === '0'
  169. || (ctype_digit((string)$operator_admin_id) && (int)$operator_admin_id > 0));
  170. $aggregateBase = function () use ($table, $operatorFilterActive) {
  171. $q = DB::connection('write')->table($table)
  172. ->leftJoin('QPAccountsDB.dbo.AccountsInfo as ai', 'o.user_id', '=', 'ai.UserID')
  173. ->lock('with(nolock)');
  174. if ($operatorFilterActive) {
  175. $q->leftJoin('QPAccountsDB.dbo.AccountsRecord as ar', function ($join) {
  176. $join->on('o.id', '=', 'ar.RecordID');
  177. $join->where('ar.type', 2);
  178. });
  179. }
  180. return $q;
  181. };
  182. // 充值总金额、手续费汇总(管理员可见);有操作人筛选时 join ar,汇总用 distinct 避免重复行
  183. $payTotalMoney = $aggregateBase()
  184. ->where($where)
  185. ->selectRaw(
  186. $operatorFilterActive
  187. ? 'sum(o.amount) as amount,sum(ISNULL(o.payment_fee,0)) as total_payment_fee,count(distinct o.user_id) count_u,count(distinct o.id) count_id'
  188. : 'sum(amount) as amount,sum(ISNULL(payment_fee,0)) as total_payment_fee,count(distinct(user_id)) count_u,count(id) count_id'
  189. )
  190. ->first();
  191. $totalMoney = isset($payTotalMoney->amount) ? number_float($payTotalMoney->amount / NumConfig::NUM_VALUE) : 0;
  192. $totalPaymentFee = isset($payTotalMoney->total_payment_fee) ? number_float($payTotalMoney->total_payment_fee / NumConfig::NUM_VALUE) : 0;
  193. // 已到账
  194. if ($recharge_type == 1) {
  195. $payOverMoney = $aggregateBase()
  196. ->where($where)
  197. ->selectRaw(
  198. $operatorFilterActive
  199. ? 'sum(o.amount) as amount,count(distinct o.user_id) count_u,count(distinct o.id) count_id'
  200. : 'sum(amount) as amount,count(distinct(user_id)) count_u,count(id) count_id'
  201. )
  202. ->first();
  203. } elseif (empty($recharge_type)) {
  204. $payOverMoney = $aggregateBase()
  205. ->where($where)
  206. ->where('pay_status', 1)
  207. ->selectRaw(
  208. $operatorFilterActive
  209. ? 'sum(o.amount) as amount,count(distinct o.user_id) count_u,count(distinct o.id) count_id'
  210. : 'sum(amount) as amount,count(distinct(user_id)) count_u,count(id) count_id'
  211. )->first();
  212. }
  213. $overMoney = isset($payOverMoney->amount) ? number_float($payOverMoney->amount / NumConfig::NUM_VALUE) : 0;
  214. if ($excel) {
  215. $cellData = $build_sql
  216. ->selectRaw('o.order_sn,ai.GameID,o.payment_code,o.pay_status,o.amount,pay_at,o.created_at,o.after_amount,au.account,ai.Channel,ascore.Score as score,ascore.MaxScore as MaxScore,ascore.MaxWinScore as MaxWinScore')
  217. ->orderByDesc('o.id')
  218. ->where($where)
  219. ->lock('with(nolock)')
  220. ->get();
  221. foreach ($cellData as &$val) {
  222. if ($val->pay_status == 1) {
  223. $val->pay_status = '已到账';
  224. } elseif ($val->pay_status == 0) {
  225. $val->pay_status = '未支付';
  226. } elseif ($val->pay_status == 9) {
  227. $val->pay_status = '退款';
  228. } else {
  229. $val->pay_status = '充值出错';
  230. }
  231. $val->amount = number_float($val->amount / NumConfig::NUM_VALUE);
  232. $val->score = number_float($val->score / NumConfig::NUM_VALUE);
  233. $val->created_at_date = date('Y-m-d', strtotime($val->created_at));
  234. $val->created_at_hours = date('H:i:s', strtotime($val->created_at));
  235. $val->finished_at_date = !empty($val->pay_at) ? date('Y-m-d', strtotime($val->pay_at)) : '';
  236. $val->finished_at_hours = !empty($val->pay_at) ? date('H:i:s', strtotime($val->pay_at)) : '';
  237. unset($val->created_at);
  238. unset($val->pay_at);
  239. }
  240. $title = ['订单号', '充值玩家ID', '充值来源', '状态', '充值金额', '操作人', '玩家渠道', '订单创建日期', '订单创建时间', '订单完成日期', '订单完成日期'];
  241. $cellData = json_decode(json_encode($cellData), true);
  242. downloadExcel($cellData, $title, '充值查询');
  243. } else {
  244. $build_sql = $build_sql
  245. ->selectRaw('o.*,og.goods_id,og.price as og_price,og.quantity as og_quantity,ai.GameID as ai_GameID,au.account,ar.RecordID,ar.remarks ar_remarks,ascore.Score as score,aphone.PhoneNum as Phone,ascore.MaxScore as MaxScore,ascore.MaxWinScore as MaxWinScore')
  246. ->lock('with(nolock)')
  247. ->where($where);
  248. if (!empty($amountSort)) {
  249. $build_sql->orderBy('amount', $amountSort);
  250. } else {
  251. $build_sql->orderByDesc('o.id');
  252. }
  253. $list = $build_sql->paginate(10);
  254. foreach ($list as &$val) {
  255. $val->amount = number_float($val->amount / NumConfig::NUM_VALUE);
  256. $val->after_amount = number_float($val->after_amount / NumConfig::NUM_VALUE);
  257. $val->score = number_float($val->score / NumConfig::NUM_VALUE);
  258. $val->payment_fee = number_float(($val->payment_fee ?? 0) / NumConfig::NUM_VALUE);
  259. $val->MaxScore = number_float($val->MaxScore / NumConfig::NUM_VALUE);
  260. $val->MaxWinScore = number_float($val->MaxWinScore / NumConfig::NUM_VALUE);
  261. $val->created_at_date = date('Y-m-d', strtotime($val->created_at));
  262. $val->created_at_hours = date('H:i:s', strtotime($val->created_at));
  263. $val->finished_at_date = !empty($val->pay_at) ? date('Y-m-d', strtotime($val->pay_at)) : '';
  264. $val->finished_at_hours = !empty($val->pay_at) ? date('H:i:s', strtotime($val->pay_at)) : '';
  265. $val->GiftsName = Order::GiftsName($val->GiftsID);
  266. }
  267. $dates = [2 => '今日', 3 => '昨日', 4 => '本周', 5 => '本月'];
  268. // $allChannel = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo')->where('IsAndroid', 0)->groupBy('Channel')->pluck('Channel');
  269. $allChannel=$adminChannels;
  270. // 充值来源青铜月卡,白银月卡,黄金月卡,首充礼包,周卡,商城(充值)
  271. //后续还要加个10卢比破冰首充礼包
  272. $sourceList = [
  273. '-1' => '商城',
  274. '301' => '首充',
  275. '302' => '破产礼包',
  276. '303' => '每日首充礼包',
  277. '304' => '每日礼包',
  278. '305' => '召回礼包',
  279. '306' => 'freeBonus礼包',
  280. '401' => '转盘活动充值',
  281. '402' => '圣诞活动',
  282. ];
  283. // 充值档位金额从充值档位配置中动态获取,并加缓存(直接使用档位原始金额)
  284. $chargeMoneyList = Cache::remember('recharge_charge_money_list1', 600, function () {
  285. return DB::connection('write')
  286. ->table('agent.dbo.recharge_gear')
  287. ->where('status', 1)
  288. ->where('first_pay', 0)
  289. ->groupBy('money')
  290. ->orderBy('money')
  291. ->pluck('money')
  292. ->toArray();
  293. });
  294. $admin = session('admin');
  295. $viewAll=1;
  296. if(!in_array($admin->roles[0]->id,[1,12,2010,2011])){
  297. $viewAll=0;
  298. }
  299. $operatorOptions = DB::connection('write')
  300. ->table('QPAccountsDB.dbo.AccountsRecord as ar')
  301. ->join('agent.dbo.admin_users as au', 'ar.admin_id', '=', 'au.id')
  302. ->where('ar.type', 2)
  303. ->whereNotNull('ar.admin_id')
  304. ->select('au.id', 'au.account')
  305. ->distinct()
  306. ->orderBy('au.account')
  307. ->get();
  308. return view('admin.recharge.list', [
  309. 'viewAll' => $viewAll,
  310. 'operator_admin_id' => $operator_admin_id,
  311. 'operatorOptions' => $operatorOptions,
  312. 'list' => $list,
  313. 'UserID' => $userid,
  314. 'order_sn' => $order_sn,
  315. 'end_time' => empty($end_time) ? '' : date('Y-m-d', strtotime($end_time)) . 'T' . date('H:i:s', strtotime($end_time)),
  316. 'start_time' => empty($start_time) ? '' : date('Y-m-d', strtotime($start_time)) . 'T' . date('H:i:s', strtotime($start_time)),
  317. 'create_start_time' => empty($create_start_time) ? '' : date('Y-m-d', strtotime($create_start_time)) . 'T' . date('H:i:s', strtotime($create_start_time)),
  318. 'create_end_time' => empty($create_end_time) ? '' : date('Y-m-d', strtotime($create_end_time)) . 'T' . date('H:i:s', strtotime($create_end_time)),
  319. 'order' => $order,
  320. 'type' => $type,
  321. 'type_list' => $type_list,
  322. 'recharge_type' => $recharge_type,
  323. 'totalMoney' => $totalMoney,
  324. 'totalPaymentFee' => $totalPaymentFee,
  325. 'overMoney' => $overMoney,
  326. 'payOverMoney' => $payOverMoney ?? 0,
  327. 'payTotalMoney' => $payTotalMoney,
  328. 'date' => $date,
  329. 'dates' => $dates,
  330. 'allChannel' => $allChannel,
  331. 'Channel' => $Channel,
  332. 'isEmpty' => $isEmpty,
  333. 'register_start_time' => $register_start_time,
  334. 'register_end_time' => $register_end_time,
  335. 'sourceList' => $sourceList,
  336. 'source' => $source,
  337. 'chargeMoneyList' => $chargeMoneyList,
  338. 'chargeMoney' => $chargeMoney,
  339. 'amountSort' => $amountSort,
  340. 'request' => $request,
  341. 'payMethod' => $payMethod,
  342. 'payMethods' => [
  343. 1 => 'cashapp',
  344. 2 => 'paypal',
  345. 4 => 'applepay',
  346. 8 => 'googlepay'
  347. ]
  348. ]);
  349. }
  350. }
  351. //充值排行榜,每日&累计
  352. public function rechargeRank1(Request $request)
  353. {
  354. $excel = $request->get('excel');
  355. $end_time = $request->input('end_time');
  356. $start_time = $request->input('start_time');
  357. $sort = $request->get('sort');
  358. $todayPayAmount = $request->get('todayPayAmount');
  359. $chargeMin = $request->chargeMin ?: '';
  360. $chargeMax = $request->chargeMax ?: '';
  361. $last_login_start_time = $request->last_login_start_time ?: '';
  362. $last_login_end_time = $request->last_login_end_time ?: '';
  363. $page = $_SERVER['QUERY_STRING'] ? urlencode($_SERVER['QUERY_STRING']) : 'page=1';
  364. $where = [];
  365. $where[] = ['Recharge', '>', 0];
  366. !empty($start_time) && $where[] = ['o.pay_at', '>=', $start_time];
  367. !empty($end_time) ? $where[] = ['o.pay_at', '<=', date('Y-m-d', strtotime("$end_time+1day"))] : '';
  368. !empty($chargeMin) && $where[] = ['Recharge', '>=', $chargeMin];
  369. !empty($chargeMax) && $where[] = ['Recharge', '<=', $chargeMax];
  370. !empty($last_login_start_time) && $where[] = ['LastLogonDate', '>=', $last_login_start_time];
  371. !empty($last_login_end_time) && $where[] = ['LastLogonDate', '<=', $last_login_end_time];
  372. if (empty($start_time)) {
  373. $pay_at_start_time = date('Y-m-d');
  374. } else {
  375. $pay_at_start_time = $start_time;
  376. }
  377. if (empty($end_time)) {
  378. $pay_at_end_time = date('Y-m-d');
  379. } else {
  380. $pay_at_end_time = $end_time;
  381. }
  382. switch ($sort) {
  383. case '1':
  384. $order_sql = 'a.Experience DESC';
  385. break;
  386. case '2':
  387. $order_sql = 'DATEDIFF(DAY,a.LastLogonDate,GETDATE()) DESC';
  388. break;
  389. default:
  390. $order_sql = 'Recharge DESC';
  391. break;
  392. }
  393. if ($excel) {
  394. // $cellData = DB::connection('write')->table('agent.dbo.order as o')
  395. // ->leftjoin('QPAccountsDB.dbo.AccountsInfo as a', 'o.user_id', '=', 'a.UserID')
  396. // ->leftjoin('QPAccountsDB.dbo.AccountPhone as i', 'o.user_id', '=', 'i.UserID')
  397. // ->leftjoin('agent.dbo.agent as ag', 'o.user_id', '=', 'ag.UserID')
  398. // ->join('QPAccountsDB.dbo.YN_VIPAccount as vip', 'o.user_id', '=', 'vip.UserID')
  399. // ->select(DB::raw('null as rank'), 'o.user_id', 'a.GameID', 'a.NickName', DB::raw('null as type'), 'i.PhoneNum', 'Recharge as money', DB::raw('a.Experience,a.LastLogonDate,a.RegisterDate,DATEDIFF(DAY,a.LastLogonDate,GETDATE()) as time'), 'ag.id', 'a.Channel')
  400. // ->whereNotNull('pay_at')
  401. // ->where($where)
  402. // ->groupBy('o.user_id', 'Recharge', 'a.GameID', 'a.NickName', 'a.LastLogonDate', 'a.RegisterDate', 'a.Experience', 'i.PhoneNum', 'ag.id', 'a.Channel')
  403. // ->orderByRaw($order_sql)
  404. // ->get();
  405. $cellData = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
  406. ->where('Recharge', '>', 0)
  407. ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ds.UserID', 'ai.UserID')
  408. ->leftjoin('QPAccountsDB.dbo.AccountPhone as ap', 'ds.UserID', 'ap.UserID')
  409. ->select('ai.UserID', 'ai.GameID', 'ai.NickName', 'ai.Channel', 'ap.PhoneNum', 'ds.Recharge', 'ai.PlayTimeCount', 'ai.LastLogonDate', 'ai.RegisterDate')
  410. ->orderByDesc('Recharge')
  411. ->get();
  412. $pyq = DB::connection('write')->table('QPAccountsDB.dbo.PyqInfo')->select('UserID')->get();
  413. $pyq_list = [];
  414. foreach ($pyq as $k => $v) {
  415. $pyq_list[$v->UserID] = 1;
  416. }
  417. foreach ($cellData as $key => &$value) {
  418. $second = $value->Experience;
  419. $day = floor($second / (3600 * 24));
  420. $second = $second % (3600 * 24);//除去整天之后剩余的时间
  421. $hour = floor($second / 3600);
  422. $second = $second % 3600;//除去整小时之后剩余的时间
  423. $minute = floor($second / 60);
  424. //返回字符串
  425. $value->Experience = $day . '天' . $hour . '小时' . $minute . '分';
  426. $value->type = '玩家';
  427. $value->time = !empty($value->time) ? $value->time . '天' : '';
  428. unset($value->id);
  429. $value->rank = $key + 1;
  430. }
  431. $title = ['排名', '用户ID', '游戏ID', '游戏昵称', '玩家状态', '手机号', '充值总额', '游戏时长', '最后登录时间', '注册时间', '距上次登录时间', '玩家渠道'];
  432. $cellData = json_decode(json_encode($cellData), true);
  433. downloadExcel($cellData, $title, '充值排行榜');
  434. } else {
  435. $sql = DB::connection('write')->table('agent.dbo.order as o')
  436. ->leftjoin('QPAccountsDB.dbo.AccountsInfo as a', 'o.user_id', '=', 'a.UserID')
  437. ->leftjoin('QPAccountsDB.dbo.AccountPhone as i', 'o.user_id', '=', 'i.UserID')
  438. ->leftjoin('QPAccountsDB.dbo.YN_VIPAccount as vip', 'o.user_id', '=', 'vip.UserID')
  439. ->select(DB::raw('null as rank'), 'i.PhoneNum', 'o.user_id', 'a.GameID', 'a.NickName', 'Recharge as money', DB::raw('a.Experience,a.LastLogonDate,a.RegisterDate,DATEDIFF(DAY,a.LastLogonDate,GETDATE()) as time'), 'a.Channel');
  440. if (!empty($todayPayAmount)) {
  441. $list = $sql
  442. ->where('pay_at', '>=', $pay_at_start_time . ' 00:00:00')
  443. ->where('pay_at', '<=', $pay_at_end_time . ' 23:59:59')
  444. ->orderByRaw("sum(amount) $todayPayAmount");
  445. } else {
  446. $list = $sql
  447. ->where('pay_at', '>=', $pay_at_start_time . ' 00:00:00')
  448. ->where('pay_at', '<=', $pay_at_end_time . ' 23:59:59')
  449. ->orderByRaw($order_sql);
  450. }
  451. $list = $list->where($where)
  452. ->groupBy('o.user_id', 'a.GameID', 'a.NickName', 'a.LastLogonDate', 'a.RegisterDate', 'a.Experience', 'i.PhoneNum', 'a.Channel', 'Recharge')
  453. ->paginate(10);
  454. $UserIDs = [];
  455. foreach ($list as $value) {
  456. $UserIDs[] = $value->user_id;
  457. }
  458. $todayPay = DB::connection('write')->table('agent.dbo.order')
  459. ->whereIn('user_id', $UserIDs)
  460. ->where('pay_at', '>=', $pay_at_start_time . ' 00:00:00')
  461. ->where('pay_at', '<=', $pay_at_end_time . ' 23:59:59')
  462. ->selectRaw('IsNull(sum(amount),0) amount,user_id')
  463. ->groupBy('user_id')
  464. ->pluck('amount', 'user_id')->toArray();
  465. foreach ($list as $key => &$value) {
  466. $second = $value->Experience;
  467. $day = floor($second / (3600 * 24));
  468. $second = $second % (3600 * 24);//除去整天之后剩余的时间
  469. $hour = floor($second / 3600);
  470. $second = $second % 3600;//除去整小时之后剩余的时间
  471. $minute = floor($second / 60);
  472. //返回字符串
  473. $value->Experience = $day . '天' . $hour . '小时' . $minute . '分';
  474. $value->type = '玩家';
  475. $value->rank = $key + 1;
  476. $value->money = number_float($value->money);
  477. $value->todayPayAmount = isset($todayPay[$value->user_id]) ? number_float($todayPay[$value->user_id] / NumConfig::NUM_VALUE) : 0;
  478. }
  479. $chargeMin = $request->chargeMin ?: '';
  480. $chargeMax = $request->chargeMax ?: '';
  481. $last_login_start_time = $request->last_login_start_time ?: '';
  482. $last_login_end_time = $request->last_login_end_time ?: '';
  483. $sort_list = [0 => '充值金额', 1 => '游戏时长', 2 => '距上次登录时间'];
  484. return view('admin.recharge.rank', [
  485. 'list' => $list,
  486. 'end_time' => $end_time,
  487. 'start_time' => $start_time,
  488. 'sort' => $sort,
  489. 'sort_list' => $sort_list,
  490. 'page' => '/admin/recharge/rank?' . $page,
  491. 'todayPayAmount' => $todayPayAmount,
  492. 'chargeMin' => $chargeMin,
  493. 'chargeMax' => $chargeMax,
  494. 'last_login_start_time' => $last_login_start_time,
  495. 'last_login_end_time' => $last_login_end_time,
  496. 'pay_at_start_time' => $pay_at_start_time,
  497. 'pay_at_end_time' => $pay_at_end_time,
  498. ]);
  499. }
  500. }
  501. public function rechargeRank(Request $request)
  502. {
  503. $excel = $request->get('excel');
  504. $date = Carbon::now();
  505. $start_time = $request->input('start_time', $date->format('Y-m-d'));
  506. $end_time = $request->input('end_time', $date->format('Y-m-d'));
  507. $sort = $request->get('sort');
  508. $Channel = $request->get('Channel');
  509. $chargeMin = $request->chargeMin ?: '';
  510. $chargeMax = $request->chargeMax ?: '';
  511. $adminChannels = session('admin_channels');
  512. $Channels = session('all_channels');
  513. $admin = session('admin');
  514. $where = [];
  515. !empty($start_time) && $where[] = ['DateID', '>=', Carbon::parse($start_time)->format('Ymd')];
  516. !empty($end_time) && $where[] = ['DateID', '<', Carbon::parse($end_time)->addDay(1)->format('Ymd')];
  517. !empty($chargeMin) && $where[] = ['Recharge', '>=', $chargeMin];
  518. !empty($chargeMax) && $where[] = ['Recharge', '<=', $chargeMax];
  519. $where2=$where;
  520. $channelWhere=[];
  521. if(!empty($Channel) || $Channel === '0') {
  522. $where2[] = ['ai.Channel', $Channel];
  523. $channelWhere[] = ['ai.Channel', $Channel];
  524. }else if(count($adminChannels)<5){
  525. $where2[] = [function ($where) use ($adminChannels) {
  526. $where->whereIn('ai.Channel', $adminChannels);
  527. }];
  528. $channelWhere[] = [function ($where) use ($adminChannels) {
  529. $where->whereIn('ai.Channel', $adminChannels);
  530. }];
  531. }
  532. switch ($sort) {
  533. case '1':
  534. $order_sql = 'ai.PlayTimeCount DESC';
  535. break;
  536. case '2':
  537. $order_sql = 'DATEDIFF(DAY,a.LastLogonDate,GETDATE()) DESC';
  538. break;
  539. default:
  540. $order_sql = 'sum(ds.Recharge) DESC';
  541. break;
  542. }
  543. if ($excel && false) {
  544. $cellData = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
  545. ->where('Recharge', '>', 0)
  546. ->where($where2)
  547. ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ds.UserID', 'ai.UserID')
  548. ->leftjoin('QPAccountsDB.dbo.AccountPhone as ap', 'ds.UserID', 'ap.UserID')
  549. ->select('ai.UserID','ai.GameID', 'ai.NickName', 'ai.Channel', 'ap.PhoneNum', 'ai.PlayTimeCount', 'ai.LastLogonDate', 'ai.RegisterDate')
  550. ->lock('with(nolock)')
  551. ->orderByRaw($order_sql)
  552. ->get();
  553. $rechargeSum = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
  554. ->where('Recharge', '>', 0)
  555. ->where($where)
  556. ->selectRaw('sum(ds.Recharge) Recharge,UserID')
  557. ->lock('with(nolock)')
  558. ->groupBy('UserID')
  559. ->pluck('Recharge', 'UserID')->toArray();
  560. $UserIDs = [];
  561. foreach ($cellData as $value) {
  562. $UserIDs[] = $value->UserID;
  563. }
  564. foreach ($cellData as $key => &$value) {
  565. $second = $value->PlayTimeCount;
  566. $day = floor($second / (3600 * 24));
  567. $second = $second % (3600 * 24);//除去整天之后剩余的时间
  568. $hour = floor($second / 3600);
  569. $second = $second % 3600;//除去整小时之后剩余的时间
  570. $minute = floor($second / 60);
  571. //返回字符串
  572. $value->PlayTimeCount = $day . '天' . $hour . '小时' . $minute . '分';
  573. $value->type = '玩家';
  574. $value->money = $rechargeSum[$value->UserID] ?? 0;
  575. $value->time = Carbon::parse(now())->diffInDays($value->LastLogonDate, true);
  576. }
  577. $title = [ '用户ID', '游戏ID', '游戏昵称', '渠道号', '手机号','游戏时长', '最后登录时间', '注册时间','类型','充值金额', '距上次登录时间'];
  578. $cellData = json_decode(json_encode($cellData), true);
  579. downloadExcel($cellData, $title, '充值排行榜');
  580. } else {
  581. $channelUsers=DB::table(TableName::QPAccountsDB() . 'AccountsInfo as ai')->where($channelWhere)->select('UserID');
  582. $rechargeSum = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
  583. ->where('Recharge', '>', 0)
  584. ->where($where)
  585. ->whereIn('UserID',$channelUsers)
  586. ->selectRaw('sum(ds.Recharge) RechargeAll,UserID')
  587. ->groupBy('UserID')
  588. ->lock('with(nolock)')
  589. ->orderByRaw($order_sql)
  590. ->paginate(10);
  591. $UserIDs = [];
  592. $ReSort=[];
  593. foreach ($rechargeSum as &$value) {
  594. $UserIDs[] = $value->UserID;
  595. $ReSort[$value->UserID]=$value;
  596. }
  597. $list = DB::table(TableName::QPAccountsDB() . 'AccountsInfo as ai')
  598. ->leftjoin('QPAccountsDB.dbo.AccountPhone as ap', 'ai.UserID', 'ap.UserID')
  599. ->select('ai.UserID', 'ai.GameID', 'ai.NickName', 'ai.Channel', 'ap.PhoneNum', 'ai.PlayTimeCount', 'ai.LastLogonDate', 'ai.RegisterDate')
  600. ->whereIn('ai.UserID',$UserIDs)
  601. ->lock('with(nolock)')
  602. ->get();
  603. foreach ($list as $key => &$value) {
  604. $second = $value->PlayTimeCount;
  605. $day = floor($second / (3600 * 24));
  606. $second = $second % (3600 * 24);//除去整天之后剩余的时间
  607. $hour = floor($second / 3600);
  608. $second = $second % 3600;//除去整小时之后剩余的时间
  609. $minute = floor($second / 60);
  610. $value2=$ReSort[$value->UserID];
  611. $value2->GameID=$value->GameID;
  612. $value2->NickName=$value->NickName;
  613. $value2->Channel=$value->Channel;
  614. $value2->PhoneNum=$value->PhoneNum;
  615. $value2->PlayTimeCount=$value->PlayTimeCount;
  616. $value2->LastLogonDate=$value->LastLogonDate;
  617. $value2->RegisterDate=$value->RegisterDate;
  618. //返回字符串
  619. $value2->Experience = $day . '天' . $hour . '小时' . $minute . '分';
  620. $value2->type = '玩家';
  621. $value2->rank = $key + 1;
  622. $value2->money = $value2->RechargeAll;//$rechargeSum[$value->UserID] ?? 0;
  623. $value2->time = Carbon::parse(now())->diffInDays($value->LastLogonDate, true);
  624. }
  625. $chargeMin = $request->chargeMin ?: '';
  626. $chargeMax = $request->chargeMax ?: '';
  627. $sort_list = [0 => '充值金额', 1 => '游戏时长', 2 => '距上次登录时间'];
  628. $channels=$adminChannels;
  629. return view('admin.recharge.rank', [
  630. 'list' => $rechargeSum,
  631. 'end_time' => $end_time,
  632. 'start_time' => $start_time,
  633. 'sort' => $sort,
  634. 'sort_list' => $sort_list,
  635. 'chargeMin' => $chargeMin,
  636. 'chargeMax' => $chargeMax,
  637. 'Channel'=>$Channel,
  638. 'channels' => $channels
  639. ]);
  640. }
  641. }
  642. // 补单
  643. public function supplement(Request $request, $id)
  644. {
  645. try {
  646. if ($request->method() == 'POST') {
  647. $admin_id = $request->session()->get('admin')->id;
  648. $order = DB::table('agent.dbo.order')->where('id', $id)->first();
  649. if (!$order) {
  650. return apiReturnFail('订单不存在!');
  651. }
  652. if ((int)$order->pay_status === 1) {
  653. return apiReturnFail('订单已完成!');
  654. }
  655. // 退款订单禁止补单
  656. if ((int)$order->pay_status === 9) {
  657. return apiReturnFail('退款订单不可补单');
  658. }
  659. $payAmt = $order->amount / NumConfig::NUM_VALUE;
  660. $order_sn = $order->order_sn;
  661. Log::info('补单单号:' . $order_sn);
  662. // 成功处理回调
  663. $GiftsID = $order->GiftsID ?: '';
  664. $userID = $order->user_id ?: '';
  665. //$res = (new OrderService())->paySuccess($GiftsID, $userID, $payAmt, $order_sn);
  666. // 获取金额
  667. $service = new OrderServices();
  668. $recharge_gear = DB::connection('write')->table('agent.dbo.recharge_gear')->where('first_pay', 0)->where('money', $payAmt)->select('favorable_price', 'give')->first();
  669. if($recharge_gear || $GiftsID){
  670. [$give, $favorable_price, $Recharge, $czReason, $cjReason] = $service->getPayInfo($GiftsID, $userID, $payAmt);
  671. }else{
  672. $Recharge = $payAmt;
  673. $give = 0;
  674. $favorable_price = $Recharge + $give;
  675. $czReason = 1;
  676. $cjReason = 45;
  677. }
  678. // [$give, $favorable_price, $Recharge, $czReason, $cjReason] = $service->getPayInfo($GiftsID, $userID, $payAmt);
  679. // 增加充值记录
  680. [$Score] = $service->addRecord($userID, $payAmt, $favorable_price, $order_sn, $GiftsID, $Recharge, $czReason, $give, $cjReason, $order->AdId, $order->eventType);
  681. // 成功处理回调
  682. \App\Jobs\Order::dispatch([$userID, $payAmt, $Score, $favorable_price, $GiftsID, $order_sn]);
  683. // 修改订单状态
  684. $data = [
  685. 'pay_status' => 1,
  686. 'finished_at' => date('Y-m-d H:i:s'),
  687. 'updated_at' => date('Y-m-d H:i:s'),
  688. 'pay_at' => date('Y-m-d H:i:s')
  689. ];
  690. $order_up = DB::table('agent.dbo.order')->where('id', $id)->update($data);
  691. // 添加操作记录
  692. (new AccountsRecordLogic())->create_record($id, $order->pay_status, 1, '', $admin_id, 2);
  693. if ($order_up === false) {
  694. return apiReturnFail('补单失败');
  695. }
  696. return apiReturnSuc();
  697. }
  698. } catch (\Exception $exception) {
  699. return apiReturnFail($exception->getMessage());
  700. }
  701. }
  702. // 标记订单为退款状态
  703. public function refund(Request $request, $id)
  704. {
  705. try {
  706. $admin = $request->session()->get('admin');
  707. $roleId = $admin->roles[0]->id ?? 0;
  708. // 仅管理员角色允许操作(与补单权限保持一致)
  709. if (!in_array($roleId, [1, 12])) {
  710. return apiReturnFail('无权限执行该操作');
  711. }
  712. $order = DB::connection('write')->table('agent.dbo.order')->where('id', $id)->lockForUpdate()->first();
  713. if (!$order) {
  714. return apiReturnFail('订单不存在!');
  715. }
  716. if ($order->pay_status == 9) {
  717. return apiReturnFail('订单已为退款状态');
  718. }
  719. if ($order->pay_status != 1) {
  720. return apiReturnFail('仅已到账订单可设置为退款状态');
  721. }
  722. $now = date('Y-m-d H:i:s');
  723. $updated = DB::connection('write')->table('agent.dbo.order')
  724. ->where('id', $id)
  725. ->update([
  726. 'pay_status' => 9,
  727. 'refund_fee' => ($order->payment_code=='AiNewPay' && $order->title==2)?800:3000,
  728. 'updated_at' => $now,
  729. ]);
  730. if ($updated === false) {
  731. return apiReturnFail('设置退款状态失败');
  732. }
  733. $admin_id = $admin->id;
  734. (new AccountsRecordLogic())->create_record($id, $order->pay_status, 9, '', $admin_id, 2);
  735. return apiReturnSuc();
  736. } catch (\Exception $exception) {
  737. return apiReturnFail($exception->getMessage());
  738. }
  739. }
  740. /**
  741. * 模拟上报 FB 支付事件(仅管理员可用)
  742. */
  743. public function fbReportMock(Request $request, $id)
  744. {
  745. try {
  746. $admin = $request->session()->get('admin');
  747. $roleId = $admin->roles[0]->id ?? 0;
  748. if (!in_array($roleId, [1, 12])) {
  749. return apiReturnFail('无权限执行该操作');
  750. }
  751. $order = DB::connection('write')->table('agent.dbo.order')->where('id', $id)->first();
  752. if (!$order) {
  753. return apiReturnFail('订单不存在!');
  754. }
  755. // 退款订单不允许模拟上报
  756. if ((int)$order->pay_status === 9) {
  757. return apiReturnFail('退款订单不可模拟上报');
  758. }
  759. // 只允许对未成功的订单做模拟上报(已到账的默认认为已正常上报)
  760. if ((int)$order->pay_status === 1) {
  761. return apiReturnFail('仅对未成功订单开放模拟上报');
  762. }
  763. $userId = $order->user_id;
  764. $payAmt = $order->amount; // 内部金额单位,保持与原上报一致
  765. // 构造模拟上报的 params
  766. $item = [
  767. 'regtime' => time(), // 当前时间
  768. 'isd0' => 1, // 固定为首日
  769. 'first' => 1, // 固定视为首充
  770. 'golds' => $payAmt, // 金额
  771. 'udis' => $userId, // 注意:按需求使用 udis 字段
  772. 'order_sn'=> $order->order_sn,
  773. ];
  774. // 通过 OuroGameService 模拟一次 pay_finish 上报
  775. OuroGameService::notifyWebHall(
  776. $userId,
  777. '',
  778. 'pay_finish',
  779. [
  780. 'Golds' => $payAmt,
  781. 'PayNum'=> $payAmt,
  782. 'event' => 'pay',
  783. 'params'=> $item,
  784. ]
  785. );
  786. return apiReturnSuc();
  787. } catch (\Exception $exception) {
  788. Log::error('模拟 FB 上报失败:' . $exception->getMessage(), [
  789. 'order_id' => $id,
  790. ]);
  791. return apiReturnFail('上报失败,请稍后重试');
  792. }
  793. }
  794. public function search($orderId)
  795. {
  796. $order = DB::table('agent.dbo.order')->where('id', $orderId)->first();
  797. if (!$order) {
  798. return apiReturnFail('未查询到订单信息');
  799. }
  800. $agent = $order->payment_code;
  801. $service = PayMentService::pay_logic($agent);
  802. $res = $service->pay_search($order->order_sn);
  803. if($res){
  804. return apiReturnSuc([],'','订单支付成功');
  805. }else{
  806. return apiReturnFail('订单未成功');
  807. }
  808. }
  809. // 充值渠道修改
  810. public function config($method, Request $request)
  811. {
  812. if ($request->method() == 'GET') {
  813. $res = (new RechargeLogic())->config($method);
  814. return view('admin.recharge.config', $res);
  815. }
  816. $validator = Validator::make($request->all(), [
  817. 'config.*.sort' => 'required|int',
  818. 'config.*.status' => 'required|in:1,-1',
  819. 'config.*.weight.1' => 'nullable|int|min:0|max:100000',
  820. 'config.*.weight.2' => 'nullable|int|min:0|max:100000',
  821. 'config.*.weight.4' => 'nullable|int|min:0|max:100000',
  822. 'config.*.weight.8' => 'nullable|int|min:0|max:100000',
  823. ]);
  824. if ($validator->fails()) {
  825. return apiReturnFail($validator->errors()->first());
  826. }
  827. $config = $request->input('config');
  828. $opened = array_filter($config, function ($item) {
  829. return $item['status'] == 1;
  830. });
  831. if (array_sum(array_column($opened, 'sort')) != 100) {
  832. return apiReturnFail('权重值分配不正确');
  833. }
  834. foreach ($config as $id => $v) {
  835. $weightInput = $v['weight'] ?? null;
  836. // 防御性处理:避免后续误把 weight 数组直接参与 update
  837. unset($v['weight']);
  838. $remarksRaw = DB::table('agent.dbo.admin_configs')->where('id', $id)->value('remarks');
  839. $remarks = [];
  840. if (!empty($remarksRaw)) {
  841. $decoded = \GuzzleHttp\json_decode($remarksRaw, true);
  842. if (is_array($decoded)) {
  843. $remarks = $decoded;
  844. }
  845. }
  846. if (is_array($weightInput)) {
  847. $existingWeights = $remarks['weight'] ?? ($remarks['weights'] ?? []);
  848. if (!is_array($existingWeights)) {
  849. $existingWeights = [];
  850. }
  851. $methodWeights = $existingWeights;
  852. foreach ([1, 2, 4, 8] as $methodKey) {
  853. if (array_key_exists($methodKey, $weightInput)) {
  854. $weightKey = 'type_' . $methodKey;
  855. if ($weightInput[$methodKey] === '' || $weightInput[$methodKey] === null) {
  856. $methodWeights[$weightKey] = 0;
  857. } else {
  858. $methodWeights[$weightKey] = (int)$weightInput[$methodKey];
  859. }
  860. }
  861. }
  862. $remarks['weight'] = $methodWeights;
  863. }
  864. $updateData = [
  865. 'sort' => (int)$v['sort'],
  866. 'status' => (int)$v['status'],
  867. 'admin_id' => session('admin')['id'],
  868. 'updated_at' => date('Y-m-d H:i:s'),
  869. 'remarks' => \GuzzleHttp\json_encode($remarks, JSON_UNESCAPED_UNICODE),
  870. ];
  871. if ((int)$v['status'] === -1) {
  872. $updateData['sort'] = 0;
  873. }
  874. DB::table('agent.dbo.admin_configs')->where('id', $id)->update($updateData);
  875. if ((int)$v['status'] === -1) {
  876. DB::table('QPPlatformDB.dbo.ChannelOpenRecharge')->where('ConfigID', $id)
  877. ->update([
  878. 'sort' => 0,
  879. 'status' => 2
  880. ]);
  881. }
  882. }
  883. return apiReturnSuc();
  884. }
  885. public function methods()
  886. {
  887. $methods = DB::table('agent.dbo.admin_configs')
  888. ->leftJoin('agent.dbo.admin_users as u', 'admin_configs.admin_id', '=', 'u.id')
  889. ->select('admin_configs.*', 'u.account')
  890. ->where('admin_configs.type', 'pay_method')
  891. ->get();
  892. return view('admin.recharge.methods', [
  893. 'methods' => $methods,
  894. ]);
  895. }
  896. // 充值渠道修改 开关
  897. public function switch_control(Request $request, $id)
  898. {
  899. $type = $request->type;
  900. $admin_id = $request->session()->get('admin')->id;
  901. $logic = new RechargeLogic();
  902. $res = $logic->switch_control($id, $type, $admin_id);
  903. if ($res === false) {
  904. return apiReturnFail($logic->getError());
  905. }
  906. ClearCache::dispatch();
  907. return apiReturnSuc();
  908. }
  909. // 充值档位修改
  910. public function gear_list()
  911. {
  912. $res = (new RechargeLogic())->gear_list();
  913. // dd($res);
  914. return view('admin.recharge.gear_list', $res);
  915. }
  916. public function channel_switch(Request $request, $id)
  917. {
  918. $type = $request->type;
  919. $logic = new RechargeLogic();
  920. $res = $logic->channel_switch($id, $type);
  921. if ($res === false) {
  922. return apiReturnFail($logic->getError());
  923. }
  924. return apiReturnSuc();
  925. }
  926. // 添加
  927. public function add(Request $request)
  928. {
  929. $list = DB::table('agent.dbo.admin_configs')->where('type', 'pay')->pluck('name', 'id');
  930. if ($request->method() == 'POST') {
  931. $money = (float)$request->money ?: '';
  932. $status = $request->status;
  933. // $config_ids = $request->config_ids;
  934. $favorable_price = (float)$request->favorable_price;
  935. $give = (float)$request->give;
  936. $pay_methods = (int)$request->pay_methods ?: 0; // 支付方式位掩码
  937. $in_shop = (int)$request->input('in_shop', 1); // 是否在商城展示
  938. $logic = new RechargeLogic();
  939. $res = $logic->add($money, $status, '', $favorable_price, $give, $pay_methods, $in_shop);
  940. return apiReturnSuc();
  941. }
  942. return view('admin.recharge.add', ['list' => $list]);
  943. }
  944. public function update_config(Request $request, $id)
  945. {
  946. if ($request->isMethod('post')) {
  947. $money = (float)($request->money ?: '');
  948. $favorable_price = (float)($request->favorable_price ?: 0);
  949. $give = (float)($request->give ?: 0);
  950. $second_give = (int)($request->second_give ?: 0);
  951. $pay_methods = (int)($request->pay_methods ?: 0); // 支付方式位掩码
  952. $in_shop = (int)$request->input('in_shop', 1); // 是否在商城展示
  953. // 构建支付方式数组
  954. $gearData = [];
  955. $payMethodsMap = [
  956. 1 => 'cashapp',
  957. 2 => 'paypal',
  958. 4 => 'applepay',
  959. 8 => 'googlepay',
  960. 64 => 'usdt-trc20',
  961. 128 => 'usdt-erc20',
  962. 256 => 'usdc-trc20',
  963. 512 => 'usdc-erc20'
  964. ];
  965. foreach ($payMethodsMap as $value => $name) {
  966. if ($pay_methods & $value) {
  967. $gearData[] = [
  968. 'name' => $name,
  969. 'value' => $value,
  970. 'status' => 1
  971. ];
  972. }
  973. }
  974. $data = [
  975. 'money' => $money,
  976. 'favorable_price' => $favorable_price,
  977. 'second_give' => $second_give,
  978. 'give' => $give,
  979. 'in_shop' => $in_shop,
  980. 'gear' => \GuzzleHttp\json_encode($gearData) // 存储到gear字段
  981. ];
  982. DB::table('agent.dbo.recharge_gear')->where('id', $id)->update($data);
  983. return apiReturnSuc();
  984. } else {
  985. $info = DB::table('agent.dbo.recharge_gear')->where('id', $id)->first();
  986. // 解析gear字段,计算pay_methods用于回显
  987. $pay_methods = 0;
  988. if (!empty($info->gear)) {
  989. $gear = \GuzzleHttp\json_decode($info->gear, true);
  990. if (is_array($gear)) {
  991. foreach ($gear as $item) {
  992. if (isset($item['value']) && ($item['status'] ?? 0) == 1) {
  993. $pay_methods += $item['value'];
  994. }
  995. }
  996. }
  997. }
  998. $info->pay_methods = $pay_methods;
  999. return view('admin.recharge.update_config', ['info' => $info]);
  1000. }
  1001. }
  1002. // 加载修改页面
  1003. public function update(Request $request, $id)
  1004. {
  1005. $info = (new RechargeLogic())->update($id);
  1006. return view('admin.recharge.update', $info);
  1007. }
  1008. // 修改里面的开关
  1009. public function gear_switch(Request $request, $id)
  1010. {
  1011. $config_id = $request->config_id ?: '';
  1012. $type = $request->type ?: '';
  1013. $logic = new RechargeLogic();
  1014. $res = $logic->gear_switch($id, $config_id, $type);
  1015. if ($res === false) {
  1016. return apiReturnFail($logic->getError());
  1017. }
  1018. ClearCache::dispatch();
  1019. return apiReturnSuc();
  1020. }
  1021. // 修改排序
  1022. public function update_sort(Request $request, $id)
  1023. {
  1024. $sort = $request->sort ?: 0;
  1025. DB::connection('write')->table('agent.dbo.admin_configs')
  1026. ->where('id', $id)
  1027. ->update(['sort' => $sort]);
  1028. ClearCache::dispatch();
  1029. return apiReturnSuc();
  1030. }
  1031. // 添加备注
  1032. public function remarks(Request $request, $id)
  1033. {
  1034. $remarks = $request->remark ?: '';
  1035. DB::connection('write')->table('agent.dbo.admin_configs')
  1036. ->where('id', $id)
  1037. ->update(['remarks' => $remarks]);
  1038. return apiReturnSuc();
  1039. }
  1040. // 首冲10元礼包--修改渠道
  1041. public function firstCharge(Request $request)
  1042. {
  1043. $StatusValue = $request->StatusValue ?: '';
  1044. DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  1045. ->where('StatusName', 'FirstChargeGiftBag')
  1046. ->update(['StatusValue' => $StatusValue]);
  1047. return apiReturnSuc();
  1048. }
  1049. // 首冲10元礼包 -- 修改状态
  1050. public function firstChargeStatus(Request $request)
  1051. {
  1052. $StatusValue = $request->StatusValue ?: '';
  1053. DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  1054. ->where('StatusName', 'FirstChargeGiftBagStatus')
  1055. ->update(['StatusValue' => $StatusValue]);
  1056. return apiReturnSuc();
  1057. }
  1058. // IP回调白名单
  1059. public function ip_white(Request $request)
  1060. {
  1061. $list = DB::connection('write')->table('agent.dbo.admin_configs as ac')
  1062. ->leftJoin('agent.dbo.recharge_ip as ri', 'ac.id', '=', 'ri.config_id')
  1063. ->leftJoin('agent.dbo.admin_users as au', 'ri.admin_id', 'au.id')
  1064. ->where('ac.status', 1)
  1065. ->select('ac.id', 'ac.name', 'ac.config_value', 'ip', 'account', 'last_time', 'ac.status', 'ri.remarks')
  1066. ->paginate(5);
  1067. return view('admin.recharge.ip_white', compact('list'));
  1068. }
  1069. public function ip_white_update(Request $request, $id)
  1070. {
  1071. if ($request->isMethod('post')) {
  1072. $post = $request->post();
  1073. if (empty($post['ip'])) {
  1074. return apiReturnFail('IP白名单不能为空');
  1075. }
  1076. $ip = explode(',', $post['ip']);
  1077. foreach ($ip as $val) {
  1078. if (!filter_var($val, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
  1079. return apiReturnFail('ip不合法');
  1080. }
  1081. }
  1082. $post['last_time'] = date('Y-m-d H:i:s');
  1083. $post['admin_id'] = session('admin')->id;
  1084. DB::connection('write')->table('agent.dbo.recharge_ip')
  1085. ->updateOrInsert(['config_id' => $id], $post);
  1086. return apiReturnSuc();
  1087. }
  1088. $info = DB::connection('write')->table('agent.dbo.admin_configs as ac')
  1089. ->leftJoin('agent.dbo.recharge_ip as ri', 'ac.id', '=', 'ri.config_id')
  1090. ->where('ac.id', $id)
  1091. ->select('ac.id', 'ac.name', 'ac.config_value', 'ip', 'ri.remarks')
  1092. ->first();
  1093. return view('admin.recharge.ip_white_update', compact('info'));
  1094. }
  1095. // 充值推荐档位
  1096. public function recomendar_recharge(Request $request)
  1097. {
  1098. $StatusValue = $request->StatusValue ?: '';
  1099. DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  1100. ->where('StatusName', 'RecomendarRecharge')
  1101. ->update(['StatusValue' => $StatusValue]);
  1102. return apiReturnSuc();
  1103. }
  1104. // 修改图片地址
  1105. public function updatePic(Request $request, $id)
  1106. {
  1107. $picList = config('games.recharge_pic_config');
  1108. if ($request->isMethod('post')) {
  1109. $pic_number = $request->post('pic_number');
  1110. if ($pic_number < 0) {
  1111. return apiReturnFail('请选择图片!');
  1112. }
  1113. $pic_url = config('games.recharge_pic.recharge_pic_url');
  1114. $recharge_pic_url = str_replace('{num}', $picList[$pic_number], $pic_url);
  1115. DB::table(TableName::agent() . 'admin_configs')
  1116. ->where('id', $id)
  1117. ->update(['config_value' => $recharge_pic_url, 'pic_num' => $pic_number]);
  1118. return apiReturnSuc();
  1119. }
  1120. return view('admin.recharge.update_pic', compact('id', 'picList'));
  1121. }
  1122. // 轮询开关
  1123. public function poll(Request $request)
  1124. {
  1125. $StatusValue = $request->StatusValue ?: '';
  1126. DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo')
  1127. ->where('StatusName', 'PollSwitch')
  1128. ->update(['StatusValue' => $StatusValue]);
  1129. return apiReturnSuc();
  1130. }
  1131. // 充值礼包
  1132. public function gift()
  1133. {
  1134. $res = (new RechargeLogic())->gift();
  1135. return view('admin.recharge.gift', $res);
  1136. }
  1137. public function clearCache()
  1138. {
  1139. ClearCache::dispatch();
  1140. return apiReturnSuc();
  1141. }
  1142. public function monthCardEdit($id, Request $request) {
  1143. $monthCard = MonthCard::findOrFail($id);
  1144. if ($request->method() == 'GET') {
  1145. return view('admin.recharge.month_card_edit', [
  1146. 'monthCard' => $monthCard,
  1147. ]);
  1148. }
  1149. $validator = Validator::make($request->all(), [
  1150. 'Price' => 'required|min:1',
  1151. 'FirstReward' => 'required|int|min:1',
  1152. 'DayReward' => 'required|int|min:1',
  1153. ]);
  1154. if ($validator->fails()) {
  1155. return apiReturnFail($validator->errors()->first());
  1156. }
  1157. $monthCard->Price = $request->input('Price');
  1158. $monthCard->FirstReward = $request->input('FirstReward')*100;
  1159. $monthCard->DayReward = $request->input('DayReward')*100;
  1160. $monthCard->save();
  1161. return apiReturnSuc();
  1162. }
  1163. public function monthCardChannelEdit($id, Request $request)
  1164. {
  1165. $monthCard = MonthCard::findOrFail($id);
  1166. $gears = $monthCard->gear;
  1167. $channels = AdminConfig::where(['type' => 'pay'])->pluck('name', 'id');
  1168. $monthCardChannels = [];
  1169. foreach ($channels as $id => $name) {
  1170. $status = 0;
  1171. foreach ($gears as $v1) {
  1172. if ($v1['id'] == $id) {
  1173. $status = $v1['status'];
  1174. break;
  1175. }
  1176. }
  1177. $monthCardChannels[] = [
  1178. 'id' => $id,
  1179. 'name' => $name,
  1180. 'status' => $status
  1181. ];
  1182. }
  1183. return view('/admin/recharge/month_card_channel_edit', [
  1184. 'monthCard' => $monthCard,
  1185. 'monthCardChannels' => $monthCardChannels
  1186. ]);
  1187. }
  1188. public function monthCardSwitch($CardID)
  1189. {
  1190. $monthCard = MonthCard::findOrFail($CardID);
  1191. $monthCard->CardState = $monthCard->CardState ? 0 : 1;
  1192. $monthCard->save();
  1193. return apiReturnSuc();
  1194. }
  1195. public function monthCardChannelSwitch($CardID, $channel)
  1196. {
  1197. $monthCard = MonthCard::findOrFail($CardID);
  1198. $gears = $monthCard->gear;
  1199. if (in_array($channel, array_column($gears, 'id'))) {
  1200. $status = 0;
  1201. foreach ($gears as $k => $v) {
  1202. if ($v['id'] == $channel) {
  1203. $status = $v['status'] ? 0 : 1;
  1204. $v['status'] = $status;
  1205. $gears[$k] = $v;
  1206. break;
  1207. }
  1208. }
  1209. } else {
  1210. $status = 1;
  1211. $gears[] = [
  1212. 'id' => $channel,
  1213. 'status' => 1
  1214. ];
  1215. }
  1216. $monthCard->gear = json_encode($gears);
  1217. $monthCard->save();
  1218. return apiReturnSuc();
  1219. }
  1220. // 充值礼包配置列表
  1221. public function gift_list(Request $request)
  1222. {
  1223. try {
  1224. $list = DB::connection('write')->table('agent.dbo.recharge_gift')
  1225. ->orderBy('id', 'desc')
  1226. ->paginate(10);
  1227. foreach ($list as &$item) {
  1228. $item->day_rewards = $item->day_rewards ? json_decode($item->day_rewards, true) : null;
  1229. $item->betting_bonus = $item->betting_bonus ? json_decode($item->betting_bonus, true) : null;
  1230. $item->betting_task = $item->betting_task ? json_decode($item->betting_task, true) : null;
  1231. // task_bonus 是数字字段,保留两位小数
  1232. $item->task_bonus = $item->task_bonus !== null ? round((float)$item->task_bonus, 2) : null;
  1233. }
  1234. return view('admin.recharge.gift_list', compact('list'));
  1235. } catch (\Exception $e) {
  1236. \Log::error('充值礼包列表错误:' . $e->getMessage());
  1237. return apiReturnFail('数据库错误:' . $e->getMessage());
  1238. }
  1239. }
  1240. // 添加充值礼包
  1241. public function gift_add(Request $request)
  1242. {
  1243. \Log::info('gift_add method called', ['method' => $request->method()]);
  1244. if ($request->isMethod('post')) {
  1245. try {
  1246. // 获取最大ID
  1247. $maxId = DB::connection('write')->table('agent.dbo.recharge_gift')->max('id') ?: 0;
  1248. $data = [
  1249. 'id' => $maxId + 1,
  1250. 'bonus_instantly' => (int)$request->bonus_instantly ?: 0,
  1251. 'total_bonus' => (int)$request->total_bonus ?: 0,
  1252. 'first_pay' => (int)$request->first_pay ?: 0,
  1253. 'is_vip' => (int)$request->is_vip ?: 0,
  1254. 'valid_h' => (int)$request->valid_h ?: 0,
  1255. 'valid_h_2' => (int)$request->valid_h_2 ?: 0,
  1256. 'gift_id' => (int)$request->gift_id ?: 0,
  1257. 'gift_name' => $request->gift_name ?: '',
  1258. 'recommend' => round((float)$request->recommend ?: 0, 2),
  1259. ];
  1260. // 处理每日奖励
  1261. if ($request->has('day_rewards_enable') && $request->day_rewards_enable) {
  1262. $day_rewards = [
  1263. 'total_bonus' => (float)$request->day_rewards_total_bonus ?: 0,
  1264. 'bonus_day' => (int)$request->day_rewards_bonus_day ?: 0,
  1265. 'start_day' => (int)$request->day_rewards_start_day ?: 0,
  1266. 'bonus' => array_map('floatval', explode(',', $request->day_rewards_bonus ?: ''))
  1267. ];
  1268. $data['day_rewards'] = json_encode($day_rewards);
  1269. } else {
  1270. $data['day_rewards'] = '';
  1271. }
  1272. // 处理下注奖励
  1273. if ($request->has('betting_bonus_enable') && $request->betting_bonus_enable) {
  1274. $betting_bonus = [
  1275. 'total_bonus' => (float)$request->betting_bonus_total_bonus ?: 0,
  1276. 'per_bet' => (int)$request->betting_bonus_per_bet ?: 0,
  1277. 'per_bet_bonus' => (float)$request->betting_bonus_per_bet_bonus ?: 0
  1278. ];
  1279. $data['betting_bonus'] = json_encode($betting_bonus);
  1280. } else {
  1281. $data['betting_bonus'] = '';
  1282. }
  1283. // 处理下注任务
  1284. if ($request->has('betting_task_enable') && $request->betting_task_enable) {
  1285. $betting_task = [
  1286. 'total_bonus' => (float)$request->betting_task_total_bonus ?: 0,
  1287. 'bet_pay_times' => (int)$request->betting_task_bet_pay_times ?: 0
  1288. ];
  1289. $data['betting_task'] = json_encode($betting_task);
  1290. } else {
  1291. $data['betting_task'] = '';
  1292. }
  1293. // 处理每日任务奖励(数字字段,保留两位小数)
  1294. if ($request->has('task_bonus')) {
  1295. $data['task_bonus'] = round((float)$request->task_bonus ?: 0, 2);
  1296. } else {
  1297. $data['task_bonus'] = null;
  1298. }
  1299. DB::connection('write')->table('agent.dbo.recharge_gift')->insert($data);
  1300. return apiReturnSuc();
  1301. } catch (\Exception $e) {
  1302. \Log::error('添加充值礼包错误:' . $e->getMessage());
  1303. return apiReturnFail('添加失败:' . $e->getMessage());
  1304. }
  1305. }
  1306. \Log::info('Rendering gift_add view');
  1307. try {
  1308. // 测试简单视图
  1309. // return view('admin.recharge.gift_add_simple_test');
  1310. return view('admin.recharge.gift_add');
  1311. } catch (\Exception $e) {
  1312. \Log::error('gift_add view error: ' . $e->getMessage());
  1313. return response('View error: ' . $e->getMessage() . '<br><pre>' . $e->getTraceAsString() . '</pre>', 500);
  1314. }
  1315. }
  1316. // 修改充值礼包
  1317. public function gift_update(Request $request, $id)
  1318. {
  1319. if ($request->isMethod('post')) {
  1320. $data = [
  1321. 'bonus_instantly' => (int)$request->bonus_instantly ?: 0,
  1322. 'total_bonus' => (int)$request->total_bonus ?: 0,
  1323. 'first_pay' => (int)$request->first_pay ?: 0,
  1324. 'is_vip' => (int)$request->is_vip ?: 0,
  1325. 'valid_h' => (int)$request->valid_h ?: 0,
  1326. 'valid_h_2' => (int)$request->valid_h_2 ?: 0,
  1327. 'gift_id' => (int)$request->gift_id ?: 0,
  1328. 'gift_name' => $request->gift_name ?: '',
  1329. 'recommend' => round((float)$request->recommend ?: 0, 2),
  1330. ];
  1331. // 处理每日奖励
  1332. if ($request->has('day_rewards_enable') && $request->day_rewards_enable) {
  1333. $day_rewards = [
  1334. 'total_bonus' => (float)$request->day_rewards_total_bonus ?: 0,
  1335. 'bonus_day' => (int)$request->day_rewards_bonus_day ?: 0,
  1336. 'start_day' => (int)$request->day_rewards_start_day ?: 0,
  1337. 'bonus' => array_map('floatval', explode(',', $request->day_rewards_bonus ?: ''))
  1338. ];
  1339. $data['day_rewards'] = json_encode($day_rewards);
  1340. } else {
  1341. $data['day_rewards'] = '';
  1342. }
  1343. // 处理下注奖励
  1344. if ($request->has('betting_bonus_enable') && $request->betting_bonus_enable) {
  1345. $betting_bonus = [
  1346. 'total_bonus' => (float)$request->betting_bonus_total_bonus ?: 0,
  1347. 'per_bet' => (int)$request->betting_bonus_per_bet ?: 0,
  1348. 'per_bet_bonus' => (float)$request->betting_bonus_per_bet_bonus ?: 0
  1349. ];
  1350. $data['betting_bonus'] = json_encode($betting_bonus);
  1351. } else {
  1352. $data['betting_bonus'] = '';
  1353. }
  1354. // 处理下注任务
  1355. if ($request->has('betting_task_enable') && $request->betting_task_enable) {
  1356. $betting_task = [
  1357. 'total_bonus' => (float)$request->betting_task_total_bonus ?: 0,
  1358. 'bet_pay_times' => (int)$request->betting_task_bet_pay_times ?: 0
  1359. ];
  1360. $data['betting_task'] = json_encode($betting_task);
  1361. } else {
  1362. $data['betting_task'] = '';
  1363. }
  1364. // 处理每日任务奖励(数字字段,保留两位小数)
  1365. if ($request->has('task_bonus')) {
  1366. $data['task_bonus'] = round((float)$request->task_bonus ?: 0, 2);
  1367. } else {
  1368. $data['task_bonus'] = null;
  1369. }
  1370. DB::connection('write')->table('agent.dbo.recharge_gift')->where('id', $id)->update($data);
  1371. return apiReturnSuc();
  1372. }
  1373. $info = DB::connection('write')->table('agent.dbo.recharge_gift')->where('id', $id)->first();
  1374. $info->day_rewards = $info->day_rewards ? json_decode($info->day_rewards, true) : null;
  1375. $info->betting_bonus = $info->betting_bonus ? json_decode($info->betting_bonus, true) : null;
  1376. $info->betting_task = $info->betting_task ? json_decode($info->betting_task, true) : null;
  1377. // task_bonus 是数字字段,保留两位小数
  1378. $info->task_bonus = $info->task_bonus !== null ? round((float)$info->task_bonus, 2) : null;
  1379. return view('admin.recharge.gift_update', compact('info'));
  1380. }
  1381. // 删除充值礼包
  1382. public function gift_delete($id)
  1383. {
  1384. DB::connection('write')->table('agent.dbo.recharge_gift')->where('id', $id)->delete();
  1385. return apiReturnSuc();
  1386. }
  1387. }