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 = $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); } }