fix 顺丰下单 bug
This commit is contained in:
parent
d7793cc24f
commit
1e181a7638
@ -2,77 +2,72 @@ package com.suisung.mall.common.exception;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.IErrorCode;
|
||||
import com.suisung.mall.common.api.ResultCode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* 全局异常处理
|
||||
* 全局异常处理器
|
||||
*
|
||||
* <p>主要功能:
|
||||
* <ul>
|
||||
* <li>统一处理系统未捕获异常</li>
|
||||
* <li>特殊处理数据库相关异常</li>
|
||||
* <li>规范化业务异常响应格式</li>
|
||||
* </ul>
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
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) {
|
||||
// 获取异常的第一帧堆栈信息
|
||||
StackTraceElement[] stackTrace = e.getStackTrace();
|
||||
String location = "未知位置";
|
||||
|
||||
if (stackTrace.length > 0) {
|
||||
StackTraceElement element = stackTrace[0]; // 第一个异常抛出点
|
||||
String className = element.getClassName();
|
||||
String methodName = element.getMethodName();
|
||||
int lineNumber = element.getLineNumber();
|
||||
location = String.format("%s.%s (line: %d)", className, methodName, lineNumber);
|
||||
/**
|
||||
* 获取异常发生位置信息
|
||||
*
|
||||
* @param stackTrace 异常堆栈
|
||||
* @return 格式化的位置信息(类名.方法名 : 行号)
|
||||
*/
|
||||
private String getExceptionLocation(StackTraceElement[] stackTrace) {
|
||||
if (stackTrace == null || stackTrace.length == 0) {
|
||||
return UNKNOWN_LOCATION;
|
||||
}
|
||||
StackTraceElement first = stackTrace[0];
|
||||
return String.format("%s.%s:%d", first.getClassName(), first.getMethodName(), first.getLineNumber());
|
||||
}
|
||||
|
||||
logger.error("Exception全局异常捕获 URI: {} - Method: {} - Error: {} at {}",
|
||||
req.getRequestURI(),
|
||||
req.getMethod(),
|
||||
e.getMessage(),
|
||||
location,
|
||||
e);
|
||||
/**
|
||||
* 处理系统级异常(数据库异常/通用异常)
|
||||
*/
|
||||
@ExceptionHandler({SQLException.class, DataAccessException.class, Exception.class})
|
||||
public CommonResult handleSystemException(HttpServletRequest req, Exception 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());
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = ApiException.class)
|
||||
public CommonResult exceptionHandler(HttpServletRequest req, ApiException e) {
|
||||
// 获取异常位置信息
|
||||
StackTraceElement[] stackTrace = e.getStackTrace();
|
||||
String location = "未知错误位置";
|
||||
/**
|
||||
* 处理业务API异常
|
||||
*/
|
||||
@ExceptionHandler(ApiException.class)
|
||||
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();
|
||||
String message = e.getMessage();
|
||||
|
||||
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);
|
||||
}
|
||||
return StrUtil.isNotBlank(e.getMessage())
|
||||
? CommonResult.failed(e.getMessage())
|
||||
: CommonResult.failed(ResultCode.FAILED);
|
||||
}
|
||||
}
|
||||
@ -9,13 +9,19 @@
|
||||
package com.suisung.mall.shop.config;
|
||||
|
||||
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.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class AsyncConfig implements AsyncConfigurer {
|
||||
|
||||
@Bean(name = "asyncExecutor")
|
||||
@Override
|
||||
public Executor getAsyncExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
|
||||
@ -47,7 +47,7 @@ public class LakalaController extends BaseControllerImpl {
|
||||
@ApiOperation(value = "测试案例", notes = "测试案例")
|
||||
@RequestMapping(value = "/testcase", method = RequestMethod.POST)
|
||||
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.LedgerMerEcDownload(975790666910121984L);
|
||||
|
||||
|
||||
@ -1379,10 +1379,15 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
|
||||
// 2. 解析回调参数
|
||||
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("商家绑定分账接收方异步通知参数转化失败");
|
||||
return JSONUtil.createObj().put("code", "FAIL").put("message", "参数转换失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 提取核心参数
|
||||
String merCupNo = paramsJSON.getStr("merCupNo");
|
||||
@ -1426,8 +1431,10 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
// 7. 成功后更新商户绑定状态为已绑定
|
||||
shopMchEntryService.updateMulStatus("", merCupNo, 0, 0, 0, 0, 0, 1, CommonConstant.MCH_APPR_STA_PASS);
|
||||
|
||||
// 8. 检查商户绑定状态是否完成, 更改总的审核状态
|
||||
shopMchEntryService.checkMerchEntryFinished("", merCupNo);
|
||||
// 8. 日志记录并返回成功响应
|
||||
|
||||
// 9. 日志记录并返回成功响应
|
||||
log.debug("商家绑定分账接收方异步通知处理完成,merCupNo:{}", merCupNo);
|
||||
return JSONUtil.createObj().put("code", "SUCCESS").put("message", "分账接收方绑定成功");
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ public class PushMessageServiceImpl implements PushMessageService {
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Async("pushAsyncExecutor")
|
||||
@Async("asyncExecutor")
|
||||
@Override
|
||||
public CompletableFuture<Boolean> noticeMerchantSignEcContract(Integer userId, JSONObject payload) {
|
||||
try {
|
||||
@ -107,12 +107,16 @@ public class PushMessageServiceImpl implements PushMessageService {
|
||||
* @param content 必填参数
|
||||
* @param payload 可选参数
|
||||
*/
|
||||
@Async("pushAsyncExecutor")
|
||||
@Async("asyncExecutor")
|
||||
@Override
|
||||
public void noticeMerchantEmployeeOrderAction(Integer storeId, String orderId, String title, String content, JSONObject payload) {
|
||||
try {
|
||||
List<String> cidList = shopStoreEmployeeService.selectEmployeeGeTuiCidByStoreId(storeId, orderId, null);
|
||||
// 获取 商家的 cid
|
||||
uniCloudPushService.sendPushMessageBatch(cidList, title, content, payload);
|
||||
} catch (Exception e) {
|
||||
log.error("执行 noticeMerchantEmployeeOrderAction 方法时发生异常,storeId:{}", storeId, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.suisung.mall.shop.order.controller.admin;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.ResultCode;
|
||||
@ -198,5 +199,13 @@ public class ShopOrderReturnController extends BaseControllerImpl {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.suisung.mall.shop.order.service;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.order.ShopOrderInfo;
|
||||
import com.suisung.mall.common.modules.order.ShopOrderItem;
|
||||
@ -86,10 +87,9 @@ public interface ShopOrderReturnService extends IBaseService<ShopOrderReturn> {
|
||||
* 支付订单,顺丰同城配送超时,自动取消订单并退款,加库存
|
||||
*
|
||||
* @param orderId 订单Id
|
||||
* @param returnFlag 退货类型(ENUM): 0-不用退货;1-需要退货
|
||||
* @return
|
||||
*/
|
||||
Boolean sfExpressExpiredForceRefund(String orderId, Integer returnFlag);
|
||||
Boolean sfExpressExpiredForceRefund(String orderId);
|
||||
|
||||
CommonResult editRefund(String return_id, BigDecimal return_refund_amount);
|
||||
|
||||
@ -159,4 +159,12 @@ public interface ShopOrderReturnService extends IBaseService<ShopOrderReturn> {
|
||||
* @return
|
||||
*/
|
||||
boolean transferToSupplier(String return_id);
|
||||
|
||||
/**
|
||||
* 商家退货退款,支持全单或个别商品退货
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
CommonResult doRefundForMch(JSONObject params);
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.PhoneUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
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);
|
||||
|
||||
if (is_denyreturn) {
|
||||
throw new ApiException(I18nUtil._("此商品不允许退货!"));
|
||||
}
|
||||
@ -916,7 +916,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
*/
|
||||
@GlobalTransactional
|
||||
@Override
|
||||
public Boolean sfExpressExpiredForceRefund(String orderId, Integer returnFlag) {
|
||||
public Boolean sfExpressExpiredForceRefund(String orderId) {
|
||||
|
||||
// 先整单退货申请
|
||||
CommonResult commonResult = addWholeItems(orderId);
|
||||
@ -929,30 +929,12 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
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());
|
||||
|
||||
//订单已支付,但拣货超时,顺丰同城配送异常超时被取消, 强制退款
|
||||
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);
|
||||
// 退货审核(商家同意退款,仅仅退款,因为商品还没有配送出去)
|
||||
return processReviewList(shopOrderReturn, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1188,81 +1170,78 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
}
|
||||
|
||||
/**
|
||||
* 退货单审核 - 商家同意退款退库
|
||||
* 退货单审核(商家同意退款退库)
|
||||
* 处理逻辑:
|
||||
* 1. 验证店铺权限
|
||||
* 2. 根据退货标志(return_flag)区分处理流程:
|
||||
* - 0:无需退货,直接完成退货单
|
||||
* - 1:需要退货,设置退货地址后审核
|
||||
* 3. 审核完成后通知买家
|
||||
*
|
||||
* @param shopOrderReturn
|
||||
* @return
|
||||
* @param shopOrderReturn 退货单信息
|
||||
* @param receiving_address 收货地址ID
|
||||
* @return 处理结果
|
||||
* @throws ApiException 处理失败时抛出异常
|
||||
*/
|
||||
@Override
|
||||
@GlobalTransactional
|
||||
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;
|
||||
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<String> return_ids = Convert.toList(String.class, shopOrderReturn.getReturn_id());
|
||||
List<ShopOrderReturn> orderReturns = gets(return_ids);
|
||||
|
||||
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 {
|
||||
// 没有权限
|
||||
if (!CheckUtil.checkDataRights(store_id, orderReturns, ShopOrderReturn::getStore_id)) {
|
||||
throw new ApiException(ResultCode.FORBIDDEN);
|
||||
}
|
||||
|
||||
// 通知买家退货退款成功
|
||||
String message_id = "refunds-and-reminders";
|
||||
Map args = new HashMap();
|
||||
args.put("order_id", shopOrderReturn.getReturn_id());
|
||||
args.put("return_refund_amount", shopOrderReturn.getReturn_refund_amount());
|
||||
messageService.sendNoticeMsg(shopOrderReturn.getBuyer_user_id(), 0, message_id, args);
|
||||
// 2. 根据退货标志处理不同流程
|
||||
if (ObjectUtil.equal(shopOrderReturn.getReturn_flag(), 0)) {
|
||||
// 2.1 无需退货流程
|
||||
if (!edit(shopOrderReturn)) {
|
||||
throw new ApiException(I18nUtil._("修改订单信息失败!"));
|
||||
}
|
||||
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;
|
||||
} 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.setOrder_id(order_id);
|
||||
orderReturnInputVo.setReturn_tel("");
|
||||
orderReturnInputVo.setReturn_tel(""); // 为什么不获取订单用户的手机号码
|
||||
orderReturnInputVo.setReturn_buyer_message(I18nUtil._("整单退!"));
|
||||
orderReturnInputVo.setUser_id(orderInfo.getBuyer_user_id());
|
||||
|
||||
@ -2188,4 +2167,15 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家退货退款,支持全单或个别商品退货
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult doRefundForMch(JSONObject params) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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.user.service.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.utils.CloneUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
@ -87,8 +87,6 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
@ -215,7 +213,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
@Autowired
|
||||
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
|
||||
public boolean trySaveProduct(String productObj, String productItems) {
|
||||
@ -463,7 +465,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
spec_rows = JSONArray.parseArray(JSON.toJSONString(productSpecList));
|
||||
}
|
||||
|
||||
if(null!=spec_rows){
|
||||
if (null != spec_rows) {
|
||||
for (Object spec_row : spec_rows) {
|
||||
JSONObject _spec_row = (JSONObject) spec_row;
|
||||
String spec_format = Convert.toStr(_spec_row.get("spec_format"));
|
||||
@ -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_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相关数据
|
||||
if (CollUtil.isNotEmpty(item_ids_deprecate)) {
|
||||
@ -1439,7 +1445,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
return $flag;
|
||||
}
|
||||
|
||||
|
||||
private JSONObject findColor(JSONArray item_spec, Integer buildin_spec_id) {
|
||||
for (Object spec : item_spec) {
|
||||
JSONObject _spec = (JSONObject) spec;
|
||||
@ -2405,7 +2410,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
return productItem.get(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map shippingDistrict() {
|
||||
|
||||
@ -2738,7 +2742,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
public Map getList(QueryWrapper<ShopProductBase> wrapper, Integer pageNum, Integer pageSize) {
|
||||
|
||||
Map map = new HashMap();
|
||||
Integer store_id = Convert.toInt(getCurrentUser().getStore_id(),1);
|
||||
Integer store_id = Convert.toInt(getCurrentUser().getStore_id(), 1);
|
||||
Integer nodeid = Convert.toInt(getParameter("nodeid"), 0);
|
||||
|
||||
if (CheckUtil.isNotEmpty(nodeid)) {
|
||||
@ -2976,17 +2980,17 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
});
|
||||
}
|
||||
}
|
||||
boolean openCount=getParameter("openCount",false);//1是开启,0是不开启
|
||||
if(openCount){
|
||||
ShopProductIndex shopProductIndex=new ShopProductIndex();
|
||||
boolean openCount = getParameter("openCount", false);//1是开启,0是不开启
|
||||
if (openCount) {
|
||||
ShopProductIndex shopProductIndex = new ShopProductIndex();
|
||||
shopProductIndex.setCategory_id(category_id);
|
||||
shopProductIndex.setStore_id(store_id);
|
||||
Integer[] countArrays= countShopIndex(shopProductIndex);
|
||||
data.put("allRecords",countArrays[0]);//全部
|
||||
data.put("normalRecords",countArrays[1]);//销售中
|
||||
data.put("offRecords",countArrays[2]);//仓库中
|
||||
data.put("illegalRecords",countArrays[3]);//违规禁售
|
||||
data.put("unCheckedRecords",countArrays[4]);//未分配或者待审核
|
||||
Integer[] countArrays = countShopIndex(shopProductIndex);
|
||||
data.put("allRecords", countArrays[0]);//全部
|
||||
data.put("normalRecords", countArrays[1]);//销售中
|
||||
data.put("offRecords", countArrays[2]);//仓库中
|
||||
data.put("illegalRecords", countArrays[3]);//违规禁售
|
||||
data.put("unCheckedRecords", countArrays[4]);//未分配或者待审核
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@ -3598,7 +3602,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改商品状态
|
||||
*/
|
||||
@ -3694,7 +3697,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
return product_base_rows;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理 shop_product_item 中json字符格式的 item_spec字段 转为json对象
|
||||
*
|
||||
@ -4537,7 +4539,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
return category_rows;
|
||||
}
|
||||
|
||||
|
||||
private Map handleUniqid(String product_uniqid) {
|
||||
Map data = new HashMap();
|
||||
if (StrUtil.isBlank(product_uniqid) || "[]".equals(product_uniqid)) return data;
|
||||
@ -5270,7 +5271,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
return successCnt > 0;
|
||||
}
|
||||
|
||||
|
||||
public String initProductLangIndex(Long productId, String productNameIndex) {
|
||||
QueryWrapper<ShopBaseLangMeta> queryParams = new QueryWrapper<>();
|
||||
queryParams.eq("table_name", "shop_product_base");
|
||||
@ -5294,7 +5294,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
List<ShopProductData> shopProductDataList, List<ShopProductDetail> shopProductDetailList,
|
||||
List<ShopProductInfo> shopProductInfoList, List<List<ShopProductItem>> shopProductItemList,
|
||||
List<ShopProductImage> shopProductImageList, List<ShopProductValidPeriod> shopProductValidPeriodList,
|
||||
List<ShopProductAssistIndex> shopProductAssistIndexList,String priorityMode) {
|
||||
List<ShopProductAssistIndex> shopProductAssistIndexList, String priorityMode) {
|
||||
|
||||
// 1. 参数校验
|
||||
if (shopProductBaseList == null || shopProductBaseList.isEmpty()) {
|
||||
@ -5311,26 +5311,26 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
List<ShopProductIndex> newShopProductIndexList = new ArrayList<>();
|
||||
List<ShopProductIndex> updateShopProductIndexList = new ArrayList<>();
|
||||
|
||||
List<ShopProductData> newProductDataList=new ArrayList<>();
|
||||
List<ShopProductData> updateProductDataList=new ArrayList<>();
|
||||
List<ShopProductData> newProductDataList = new ArrayList<>();
|
||||
List<ShopProductData> updateProductDataList = new ArrayList<>();
|
||||
|
||||
List<ShopProductDetail> newShopProductDetailList=new ArrayList<>();
|
||||
List<ShopProductDetail> updateShopProductDetailList=new ArrayList<>();
|
||||
List<ShopProductDetail> newShopProductDetailList = new ArrayList<>();
|
||||
List<ShopProductDetail> updateShopProductDetailList = new ArrayList<>();
|
||||
|
||||
List<ShopProductInfo> newShopProductInfoList=new ArrayList<>();
|
||||
List<ShopProductInfo> updateShopProductInfoList=new ArrayList<>();
|
||||
List<ShopProductInfo> newShopProductInfoList = new ArrayList<>();
|
||||
List<ShopProductInfo> updateShopProductInfoList = new ArrayList<>();
|
||||
|
||||
List<List<ShopProductItem>> newShopProductItemList=new ArrayList<>();
|
||||
List<List<ShopProductItem>> updateShopProductItemList=new ArrayList<>();
|
||||
List<List<ShopProductItem>> newShopProductItemList = new ArrayList<>();
|
||||
List<List<ShopProductItem>> updateShopProductItemList = new ArrayList<>();
|
||||
|
||||
List<ShopProductImage> newShopProductImageList=new ArrayList<>();
|
||||
List<ShopProductImage> updateShopProductImageList=new ArrayList<>();
|
||||
List<ShopProductImage> newShopProductImageList = new ArrayList<>();
|
||||
List<ShopProductImage> updateShopProductImageList = new ArrayList<>();
|
||||
|
||||
List<ShopProductValidPeriod> newShopProductValidPeriodList=new ArrayList<>();
|
||||
List<ShopProductValidPeriod> updateShopProductValidPeriodList=new ArrayList<>();
|
||||
List<ShopProductValidPeriod> newShopProductValidPeriodList = new ArrayList<>();
|
||||
List<ShopProductValidPeriod> updateShopProductValidPeriodList = new ArrayList<>();
|
||||
|
||||
List<ShopProductAssistIndex> newShopProductAssistIndexList=new ArrayList<>();
|
||||
List<ShopProductAssistIndex> updateShopProductAssistIndexList=new ArrayList<>();
|
||||
List<ShopProductAssistIndex> newShopProductAssistIndexList = new ArrayList<>();
|
||||
List<ShopProductAssistIndex> updateShopProductAssistIndexList = new ArrayList<>();
|
||||
try {
|
||||
for (int i = 0; i < shopProductBaseList.size(); i++) {
|
||||
ShopProductBase base = shopProductBaseList.get(i);
|
||||
@ -5358,29 +5358,29 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
// shopProductDataList.get(i).setProduct_id(existId);
|
||||
// shopProductDetailList.get(i).setProduct_id(existId);
|
||||
// shopProductInfoList.get(i).setProduct_id(existId);
|
||||
if(CollUtil.isNotEmpty(shopProductIndexList)){
|
||||
if (CollUtil.isNotEmpty(shopProductIndexList)) {
|
||||
updateShopProductIndexList.add(shopProductIndexList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductDataList)){
|
||||
if (CollUtil.isNotEmpty(shopProductDataList)) {
|
||||
updateProductDataList.add(shopProductDataList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductDetailList)){
|
||||
if (CollUtil.isNotEmpty(shopProductDetailList)) {
|
||||
updateShopProductDetailList.add(shopProductDetailList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductInfoList)){
|
||||
if (CollUtil.isNotEmpty(shopProductInfoList)) {
|
||||
updateShopProductInfoList.add(shopProductInfoList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductItemList)){
|
||||
if (CollUtil.isNotEmpty(shopProductItemList)) {
|
||||
updateShopProductItemList.add(shopProductItemList.get(i));
|
||||
}
|
||||
|
||||
if(CollUtil.isNotEmpty(shopProductImageList)){
|
||||
if (CollUtil.isNotEmpty(shopProductImageList)) {
|
||||
updateShopProductImageList.add(shopProductImageList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductValidPeriodList)){
|
||||
if (CollUtil.isNotEmpty(shopProductValidPeriodList)) {
|
||||
updateShopProductValidPeriodList.add(shopProductValidPeriodList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductAssistIndexList)){
|
||||
if (CollUtil.isNotEmpty(shopProductAssistIndexList)) {
|
||||
updateShopProductAssistIndexList.add(shopProductAssistIndexList.get(i));
|
||||
}
|
||||
updateProducts.add(base);
|
||||
@ -5402,28 +5402,28 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
shopProductIndexList.get(i).setProduct_number(base.getProduct_number());
|
||||
base.setProduct_market_price(base.getProduct_unit_price());
|
||||
shopProductInfoList.get(i).setProduct_spec("[]");
|
||||
if(CollUtil.isNotEmpty(shopProductIndexList)){
|
||||
if (CollUtil.isNotEmpty(shopProductIndexList)) {
|
||||
newShopProductIndexList.add(shopProductIndexList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductDataList)){
|
||||
if (CollUtil.isNotEmpty(shopProductDataList)) {
|
||||
newProductDataList.add(shopProductDataList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductDetailList)){
|
||||
if (CollUtil.isNotEmpty(shopProductDetailList)) {
|
||||
newShopProductDetailList.add(shopProductDetailList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductInfoList)){
|
||||
if (CollUtil.isNotEmpty(shopProductInfoList)) {
|
||||
newShopProductInfoList.add(shopProductInfoList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductItemList)){
|
||||
if (CollUtil.isNotEmpty(shopProductItemList)) {
|
||||
newShopProductItemList.add(shopProductItemList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductImageList)){
|
||||
if (CollUtil.isNotEmpty(shopProductImageList)) {
|
||||
newShopProductImageList.add(shopProductImageList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductValidPeriodList)){
|
||||
if (CollUtil.isNotEmpty(shopProductValidPeriodList)) {
|
||||
newShopProductValidPeriodList.add(shopProductValidPeriodList.get(i));
|
||||
}
|
||||
if(CollUtil.isNotEmpty(shopProductAssistIndexList)){
|
||||
if (CollUtil.isNotEmpty(shopProductAssistIndexList)) {
|
||||
newShopProductAssistIndexList.add(shopProductAssistIndexList.get(i));
|
||||
}
|
||||
// 新商品,加入新增列表
|
||||
@ -5431,27 +5431,26 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
}
|
||||
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.info("异常报错:{}",e.getMessage());
|
||||
} catch (RuntimeException e) {
|
||||
logger.info("异常报错:{}", e.getMessage());
|
||||
}
|
||||
|
||||
return executeBatchOperations(newProducts,updateProducts,newShopProductIndexList,updateShopProductIndexList,
|
||||
newProductDataList,updateProductDataList,newShopProductDetailList,updateShopProductDetailList,
|
||||
newShopProductInfoList,updateShopProductInfoList,newShopProductItemList,updateShopProductItemList,
|
||||
newShopProductImageList,updateShopProductImageList,newShopProductValidPeriodList,updateShopProductValidPeriodList,
|
||||
newShopProductAssistIndexList,updateShopProductAssistIndexList,priorityMode);
|
||||
return executeBatchOperations(newProducts, updateProducts, newShopProductIndexList, updateShopProductIndexList,
|
||||
newProductDataList, updateProductDataList, newShopProductDetailList, updateShopProductDetailList,
|
||||
newShopProductInfoList, updateShopProductInfoList, newShopProductItemList, updateShopProductItemList,
|
||||
newShopProductImageList, updateShopProductImageList, newShopProductValidPeriodList, updateShopProductValidPeriodList,
|
||||
newShopProductAssistIndexList, updateShopProductAssistIndexList, priorityMode);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 执行批量操作(新增和更新分开处理)
|
||||
*/
|
||||
private Pair<Boolean, String> executeBatchOperations(List<ShopProductBase> newProducts, List<ShopProductBase> updateProducts,
|
||||
List<ShopProductIndex> newShopProductIndexList,List<ShopProductIndex> updateShopProductIndexList,
|
||||
List<ShopProductIndex> newShopProductIndexList, List<ShopProductIndex> updateShopProductIndexList,
|
||||
List<ShopProductData> newShopProductDataList, List<ShopProductData> updateShopProductDataList,
|
||||
List<ShopProductDetail> newShopProductDetailList, List<ShopProductDetail> updateShopProductDetailList,
|
||||
List<ShopProductInfo> newShopProductInfoList, List<ShopProductInfo> updateShopProductInfoList,
|
||||
List<List<ShopProductItem>> newShopProductItemList,List<List<ShopProductItem>> udpateShopProductItemList,
|
||||
List<List<ShopProductItem>> newShopProductItemList, List<List<ShopProductItem>> udpateShopProductItemList,
|
||||
List<ShopProductImage> newShopProductImageList, List<ShopProductImage> udpteShopProductImageList,
|
||||
List<ShopProductValidPeriod> newShopProductValidPeriodList, List<ShopProductValidPeriod> updateShopProductValidPeriodList,
|
||||
List<ShopProductAssistIndex> newShopProductAssistIndexList, List<ShopProductAssistIndex> udpateShopProductAssistIndexList,
|
||||
@ -5472,11 +5471,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
|
||||
List<Serializable> addItemIds = new ArrayList<>();
|
||||
List<Serializable> udpateItemIds = new ArrayList<>();
|
||||
List<ShopProductItem> addShopProductItems=new ArrayList<>();
|
||||
List<ShopProductItem> updateShopProductItems=new ArrayList<>();
|
||||
List<ShopProductItem> addShopProductItems = new ArrayList<>();
|
||||
List<ShopProductItem> updateShopProductItems = new ArrayList<>();
|
||||
|
||||
List<ShopProductSpecItem> addShopProductSpecItems=new ArrayList<>();
|
||||
List<ShopProductSpecItem> updateShopProductSpecItems=new ArrayList<>();
|
||||
List<ShopProductSpecItem> addShopProductSpecItems = new ArrayList<>();
|
||||
List<ShopProductSpecItem> updateShopProductSpecItems = new ArrayList<>();
|
||||
// int taskCount = 2;
|
||||
// CountDownLatch latch = new CountDownLatch(taskCount);
|
||||
// 1. 批量新增
|
||||
@ -5502,39 +5501,39 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
addShopProductItems.addAll(items);
|
||||
|
||||
// 处理图片
|
||||
if(CollUtil.isNotEmpty(newShopProductImageList)){
|
||||
processProductImages(newShopProductImageList.get(i), productId,base.getStore_id(),newProducts.get(i).getProduct_number(),newProducts.get(i).getProduct_name());//设置默认属性1
|
||||
if (CollUtil.isNotEmpty(newShopProductImageList)) {
|
||||
processProductImages(newShopProductImageList.get(i), productId, base.getStore_id(), newProducts.get(i).getProduct_number(), newProducts.get(i).getProduct_name());//设置默认属性1
|
||||
}
|
||||
|
||||
// 处理辅助属性
|
||||
if(CollUtil.isNotEmpty(newShopProductAssistIndexList)){
|
||||
processAssistIndices(newShopProductAssistIndexList, base.getStore_id(),false);
|
||||
if (CollUtil.isNotEmpty(newShopProductAssistIndexList)) {
|
||||
processAssistIndices(newShopProductAssistIndexList, base.getStore_id(), false);
|
||||
}
|
||||
|
||||
// 准备分析数据
|
||||
ShopProductAnalytics shopProductAnalytics= new ShopProductAnalytics();
|
||||
ShopProductAnalytics shopProductAnalytics = new ShopProductAnalytics();
|
||||
shopProductAnalytics.setProduct_id(productId);
|
||||
shopProductAnalytics.setProduct_click(0);
|
||||
addAnalyticsList.add(shopProductAnalytics);
|
||||
}
|
||||
List<Serializable> itemIds = processProductItemsId(addShopProductItems, addItemSeqs,newShopProductInfoList);
|
||||
List<Serializable> itemIds = processProductItemsId(addShopProductItems, addItemSeqs, newShopProductInfoList);
|
||||
addItemIds.addAll(itemIds);
|
||||
// 2. 批量更新
|
||||
if (CollUtil.isNotEmpty(newProducts)) {
|
||||
logger.info("保存任务开始执行");
|
||||
try {
|
||||
long startTime=System.nanoTime();
|
||||
saveBatch(newProducts,newProducts.size());
|
||||
long startTime = System.nanoTime();
|
||||
saveBatch(newProducts, newProducts.size());
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("新增newProducts--{}条数据耗时:{}",newProducts.size(),duration/1000000000);
|
||||
logger.info("新增newProducts--{}条数据耗时:{}", newProducts.size(), duration / 1000000000);
|
||||
} catch (Exception e) {
|
||||
logger.error("系统异常"+e.getMessage());
|
||||
logger.error("系统异常" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(updateProducts)) {
|
||||
for(int i=0;i<updateProducts.size();i++){
|
||||
for (int i = 0; i < updateProducts.size(); i++) {
|
||||
Long productId = updateProducts.get(i).getProduct_id();
|
||||
ShopProductBase base = updateProducts.get(i);
|
||||
base.setProduct_id(productId);
|
||||
@ -5552,51 +5551,51 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
updateShopProductItems.addAll(items);
|
||||
|
||||
// 处理图片
|
||||
if(CollUtil.isNotEmpty(udpteShopProductImageList)){
|
||||
processProductImages(udpteShopProductImageList.get(i), productId,base.getStore_id(),updateProducts.get(i).getProduct_number(),updateProducts.get(i).getProduct_name());
|
||||
if (CollUtil.isNotEmpty(udpteShopProductImageList)) {
|
||||
processProductImages(udpteShopProductImageList.get(i), productId, base.getStore_id(), updateProducts.get(i).getProduct_number(), updateProducts.get(i).getProduct_name());
|
||||
}
|
||||
|
||||
// 处理辅助属性
|
||||
if(CollUtil.isNotEmpty(udpateShopProductAssistIndexList)){
|
||||
processAssistIndices(udpateShopProductAssistIndexList, base.getStore_id(),true);
|
||||
if (CollUtil.isNotEmpty(udpateShopProductAssistIndexList)) {
|
||||
processAssistIndices(udpateShopProductAssistIndexList, base.getStore_id(), true);
|
||||
}
|
||||
|
||||
// 准备分析数据
|
||||
ShopProductAnalytics shopProductAnalytics= new ShopProductAnalytics();
|
||||
ShopProductAnalytics shopProductAnalytics = new ShopProductAnalytics();
|
||||
shopProductAnalytics.setProduct_id(productId);
|
||||
shopProductAnalytics.setProduct_click(0);
|
||||
udpateAnalyticsList.add(shopProductAnalytics);
|
||||
}
|
||||
List<Serializable> itemIds = processProductItemsId(updateShopProductItems, updateItemSeqs,newShopProductInfoList);
|
||||
List<Serializable> itemIds = processProductItemsId(updateShopProductItems, updateItemSeqs, newShopProductInfoList);
|
||||
udpateItemIds.addAll(itemIds);
|
||||
// 2. 批量更新
|
||||
if (CollUtil.isNotEmpty(updateProducts)) {
|
||||
logger.info("更新任务开始执行");
|
||||
try {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
updateBatchById(updateProducts);
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("更新updateProducts-{}条数据耗时:{}",updateProducts.size(),duration/1000000000);
|
||||
logger.info("更新updateProducts-{}条数据耗时:{}", updateProducts.size(), duration / 1000000000);
|
||||
} catch (Exception e) {
|
||||
logger.error("系统异常"+e.getMessage());
|
||||
logger.error("系统异常" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 3. 处理其他表的批量操作(同样需要区分新增和更新)
|
||||
batchProcessOtherTables(newShopProductIndexList,updateShopProductIndexList,newShopProductDataList,updateShopProductDataList,
|
||||
newShopProductDetailList,updateShopProductDetailList,newShopProductInfoList,updateShopProductInfoList,
|
||||
newShopProductValidPeriodList,updateShopProductValidPeriodList,addShopProductItems,updateShopProductItems,
|
||||
addAnalyticsList,udpateAnalyticsList,addItemSeqs,updateItemSeqs,newShopProductImageList,udpteShopProductImageList);
|
||||
batchProcessOtherTables(newShopProductIndexList, updateShopProductIndexList, newShopProductDataList, updateShopProductDataList,
|
||||
newShopProductDetailList, updateShopProductDetailList, newShopProductInfoList, updateShopProductInfoList,
|
||||
newShopProductValidPeriodList, updateShopProductValidPeriodList, addShopProductItems, updateShopProductItems,
|
||||
addAnalyticsList, udpateAnalyticsList, addItemSeqs, updateItemSeqs, newShopProductImageList, udpteShopProductImageList);
|
||||
logger.info("处理成功,新增{}条,更新{}条", newProducts.size(), updateProducts.size());
|
||||
|
||||
//计算规格
|
||||
if(CollUtil.isNotEmpty(newProducts)){
|
||||
productMappingService.computeProductMapping(newProducts,newProducts.get(0).getStore_id(),false);
|
||||
if (CollUtil.isNotEmpty(newProducts)) {
|
||||
productMappingService.computeProductMapping(newProducts, newProducts.get(0).getStore_id(), false);
|
||||
}
|
||||
if(CollUtil.isNotEmpty(updateProducts)){//如果时自动优先,则按平台规则切割商品
|
||||
if(DicEnum.PRIORITY_MODE_2.getCode().equals(priorityMode)){
|
||||
productMappingService.computeProductMapping(updateProducts,updateProducts.get(0).getStore_id(),true);
|
||||
if (CollUtil.isNotEmpty(updateProducts)) {//如果时自动优先,则按平台规则切割商品
|
||||
if (DicEnum.PRIORITY_MODE_2.getCode().equals(priorityMode)) {
|
||||
productMappingService.computeProductMapping(updateProducts, updateProducts.get(0).getStore_id(), true);
|
||||
}
|
||||
}
|
||||
return Pair.of(true, String.format("处理成功,新增%d条,更新%d条",
|
||||
@ -5613,12 +5612,12 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
private void batchProcessOtherTables(List<ShopProductIndex> newShopProductIndex, List<ShopProductIndex> updateShopProductIndex,
|
||||
List<ShopProductData> newShopProductDataList, List<ShopProductData> updateShopProductDataList,
|
||||
List<ShopProductDetail> newshopProductDetailList, List<ShopProductDetail> updateShopProductDetailList,
|
||||
List<ShopProductInfo> newShopProductInfoList,List<ShopProductInfo> updateShopProductInfoList,
|
||||
List<ShopProductValidPeriod> newShopProductValidPeriodList,List<ShopProductValidPeriod> updateShopProductValidPeriodList,
|
||||
List<ShopProductItem> newshopProductItemList,List<ShopProductItem> updateshopProductItemList,
|
||||
List<ShopProductAnalytics> newShopProductAnalyticList,List<ShopProductAnalytics> updateShopProductAnalyticList,
|
||||
List<ShopProductItemSeq> newShopProductItemSeqList,List<ShopProductItemSeq> updateShopProductItemSeqList,
|
||||
List<ShopProductImage> addShopProductImageList,List<ShopProductImage> updateShopProductImageList) {
|
||||
List<ShopProductInfo> newShopProductInfoList, List<ShopProductInfo> updateShopProductInfoList,
|
||||
List<ShopProductValidPeriod> newShopProductValidPeriodList, List<ShopProductValidPeriod> updateShopProductValidPeriodList,
|
||||
List<ShopProductItem> newshopProductItemList, List<ShopProductItem> updateshopProductItemList,
|
||||
List<ShopProductAnalytics> newShopProductAnalyticList, List<ShopProductAnalytics> updateShopProductAnalyticList,
|
||||
List<ShopProductItemSeq> newShopProductItemSeqList, List<ShopProductItemSeq> updateShopProductItemSeqList,
|
||||
List<ShopProductImage> addShopProductImageList, List<ShopProductImage> updateShopProductImageList) {
|
||||
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
|
||||
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
transactionTemplate.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
|
||||
@ -5629,11 +5628,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
try {
|
||||
if (CollUtil.isNotEmpty(newShopProductIndex)) {
|
||||
// synchronized (this){
|
||||
long startTime=System.nanoTime();
|
||||
shopProductIndexService.saveBatch(newShopProductIndex,newShopProductIndex.size());
|
||||
long startTime = System.nanoTime();
|
||||
shopProductIndexService.saveBatch(newShopProductIndex, newShopProductIndex.size());
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("新增newShopProductIndex-{}条数据耗时:{}",newShopProductIndex.size(),duration/1000000000);
|
||||
logger.info("新增newShopProductIndex-{}条数据耗时:{}", newShopProductIndex.size(), duration / 1000000000);
|
||||
boolean esearch_enable = accountBaseConfigService.getConfig("esearch_enable", false);
|
||||
//调用es,create
|
||||
if (esearch_enable) {
|
||||
@ -5644,11 +5643,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
}
|
||||
if (CollUtil.isNotEmpty(updateShopProductIndex)) {
|
||||
// synchronized (this) {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
shopProductIndexService.updateBatchById(updateShopProductIndex);
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("更新updateShopProductIndex-{}条数据耗时:{}",updateShopProductIndex.size(),duration/1000000000);
|
||||
logger.info("更新updateShopProductIndex-{}条数据耗时:{}", updateShopProductIndex.size(), duration / 1000000000);
|
||||
boolean esearch_enable = accountBaseConfigService.getConfig("esearch_enable", false);
|
||||
//调用es,create
|
||||
if (esearch_enable) {
|
||||
@ -5659,28 +5658,28 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
|
||||
if (CollUtil.isNotEmpty(newShopProductDataList)) {
|
||||
//synchronized (this) {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
shopProductDataService.saveBatch(newShopProductDataList, newShopProductDataList.size());
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("新增newShopProductDataList-{}条数据耗时:{}",newShopProductDataList.size(),duration/1000000000);
|
||||
logger.info("新增newShopProductDataList-{}条数据耗时:{}", newShopProductDataList.size(), duration / 1000000000);
|
||||
//}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(updateShopProductDataList)) {
|
||||
// synchronized (this) {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
shopProductDataService.updateBatchById(updateShopProductDataList);
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("更新updateShopProductDataList-{}条数据耗时:{}",updateShopProductDataList.size(),duration/1000000000);
|
||||
logger.info("更新updateShopProductDataList-{}条数据耗时:{}", updateShopProductDataList.size(), duration / 1000000000);
|
||||
// }
|
||||
}
|
||||
if(CollectionUtil.isNotEmpty(addShopProductImageList)){
|
||||
long startTime=System.nanoTime();
|
||||
shopProductImageService.saveBatch(addShopProductImageList,addShopProductImageList.size());
|
||||
if (CollectionUtil.isNotEmpty(addShopProductImageList)) {
|
||||
long startTime = System.nanoTime();
|
||||
shopProductImageService.saveBatch(addShopProductImageList, addShopProductImageList.size());
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("新增addShopProductImageList-{}条数据耗时:{}",addShopProductImageList.size(),duration/1000000000);
|
||||
logger.info("新增addShopProductImageList-{}条数据耗时:{}", addShopProductImageList.size(), duration / 1000000000);
|
||||
}
|
||||
// if(CollectionUtil.isNotEmpty(updateShopProductImageList)){
|
||||
// long startTime=System.nanoTime();
|
||||
@ -5690,8 +5689,8 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
// long duration = (endTime - startTime);
|
||||
// logger.info("更新updateShopProductImageList-{}条数据耗时:{}",updateShopProductImageList.size(),duration/1000000000);
|
||||
// }
|
||||
}catch (RuntimeException e){
|
||||
logger.info("批量报错附表失败{}",e.getMessage());
|
||||
} catch (RuntimeException e) {
|
||||
logger.info("批量报错附表失败{}", e.getMessage());
|
||||
}
|
||||
|
||||
// });
|
||||
@ -5700,43 +5699,43 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
try {
|
||||
if (CollUtil.isNotEmpty(newshopProductDetailList)) {
|
||||
// synchronized (this) {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
shopProductDetailService.saveBatch(newshopProductDetailList, newshopProductDetailList.size());
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("新增newshopProductDetailList-{}条数据耗时:{}",newshopProductDetailList.size(),duration/1000000000);
|
||||
logger.info("新增newshopProductDetailList-{}条数据耗时:{}", newshopProductDetailList.size(), duration / 1000000000);
|
||||
|
||||
// }
|
||||
}
|
||||
if (CollUtil.isNotEmpty(updateShopProductDetailList)) {
|
||||
// synchronized (this) {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
shopProductDetailService.updateBatchById(updateShopProductDetailList);
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("更新updateShopProductDetailList-{}条数据耗时:{}",updateShopProductDetailList.size(),duration/1000000000);
|
||||
logger.info("更新updateShopProductDetailList-{}条数据耗时:{}", updateShopProductDetailList.size(), duration / 1000000000);
|
||||
// }
|
||||
}
|
||||
if (CollUtil.isNotEmpty(newShopProductInfoList)) {
|
||||
// synchronized (this) {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
shopProductInfoService.saveBatch(newShopProductInfoList, newShopProductInfoList.size());
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("新增updateShopProductDetailList-{}条数据耗时:{}",newShopProductInfoList.size(),duration/1000000000);
|
||||
logger.info("新增updateShopProductDetailList-{}条数据耗时:{}", newShopProductInfoList.size(), duration / 1000000000);
|
||||
// }
|
||||
}
|
||||
if (CollUtil.isNotEmpty(updateShopProductInfoList)) {
|
||||
// synchronized (this) {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
shopProductInfoService.updateBatchById(updateShopProductInfoList);
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("更新updateShopProductInfoList-{}条数据耗时:{}",updateShopProductInfoList.size(),duration/1000000000);
|
||||
logger.info("更新updateShopProductInfoList-{}条数据耗时:{}", updateShopProductInfoList.size(), duration / 1000000000);
|
||||
// }
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.info("批量报错附表失败{}",e.getMessage());
|
||||
} catch (RuntimeException e) {
|
||||
logger.info("批量报错附表失败{}", e.getMessage());
|
||||
}
|
||||
//});
|
||||
|
||||
@ -5744,42 +5743,42 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
try {
|
||||
if (CollUtil.isNotEmpty(newShopProductValidPeriodList)) {
|
||||
// synchronized (this) {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
validPeriodService.saveBatch(newShopProductValidPeriodList, newShopProductValidPeriodList.size());
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("新增newShopProductValidPeriodList-{}条数据耗时:{}",newShopProductValidPeriodList.size(),duration/1000000000);
|
||||
logger.info("新增newShopProductValidPeriodList-{}条数据耗时:{}", newShopProductValidPeriodList.size(), duration / 1000000000);
|
||||
// }
|
||||
}
|
||||
if (CollUtil.isNotEmpty(updateShopProductValidPeriodList)) {
|
||||
//synchronized (this) {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
validPeriodService.updateBatchById(updateShopProductValidPeriodList);
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("更新updateShopProductValidPeriodList-{}条数据耗时:{}",updateShopProductValidPeriodList.size(),duration/1000000000);
|
||||
logger.info("更新updateShopProductValidPeriodList-{}条数据耗时:{}", updateShopProductValidPeriodList.size(), duration / 1000000000);
|
||||
// }
|
||||
}
|
||||
if (CollUtil.isNotEmpty(newShopProductAnalyticList)) {
|
||||
// synchronized (this) {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
shopProductAnalyticsService.saveBatch(newShopProductAnalyticList, newShopProductAnalyticList.size());
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("新增newShopProductAnalyticList-{}条数据耗时:{}",newShopProductAnalyticList.size(),duration/1000000000);
|
||||
logger.info("新增newShopProductAnalyticList-{}条数据耗时:{}", newShopProductAnalyticList.size(), duration / 1000000000);
|
||||
// }
|
||||
}
|
||||
if (CollUtil.isNotEmpty(updateShopProductAnalyticList)) {
|
||||
// synchronized (this) {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
shopProductAnalyticsService.updateBatchById(updateShopProductAnalyticList);
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("更新updateShopProductAnalyticList-{}条数据耗时:{}",updateShopProductAnalyticList.size(),duration/1000000000);
|
||||
logger.info("更新updateShopProductAnalyticList-{}条数据耗时:{}", updateShopProductAnalyticList.size(), duration / 1000000000);
|
||||
// }
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.info("批量报错附表失败{}",e.getMessage());
|
||||
} catch (RuntimeException e) {
|
||||
logger.info("批量报错附表失败{}", e.getMessage());
|
||||
}
|
||||
|
||||
//});
|
||||
@ -5788,11 +5787,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
try {
|
||||
if (CollUtil.isNotEmpty(newshopProductItemList)) {
|
||||
// synchronized (this) {
|
||||
long startTime=System.nanoTime();
|
||||
long startTime = System.nanoTime();
|
||||
shopProductItemService.saveBatch(newshopProductItemList, newshopProductItemList.size());
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("新增newshopProductItemList-{}条数据耗时:{}",newshopProductItemList.size(),duration/1000000000);
|
||||
logger.info("新增newshopProductItemList-{}条数据耗时:{}", newshopProductItemList.size(), duration / 1000000000);
|
||||
//}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(updateshopProductItemList)) {
|
||||
@ -5801,7 +5800,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
shopProductItemService.updateBatchById(updateshopProductItemList);
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("更新updateshopProductItemList-{}条数据耗时:{}",updateshopProductItemList.size(),duration/1000000000);
|
||||
logger.info("更新updateshopProductItemList-{}条数据耗时:{}", updateshopProductItemList.size(), duration / 1000000000);
|
||||
//}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(newShopProductItemSeqList)) {
|
||||
@ -5810,7 +5809,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
shopProductItemSeqService.saveBatch(newShopProductItemSeqList, newShopProductItemSeqList.size());
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("新曾newShopProductItemSeqList-{}条数据耗时:{}",newShopProductItemSeqList.size(),duration/1000000000);
|
||||
logger.info("新曾newShopProductItemSeqList-{}条数据耗时:{}", newShopProductItemSeqList.size(), duration / 1000000000);
|
||||
// }
|
||||
}
|
||||
if (CollUtil.isNotEmpty(updateShopProductItemSeqList)) {
|
||||
@ -5819,12 +5818,12 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
shopProductItemSeqService.updateBatchById(updateShopProductItemSeqList);
|
||||
long endTime = System.nanoTime();
|
||||
long duration = (endTime - startTime);
|
||||
logger.info("更新updateShopProductItemSeqList-{}条数据耗时:{}",updateShopProductItemSeqList.size(),duration/1000000000);
|
||||
logger.info("更新updateShopProductItemSeqList-{}条数据耗时:{}", updateShopProductItemSeqList.size(), duration / 1000000000);
|
||||
// }
|
||||
}
|
||||
|
||||
}catch (RuntimeException e){
|
||||
logger.info("批量报错附表失败{}",e.getMessage());
|
||||
} catch (RuntimeException e) {
|
||||
logger.info("批量报错附表失败{}", e.getMessage());
|
||||
}
|
||||
//});
|
||||
// 等待所有操作完成
|
||||
@ -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
|
||||
@ -5916,6 +5882,39 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
// 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,
|
||||
@ -5975,6 +5974,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
|
||||
/**
|
||||
* 生成SKU唯一标识符
|
||||
*
|
||||
* @param item 商品项
|
||||
* @return SKU唯一标识字符串
|
||||
*/
|
||||
@ -6014,8 +6014,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
return CollUtil.join(specItemIds, "-");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 检查哪些商品已存在
|
||||
*/
|
||||
@ -6033,7 +6031,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 3. 批量查询(优化为一次查询)
|
||||
List<ShopProductBase> existing = batchGetByStoreAndProductNumber(storeProductPairs,productBases.get(0).getStore_id());
|
||||
List<ShopProductBase> existing = batchGetByStoreAndProductNumber(storeProductPairs, productBases.get(0).getStore_id());
|
||||
|
||||
// 4. 构建存在商品的映射表
|
||||
return existing.stream()
|
||||
@ -6043,11 +6041,10 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量根据店铺和货号查询商品
|
||||
*/
|
||||
private List<ShopProductBase> batchGetByStoreAndProductNumber(List<Pair<Integer, String>> storeProductPairs,Integer storeId) {
|
||||
private List<ShopProductBase> batchGetByStoreAndProductNumber(List<Pair<Integer, String>> storeProductPairs, Integer storeId) {
|
||||
if (CollUtil.isEmpty(storeProductPairs)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@ -6065,13 +6062,13 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
return list(query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理商品图片批量操作
|
||||
*
|
||||
* @param productImage 商品图片列表
|
||||
* @param productId 商品ID
|
||||
*/
|
||||
private void processProductImages(ShopProductImage productImage, Long productId, Integer storeId,String productNumber,String productName) {
|
||||
private void processProductImages(ShopProductImage productImage, Long productId, Integer storeId, String productNumber, String productName) {
|
||||
if (ObjectUtil.isEmpty(productImage)) {
|
||||
return;
|
||||
}
|
||||
@ -6086,10 +6083,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
|
||||
/**
|
||||
* 处理商品辅助属性批量操作
|
||||
*
|
||||
* @param assistIndices 辅助属性列表
|
||||
* @param storeId 商品ID
|
||||
*/
|
||||
private void processAssistIndices(List<ShopProductAssistIndex> assistIndices, Integer storeId,boolean isUpdate) {
|
||||
private void processAssistIndices(List<ShopProductAssistIndex> assistIndices, Integer storeId, boolean isUpdate) {
|
||||
if (CollUtil.isEmpty(assistIndices)) {
|
||||
return;
|
||||
}
|
||||
@ -6114,10 +6112,10 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
|
||||
// 执行批量操作
|
||||
if (CollUtil.isNotEmpty(assistIndices)) {
|
||||
if(isUpdate){
|
||||
if (isUpdate) {
|
||||
assistIndexService.updateBatchById(assistIndices);
|
||||
}else {
|
||||
assistIndexService.saveBatch(assistIndices,assistIndices.size());
|
||||
} else {
|
||||
assistIndexService.saveBatch(assistIndices, assistIndices.size());
|
||||
}
|
||||
|
||||
}
|
||||
@ -6128,17 +6126,17 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Long> getProductBasicIdByStore(Integer store_id,List<String> productNumberList) {
|
||||
QueryWrapper<ShopProductBase> queryWrapper=new QueryWrapper();
|
||||
queryWrapper.select("product_number","product_id");
|
||||
productNumberList.forEach(productNumber->{
|
||||
queryWrapper.or(q->q.eq("store_id",store_id).eq("product_number",productNumber));
|
||||
public Map<String, Long> getProductBasicIdByStore(Integer store_id, List<String> productNumberList) {
|
||||
QueryWrapper<ShopProductBase> queryWrapper = new QueryWrapper();
|
||||
queryWrapper.select("product_number", "product_id");
|
||||
productNumberList.forEach(productNumber -> {
|
||||
queryWrapper.or(q -> q.eq("store_id", store_id).eq("product_number", productNumber));
|
||||
});
|
||||
List<ShopProductBase> shopProductBaseList= this.list(queryWrapper);
|
||||
Map<String,Long> resultMap=new HashMap();
|
||||
shopProductBaseList.forEach(shopProductBase->{
|
||||
if(StringUtils.isNotEmpty(shopProductBase.getProduct_number())){
|
||||
resultMap.put(String.valueOf(shopProductBase.getProduct_number()),shopProductBase.getProduct_id());
|
||||
List<ShopProductBase> shopProductBaseList = this.list(queryWrapper);
|
||||
Map<String, Long> resultMap = new HashMap();
|
||||
shopProductBaseList.forEach(shopProductBase -> {
|
||||
if (StringUtils.isNotEmpty(shopProductBase.getProduct_number())) {
|
||||
resultMap.put(String.valueOf(shopProductBase.getProduct_number()), shopProductBase.getProduct_id());
|
||||
}
|
||||
});
|
||||
return resultMap;
|
||||
@ -6149,72 +6147,66 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
//商品状态:1001-正常;1002-下架仓库中;1003-待审核; 1000-违规禁售,1003
|
||||
int taskCount = 5;
|
||||
CompletableFuture<Integer> count1 = CompletableFuture.supplyAsync(() -> {
|
||||
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
|
||||
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
|
||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
||||
}
|
||||
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
||||
return ((int) shopProductIndexService.count(queryWrapper));
|
||||
});
|
||||
CompletableFuture<Integer> count2 = CompletableFuture.supplyAsync(() -> {
|
||||
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
|
||||
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
|
||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
||||
}
|
||||
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_NORMAL);
|
||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_NORMAL);
|
||||
return ((int) shopProductIndexService.count(queryWrapper));
|
||||
});
|
||||
CompletableFuture<Integer> count3 = CompletableFuture.supplyAsync(() -> {
|
||||
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
|
||||
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
|
||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
||||
}
|
||||
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_OFF_THE_SHELF);
|
||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_OFF_THE_SHELF);
|
||||
return ((int) shopProductIndexService.count(queryWrapper));
|
||||
});
|
||||
CompletableFuture<Integer> count4 = CompletableFuture.supplyAsync(() -> {
|
||||
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
|
||||
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
|
||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
||||
}
|
||||
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_ILLEGAL);
|
||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_ILLEGAL);
|
||||
return ((int) shopProductIndexService.count(queryWrapper));
|
||||
});
|
||||
CompletableFuture<Integer> count5 = CompletableFuture.supplyAsync(() -> {
|
||||
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
|
||||
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
|
||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
||||
}
|
||||
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK);
|
||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK);
|
||||
return ((int) shopProductIndexService.count(queryWrapper));
|
||||
});
|
||||
|
||||
// 等待所有任务完成
|
||||
CompletableFuture<Void> allFutures = CompletableFuture.allOf(count1, count2, count3,count4,count5);
|
||||
CompletableFuture<Void> allFutures = CompletableFuture.allOf(count1, count2, count3, count4, count5);
|
||||
allFutures.thenRun(() -> {
|
||||
logger.info("所有统计任务完成");
|
||||
});
|
||||
Integer[] resultInt=new Integer[taskCount];
|
||||
Integer[] resultInt = new Integer[taskCount];
|
||||
try {
|
||||
resultInt[0]=count1.get();
|
||||
resultInt[1]=count2.get();
|
||||
resultInt[2]=count3.get();
|
||||
resultInt[3]=count4.get();
|
||||
resultInt[4]=count5.get();
|
||||
resultInt[0] = count1.get();
|
||||
resultInt[1] = count2.get();
|
||||
resultInt[2] = count3.get();
|
||||
resultInt[3] = count4.get();
|
||||
resultInt[4] = count5.get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return resultInt;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
AtomicInteger count1=new AtomicInteger(0);//全部
|
||||
System.out.println(count1.addAndGet(10));
|
||||
System.out.println(count1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
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.pojo.res.ThirdApiRes;
|
||||
import com.suisung.mall.common.utils.SseEmitterUtil;
|
||||
@ -71,6 +72,10 @@ public class SFExpressController {
|
||||
@ApiOperation(value = "查询顺丰同城订单状态流", notes = "查询顺丰同城订单状态流")
|
||||
@RequestMapping(value = "/list-order-feed", method = RequestMethod.POST)
|
||||
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<>();
|
||||
params.put("order_id", shopStoreSfOrderService.getSfOrderIdByShopOrderId(orderId));
|
||||
return sfExpressApiService.listOrderFeed(params);
|
||||
|
||||
@ -313,7 +313,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
// List<String> orderList = new ArrayList<>();
|
||||
// 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) {
|
||||
throw new ApiException(I18nUtil._("取消商家订单失败!"));
|
||||
}
|
||||
@ -578,7 +578,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
|
||||
// 重要:订单取消
|
||||
// success = shopOrderBaseService.cancel(orderList, null, false);
|
||||
success = shopOrderReturnService.sfExpressExpiredForceRefund(shopOrderId, 0);
|
||||
success = shopOrderReturnService.sfExpressExpiredForceRefund(shopOrderId);
|
||||
if (!success) {
|
||||
return new ThirdApiRes().fail(-1, "取消订单业务处理失败!");
|
||||
}
|
||||
|
||||
@ -1315,7 +1315,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
ShopMchEntry merchantEntryUpd = new ShopMchEntry();
|
||||
merchantEntryUpd.setId(merchantEntry.getId());
|
||||
merchantEntryUpd.setApproval_status(CommonConstant.MCH_APPR_STA_PASS); // 设置审批状态为已通过
|
||||
merchantEntryUpd.setApproval_remark("入驻流程已全部完成!"); // 设置审批备注
|
||||
merchantEntryUpd.setApproval_remark("已全部完成入驻流程!"); // 设置审批备注
|
||||
boolean updateResult = updateById(merchantEntry); // 更新商户入驻信息
|
||||
if (!updateResult) {
|
||||
log.error("更新商户入驻信息状态失败, merchantId={}", merchantEntry.getId());
|
||||
|
||||
18
pom.xml
18
pom.xml
@ -317,18 +317,18 @@
|
||||
<!-- sentinel配置 -->
|
||||
<sentinel.transport.dashboard>114.132.210.208:8718</sentinel.transport.dashboard>
|
||||
<!-- 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.port>3306</mysql.port>-->
|
||||
<!-- <mysql.db>mall_prod</mysql.db>-->
|
||||
<!-- <mysql.user>root</mysql.user>-->
|
||||
<!-- <mysql.pwd>J0XivNvAcR14}pA6Cysm.E17</mysql.pwd>-->
|
||||
<!-- <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.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.host>114.132.210.208</redis.host>
|
||||
<redis.database>15</redis.database>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user