// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\api\service; use app\common\model\Finance as FinanceModel; use app\common\service\BaseService; use cores\exception\BaseException; use yiovo\captcha\facade\CaptchaApi; /** * 用户余额充值服务 * Class Recharge * @package app\api\controller */ class Finance extends BaseService { //添加提现 public function add($data) { //$userInfo = UserService::getCurrentLoginUser(true); if (empty($data['money']) || empty($data['bank_no']) || empty($data['card_no']) || empty($data['bank_phone']) || empty($data['user_name'])) { $this->error = '请补全提现信息'; return false; } if(!empty($data['type']) && empty($data['invoice_img_id'])){ $this->error = '请上传发票图片'; return false; } // 验证短信验证码是否匹配 try { CaptchaApi::checkSms($data['smsCode'], $data['bank_phone']); } catch (\Exception $e) { $this->error = $e->getMessage() ?? '短信验证码不正确'; return false; } $money = (float) number_format($data['money'], 2); $addData = [ 'user_id' => 10003, // 'user_id' => $userInfo->user_id, 'money' => $money, 'remark' => trim($data['remark']), 'user_name' => $data['user_name'], 'bank_phone' => $data['bank_phone'], 'status' => 0, 'created_at' => time(), 'store_id' => $this->storeId, 'type' => $data['type']??0, 'bank_no' => $data['bank_no'], 'card_no' => $data['card_no'], 'invoice_img_id' => $data['invoice_img_id'] ]; $model = new FinanceModel(); return $model->insert($addData); } //反馈列表 public function getList($params, $listRows = 10) { $query = new FinanceModel(); $query = $query->where(['user_id' => $params['user_id']])->order('id desc'); $list = $query->paginate($listRows)->toArray(); return $list; } }