GzcLogs.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. return app('json')->fail('不可执行');
  70. $params = $this->request->params(['account_type', 'bank_name', 'branch_name', 'bank_account', 'bank_no', 'alipay_account','alipay_no','wxpay_account','wxpay_no','deposit_dt']);
  71. Db::table('rrx_gzc_logs')
  72. ->where('gzc', 0)
  73. ->where('pension', '>', 0)
  74. ->update($params);
  75. $cursor = Db::table('rrx_gzc_logs')
  76. ->where('gzc', 0)
  77. ->where('pension', '>', 0)
  78. ->cursor();
  79. foreach($cursor as $log){
  80. if (!$log){
  81. return app('json')->fail('暂无记录');
  82. }
  83. $phone= Db::table('rrx_user')->where('uid',$log['uid'])->value('phone');
  84. $OrderGzcRepository = app()->make(OrderGzcRepository::class);
  85. $uid = $OrderGzcRepository->register($phone);
  86. $OrderGzcRepository->gzc($uid,$log['pension']);
  87. }
  88. $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
  89. $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
  90. Db::table('rrx_gzc_logs')
  91. ->where('gzc', 0)
  92. ->where('pension', '>', 0)
  93. ->update([
  94. 'gzc' => 1,
  95. 'platform_no' => $orderId,
  96. 'update_time' => date('Y-m-d H:i:s')
  97. ]);
  98. return app('json')->success('发起成功');
  99. }
  100. /**
  101. * TODO 导出文件
  102. * @author Qinii
  103. * @day 2020-07-30
  104. */
  105. public function excel()
  106. {
  107. $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn']);
  108. app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'order',0);
  109. return app('json')->success('开始导出数据');
  110. }
  111. public function checkAmount(){
  112. $where = $this->request->params(['user_name', 'user_card']);
  113. $return = $this->repository->checkAmount($where);
  114. return app('json')->success($return);
  115. }
  116. }