update
This commit is contained in:
parent
ab8c406c12
commit
5396290624
127
app/admin/controller/withdraw/MerchantWithdrawController.php
Normal file
127
app/admin/controller/withdraw/MerchantWithdrawController.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\withdraw;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\withdraw\MerchantWithdrawLists;
|
||||
use app\admin\logic\withdraw\MerchantWithdrawLogic;
|
||||
use app\admin\validate\withdraw\MerchantWithdrawValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 商户供应商提现表控制器
|
||||
* Class MerchantWithdrawController
|
||||
* @package app\admin\controller\withdraw
|
||||
*/
|
||||
class MerchantWithdrawController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商户供应商提现表列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new MerchantWithdrawLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加商户供应商提现表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new MerchantWithdrawValidate())->post()->goCheck('add');
|
||||
$result = MerchantWithdrawLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(MerchantWithdrawLogic::getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 审核
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
$params = (new MerchantWithdrawValidate())->post()->goCheck('check');
|
||||
$result = MerchantWithdrawLogic::check($params,$this->adminId);
|
||||
if (true === $result) {
|
||||
return $this->success('审核成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(MerchantWithdrawLogic::getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置到账
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function arrival()
|
||||
{
|
||||
$params = (new MerchantWithdrawValidate())->post()->goCheck('arrival');
|
||||
$result = MerchantWithdrawLogic::arrival($params,$this->adminId);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(MerchantWithdrawLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑商户供应商提现表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new MerchantWithdrawValidate())->post()->goCheck('edit');
|
||||
$result = MerchantWithdrawLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(MerchantWithdrawLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除商户供应商提现表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new MerchantWithdrawValidate())->post()->goCheck('delete');
|
||||
MerchantWithdrawLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商户供应商提现表详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new MerchantWithdrawValidate())->goCheck('detail');
|
||||
$result = MerchantWithdrawLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -57,10 +57,10 @@ class MerchantBankLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
$data['bank_info'] = $bank;
|
||||
$data['is_own_text'] = $data['is_own'] == 0 ? '个人账户' : '对公账户';
|
||||
$data['is_check_text'] = $data->is_check_text;
|
||||
if($data['user_type'] == 1){
|
||||
if(!empty($data['mer_id'])){
|
||||
$merchant = Merchant::field('mer_name')->where('mer_id',$data['mer_id'])->findOrEmpty();
|
||||
$data['mer_name'] = $merchant['mer_name'];
|
||||
}else{
|
||||
}elseif(!empty($data['supplier_id'])){
|
||||
$supplier = Supplier::field('mer_name')->where('id',$data['supplier_id'])->findOrEmpty();
|
||||
$data['mer_name'] = $supplier['mer_name'];
|
||||
}
|
||||
|
84
app/admin/lists/withdraw/MerchantWithdrawLists.php
Normal file
84
app/admin/lists/withdraw/MerchantWithdrawLists.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\withdraw;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\bank\Bank;
|
||||
use app\common\model\merchant\Merchant;
|
||||
use app\common\model\merchant\MerchantBank;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\model\withdraw\MerchantWithdraw;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 商户供应商提现表列表
|
||||
* Class MerchantWithdrawLists
|
||||
* @package app\admin\listswithdraw
|
||||
*/
|
||||
class MerchantWithdrawLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['mer_id', 'supplier_id', 'merchant_bank_id', 'amount', 'is_check', 'is_arrival', 'arrival_proof', 'admin_id'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商户供应商提现表列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return MerchantWithdraw::where($this->searchWhere)
|
||||
->field(['id', 'mer_id', 'supplier_id', 'merchant_bank_id', 'amount', 'is_check', 'is_arrival', 'arrival_proof', 'admin_id'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
$merchant_bank = MerchantBank::where('id',$data['merchant_bank_id'])->findOrEmpty();
|
||||
$bank = Bank::where('id',$merchant_bank['bank_id'])->findOrEmpty();
|
||||
$merchant_bank['bank_info'] = $bank;
|
||||
$data['merchant_bank_info'] = $merchant_bank;
|
||||
if(!empty($data['mer_id'])){
|
||||
$merchant = Merchant::field('mer_name')->where('mer_id',$data['mer_id'])->findOrEmpty();
|
||||
$data['mer_name'] = $merchant['mer_name'];
|
||||
}elseif(!empty($data['supplier_id'])){
|
||||
$supplier = Supplier::field('mer_name')->where('id',$data['supplier_id'])->findOrEmpty();
|
||||
$data['mer_name'] = $supplier['mer_name'];
|
||||
}
|
||||
$admin = Admin::field('name')->where('id',$data['admin_id'])->findOrEmpty();
|
||||
$data['admin_name'] = !$admin->isEmpty() ? $admin['name'] : '';
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商户供应商提现表数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return MerchantWithdraw::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -25,6 +25,11 @@ class MerchantBankLogic extends BaseLogic
|
||||
* @date 2024/05/13 15:06
|
||||
*/
|
||||
public static function check($params,$admin_id){
|
||||
$data = MerchantBank::where('id',$params['id'])->findOrEmpty();
|
||||
if($data['is_check'] != 0){
|
||||
self::setError("已审核,无需重新审核");
|
||||
return false;
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
MerchantBank::where('id',$params['id'])->update([
|
||||
|
182
app/admin/logic/withdraw/MerchantWithdrawLogic.php
Normal file
182
app/admin/logic/withdraw/MerchantWithdrawLogic.php
Normal file
@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic\withdraw;
|
||||
|
||||
|
||||
use app\common\model\merchant\Merchant;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\model\withdraw\MerchantWithdraw;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 商户供应商提现表逻辑
|
||||
* Class MerchantWithdrawLogic
|
||||
* @package app\admin\logic\withdraw
|
||||
*/
|
||||
class MerchantWithdrawLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加商户供应商提现表
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
MerchantWithdraw::create([
|
||||
'mer_id' => $params['mer_id'],
|
||||
'supplier_id' => $params['supplier_id'],
|
||||
'merchant_bank_id' => $params['merchant_bank_id'],
|
||||
'amount' => $params['amount'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑商户供应商提现表
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
MerchantWithdraw::where('id', $params['id'])->update([
|
||||
'mer_id' => $params['mer_id'],
|
||||
'supplier_id' => $params['supplier_id'],
|
||||
'merchant_bank_id' => $params['merchant_bank_id'],
|
||||
'amount' => $params['amount'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 审核
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public static function check(array $params,$admin_id): bool
|
||||
{
|
||||
$data = MerchantWithdraw::where('id', $params['id'])->findOrEmpty();
|
||||
if($data['is_check'] != 0){
|
||||
self::setError('此提现申请已审核,无需重复审核');
|
||||
return false;
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
MerchantWithdraw::where('id', $params['id'])->update([
|
||||
'is_check' => $params['is_check'],
|
||||
'fail_msg' => $params['fail_msg'] ?? '',
|
||||
'admin_id' => $admin_id
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置到账
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public static function arrival(array $params,$admin_id): bool
|
||||
{
|
||||
$data = MerchantWithdraw::where('id', $params['id'])->findOrEmpty();
|
||||
if($data['is_check'] == 0){
|
||||
self::setError('该提现申请还未审核,不能操作');
|
||||
return false;
|
||||
}
|
||||
if($data['is_check'] == 2){
|
||||
self::setError('该提现申请审核未通过,不能操作');
|
||||
return false;
|
||||
}
|
||||
if($data['is_arrival'] == 1){
|
||||
self::setError('该提现申请已到账,无需设置');
|
||||
return false;
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
MerchantWithdraw::where('id', $params['id'])->update([
|
||||
'is_arrival' => 1,
|
||||
'arrival_proof' => $params['arrival_proof'] ? json_encode($params['arrival_proof']) : null,
|
||||
'arrival_user' => $admin_id
|
||||
]);
|
||||
if(!empty($data['mer_id'])){
|
||||
$merchant = Merchant::where('mer_id',$data['mer_id'])->findOrEmpty();
|
||||
$merchant->where('mer_id',$data['mer_id'])->update([
|
||||
'mer_money' => bcsub($merchant['mer_money'],$data['amount'],2)
|
||||
]);
|
||||
}
|
||||
if(!empty($data['supplier_id'])){
|
||||
$supplier = Supplier::where('id',$data['supplier_id'])->findOrEmpty();
|
||||
$supplier->where('id',$data['supplier_id'])->update([
|
||||
'mer_money' => bcsub($supplier['mer_money'],$data['amount'],2)
|
||||
]);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除商户供应商提现表
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return MerchantWithdraw::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商户供应商提现表详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return MerchantWithdraw::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
@ -20,7 +20,6 @@ class UserFeedbackValidate extends BaseValidate
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'uid' => 'require',
|
||||
'content' => 'require',
|
||||
];
|
||||
|
||||
@ -31,7 +30,6 @@ class UserFeedbackValidate extends BaseValidate
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'uid' => '用户id',
|
||||
'content' => '反馈内容',
|
||||
];
|
||||
|
||||
@ -44,7 +42,7 @@ class UserFeedbackValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['uid','content','images','name','contact']);
|
||||
return $this->only(['content','images','name','contact']);
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +54,7 @@ class UserFeedbackValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','uid','content','images','name','contact']);
|
||||
return $this->only(['id','content','images','name','contact']);
|
||||
}
|
||||
|
||||
|
||||
|
139
app/admin/validate/withdraw/MerchantWithdrawValidate.php
Normal file
139
app/admin/validate/withdraw/MerchantWithdrawValidate.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\withdraw;
|
||||
|
||||
|
||||
use app\common\model\merchant\MerchantBank;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 商户供应商提现表验证器
|
||||
* Class MerchantWithdrawValidate
|
||||
* @package app\admin\validate\withdraw
|
||||
*/
|
||||
class MerchantWithdrawValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'mer_id' => 'require',
|
||||
'supplier_id' => 'require',
|
||||
'merchant_bank_id' => 'require|checkMerchantBank',
|
||||
'amount' => 'require|float|gt:0',
|
||||
'is_check' => 'require|in:1,2',
|
||||
'fail_msg' => 'requireIf:is_check,2',
|
||||
'arrival_proof' => 'require|checkArrivalProof'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'mer_id' => '商户id',
|
||||
'supplier_id' => '供应商id',
|
||||
'merchant_bank_id' => '提现账户id',
|
||||
'amount' => '提现金额',
|
||||
'is_check' => '审核状态',
|
||||
'fail_msg' => '审核不通过原因',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return MerchantWithdrawValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['mer_id','supplier_id','merchant_bank_id','amount']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return MerchantWithdrawValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','mer_id','supplier_id','merchant_bank_id','amount']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 审核场景
|
||||
* @return MerchantWithdrawValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function sceneCheck()
|
||||
{
|
||||
return $this->only(['id','is_check','fail_msg']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置到账场景
|
||||
* @return MerchantWithdrawValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function sceneArrival()
|
||||
{
|
||||
return $this->only(['id','arrival_proof']);
|
||||
}
|
||||
|
||||
public function sceneWithdraw()
|
||||
{
|
||||
return $this->only(['merchant_bank_id','amount']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return MerchantWithdrawValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return MerchantWithdrawValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkMerchantBank($value){
|
||||
$data = MerchantBank::where('id',$value)->where('is_check',1)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '提现账户信息错误';
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkArrivalProof($value){
|
||||
if(empty($value) || !is_array($value)){
|
||||
return '到账凭据数据格式错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -5,10 +5,6 @@ namespace app\api\controller\merchant;
|
||||
use app\api\lists\merchant\MerchantLists;
|
||||
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\validate\MerchantBankValidate;
|
||||
use app\common\service\ThinkApi;
|
||||
use support\Cache;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class MerchantController extends BaseApiController
|
||||
@ -16,69 +12,4 @@ class MerchantController extends BaseApiController
|
||||
public function lists(){
|
||||
return $this->dataLists(new MerchantLists());
|
||||
}
|
||||
|
||||
public function add_bank()
|
||||
{
|
||||
$params = (new MerchantBankValidate())->post()->goCheck('add');
|
||||
if($params['user_type'] == 1){
|
||||
$has = Db::name('merchant_bank')->where('mer_id',$params['mer_id'])->where('is_own',$params['is_own'])->where('is_check','<>',2)->findOrEmpty();
|
||||
}else{
|
||||
$has = Db::name('merchant_bank')->where('supplier_id',$params['supplier_id'])->where('is_own',$params['is_own'])->where('is_check','<>',2)->findOrEmpty();
|
||||
}
|
||||
if(!empty($has)){
|
||||
return $this->fail('已提交审核请勿重复提交');
|
||||
}
|
||||
$expireAt = strtotime(date('Y-m-d 23:59:59')); // 当天结束时间戳
|
||||
$totalKey = $params['user_type'] == 1 ? $params['mer_id'].$params['bank_code'] : $params['supplier_id'].$params['bank_code'];
|
||||
$checkKey = $params['user_type'] == 1 ? $params['mer_id'].'check' : $params['supplier_id'].'check';
|
||||
$check = Cache::get($totalKey) ?? 0;
|
||||
if ($check && $check > 9) {
|
||||
return $this->fail('超出绑定限制请明日再绑定');
|
||||
}
|
||||
$wrongNum = Cache::get($checkKey) ?? 0;
|
||||
if($wrongNum && $wrongNum > 2){
|
||||
return $this->fail('当日认证次数已超限制,请勿重复提交,请次日后再试');
|
||||
}
|
||||
Cache::set($totalKey, (int)($check+1),$expireAt);
|
||||
if($params['is_own'] == 0){
|
||||
$info = [
|
||||
'name'=>$params['name'],
|
||||
'idNum'=>$params['id_card'],
|
||||
'cardNo'=>$params['bank_code'],
|
||||
'mobile'=>$params['phone'],
|
||||
];
|
||||
$thinkApi = new ThinkApi();
|
||||
$result = $thinkApi->request('bankcard/auth',$info);
|
||||
if($result['code'] != 0 || empty($result['data'])){
|
||||
return $this->fail($result['message']);
|
||||
}
|
||||
//认证结果。01:一致 02:不一致 03:认证不确定 04:认证失败。01、02收费
|
||||
if($result['data']['result'] == 4 || $result['data']['result'] == 2){
|
||||
Cache::set($checkKey, (int)($wrongNum+1),$expireAt);
|
||||
}
|
||||
if($result['data']['result'] == 4 || $result['data']['result'] == 2){
|
||||
$wrongNum = Cache::get($checkKey);
|
||||
$numMsg = ',当日剩余认证次数'.(3-$wrongNum);
|
||||
return $this->fail('认证失败,请检查姓名,身份证,银行卡,银行预留手机号码是否正确'.$numMsg);
|
||||
}
|
||||
}
|
||||
$save_data = [
|
||||
'user_type' => $params['user_type'],
|
||||
'mer_id' => $params['mer_id'] ?? 0,
|
||||
'supplier_id' => $params['supplier_id'] ?? 0,
|
||||
'name' => $params['name'],
|
||||
'bank_id' => $params['bank_id'],
|
||||
'bank_code' => $params['bank_code'],
|
||||
'bank_branch' => $params['bank_branch'],
|
||||
'phone' => $params['phone'] ?? '',
|
||||
'id_card' => $params['id_card'] ?? '',
|
||||
'financial_img' => $params['financial_img'] ?? '',
|
||||
'is_own' => $params['is_own'],
|
||||
'is_check' => 0,
|
||||
'create_time' => time()
|
||||
];
|
||||
//写入数据
|
||||
$res = Db::name('merchant_bank')->insert($save_data);
|
||||
return $res ? $this->success('添加成功') : $this->fail('添加失败');
|
||||
}
|
||||
}
|
105
app/api/controller/user/UserBankController.php
Normal file
105
app/api/controller/user/UserBankController.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\user;
|
||||
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\validate\MerchantBankValidate;
|
||||
use app\common\model\merchant\Merchant;
|
||||
use app\common\model\merchant\MerchantBank;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\service\ThinkApi;
|
||||
|
||||
class UserBankController extends BaseApiController
|
||||
{
|
||||
//绑定银行卡
|
||||
public function add_bank()
|
||||
{
|
||||
$params = (new MerchantBankValidate())->post()->goCheck('add');
|
||||
$uid = $this->request->userInfo['user_id'];
|
||||
$merchant = Merchant::where('uid',$uid)->findOrEmpty();
|
||||
$supplier = Supplier::where('uid',$uid)->findOrEmpty();
|
||||
if($merchant->isEmpty() && $supplier->isEmpty()){
|
||||
return $this->fail('当前用户非商户或供应商');
|
||||
}
|
||||
//判断是否已绑定
|
||||
if(!$merchant->isEmpty()){
|
||||
$has = MerchantBank::where('mer_id',$merchant['mer_id'])->where('is_own',$params['is_own'])->where('is_check','<>',2)->findOrEmpty();
|
||||
if(!$has->isEmpty()){
|
||||
return $this->fail('已提交审核请勿重复提交1');
|
||||
}
|
||||
if($params['is_own'] == 0){
|
||||
$info = [
|
||||
'name'=>$params['name'],
|
||||
'idNum'=>$params['id_card'],
|
||||
'cardNo'=>$params['bank_code'],
|
||||
'mobile'=>$params['phone'],
|
||||
];
|
||||
$thinkApi = new ThinkApi();
|
||||
$result = $thinkApi->request('bankcard/auth',$info);
|
||||
if($result['code'] != 0 || empty($result['data'])){
|
||||
return $this->fail($result['message']);
|
||||
}
|
||||
//认证结果。01:一致 02:不一致 03:认证不确定 04:认证失败。01、02收费
|
||||
if($result['data']['result'] == 4 || $result['data']['result'] == 2){
|
||||
return $this->fail('认证失败,请检查姓名,身份证,银行卡,银行预留手机号码是否正确');
|
||||
}
|
||||
}
|
||||
$save_data = [
|
||||
'mer_id' => $merchant['mer_id'],
|
||||
'name' => $params['name'],
|
||||
'bank_id' => $params['bank_id'],
|
||||
'bank_code' => $params['bank_code'],
|
||||
'bank_branch' => $params['bank_branch'],
|
||||
'phone' => $params['phone'] ?? '',
|
||||
'id_card' => $params['id_card'] ?? '',
|
||||
'financial_img' => $params['financial_img'] ?? '',
|
||||
'is_own' => $params['is_own'],
|
||||
'is_check' => 0,
|
||||
'create_time' => time()
|
||||
];
|
||||
//写入数据
|
||||
(new MerchantBank)->save($save_data);
|
||||
return $this->success('添加成功');
|
||||
}elseif (!$supplier->isEmpty()){
|
||||
$has = MerchantBank::where('supplier_id',$supplier['id'])->where('is_own',$params['is_own'])->where('is_check','<>',2)->findOrEmpty();
|
||||
if(!$has->isEmpty()){
|
||||
return $this->fail('已提交审核请勿重复提交2');
|
||||
}
|
||||
if($params['is_own'] == 0){
|
||||
$info = [
|
||||
'name'=>$params['name'],
|
||||
'idNum'=>$params['id_card'],
|
||||
'cardNo'=>$params['bank_code'],
|
||||
'mobile'=>$params['phone'],
|
||||
];
|
||||
$thinkApi = new ThinkApi();
|
||||
$result = $thinkApi->request('bankcard/auth',$info);
|
||||
if($result['code'] != 0 || empty($result['data'])){
|
||||
return $this->fail($result['message']);
|
||||
}
|
||||
//认证结果。01:一致 02:不一致 03:认证不确定 04:认证失败。01、02收费
|
||||
if($result['data']['result'] == 4 || $result['data']['result'] == 2){
|
||||
return $this->fail('认证失败,请检查姓名,身份证,银行卡,银行预留手机号码是否正确');
|
||||
}
|
||||
}
|
||||
$save_data = [
|
||||
'supplier_id' => $supplier['id'],
|
||||
'name' => $params['name'],
|
||||
'bank_id' => $params['bank_id'],
|
||||
'bank_code' => $params['bank_code'],
|
||||
'bank_branch' => $params['bank_branch'],
|
||||
'phone' => $params['phone'] ?? '',
|
||||
'id_card' => $params['id_card'] ?? '',
|
||||
'financial_img' => $params['financial_img'] ?? '',
|
||||
'is_own' => $params['is_own'],
|
||||
'is_check' => 0,
|
||||
'create_time' => time()
|
||||
];
|
||||
//写入数据
|
||||
(new MerchantBank)->save($save_data);
|
||||
return $this->success('添加成功');
|
||||
}else{
|
||||
return $this->fail('未找到商户或供应商信息');
|
||||
}
|
||||
}
|
||||
}
|
@ -25,11 +25,7 @@
|
||||
public function add()
|
||||
{
|
||||
$params = (new UserFeedbackValidate())->post()->goCheck('add');
|
||||
$user = $this->request->userInfo;
|
||||
if($params['uid'] != $user['user_id']){
|
||||
return $this->fail('用户信息错误');
|
||||
}
|
||||
$result = UserFeedbackLogic::add($params);
|
||||
$result = UserFeedbackLogic::add($params,$this->request->userInfo['user_id']);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
|
119
app/api/controller/user/UserWithdrawController.php
Normal file
119
app/api/controller/user/UserWithdrawController.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\user;
|
||||
|
||||
use app\admin\validate\withdraw\MerchantWithdrawValidate;
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\lists\withdraw\MerchantWithdrawLists;
|
||||
use app\common\model\bank\Bank;
|
||||
use app\common\model\merchant\Merchant;
|
||||
use app\common\model\merchant\MerchantBank;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\model\withdraw\MerchantWithdraw;
|
||||
|
||||
class UserWithdrawController extends BaseApiController
|
||||
{
|
||||
//获取用户余额和绑定银行账户信息
|
||||
public function amount_account(){
|
||||
$uid = $this->request->userInfo['user_id'];
|
||||
$merchant = Merchant::where('uid',$uid)->findOrEmpty();
|
||||
$supplier = Supplier::where('uid',$uid)->findOrEmpty();
|
||||
if($merchant->isEmpty() && $supplier->isEmpty()){
|
||||
return $this->fail('当前用户非商户或供应商');
|
||||
}
|
||||
if(!$merchant->isEmpty()){
|
||||
$bank_list = MerchantBank::where('mer_id',$merchant['mer_id'])->where('is_check',1)->select()->each(function($data){
|
||||
$bank_info = Bank::where('id',$data['bank_id'])->findOrEmpty();
|
||||
$data['bank_name'] = !$bank_info->isEmpty() ? $bank_info['name'] : '';
|
||||
$data['bank_image'] = !$bank_info->isEmpty() ? $bank_info['image'] : '';
|
||||
return $data;
|
||||
})->toArray();
|
||||
return $this->success('请求成功',[
|
||||
'balance' => $merchant['mer_money'],
|
||||
'bank_list' => $bank_list
|
||||
]);
|
||||
} elseif (!$supplier->isEmpty()){
|
||||
$bank_list = MerchantBank::where('supplier_id',$supplier['id'])->where('is_check',1)->select()->each(function($data){
|
||||
$bank_info = Bank::where('id',$data['bank_id'])->findOrEmpty();
|
||||
$data['bank_name'] = !$bank_info->isEmpty() ? $bank_info['name'] : '';
|
||||
$data['bank_image'] = !$bank_info->isEmpty() ? $bank_info['image'] : '';
|
||||
return $data;
|
||||
})->toArray();
|
||||
return $this->success('请求成功',[
|
||||
'balance' => $merchant['mer_money'],
|
||||
'bank_list' => $bank_list
|
||||
]);
|
||||
}else{
|
||||
return $this->fail('未找到商户或供应商信息');
|
||||
}
|
||||
}
|
||||
|
||||
//用户提现操作
|
||||
public function withdraw(){
|
||||
$params = (new MerchantWithdrawValidate())->post()->goCheck('withdraw');
|
||||
$uid = $this->request->userInfo['user_id'];
|
||||
$merchant = Merchant::where('uid',$uid)->findOrEmpty();
|
||||
$supplier = Supplier::where('uid',$uid)->findOrEmpty();
|
||||
if($merchant->isEmpty() && $supplier->isEmpty()){
|
||||
return $this->fail('当前用户非商户或供应商');
|
||||
}
|
||||
if(!$merchant->isEmpty()){
|
||||
if($params['amount'] > $merchant['mer_money']){
|
||||
return $this->fail('提现余额不足');
|
||||
}
|
||||
$save_data = [
|
||||
'mer_id' => $merchant['mer_id'],
|
||||
'merchant_bank_id' => $params['merchant_bank_id'],
|
||||
'amount' => $params['amount'],
|
||||
'is_check' => 0,
|
||||
'is_arrival' => 0,
|
||||
'admin_id' => 0,
|
||||
'create_time' => time(),
|
||||
];
|
||||
(new MerchantWithdraw) -> save($save_data);
|
||||
return $this->success('提现成功,等待管理员审核');
|
||||
} elseif (!$supplier->isEmpty()){
|
||||
if($params['amount'] > $supplier['mer_money']){
|
||||
return $this->fail('提现余额不足');
|
||||
}
|
||||
$save_data = [
|
||||
'supplier_id' => $supplier['id'],
|
||||
'merchant_bank_id' => $params['merchant_bank_id'],
|
||||
'amount' => $params['amount'],
|
||||
'is_check' => 0,
|
||||
'is_arrival' => 0,
|
||||
'admin_id' => 0,
|
||||
'create_time' => time(),
|
||||
];
|
||||
(new MerchantWithdraw) -> save($save_data);
|
||||
return $this->success('提现成功,等待管理员审核');
|
||||
}else{
|
||||
return $this->fail('未找到商户或供应商信息');
|
||||
}
|
||||
}
|
||||
|
||||
public function index(){
|
||||
$uid = $this->request->userInfo['user_id'];
|
||||
$merchant = Merchant::where('uid',$uid)->findOrEmpty();
|
||||
$supplier = Supplier::where('uid',$uid)->findOrEmpty();
|
||||
if($merchant->isEmpty() && $supplier->isEmpty()){
|
||||
return $this->fail('当前用户非商户或供应商');
|
||||
}
|
||||
if(!$merchant->isEmpty()){
|
||||
$total_amount = MerchantWithdraw::where('mer_id',$merchant['mer_id'])->where('is_check',1)->where('is_arrival',1)->sum('amount');
|
||||
$count = MerchantWithdraw::where('mer_id',$merchant['mer_id'])->where('is_check',1)->where('is_arrival',1)->count();
|
||||
return $this->success('请求成功',['total'=>$total_amount,'count'=>$count]);
|
||||
} elseif (!$supplier->isEmpty()){
|
||||
$total_amount = MerchantWithdraw::where('supplier_id',$supplier['id'])->where('is_check',1)->where('is_arrival',1)->sum('amount');
|
||||
$count = MerchantWithdraw::where('supplier_id',$supplier['id'])->where('is_check',1)->where('is_arrival',1)->count();
|
||||
return $this->success('请求成功',['total'=>$total_amount,'count'=>$count]);
|
||||
}else{
|
||||
return $this->fail('未找到商户或供应商信息');
|
||||
}
|
||||
}
|
||||
|
||||
//提现列表
|
||||
public function lists(){
|
||||
return $this->dataLists(new MerchantWithdrawLists());
|
||||
}
|
||||
}
|
102
app/api/lists/withdraw/MerchantWithdrawLists.php
Normal file
102
app/api/lists/withdraw/MerchantWithdrawLists.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\lists\withdraw;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\bank\Bank;
|
||||
use app\common\model\merchant\Merchant;
|
||||
use app\common\model\merchant\MerchantBank;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\model\withdraw\MerchantWithdraw;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 商户供应商提现表列表
|
||||
* Class MerchantWithdrawLists
|
||||
* @package app\admin\listswithdraw
|
||||
*/
|
||||
class MerchantWithdrawLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商户供应商提现表列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$uid = $this->request->userInfo['user_id'];
|
||||
$merchant = Merchant::where('uid',$uid)->findOrEmpty();
|
||||
$supplier = Supplier::where('uid',$uid)->findOrEmpty();
|
||||
$where = [];
|
||||
if(!$merchant->isEmpty()){
|
||||
$where[] = ['mer_id','=',$merchant['mer_id']];
|
||||
}elseif(!$supplier->isEmpty()){
|
||||
$where[] = ['supplier_id','=',$supplier['id']];
|
||||
}
|
||||
if(isset($params['create_time']) && $params['create_time'] != ''){
|
||||
$firstDayOfMonth = strtotime("{$params['create_time']}-01");
|
||||
$lastDayOfMonth = strtotime("+1 month -1 second", $firstDayOfMonth);
|
||||
$where[] = ['create_time','between',[$firstDayOfMonth,$lastDayOfMonth]];
|
||||
}
|
||||
return MerchantWithdraw::where($this->searchWhere)->where($where)
|
||||
->field(['id', 'mer_id', 'supplier_id', 'merchant_bank_id', 'amount', 'is_check', 'is_arrival', 'arrival_proof', 'create_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
$merchant_bank = MerchantBank::where('id',$data['merchant_bank_id'])->findOrEmpty();
|
||||
$bank = Bank::where('id',$merchant_bank['bank_id'])->findOrEmpty();
|
||||
$merchant_bank['bank_info'] = $bank;
|
||||
$data['merchant_bank_info'] = $merchant_bank;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商户供应商提现表数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/05/14 11:21
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$uid = $this->request->userInfo['user_id'];
|
||||
$merchant = Merchant::where('uid',$uid)->findOrEmpty();
|
||||
$supplier = Supplier::where('uid',$uid)->findOrEmpty();
|
||||
$where = [];
|
||||
if(!$merchant->isEmpty()){
|
||||
$where[] = ['mer_id','=',$merchant['mer_id']];
|
||||
}elseif(!$supplier->isEmpty()){
|
||||
$where[] = ['supplier_id','=',$supplier['id']];
|
||||
}
|
||||
if(isset($params['create_time']) && $params['create_time'] != ''){
|
||||
$firstDayOfMonth = strtotime("{$params['create_time']}-01");
|
||||
$lastDayOfMonth = strtotime("+1 month -1 second", $firstDayOfMonth);
|
||||
$where[] = ['create_time','between',[$firstDayOfMonth,$lastDayOfMonth]];
|
||||
}
|
||||
return MerchantWithdraw::where($this->searchWhere)->where($where)->count();
|
||||
}
|
||||
|
||||
}
|
@ -15,12 +15,12 @@
|
||||
* @author likeadmin
|
||||
* @date 2024/05/13 16:56
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
public static function add(array $params,$uid): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
UserFeedback::create([
|
||||
'uid' => $params['uid'],
|
||||
'uid' => $uid,
|
||||
'content' => $params['content'],
|
||||
'images' => $params['images'] ? json_encode($params['images']) : null,
|
||||
'name' => $params['name'],
|
||||
|
@ -8,9 +8,6 @@
|
||||
class MerchantBankValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'user_type|用户类型' => 'require|in:1,2',
|
||||
'mer_id|商户id' => 'requireIf:user_type,1|checkMerchant',
|
||||
'supplier_id|供应商id' => 'requireIf:user_type,2|checkSupplier',
|
||||
'is_own|账号类型' => 'require|in:0,1',
|
||||
'name|姓名' => 'require',
|
||||
'bank_id|开户银行' => 'require|checkBank',
|
||||
@ -24,7 +21,7 @@
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['user_type','mer_id','supplier_id','is_own','bank_id','name','bank_code','bank_branch','id_card','phone','financial_img']);
|
||||
return $this->only(['is_own','bank_id','name','bank_code','bank_branch','id_card','phone','financial_img']);
|
||||
}
|
||||
|
||||
public function checkBank($value){
|
||||
@ -34,20 +31,4 @@
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkMerchant($value){
|
||||
$data = Db::name('merchant')->where('mer_id',$value)->findOrEmpty();
|
||||
if(empty($data)){
|
||||
return '商户不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkSupplier($value){
|
||||
$data = Db::name('supplier')->where('id',$value)->findOrEmpty();
|
||||
if(empty($data)){
|
||||
return '供应商不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
22
app/common/model/withdraw/MerchantWithdraw.php
Normal file
22
app/common/model/withdraw/MerchantWithdraw.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\withdraw;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 商户供应商提现表模型
|
||||
* Class MerchantWithdraw
|
||||
* @package app\common\model\withdraw
|
||||
*/
|
||||
class MerchantWithdraw extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'merchant_withdraw';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
@ -30,7 +30,7 @@ class BaseValidate extends Validate
|
||||
*/
|
||||
public function post()
|
||||
{
|
||||
if (!request()->method() == 'POST') {
|
||||
if (!(request()->method() == 'POST')) {
|
||||
JsonService::throw('请求方式错误,请使用post请求方式');
|
||||
}
|
||||
$this->method = 'POST';
|
||||
@ -44,7 +44,7 @@ class BaseValidate extends Validate
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
if (!request()->method() == 'GET') {
|
||||
if (!(request()->method() == 'GET')) {
|
||||
JsonService::throw('请求方式错误,请使用get请求方式');
|
||||
}
|
||||
return $this;
|
||||
|
@ -50,7 +50,8 @@
|
||||
"hyperf/pimple": "~2.2.0",
|
||||
"yansongda/pay": "~3.7.3",
|
||||
"webman/redis-queue": "^1.3",
|
||||
"webman/push": "^1.0"
|
||||
"webman/push": "^1.0",
|
||||
"ext-bcmath": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-event": "For better performance. "
|
||||
|
Loading…
x
Reference in New Issue
Block a user