MoneyController.php 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\Withdraw_rule;
  5. use Illuminate\Support\Facades\DB;
  6. use Request;
  7. /**
  8. *
  9. */
  10. class MoneyController extends Controller
  11. {
  12. /**
  13. * @return 账务管理
  14. */
  15. function index()
  16. {
  17. return view('admin.MoneyManage/Index');
  18. }
  19. //用户存取反水列表
  20. function moneyList()
  21. {
  22. $page = Request::has('page') ? Request::get('page') : 1;
  23. $limit = Request::has('limit') ? Request::get('limit') : 10;
  24. $field = Request::has('field') ? Request::get('field') : 6;
  25. $order = Request::has('order') ? Request::get('order') : 'desc';
  26. $account_name = Request::has('account_name') ? Request::get('account_name') : '';
  27. $order_id = Request::has('order_id') ? Request::get('order_id') : '';
  28. $trade_type = Request::has('trade_type') ? Request::get('trade_type') : '';
  29. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  30. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  31. $money_small = Request::has('money_small') ? Request::get('money_small') : '';
  32. $money_big = Request::has('money_big') ? Request::get('money_big') : '';
  33. $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
  34. $status = Request::has('status') ? Request::get('status') : '';
  35. $where = array();
  36. if (is_numeric($status)) {
  37. $where[] = array('money_details.status', '=', $status);
  38. }
  39. if (!empty($trade_type)) {
  40. $where[] = array('trade_type', '=', $trade_type);
  41. }
  42. if (!empty($star_time)) {
  43. $star_time = date('Y-m-d H:i:s', strtotime($star_time));
  44. $where[] = array('money_time', '>=', $star_time);
  45. }
  46. if (!empty($end_time)) {
  47. $end_time = date('Y-m-d H:i:s', strtotime($end_time));
  48. $where[] = array('money_time', '<=', $end_time);
  49. }
  50. if (!empty($money_small)) {
  51. $where[] = array('money', '>=', $money_small);
  52. }
  53. if (!empty($money_big)) {
  54. $where[] = array('money', '<=', $money_big);
  55. }
  56. if (!empty($account_name)) {
  57. if (empty($sureblur) || $sureblur == '模糊') {
  58. $where[] = array('account_name', 'like', '%' . $account_name . '%');
  59. } else {
  60. $where[] = array('money_details.account_name', '=', $account_name);
  61. }
  62. }
  63. if (!empty($order_id)) {
  64. $where = array(array('trade_id', '=', $order_id));
  65. }
  66. $moneydetails = new \App\Models\Money_details;
  67. $data = $moneydetails->getPartlist($where, 1, $limit, $field, $order);
  68. if ($data < 0) {
  69. return responseToJson($data);
  70. }
  71. $data['data'] = arrayToNumber($data['data'], ['money']);
  72. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  73. }
  74. //用户账务日志
  75. function fundLog()
  76. {
  77. $page = Request::has('page') ? Request::get('page') : 1;
  78. $limit = Request::has('limit') ? Request::get('limit') : 10;
  79. $field = Request::has('field') ? Request::get('field') : 6;
  80. $order = Request::has('order') ? Request::get('order') : 'desc';
  81. $account_name = Request::has('account_name') ? Request::get('account_name') : '';
  82. $loss_name = Request::has('loss_name') ? Request::get('loss_name') : '';
  83. $agent_name = Request::has('agent_name') ? Request::get('agent_name') : '';
  84. $startime = Request::get('startime') ? Request::get('startime') . ' 00:00:00' : '';
  85. $endtime = Request::get('endtime') ? Request::get('endtime') . ' 23:59:59' : '';
  86. if (empty($account_name) && !empty($agent_name)) {
  87. $db = new \App\Models\NagentChild;
  88. $account_name = $db->getChildStr($agent_name);
  89. }
  90. /*$whereIn = array();
  91. $whereNotin = array();
  92. $where = array();
  93. if (!empty($account_name)) {
  94. $whereIn[] = array('account_name', explode(',', $account_name));
  95. }
  96. if (!empty($loss_name)) {
  97. $whereNotin[] = array('account_name', explode(',', $loss_name));
  98. }
  99. if (!empty($startime)) {
  100. $startime = date('Y-m-d H:i:s', strtotime($startime));
  101. $where[] = array('money_time', '>=', $startime);
  102. }
  103. if (!empty($endtime)) {
  104. $endtime = date('Y-m-d H:i:s', strtotime($endtime));
  105. $where[] = array('money_time', '<=', $endtime);
  106. }*/
  107. $where = '';
  108. if (!empty($account_name)) {
  109. $account_name = explode(',', $account_name);
  110. $account_name = implode("','", $account_name);
  111. $where .= " where account_name in ('" . $account_name . "') ";
  112. }
  113. if (!empty($loss_name)) {
  114. $loss_name = explode(',', $loss_name);
  115. $loss_name = implode("','", $loss_name);
  116. $where .= empty($where) ? ' where ' : ' and ';
  117. $where .= "account_name not in ('" . $loss_name . "')";
  118. }
  119. if (!empty($startime)) {
  120. $startime = date('Y-m-d H:i:s', strtotime($startime));
  121. $where .= empty($where) ? ' where ' : ' and ';
  122. $where .= "money_time>='" . $startime . "'";
  123. }
  124. if (!empty($endtime)) {
  125. $endtime = date('Y-m-d H:i:s', strtotime($endtime));
  126. $where .= empty($where) ? ' where ' : ' and ';
  127. $where .= "money_time<='" . $endtime . "'";
  128. }
  129. $moneydetails = new \App\Models\Money_details();
  130. $data = $moneydetails->getFundlog($where, 1, $limit, $field, $order, $page);
  131. if ($data < 0) {
  132. return responseToJson($data);
  133. }
  134. $data['data'] = arrayToNumber($data['data'], ['sendmoney', 'savemoney', 'getmoney', 'winmoney', 'adminadd', 'adminpull', 'recharge_send', 'back_return']);
  135. /*$uwhere = array();
  136. $uwhere = $where;
  137. $countmoney = $moneydetails->getPatlog($where, 4);
  138. foreach ($data['data'] as $k => $v) {
  139. $data['data'][$k]['sendmoney'] = 0;
  140. $data['data'][$k]['savemoney'] = 0;
  141. $data['data'][$k]['getmoney'] = 0;
  142. $data['data'][$k]['winmoney'] = 0;
  143. $data['data'][$k]['adminadd'] = 0;
  144. $data['data'][$k]['adminpull'] = 0;
  145. $data['data'][$k]['recharge_send'] = 0;
  146. $data['data'][$k]['back_return'] = 0;
  147. $data['data'][$k]['countmoney'] = $countmoney;
  148. if (is_array($countmoney) && count($countmoney) > 0) {
  149. foreach ($countmoney as $sk => $sv) {
  150. if ($v['account_name'] == $sv['account_name']) {
  151. $data['data'][$k]['sendmoney'] = ($sv['trade_type'] == 14) ? ($data['data'][$k]['sendmoney'] + $sv['summoney']) : $data['data'][$k]['sendmoney'];
  152. $data['data'][$k]['savemoney'] = ($sv['trade_type'] == 6 || $sv['trade_type'] == 11 || $sv['trade_type'] == 14) ? ($data['data'][$k]['savemoney'] + $sv['summoney']) : $data['data'][$k]['savemoney'];
  153. $data['data'][$k]['getmoney'] = ($sv['trade_type'] == 5 || $sv['trade_type'] == 9) ? ($data['data'][$k]['getmoney'] + $sv['summoney']) : $data['data'][$k]['getmoney'];
  154. $data['data'][$k]['adminadd'] = ($sv['trade_type'] == 12 && $sv['money_type'] == 1) ? ($data['data'][$k]['adminadd'] + $sv['summoney']) : $data['data'][$k]['adminadd'];
  155. $data['data'][$k]['adminpull'] = ($sv['trade_type'] == 12 && $sv['money_type'] == 2) ? ($data['data'][$k]['adminpull'] + $sv['summoney']) : $data['data'][$k]['adminpull'];
  156. $data['data'][$k]['recharge_send'] = ($sv['trade_type'] == 13) ? ($data['data'][$k]['recharge_send'] + $sv['summoney']) : $data['data'][$k]['recharge_send'];
  157. $data['data'][$k]['back_return'] = ($sv['trade_type'] == 7 || $sv['trade_type'] == 8) ? ($data['data'][$k]['back_return'] + $sv['summoney']) : $data['data'][$k]['back_return'];
  158. }
  159. }
  160. }
  161. $data['data'][$k]['winmoney'] = $data['data'][$k]['sendmoney'] + $data['data'][$k]['savemoney'] - $data['data'][$k]['getmoney'];
  162. }
  163. $data['data'] = arrayToNumber($data['data'], ['sendmoney', 'savemoney', 'getmoney', 'winmoney', 'adminadd', 'adminpull', 'recharge_send', 'back_return']);*/
  164. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  165. }
  166. //用户资金流水列表
  167. function moneyWaterList()
  168. {
  169. $page = Request::has('page') ? Request::get('page') : 1;
  170. $limit = Request::has('limit') ? Request::get('limit') : 10;
  171. $field = Request::has('field') ? Request::get('field') : 6;
  172. $order = Request::has('order') ? Request::get('order') : 'desc';
  173. $field = $field == 'change_cash' ? 'money_details.money' : $field;
  174. $account_name = Request::has('account_name') ? Request::get('account_name') : '';
  175. $order_id = Request::has('order_id') ? Request::get('order_id') : '';
  176. $trade_type = Request::has('trade_type') ? Request::get('trade_type') : '';
  177. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  178. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  179. $money_small = Request::has('money_small') ? Request::get('money_small') : '';
  180. $money_big = Request::has('money_big') ? Request::get('money_big') : '';
  181. $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
  182. $status = Request::has('status') ? Request::get('status') : '';
  183. $isuser = Request::has('isuser') ? Request::get('isuser') : 2;
  184. if ($isuser == 1) {
  185. $star_time = '';
  186. $end_time = '';
  187. }
  188. $where = array();
  189. if (!empty($account_name)) {
  190. if (empty($sureblur) || $sureblur == '模糊') {
  191. $where[] = array('money_details.account_name', 'like', '%' . $account_name . '%');
  192. } else {
  193. $where[] = array('money_details.account_name', '=', $account_name);
  194. }
  195. }
  196. if (!empty($trade_type)) {
  197. $where[] = array('trade_type', '=', $trade_type);
  198. }
  199. if (!empty($status)) {
  200. $where[] = array('money_details.status', '=', $status);
  201. }
  202. if (!empty($star_time)) {
  203. $star_time = date('Y-m-d H:i:s', strtotime($star_time));
  204. $where[] = array('money_time', '>=', $star_time);
  205. }
  206. if (!empty($end_time)) {
  207. $end_time = date('Y-m-d H:i:s', strtotime($end_time));
  208. $where[] = array('money_time', '<=', $end_time);
  209. }
  210. if (!empty($money_small)) {
  211. $where[] = array('money_details.money', '>=', $money_small);
  212. }
  213. if (!empty($money_big)) {
  214. $where[] = array('money_details.money', '<=', $money_big);
  215. }
  216. if (!empty($order_id)) {
  217. $where = array(array('trade_id', '=', $order_id));
  218. }
  219. if (count($where) == 0) {
  220. return \App\Lib\DataTable\DataTable::init()->toJson(array(), 0, 0, $where);
  221. }
  222. $moneydetails = new \App\Models\Money_details();
  223. $data = $moneydetails->getMoneylist($where, 1, $limit, $field, $order);
  224. if ($data < 0) {
  225. return responseToJson($data);
  226. }
  227. $usercash = array();
  228. $data['data'] = arrayToNumber($data['data'], ['money']);
  229. foreach ($data['data'] as $k => $v) {
  230. /*if(isset($usercash[$v['account_name']])){
  231. if($v['money_type'] == 1){
  232. $ccash = $usercash[$v['account_name']] + $v['money'];
  233. }else{
  234. $ccash = $usercash[$v['account_name']] - $v['money'];
  235. }
  236. //$usercash[$v['account_name']] = $ccash;
  237. if($v['money_cash'] != $ccash){
  238. $data['data'][$k]['money_cash'] = $ccash;
  239. }
  240. }else{
  241. $usercash[$v['account_name']] = $v['money_cash'];
  242. }*/
  243. if ($v['trade_type'] == 9 && strpos($v['trade_desc'], '撤销') !== false) {
  244. if (strpos($v['trade_desc'], '重新开奖') !== false) {
  245. $data['data'][$k]['isdel'] = 2;
  246. } else {
  247. $data['data'][$k]['isdel'] = 1;
  248. }
  249. } else {
  250. $data['data'][$k]['isdel'] = 2;
  251. }
  252. $data['data'][$k]['money_time'] = date('Y-m-d H:i:s', strtotime($v['money_time']));
  253. }
  254. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  255. }
  256. //交易订单详情
  257. function moneyDetails()
  258. {
  259. $tradeid = Request::has('tradeid') ? Request::get('tradeid') : '';
  260. if (empty($tradeid)) {
  261. return responseToJson(-3021000202); //未提交对应订单号
  262. }
  263. $moneydetails = new \App\Models\Money_details();
  264. $data = $moneydetails->getOrderDetails($tradeid, 3, 'account_bank', 'account_identity', 'account_identity');
  265. return responseToJson($data);
  266. }
  267. //充值记录
  268. function recharge()
  269. {
  270. $page = Request::has('page') ? Request::get('page') : 1;
  271. $limit = Request::has('limit') ? Request::get('limit') : 10;
  272. $field = Request::has('field') ? Request::get('field') : 6;
  273. $order = Request::has('order') ? Request::get('order') : 'desc';
  274. $account_name = Request::has('account_name') ? Request::get('account_name') : '';
  275. $order_id = Request::has('order_id') ? Request::get('order_id') : '';
  276. $recharge_type = Request::has('recharge_type') ? Request::get('recharge_type') : '';
  277. $status = Request::has('status') ? Request::get('status') : '';
  278. $apply_startime = Request::get('apply_startime') ? Request::get('apply_startime') . ' 00:00:00' : '';
  279. $apply_endtime = Request::get('apply_endtime') ? Request::get('apply_endtime') . ' 23:59:59' : '';
  280. $haddle_startime = Request::get('haddle_startime') ? Request::get('haddle_startime') . ' 00:00:00' : '';
  281. $haddle_endtime = Request::get('haddle_endtime') ? Request::get('haddle_endtime') . ' 23:59:59' : '';
  282. $money_small = Request::has('money_small') ? Request::get('money_small') : '';
  283. $money_big = Request::has('money_big') ? Request::get('money_big') : '';
  284. $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
  285. if($status==-1)$status='';
  286. $where = array();
  287. $whereIn = array();
  288. $sql = '';
  289. if (!empty($recharge_type) && empty($status)) {
  290. $where[] = array('recharge_type', '=', $recharge_type);
  291. }
  292. if (!empty($recharge_type)) {
  293. $where[] = array('recharge_type', '=', $recharge_type);
  294. }
  295. if ($status || $status === '0') $where[] = array('status', '=', $status);
  296. if (!empty($apply_startime)) {
  297. $apply_startime = date('Y-m-d H:i:s', strtotime($apply_startime));
  298. $where[] = array('apply_time', '>=', $apply_startime);
  299. }
  300. if (!empty($apply_endtime)) {
  301. $apply_endtime = date('Y-m-d H:i:s', strtotime($apply_endtime));
  302. $where[] = array('apply_time', '<=', $apply_endtime);
  303. }
  304. if (!empty($haddle_startime)) {
  305. $haddle_startime = date('Y-m-d H:i:s', strtotime($haddle_startime));
  306. $where[] = array('complete_time', '>=', $haddle_startime);
  307. }
  308. if (!empty($haddle_endtime)) {
  309. $haddle_endtime = date('Y-m-d H:i:s', strtotime($haddle_endtime));
  310. $where[] = array('complete_time', '<=', $haddle_endtime);
  311. }
  312. if (!empty($money_small)) {
  313. $where[] = array('money', '>=', $money_small);
  314. }
  315. if (!empty($money_big)) {
  316. $where[] = array('money', '<=', $money_big);
  317. }
  318. if (!empty($account_name)) {
  319. if (empty($sureblur) || $sureblur == '模糊') {
  320. $where[] = array('account_name', 'like', '%' . $account_name . '%');
  321. } else {
  322. $where[] = array('account_name', '=', $account_name);
  323. }
  324. }
  325. if (!empty($order_id)) {
  326. $where = array(array('order_id', '=', $order_id));
  327. }
  328. $moneydetails = new \App\Models\Money_recharge();
  329. if ($status || (int)$status < -1) {
  330. $sql = "status={$status}";
  331. }
  332. $data = $moneydetails->getRechargelist($where, 1, $limit, $field, $order, '', '', '', $whereIn, $sql);
  333. if ($data < 0) {
  334. return $data;
  335. }
  336. $data['data'] = arrayToNumber($data['data'], ['money', 'money_cash']);
  337. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  338. }
  339. //待审核充值记录量获取
  340. function getRechargeNum()
  341. {
  342. $recharge = new \App\Models\Money_recharge();
  343. $status = Request::has('status') ? Request::get('status') : 1;
  344. $data = $recharge->getCount($status);
  345. return responseToJson(1, '', $data);
  346. }
  347. //充值订单详情
  348. function rechargeDetails()
  349. {
  350. $orderid = Request::has('orderid') ? Request::get('orderid') : '';
  351. if (empty($orderid)) {
  352. return responseToJson(-3020000202); //未提交对应订单号
  353. }
  354. $rechargedetails = new \App\Models\Money_recharge();
  355. $data = $rechargedetails->getOrderDetails($orderid, 3, 'account_bank', 'account_identity', 'account_identity');
  356. return responseToJson($data);
  357. }
  358. //提现记录
  359. function withdraw()
  360. {
  361. $page = Request::has('page') ? Request::get('page') : 1;
  362. $limit = Request::has('limit') ? Request::get('limit') : 10;
  363. $field = Request::has('field') ? Request::get('field') : 'id';
  364. $order = Request::has('order') ? Request::get('order') : 'desc';
  365. $grade = Request::has('grade') ? Request::get('grade') : '-1';
  366. $account_name = Request::has('account_name') ? Request::get('account_name') : '';
  367. $order_id = Request::has('order_id') ? Request::get('order_id') : '';
  368. $bank_user = Request::has('bank_user') ? Request::get('bank_user') : '';
  369. $money_small = Request::has('money_small') ? Request::get('money_small') : '';
  370. $money_big = Request::has('money_big') ? Request::get('money_big') : '';
  371. $apply_startime = Request::get('apply_startime') ? Request::get('apply_startime') . ' 00:00:00' : '';
  372. $apply_endtime = Request::get('apply_endtime') ? Request::get('apply_endtime') . ' 23:59:59' : '';
  373. $haddle_startime = Request::get('haddle_startime') ? Request::get('haddle_startime') . ' 00:00:00' : '';
  374. $haddle_endtime = Request::get('haddle_endtime') ? Request::get('haddle_endtime') . ' 23:59:59' : '';
  375. $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'on';
  376. $status = Request::has('status') ? Request::get('status') : '';
  377. $where = array();
  378. if ($grade < 0) {
  379. // $where .= ' AND grade=';
  380. $grade = '';
  381. } else {
  382. $grade = ($grade == 10) ? '' : $grade;
  383. $where[] = array('grade', '=', $grade);
  384. }
  385. if (!empty($bank_user)) {
  386. $where[] = array('bank_user', 'like', '%' . $bank_user . '%');
  387. }
  388. if (!empty($money_small)) {
  389. $where[] = array('money', '>=', $money_small);
  390. }
  391. if (!empty($money_big)) {
  392. $where[] = array('money', '<=', $money_big);
  393. }
  394. if (!empty($apply_startime)) {
  395. $apply_startime = date('Y-m-d H:i:s', strtotime($apply_startime));
  396. $where[] = array('apply_time', '>=', $apply_startime);
  397. }
  398. if (!empty($apply_endtime)) {
  399. $apply_endtime = date('Y-m-d H:i:s', strtotime($apply_endtime));
  400. $where[] = array('apply_time', '<=', $apply_endtime);
  401. }
  402. if (!empty($haddle_startime)) {
  403. $haddle_startime = date('Y-m-d H:i:s', strtotime($haddle_startime));
  404. $where[] = array('pass_time', '>=', $haddle_startime);
  405. }
  406. if (!empty($haddle_endtime)) {
  407. $haddle_endtime = date('Y-m-d H:i:s', strtotime($haddle_endtime));
  408. $where[] = array('pass_time', '<=', $haddle_endtime);
  409. }
  410. if (!empty($status) && $status != 4) {
  411. if ($status == 3) {
  412. $where[] = array('status', '=', '0');
  413. } else {
  414. $where[] = array('status', '=', $status);
  415. }
  416. }
  417. if (!empty($account_name)) {
  418. if (empty($sureblur) || $sureblur == 'off') {
  419. $where = array(array('account_name', 'like', '%' . $account_name . '%'));
  420. } else {
  421. $where = array(array('account_name', '=', $account_name));
  422. }
  423. }
  424. if (!empty($order_id)) {
  425. $where = array(array('order_id', '=', $order_id));
  426. }
  427. $takedetails = new \App\Models\Money_take();
  428. $jointable = '';
  429. if (is_numeric($grade)) {
  430. $jointable = 'account_detailed';
  431. }
  432. $data = $takedetails->getTakelist($where, 1, $limit, $field, $order, $jointable, $grade);
  433. if ($data < 0) {
  434. return responseToJson($data);
  435. }
  436. $take_status = trans('status.money_take.status');
  437. $has_root = 0;
  438. if (\App\Models\Role::hasRoot('/enable/show/bankcard') < 0) {
  439. $has_root = 1;
  440. }
  441. foreach ($data['data'] as $k => $v) {
  442. $data['data'][$k]['apply_time'] = $v['order_id'] . '<br>' . $v['apply_time'];
  443. $data['data'][$k]['status'] = ($v['status'] == 0) ? $take_status[3] : $take_status[$v['status']];
  444. // $data['data'][$k]['bank_info_no'] = $v['bank_info'] . '<br>' . bankHide($v['bank_no']);
  445. $has_root == 1 ? $data['data'][$k]['bank_no'] = bankHide($v['bank_no']) : null;
  446. $data['data'][$k]['bank_user_address'] = $v['bank_user'] . '<br>' . $v['bank_address'];
  447. // $data['data'][$k]['pass_time'] = '<p style="color:red;">'.$data['data'][$k]['status'] . '<br>' . $v['pass_time'];
  448. }
  449. $data['data'] = arrayToNumber($data['data'], ['money']);
  450. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  451. }
  452. //待审核提现记录量获取
  453. function getTakeNum()
  454. {
  455. $take = new \App\Models\Money_take();
  456. $status = Request::has('status') ? Request::get('status') : 3;
  457. $data = $take->getCountnum($status);
  458. return responseToJson(1, '', $data);
  459. }
  460. //提现订单详情
  461. function withdrawDetails()
  462. {
  463. $orderid = Request::has('orderid') ? Request::get('orderid') : '';
  464. if (empty($orderid)) {
  465. return responseToJson(-3020100202); //未提交对应订单号
  466. }
  467. $takedetails = new \App\Models\Money_take();
  468. $data = $takedetails->getOrderDetails($orderid, 3, '', '', '', 2);
  469. if ($data < 0) {
  470. return responseToJson($data);
  471. }
  472. $data['trade_type'] = 5;
  473. return responseToJson($data);
  474. }
  475. //回水记录
  476. function returnList()
  477. {
  478. $page = Request::has('page') ? Request::get('page') : 1;
  479. $limit = Request::has('limit') ? Request::get('limit') : 10;
  480. $field = Request::has('field') ? Request::get('field') : 6;
  481. $order = Request::has('order') ? Request::get('order') : 'desc';
  482. $account_name = Request::has('account_name') ? Request::get('account_name') : '';
  483. $order_id = Request::has('order_id') ? Request::get('order_id') : '';
  484. $haddle_startime = Request::get('haddle_startime') ? Request::get('haddle_startime') . ' 00:00:00' : '';
  485. $haddle_endtime = Request::get('haddle_endtime') ? Request::get('haddle_endtime') . ' 23:59:59' : '';
  486. $money_small = Request::has('money_small') ? Request::get('money_small') : '';
  487. $money_big = Request::has('money_big') ? Request::get('money_big') : '';
  488. $lossmoney_small = Request::has('lossmoney_small') ? Request::get('lossmoney_small') : '';
  489. $lossmoney_big = Request::has('lossmoney_big') ? Request::get('lossmoney_big') : '';
  490. $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
  491. $where = array();
  492. if (!empty($account_name)) {
  493. if (empty($sureblur) || $sureblur == '模糊') {
  494. $where[] = array('account_name', 'like', '%' . $account_name . '%');
  495. } else {
  496. $where[] = array('account_name', '=', $account_name);
  497. }
  498. }
  499. if (!empty($haddle_startime)) {
  500. $haddle_startime = date('Y-m-d H:i:s', strtotime($haddle_startime));
  501. $where[] = array('processing_time', '>=', $haddle_startime);
  502. }
  503. if (!empty($haddle_endtime)) {
  504. $haddle_endtime = date('Y-m-d H:i:s', strtotime($haddle_endtime));
  505. $where[] = array('processing_time', '<=', $haddle_endtime);
  506. }
  507. if (!empty($money_small)) {
  508. $where[] = array('money', '>=', $money_small);
  509. }
  510. if (!empty($money_big)) {
  511. $where[] = array('money', '<=', $money_big);
  512. }
  513. if (!empty($lossmoney_small)) {
  514. $where[] = array('total_money', '>=', $lossmoney_small);
  515. }
  516. if (!empty($lossmoney_big)) {
  517. $where[] = array('total_money', '<=', $lossmoney_big);
  518. }
  519. if (!empty($order_id)) {
  520. $where = array(array('order_id', '=', $order_id));
  521. }
  522. $moneydetails = new \App\Models\Money_return();
  523. $data = $moneydetails->getReturnlist($where, 1, $limit, $field, $order);
  524. if ($data < 0) {
  525. return responseToJson($data);
  526. }
  527. foreach ($data['data'] as $k => $v) {
  528. $data['data'][$k]['orderid_time'] = $v['order_id'] . '<br>' . $v['processing_time'];
  529. }
  530. $data['data'] = arrayToNumber($data['data'], array('return_money', 'total_money'));
  531. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
  532. }
  533. //回水订单详情
  534. function returnDetails()
  535. {
  536. $orderid = Request::has('orderid') ? Request::get('orderid') : '';
  537. if (empty($orderid)) {
  538. return responseToJson(-3020200202); //未提交对应订单号
  539. }
  540. $returndetails = new \App\Models\Money_return();
  541. $data = $returndetails->getOrderDetails($orderid, 3, 'account_bank', 'account_identity', 'account_identity');
  542. if ($data < 0) {
  543. return responseToJson($data);
  544. }
  545. $data['trade_type'] = 8;
  546. return responseToJson($data);
  547. }
  548. //加款扣款
  549. function moneyChange()
  550. {
  551. $changeType = Request::has('changetype') ? Request::get('changetype') : '';
  552. $account_identity = Request::has('account_identity') ? Request::get('account_identity') : '';
  553. $money = Request::has('money') ? Request::get('money') : '';
  554. $bili = Request::has('bili') ? Request::get('bili') : 0;
  555. $reson = Request::has('reson') ? Request::get('reson') : 0;
  556. $orderid = Request::has('orderid') ? Request::get('orderid') : '';
  557. $status = Request::has('status') ? Request::get('status') : 1; //1:成功 2:失败
  558. if (empty($changeType)) {
  559. return responseToJson(-3020300302); //未提交加款扣款类型 1:加款,2:扣款
  560. }
  561. if (empty($money)) {
  562. return responseToJson(-3020300402); //操作金额不能为空
  563. }
  564. if (empty($account_identity)) {
  565. return responseToJson(-3020300502); //未提交用户ID
  566. }
  567. if ($bili > 0) {
  568. $money = $money * $bili;
  569. }
  570. //第三方充值
  571. if (empty($orderid)) {
  572. $res = $status; //加款扣款
  573. if ($res == 1) {
  574. return responseToJson($res);
  575. }
  576. return responseToJson(-3020300602); //加款扣款失败
  577. }
  578. //活动加款扣款
  579. $res = $status; //加款扣款
  580. if ($res == 1) {
  581. return responseToJson($res);
  582. }
  583. return responseToJson(-3020300702); //加款扣款失败
  584. }
  585. //加款扣款用户信息获取
  586. function getUser()
  587. {
  588. $page = Request::has('page') ? Request::get('page') : 1;
  589. $limit = Request::has('limit') ? Request::get('limit') : 10;
  590. $field = Request::has('field') ? Request::get('field') : 'id';
  591. $order = Request::has('order') ? Request::get('order') : 'desc';
  592. $account = Request::has('account_name') ? Request::get('account_name') : '';
  593. $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
  594. if (empty($account)) {
  595. $data = array(
  596. array(
  597. 'account_name' => '',
  598. 'account_identity' => '',
  599. 'cash' => '',
  600. ),
  601. );
  602. return \App\Lib\DataTable\DataTable::init()->toJson($data, 1);
  603. }
  604. $account = strtolower($account);
  605. $where = array();
  606. if (!empty($account)) {
  607. // if (empty($sureblur) || $sureblur == '模糊') {
  608. // $where[] = array('account', 'like', '%' . $account . '%');
  609. // } else {
  610. $where[] = array('account', '=', $account);
  611. // }
  612. }
  613. $userdetails = new \App\Models\Account();
  614. $data = $userdetails->getUserDetails($where, 3, 'account_detailed', 'identity', 'account_identity', $page, $limit, $field, $order);
  615. if ($data < 0) {
  616. return responseToJson($data); //没有用户数据
  617. }
  618. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
  619. }
  620. //回水管理
  621. function returnInfo()
  622. {
  623. $page = Request::has('page') ? Request::get('page') : 1;
  624. $limit = Request::has('limit') ? Request::get('limit') : 10;
  625. // $field = Request::has('field') ? Request::get('field') : '';
  626. // $order = Request::has('order') ? Request::get('order') : 'desc';
  627. $account_name = Request::has('account_name') ? Request::get('account_name') : '';
  628. // $account_name = 'gust17687';
  629. $gametype = Request::has('gametype') ? Request::get('gametype') : '';
  630. $lossmoney_small = Request::has('lossmoney_small') ? Request::get('lossmoney_small') : '';
  631. $lossmoney_big = Request::has('lossmoney_big') ? Request::get('lossmoney_big') : '';
  632. $sureblur = Request::has('sureblur') ? Request::get('sureblur') : '';
  633. $star_time = Request::get('star_time') ? Request::get('star_time') . ' 00:00:00' : '';
  634. $end_time = Request::get('end_time') ? Request::get('end_time') . ' 23:59:59' : '';
  635. $total_money = Request::has('total_money') ? Request::get('total_money') : '';
  636. $where = array();
  637. $user_where = array();
  638. $wheregame = array();
  639. $orwhere = array();
  640. $having = '';
  641. if (!empty($total_money)) {
  642. $having = 'sum("get_money")<=' . (-$total_money);
  643. }
  644. if (!empty($account_name)) {
  645. if (empty($sureblur) || $sureblur == '模糊') {
  646. $where[] = array('account_name', 'like', '%' . $account_name . '%');
  647. } else {
  648. $where[] = array('account_name', '=', $account_name);
  649. }
  650. $user_where = array('account' => $account_name, 'status' => 4);
  651. }
  652. if (!empty($gametype) || $gametype != 0) {
  653. $where[] = array('game_name', '=', $gametype);
  654. } else {
  655. // $wheregame[] = array('game_name', '=', 'xy28');
  656. // $orwhere[] = array('game_name', '=', 'jnd28');
  657. $wheregame = array('xy28', 'jnd28');
  658. }
  659. if (!empty($lossmoney_small)) {
  660. $where[] = array('total_money', '>=', $lossmoney_small);
  661. }
  662. if (!empty($lossmoney_big)) {
  663. $where[] = array('total_money', '<=', $lossmoney_big);
  664. }
  665. if (!empty($star_time)) {
  666. $star_time = date('Y-m-d H:i:s', strtotime($star_time));
  667. $where[] = array('money_time', '>=', $star_time);
  668. }
  669. if (!empty($end_time)) {
  670. $end_time = date('Y-m-d H:i:s', strtotime($end_time));
  671. $where[] = array('money_time', '<=', $end_time);
  672. }
  673. // $user= new \App\Model\Account;
  674. // $users=$user->Accounta($user_where);
  675. $moneyreturn = new \App\Models\MoneyBuy();
  676. // if ($users > 0){
  677. // return responseToJson(-3020400202);
  678. // }
  679. $data = $moneyreturn->getMoneyReturn($where, 1, $limit, $wheregame, $orwhere, $having);
  680. if ($data < 0) {
  681. return responseToJson($data);
  682. }
  683. // $game = trans('money');
  684. // var_dump($data['data']);
  685. // $gamearr = $game['gametype'];
  686. foreach ($data['data'] as $k => $v) {
  687. // $data['data'][$k]['game_name'] = $gamearr[$v['game_name']];
  688. if ($v['total_money'] < 0) {
  689. $data['data'][$k]['total_money'] = floatval(abs($v['total_money']));
  690. } else {
  691. unset($data['data'][$k]);
  692. }
  693. // $data['data'][$k]['total_money'] = floatval($v['total_money']);
  694. }
  695. // var_dump($data['data'])
  696. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
  697. }
  698. //回水
  699. function returnAct()
  700. {
  701. $status = Request::has('status') ? Request::get('status') : 1; //1:成功 2:失败
  702. $systemUser = Request::has('systemuser') ? Request::get('systemuser') : ''; //管理员名
  703. $data = Request::has('data') ? Request::get('data') : '';
  704. //$data = '{"data":[{"account_name":"147ceshi","account_identity":"3df48c6c-f805-ed8b-1d2f-e4e95f09242f","total_money":200,"status":2,"game_name":"\u5e78\u8fd028","ratio":0.1},{"account_name":"123daili","account_identity":"f243a05d-f0b4-6eee-e8ad-53472612230e","total_money":0,"status":1,"game_name":"\u5e78\u8fd028","ratio":0.1}]}';
  705. if (empty($data)) {
  706. return Rens(-3020400202); //未提交回水信息
  707. }
  708. if (empty($systemUser)) {
  709. return Rens(-3020400302); //未提交操作管理员信息
  710. }
  711. $data = json_decode($data);
  712. $data = $data->data;
  713. $addData = array();
  714. foreach ($data as $k => $v) {
  715. $addData[] = array(
  716. 'info_identity' => '',
  717. 'order_id' => '',
  718. 'account_name' => $v->account_name,
  719. 'account_identity' => $v->account_identity,
  720. 'money' => $v->total_money * $v->ratio,
  721. 'total_money' => $v->total_money,
  722. 'sysetem_user' => $systemUser,
  723. 'processing_time' => date('Y-m-d H:i:s', time()),
  724. 'ratio' => $v->ratio,
  725. 'reason' => '',
  726. );
  727. }
  728. foreach ($addData as $v) {
  729. if (!empty($v)) {
  730. $res = $status;
  731. }
  732. }
  733. if ($res == 1) {
  734. return Rens($res);
  735. }
  736. return Rens(-3020400402); //回水操作失败
  737. }
  738. //提现账单详情
  739. function stateDetails()
  740. {
  741. $page = Request::has('page') ? Request::get('page') : 1;
  742. $limit = Request::has('limit') ? Request::get('limit') : 10;
  743. $field = Request::has('field') ? Request::get('field') : 6;
  744. $order = Request::has('order') ? Request::get('order') : 'desc';
  745. $account_name = Request::has('account_name') ? Request::get('account_name') : '';
  746. $account_identity = Request::has('account_identity') ? Request::get('account_identity') : '';
  747. $status = Request::has('status') ? Request::get('status') : '';
  748. if (empty($account_name) && empty($account_identity)) {
  749. return responseToJson(-3020200102); //未提交对应用户信息
  750. }
  751. if (empty($status)) {
  752. return responseToJson(-3020200202); //未提交对应信息状态
  753. }
  754. $where = array();
  755. if (!empty($account_name)) {
  756. $where[] = array('account_name', '=', $account_name);
  757. } else {
  758. $where[] = array('account_identity', '=', $account_identity);
  759. }
  760. if ($status == 3) {
  761. $where[] = array('money_take.status', '=', '0');
  762. } else {
  763. $where[] = array('money_take.status', '=', $status);
  764. }
  765. $takedetails = new \App\Models\Money_take();
  766. $data = $takedetails->getTotalDetails($where, 1, $limit, $page, $field, $order);
  767. if ($data < 0) {
  768. return responseToJson($data);
  769. }
  770. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
  771. }
  772. //充值账单详情
  773. function rechargesDetails()
  774. {
  775. $page = Request::has('page') ? Request::get('page') : 1;
  776. $limit = Request::has('limit') ? Request::get('limit') : 10;
  777. $field = Request::has('field') ? Request::get('field') : 6;
  778. $order = Request::has('order') ? Request::get('order') : 'desc';
  779. $account_name = Request::has('account_name') ? Request::get('account_name') : '';
  780. $account_identity = Request::has('account_identity') ? Request::get('account_identity') : '';
  781. $status = Request::has('status') ? Request::get('status') : '';
  782. if (empty($account_name) && empty($account_identity)) {
  783. return responseToJson(-3020200102); //未提交对应用户信息
  784. }
  785. if (empty($status)) {
  786. return responseToJson(-3020200202); //未提交对应信息状态
  787. }
  788. $where = array();
  789. if (!empty($account_name)) {
  790. $where[] = array('money_recharge.account_name', '=', $account_name);
  791. } else {
  792. $where[] = array('money_recharge.account_identity', '=', $account_identity);
  793. }
  794. $where[] = array('money_recharge.status', '=', $status);
  795. $takedetails = new \App\Models\Money_recharge();
  796. $data = $takedetails->getTotalDetails($where, 1, $limit, $page, $field, $order);
  797. if ($data < 0) {
  798. return responseToJson($data);
  799. }
  800. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
  801. }
  802. //用户回水详情列表
  803. function userreturnList()
  804. {
  805. $page = Request::has('page') ? Request::get('page') : 1;
  806. $limit = Request::has('limit') ? Request::get('limit') : 10;
  807. $field = Request::has('field') ? Request::get('field') : 13;
  808. $order = Request::has('order') ? Request::get('order') : 'desc';
  809. $account_name = Request::has('account_name') ? Request::get('account_name') : '';
  810. $game_name = Request::has('game_name') ? Request::get('game_name') : '';
  811. if (empty($account_name) && empty($account_identity)) {
  812. return responseToJson(-3020300102); //未提交对应用户信息
  813. }
  814. $game_name = ($game_name == '幸运28') ? 'xy28' : ($game_name == '加拿大28' ? 'jnd28' : '');
  815. if (empty($game_name)) {
  816. return responseToJson(-3020300202); //未提交对应游戏信息
  817. }
  818. $where = array();
  819. $where[] = array('account_name', '=', $account_name);
  820. $where[] = array('game_name', '=', $game_name);
  821. $moneybuy = new \App\Models\MoneyBuy();
  822. $data = $moneybuy->getUserReturndetail($where, 1, $limit, $field, $order);
  823. if ($data < 0) {
  824. return responseToJson($data);
  825. }
  826. foreach ($data['data'] as $k => $v) {
  827. $data['data'][$k]['money_time'] = $v['order_id'] . '<br>' . $v['money_time'];
  828. }
  829. return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
  830. }
  831. //统计
  832. /**
  833. * 充值金额统计
  834. * 'money description'
  835. * @return 'type' 'description'
  836. */
  837. function rechargeMoneyCount()
  838. {
  839. $where = Request::has('where') ? Request::get('where') : '';
  840. $db = new \App\Models\Money_recharge;
  841. $data = $db->rechargeMoneyCount($where);
  842. return responseToJson($data);
  843. }
  844. /**
  845. * 提款金额统计
  846. * 'money description'
  847. * @return 'type' 'description'
  848. */
  849. function takeMoneyCount()
  850. {
  851. $where = Request::has('where') ? Request::get('where') : '';
  852. $db = new \App\Models\Money_take;
  853. $data = $db->takeMoneyCount($where);
  854. return responseToJson($data);
  855. }
  856. /**
  857. * 汇款金额统计
  858. * 'money description'
  859. * @return 'type' 'description'
  860. */
  861. function sendMoneyCount()
  862. {
  863. $where = Request::has('where') ? Request::get('where') : '';
  864. $db = new \App\Models\Money_recharge;
  865. $data = $db->sendMoneyCount($where);
  866. return responseToJson($data);
  867. }
  868. /**
  869. * 回水金额统计
  870. * 'money description'
  871. * @return 'type' 'description'
  872. */
  873. function returnMoneyCount()
  874. {
  875. $where = Request::has('where') ? Request::get('where') : '';
  876. $db = new \App\Models\Money_return;
  877. $data = $db->returnMoneyCount($where);
  878. return responseToJson($data);
  879. }
  880. //获取交易表名后缀
  881. private function getTradetable($num)
  882. {
  883. $type = array(
  884. '1' => 'buy',
  885. '2' => 'buy',
  886. '3' => 'buy',
  887. '4' => 'prize',
  888. '5' => 'take',
  889. '6' => 'recharge',
  890. '7' => 'back',
  891. '8' => 'return',
  892. '11' => 'recharge',
  893. '12' => 'recharge',
  894. '13' => 'recharge',
  895. '14' => 'recharge',
  896. );
  897. return $type[$num];
  898. }
  899. //汇款
  900. function Rimit($order_id, $rale)
  901. {
  902. DB::beginTransaction();
  903. $db = new \App\Models\Money_recharge;
  904. $accountDB = new \App\Models\Account_detailed(); //用户详情
  905. $info = $db->getRimitDetails($order_id);
  906. if ($info < 0) {
  907. return $info;
  908. }
  909. $limitroot = new \App\Models\System_user();
  910. $limitmoney = $limitroot->checkActMoney($info['money']);
  911. if ($limitmoney < 0) {
  912. return $limitmoney;
  913. }
  914. //更新统计数据
  915. $data = $info;
  916. $info['complete_time'] = date('Y-m-d H:i:s');
  917. $data['pass_time'] = $info['complete_time'];
  918. $res = \App\Models\Money_count::AddCountinfo($data, 'save');
  919. if ($res < 0) {
  920. DB::rollback();//事务回滚
  921. return responseToJson($res);
  922. }
  923. //更新数据状态
  924. $res = $db->updateStatus($order_id, 1);
  925. if ($res < 0) {
  926. DB::rollBack();
  927. return $res;
  928. }
  929. $acount = new \App\Models\Account_detailed;
  930. $acount_info = $acount->getInfoBy($info['account_identity']);
  931. $prize_moeny = 0;
  932. //添加汇款详情
  933. unset($info['apply_time']);
  934. unset($info['complete_time']);
  935. unset($info['status']);
  936. unset($info['recharge_type']);
  937. unset($info['recharge_type']);
  938. unset($info['id']);
  939. unset($info['info_identity']);
  940. unset($info['money_cash']);
  941. unset($info['order_id']);
  942. unset($info['remark']);
  943. $rate = $info['rate'] ?? 1;
  944. if (isset($info['rate']))
  945. unset($info['rate']);
  946. //获取充值备注信息
  947. $remarkinfo = \App\Models\Recharge_Remark::where('order_id', $order_id)->first();
  948. if (!$remarkinfo) {
  949. return -30010102;
  950. }
  951. $remarkinfo = $remarkinfo->toArray();
  952. //添加汇款详情
  953. $info["sysetem_user"] = session('adminInfo.admin_name');
  954. $res = $this->addLog($info, 14, $acount_info['cash'], $rate, $order_id);
  955. if ($res < 0) {
  956. DB::rollBack();
  957. return $res;
  958. }
  959. //更新余额
  960. $rimt_res = $accountDB->addMoney($acount_info['account_identity'], $info['money']);
  961. if ($rimt_res < 0) {
  962. DB::rollBack();
  963. return $rimt_res;
  964. }
  965. //含赠送金额时插入赠送新数据
  966. if (!empty($rale)) {
  967. $order_id2 = OrderID();
  968. $prize_moeny = $info['money'] * $rale; //奖励金额
  969. $money_cash = $prize_moeny + $acount_info['cash'] + $info['money'];
  970. $data = array(
  971. 'money' => $prize_moeny,
  972. "account_name" => $info['account_name'],
  973. "account_identity" => $info['account_identity'],
  974. "sysetem_user" => session('adminInfo.admin_name'),
  975. "reason" => '汇款赠送1',
  976. "money_cash" => $money_cash,
  977. );
  978. $re_data = $data;
  979. $data['order_id'] = $order_id2;
  980. $data['apply_time'] = date('Y-m-d H:i:s');
  981. $data['complete_time'] = date('Y-m-d H:i:s');
  982. $data['status'] = 1;
  983. $data['recharge_type'] = '汇款赠送';
  984. //添加充值赠送备注信息
  985. $remarkdata = array(
  986. 'order_id' => $order_id2,
  987. 'name' => $remarkinfo['name'],
  988. 'recharge_time' => $remarkinfo['recharge_time'],
  989. 'money' => $prize_moeny,
  990. );
  991. $rminfo = \App\Models\Recharge_Remark::insert($remarkdata);
  992. if (!$rminfo) {
  993. DB::rollBack();
  994. return -30010202;
  995. }
  996. $order_id2 = $db->addMoney($data);
  997. if ($order_id2 < 0) {
  998. DB::rollBack();
  999. return $order_id2;
  1000. }
  1001. //添加充值详情
  1002. $res2 = $this->addLog($re_data, 13, ($acount_info['cash'] + $info['money']));
  1003. if ($res2 < 0) {
  1004. DB::rollBack();
  1005. return $res2;
  1006. }
  1007. $rimt_res = $accountDB->addMoney($data['account_identity'], $data['money']);
  1008. if ($rimt_res < 0) {
  1009. DB::rollBack();
  1010. return $rimt_res;
  1011. }
  1012. }
  1013. $uinfo = $accountDB->getInfoBy($acount_info['account_identity']);
  1014. $data = array('money_cash' => $uinfo['cash'] - $prize_moeny);
  1015. $res5 = $db->updateInfo($data, 'order_id', $order_id);
  1016. if ($res5 < 0) {
  1017. DB::rollBack();
  1018. return $res5;
  1019. }
  1020. DB::commit();
  1021. return 1;
  1022. }
  1023. //详情记录
  1024. function addLog($data, $type, $cash, int $rate = 1, $order_id = '')
  1025. {
  1026. $data['money_cash'] = $data['money'] + $cash;
  1027. $data['trade_id'] = !empty($order_id) ? $order_id : OrderID();
  1028. $data['trade_type'] = $type;
  1029. $data['money_time'] = date('Y-m-d H:i:s');
  1030. $data['money_type'] = 1;
  1031. $admin_name = session('adminInfo.admin_name');
  1032. $detailsinfo = \App\Models\Money_details::where('trade_id', $order_id)->where('trade_id', '<>', '')->first();
  1033. if ($detailsinfo) {
  1034. return -3020035022;
  1035. }
  1036. if ($type == 13) {
  1037. $data['trade_desc'] = sprintf(trans('trade.admin_prize_money'), $admin_name, $data['account_name'], $data['money'], $data['trade_id'], $rate);
  1038. $data['reason'] = '汇款赠送';
  1039. } else if ($type == 14) {
  1040. $data['trade_desc'] = sprintf(trans('trade.admin_rimit_money'), $admin_name, $data['account_name'], $data['money'], $data['trade_id'], $rate);
  1041. $data['reason'] = '汇款';
  1042. }
  1043. $db_money = new \App\Models\Money_details;
  1044. $res = $db_money->insertData($data);
  1045. return $res;
  1046. }
  1047. //获取提现,汇款,充值待处理内容
  1048. function getNum()
  1049. {
  1050. $model = new \App\Models\Money_recharge();
  1051. $data['rimit'] = $model::where('status', 0)->where('recharge_type', '汇款')->count();
  1052. $data['take'] = \App\Models\Money_take::where('status', 0)->count();
  1053. $data['vip'] = \App\Models\Uservip::where('status', 1)->count();
  1054. // $data['back'] = \App\Model\Oggame_transfer_record::where('type', 3)->count();
  1055. // $data['lotteryMoney'] = \App\Model\LotteryMoneyLog::where('status', 0)->count();//待审核彩金条数
  1056. // $msg_db = new \App\Model\MessageRead;
  1057. // $data['msg'] = $msg_db->countNoReade (session ('adminInfo.admin_id'));
  1058. // $data['agent'] = \App\Model\Agent_detailed::where ('status', 0)->count ('id');
  1059. return responseToJson($data);
  1060. }
  1061. /**
  1062. *检查用户提现规则
  1063. * @param $idd
  1064. * @param null $money
  1065. * @return int
  1066. */
  1067. public function checkWithdrawRule()
  1068. {
  1069. $idd = Request::has('idd') ? Request::get('idd') : '';
  1070. if (!$idd)
  1071. return responseToJson(-1, '非法操作,用户账户不能为空', '');
  1072. $ret = Withdraw_rule::check($idd);
  1073. return responseToJson($ret ? 1 : -1, $ret ? 'success' : '无结果', $ret);
  1074. }
  1075. /**
  1076. * 更新用户提现规则
  1077. * @param $idd
  1078. * @param $data
  1079. * @return array
  1080. */
  1081. public function changeWithDrawRule()
  1082. {
  1083. $idd = Request::has('idd') ? Request::get('idd') : '';
  1084. $start_time = Request::has('start_time') ? Request::post('start_time') : '';
  1085. $end_time = Request::has('end_time') ? Request::post('end_time') : '';
  1086. $bettingMoney = Request::has('bettingMoney') ? Request::post('bettingMoney') : 0;
  1087. $rate = Request::has('rate') ? Request::post('rate') : 1;
  1088. $needBettingMoney = Request::has('needBettingMoney') ? Request::post('needBettingMoney') : 0;
  1089. if (!$idd)
  1090. return responseToJson(-1, '非法操作,用户账户不能为空', '');
  1091. $ret = Withdraw_rule::updateRule($idd, $bettingMoney, $rate);
  1092. return responseToJson($ret ? 1 : -1, $ret ? '修改规则成功' : '修改规则失败', '');
  1093. }
  1094. /**
  1095. *添加用户提现规则
  1096. * @return array|int
  1097. */
  1098. public function addRule()
  1099. {
  1100. $idd = Request::has('idd') ? Request::get('idd') : '';
  1101. $startTime = Request::has('startTime') ? Request::post('startTime') : '';
  1102. $endTime = Request::has('endTime') ? Request::post('endTime') : '';
  1103. $bettingMoney = Request::has('bettingMoney') ? Request::post('bettingMoney') : 0;
  1104. $needBettingMoney = Request::has('needBettingMoney') ? Request::post('needBettingMoney') : 0;
  1105. if (!$idd)
  1106. return responseToJson(-1, '非法操作,用户账户不能为空', '');
  1107. if (!$startTime)
  1108. $startTime = time();
  1109. if (!$endTime)
  1110. $endTime = time();
  1111. if (!$bettingMoney || !$needBettingMoney) {
  1112. //return responseToJson (-1, '金额不能为空或0', '');
  1113. }
  1114. if ($bettingMoney) $data['bettingMoney'] = $bettingMoney;
  1115. if ($needBettingMoney) $data['needBettingMoney'] = $needBettingMoney;
  1116. //$ret = Withdraw_rule::setRule ($idd, $startTime, $endTime, $bettingMoney, $needBettingMoney);
  1117. $ret = Withdraw_rule::setRule($idd, time(), time(), 1000, 1200);
  1118. return responseToJson($ret ? 1 : -1, $ret ? '添加规则成功' : '添加规则失败', $ret);
  1119. }
  1120. /**
  1121. * 删除用户提现规则
  1122. * @return mixed
  1123. */
  1124. public function rmWithdrawRule()
  1125. {
  1126. $idd = Request::has('idd') ? Request::post('idd') : '';
  1127. if (!$idd)
  1128. return responseToJson('', '非法操作', '');
  1129. $ret = Withdraw_rule::rmRule($idd);
  1130. return responseToJson($ret ? 1 : -1, $ret ? '删除规则成功' : '删除规则失败', '');
  1131. }
  1132. public function getWithdrawList()
  1133. {
  1134. $data = Withdraw_rule::get();
  1135. //return responseToJson (1,'',$data);
  1136. return ['code' => 0, 'count' => count($data), 'data' => $data, 'msg' => 'success'];
  1137. }
  1138. /**
  1139. * 用户提现规则表页面
  1140. */
  1141. public function withdrawRules(Request $req)
  1142. {
  1143. $request['title'] = isset($req->title) ? trim($req->title) : '提现规则表';
  1144. $request['type'] = isset($req->type) ? trim($req->type) : null;
  1145. $dt = \App\Lib\DataTable\DataTable::init();
  1146. $dt->setDataSource('/admin/money/getWithdrawList');
  1147. $dt->setLang('withdrawRule');
  1148. $dt->addColsFields('account_identity', ['templet' => '#account_identity']);
  1149. $dt->addColsFields('bettingMoney');
  1150. $dt->addColsFields('needBettingMoney');
  1151. $dt->addColsFields('start_time');
  1152. $dt->addColsFields('end_time');
  1153. //$dt->enableCheckBox ();
  1154. $arr[] = 'editRule';
  1155. $dt->setToolBar($arr, array('width' => 140));
  1156. return view('admin.withdraw/rules', $dt->render($request));
  1157. }
  1158. /**
  1159. * 修改用户提现规则页面
  1160. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1161. */
  1162. public function editRule()
  1163. {
  1164. $id = Request::has('id') ? Request::get('id') : '';
  1165. if ($id) {
  1166. $data = Withdraw_rule::getRule($id);
  1167. return view('admin.withdraw.editRule', ['data' => $data]);
  1168. }
  1169. die('error');
  1170. }
  1171. }
  1172. function test()
  1173. {
  1174. $db = new \App\Models\Money_recharge;
  1175. $data = $db->text();
  1176. print_r($data);
  1177. }