GzcLogs.php 8.0 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. $cursor = Db::table('rrx_gzc_logs')
  71. ->where('id', $id)
  72. ->where('gzc', 0)
  73. ->where('success', 0)
  74. ->where('pension', '>', 0)
  75. ->cursor();
  76. foreach($cursor as $log){
  77. if (!$log){
  78. return app('json')->fail('暂无记录');
  79. }
  80. $mobile= $log['mobile'];
  81. $user_name = Db::name('user_certification')->where('uid',$log['uid'])->value('user_name');
  82. $user_card = Db::name('user_certification')->where('uid',$log['uid'])->value('user_card');
  83. $card_positive = Db::name('user_certification')->where('uid',$log['uid'])->value('card_positive');
  84. $card_reverse = Db::name('user_certification')->where('uid',$log['uid'])->value('card_reverse');
  85. if(!$mobile || !$user_name || !$user_card || !$card_positive || !$card_reverse){
  86. return app('json')->fail('暂无记录');
  87. }
  88. //发起入账gzc
  89. $OrderGzcRepository = app()->make(OrderGzcRepository::class);
  90. $register = $OrderGzcRepository->register($mobile);
  91. if($register['status'] != 200) return app('json')->fail('入账失败:'.$register['message']);
  92. $uid = $register['data']['uid'] ?? 0;
  93. if(!$uid) return app('json')->fail('创建或获取用户失败');
  94. $certification = $OrderGzcRepository->certification($uid, $mobile, $user_name, $user_card, $card_positive, $card_reverse);
  95. if($certification['status'] != 200) return app('json')->fail('实名认证失败:'.$certification['message']);
  96. $gzc = $OrderGzcRepository->gzc($uid,$log['pension']);
  97. if($gzc['status'] != 200) return app('json')->fail('入账失败:'.$gzc['message']);
  98. $gzc_deposit_no = $gzc['data'];
  99. $gzc_confirm_result = $gzc['message'];
  100. }
  101. $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
  102. $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
  103. Db::table('rrx_gzc_logs')
  104. ->where('id', $id)
  105. ->where('gzc', 0)
  106. ->where('success', 0)
  107. ->where('pension', '>', 0)
  108. ->update([
  109. 'gzc' => 1,
  110. 'platform_no' => $orderId,
  111. 'gzc_deposit_no' => $gzc_deposit_no,
  112. 'gzc_confirm_result' => $gzc_confirm_result,
  113. 'success' => 1,
  114. 'update_time' => date('Y-m-d H:i:s')
  115. ]);
  116. return app('json')->success('发起成功');
  117. }
  118. /**
  119. * 发起入账
  120. * author: php迷途小书童
  121. * created: 2021/3/24 13:56
  122. */
  123. public function inGzcAll()
  124. {
  125. $ids = intval($this->request->param('ids'));
  126. if(!$ids) return app('json')->fail('请选择需要入账的记录');
  127. $ids = explode(",", $ids);
  128. if(!count($ids)){
  129. return app('json')->fail('暂无记录');
  130. }
  131. $cursor = Db::table('rrx_gzc_logs')
  132. ->whereIn('id', $ids)
  133. ->where('gzc', 0)
  134. ->where('success', 0)
  135. ->where('pension', '>', 0)
  136. ->cursor();
  137. foreach($cursor as $log){
  138. if (!$log){
  139. return app('json')->fail('暂无记录');
  140. }
  141. $mobile= $log['mobile'];
  142. $user_name = Db::name('user_certification')->where('uid',$log['uid'])->value('user_name');
  143. $user_card = Db::name('user_certification')->where('uid',$log['uid'])->value('user_card');
  144. $card_positive = Db::name('user_certification')->where('uid',$log['uid'])->value('card_positive');
  145. $card_reverse = Db::name('user_certification')->where('uid',$log['uid'])->value('card_reverse');
  146. if(!$mobile || !$user_name || !$user_card || !$card_positive || !$card_reverse){
  147. return app('json')->fail('暂无记录');
  148. }
  149. //发起入账gzc
  150. $OrderGzcRepository = app()->make(OrderGzcRepository::class);
  151. $register = $OrderGzcRepository->register($mobile);
  152. if($register['status'] != 200) return app('json')->fail('入账失败:'.$register['message']);
  153. $uid = $register['data']['uid'] ?? 0;
  154. if(!$uid) return app('json')->fail('创建或获取用户失败');
  155. $certification = $OrderGzcRepository->certification($uid, $mobile, $user_name, $user_card, $card_positive, $card_reverse);
  156. if($certification['status'] != 200) return app('json')->fail('实名认证失败:'.$certification['message']);
  157. $gzc = $OrderGzcRepository->gzc($uid,$log['pension']);
  158. if($gzc['status'] != 200) return app('json')->fail('入账失败:'.$gzc['message']);
  159. $gzc_deposit_no = $gzc['data'];
  160. $gzc_confirm_result = $gzc['message'];
  161. $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
  162. $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
  163. Db::table('rrx_gzc_logs')
  164. ->where('id', $log['id'])
  165. ->where('gzc', 0)
  166. ->where('success', 0)
  167. ->where('pension', '>', 0)
  168. ->update([
  169. 'gzc' => 1,
  170. 'platform_no' => $orderId,
  171. 'gzc_deposit_no' => $gzc_deposit_no,
  172. 'gzc_confirm_result' => $gzc_confirm_result,
  173. 'success' => 1,
  174. 'update_time' => date('Y-m-d H:i:s')
  175. ]);
  176. }
  177. return app('json')->success('发起成功');
  178. }
  179. /**
  180. * TODO 导出文件
  181. * @author Qinii
  182. * @day 2020-07-30
  183. */
  184. public function excel()
  185. {
  186. $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn']);
  187. app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'order',0);
  188. return app('json')->success('开始导出数据');
  189. }
  190. public function checkAmount(){
  191. $where = $this->request->params(['user_name', 'user_card']);
  192. $return = $this->repository->checkAmount($where);
  193. return app('json')->success($return);
  194. }
  195. }