TransferVerifyController.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <?php
  2. /**
  3. * 真人转账审核
  4. * User: qin
  5. * Date: 2019/2/18
  6. * Time: 14:30
  7. */
  8. namespace App\Http\Controllers\Admin;
  9. use App\Http\Controllers\Controller;
  10. use Request;
  11. use Illuminate\Support\Facades\DB;
  12. class TransferVerifyController extends Controller
  13. {
  14. /**
  15. * 审核用户转账申请接口
  16. */
  17. public function transferCredit()
  18. {
  19. $username = isset($_POST['username']) ? $_POST['username'] : '';
  20. $game_type = isset($_POST['game_type']) ? $_POST['game_type'] : '';
  21. $localuser = isset($_POST['localuser']) ? $_POST['localuser'] : '';
  22. $credit = isset($_POST['credit']) ? $_POST['credit'] : '';
  23. $type = isset($_POST['type']) ? $_POST['type'] : '';
  24. $billno = isset($_POST['billno']) ? $_POST['billno'] : '';
  25. $stype = isset($_POST['stype']) ? $_POST['stype'] : '';
  26. $remarks = isset($_POST['remarks']) ? $_POST['remarks'] : '';
  27. $zngame = isset($_POST['zngame']) ? $_POST['zngame'] : '';
  28. if(empty($game_type))
  29. {
  30. echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入游戏英文名称'));
  31. }
  32. else if(empty($localuser))
  33. {
  34. echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入用户名'));
  35. }
  36. else if(empty($credit))
  37. {
  38. echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入转账金额'));
  39. }
  40. else if(empty($type))
  41. {
  42. echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入转账类型'));
  43. }
  44. else if(empty($billno))
  45. {
  46. echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入订单号'));
  47. }
  48. else if(empty($stype))
  49. {
  50. echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入审核类型'));
  51. }
  52. else if(empty($remarks))
  53. {
  54. echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入审核理由'));
  55. }else if(empty($zngame))
  56. {
  57. echo json_encode(array('status' => -1, 'data' => '', 'msg' => '请传入游戏中文名称'));
  58. }
  59. else
  60. {
  61. $ostr = '\\App\\Lib\\Biz\\Game\\Egame\\'.ucfirst($game_type);
  62. $obj = new $ostr();
  63. $user = new \App\Models\Account();
  64. $userobj = new \App\Models\Account_detailed();
  65. $moneydetails = new \App\Models\Money_details();
  66. $moneyrecharge = new \App\Models\Money_recharge();
  67. $re = new \App\Models\Oggame_transfer_record();
  68. //查询用户信息
  69. $un = $user->getinfo($localuser,3);
  70. //查询用户可操作余额
  71. $userinfo = $userobj->getInfoBy($un['identity']);
  72. $set = new \App\Models\Rgame_setting();
  73. $where = array();
  74. $where[] = array('game_type','=',$game_type);
  75. $set_obj = $set->getGame($where);
  76. if($stype ==1){
  77. $logtwo = array(session ('adminInfo.admin_name'),$type.'-'.$stype,$localuser,$game_type,$zngame);
  78. OperationLog (session ('adminInfo.admin_id'), 'transferCredit', $logtwo);
  79. //查询用户当前最新余额
  80. $nc = $userobj->getInfoBy($un['identity']);
  81. if($type == 1)
  82. {
  83. $res_to=$obj->transferCreditNew($localuser,$username,$credit,1);
  84. if($res_to['status'] !=1){
  85. $logtwo = array(session ('adminInfo.admin_name'),$type.'-'.$stype,$localuser,$game_type,$zngame);
  86. OperationLog (session ('adminInfo.admin_id'), 'transferCredit', $logtwo);
  87. echo json_encode(array('status' => 0, 'data' => '', 'msg' => $res_to['msg']));
  88. }else{
  89. $msg = '[审核通过]从余额转入到'.$zngame.',金额为:'.$credit.' 元。订单号为:'.$billno.'';
  90. $ud['trade_desc'] = $msg;
  91. $moneydetails->updateInfo($ud,$billno,3);
  92. //更改用户转账申请状态
  93. $w[] = array('order_no','=',$billno);
  94. $w[] = array('game_type','=',$game_type);
  95. $w[] = array('local_user','=',$localuser);
  96. $d['type'] = 1;
  97. $d['exec_time'] = time();
  98. $d['exec_result'] = '[转账成功]从余额转入到游戏(手机版)';
  99. $d['remarks'] = $remarks;
  100. $re->setTransferCredit($w,$d);
  101. echo json_encode(array('status' => 1, 'data' => '', 'msg' => '转账成功', 'exec_result' => $d['exec_result']));
  102. }
  103. }
  104. else if($type == 2)
  105. {
  106. $add = $userobj->addMoney($userinfo['account_identity'],$credit);
  107. //写入资金操作记录
  108. $msg = '[审核成功]从'.$zngame.'转入到余额,金额为:'.$credit.' 元。订单号为:'.$billno.'';
  109. $log=array(
  110. 'info_identity'=>UUID (),
  111. 'trade_id'=>date('YmdHis', time()).rand(111111,999999),
  112. 'account_name'=>$localuser,
  113. 'account_identity'=>$userinfo['account_identity'],
  114. 'money'=>$credit,
  115. 'money_time'=>date('Y-m-d H:i:s'),
  116. 'money_type'=>1,
  117. 'reason'=>$remarks,
  118. 'trade_type'=>19,
  119. 'trade_desc'=>$msg,
  120. 'sysetem_user'=>session ('adminInfo.admin_name'),
  121. 'money_cash'=>floatval($userinfo['cash'])+floatval($credit),
  122. 'status'=>1,
  123. );
  124. $moneydetails->insert($log);
  125. // $ud['trade_desc'] = $msg;
  126. // $ud['money_cash'] = floatval($userinfo['cash'])+floatval($credit);
  127. // $moneydetails->updateInfo($ud,$billno,3);
  128. //更新充值记录状态
  129. $da['info_identity'] = UUID ();
  130. $da['order_id'] = date('YmdHis', time()).rand(111111,999999);
  131. $da['apply_time'] = date('Y-m-d H:i:s');
  132. $da['complete_time'] = date('Y-m-d H:i:s');
  133. $da['money'] = $credit;
  134. $da['account_name'] = $localuser;
  135. $da['account_identity'] = $userinfo['account_identity'];
  136. $da['status'] = 1;
  137. $da['recharge_type'] = '额度转换';
  138. $da['sysetem_user'] = session ('adminInfo.admin_name');
  139. $da['reason'] = '审核通过';
  140. $da['money_cash'] = floatval($userinfo['cash'])+floatval($credit);
  141. $da['remark'] = '审核通过加款';
  142. $moneyrecharge->insert($da);
  143. //更改用户转账申请状态
  144. $w[] = array('order_no','=',$billno);
  145. $w[] = array('game_type','=',$game_type);
  146. $w[] = array('local_user','=',$localuser);
  147. $d['type'] = 1;
  148. $d['exec_time'] = time();
  149. $d['exec_result'] = '[转账成功]从游戏转入到余额(手机版)';
  150. $d['remarks'] = $remarks;
  151. $re->setTransferCredit($w,$d);
  152. echo json_encode(array('status' => 1, 'data' => '', 'msg' => '转账成功', 'exec_result' => $d['exec_result']));
  153. }
  154. }else{
  155. if($type == 1)
  156. {
  157. //返回到用户余额
  158. $userobj->addMoney($userinfo['account_identity'],$credit);
  159. $msg = '[审核未通过]从余额转入到'.$zngame.',金额为:'.$credit.' 元。订单号为:'.$billno.'';
  160. $log=array(
  161. 'info_identity'=>UUID (),
  162. 'trade_id'=>date('YmdHis', time()).rand(111111,999999),
  163. 'account_name'=>$localuser,
  164. 'account_identity'=>$userinfo['account_identity'],
  165. 'money'=>$credit,
  166. 'money_time'=>date('Y-m-d H:i:s'),
  167. 'money_type'=>1,
  168. 'trade_type'=>19,
  169. 'trade_desc'=>$msg,
  170. 'sysetem_user'=>session ('adminInfo.admin_name'),
  171. 'money_cash'=>floatval($userinfo['cash'])+floatval($credit),
  172. 'status'=>1,
  173. );
  174. $moneydetails->insert($log);
  175. // $ud['trade_desc'] = $msg;
  176. // $ud['money_cash'] = floatval($userinfo['cash'])+floatval($credit);
  177. // $moneydetails->updateInfo($ud,$billno,3);
  178. $da['info_identity'] = UUID ();
  179. $da['order_id'] = date('YmdHis', time()).rand(111111,999999);
  180. $da['apply_time'] = date('Y-m-d H:i:s');
  181. $da['complete_time'] = date('Y-m-d H:i:s');
  182. $da['money'] = $credit;
  183. $da['account_name'] = $localuser;
  184. $da['account_identity'] = $userinfo['account_identity'];
  185. $da['status'] = 1;
  186. $da['recharge_type'] = '额度转换';
  187. $da['sysetem_user'] = session ('adminInfo.admin_name');
  188. $da['reason'] = '审核未通过';
  189. $da['money_cash'] = floatval($userinfo['cash'])+floatval($credit);
  190. $da['remark'] = '审核未通过退款';
  191. //var_dump($da);exit;
  192. $moneyrecharge->insert($da);
  193. //更改用户转账申请状态
  194. $w[] = array('order_no','=',$billno);
  195. $w[] = array('game_type','=',$game_type);
  196. $w[] = array('local_user','=',$localuser);
  197. $d['type'] = 4;
  198. $d['exec_time'] = time();
  199. $d['exec_result'] = '[审核未通过]从余额转入到游戏(手机版)';
  200. $d['remarks'] = $remarks;
  201. $re->setTransferCredit($w,$d);
  202. echo json_encode(array('status' => 1, 'data' => '', 'msg' => '申请未通过', 'exec_result' => $d['exec_result']));
  203. exit;
  204. }
  205. else if($type == 2)
  206. {
  207. //更改用户转账申请状态
  208. $w[] = array('order_no','=',$billno);
  209. $w[] = array('game_type','=',$game_type);
  210. $w[] = array('local_user','=',$localuser);
  211. $d['type'] = 4;
  212. $d['exec_time'] = time();
  213. $d['exec_result'] = '[审核未通过]从游戏转入到余额(手机版)';
  214. $d['remarks'] = $remarks;
  215. $re->setTransferCredit($w,$d);
  216. //返还到用户游戏余额
  217. $res_to=$obj->transferCreditNew($localuser,$username,$credit,1);
  218. if($res_to['status'] !=1){
  219. $logtwo = array(session ('adminInfo.admin_name'),$type.'-'.$stype,$localuser,$game_type,$zngame);
  220. OperationLog (session ('adminInfo.admin_id'), 'transferCredit', $logtwo);
  221. }
  222. echo json_encode(array('status' => 1, 'data' => '', 'msg' => '申请未通过', 'exec_result' => $d['exec_result']));
  223. exit;
  224. }
  225. }
  226. }
  227. }
  228. }
  229. ?>