订单字段优化

This commit is contained in:
Jack 2025-04-15 15:52:38 +08:00
parent 80563a0785
commit d3750cb077
5 changed files with 83 additions and 56 deletions

View File

@ -38,6 +38,9 @@ public interface AccountUserBindConnectService extends IBaseService<AccountUserB
*/
AccountUserBindConnect getBindByBindId(String bind_id, Integer bind_type, Integer user_type);
// 根据 bind_id bind_type user_iduser_type获取一条记录
AccountUserBindConnect getBindByBindId(String bind_id, Integer bind_type, Integer user_id, Integer user_type);
boolean checkBind(String bind_id, int bind_type, Integer user_id, Integer user_type, AccountUserBindConnect user_info_row);

View File

@ -1801,10 +1801,31 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
throw new ApiException(ResultCode.FAILED);
}
// 绑定基本关系
AccountUserBindConnect accountUserBindConnect = accountUserBindConnectService.initAccountUserBindConnect(user_mobile, bind_type, user_id, userIsAdmin);
if (accountUserBindConnect == null) {
throw new ApiException(_("绑定账号失败"));
boolean addUserBindConnect = false;
// 验证是否手机绑定过了
if (StrUtil.isNotBlank(user_mobile)) {
// connect绑定操作
AccountUserBindConnect bindConnect = accountUserBindConnectService.getBindByBindId(user_mobile, BindCode.MOBILE, user_id, userIsAdmin);
if (bindConnect == null) {
addUserBindConnect = true;
}
}
// 验证是否邮箱绑定过了
if (StrUtil.isNotBlank(user_email) || bind_type.equals(BindCode.EMAIL)) {
// connect绑定操作
AccountUserBindConnect bindConnect = accountUserBindConnectService.getBindByBindId(user_email, BindCode.EMAIL, user_id, userIsAdmin);
if (bindConnect == null) {
addUserBindConnect = true;
}
}
if (addUserBindConnect) {
// 初始化绑用户定关系
AccountUserBindConnect accountUserBindConnect = accountUserBindConnectService.initAccountUserBindConnect(user_mobile, bind_type, user_id, userIsAdmin);
if (accountUserBindConnect == null) {
throw new ApiException(_("绑定账号失败"));
}
}
AccountUserLogin user_login_reg_row = new AccountUserLogin();
@ -1820,29 +1841,6 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
throw new ApiException(ResultCode.FAILED);
}
// 是否为手机号注册
if (StrUtil.isNotBlank(user_mobile)) {
// connect绑定操作
AccountUserBindConnect bindConnect = new AccountUserBindConnect();
bindConnect.setBind_openid(user_mobile);
bindConnect.setBind_active(CommonConstant.Enable);
if (!bindConnectService.checkBind(user_mobile, BindCode.MOBILE, user_id, userIsAdmin, bindConnect)) {
throw new ApiException(ResultCode.FAILED);
}
}
// 是否为邮箱注册
if (StrUtil.isNotBlank(user_email) || bind_type.equals(BindCode.EMAIL)) {
// connect绑定操作
AccountUserBindConnect bindConnect = new AccountUserBindConnect();
bindConnect.setBind_openid(user_email);
bindConnect.setBind_active(CommonConstant.Enable);
if (!bindConnectService.checkBind(user_email, BindCode.EMAIL, user_id, userIsAdmin, bindConnect)) {
throw new ApiException(ResultCode.FAILED);
}
}
// 远程调用异常忽略掉
try {

View File

@ -16,7 +16,6 @@ import com.suisung.mall.common.modules.account.AccountUserBase;
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
import com.suisung.mall.common.modules.account.AccountUserInfo;
import com.suisung.mall.common.pojo.req.WxUserInfoReq;
import com.suisung.mall.common.utils.CheckUtil;
import com.suisung.mall.common.utils.I18nUtil;
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
@ -97,41 +96,64 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
}
@Override
public boolean checkBind(String bind_id, int bind_type, Integer user_id, Integer user_type, AccountUserBindConnect user_info_row) {
public AccountUserBindConnect getBindByBindId(String bind_id, Integer bind_type, Integer user_id, Integer user_type) {
if (StrUtil.isEmpty(bind_id)) {
return null;
}
// 如果是手机号码则进行转换带 +86 的手机号码
bind_id = bind_type == BindCode.MOBILE ? PhoneNumberUtils.convZhPhoneNumber(bind_id) : bind_id;
user_type = ObjectUtil.isNotEmpty(user_type) ? user_type : CommonConstant.USER_TYPE_NORMAL;
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("bind_id", bind_id)
.eq("bind_type", bind_type)
.eq("user_type", user_type)
.eq("user_id", user_id)
.eq("bind_active", CommonConstant.Enable);
return findOne(queryWrapper);
}
@Override
public boolean checkBind(String bind_id, int bind_type, Integer user_id, Integer user_type, AccountUserBindConnect accountUserBindConnect) {
// 如果是手机号码则进行转换带 +86 的手机号码
bind_id = bind_type == BindCode.MOBILE ? PhoneNumberUtils.convZhPhoneNumber(bind_id) : bind_id;
AccountUserBindConnect currAccountUserBindConnect = get(bind_id);
if (currAccountUserBindConnect != null && CheckUtil.isNotEmpty(currAccountUserBindConnect.getUser_id())) {
// 验证通过, 登录成功.
Integer bind_user_id = currAccountUserBindConnect.getUser_id();
if (CheckUtil.isNotEmpty(user_id) && ObjectUtil.equal(user_id, bind_user_id)) {
throw new ApiException(I18nUtil._("非法请求,已经登录用户不应该访问到此页面-重复绑定"));
} else if (CheckUtil.isEmpty(user_id) && ObjectUtil.equal(user_id, bind_user_id)) {
throw new ApiException(I18nUtil._("非法请求,错误绑定数据"));
}
} else if (currAccountUserBindConnect != null && CheckUtil.isEmpty(currAccountUserBindConnect.getUser_id())) {
user_info_row.setUser_id(user_id);
user_info_row.setBind_id(bind_id);
user_info_row.setUser_type(user_type);
// AccountUserBindConnect currAccountUserBindConnect = get(bind_id);
AccountUserBindConnect currAccountUserBindConnect = getBindByBindId(bind_id, bind_type, user_id, user_type);
if (currAccountUserBindConnect == null) {
accountUserBindConnect.setBind_id(bind_id);
accountUserBindConnect.setBind_type(bind_type);
accountUserBindConnect.setUser_id(user_id);
accountUserBindConnect.setUser_type(user_type);
// 重要新增或更新用户绑定关系
if (!saveOrUpdate(user_info_row)) {
throw new ApiException(ResultCode.FAILED);
}
} else if (currAccountUserBindConnect == null) {
// todo 头像会变动, 需要本地缓存, 生成新网址.
user_info_row.setBind_id(bind_id);
user_info_row.setBind_type(bind_type);
user_info_row.setUser_id(user_id);
user_info_row.setUser_type(user_type);
// 重要新增或更新用户绑定关系
if (!saveOrUpdate(user_info_row)) {
if (!saveOrUpdate(accountUserBindConnect)) {
throw new ApiException(ResultCode.FAILED);
}
}
// else {
//
// if (CheckUtil.isNotEmpty(currAccountUserBindConnect.getUser_id())) {
// // 验证通过, 登录成功.
// Integer bind_user_id = currAccountUserBindConnect.getUser_id();
// if (CheckUtil.isNotEmpty(user_id) && ObjectUtil.equal(user_id, bind_user_id)) {
// throw new ApiException(I18nUtil._("非法请求,已经登录用户不应该访问到此页面-重复绑定"));
// } else if (CheckUtil.isEmpty(user_id) && ObjectUtil.equal(user_id, bind_user_id)) {
// throw new ApiException(I18nUtil._("非法请求,错误绑定数据"));
// }
// } else {
// accountUserBindConnect.setUser_id(user_id);
// accountUserBindConnect.setBind_id(bind_id);
// accountUserBindConnect.setUser_type(user_type);
// accountUserBindConnect.setBind_type(bind_type);
//
// // 重要新增或更新用户绑定关系
// if (!saveOrUpdate(accountUserBindConnect)) {
// throw new ApiException(ResultCode.FAILED);
// }
// }
// }
return true;
}

View File

@ -85,11 +85,15 @@ public class ShopMerchEntryController extends BaseControllerImpl {
result.put("id", 0L);
result.put("approval_status", 4);
result.put("approval_remark", "");
result.put("signed_status", -1);
result.put("store_status", 2);
result.put("approval_invalid_col", "[]");
} else {
result.put("id", record.getId());
result.put("approval_status", record.getApproval_status());
result.put("approval_remark", record.getApproval_remark());
result.put("signed_status", record.getSigned_status());
result.put("store_status", record.getStore_status());
result.put("approval_invalid_col", record.getApproval_invalid_col());
}

View File

@ -586,7 +586,7 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl<ShopMerchEntryMap
QueryWrapper<ShopMerchEntry> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("login_mobile", loginMobile)
.select("id", "approval_status", "approval_remark", "login_mobile", "approval_invalid_col", "signed_status", "contract_download_url")
.select("id", "approval_status", "approval_remark", "login_mobile", "approval_invalid_col", "signed_status", "contract_download_url", "store_status")
.orderByAsc("id");
List<ShopMerchEntry> recordList = list(queryWrapper);