会员定时任务
This commit is contained in:
parent
ac7af967a1
commit
c7f5acf2e1
|
|
@ -15,6 +15,8 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单定时任务
|
* 订单定时任务
|
||||||
*
|
*
|
||||||
|
|
@ -23,7 +25,7 @@ import org.springframework.stereotype.Component;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class MemberDeliverTask {
|
public class MemberTask {
|
||||||
@Resource
|
@Resource
|
||||||
private OrderInfoService orderInfoService;
|
private OrderInfoService orderInfoService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
|
|
@ -36,10 +38,19 @@ public class MemberDeliverTask {
|
||||||
* order 过期
|
* order 过期
|
||||||
*/
|
*/
|
||||||
// @Scheduled(cron = "0 0 1 * * ? ")
|
// @Scheduled(cron = "0 0 1 * * ? ")
|
||||||
public void run() {
|
public void deliver() {
|
||||||
shopUserService.list(new QueryWrapper().eq(ShopUser::getIsVip, 1).lt(ShopUser::getNextDeliverTime, DateUtil.date().toLocalDateTime())).forEach(item -> {
|
shopUserService.list(new QueryWrapper().eq(ShopUser::getIsVip, 1).lt(ShopUser::getNextDeliverTime, DateUtil.date().toLocalDateTime())).forEach(item -> {
|
||||||
memberConfigService.deliver(item.getSourceShopId(), item.getUserId(), TableValueConstant.MemberExpFlow.Type.MEMBER_TASK, null, null, null);
|
memberConfigService.deliver(item.getSourceShopId(), item.getUserId(), TableValueConstant.MemberExpFlow.Type.MEMBER_TASK, null, null, null);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void check() {
|
||||||
|
List<ShopUser> shopUsers = shopUserService.list(new QueryWrapper().isNotNull(ShopUser::getEndTime).eq(ShopUser::getIsVip, 1).lt(ShopUser::getEndTime, DateUtil.date()));
|
||||||
|
shopUsers.forEach(item -> {
|
||||||
|
item.setIsVip(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
shopUserService.updateBatch(shopUsers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +38,7 @@ public interface TbMemberConfigService extends IService<TbMemberConfig> {
|
||||||
* @return 是否加入成功
|
* @return 是否加入成功
|
||||||
*/
|
*/
|
||||||
boolean joinMember(Long shopId, Long userId, Long memberOrderId);
|
boolean joinMember(Long shopId, Long userId, Long memberOrderId);
|
||||||
boolean joinMemberByCOndition(Long shopId, Long userId);
|
boolean joinMemberByCondition(Long shopId, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发放会员奖励
|
* 发放会员奖励
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,7 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean joinMemberByCOndition(Long shopId, Long userId) {
|
public boolean joinMemberByCondition(Long shopId, Long userId) {
|
||||||
MemberConfigVO memberConfigVO = detail(shopId);
|
MemberConfigVO memberConfigVO = detail(shopId);
|
||||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getSourceShopId, shopId).eq(ShopUser::getUserId, userId));
|
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getSourceShopId, shopId).eq(ShopUser::getUserId, userId));
|
||||||
if (shopUser == null) {
|
if (shopUser == null) {
|
||||||
|
|
|
||||||
|
|
@ -838,6 +838,9 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||||
}
|
}
|
||||||
upOrderInfo(orderInfo, new BigDecimal(czgCallBackDto.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN),
|
upOrderInfo(orderInfo, new BigDecimal(czgCallBackDto.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN),
|
||||||
DateUtil.parseLocalDateTime(czgCallBackDto.getPayTime()), payment.getId(), null);
|
DateUtil.parseLocalDateTime(czgCallBackDto.getPayTime()), payment.getId(), null);
|
||||||
|
|
||||||
|
// 会员加入
|
||||||
|
memberConfigService.joinMemberByCondition(orderInfo.getShopId(), orderInfo.getUserId());
|
||||||
} else if ("memberIn".equals(payment.getPayType()) || "free".equals(payment.getPayType())) {
|
} else if ("memberIn".equals(payment.getPayType()) || "free".equals(payment.getPayType())) {
|
||||||
boolean isFree = "free".equals(payment.getPayType());
|
boolean isFree = "free".equals(payment.getPayType());
|
||||||
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
|
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue