MoneyController.php 52 KB

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