parent
4477b22f9d
commit
832256285a
@ -0,0 +1,49 @@ |
|||||||
|
<?php |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Author: 萤火科技 <admin@yiovo.com> |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\api\controller; |
||||||
|
|
||||||
|
use app\api\service\Finance as FinanceService; |
||||||
|
use think\response\Json; |
||||||
|
use app\api\service\User as UserService; |
||||||
|
use cores\exception\BaseException; |
||||||
|
use app\api\model\user\BalanceLog; |
||||||
|
|
||||||
|
/** |
||||||
|
* 用户管理 |
||||||
|
* Class User |
||||||
|
* @package app\api\controller |
||||||
|
*/ |
||||||
|
class Finance extends Controller |
||||||
|
{ |
||||||
|
|
||||||
|
//获取列表 |
||||||
|
public function list(): Json |
||||||
|
{ |
||||||
|
//$userInfo = UserService::getCurrentLoginUser(true); |
||||||
|
$params = $this->request->param(); |
||||||
|
$params['user_id'] = 10003; |
||||||
|
$service = new FinanceService(); |
||||||
|
$list = $service->getList($params); |
||||||
|
return $this->renderSuccess(compact('list')); |
||||||
|
} |
||||||
|
|
||||||
|
//申请提现 |
||||||
|
public function add(): Json |
||||||
|
{ |
||||||
|
$service = new FinanceService(); |
||||||
|
if ($service->add($this->postForm())) { |
||||||
|
return $this->renderSuccess('申请成功'); |
||||||
|
} |
||||||
|
return $this->renderError($service->getError() ?? '申请失败'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,75 @@ |
|||||||
|
<?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; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
<?php |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Author: 萤火科技 <admin@yiovo.com> |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\common\model; |
||||||
|
|
||||||
|
use cores\BaseModel; |
||||||
|
use think\model\relation\HasOne; |
||||||
|
use app\common\model\store\Shop; |
||||||
|
/** |
||||||
|
* 用户模型类 |
||||||
|
* Class User |
||||||
|
* @package app\common\model |
||||||
|
*/ |
||||||
|
class Finance extends BaseModel |
||||||
|
{ |
||||||
|
// 定义表名 |
||||||
|
protected $name = 'finance'; |
||||||
|
|
||||||
|
// 定义主键 |
||||||
|
protected $pk = 'id'; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 关联用户 |
||||||
|
* @return HasOne |
||||||
|
*/ |
||||||
|
public function user(): HasOne |
||||||
|
{ |
||||||
|
return $this->hasOne('user', 'user_id', 'user_id'); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue