fix bug account

This commit is contained in:
Jack 2025-06-07 23:54:34 +08:00
parent a9b0d07b8d
commit 62412721ea
4 changed files with 113 additions and 121 deletions

View File

@ -66,7 +66,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.util.Pair;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -212,17 +211,18 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
//user_is_admin 用户类型0-普通用户1-管理员2-入驻商户默认是普通用户
if (StrUtil.isNotBlank(params.get("user_mobile"))
&& StrUtil.isNotBlank(params.get("user_is_admin"))
&& params.get("user_is_admin").equals(CommonConstant.USER_TYPE_MCH)) {
&& CommonConstant.USER_TYPE_MCH.equals(params.get("user_is_admin"))) {
// 商家版app显示申请入驻的状态
data.put("is_merch", 1);
data.put("is_merch", CommonConstant.Enable);
data.put("user_mobile", params.get("user_mobile"));
//入驻商家的审批状态1-已通过2-未通过3-待审核4-未申请
Map<String, Object> params2 = new HashMap<>();
params2.put("user_mobile", params.get("user_mobile"));
data.put("merch_approval_status", shopService.shopMerchEntryApprovalStatus(params2));
// Map<String, Object> params2 = new HashMap<>();
// params2.put("user_mobile", params.get("user_mobile"));
// data.put("merch_approval_status", shopService.shopMerchEntryApprovalStatus(params2));
}
String cid=params.get("cid");
if(StrUtil.isNotBlank(cid)){
String cid = params.get("cid");
if (StrUtil.isNotBlank(cid)) {
UserDeviceBind userDeviceBind = new UserDeviceBind();
userDeviceBind.setCid(params.get("cid"));
userDeviceBind.setOsType(params.get("os_type"));
@ -240,8 +240,8 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
public Map<String, Object> getUserInfo(Integer user_id) {
QueryWrapper<AccountUserBase> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id", user_id).select(AccountUserBase.class, info -> !info.getColumn().equals("user_password"));
AccountUserBase admin = getOne(queryWrapper);
setIdentityByUser(admin);
AccountUserBase accountUserBase = getOne(queryWrapper);
setIdentityByUser(accountUserBase);
AccountUserInfo userInfo = accountUserInfoService.get(user_id);
@ -250,7 +250,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
userInfo.setUser_avatar(user_no_avatar);
}
Map<String, Object> adminMap = BeanUtil.beanToMap(admin);
Map<String, Object> adminMap = BeanUtil.beanToMap(accountUserBase);
Map<String, Object> userInfoMap = BeanUtil.beanToMap(userInfo);
if (ObjectUtil.isNull(userInfo)) {
@ -2873,11 +2873,10 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
}
String iddCode = wxUserInfoReq.getCountryCode();
if (StrUtil.isNotBlank(iddCode)) {
iddCode = iddCode.startsWith("+") ? iddCode : ("+" + iddCode);
} else {
if (StrUtil.isBlank(iddCode) || !PhoneNumberUtils.isValidCountryCode(iddCode)) {
iddCode = CommonConstant.IDD_ZH_CN;
}
// 带国家编码的手机号
String mobile = PhoneNumberUtils.convWithIDDCodePhoneNumber(wxUserInfoReq.getPhoneNumber(), iddCode);
@ -2933,7 +2932,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
AccountUserInfo user_info_reg_row = new AccountUserInfo();
if (StrUtil.isNotBlank(mobile)) {
user_info_reg_row.setUser_mobile(mobile);
user_info_reg_row.setUser_mobile(PhoneNumberUtils.cleanPhoneNumber(mobile));
} else {
user_info_reg_row.setUser_mobile("");
}
@ -3112,8 +3111,8 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
params.put("password", "");
params.put("user_mobile", user_mobile);
params.put("is_merch", "1"); // 是否为商家入驻 1-其他-
params.put("cid",getParameter("cid"));
params.put("osType",getParameter("osType"));
params.put("cid", getParameter("cid"));
params.put("osType", getParameter("osType"));
return login(params);
}

View File

@ -8,123 +8,99 @@
package com.suisung.mall.common.utils;
import cn.hutool.core.util.StrUtil;
/**
* 中国银行相关工具类
*/
public class BankUtil {
public static void main(String[] args) {
String mainlandAccount = "6217680389311429";
String hongKongAccount = "00100212345678901";
String macauAccount = "0102123456789012";
String taiwanAccount = "00100021234567890";
System.out.println("内地账号是否有效: " + isValidZHCNBankAccount(mainlandAccount));
System.out.println("香港账号是否有效: " + isValidZHHKBankAccount(hongKongAccount));
System.out.println("澳门账号是否有效: " + isValidZHMOBankAccount(macauAccount));
System.out.println("台湾账号是否有效: " + isValidZHTWBankAccount(taiwanAccount));
/**
* 校验银行卡号是否有效支持中国国内及港澳台地区对公和对私
*
* @param cardNumber 银行卡号
* @param region 地区代码"CN"中国大陆"HK"香港"MO"澳门"TW"台湾
* @param isCorporate 是否为对公账户true表示对公false表示对私
* @return true表示银行卡号有效false表示无效
*/
public static boolean validateBankCard(String cardNumber, String region, boolean isCorporate) {
// 检查银行卡号是否为空或长度不符合要求
if (cardNumber == null || cardNumber.trim().isEmpty()) {
return false;
}
System.out.println("账号是否有效: " + isValidZHBankAccount(mainlandAccount));
// 去除空格和非数字字符
cardNumber = cardNumber.trim();
// 根据地区和账户类型进行校验
if (isCorporate) {
// 对公账户校验长度为12-20位数字
if (!cardNumber.matches("\\d{12,20}")) {
return false;
}
} else {
// 对私账户校验根据地区规则校验长度
switch (region.toUpperCase()) {
case "CN": // 中国大陆
if (!cardNumber.matches("\\d{16,19}")) {
return false;
}
break;
case "HK": // 香港
case "MO": // 澳门
if (!cardNumber.matches("\\d{15,19}")) {
return false;
}
break;
case "TW": // 台湾
if (!cardNumber.matches("\\d{16,19}")) {
return false;
}
break;
default:
return false; // 不支持的地区
}
}
// 对私账户需要进行Luhn算法校验对公账户跳过Luhn校验
return isCorporate || validateLuhn(cardNumber);
}
// 校验中国银行账号的 Luhn 算法
public static boolean isValidZHBankAccount(String accountNumber) {
if (StrUtil.isBlank(accountNumber)) {
return false;
}
if (isValidZHCNBankAccount(accountNumber)) {
return true;
}
if (isValidZHHKBankAccount(accountNumber)) {
return true;
}
if (isValidZHMOBankAccount(accountNumber)) {
return true;
}
return isValidZHTWBankAccount(accountNumber);
}
// 校验中国内地银行卡号的 Luhn 算法
public static boolean isValidZHCNBankAccount(String accountNumber) {
if (accountNumber == null || accountNumber.length() < 13 || accountNumber.length() > 19) {
return false;
}
try {
long number = Long.parseLong(accountNumber);
} catch (NumberFormatException e) {
return false;
}
/**
* 使用Luhn算法校验银行卡号
*
* @param cardNumber 银行卡号
* @return true表示通过Luhn校验false表示未通过
*/
private static boolean validateLuhn(String cardNumber) {
int sum = 0;
boolean alternate = false;
for (int i = accountNumber.length() - 1; i >= 0; i--) {
int n = Integer.parseInt(accountNumber.substring(i, i + 1));
// 从右到左处理每一位数字
for (int i = cardNumber.length() - 1; i >= 0; i--) {
int digit = Character.getNumericValue(cardNumber.charAt(i));
if (alternate) {
n *= 2;
if (n > 9) {
n = (n % 10) + 1;
digit *= 2;
if (digit > 9) {
digit -= 9;
}
}
sum += n;
sum += digit;
alternate = !alternate;
}
return (sum % 10 == 0);
// 如果总和能被10整除则通过校验
return sum % 10 == 0;
}
// 校验香港银行账号
public static boolean isValidZHHKBankAccount(String accountNumber) {
// 简单示例假设格式为 3 位银行代码 + 3 位分行代码 + 11 位账号
if (accountNumber == null || accountNumber.length() != 17) {
return false;
}
try {
// 检查是否为纯数字
Integer.parseInt(accountNumber.substring(0, 3));
Integer.parseInt(accountNumber.substring(3, 6));
Integer.parseInt(accountNumber.substring(6));
} catch (NumberFormatException e) {
return false;
}
return true;
}
public static void main(String[] args) {
// 测试对公账户
String corporateCard = "2116709509100106309"; // 示例对公银行卡号
System.out.println("对公账户校验结果: " + validateBankCard(corporateCard, "CN", true)); // true
// 校验澳门银行账号
public static boolean isValidZHMOBankAccount(String accountNumber) {
// 简单示例假设格式为 2 位银行代码 + 2 位分行代码 + 12 位账号
if (accountNumber == null || accountNumber.length() != 16) {
return false;
}
try {
// 检查是否为纯数字
Integer.parseInt(accountNumber.substring(0, 2));
Integer.parseInt(accountNumber.substring(2, 4));
Integer.parseInt(accountNumber.substring(4));
} catch (NumberFormatException e) {
return false;
}
return true;
// 测试对私账户
String personalCard = "6222021234567890128"; // 示例对私银行卡号
System.out.println("对私账户校验结果: " + validateBankCard(personalCard, "CN", false)); // true
}
// 校验台湾银行账号
public static boolean isValidZHTWBankAccount(String accountNumber) {
// 简单示例假设格式为 3 位银行代码 + 4 位分行代码 + 10 位账号
if (accountNumber == null || accountNumber.length() != 17) {
return false;
}
try {
// 检查是否为纯数字
Integer.parseInt(accountNumber.substring(0, 3));
Integer.parseInt(accountNumber.substring(3, 7));
Integer.parseInt(accountNumber.substring(7));
} catch (NumberFormatException e) {
return false;
}
return true;
}
}

View File

@ -31,6 +31,7 @@ import com.suisung.mall.shop.order.service.ShopOrderInfoService;
import com.suisung.mall.shop.sfexpress.service.SFExpressApiService;
import com.suisung.mall.shop.store.service.ShopStoreSameCityTransportBaseService;
import com.suisung.mall.shop.store.service.ShopStoreSfOrderService;
import com.suisung.mall.shop.wechat.service.WxOrderShippingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -70,6 +71,10 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
@Autowired
private ShopStoreSameCityTransportBaseService shopStoreSameCityTransportBaseService;
@Lazy
@Autowired
private WxOrderShippingService wxOrderShippingService;
@Override
public ThirdApiRes createOrder(String shopOrderId) {
// 组织请求参数
@ -209,6 +214,9 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
// 商城订单状态2020-待配货/待出库审核
shopOrderInfoService.changeOrderStatus(shopOrderId, StateCode.ORDER_STATE_PICKING, 0, 0);
// 上传发货信息到微信
wxOrderShippingService.uploadShippingInfoToWx(2, shopOrderId);
return Pair.of(true, "顺丰同城下单成功!");
}
@ -606,6 +614,10 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
orderStatus = StateCode.ORDER_STATE_SHIPPED;
orderIsOutStatus = 0;
orderIsShippedStatus = StateCode.ORDER_SHIPPED_STATE_YES; // 已发货
} else if (shopStoreSfOrder.getOrder_status().equals(StateCode.SF_ORDER_STATUS_FINISH)) {
// 顺丰同城状态17-配送员妥投完单;
// 通知微信用户确认收货
wxOrderShippingService.notifyConfirmReceive(shopStoreSfOrder.getShop_order_id());
}
success = shopOrderInfoService.changeOrderStatus(shopStoreSfOrder.getShop_order_id(), orderStatus, orderIsOutStatus, orderIsShippedStatus);

View File

@ -172,8 +172,11 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
return CommonResult.failed(isApplied.getSecond());
}
Boolean isQy = true;
// 检查企业法人或个人的营业执照或身份证
if (ObjectUtil.isNotEmpty(record.getEntity_type()) && record.getEntity_type().equals(CommonConstant.MCH_ENTITY_TYPE_GR)) {
isQy = false; // 个人入驻
// 个人
if (StrUtil.isBlank(record.getIndividual_id_number())
|| StrUtil.isBlank(record.getIndividual_id_name())
@ -231,7 +234,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
return CommonResult.failed("缺少银行账号信息!");
}
if (!BankUtil.isValidZHBankAccount(record.getAccount_number())) {
if (!BankUtil.validateBankCard(record.getAccount_number(), "CN", isQy)) {
return CommonResult.failed("银行卡号格式有误!");
}
@ -242,7 +245,6 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
// 对公对私结算账户清算号和结算账户开户号一定一致
record.setClearing_bank_code(record.getOpenning_bank_code());
if (StrUtil.isNotBlank(record.getStore_name()) && shopStoreBaseService.isExistsByStoreName(record.getStore_name())) {
return CommonResult.failed("店铺名已被使用!");
}
@ -317,13 +319,16 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
return CommonResult.failed("参数转换失败,请联系管理员!");
}
Boolean isQy = true;
// 检查企业法人或个人的营业执照或身份证
if (ObjectUtil.isNotEmpty(record.getEntity_type()) && record.getEntity_type().equals(2)) {
if (ObjectUtil.isNotEmpty(oldRecord.getEntity_type()) && oldRecord.getEntity_type().equals(2)) {
// 个人
// if (StrUtil.isBlank(record.getIndividual_id_number()) || StrUtil.isBlank(record.getIndividual_id_images()) || StrUtil.isBlank(record.getIndividual_id_images2())) {
// return CommonResult.failed("缺少个人身份证信息!");
// }
isQy = false; // 个人入驻
if (StrUtil.isNotBlank(record.getIndividual_id_number()) && !StringUtils.validateIDCard(record.getIndividual_id_number())) {
return CommonResult.failed("个人身份证号码有误!");
}
@ -360,7 +365,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
// return CommonResult.failed("缺少银行账号信息!");
// }
if (StrUtil.isNotBlank(record.getAccount_number()) && !BankUtil.isValidZHBankAccount(record.getAccount_number())) {
if (StrUtil.isNotBlank(record.getAccount_number()) && !BankUtil.validateBankCard(record.getAccount_number(), "CN", isQy)) {
return CommonResult.failed("银行卡号格式有误!");
}