修改创建顺丰店铺,获取县级市的代码。
This commit is contained in:
parent
706c6f0c8b
commit
23f2e8a7e2
@ -40,7 +40,7 @@ public class ShopStoreSameCityTransport implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "运费自增ID")
|
||||
@TableId(value = "transport_id", type = IdType.INPUT)
|
||||
@TableId(value = "transport_id", type = IdType.AUTO)
|
||||
private Long transport_id;
|
||||
|
||||
@ApiModelProperty(value = "基础运费自增ID")
|
||||
|
||||
@ -40,7 +40,7 @@ public class ShopStoreSameCityTransportBase implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "基础运费自增ID")
|
||||
@TableId(value = "transport_base_id", type = IdType.INPUT)
|
||||
@TableId(value = "transport_base_id", type = IdType.AUTO)
|
||||
private Long transport_base_id;
|
||||
|
||||
@ApiModelProperty(value = "店铺ID")
|
||||
|
||||
@ -105,7 +105,7 @@ public class LakalaController extends BaseControllerImpl {
|
||||
|
||||
// return shopOrderBaseService.sameCityOrderExpireSeconds(10000L);
|
||||
|
||||
return sfExpressApiService.createSfExpressShop(58, "桂平能辉超市", "桂平市", "广西壮族自治区贵港市桂平市中山南路凤凰商业中心19-3号", "谢能坤", "17777525395", "110.08105", "23.39339");
|
||||
return sfExpressApiService.createSfExpressShop(66, "能辉超市", "桂平市", "广西壮族自治区贵港市桂平市广佰汇超市(桂平店)", "谢能坤", "17777525395", "110.07165452271", "23.369069486251");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -434,20 +434,23 @@ public class LakalaUtil {
|
||||
|
||||
return decodedDataStr;
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.error("Base64解码失败: {}", e.getMessage(), e);
|
||||
log.error("Base64解码失败: {}", e.getMessage());
|
||||
return null;
|
||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
|
||||
log.error("RSA算法初始化失败: {}", e.getMessage(), e);
|
||||
log.error("RSA算法初始化失败: {}", e.getMessage());
|
||||
return null;
|
||||
} catch (InvalidKeySpecException | InvalidKeyException e) {
|
||||
log.error("私钥格式或类型错误: {}", e.getMessage(), e);
|
||||
log.error("私钥格式或类型错误: {}", e.getMessage());
|
||||
return null;
|
||||
} catch (BadPaddingException | IllegalBlockSizeException e) {
|
||||
log.error("解密数据块大小或填充错误: {}", e.getMessage(), e);
|
||||
log.error("解密数据块大小或填充错误: {}", e.getMessage());
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
log.error("解密过程中出现未知异常: {}", e.getMessage(), e);
|
||||
log.error("解密过程中出现未知异常: {}", e.getMessage());
|
||||
return null;
|
||||
} finally {
|
||||
closeQuietly(out);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -126,14 +126,15 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
|
||||
if (transportBase == null) {
|
||||
// 如果没有商家配送运费设置,则初始化
|
||||
Pair<Boolean, String> initResult = shopStoreSameCityTransportBaseService.initDefaultSameCityTransport(storeId);
|
||||
if (!initResult.getFirst()) {
|
||||
logger.error("初始化商家配送运费设置失败:{}", initResult.getSecond());
|
||||
return initResult;
|
||||
}
|
||||
shopStoreSameCityTransportBaseService.initDefaultSameCityTransport(storeId);
|
||||
transportBase = shopStoreSameCityTransportBaseService.getShopStoreSameCityTransportBaseById(Long.valueOf(storeId));
|
||||
}
|
||||
|
||||
if (transportBase == null) {
|
||||
logger.error("创建商家配送信息失败!");
|
||||
return Pair.of(false, "创建商家配送信息失败");
|
||||
}
|
||||
|
||||
// 3. 如果已存在顺丰店铺ID,验证其有效性
|
||||
if (CheckUtil.isNotEmpty(transportBase.getShop_id())) {
|
||||
logger.debug("如果存在店铺Id,从顺丰同城平台查询店铺ID,开始验证其有效性!");
|
||||
@ -163,11 +164,13 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
params.put("shop_contact_name", contactName); // 联系人姓名
|
||||
params.put("shop_contact_phone", contactPhone); // 联系电话
|
||||
|
||||
logger.debug("开始创建顺丰店铺,参数:{}", params);
|
||||
|
||||
// 5. 发送请求到顺丰接口
|
||||
String paramJSON = JsonUtil.toJSONString(params);
|
||||
String sendUrl = buildUrl("createShop", paramJSON);
|
||||
String responseStr = HttpUtil.post(sendUrl, paramJSON);
|
||||
|
||||
logger.debug("创建顺丰店铺结果:{}", responseStr);
|
||||
if (StrUtil.isBlank(responseStr)) {
|
||||
logger.error("创建顺丰店铺异常,无返回值!");
|
||||
return Pair.of(false, "创建顺丰店铺异常,无返回值!");
|
||||
|
||||
@ -729,17 +729,17 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getStoreList(Integer page, Integer rows,Map<String,Object> paramsMap) {
|
||||
public Map getStoreList(Integer page, Integer rows, Map<String, Object> paramsMap) {
|
||||
|
||||
Map<String, Object> data;
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
|
||||
Integer store_id = getParameter("store_id", Integer.class);
|
||||
Integer store_category_id = getParameter("store_category_id", Integer.class);
|
||||
boolean findStore= MapUtils.getBoolean(paramsMap, "findStore", false);
|
||||
if(ObjectUtil.isNull(store_category_id)){
|
||||
if(null!=paramsMap.get("store_category_id")){
|
||||
store_category_id=MapUtils.getInteger(paramsMap,"store_category_id");
|
||||
boolean findStore = MapUtils.getBoolean(paramsMap, "findStore", false);
|
||||
if (ObjectUtil.isNull(store_category_id)) {
|
||||
if (null != paramsMap.get("store_category_id")) {
|
||||
store_category_id = MapUtils.getInteger(paramsMap, "store_category_id");
|
||||
}
|
||||
}
|
||||
Long distance = getParameter("distance", Long.class);
|
||||
@ -761,9 +761,9 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
|
||||
UserDto user = ContextUtil.getCurrentUser();
|
||||
if (store_type == null) {
|
||||
if(null!=paramsMap.get("store_type")){
|
||||
store_type=MapUtils.getInteger(paramsMap,"store_type");
|
||||
}else {
|
||||
if (null != paramsMap.get("store_type")) {
|
||||
store_type = MapUtils.getInteger(paramsMap, "store_type");
|
||||
} else {
|
||||
store_type = user != null && user.isStore() && shopStoreBaseService.ifSupplierMarket() ? 2 : 1;
|
||||
}
|
||||
}
|
||||
@ -784,14 +784,14 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
QueryWrapper<ShopBaseStoreCategory> storeCategoryQueryWrapper = new QueryWrapper<>();
|
||||
storeCategoryQueryWrapper.eq("store_category_parent_id", store_category_id);
|
||||
storeCategoryQueryWrapper.select("store_category_id");
|
||||
List<ShopBaseStoreCategory> shopBaseStoreCategories= shopBaseStoreCategoryService.list(storeCategoryQueryWrapper);
|
||||
List<ShopBaseStoreCategory> shopBaseStoreCategories = shopBaseStoreCategoryService.list(storeCategoryQueryWrapper);
|
||||
store_category_ids.add(store_category_id);
|
||||
for (ShopBaseStoreCategory storeCategory:shopBaseStoreCategories) {
|
||||
for (ShopBaseStoreCategory storeCategory : shopBaseStoreCategories) {
|
||||
store_category_ids.add(storeCategory.getStore_category_id());
|
||||
}
|
||||
if(store_category_ids.size()>1){
|
||||
if (store_category_ids.size() > 1) {
|
||||
queryWrapper.in("store_category_id", store_category_ids);
|
||||
}else {
|
||||
} else {
|
||||
queryWrapper.eq("store_category_id", store_category_id);
|
||||
}
|
||||
params.put("store_category_id", store_category_id);
|
||||
@ -901,7 +901,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
data = shopStoreBaseService.getLists(queryWrapper, page, rows);
|
||||
}
|
||||
//start只查询店铺
|
||||
if(findStore){
|
||||
if (findStore) {
|
||||
return data;
|
||||
}
|
||||
//end 只查询店铺
|
||||
@ -3321,7 +3321,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
|
||||
// 立即创建顺丰店铺,附带初始化同城配送默认设置
|
||||
String[] areaNames = StrUtil.isNotBlank(shopStoreBase.getStore_area()) ? shopStoreBase.getStore_area().split("/") : new String[0];
|
||||
String cityName = areaNames.length >= 2 ? areaNames[1] : shopStoreBase.getStore_area().replace("/", "");
|
||||
String cityName = areaNames.length > 0 ? areaNames[areaNames.length - 1] : shopStoreBase.getStore_area().replace("/", "");
|
||||
sfExpressApiService.createSfExpressShop(storeId, shopStoreBase.getStore_name(), cityName, shopStoreBase.getStore_address(), shopMchEntry.getContact_name(), contact_mobile, shopStoreBase.getStore_longitude(), shopStoreBase.getStore_longitude());
|
||||
|
||||
return Pair.of(storeId, "新增成功");
|
||||
@ -3473,6 +3473,8 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
// 添加店铺到用户
|
||||
AccountUserBase accountUserBase = new AccountUserBase();
|
||||
List<Integer> rights_group_id = shopStoreEmployeeRightsGroups.stream().map(s -> s.getRights_group_id()).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(rights_group_id)) {
|
||||
// 初始化雇员信息
|
||||
@ -3481,22 +3483,21 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
.set("rights_group_id", CollUtil.join(rights_group_id, ","))
|
||||
.set("employee_is_admin", CommonConstant.USER_TYPE_ADMIN);
|
||||
if (!shopStoreEmployeeService.update(queryWrapper)) {
|
||||
throw new ApiException(I18nUtil._("设置店铺管理员权限失败"));
|
||||
// throw new ApiException(I18nUtil._("设置店铺管理员权限失败"));
|
||||
log.error("设置店铺管理员权限失败!");
|
||||
}
|
||||
|
||||
// 添加店铺到用户
|
||||
AccountUserBase accountUserBase = new AccountUserBase();
|
||||
accountUserBase.setUser_id(userId);
|
||||
String storeIds = appendStoreIdToAccount(userId, storeId);
|
||||
accountUserBase.setStore_ids(storeIds);
|
||||
|
||||
|
||||
// todo 初始化商家角色(默认 店铺管理员角色)
|
||||
String user_rights_group_id = Convert.toStr(rights_group_id.get(0));
|
||||
accountUserBase.setRights_group_id(StrUtil.join(",", user_rights_group_id, 2));
|
||||
if (!accountService.saveOrUpdateUserBase(accountUserBase)) {
|
||||
throw new ApiException(I18nUtil._("店铺关联到用户失败"));
|
||||
}
|
||||
}
|
||||
|
||||
// 用法人、小微个人的手机号注册商家账号,作为店铺的管理员
|
||||
accountUserBase.setUser_id(userId);
|
||||
String storeIds = appendStoreIdToAccount(userId, storeId);
|
||||
accountUserBase.setStore_ids(storeIds); // 重要,给用户添加上这个店铺的归属权
|
||||
if (!accountService.saveOrUpdateUserBase(accountUserBase)) {
|
||||
throw new ApiException(I18nUtil._("店铺关联到用户失败"));
|
||||
}
|
||||
|
||||
// 添加默认运输模板
|
||||
@ -3905,19 +3906,23 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
AccountUserBase accountUserBase = accountService.getUserBase(userId);
|
||||
|
||||
// 用户不存在或没有店铺时返回空
|
||||
if (accountUserBase == null || StrUtil.isBlank(accountUserBase.getStore_ids())) {
|
||||
if (accountUserBase == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 标准化格式:确保末尾有逗号
|
||||
List<String> idList = new ArrayList<>();
|
||||
String storeIds = accountUserBase.getStore_ids();
|
||||
if (!storeIds.endsWith(",")) {
|
||||
storeIds += ",";
|
||||
if (StrUtil.isBlank(storeIds)) {
|
||||
idList.add(storeId.toString());
|
||||
} else {
|
||||
idList = StrUtil.split(storeIds, ",");
|
||||
if (!idList.contains(storeId.toString())) {
|
||||
// 追加新店铺ID
|
||||
idList.add(storeId.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// 追加新店铺ID
|
||||
return storeIds + storeId;
|
||||
|
||||
return StrUtil.join(",", CollUtil.distinct(idList));
|
||||
} catch (Exception e) {
|
||||
log.error("追加店铺ID到用户失败,userId: {}, storeId: {}", userId, storeId, e);
|
||||
return "";
|
||||
|
||||
@ -332,8 +332,17 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
if (exist == null) {
|
||||
// 新增
|
||||
transportBase.setCreated_by(transportBase.getUpdated_by());
|
||||
if (save(transportBase)) {
|
||||
return Pair.of(transportBase.getTransport_base_id(), "添加成功!");
|
||||
if (add(transportBase)) {
|
||||
// 确保获取到ID
|
||||
Long transportBaseId = transportBase.getTransport_base_id();
|
||||
if (transportBaseId == null || transportBaseId <= 0) {
|
||||
// 补偿机制:若transportBase.getTransport_base_id()==null,重新查询数据
|
||||
exist = getOne(queryWrapper);
|
||||
if (exist != null) {
|
||||
transportBaseId = exist.getTransport_base_id();
|
||||
}
|
||||
}
|
||||
return Pair.of(transportBaseId, "添加成功!");
|
||||
} else {
|
||||
return Pair.of(0L, "添加失败!");
|
||||
}
|
||||
@ -406,7 +415,7 @@ public class ShopStoreSameCityTransportBaseServiceImpl extends BaseServiceImpl<S
|
||||
Pair<Long, String> saveOrUpdateResult = saveOrUpdateShopStoreSameCityTransportBase(transportBase);
|
||||
Long transportBaseId = saveOrUpdateResult.getFirst();
|
||||
if (transportBaseId == null || transportBaseId <= 0) {
|
||||
log.error("初始化店铺默认配置:新增同城配送基础设置失败!");
|
||||
log.error("初始化店铺默认配置:新增同城配送基础设置失败!transportBaseId:{}", transportBaseId);
|
||||
return Pair.of(false, saveOrUpdateResult.getSecond());
|
||||
}
|
||||
|
||||
|
||||
@ -116,7 +116,6 @@ public class ShopStoreSameCityTransportServiceImpl extends BaseServiceImpl<ShopS
|
||||
|
||||
if (CheckUtil.isEmpty(transport.getMax_delivery_radius())) {
|
||||
logger.error("缺少配送范围,忽略保存!");
|
||||
// continue;
|
||||
transport.setMax_delivery_radius(5000); //配送范围半径(米)
|
||||
}
|
||||
|
||||
@ -133,13 +132,9 @@ public class ShopStoreSameCityTransportServiceImpl extends BaseServiceImpl<ShopS
|
||||
|
||||
// 新增或更新
|
||||
if (CheckUtil.isEmpty(transport.getTransport_id())) {
|
||||
if (save(transport)) {
|
||||
count++;
|
||||
}
|
||||
if (save(transport)) count++;
|
||||
} else {
|
||||
if (updateShopStoreSameCityTransport(transport)) {
|
||||
count++;
|
||||
}
|
||||
if (updateShopStoreSameCityTransport(transport)) count++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("处理单条运费配置信息失败: ", e);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user