GzcLogs.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author Qinii
  6. * @day 2020-06-15
  7. *
  8. *
  9. */
  10. namespace app\controller\admin\system\merchant;
  11. use app\common\repositories\merchant\order\OrderGzcRepository;
  12. use app\common\repositories\merchant\order\OrderMerchantRepository;
  13. use crmeb\basic\BaseController;
  14. use app\common\repositories\store\ExcelRepository;
  15. use think\App;
  16. use think\facade\Db;
  17. class GzcLogs extends BaseController
  18. {
  19. protected $repository;
  20. public function __construct(App $app, OrderGzcRepository $repository)
  21. {
  22. parent::__construct($app);
  23. $this->repository = $repository;
  24. }
  25. public function lst()
  26. {
  27. [$page, $limit] = $this->getPage();
  28. $where = $this->request->params(['keyword', 'date', 'status', 'account']);
  29. return app('json')->success($this->repository->getList($where, $page, $limit));
  30. }
  31. /**
  32. * 入账表单
  33. * author: php迷途小书童
  34. * created: 2021/3/24 13:56
  35. */
  36. public function inForm()
  37. {
  38. return app('json')->success(formToData($this->repository->inForm()));
  39. }
  40. /**
  41. * 编辑表单
  42. * @param $id
  43. * author: php迷途小书童
  44. * created: 2021/3/24 15:21
  45. */
  46. public function editForm($id)
  47. {
  48. return app('json')->success(formToData($this->repository->editForm($id)));
  49. }
  50. /**
  51. * 编辑处理
  52. * author: php迷途小书童
  53. * created: 2021/3/24 15:22
  54. */
  55. public function editFormPost()
  56. {
  57. $params = $this->request->params(['id', 'user_name', 'mobile', 'user_card', 'bank_name', 'branch_name', 'bank_account', 'bank_no', 'alipay_account','alipay_no','wxpay_account','wxpay_no','deposit_dt']);
  58. Db::table('rrx_gzc_logs')
  59. ->update($params);
  60. return app('json')->success('编辑成功');
  61. }
  62. /**
  63. * 发起入账
  64. * author: php迷途小书童
  65. * created: 2021/3/24 13:56
  66. */
  67. public function inGzc()
  68. {
  69. $id = intval($this->request->param('id'));
  70. $log = Db::table('rrx_gzc_logs')
  71. ->where('id', $id)
  72. ->where('gzc', 0)
  73. ->where('success', 0)
  74. ->where('pension', '>', 0)
  75. ->find();
  76. if(!$log){
  77. return app('json')->fail('请选择未入账的记录', );
  78. }
  79. $mobile= $log['mobile'];
  80. $user_name = Db::name('user_certification')->where('uid',$log['uid'])->value('user_name');
  81. $user_card = Db::name('user_certification')->where('uid',$log['uid'])->value('user_card');
  82. $card_positive = Db::name('user_certification')->where('uid',$log['uid'])->value('card_positive');
  83. $card_reverse = Db::name('user_certification')->where('uid',$log['uid'])->value('card_reverse');
  84. if(!$mobile || !$user_name || !$user_card || !$card_positive || !$card_reverse){
  85. return app('json')->fail('存在实名数据缺失');
  86. }
  87. //发起入账gzc
  88. $OrderGzcRepository = app()->make(OrderGzcRepository::class);
  89. $register = $OrderGzcRepository->register($mobile);
  90. if($register['status'] != 200) return app('json')->fail('入账失败:'.$register['message']);
  91. $uid = $register['data']['uid'] ?? 0;
  92. if(!$uid) return app('json')->fail('创建或获取用户失败');
  93. $certification = $OrderGzcRepository->certification($uid, $mobile, $user_name, $user_card, $card_positive, $card_reverse);
  94. if($certification['status'] != 200) return app('json')->fail('实名认证失败:'.$certification['message']);
  95. $gzc = $OrderGzcRepository->gzc($uid,$log['pension']);
  96. if($gzc['status'] != 200) return app('json')->fail('入账失败:'.$gzc['message']);
  97. $gzc_deposit_no = $gzc['data'];
  98. $gzc_confirm_result = $gzc['message'];
  99. $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
  100. $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
  101. Db::table('rrx_gzc_logs')
  102. ->where('id', $id)
  103. ->where('gzc', 0)
  104. ->where('success', 0)
  105. ->where('pension', '>', 0)
  106. ->update([
  107. 'gzc' => 1,
  108. 'platform_no' => $orderId,
  109. 'gzc_deposit_no' => $gzc_deposit_no,
  110. 'gzc_confirm_result' => $gzc_confirm_result,
  111. 'success' => 1,
  112. 'update_time' => date('Y-m-d H:i:s')
  113. ]);
  114. return app('json')->success('发起成功', $log);
  115. }
  116. /**
  117. * 发起入账
  118. * author: php迷途小书童
  119. * created: 2021/3/24 13:56
  120. */
  121. public function inGzcAll()
  122. {
  123. $ids = intval($this->request->param('ids'));
  124. if(!$ids) return app('json')->fail('请选择需要入账的记录');
  125. $ids = explode(",", $ids);
  126. if(!count($ids)){
  127. return app('json')->fail('暂无记录');
  128. }
  129. $cursor = Db::table('rrx_gzc_logs')
  130. ->whereIn('id', $ids)
  131. ->where('gzc', 0)
  132. ->where('success', 0)
  133. ->where('pension', '>', 0)
  134. ->cursor();
  135. foreach($cursor as $log){
  136. if (!$log){
  137. return app('json')->fail('暂无记录');
  138. }
  139. $mobile= $log['mobile'];
  140. $user_name = Db::name('user_certification')->where('uid',$log['uid'])->value('user_name');
  141. $user_card = Db::name('user_certification')->where('uid',$log['uid'])->value('user_card');
  142. $card_positive = Db::name('user_certification')->where('uid',$log['uid'])->value('card_positive');
  143. $card_reverse = Db::name('user_certification')->where('uid',$log['uid'])->value('card_reverse');
  144. if(!$mobile || !$user_name || !$user_card || !$card_positive || !$card_reverse){
  145. return app('json')->fail('存在实名数据缺失');
  146. }
  147. //发起入账gzc
  148. $OrderGzcRepository = app()->make(OrderGzcRepository::class);
  149. $register = $OrderGzcRepository->register($mobile);
  150. if($register['status'] != 200) return app('json')->fail('入账失败:'.$register['message']);
  151. $uid = $register['data']['uid'] ?? 0;
  152. if(!$uid) return app('json')->fail('创建或获取用户失败');
  153. $certification = $OrderGzcRepository->certification($uid, $mobile, $user_name, $user_card, $card_positive, $card_reverse);
  154. if($certification['status'] != 200) return app('json')->fail('实名认证失败:'.$certification['message']);
  155. $gzc = $OrderGzcRepository->gzc($uid,$log['pension']);
  156. if($gzc['status'] != 200) return app('json')->fail('入账失败:'.$gzc['message']);
  157. $gzc_deposit_no = $gzc['data'];
  158. $gzc_confirm_result = $gzc['message'];
  159. $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
  160. $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
  161. Db::table('rrx_gzc_logs')
  162. ->where('id', $log['id'])
  163. ->where('gzc', 0)
  164. ->where('success', 0)
  165. ->where('pension', '>', 0)
  166. ->update([
  167. 'gzc' => 1,
  168. 'platform_no' => $orderId,
  169. 'gzc_deposit_no' => $gzc_deposit_no,
  170. 'gzc_confirm_result' => $gzc_confirm_result,
  171. 'success' => 1,
  172. 'update_time' => date('Y-m-d H:i:s')
  173. ]);
  174. }
  175. return app('json')->success('发起成功');
  176. }
  177. /**
  178. * TODO 导出文件
  179. * @author Qinii
  180. * @day 2020-07-30
  181. */
  182. public function excel()
  183. {
  184. $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn']);
  185. app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'order',0);
  186. return app('json')->success('开始导出数据');
  187. }
  188. public function checkAmount(){
  189. $where = $this->request->params(['user_name', 'user_card']);
  190. $return = $this->repository->checkAmount($where);
  191. return app('json')->success($return);
  192. }
  193. }