This commit is contained in:
mkm 2024-05-23 09:57:19 +08:00
parent cd9eb33f8f
commit c911a4f951
8 changed files with 180 additions and 70 deletions

View File

@ -6,6 +6,7 @@ namespace app\admin\controller\merchat;
use app\admin\controller\BaseAdminController; use app\admin\controller\BaseAdminController;
use app\admin\lists\merchant\MerchantLists; use app\admin\lists\merchant\MerchantLists;
use app\admin\logic\merchant\MerchantLogic; use app\admin\logic\merchant\MerchantLogic;
use app\admin\validate\bank\BankValidate;
use app\admin\validate\merchant\MerchantValidate; use app\admin\validate\merchant\MerchantValidate;
use app\common\model\goods\Goods; use app\common\model\goods\Goods;
use app\common\model\goods\GoodsLabel; use app\common\model\goods\GoodsLabel;
@ -164,6 +165,19 @@ class MerchantController extends BaseAdminController
} }
return $this->fail('绑定失败'); return $this->fail('绑定失败');
} }
/**
* @notes 绑定银行卡
*/
public function bind_bank()
{
$params = (new BankValidate())->post()->goCheck('BindBank');
$result = MerchantLogic::bind_bank($params);
if (true === $result) {
return $this->success('设置成功', [], 1, 1);
}
return $this->fail(MerchantLogic::getError());
}
/** /**
* @notes 绑定商品 * @notes 绑定商品

View File

@ -3,12 +3,14 @@
namespace app\admin\logic\merchant; namespace app\admin\logic\merchant;
use app\admin\logic\user\UserLogic; use app\admin\logic\user\UserLogic;
use app\admin\service\JgPushService; use app\common\service\JgPushService;
use app\common\enum\OrderEnum; use app\common\enum\OrderEnum;
use app\common\model\merchant\Merchant; use app\common\model\merchant\Merchant;
use app\common\logic\BaseLogic; use app\common\logic\BaseLogic;
use app\common\model\financial\FinancialRecord; use app\common\model\financial\FinancialRecord;
use app\common\model\merchant\MerchantBank;
use app\common\model\user\User; use app\common\model\user\User;
use app\common\service\ThinkApi;
use think\facade\Db; use think\facade\Db;
use support\exception\BusinessException; use support\exception\BusinessException;
@ -33,7 +35,7 @@ class MerchantLogic extends BaseLogic
{ {
Db::startTrans(); Db::startTrans();
try { try {
$res= Merchant::create([ $res = Merchant::create([
'category_id' => $params['category_id'], 'category_id' => $params['category_id'],
'type_id' => $params['type_id'] ?? '', 'type_id' => $params['type_id'] ?? '',
'mer_name' => $params['mer_name'], 'mer_name' => $params['mer_name'],
@ -64,10 +66,10 @@ class MerchantLogic extends BaseLogic
'company_nickname' => $params['company_nickname'] ?? '', 'company_nickname' => $params['company_nickname'] ?? '',
'social_credit_code' => $params['social_credit_code'] ?? '', 'social_credit_code' => $params['social_credit_code'] ?? '',
'company_name' => $params['company_name'] ?? '', 'company_name' => $params['company_name'] ?? '',
'images'=>$params['images'][0] ?? '', 'images' => $params['images'][0] ?? '',
]) ])
]); ]);
Db::name('user_auth_shop')->insert(['pid'=>$res->id,'user_id'=>0,'shop_uid'=>$params['shop_user_id'],'status'=>0,'type'=>1,'create_time'=>time(),'jg_register_id'=>$params['jg_register_id']]); Db::name('user_auth_shop')->insert(['pid' => $res->id, 'user_id' => 0, 'shop_uid' => $params['shop_user_id'], 'status' => 0, 'type' => 1, 'create_time' => time(), 'jg_register_id' => $params['jg_register_id']]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -120,7 +122,7 @@ class MerchantLogic extends BaseLogic
'company_nickname' => $params['company_nickname'] ?? '', 'company_nickname' => $params['company_nickname'] ?? '',
'social_credit_code' => $params['social_credit_code'] ?? '', 'social_credit_code' => $params['social_credit_code'] ?? '',
'company_name' => $params['company_name'] ?? '', 'company_name' => $params['company_name'] ?? '',
'images'=>$params['images'][0] ?? '', 'images' => $params['images'][0] ?? '',
]) ])
]); ]);
@ -141,13 +143,13 @@ class MerchantLogic extends BaseLogic
*/ */
public static function status(array $params): bool public static function status(array $params): bool
{ {
$apply_info = Db::name('user_auth_shop')->where('id',$params['apply_id'])->findOrEmpty(); $apply_info = Db::name('user_auth_shop')->where('id', $params['apply_id'])->findOrEmpty();
Db::startTrans(); Db::startTrans();
try { try {
if($params['status']==1){ if ($params['status'] == 1) {
$user=[ $user = [
'real_name'=>$params['service_phone'], 'real_name' => $params['service_phone'],
'nickname' => '用户'.$params['service_phone'], 'nickname' => '用户' . $params['service_phone'],
'account' => $params['service_phone'], 'account' => $params['service_phone'],
'mobile' => $params['service_phone'], 'mobile' => $params['service_phone'],
'password' => $params['service_phone'], 'password' => $params['service_phone'],
@ -156,33 +158,33 @@ class MerchantLogic extends BaseLogic
'user_money' => 0 'user_money' => 0
]; ];
$res1=UserLogic::add($user); $res1 = UserLogic::add($user);
if($res1==false){ if ($res1 == false) {
Db::rollback(); Db::rollback();
throw new BusinessException(UserLogic::getError(), 0); throw new BusinessException(UserLogic::getError(), 0);
} }
$data=[ $data = [
'user_id'=>$res1['id'], 'user_id' => $res1['id'],
'status'=>1, 'status' => 1,
'apply_status'=>1, 'apply_status' => 1,
'pid'=>$params['mer_id'] 'pid' => $params['mer_id']
]; ];
Merchant::where('mer_id',$params['mer_id'])->update(['status'=>1,'uid'=>$res1['id']]); Merchant::where('mer_id', $params['mer_id'])->update(['status' => 1, 'uid' => $res1['id']]);
Db::name('user_auth_shop')->where('id',$params['apply_id'])->update($data); Db::name('user_auth_shop')->where('id', $params['apply_id'])->update($data);
} }
if($params['status']==0){ if ($params['status'] == 0) {
$data=[ $data = [
'mark'=>$params['mark']??'', 'mark' => $params['mark'] ?? '',
'apply_status'=>-1 'apply_status' => -1
]; ];
Merchant::where('mer_id', $params['mer_id'])->update([ Merchant::where('mer_id', $params['mer_id'])->update([
'status' => 0, 'status' => 0,
]); ]);
Db::name('user_auth_shop')->where('id',$params['apply_id'])->update($data); Db::name('user_auth_shop')->where('id', $params['apply_id'])->update($data);
} }
if(!empty($apply_info['jg_register_id'])){ if (!empty($apply_info['jg_register_id'])) {
(new JgPushService()) -> sendMsg($apply_info['jg_register_id'],'您的经销入驻请求审核'.($params['status']==1?'通过':'被拒绝'),'/pages/bindDistribution/index'); (new JgPushService())->sendMsg($apply_info['jg_register_id'], '您的经销入驻请求审核' . ($params['status'] == 1 ? '通过' : '被拒绝'), '/pages/bindDistribution/index');
} }
Db::commit(); Db::commit();
return true; return true;
@ -195,15 +197,16 @@ class MerchantLogic extends BaseLogic
/** /**
* @notes 设置余额 * @notes 设置余额
*/ */
public static function set_money($id,$set_money,$type=1){ public static function set_money($id, $set_money, $type = 1)
{
Db::startTrans(); Db::startTrans();
try { try {
if($type==1){ if ($type == 1) {
Merchant::where('mer_id',$id)->inc('mer_money',$set_money)->update(); Merchant::where('mer_id', $id)->inc('mer_money', $set_money)->update();
$record = [ $record = [
'financial_record_sn' => time(), 'financial_record_sn' => time(),
'order_id' => 0, 'order_id' => 0,
'number_sn' =>getNewOrderId('XTCZ') , 'number_sn' => getNewOrderId('XTCZ'),
'user_id' => 0, 'user_id' => 0,
'financial_type' => OrderEnum::SYSTEM_SET, 'financial_type' => OrderEnum::SYSTEM_SET,
'financial_pm' => OrderEnum::INCOME, 'financial_pm' => OrderEnum::INCOME,
@ -213,18 +216,18 @@ class MerchantLogic extends BaseLogic
'mer_id' => $id, 'mer_id' => $id,
]; ];
FinancialRecord::create($record); FinancialRecord::create($record);
}else{ } else {
$money=Merchant::where('mer_id',$id)->value('mer_money'); $money = Merchant::where('mer_id', $id)->value('mer_money');
if($money<$set_money){ if ($money < $set_money) {
Db::rollback(); Db::rollback();
self::setError('余额不足'); self::setError('余额不足');
return false; return false;
} }
Merchant::where('mer_id',$id)->dec('mer_money',$set_money)->update(); Merchant::where('mer_id', $id)->dec('mer_money', $set_money)->update();
$record = [ $record = [
'financial_record_sn' => time(), 'financial_record_sn' => time(),
'order_id' => 0, 'order_id' => 0,
'number_sn' =>getNewOrderId('XTJS') , 'number_sn' => getNewOrderId('XTJS'),
'user_id' => 0, 'user_id' => 0,
'financial_type' => OrderEnum::SYSTEM_SET, 'financial_type' => OrderEnum::SYSTEM_SET,
'financial_pm' => OrderEnum::EXPENDITURE, 'financial_pm' => OrderEnum::EXPENDITURE,
@ -275,7 +278,68 @@ class MerchantLogic extends BaseLogic
return false; return false;
} }
} }
/**
* @notes 商户绑定银行卡
* @param array $params
* @return bool
* @date 2024/04/23 16:35
*/
public static function bind_bank(array $params): bool
{
$merchant = Merchant::where('mer_id', $params['mer_id'])->findOrEmpty();
$user=User::where('id',$merchant['uid'])->field('real_name','mobile')->find();
if (!$merchant) {
self::setError('商户不存在');
return false;
}
if(!$user){
self::setError('没有绑定用户');
return false;
}
if ($params['is_own'] == 0) {
$info = [
'name' => $params['name'],
'idNum' => $params['id_card'],
'cardNo' => $params['bank_code'],
'mobile' => $user['mobile'],
];
$thinkApi = new ThinkApi();
$result = $thinkApi->request('bankcard/auth', $info);
if ($result['code'] != 0 || empty($result['data'])) {
self::setError($result['message']);
return false;
}
//认证结果。01一致 02不一致 03认证不确定 04认证失败。01、02收费
if ($result['data']['result'] == 4 || $result['data']['result'] == 2) {
self::setError('认证失败,请检查姓名,身份证,银行卡,银行预留手机号码是否正确');
return false;
}
}
Db::startTrans();
try {
$save_data = [
'mer_id' => $params['mer_id'],
'name' => $params['name'],
'bank_id' => $params['bank_id'],
'bank_code' => $params['bank_code'],
'bank_branch' => $params['bank_branch'],
'phone' => $user['mobile'],
'id_card' => $params['id_card'] ?? '',
'financial_img' => $params['financial_img'],
'is_own' => $params['is_own'],
'is_check' => 1,
'create_time' => time()
];
//写入数据
(new MerchantBank)->save($save_data);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/** /**
* @notes 删除商户列表 * @notes 删除商户列表

View File

@ -3,7 +3,7 @@
namespace app\admin\logic\supplier; namespace app\admin\logic\supplier;
use app\admin\logic\user\UserLogic; use app\admin\logic\user\UserLogic;
use app\admin\service\JgPushService; use app\common\service\JgPushService;
use app\common\enum\OrderEnum; use app\common\enum\OrderEnum;
use app\common\model\goods\GoodsLabel; use app\common\model\goods\GoodsLabel;
use app\common\model\merchant\MerchantBank; use app\common\model\merchant\MerchantBank;

View File

@ -22,6 +22,10 @@ class BankValidate extends BaseValidate
'id' => 'require', 'id' => 'require',
'name' => 'require', 'name' => 'require',
'image' => 'require', 'image' => 'require',
'bank_id' => 'require',
'bank_code' => 'require',
'bank_branch' => 'require',
'financial_img' => 'require',
]; ];
@ -33,9 +37,22 @@ class BankValidate extends BaseValidate
'id' => 'id', 'id' => 'id',
'name' => '银行名称', 'name' => '银行名称',
'image' => '银行图片', 'image' => '银行图片',
'bank_id' => '开户银行',
'bank_code' => '银行账号',
'bank_branch' => '开户网点',
'financial_img' => '图片证明',
]; ];
/**
* @notes 状态场景
* @return MerchantValidate
* @author likeadmin
* @date 2024/04/23 16:35
*/
public function sceneBindBank()
{
return $this->only(['name', 'bank_code','bank_id','bank_branch','financial_img']);
}
/** /**
* @notes 添加场景 * @notes 添加场景
* @return BankValidate * @return BankValidate

View File

@ -56,7 +56,7 @@ class MerchantController extends BaseApiController
} }
/** /**
* 提现信息 * 提现总次数和金额
*/ */
public function taking_info() public function taking_info()
{ {

View File

@ -24,7 +24,7 @@ class IndexController extends BaseApiController{
} }
$res=ShopLogic::auth($token,$jg_register_id); $res=ShopLogic::auth($token,$jg_register_id);
if(ShopLogic::hasError()||$res==false){ if(ShopLogic::hasError()||$res==false){
return $this->fail('没有授权信息'); return $this->success('没有授权信息');
}else{ }else{
return $this->success('ok',['token'=>$res]); return $this->success('ok',['token'=>$res]);
} }
@ -112,7 +112,7 @@ class IndexController extends BaseApiController{
} }
} }
} }
return $this->fail('没有授权信息'); return $this->success('没有授权信息');
} }
/** /**
* 申请详情 * 申请详情

View File

@ -1,6 +1,6 @@
<?php <?php
namespace app\admin\service; namespace app\common\service;
use JPush\Client; use JPush\Client;
use support\Log; use support\Log;

View File

@ -3,13 +3,16 @@
namespace app\queue\redis; namespace app\queue\redis;
use app\admin\logic\operation\OpurchaseclassLogic; use app\admin\logic\operation\OpurchaseclassLogic;
use app\common\model\opurchase\OpurchaseGoodsOffer;
use app\common\model\opurchase\Opurchaseinfo; use app\common\model\opurchase\Opurchaseinfo;
use app\common\service\JgPushService;
use Webman\RedisQueue\Consumer; use Webman\RedisQueue\Consumer;
use Webman\Push\Api;
use support\exception\BusinessException;
use support\Log; use support\Log;
use think\facade\Db; use think\facade\Db;
/**
* 推送给供应商报价
*/
class PushSupplierProductsSend implements Consumer class PushSupplierProductsSend implements Consumer
{ {
// 要消费的队列名 // 要消费的队列名
@ -26,6 +29,18 @@ class PushSupplierProductsSend implements Consumer
foreach ($select as $key => $arr) { foreach ($select as $key => $arr) {
OpurchaseclassLogic::createSupplierGoods($arr); OpurchaseclassLogic::createSupplierGoods($arr);
} }
$supplier_id_arr=OpurchaseGoodsOffer::where('order',$order_id)->whereDay('create_time')->column('supplier_id');
if($supplier_id_arr){
$supplier_id_arr=array_unique($supplier_id_arr);
foreach($supplier_id_arr as $key => $supplier_id){
$jg_register_id=Db::name('user_auth_shop')-> where('pid',$supplier_id)->where('type',2)->value('jg_register_id');
if($jg_register_id){
(new JgPushService())->sendMsg($jg_register_id, '您有一笔新的报价清单,请及时处理', '/pages/quote/list',2);
}
}
}
} }
public function onConsumeFailure(\Throwable $e, $package) public function onConsumeFailure(\Throwable $e, $package)
{ {