fix 顺丰下单 bug

This commit is contained in:
Jack 2025-07-07 00:54:33 +08:00
parent d7793cc24f
commit 1e181a7638
13 changed files with 592 additions and 576 deletions

View File

@ -2,77 +2,72 @@ package com.suisung.mall.common.exception;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.api.IErrorCode;
import com.suisung.mall.common.api.ResultCode; import com.suisung.mall.common.api.ResultCode;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;
/** /**
* 全局异常处理 * 全局异常处理器
*
* <p>主要功能
* <ul>
* <li>统一处理系统未捕获异常</li>
* <li>特殊处理数据库相关异常</li>
* <li>规范化业务异常响应格式</li>
* </ul>
*/ */
@RestControllerAdvice @RestControllerAdvice
public class GlobalExceptionHandler { public class GlobalExceptionHandler {
private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
private static final String UNKNOWN_LOCATION = "未知位置";
private static final String DB_ERROR_MSG = "数据库操作失败,请稍后重试";
private static final String LOG_FORMAT = "业务异常 || URI={} || Method={} || Error={} || Location={}";
private final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class); /**
* 获取异常发生位置信息
@ExceptionHandler(value = Exception.class) *
public CommonResult exceptionHandler(HttpServletRequest req, Exception e) { * @param stackTrace 异常堆栈
// 获取异常的第一帧堆栈信息 * @return 格式化的位置信息(类名.方法名 : 行号)
StackTraceElement[] stackTrace = e.getStackTrace(); */
String location = "未知位置"; private String getExceptionLocation(StackTraceElement[] stackTrace) {
if (stackTrace == null || stackTrace.length == 0) {
if (stackTrace.length > 0) { return UNKNOWN_LOCATION;
StackTraceElement element = stackTrace[0]; // 第一个异常抛出点 }
String className = element.getClassName(); StackTraceElement first = stackTrace[0];
String methodName = element.getMethodName(); return String.format("%s.%s:%d", first.getClassName(), first.getMethodName(), first.getLineNumber());
int lineNumber = element.getLineNumber();
location = String.format("%s.%s (line: %d)", className, methodName, lineNumber);
} }
logger.error("Exception全局异常捕获 URI: {} - Method: {} - Error: {} at {}", /**
req.getRequestURI(), * 处理系统级异常(数据库异常/通用异常)
req.getMethod(), */
e.getMessage(), @ExceptionHandler({SQLException.class, DataAccessException.class, Exception.class})
location, public CommonResult handleSystemException(HttpServletRequest req, Exception e) {
e); String location = getExceptionLocation(e.getStackTrace());
logger.error(LOG_FORMAT, req.getRequestURI(), req.getMethod(), e.getMessage(), location, e);
if (e instanceof SQLException || e instanceof DataAccessException) {
return CommonResult.failed(DB_ERROR_MSG);
}
return CommonResult.failed(e.getMessage()); return CommonResult.failed(e.getMessage());
} }
@ExceptionHandler(value = ApiException.class) /**
public CommonResult exceptionHandler(HttpServletRequest req, ApiException e) { * 处理业务API异常
// 获取异常位置信息 */
StackTraceElement[] stackTrace = e.getStackTrace(); @ExceptionHandler(ApiException.class)
String location = "未知错误位置"; public CommonResult handleApiException(HttpServletRequest req, ApiException e) {
String location = getExceptionLocation(e.getStackTrace());
logger.error(LOG_FORMAT,
req.getRequestURI(), req.getMethod(), e.getErrorCode(), location, e);
IErrorCode errorCode = e.getErrorCode(); return StrUtil.isNotBlank(e.getMessage())
String message = e.getMessage(); ? CommonResult.failed(e.getMessage())
: CommonResult.failed(ResultCode.FAILED);
if (stackTrace.length > 0) {
StackTraceElement element = stackTrace[0]; // 第一个异常抛出点
location = String.format("%s.%s (line: %d)",
element.getClassName(),
element.getMethodName(),
element.getLineNumber()
);
}
logger.error("Exception全局异常捕获 URI:{} - Method:{} - Error:{} at {}",
req.getRequestURI(),
req.getMethod(),
message,
location,
e);
if (StrUtil.isNotBlank(message)) {
return CommonResult.failed(message);
} else {
return CommonResult.failed(ResultCode.FAILED);
}
} }
} }

View File

@ -9,13 +9,19 @@
package com.suisung.mall.shop.config; package com.suisung.mall.shop.config;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer; import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
@Configuration
public class AsyncConfig implements AsyncConfigurer { public class AsyncConfig implements AsyncConfigurer {
@Bean(name = "asyncExecutor")
@Override @Override
public Executor getAsyncExecutor() { public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();

View File

@ -47,7 +47,7 @@ public class LakalaController extends BaseControllerImpl {
@ApiOperation(value = "测试案例", notes = "测试案例") @ApiOperation(value = "测试案例", notes = "测试案例")
@RequestMapping(value = "/testcase", method = RequestMethod.POST) @RequestMapping(value = "/testcase", method = RequestMethod.POST)
public Object testcase(@RequestBody JSONObject paramsJSON) { public Object testcase(@RequestBody JSONObject paramsJSON) {
return shopOrderReturnService.sfExpressExpiredForceRefund(paramsJSON.getStr("orderId"), paramsJSON.getInt("returnFlag")); return shopOrderReturnService.sfExpressExpiredForceRefund(paramsJSON.getStr("orderId"));
// return lakalaPayService.applyLedgerMerEc(paramsJSON.getStr("mchMobile")); // return lakalaPayService.applyLedgerMerEc(paramsJSON.getStr("mchMobile"));
// return lakalaPayService.LedgerMerEcDownload(975790666910121984L); // return lakalaPayService.LedgerMerEcDownload(975790666910121984L);

View File

@ -1379,10 +1379,15 @@ public class LakalaApiServiceImpl implements LakalaApiService {
// 2. 解析回调参数 // 2. 解析回调参数
JSONObject paramsJSON = JSONUtil.parseObj(checkResult.getSecond()); JSONObject paramsJSON = JSONUtil.parseObj(checkResult.getSecond());
if (paramsJSON == null) { if (paramsJSON == null || StrUtil.isBlank(paramsJSON.getStr("applyId"))) {
// https://o.lakala.com/#/home/document/detail?id=386 返回的数据结果有歧义需处理
paramsJSON = paramsJSON.getJSONObject("respData");
if (paramsJSON == null || StrUtil.isBlank(paramsJSON.getStr("applyId"))) {
log.error("商家绑定分账接收方异步通知参数转化失败"); log.error("商家绑定分账接收方异步通知参数转化失败");
return JSONUtil.createObj().put("code", "FAIL").put("message", "参数转换失败"); return JSONUtil.createObj().put("code", "FAIL").put("message", "参数转换失败");
} }
}
// 3. 提取核心参数 // 3. 提取核心参数
String merCupNo = paramsJSON.getStr("merCupNo"); String merCupNo = paramsJSON.getStr("merCupNo");
@ -1426,8 +1431,10 @@ public class LakalaApiServiceImpl implements LakalaApiService {
// 7. 成功后更新商户绑定状态为已绑定 // 7. 成功后更新商户绑定状态为已绑定
shopMchEntryService.updateMulStatus("", merCupNo, 0, 0, 0, 0, 0, 1, CommonConstant.MCH_APPR_STA_PASS); shopMchEntryService.updateMulStatus("", merCupNo, 0, 0, 0, 0, 0, 1, CommonConstant.MCH_APPR_STA_PASS);
// 8. 检查商户绑定状态是否完成 更改总的审核状态
shopMchEntryService.checkMerchEntryFinished("", merCupNo); shopMchEntryService.checkMerchEntryFinished("", merCupNo);
// 8. 日志记录并返回成功响应
// 9. 日志记录并返回成功响应
log.debug("商家绑定分账接收方异步通知处理完成merCupNo{}", merCupNo); log.debug("商家绑定分账接收方异步通知处理完成merCupNo{}", merCupNo);
return JSONUtil.createObj().put("code", "SUCCESS").put("message", "分账接收方绑定成功"); return JSONUtil.createObj().put("code", "SUCCESS").put("message", "分账接收方绑定成功");

View File

@ -51,7 +51,7 @@ public class PushMessageServiceImpl implements PushMessageService {
* @return * @return
*/ */
@Async("pushAsyncExecutor") @Async("asyncExecutor")
@Override @Override
public CompletableFuture<Boolean> noticeMerchantSignEcContract(Integer userId, JSONObject payload) { public CompletableFuture<Boolean> noticeMerchantSignEcContract(Integer userId, JSONObject payload) {
try { try {
@ -107,12 +107,16 @@ public class PushMessageServiceImpl implements PushMessageService {
* @param content 必填参数 * @param content 必填参数
* @param payload 可选参数 * @param payload 可选参数
*/ */
@Async("pushAsyncExecutor") @Async("asyncExecutor")
@Override @Override
public void noticeMerchantEmployeeOrderAction(Integer storeId, String orderId, String title, String content, JSONObject payload) { public void noticeMerchantEmployeeOrderAction(Integer storeId, String orderId, String title, String content, JSONObject payload) {
try {
List<String> cidList = shopStoreEmployeeService.selectEmployeeGeTuiCidByStoreId(storeId, orderId, null); List<String> cidList = shopStoreEmployeeService.selectEmployeeGeTuiCidByStoreId(storeId, orderId, null);
// 获取 商家的 cid // 获取 商家的 cid
uniCloudPushService.sendPushMessageBatch(cidList, title, content, payload); uniCloudPushService.sendPushMessageBatch(cidList, title, content, payload);
} catch (Exception e) {
log.error("执行 noticeMerchantEmployeeOrderAction 方法时发生异常storeId{}", storeId, e);
}
} }
} }

View File

@ -3,6 +3,7 @@ package com.suisung.mall.shop.order.controller.admin;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.api.ResultCode; import com.suisung.mall.common.api.ResultCode;
@ -198,5 +199,13 @@ public class ShopOrderReturnController extends BaseControllerImpl {
return CommonResult.success(shopOrderReturnService.transferToSupplier(return_id)); return CommonResult.success(shopOrderReturnService.transferToSupplier(return_id));
} }
// 商家App 相关接口
@ApiOperation(value = "商家退货退款", notes = "商家退货退款,支持整单或个别商品退货")
@RequestMapping(value = "/mch/order/doRefund", method = RequestMethod.POST)
public CommonResult doRefundForMch(@RequestBody JSONObject params) {
return shopOrderReturnService.doRefundForMch(params);
}
} }

View File

@ -1,5 +1,6 @@
package com.suisung.mall.shop.order.service; package com.suisung.mall.shop.order.service;
import cn.hutool.json.JSONObject;
import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.modules.order.ShopOrderInfo; import com.suisung.mall.common.modules.order.ShopOrderInfo;
import com.suisung.mall.common.modules.order.ShopOrderItem; import com.suisung.mall.common.modules.order.ShopOrderItem;
@ -86,10 +87,9 @@ public interface ShopOrderReturnService extends IBaseService<ShopOrderReturn> {
* 支付订单顺丰同城配送超时自动取消订单并退款加库存 * 支付订单顺丰同城配送超时自动取消订单并退款加库存
* *
* @param orderId 订单Id * @param orderId 订单Id
* @param returnFlag 退货类型(ENUM): 0-不用退货;1-需要退货
* @return * @return
*/ */
Boolean sfExpressExpiredForceRefund(String orderId, Integer returnFlag); Boolean sfExpressExpiredForceRefund(String orderId);
CommonResult editRefund(String return_id, BigDecimal return_refund_amount); CommonResult editRefund(String return_id, BigDecimal return_refund_amount);
@ -159,4 +159,12 @@ public interface ShopOrderReturnService extends IBaseService<ShopOrderReturn> {
* @return * @return
*/ */
boolean transferToSupplier(String return_id); boolean transferToSupplier(String return_id);
/**
* 商家退货退款支持全单或个别商品退货
*
* @param params
* @return
*/
CommonResult doRefundForMch(JSONObject params);
} }

View File

@ -9,6 +9,7 @@ import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.PhoneUtil; import cn.hutool.core.util.PhoneUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -511,7 +512,6 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
} }
boolean is_denyreturn = ifDenyReturn(shopOrderInfo, shopOrderItem, shopProductIndex); boolean is_denyreturn = ifDenyReturn(shopOrderInfo, shopOrderItem, shopProductIndex);
if (is_denyreturn) { if (is_denyreturn) {
throw new ApiException(I18nUtil._("此商品不允许退货!")); throw new ApiException(I18nUtil._("此商品不允许退货!"));
} }
@ -916,7 +916,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
*/ */
@GlobalTransactional @GlobalTransactional
@Override @Override
public Boolean sfExpressExpiredForceRefund(String orderId, Integer returnFlag) { public Boolean sfExpressExpiredForceRefund(String orderId) {
// 先整单退货申请 // 先整单退货申请
CommonResult commonResult = addWholeItems(orderId); CommonResult commonResult = addWholeItems(orderId);
@ -929,30 +929,12 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
throw new ApiException(I18nUtil._("订单信息异常!")); throw new ApiException(I18nUtil._("订单信息异常!"));
} }
returnFlag = CheckUtil.isEmpty(returnFlag) ? 0 : returnFlag; shopOrderReturn.setReturn_flag(0);
shopOrderReturn.setReturn_buyer_message("配送异常,系统自动退款");
shopOrderReturn.setReturn_store_message("配送异常,系统自动退款");
// 退货审核商家同意退款仅仅退款因为商品还没有配送出去
List<String> return_ids = Collections.singletonList(shopOrderReturn.getReturn_id()); return processReviewList(shopOrderReturn, 0);
//订单已支付但拣货超时顺丰同城配送异常超时被取消 强制退款
ShopOrderReturn orderReturn = new ShopOrderReturn();
orderReturn.setReturn_state_id(StateCode.RETURN_PROCESS_RECEIVED);
orderReturn.setReturn_flag(returnFlag);
if (!editShopOrderReturnAndItemNextState(return_ids, StateCode.RETURN_PROCESS_CHECK, orderReturn)) {
throw new ApiException(I18nUtil._("修改订单信息失败!"));
}
shopOrderReturn.setReturn_state_id(StateCode.RETURN_PROCESS_RECEIVED);
shopOrderReturn.setReturn_store_message("系统自动退款");
shopOrderReturn.setReturn_flag(returnFlag);
// end 待审核状态
if (!edit(shopOrderReturn)) {
throw new ApiException(I18nUtil._("修改订单信息失败!"));
}
// 订单审核
return processReviewList(return_ids, Collections.singletonList(shopOrderReturn), StateCode.RETURN_PROCESS_RECEIVED, StateCode.RETURN_PROCESS_FINISH);
} }
/** /**
@ -1188,81 +1170,78 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
} }
/** /**
* 退货单审核 - 商家同意退款退库 * 退货单审核(商家同意退款退库)
* 处理逻辑
* 1. 验证店铺权限
* 2. 根据退货标志(return_flag)区分处理流程
* - 0:无需退货直接完成退货单
* - 1:需要退货设置退货地址后审核
* 3. 审核完成后通知买家
* *
* @param shopOrderReturn * @param shopOrderReturn 退货单信息
* @return * @param receiving_address 收货地址ID
* @return 处理结果
* @throws ApiException 处理失败时抛出异常
*/ */
@Override @Override
@GlobalTransactional @GlobalTransactional
public boolean processReviewList(ShopOrderReturn shopOrderReturn, Integer receiving_address) { public boolean processReviewList(ShopOrderReturn shopOrderReturn, Integer receiving_address) {
try {
// 1. 获取并验证店铺权限
Integer store_id = Optional.ofNullable(shopOrderReturn.getStore_id())
.orElseGet(() -> Convert.toInt(getCurrentUser().getStore_id()));
Integer store_id; List<String> return_ids = Convert.toList(String.class, shopOrderReturn.getReturn_id());
if (shopOrderReturn.getStore_id() == null) {
UserDto user = getCurrentUser();
store_id = Convert.toInt(user.getStore_id());
} else {
store_id = shopOrderReturn.getStore_id();
}
String str_return_id = shopOrderReturn.getReturn_id();
List<String> return_ids = Convert.toList(String.class, str_return_id);
List<ShopOrderReturn> orderReturns = gets(return_ids); List<ShopOrderReturn> orderReturns = gets(return_ids);
if (CheckUtil.checkDataRights(store_id, orderReturns, ShopOrderReturn::getStore_id)) { if (!CheckUtil.checkDataRights(store_id, orderReturns, ShopOrderReturn::getStore_id)) {
Integer return_flag = shopOrderReturn.getReturn_flag();
if (ObjectUtil.equal(return_flag, 0)) {
//无需退货直接修改退货单状态为完成并调用 review 方法进行审核
if (!edit(shopOrderReturn)) {
throw new ApiException(I18nUtil._("修改订单信息失败!"));
}
Integer return_next_state_id = StateCode.RETURN_PROCESS_FINISH;
// 订单审核
if (!processReviewList(return_ids, orderReturns, StateCode.RETURN_PROCESS_CHECK, return_next_state_id)) {
throw new ApiException(I18nUtil._("审核失败!"));
}
} else {
//需要退货获取收货地址信息并更新退货单的相关字段如地址联系方式等随后调用 review 方法进行审核
ShopStoreShippingAddress address_row = shopStoreShippingAddressService.get(receiving_address);
if (address_row != null) {
String return_addr = address_row.getSs_province() + address_row.getSs_city() + address_row.getSs_county() + address_row.getSs_address();
Long return_mobile = Convert.toLong(address_row.getSs_mobile());
String return_telephone = address_row.getSs_telephone();
String return_contact_name = address_row.getSs_name();
shopOrderReturn.setReturn_addr(return_addr);
shopOrderReturn.setReturn_mobile(return_mobile);
shopOrderReturn.setReturn_telephone(return_telephone);
shopOrderReturn.setReturn_contact_name(return_contact_name);
if (!edit(shopOrderReturn)) {
throw new ApiException(I18nUtil._("修改订单信息失败!"));
}
// 订单审核
if (!processReviewList(return_ids, orderReturns, StateCode.RETURN_PROCESS_CHECK, 0)) {
throw new ApiException(I18nUtil._("审核失败!"));
}
} else {
throw new ApiException(I18nUtil._("请选择收货地址!"));
}
}
} else {
// 没有权限
throw new ApiException(ResultCode.FORBIDDEN); throw new ApiException(ResultCode.FORBIDDEN);
} }
// 通知买家退货退款成功 // 2. 根据退货标志处理不同流程
String message_id = "refunds-and-reminders"; if (ObjectUtil.equal(shopOrderReturn.getReturn_flag(), 0)) {
Map args = new HashMap(); // 2.1 无需退货流程
args.put("order_id", shopOrderReturn.getReturn_id()); if (!edit(shopOrderReturn)) {
args.put("return_refund_amount", shopOrderReturn.getReturn_refund_amount()); throw new ApiException(I18nUtil._("修改订单信息失败!"));
messageService.sendNoticeMsg(shopOrderReturn.getBuyer_user_id(), 0, message_id, args); }
if (!processReviewList(return_ids, orderReturns, StateCode.RETURN_PROCESS_CHECK, StateCode.RETURN_PROCESS_FINISH)) {
throw new ApiException(I18nUtil._("审核失败!"));
}
} else {
// 2.2 需要退货流程
ShopStoreShippingAddress address = shopStoreShippingAddressService.get(receiving_address);
if (address == null) {
throw new ApiException(I18nUtil._("请选择收货地址!"));
}
// 设置退货地址信息
shopOrderReturn.setReturn_addr(address.getSs_province() + address.getSs_city() + address.getSs_county() + address.getSs_address());
shopOrderReturn.setReturn_mobile(Convert.toLong(address.getSs_mobile()));
shopOrderReturn.setReturn_telephone(address.getSs_telephone());
shopOrderReturn.setReturn_contact_name(address.getSs_name());
if (!edit(shopOrderReturn) ||
!processReviewList(return_ids, orderReturns, StateCode.RETURN_PROCESS_CHECK, 0)) {
throw new ApiException(I18nUtil._("退货流程处理失败!"));
}
}
// 3. 通知买家
messageService.sendNoticeMsg(
shopOrderReturn.getBuyer_user_id(),
0,
"refunds-and-reminders",
new HashMap<String, Object>() {{
put("order_id", shopOrderReturn.getReturn_id());
put("return_refund_amount", shopOrderReturn.getReturn_refund_amount());
}});
return true; return true;
} catch (Exception e) {
logger.error("退货单审核处理异常", e);
throw e instanceof ApiException ? (ApiException) e :
new ApiException(I18nUtil._("系统处理异常: ") + e.getMessage());
}
} }
/** /**
@ -2051,7 +2030,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
// 生成退款单 // 生成退款单
OrderReturnInputVo orderReturnInputVo = new OrderReturnInputVo(); OrderReturnInputVo orderReturnInputVo = new OrderReturnInputVo();
orderReturnInputVo.setOrder_id(order_id); orderReturnInputVo.setOrder_id(order_id);
orderReturnInputVo.setReturn_tel(""); orderReturnInputVo.setReturn_tel(""); // 为什么不获取订单用户的手机号码
orderReturnInputVo.setReturn_buyer_message(I18nUtil._("整单退!")); orderReturnInputVo.setReturn_buyer_message(I18nUtil._("整单退!"));
orderReturnInputVo.setUser_id(orderInfo.getBuyer_user_id()); orderReturnInputVo.setUser_id(orderInfo.getBuyer_user_id());
@ -2188,4 +2167,15 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
return true; return true;
} }
/**
* 商家退货退款支持全单或个别商品退货
*
* @param params
* @return
*/
@Override
public CommonResult doRefundForMch(JSONObject params) {
return null;
}
} }

View File

@ -68,7 +68,6 @@ import com.suisung.mall.shop.sync.service.ProductMappingService;
import com.suisung.mall.shop.sync.service.StoreDbConfigService; import com.suisung.mall.shop.sync.service.StoreDbConfigService;
import com.suisung.mall.shop.user.service.*; import com.suisung.mall.shop.user.service.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.CloneUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -80,6 +79,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate; import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
@ -87,8 +87,6 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -215,7 +213,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
@Autowired @Autowired
private StoreDbConfigService storeDbConfigService; private StoreDbConfigService storeDbConfigService;
public static void main(String[] args) {
AtomicInteger count1 = new AtomicInteger(0);//全部
System.out.println(count1.addAndGet(10));
System.out.println(count1);
}
@Override @Override
public boolean trySaveProduct(String productObj, String productItems) { public boolean trySaveProduct(String productObj, String productItems) {
@ -1065,7 +1067,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
} }
List<Serializable> item_ids_all = (List<Serializable>) CollUtil.union(item_ids_new, item_ids_old); List<Serializable> item_ids_all = (List<Serializable>) CollUtil.union(item_ids_new, item_ids_old);
List<Serializable> item_ids_deprecate = (List<Serializable>) CollUtil.disjunction(item_ids_all, item_ids_new); List<Serializable> item_ids_deprecate = (List<Serializable>) CollUtil.disjunction(item_ids_all, item_ids_new);
// item_ids_deprecate 的值如[40,41,42] 商品 SKU ID 集合
// logger.info("商品 SKU ID item_ids_deprecate: {}", item_ids_deprecate);
//start 清理sku相关数据 //start 清理sku相关数据
if (CollUtil.isNotEmpty(item_ids_deprecate)) { if (CollUtil.isNotEmpty(item_ids_deprecate)) {
@ -1439,7 +1445,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
return $flag; return $flag;
} }
private JSONObject findColor(JSONArray item_spec, Integer buildin_spec_id) { private JSONObject findColor(JSONArray item_spec, Integer buildin_spec_id) {
for (Object spec : item_spec) { for (Object spec : item_spec) {
JSONObject _spec = (JSONObject) spec; JSONObject _spec = (JSONObject) spec;
@ -2405,7 +2410,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
return productItem.get(0); return productItem.get(0);
} }
@Override @Override
public Map shippingDistrict() { public Map shippingDistrict() {
@ -3598,7 +3602,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
return true; return true;
} }
/** /**
* 修改商品状态 * 修改商品状态
*/ */
@ -3694,7 +3697,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
return product_base_rows; return product_base_rows;
} }
/** /**
* 处理 shop_product_item 中json字符格式的 item_spec字段 转为json对象 * 处理 shop_product_item 中json字符格式的 item_spec字段 转为json对象
* *
@ -4537,7 +4539,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
return category_rows; return category_rows;
} }
private Map handleUniqid(String product_uniqid) { private Map handleUniqid(String product_uniqid) {
Map data = new HashMap(); Map data = new HashMap();
if (StrUtil.isBlank(product_uniqid) || "[]".equals(product_uniqid)) return data; if (StrUtil.isBlank(product_uniqid) || "[]".equals(product_uniqid)) return data;
@ -5270,7 +5271,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
return successCnt > 0; return successCnt > 0;
} }
public String initProductLangIndex(Long productId, String productNameIndex) { public String initProductLangIndex(Long productId, String productNameIndex) {
QueryWrapper<ShopBaseLangMeta> queryParams = new QueryWrapper<>(); QueryWrapper<ShopBaseLangMeta> queryParams = new QueryWrapper<>();
queryParams.eq("table_name", "shop_product_base"); queryParams.eq("table_name", "shop_product_base");
@ -5442,7 +5442,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
newShopProductAssistIndexList, updateShopProductAssistIndexList, priorityMode); newShopProductAssistIndexList, updateShopProductAssistIndexList, priorityMode);
} }
/** /**
* 执行批量操作新增和更新分开处理 * 执行批量操作新增和更新分开处理
*/ */
@ -5834,39 +5833,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
} }
/**
* 批量生产itemid
* @param items
* @param itemSeqs
* @return
*/
private List<Serializable> processProductItemsId(List<ShopProductItem> items,List<ShopProductItemSeq> itemSeqs,
List<ShopProductInfo> newShopProductInfoList){
List<Serializable> itemIds = new ArrayList<>();
if (CollUtil.isEmpty(items)) return itemIds;
List<Long> generatedIds = shopNumberSeqService.batchCreateNextNo("item_id", items.size());
// Map<String,String> cacheMap=new HashMap<>();
for (int i = 0; i < items.size(); i++) {
Long itemId = generatedIds.get(i);
ShopProductItem item = items.get(i);
item.setItem_id(itemId);
// if(StringUtils.isNotEmpty(item.getItem_spec())){
// String product_uniqid=ShopJsonUtils.generateJsonWithOrgJson(item.getSpec_item_ids(),new Object[]{itemId,item.getItem_unit_price(),"",1002});
// cacheMap.put(item.getProductName(),product_uniqid);
// }
itemIds.add(itemId);
ShopProductItemSeq field_row= itemSeqs.get(i);
field_row.setItem_id(itemId);
}
// for(ShopProductInfo shopProductInfo:newShopProductInfoList){
// if(ObjectUtil.isNotEmpty(cacheMap.get(shopProductInfo.getProductName()))){
// String product_uniqid=cacheMap.get(shopProductInfo.getProductName());
// shopProductInfo.setProduct_uniqid(product_uniqid);
// }
// }
return itemIds;
}
// /** // /**
// * 计算并产生规格 与商品配置表匹配匹配正确则新增规格商品 // * 计算并产生规格 与商品配置表匹配匹配正确则新增规格商品
// * @return // * @return
@ -5916,6 +5882,39 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
// return null; // return null;
// } // }
/**
* 批量生产itemid
*
* @param items
* @param itemSeqs
* @return
*/
private List<Serializable> processProductItemsId(List<ShopProductItem> items, List<ShopProductItemSeq> itemSeqs,
List<ShopProductInfo> newShopProductInfoList) {
List<Serializable> itemIds = new ArrayList<>();
if (CollUtil.isEmpty(items)) return itemIds;
List<Long> generatedIds = shopNumberSeqService.batchCreateNextNo("item_id", items.size());
// Map<String,String> cacheMap=new HashMap<>();
for (int i = 0; i < items.size(); i++) {
Long itemId = generatedIds.get(i);
ShopProductItem item = items.get(i);
item.setItem_id(itemId);
// if(StringUtils.isNotEmpty(item.getItem_spec())){
// String product_uniqid=ShopJsonUtils.generateJsonWithOrgJson(item.getSpec_item_ids(),new Object[]{itemId,item.getItem_unit_price(),"",1002});
// cacheMap.put(item.getProductName(),product_uniqid);
// }
itemIds.add(itemId);
ShopProductItemSeq field_row = itemSeqs.get(i);
field_row.setItem_id(itemId);
}
// for(ShopProductInfo shopProductInfo:newShopProductInfoList){
// if(ObjectUtil.isNotEmpty(cacheMap.get(shopProductInfo.getProductName()))){
// String product_uniqid=cacheMap.get(shopProductInfo.getProductName());
// shopProductInfo.setProduct_uniqid(product_uniqid);
// }
// }
return itemIds;
}
// 处理商品项 // 处理商品项
private void processProductItems(List<ShopProductItem> items, Long productId, private void processProductItems(List<ShopProductItem> items, Long productId,
@ -5975,6 +5974,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
/** /**
* 生成SKU唯一标识符 * 生成SKU唯一标识符
*
* @param item 商品项 * @param item 商品项
* @return SKU唯一标识字符串 * @return SKU唯一标识字符串
*/ */
@ -6014,8 +6014,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
return CollUtil.join(specItemIds, "-"); return CollUtil.join(specItemIds, "-");
} }
/** /**
* 检查哪些商品已存在 * 检查哪些商品已存在
*/ */
@ -6043,7 +6041,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
)); ));
} }
/** /**
* 批量根据店铺和货号查询商品 * 批量根据店铺和货号查询商品
*/ */
@ -6065,9 +6062,9 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
return list(query); return list(query);
} }
/** /**
* 处理商品图片批量操作 * 处理商品图片批量操作
*
* @param productImage 商品图片列表 * @param productImage 商品图片列表
* @param productId 商品ID * @param productId 商品ID
*/ */
@ -6086,6 +6083,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
/** /**
* 处理商品辅助属性批量操作 * 处理商品辅助属性批量操作
*
* @param assistIndices 辅助属性列表 * @param assistIndices 辅助属性列表
* @param storeId 商品ID * @param storeId 商品ID
*/ */
@ -6211,10 +6209,4 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
return resultInt; return resultInt;
} }
public static void main(String[] args) {
AtomicInteger count1=new AtomicInteger(0);//全部
System.out.println(count1.addAndGet(10));
System.out.println(count1);
}
} }

View File

@ -8,6 +8,7 @@
package com.suisung.mall.shop.sfexpress.controller.mobile; package com.suisung.mall.shop.sfexpress.controller.mobile;
import cn.hutool.core.util.StrUtil;
import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.pojo.res.ThirdApiRes; import com.suisung.mall.common.pojo.res.ThirdApiRes;
import com.suisung.mall.common.utils.SseEmitterUtil; import com.suisung.mall.common.utils.SseEmitterUtil;
@ -71,6 +72,10 @@ public class SFExpressController {
@ApiOperation(value = "查询顺丰同城订单状态流", notes = "查询顺丰同城订单状态流") @ApiOperation(value = "查询顺丰同城订单状态流", notes = "查询顺丰同城订单状态流")
@RequestMapping(value = "/list-order-feed", method = RequestMethod.POST) @RequestMapping(value = "/list-order-feed", method = RequestMethod.POST)
public ThirdApiRes listOrderFeed(@RequestParam(name = "order_id", defaultValue = "") String orderId) { public ThirdApiRes listOrderFeed(@RequestParam(name = "order_id", defaultValue = "") String orderId) {
if (StrUtil.isBlank(orderId) || orderId == "undefined" || orderId == "null") {
return new ThirdApiRes().fail(1003, "请求参数有误!");
}
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("order_id", shopStoreSfOrderService.getSfOrderIdByShopOrderId(orderId)); params.put("order_id", shopStoreSfOrderService.getSfOrderIdByShopOrderId(orderId));
return sfExpressApiService.listOrderFeed(params); return sfExpressApiService.listOrderFeed(params);

View File

@ -313,7 +313,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
// List<String> orderList = new ArrayList<>(); // List<String> orderList = new ArrayList<>();
// orderList.add(shopStoreSfOrderExist.getShop_order_id()); // orderList.add(shopStoreSfOrderExist.getShop_order_id());
// 取消订单, 流程订单状态积分众宝库存礼包优惠券 有就统统退还 // 取消订单, 流程订单状态积分众宝库存礼包优惠券 有就统统退还
Boolean success = shopOrderReturnService.sfExpressExpiredForceRefund(shopStoreSfOrderExist.getShop_order_id(), 0); // 不检查订单付款状态 Boolean success = shopOrderReturnService.sfExpressExpiredForceRefund(shopStoreSfOrderExist.getShop_order_id()); // 不检查订单付款状态
if (!success) { if (!success) {
throw new ApiException(I18nUtil._("取消商家订单失败!")); throw new ApiException(I18nUtil._("取消商家订单失败!"));
} }
@ -578,7 +578,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
// 重要订单取消 // 重要订单取消
// success = shopOrderBaseService.cancel(orderList, null, false); // success = shopOrderBaseService.cancel(orderList, null, false);
success = shopOrderReturnService.sfExpressExpiredForceRefund(shopOrderId, 0); success = shopOrderReturnService.sfExpressExpiredForceRefund(shopOrderId);
if (!success) { if (!success) {
return new ThirdApiRes().fail(-1, "取消订单业务处理失败!"); return new ThirdApiRes().fail(-1, "取消订单业务处理失败!");
} }

View File

@ -1315,7 +1315,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
ShopMchEntry merchantEntryUpd = new ShopMchEntry(); ShopMchEntry merchantEntryUpd = new ShopMchEntry();
merchantEntryUpd.setId(merchantEntry.getId()); merchantEntryUpd.setId(merchantEntry.getId());
merchantEntryUpd.setApproval_status(CommonConstant.MCH_APPR_STA_PASS); // 设置审批状态为已通过 merchantEntryUpd.setApproval_status(CommonConstant.MCH_APPR_STA_PASS); // 设置审批状态为已通过
merchantEntryUpd.setApproval_remark("入驻流程已全部完成!"); // 设置审批备注 merchantEntryUpd.setApproval_remark("已全部完成入驻流程"); // 设置审批备注
boolean updateResult = updateById(merchantEntry); // 更新商户入驻信息 boolean updateResult = updateById(merchantEntry); // 更新商户入驻信息
if (!updateResult) { if (!updateResult) {
log.error("更新商户入驻信息状态失败, merchantId={}", merchantEntry.getId()); log.error("更新商户入驻信息状态失败, merchantId={}", merchantEntry.getId());

18
pom.xml
View File

@ -317,18 +317,18 @@
<!-- sentinel配置 --> <!-- sentinel配置 -->
<sentinel.transport.dashboard>114.132.210.208:8718</sentinel.transport.dashboard> <sentinel.transport.dashboard>114.132.210.208:8718</sentinel.transport.dashboard>
<!-- mysql配置 --> <!-- mysql配置 -->
<mysql.host>42.194.196.179</mysql.host>
<mysql.port>3306</mysql.port>
<mysql.db>mall_dev</mysql.db>
<mysql.user>webdev</mysql.user>
<mysql.pwd>jbFr9YewcA9Mihx6fnw51Kzq</mysql.pwd>
<mysql.driver>com.mysql.cj.jdbc.Driver</mysql.driver>
<!-- <mysql.host>42.194.196.179</mysql.host>--> <!-- <mysql.host>42.194.196.179</mysql.host>-->
<!-- <mysql.port>3306</mysql.port>--> <!-- <mysql.port>3306</mysql.port>-->
<!-- <mysql.db>mall_prod</mysql.db>--> <!-- <mysql.db>mall_dev</mysql.db>-->
<!-- <mysql.user>root</mysql.user>--> <!-- <mysql.user>webdev</mysql.user>-->
<!-- <mysql.pwd>J0XivNvAcR14}pA6Cysm.E17</mysql.pwd>--> <!-- <mysql.pwd>jbFr9YewcA9Mihx6fnw51Kzq</mysql.pwd>-->
<!-- <mysql.driver>com.mysql.cj.jdbc.Driver</mysql.driver>--> <!-- <mysql.driver>com.mysql.cj.jdbc.Driver</mysql.driver>-->
<mysql.host>42.194.196.179</mysql.host>
<mysql.port>3306</mysql.port>
<mysql.db>mall_prod</mysql.db>
<mysql.user>root</mysql.user>
<mysql.pwd>J0XivNvAcR14}pA6Cysm.E27</mysql.pwd>
<mysql.driver>com.mysql.cj.jdbc.Driver</mysql.driver>
<!-- redis配置 --> <!-- redis配置 -->
<redis.host>114.132.210.208</redis.host> <redis.host>114.132.210.208</redis.host>
<redis.database>15</redis.database> <redis.database>15</redis.database>