优化代码
This commit is contained in:
parent
45d4d9905d
commit
916ff8fe5c
@ -781,7 +781,6 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
* @param base_row shopOrderBase
|
* @param base_row shopOrderBase
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// todo 优化代码逻辑
|
|
||||||
public Map getOrderDetail(String order_id, Map base_row) {
|
public Map getOrderDetail(String order_id, Map base_row) {
|
||||||
|
|
||||||
List<String> order_ids = Convert.toList(String.class, order_id);
|
List<String> order_ids = Convert.toList(String.class, order_id);
|
||||||
@ -801,10 +800,8 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
ShopOrderData shopOrderData = shopOrderDataService.get(order_id);
|
ShopOrderData shopOrderData = shopOrderDataService.get(order_id);
|
||||||
Map order_data = Convert.toMap(String.class, Object.class, shopOrderData);
|
Map order_data = Convert.toMap(String.class, Object.class, shopOrderData);
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(order_info)) base_row.putAll(order_info);
|
|
||||||
if (CollUtil.isNotEmpty(order_data)) base_row.putAll(order_data);
|
|
||||||
|
|
||||||
// update 2025-09-10 增加KLK支付信息
|
// update 2025-09-10 增加KLK支付信息,前端确认收货用途
|
||||||
ShopOrderLkl shopOrderLkl = shopOrderLklService.getByStoreIdAndOrderId(shopOrderInfo.getStore_id(), order_id);
|
ShopOrderLkl shopOrderLkl = shopOrderLklService.getByStoreIdAndOrderId(shopOrderInfo.getStore_id(), order_id);
|
||||||
if (shopOrderLkl != null) {
|
if (shopOrderLkl != null) {
|
||||||
base_row.put("lkl_merchant_no", shopOrderLkl.getLkl_merchant_no());
|
base_row.put("lkl_merchant_no", shopOrderLkl.getLkl_merchant_no());
|
||||||
@ -1000,6 +997,10 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
Map store_info_row = Convert.toMap(String.class, Object.class, shopStoreInfoService.get(store_id));
|
Map store_info_row = Convert.toMap(String.class, Object.class, shopStoreInfoService.get(store_id));
|
||||||
if (CollUtil.isNotEmpty(store_info_row)) base_row.putAll(store_info_row);
|
if (CollUtil.isNotEmpty(store_info_row)) base_row.putAll(store_info_row);
|
||||||
|
|
||||||
|
// 这里转换订单的map数据,防止店铺的数据(打包费等字段)被覆盖
|
||||||
|
if (CollUtil.isNotEmpty(order_info)) base_row.putAll(order_info);
|
||||||
|
if (CollUtil.isNotEmpty(order_data)) base_row.putAll(order_data);
|
||||||
|
|
||||||
ShopStoreInfo shopStoreInfo = shopStoreInfoService.get(store_id);
|
ShopStoreInfo shopStoreInfo = shopStoreInfoService.get(store_id);
|
||||||
String store_opening_hours = shopStoreInfo.getStore_opening_hours();
|
String store_opening_hours = shopStoreInfo.getStore_opening_hours();
|
||||||
String store_close_hours = shopStoreInfo.getStore_close_hours();
|
String store_close_hours = shopStoreInfo.getStore_close_hours();
|
||||||
@ -1119,7 +1120,9 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
base_row.put("delivery_time_name", delivery_time == null || index != -1 ? I18nUtil._("正常配送") : delivery_time_name);
|
base_row.put("delivery_time_name", delivery_time == null || index != -1 ? I18nUtil._("正常配送") : delivery_time_name);
|
||||||
|
|
||||||
// 顺丰同城的订单信息
|
// 顺丰同城的订单信息
|
||||||
if (!is_virtual && base_row.get("delivery_type_id") != null && Convert.toInt(base_row.get("delivery_type_id")).equals(StateCode.DELIVERY_TYPE_SAME_CITY)) {
|
if (!is_virtual
|
||||||
|
&& base_row.get("delivery_type_id") != null
|
||||||
|
&& Convert.toInt(base_row.get("delivery_type_id")).equals(StateCode.DELIVERY_TYPE_SAME_CITY)) {
|
||||||
// 非虚拟商品,如果是顺丰同城配送的,返回顺丰的订单Id
|
// 非虚拟商品,如果是顺丰同城配送的,返回顺丰的订单Id
|
||||||
ShopStoreSfOrder shopStoreSfOrder = shopStoreSfOrderService.getByShopOrderId(order_id);
|
ShopStoreSfOrder shopStoreSfOrder = shopStoreSfOrderService.getByShopOrderId(order_id);
|
||||||
if (shopStoreSfOrder != null) {
|
if (shopStoreSfOrder != null) {
|
||||||
@ -6605,7 +6608,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 店铺统一设置的打包费(formatCartRows 方法里计算好的)
|
// 店铺统一设置的打包费(formatCartRows 方法里计算好的)
|
||||||
BigDecimal packingFee = Convert.toBigDecimal(store_item.get("packing_fee"));
|
BigDecimal packingFee = Convert.toBigDecimal(store_item.get("packing_fee"), BigDecimal.ZERO);
|
||||||
|
|
||||||
// 打包费
|
// 打包费
|
||||||
base_row.put("packing_fee", packingFee);
|
base_row.put("packing_fee", packingFee);
|
||||||
|
|||||||
@ -105,38 +105,41 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateByReviewRelatedId(String reviewRelatedId, Integer status, String notifyResp) {
|
public Boolean updateByReviewRelatedId(String reviewRelatedId, Integer status, String notifyResp) {
|
||||||
|
if (StrUtil.isBlank(reviewRelatedId)) {
|
||||||
|
log.warn("审核关联号不能为空,无法执行更新操作");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 参数校验
|
|
||||||
if (StrUtil.isBlank(reviewRelatedId)) {
|
|
||||||
log.warn("审核关联号不能为空,无法执行更新操作");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
LambdaUpdateWrapper<ShopMchEntryBranch> updateWrapper = new LambdaUpdateWrapper<>();
|
LambdaUpdateWrapper<ShopMchEntryBranch> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
updateWrapper.eq(ShopMchEntryBranch::getReview_related_id, reviewRelatedId).set(ShopMchEntryBranch::getUpdated_at, new Date());
|
updateWrapper.eq(ShopMchEntryBranch::getReview_related_id, reviewRelatedId)
|
||||||
|
.set(ShopMchEntryBranch::getUpdated_at, new Date());
|
||||||
|
|
||||||
// 只有当状态值有效时才更新状态字段
|
// 更新状态字段
|
||||||
if (CheckUtil.isNotEmpty(status)) {
|
if (CheckUtil.isNotEmpty(status)) {
|
||||||
updateWrapper.set(ShopMchEntryBranch::getStatus, status);
|
updateWrapper.set(ShopMchEntryBranch::getStatus, status);
|
||||||
log.debug("更新状态字段为: {}", status);
|
log.debug("更新状态字段为: {}", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新通知响应内容
|
// 更新通知响应内容和终端号
|
||||||
if (StrUtil.isNotBlank(notifyResp)) { // 允许空字符串,但不能为null
|
if (StrUtil.isNotBlank(notifyResp)) {
|
||||||
updateWrapper.set(ShopMchEntryBranch::getLkl_notify_reps, notifyResp);
|
updateWrapper.set(ShopMchEntryBranch::getLkl_notify_reps, notifyResp);
|
||||||
|
//
|
||||||
|
// JSONObject notifyRespJson = JSONUtil.parseObj(notifyResp);
|
||||||
|
// String termNo = notifyRespJson.getStr("termNo", "");
|
||||||
|
// if (StrUtil.isNotBlank(termNo)) {
|
||||||
|
// updateWrapper.set(ShopMchEntryBranch::getLkl_term_no, termNo);
|
||||||
|
// log.debug("更新商户终端编号字段为: {}", termNo);
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean result = update(updateWrapper);
|
boolean result = update(updateWrapper);
|
||||||
|
log.info("{}更新分店入驻申请记录,审核关联号: {}", result ? "成功" : "失败", reviewRelatedId);
|
||||||
if (result) {
|
|
||||||
log.info("成功更新分店入驻申请记录,审核关联号: {}", reviewRelatedId);
|
|
||||||
} else {
|
|
||||||
log.warn("更新分店入驻申请记录失败,审核关联号: {}", reviewRelatedId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("更新分店入驻申请记录时发生异常,审核关联号: {}", reviewRelatedId, e);
|
log.warn("解析通知响应数据失败,无法提取终端号: {}", e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,7 +243,7 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CommonConstant.Enable.equals(status)) {
|
if (CommonConstant.Enable.equals(status)) {
|
||||||
return Pair.of(false, "手机号已被其他商家注册");
|
return Pair.of(false, "手机已注册过商家账号,请换另一个手机号");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 检查分店终端号是否已经申请或申请中
|
// 5. 检查分店终端号是否已经申请或申请中
|
||||||
@ -307,7 +310,16 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
|||||||
shopMchEntryBranch.setLkl_term_no(termNo);
|
shopMchEntryBranch.setLkl_term_no(termNo);
|
||||||
shopMchEntryBranch.setStatus(CommonConstant.Enable);
|
shopMchEntryBranch.setStatus(CommonConstant.Enable);
|
||||||
shopMchEntryBranch.setLkl_notify_reps(lklNotifyResp);
|
shopMchEntryBranch.setLkl_notify_reps(lklNotifyResp);
|
||||||
if (!updateById(shopMchEntryBranch)) {
|
|
||||||
|
// 使用 LambdaUpdateWrapper 确保只更新指定字段
|
||||||
|
LambdaUpdateWrapper<ShopMchEntryBranch> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(ShopMchEntryBranch::getReview_related_id, reviewRelatedId)
|
||||||
|
.set(ShopMchEntryBranch::getLkl_term_no, termNo)
|
||||||
|
.set(ShopMchEntryBranch::getStatus, CommonConstant.Enable)
|
||||||
|
.set(ShopMchEntryBranch::getLkl_notify_reps, lklNotifyResp)
|
||||||
|
.set(ShopMchEntryBranch::getUpdated_at, new Date());
|
||||||
|
|
||||||
|
if (!update(updateWrapper)) {
|
||||||
throw new ApiException("更新分店入驻申请记录失败");
|
throw new ApiException("更新分店入驻申请记录失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -923,7 +923,6 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 8. 检查店铺关联关系
|
// 8. 检查店铺关联关系
|
||||||
boolean hasStoreRelation = false;
|
boolean hasStoreRelation = false;
|
||||||
if (StrUtil.isNotBlank(shopMchEntry.getStore_id()) && StrUtil.isNotBlank(userBase.getStore_ids())) {
|
if (StrUtil.isNotBlank(shopMchEntry.getStore_id()) && StrUtil.isNotBlank(userBase.getStore_ids())) {
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import cn.hutool.json.JSONArray;
|
import cn.hutool.json.JSONArray;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@ -4293,15 +4294,12 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
|||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryWrapper<ShopStoreBase> queryWrapper = new QueryWrapper<>();
|
LambdaQueryWrapper<ShopStoreBase> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq("store_id", storeId).select("packing_fee");
|
queryWrapper.select(ShopStoreBase::getPacking_fee)
|
||||||
|
.eq(ShopStoreBase::getStore_id, storeId);
|
||||||
|
|
||||||
ShopStoreBase shopStoreBase = shopStoreBaseService.findOne(queryWrapper);
|
ShopStoreBase shopStoreBase = shopStoreBaseService.findOne(queryWrapper);
|
||||||
if (shopStoreBase != null) {
|
return ObjectUtil.isEmpty(shopStoreBase) ? BigDecimal.ZERO : shopStoreBase.getPacking_fee();
|
||||||
return shopStoreBase.getPacking_fee();
|
|
||||||
}
|
|
||||||
|
|
||||||
return BigDecimal.ZERO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -3157,7 +3157,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
|
|||||||
BigDecimal packingFee = shopStoreBaseService.getStorePackingFee(storeId);
|
BigDecimal packingFee = shopStoreBaseService.getStorePackingFee(storeId);
|
||||||
|
|
||||||
// 如果打包费为空或小于等于0,直接返回0
|
// 如果打包费为空或小于等于0,直接返回0
|
||||||
if (packingFee == null || packingFee.compareTo(BigDecimal.ZERO) <= 0) {
|
if (CheckUtil.isEmpty(packingFee)) {
|
||||||
logger.debug("店铺ID为{},打包费为{}元,不收取打包费", storeId, packingFee);
|
logger.debug("店铺ID为{},打包费为{}元,不收取打包费", storeId, packingFee);
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user