request); $limitTimeList = [ 'today' => implode(' - ', [date('Y/m/d'), date('Y/m/d', strtotime('+1 day'))]), 'week' => implode(' - ', [ date('Y/m/d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)), date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)) ]), 'month' => implode(' - ', [date('Y/m') . '/01', date('Y/m') . '/' . date('t')]), 'quarter' => implode(' - ', [ date('Y') . '/' . (ceil((date('n')) / 3) * 3 - 3 + 1) . '/01', date('Y') . '/' . (ceil((date('n')) / 3) * 3) . '/' . date('t', mktime(0, 0, 0, (ceil((date('n')) / 3) * 3), 1, date('Y'))) ]), 'year' => implode(' - ', [ date('Y') . '/01/01', date('Y/m/d', strtotime(date('Y') . '/01/01 + 1year -1 day')) ]) ]; $this->assign('where', $where); $this->assign('limitTimeList', $limitTimeList); $this->assign(UserExtractModel::extractStatistics()); $this->assign(UserExtractModel::systemPage($where)); return $this->fetch(); } /** * 后台编辑提现信息 * @param $id: user_extract 表 id */ public function edit($id) { if (!$id) return $this->failed('数据不存在'); $UserExtract = UserExtractModel::get($id); if (!$UserExtract) return JsonService::fail('数据不存在!'); $f = array(); $f[] = Form::input('real_name', '姓名', $UserExtract['real_name']); $f[] = Form::number('extract_price', '提现金额', $UserExtract['extract_price'])->precision(2); if ($UserExtract['extract_type'] == 'alipay') { $f[] = Form::input('alipay_code', '支付宝账号', $UserExtract['alipay_code']); } else if ($UserExtract['extract_type'] == 'weixin') { $f[] = Form::input('wechat', '微信号', $UserExtract['wechat']); } else { $f[] = Form::input('bank_code', '银行卡号', $UserExtract['bank_code']); $f[] = Form::input('bank_address', '开户行', $UserExtract['bank_address']); } $f[] = Form::input('mark', '备注', $UserExtract['mark'])->type('textarea'); $form = Form::make_post_form('编辑', $f, Url::buildUrl('update', array('id' => $id))); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** * 处理 edit 提交的信息 * * 根据提现通道的不一样,POST 的数据也不一样 */ public function update($id) { $UserExtract = UserExtractModel::get($id); if (!$UserExtract) return JsonService::fail('数据不存在!'); if ($UserExtract['extract_type'] == 'alipay') { $data = Util::postMore([ 'real_name', 'mark', 'extract_price', 'alipay_code', ]); if (!$data['real_name']) return JsonService::fail('请输入姓名'); if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额'); if (!$data['alipay_code']) return JsonService::fail('请输入支付宝账号'); } else if ($UserExtract['extract_type'] == 'weixin') { $data = Util::postMore([ 'real_name', 'mark', 'extract_price', 'wechat', ]); // if(!$data['real_name']) return JsonService::fail('请输入姓名'); if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额'); if (!$data['wechat']) return JsonService::fail('请输入微信账号'); } else { $data = Util::postMore([ 'real_name', 'extract_price', 'mark', 'bank_code', 'bank_address', ]); if (!$data['real_name']) return JsonService::fail('请输入姓名'); if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额'); if (!$data['bank_code']) return JsonService::fail('请输入银行卡号'); if (!$data['bank_address']) return JsonService::fail('请输入开户行'); } if (!UserExtractModel::edit($data, $id)) return JsonService::fail(UserExtractModel::getErrorInfo('修改失败')); else return JsonService::successful('修改成功!'); } /** * @api {post} /fail 拒绝提现 * @apiName ExtractFail * @apiGroup Finance * * @apiParam {int} id: user_extract id * @apiBody {string} fail_msg fail reason * * @apiSuccessExample: * { * "status": 200, * "msg": "操作成功" * } * @apiErrorExample: * { * "status": 400, * "msg": "error reason" * } */ public function fail($id) { $fail_msg = request()->post(); list($suc, $msg) = PaymentService::user_extract_reject($id, $fail_msg['message']); if ($suc) { return JsonService::successful('操作成功!'); } else { return JsonService::fail($msg); } } /** * @api {post} /succ 提现通过 (后台操作) * @apiName ExtractSucc * @apiGroup Finance * * @apiParam {int} id user_extract id * * @apiSuccessExample: * { * "status": 200, * "msg": "操作成功" * } * @apiErrorExample: * { * "status": 400, * "msg": "error reason" * } */ public function succ($id) { $extractInfo = UserExtractAdmin::get($id); if (!$extractInfo) { return JsonService::fail('记录不存在'); } // API 转账 list($suc, $ec, $es) = PaymentService::extract_by_api($extractInfo); if (!$suc) { return JsonService::fail($es); } list($suc, $msg) = PaymentService::user_extract_passed($extractInfo); if (!$suc) { return JsonService::fail($msg); } else { return JsonService::successful('操作成功'); } } }