feat(UserLogic): 优化用户地址查询逻辑

This commit is contained in:
mkm 2024-07-13 11:22:12 +08:00
parent 0942299f55
commit 75c6e3b05a
2 changed files with 15 additions and 14 deletions

View File

@ -84,26 +84,20 @@ class UserLogic extends BaseLogic
self::setError('请设置村参数');
return false;
}
$arr=User::where('user_ship',$user_ship)->column('id');
if($arr){
$find=UserAddress::where('uid','in',$arr)->where('village',$params['village'])->find();
if($find){
$arr=User::where('user_ship',$user_ship)->alias('user')->join('user_address address','user.id=address.uid and village='.$params['village'])->find();
if ($arr) {
self::setError('该区域已有村长请重新选择');
return false;
}
}
}elseif($user_ship==3){
if(!isset($params['brigade'])){
self::setError('请设置队参数');
return false;
}
$arr=User::where('user_ship',$user_ship)->column('id');
$arr=User::where('user_ship',$user_ship)->alias('user')->join('user_address address','user.id=address.uid and village='.$params['village'] .' and brigade='.$params['brigade'])->find();
if($arr){
$find=UserAddress::where('uid','in',$arr)->where('village',$params['village'])->where('brigade',$params['brigade'])->find();
if($find){
self::setError('该区域已有队长请重新选择');
return false;
}
self::setError('该区域已有队长请重新选择');
return false;
}
}
return true;

View File

@ -66,8 +66,8 @@ class StoreController extends BaseApiController
$params = (new UserValidate())->post()->goCheck('rechargeStoreMoney');
$auth_code = $this->request->post('auth_code'); //微信支付条码
$recharge_type = $this->request->post('recharge_type',''); //微信支付条码
$code = $this->request->post('code','');//验证码
$phone = $params['mobile'];
// $code = $this->request->post('code','');//验证码
// $phone = $params['mobile'];
// if($code && $phone){
// $remark = $phone.'_reporting';
// $codeCache = Cache::get($remark);
@ -84,12 +84,18 @@ class StoreController extends BaseApiController
$find=User::where('account|mobile',$params['mobile'])->find();
if(!$find){
$params['create_uid']=$this->userId;
if(isset($params['user_ship']) && in_array($params['user_ship'],[2,3])){
UserUserLogic::checkAddress($params);
if(UserUserLogic::hasError()){
return $this->fail(UserUserLogic::getError());
}
}
$find=UserUserLogic::StoreAdd($params);
if(UserUserLogic::hasError()){
return $this->fail(UserUserLogic::getError());
}
}else{
if(isset($params['type']) && $params['type'] != 2){
if($find['user_ship']!=$params['user_ship'] && in_array($params['user_ship'],[2,3])){
UserUserLogic::checkAddress($params);
if(UserUserLogic::hasError()){
return $this->fail(UserUserLogic::getError());
@ -130,6 +136,7 @@ class StoreController extends BaseApiController
'recharge_type'=>'INDUSTRYMEMBERS',
'user_ship'=>$params['user_ship']??0,
];
d(123123);
$order = UserRecharge::create($data);
$order['pay_price']=$order['price'];