You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/api/service/Finance.php

75 lines
2.8 KiB

10 months ago
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
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;
}
}