| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- <?php
- /**
- * @package merchant
- *
- * @author Qinii
- * @day 2020-06-15
- *
- *
- */
- namespace app\controller\admin\system\merchant;
- use app\common\repositories\merchant\order\OrderGzcRepository;
- use app\common\repositories\merchant\order\OrderMerchantRepository;
- use crmeb\basic\BaseController;
- use app\common\repositories\store\ExcelRepository;
- use think\App;
- use think\facade\Db;
- class GzcLogs extends BaseController
- {
- protected $repository;
- public function __construct(App $app, OrderGzcRepository $repository)
- {
- parent::__construct($app);
- $this->repository = $repository;
- }
- public function lst()
- {
- [$page, $limit] = $this->getPage();
- $where = $this->request->params(['keyword', 'date', 'status', 'account']);
- return app('json')->success($this->repository->getList($where, $page, $limit));
- }
- /**
- * 入账表单
- * author: php迷途小书童
- * created: 2021/3/24 13:56
- */
- public function inForm()
- {
- return app('json')->success(formToData($this->repository->inForm()));
- }
- /**
- * 编辑表单
- * @param $id
- * author: php迷途小书童
- * created: 2021/3/24 15:21
- */
- public function editForm($id)
- {
- return app('json')->success(formToData($this->repository->editForm($id)));
- }
- /**
- * 编辑处理
- * author: php迷途小书童
- * created: 2021/3/24 15:22
- */
- public function editFormPost()
- {
- $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']);
- Db::table('rrx_gzc_logs')
- ->update($params);
- return app('json')->success('编辑成功');
- }
- /**
- * 发起入账
- * author: php迷途小书童
- * created: 2021/3/24 13:56
- */
- public function inGzc()
- {
- $id = intval($this->request->param('id'));
- $log = Db::table('rrx_gzc_logs')
- ->where('id', $id)
- ->where('gzc', 0)
- ->where('success', 0)
- ->where('pension', '>', 0)
- ->find();
-
- if(!$log){
- return app('json')->fail('请选择未入账的记录', );
- }
-
- $mobile= $log['mobile'];
- $user_name = Db::name('user_certification')->where('uid',$log['uid'])->value('user_name');
- $user_card = Db::name('user_certification')->where('uid',$log['uid'])->value('user_card');
- $card_positive = Db::name('user_certification')->where('uid',$log['uid'])->value('card_positive');
- $card_reverse = Db::name('user_certification')->where('uid',$log['uid'])->value('card_reverse');
- if(!$mobile || !$user_name || !$user_card || !$card_positive || !$card_reverse){
- return app('json')->fail('存在实名数据缺失');
- }
- //发起入账gzc
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- $register = $OrderGzcRepository->register($mobile);
- if($register['status'] != 200) return app('json')->fail('入账失败:'.$register['message']);
- $uid = $register['data']['uid'] ?? 0;
- if(!$uid) return app('json')->fail('创建或获取用户失败');
- $certification = $OrderGzcRepository->certification($uid, $mobile, $user_name, $user_card, $card_positive, $card_reverse);
- if($certification['status'] != 200) return app('json')->fail('实名认证失败:'.$certification['message']);
- $gzc = $OrderGzcRepository->gzc($uid,$log['pension']);
- if($gzc['status'] != 200) return app('json')->fail('入账失败:'.$gzc['message']);
- $gzc_deposit_no = $gzc['data'];
- $gzc_confirm_result = $gzc['message'];
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- Db::table('rrx_gzc_logs')
- ->where('id', $id)
- ->where('gzc', 0)
- ->where('success', 0)
- ->where('pension', '>', 0)
- ->update([
- 'gzc' => 1,
- 'platform_no' => $orderId,
- 'gzc_deposit_no' => $gzc_deposit_no,
- 'gzc_confirm_result' => $gzc_confirm_result,
- 'success' => 1,
- 'update_time' => date('Y-m-d H:i:s')
- ]);
- //发起成功更新记录值
- $order_id = Db::name('store_order')->where('order_sn', $log['out_trade_no'])->value('order_id');
- if($order_id){
- $bill = Db::name('user_bill')->where('link_id', $order_id)->where('commission_type', 5)->where('is_gzc', 'in', [0, 1])->find();
- if($bill){
- Db::name('user_bill')
- ->where('bill_id', $bill['bill_id'])
- ->update([
- 'is_gzc' => 2
- ]);
- }
- }
-
- return app('json')->success('发起成功', $log);
- }
- /**
- * 发起入账
- * author: php迷途小书童
- * created: 2021/3/24 13:56
- */
- public function inGzcAll()
- {
- $ids = intval($this->request->param('ids'));
- if(!$ids) return app('json')->fail('请选择需要入账的记录');
- $ids = explode(",", $ids);
- if(!count($ids)){
- return app('json')->fail('暂无记录');
- }
- $cursor = Db::table('rrx_gzc_logs')
- ->whereIn('id', $ids)
- ->where('gzc', 0)
- ->where('success', 0)
- ->where('pension', '>', 0)
- ->cursor();
- foreach($cursor as $log){
- if (!$log){
- return app('json')->fail('暂无记录');
- }
- $mobile= $log['mobile'];
- $user_name = Db::name('user_certification')->where('uid',$log['uid'])->value('user_name');
- $user_card = Db::name('user_certification')->where('uid',$log['uid'])->value('user_card');
- $card_positive = Db::name('user_certification')->where('uid',$log['uid'])->value('card_positive');
- $card_reverse = Db::name('user_certification')->where('uid',$log['uid'])->value('card_reverse');
- if(!$mobile || !$user_name || !$user_card || !$card_positive || !$card_reverse){
- return app('json')->fail('存在实名数据缺失');
- }
- //发起入账gzc
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- $register = $OrderGzcRepository->register($mobile);
- if($register['status'] != 200) return app('json')->fail('入账失败:'.$register['message']);
- $uid = $register['data']['uid'] ?? 0;
- if(!$uid) return app('json')->fail('创建或获取用户失败');
- $certification = $OrderGzcRepository->certification($uid, $mobile, $user_name, $user_card, $card_positive, $card_reverse);
- if($certification['status'] != 200) return app('json')->fail('实名认证失败:'.$certification['message']);
- $gzc = $OrderGzcRepository->gzc($uid,$log['pension']);
- if($gzc['status'] != 200) return app('json')->fail('入账失败:'.$gzc['message']);
- $gzc_deposit_no = $gzc['data'];
- $gzc_confirm_result = $gzc['message'];
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- Db::table('rrx_gzc_logs')
- ->where('id', $log['id'])
- ->where('gzc', 0)
- ->where('success', 0)
- ->where('pension', '>', 0)
- ->update([
- 'gzc' => 1,
- 'platform_no' => $orderId,
- 'gzc_deposit_no' => $gzc_deposit_no,
- 'gzc_confirm_result' => $gzc_confirm_result,
- 'success' => 1,
- 'update_time' => date('Y-m-d H:i:s')
- ]);
- //发起成功更新记录值
- $order_id = Db::name('store_order')->where('order_sn', $log['out_trade_no'])->value('order_id');
- if($order_id){
- $bill = Db::name('user_bill')->where('link_id', $order_id)->where('commission_type', 5)->where('is_gzc', 'in', [0, 1])->find();
- if($bill){
- Db::name('user_bill')
- ->where('bill_id', $bill['bill_id'])
- ->update([
- 'is_gzc' => 2
- ]);
- }
- }
- }
- return app('json')->success('发起成功');
- }
- /**
- * TODO 导出文件
- * @author Qinii
- * @day 2020-07-30
- */
- public function excel()
- {
- $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn']);
- app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'order',0);
- return app('json')->success('开始导出数据');
- }
- public function checkAmount(){
- $where = $this->request->params(['user_name', 'user_card']);
- $return = $this->repository->checkAmount($where);
- return app('json')->success($return);
- }
- }
|