Compare commits
2 Commits
951050da3d
...
99af352328
| Author | SHA1 | Date | |
|---|---|---|---|
| 99af352328 | |||
| c6736d120d |
@ -7,6 +7,7 @@ import com.suisung.mall.shop.config.SpringUtil;
|
||||
import com.suisung.mall.shop.distribution.service.ShopDistributionUserOrderService;
|
||||
import com.suisung.mall.shop.order.service.ShopOrderBaseService;
|
||||
import com.suisung.mall.shop.order.service.ShopOrderInfoService;
|
||||
import com.suisung.mall.shop.sixun.utils.CommonUtil;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
@ -23,6 +24,8 @@ public class UpdateOrderStatusJob extends QuartzJobBean {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UpdateOrderStatusJob.class);
|
||||
|
||||
private static final Integer PAGESIZE = 100;
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
ShopOrderBaseService shopOrderBaseService = SpringUtil.getBean(ShopOrderBaseService.class);
|
||||
@ -36,51 +39,52 @@ public class UpdateOrderStatusJob extends QuartzJobBean {
|
||||
//shopOrderBaseService.autoCancelOrder();
|
||||
|
||||
// 更新未付款订单,取消超时订单
|
||||
List<String> order_id_row = shopOrderInfoService.getAutoCancelOrderId();
|
||||
if (CollUtil.isNotEmpty(order_id_row)) {
|
||||
for (String order_id : order_id_row) {
|
||||
try {
|
||||
List<String> ids = Collections.singletonList(order_id);
|
||||
if (!shopOrderBaseService.cancel(ids, null, true)) {
|
||||
LogUtil.error(String.format(I18nUtil._("order_id : %s 取消出错"), order_id));
|
||||
long total = shopOrderInfoService.countgetAutoCancelOrderId();
|
||||
if (total > 0) {
|
||||
int pages = CommonUtil.getPagesCount(Math.toIntExact(total), PAGESIZE);
|
||||
for (int i = 1; i <= pages; i++) {
|
||||
List<String> order_id_row = shopOrderInfoService.getAutoCancelOrderIdByPage(i, PAGESIZE);
|
||||
for (String order_id : order_id_row) {
|
||||
try {
|
||||
List<String> ids = Collections.singletonList(order_id);
|
||||
if (!shopOrderBaseService.cancel(ids, null, true)) {
|
||||
LogUtil.error(String.format(I18nUtil._("order_id : %s 取消出错"), order_id));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(String.format(I18nUtil._("order_id : %s 取消出错"), order_id), e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(String.format(I18nUtil._("order_id : %s 取消出错"), order_id), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 自动确认收货
|
||||
//shopOrderBaseService.autoReceive();
|
||||
|
||||
// 自动确认收货
|
||||
//shopOrderBaseService.autoReceive();
|
||||
|
||||
|
||||
// 2. 更新为确认收货
|
||||
List<String> order_id_receipt = shopOrderInfoService.getAutoFinishOrderId();
|
||||
if (CollUtil.isNotEmpty(order_id_receipt)) {
|
||||
for (String order_id : order_id_receipt) {
|
||||
try {
|
||||
if (!shopOrderBaseService.receive(order_id, null)) {
|
||||
LogUtil.error(String.format(I18nUtil._("order_id : %s 确认收货出错"), order_id));
|
||||
// 2. 更新为确认收货
|
||||
List<String> order_id_receipt = shopOrderInfoService.getAutoFinishOrderId();
|
||||
if (CollUtil.isNotEmpty(order_id_receipt)) {
|
||||
for (String order_id : order_id_receipt) {
|
||||
try {
|
||||
if (!shopOrderBaseService.receive(order_id, null)) {
|
||||
LogUtil.error(String.format(I18nUtil._("order_id : %s 确认收货出错"), order_id));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(String.format(I18nUtil._("order_id : %s 确认收货出错"), order_id), e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(String.format(I18nUtil._("order_id : %s 确认收货出错"), order_id), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3.分销结算
|
||||
List<String> order_id_settle_commission = shopOrderBaseService.getWaitingSettleCommissionOrder(null, null);
|
||||
if (CollUtil.isNotEmpty(order_id_settle_commission)) {
|
||||
for (String order_id : order_id_settle_commission) {
|
||||
try {
|
||||
if (!shopDistributionUserOrderService.settleDistributionUserOrder(order_id)) {
|
||||
LogUtil.error(String.format(I18nUtil._("order_id : %s 确认佣金结算出错"), order_id));
|
||||
// 3.分销结算
|
||||
List<String> order_id_settle_commission = shopOrderBaseService.getWaitingSettleCommissionOrder(null, null);
|
||||
if (CollUtil.isNotEmpty(order_id_settle_commission)) {
|
||||
for (String order_id : order_id_settle_commission) {
|
||||
try {
|
||||
if (!shopDistributionUserOrderService.settleDistributionUserOrder(order_id)) {
|
||||
LogUtil.error(String.format(I18nUtil._("order_id : %s 确认佣金结算出错"), order_id));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(String.format(I18nUtil._("order_id : %s 确认佣金结算出错"), order_id), e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(String.format(I18nUtil._("order_id : %s 确认佣金结算出错"), order_id), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -89,4 +89,17 @@ public interface ShopOrderInfoService extends IBaseService<ShopOrderInfo> {
|
||||
*/
|
||||
Boolean updateOrderReceived(String orderId);
|
||||
|
||||
/**
|
||||
* 分页查询取消订单
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
List<String> getAutoCancelOrderIdByPage(Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 查询取消订单总数
|
||||
* @return
|
||||
*/
|
||||
long countgetAutoCancelOrderId();
|
||||
}
|
||||
|
||||
@ -56,6 +56,7 @@ import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||
|
||||
@ -180,6 +181,9 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
return Convert.toList(String.class, findKey(queryWrapper));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取能自动确认收货的订单号
|
||||
*
|
||||
@ -781,4 +785,36 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getAutoCancelOrderIdByPage(Integer pageNum, Integer pageSize) {
|
||||
QueryWrapper<ShopOrderInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("order_id","order_state_id");
|
||||
queryWrapper.eq("order_state_id", StateCode.ORDER_STATE_WAIT_PAY)
|
||||
.eq("order_is_paid", StateCode.ORDER_PAID_STATE_NO)
|
||||
.eq("payment_type_id", StateCode.PAYMENT_TYPE_ONLINE);
|
||||
|
||||
Float order_autocancel_time = accountBaseConfigService.getConfig("order_autocancel_time", 0.5f);
|
||||
int second = NumberUtil.mul(order_autocancel_time, 60, 60).intValue();
|
||||
long time = DateUtil.offsetSecond(new Date(), -second).getTime();
|
||||
queryWrapper.lt("order_time", time);
|
||||
List<ShopOrderInfo> shopOrderInfos=this.lists(queryWrapper,pageNum,pageSize).getRecords();
|
||||
return shopOrderInfos.stream().map(ShopOrderInfo::getOrder_id).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countgetAutoCancelOrderId() {
|
||||
QueryWrapper<ShopOrderInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_state_id", StateCode.ORDER_STATE_WAIT_PAY)
|
||||
.eq("order_is_paid", StateCode.ORDER_PAID_STATE_NO)
|
||||
.eq("payment_type_id", StateCode.PAYMENT_TYPE_ONLINE);
|
||||
|
||||
Float order_autocancel_time = accountBaseConfigService.getConfig("order_autocancel_time", 0.5f);
|
||||
int second = NumberUtil.mul(order_autocancel_time, 60, 60).intValue();
|
||||
long time = DateUtil.offsetSecond(new Date(), -second).getTime();
|
||||
queryWrapper.lt("order_time", time);
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -58,6 +58,7 @@ import com.suisung.mall.shop.sfexpress.service.SFExpressApiService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreConfigService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreShippingAddressService;
|
||||
import com.suisung.mall.shop.sync.service.SyncThirdDataService;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
@ -203,6 +204,9 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
|
||||
@Autowired
|
||||
private SyncThirdDataService syncThirdDataService;
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> statisticState() {
|
||||
UserDto user = getCurrentUser();
|
||||
@ -1506,6 +1510,13 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
throw new ApiException(I18nUtil._("增加库存失败!"));
|
||||
}
|
||||
logger.debug("成功增加商品库存,商品项ID: {}, 增加数量: {}", itemId, returnNum);
|
||||
|
||||
//todo 退货新增返还思迅库存
|
||||
Map<String, Integer> stockDeltaMap = new HashMap<>();
|
||||
String item_src_id= productItem.getItem_src_id();
|
||||
stockDeltaMap.put(item_src_id + "-" + shopOrderItem.getOrder_id(), returnNum);
|
||||
syncThirdDataService.incrProductStockToRedis(stockDeltaMap);
|
||||
logger.info("退货返回给思迅,存入redis成功,item_src_id:{},订单号:{},数量:{}",item_src_id,shopOrderReturn.getOrder_id(),returnNum);
|
||||
} else {
|
||||
logger.warn("退货数量为空,无法增加库存,订单项ID: {}", orderItemId);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user