Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -57,8 +57,7 @@ public class UPpPackageController {
|
||||
*/
|
||||
@GetMapping("/detail/{id}")
|
||||
public CzgResult<PpPackageVO> getPackageDetail(@PathVariable Long id) {
|
||||
PpPackage aPackage = ppPackageService.getPackageById(id);
|
||||
return CzgResult.success(ppPackageService.convertPackageToVo(aPackage));
|
||||
return CzgResult.success(ppPackageService.getPackageDetail(id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* market服务 任务总调度
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Component
|
||||
public class AAMarketTasks {
|
||||
@@ -74,5 +73,16 @@ public class AAMarketTasks {
|
||||
smsShopMoneyTask.task();
|
||||
}
|
||||
|
||||
@Resource
|
||||
private PpPackageTask ppPackageTask;
|
||||
|
||||
/**
|
||||
* 套餐推广订单 过期
|
||||
* 每两小时 触发一次
|
||||
*/
|
||||
@Scheduled(cron = "0 24 0/2 * * ?")
|
||||
public void ppOrderExpire() {
|
||||
ppPackageTask.ppOrderExpire();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.czg.task;
|
||||
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.constants.PpPackageConstants;
|
||||
import com.czg.market.entity.PpPackageOrder;
|
||||
import com.czg.market.service.PpPackageOrderService;
|
||||
import com.czg.order.entity.GbOrder;
|
||||
import com.czg.service.RedisService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 套餐推广定时任务
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2025/12/19 10:05
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PpPackageTask {
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@Resource
|
||||
private PpPackageOrderService ppPackageOrderService;
|
||||
|
||||
/**
|
||||
* 订单 过期
|
||||
* 每两小时 触发一次
|
||||
*/
|
||||
public void ppOrderExpire() {
|
||||
// 当前系统时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 过期时间下限:当前时间往前推4小时(只查最近4小时内过期的)
|
||||
LocalDateTime expire4HoursAgo = now.minusHours(4);
|
||||
List<PpPackageOrder> expiredOrderList = ppPackageOrderService.list(QueryWrapper.create()
|
||||
.eq(PpPackageOrder::getStatus, PpPackageConstants.OrderStatus.PROCESSING)
|
||||
.le(PpPackageOrder::getExpireTime, now)
|
||||
.ge(PpPackageOrder::getExpireTime, expire4HoursAgo));
|
||||
|
||||
// 处理已过期订单
|
||||
for (PpPackageOrder expiredOrder : expiredOrderList) {
|
||||
//退款
|
||||
ppPackageOrderService.expiredOrder(expiredOrder.getId());
|
||||
}
|
||||
|
||||
//查询【当前时间往后2小时内】将要过期的订单
|
||||
LocalDateTime willExpire2HoursLater = now.plusHours(2);
|
||||
List<PpPackageOrder> willExpireOrderList = ppPackageOrderService.list(QueryWrapper.create()
|
||||
.eq(PpPackageOrder::getStatus, PpPackageConstants.OrderStatus.PROCESSING)
|
||||
.ge(PpPackageOrder::getExpireTime, now)
|
||||
.le(PpPackageOrder::getExpireTime, willExpire2HoursLater));
|
||||
// 处理将要过期订单(如推送提醒、催参团等)
|
||||
for (PpPackageOrder willExpireOrder : willExpireOrderList) {
|
||||
LocalDateTime endTime = willExpireOrder.getExpireTime();
|
||||
Duration duration = Duration.between(now, endTime);
|
||||
long seconds = duration.getSeconds();
|
||||
redisService.set(RedisCst.classKeyExpired.EXPIRED_PP_ORDER + willExpireOrder.getId(), willExpireOrder.getId(), seconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.czg.account.service.ShopTableService;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
import com.czg.market.service.AcPushEventService;
|
||||
import com.czg.market.service.MkShopCouponRecordService;
|
||||
import com.czg.market.service.PpPackageOrderService;
|
||||
import com.czg.market.service.SmsPushEventService;
|
||||
import com.czg.order.service.GbOrderService;
|
||||
import com.czg.order.service.OrderInfoCustomService;
|
||||
@@ -43,6 +44,8 @@ public class RedisKeyExpirationListener implements MessageListener {
|
||||
private AcPushEventService acPushEventService;
|
||||
@Resource
|
||||
private GbOrderService gbOrderService;
|
||||
@DubboReference
|
||||
private PpPackageOrderService ppPackageOrderService;
|
||||
|
||||
|
||||
//redis key失效监听
|
||||
@@ -79,6 +82,10 @@ public class RedisKeyExpirationListener implements MessageListener {
|
||||
log.info("监听到拼团任务过期,gb_order任务Id: {}", expiredKey);
|
||||
String eventId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_GB_ORDER.length());
|
||||
gbOrderService.expireRefund(Long.parseLong(eventId), null);
|
||||
} else if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_PP_ORDER)) {
|
||||
log.info("监听到套餐推广任务过期,pp_order任务Id: {}", expiredKey);
|
||||
String eventId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_PP_ORDER.length());
|
||||
ppPackageOrderService.expiredOrder(Long.parseLong(eventId));
|
||||
} else if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_SMS)) {
|
||||
log.info("监听到短信定时发放优惠券,sms_push_event任务Id: {}", expiredKey);
|
||||
String eventId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_SMS.length());
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PpOrderController {
|
||||
//退钱
|
||||
String refPayOrderNo = CzgRandomUtils.snowflake(OrderNoPrefixEnum.REPP);
|
||||
payService.unifyRefund(detail.getShopId(), detail.getId(), detail.getPayOrderId(), refPayOrderNo,
|
||||
StrUtil.isBlankIfStr(detail.getRefundReason()) ? "拼团退款" : detail.getRefundReason(), detail.getFinalPrice());
|
||||
StrUtil.isBlankIfStr(detail.getRefundReason()) ? "套餐推广退款" : detail.getRefundReason(), detail.getFinalPrice());
|
||||
|
||||
return CzgResult.success();
|
||||
}
|
||||
@@ -70,6 +70,7 @@ public class PpOrderController {
|
||||
|
||||
/**
|
||||
* 套餐推广-核销
|
||||
* 参数: {"verifyCode": "123456"}
|
||||
*/
|
||||
@PostMapping("checkout")
|
||||
@OperationLog("套餐推广-核销")
|
||||
|
||||
@@ -109,7 +109,11 @@ public class OTimeTask {
|
||||
@Scheduled(cron = "0 50 23 * * ? ")
|
||||
public void refundCompensate() {
|
||||
//积分 和 拼团
|
||||
List<String> ware = List.of(PayTypeConstants.SourceType.WARE, PayTypeConstants.SourceType.POINT);
|
||||
List<String> ware = List.of(
|
||||
PayTypeConstants.SourceType.WARE,
|
||||
PayTypeConstants.SourceType.POINT,
|
||||
PayTypeConstants.SourceType.PP
|
||||
);
|
||||
|
||||
LocalDateTime tenMinutesAgo = LocalDateTime.now().minusMinutes(10);
|
||||
LocalDateTime thirdDayAgo = LocalDateTime.now().minusDays(3);
|
||||
|
||||
@@ -25,6 +25,8 @@ public interface RedisCst {
|
||||
public static final String EXPIRED_COUPON = "expired:coupon:";
|
||||
//拼团 任务过期
|
||||
public static final String EXPIRED_GB_ORDER = "expired:gb:order:";
|
||||
// 套餐推广 任务过期
|
||||
public static final String EXPIRED_PP_ORDER = "expired:pp:order:";
|
||||
//短信定时发放 倒计时KEY
|
||||
public static final String EXPIRED_SMS = "expired:sms:";
|
||||
//公众号推送 倒计时KEY
|
||||
|
||||
@@ -70,4 +70,9 @@ public interface PpPackageOrderService extends IService<PpPackageOrder> {
|
||||
* 核销
|
||||
*/
|
||||
boolean checkout(String verifyCode, Long shopId);
|
||||
|
||||
/**
|
||||
* 过期订单
|
||||
*/
|
||||
void expiredOrder(Long orderId);
|
||||
}
|
||||
|
||||
@@ -48,5 +48,8 @@ public interface PpPackageService extends IService<PpPackage> {
|
||||
|
||||
PpPackage getPackageById(Long id);
|
||||
|
||||
PpPackageVO getPackageDetail(Long id);
|
||||
|
||||
PpPackageVO convertPackageToVo(PpPackage ppPackage);
|
||||
|
||||
}
|
||||
|
||||
@@ -182,4 +182,19 @@ public class PpPackageVO {
|
||||
* 已售数量
|
||||
*/
|
||||
private Integer saleNum;
|
||||
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
private String shopName;
|
||||
|
||||
/**
|
||||
* 店铺logo
|
||||
*/
|
||||
private String shopLogo;
|
||||
|
||||
/**
|
||||
* 店铺地址
|
||||
*/
|
||||
private String shopAddress;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.update.UpdateChain;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -42,6 +43,7 @@ import java.util.List;
|
||||
* @author gyj
|
||||
* @since 2025-12-18
|
||||
*/
|
||||
@Slf4j
|
||||
@DubboService
|
||||
public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper, PpPackageOrder> implements PpPackageOrderService {
|
||||
|
||||
@@ -271,4 +273,24 @@ public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper,
|
||||
|
||||
return updateById(packageOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void expiredOrder(Long orderId) {
|
||||
PpPackageOrder order = getById(orderId);
|
||||
if (order == null) {
|
||||
log.info("套餐推广 订单过期 订单不存在:Id == {}", orderId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PpPackageConstants.OrderStatus.PROCESSING.equals(order.getStatus())) {
|
||||
log.info("套餐推广 订单过期 订单状态错误:Id == {}", orderId);
|
||||
return;
|
||||
}
|
||||
|
||||
order.setStatus(PpPackageConstants.OrderStatus.TIMEOUT);
|
||||
updateById(order);
|
||||
|
||||
ppHelpRecordService.removeHelpRecord(orderId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.czg.service.market.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.czg.account.entity.ShopConfig;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.service.ShopConfigService;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.constants.PpPackageConstants;
|
||||
@@ -196,6 +197,21 @@ public class PpPackageServiceImpl extends ServiceImpl<PpPackageMapper, PpPackage
|
||||
return ppPackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PpPackageVO getPackageDetail(Long id) {
|
||||
PpPackage ppPackage = getPackageById(id);
|
||||
|
||||
PpPackageVO packageVO = convertPackageToVo(ppPackage);
|
||||
|
||||
ShopInfo shopInfo = shopInfoService.getById(ppPackage.getShopId());
|
||||
if (shopInfo != null) {
|
||||
packageVO.setShopName(shopInfo.getShopName());
|
||||
packageVO.setShopAddress(shopInfo.getAddress());
|
||||
packageVO.setShopLogo(shopInfo.getLogo());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PpPackageVO convertPackageToVo(PpPackage ppPackage) {
|
||||
PpPackageVO packageVO = new PpPackageVO();
|
||||
|
||||
Reference in New Issue
Block a user