Commit 6cb8abef authored by liwei's avatar liwei

Merge remote-tracking branch 'origin/master'

parents 631e5bc5 2716b404
...@@ -57,7 +57,7 @@ public class AppOrderController extends CyPaginationController<CmsOrder> { ...@@ -57,7 +57,7 @@ public class AppOrderController extends CyPaginationController<CmsOrder> {
@CyOpeLogAnno(title = "system-订单信息表管理-活动下单", businessType = CyLogTypeEnum.INSERT) @CyOpeLogAnno(title = "system-订单信息表管理-活动下单", businessType = CyLogTypeEnum.INSERT)
@Operation(summary="活动下单", description="活动下单") @Operation(summary="活动下单", description="活动下单")
@PostMapping(value = "/order/add") @PostMapping(value = "/order/add")
public CyResult add(@Valid CmsOrder cmsOrder, BindingResult bindingResult) { public CyResult add(@Valid @RequestBody CmsOrder cmsOrder, BindingResult bindingResult) {
CyPersistModel data = cmsOrderServiceImpl.persist(cmsOrder); CyPersistModel data = cmsOrderServiceImpl.persist(cmsOrder);
return CyResultGenUtil.builder(data, return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS, CyMessCons.MESSAGE_ALERT_SUCCESS,
......
...@@ -19,11 +19,13 @@ import org.redisson.api.RLock; ...@@ -19,11 +19,13 @@ import org.redisson.api.RLock;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -44,7 +46,7 @@ public class CmsActivityServiceImpl extends ServiceImpl<CmsActivityRepository, C ...@@ -44,7 +46,7 @@ public class CmsActivityServiceImpl extends ServiceImpl<CmsActivityRepository, C
@Autowired @Autowired
private RedissonClient redissonClient; private RedissonClient redissonClient;
@Autowired @Autowired
private RedisTemplate redisTemplate; private StringRedisTemplate redisTemplate;
/** /**
* 保存 活动 * 保存 活动
* *
......
...@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service; ...@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPool;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -37,7 +38,7 @@ public class StockService { ...@@ -37,7 +38,7 @@ public class StockService {
* Redis 客户端 * Redis 客户端
*/ */
@Autowired @Autowired
private RedisTemplate redisTemplate; private RedisTemplate<String, Object> redisTemplate;
/** /**
* 执行扣库存的脚本 * 执行扣库存的脚本
......
...@@ -28,6 +28,7 @@ import org.redisson.api.RLock; ...@@ -28,6 +28,7 @@ import org.redisson.api.RLock;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
...@@ -42,6 +43,8 @@ import java.util.concurrent.atomic.AtomicReference; ...@@ -42,6 +43,8 @@ import java.util.concurrent.atomic.AtomicReference;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
/** /**
* Created by cy on 2025年1月6日 下午1:44:44. * Created by cy on 2025年1月6日 下午1:44:44.
*/ */
...@@ -71,7 +74,7 @@ public class CmsOrderServiceImpl extends ServiceImpl<CmsOrderRepository,CmsOrder ...@@ -71,7 +74,7 @@ public class CmsOrderServiceImpl extends ServiceImpl<CmsOrderRepository,CmsOrder
private CmsActivityRepository activityRepository; private CmsActivityRepository activityRepository;
@Autowired @Autowired
private RedisTemplate redisTemplate; private StringRedisTemplate redisTemplate;
@Autowired @Autowired
CyIdGenUtil cyIdGenUtil; CyIdGenUtil cyIdGenUtil;
...@@ -154,7 +157,8 @@ public class CmsOrderServiceImpl extends ServiceImpl<CmsOrderRepository,CmsOrder ...@@ -154,7 +157,8 @@ public class CmsOrderServiceImpl extends ServiceImpl<CmsOrderRepository,CmsOrder
orderInfo.setBusinessId(orderId); orderInfo.setBusinessId(orderId);
orderInfo.setName(info.getTitle()); orderInfo.setName(info.getTitle());
// orderInfo.setGoodsId(orderGoodsDto.getGoodsId()); // orderInfo.setGoodsId(orderGoodsDto.getGoodsId());
orderInfo.setUserId(Integer.valueOf(CyUserUtil.getAuthenBusinessId())); String userId = CyUserUtil.getAuthenBusinessId();
orderInfo.setUserId(Integer.valueOf(userId));
orderInfo.setAccount(CyUserUtil.getAuthenUsername()); orderInfo.setAccount(CyUserUtil.getAuthenUsername());
// orderInfo.setNum(orderInfo.getNum()); // orderInfo.setNum(orderInfo.getNum());
//计算价格 -开始 //计算价格 -开始
...@@ -182,7 +186,7 @@ public class CmsOrderServiceImpl extends ServiceImpl<CmsOrderRepository,CmsOrder ...@@ -182,7 +186,7 @@ public class CmsOrderServiceImpl extends ServiceImpl<CmsOrderRepository,CmsOrder
} }
//初始化redis 活动数 //初始化redis 活动数
private int initStock(long goodsId) { private int initStock(Integer goodsId) {
CmsActivity info = activityRepository.selectById(goodsId); CmsActivity info = activityRepository.selectById(goodsId);
//redis ttl 活动结束时间+1天 //redis ttl 活动结束时间+1天
Date endTime = TimeUtil.getTime(info.getEndTime(), Calendar.DATE, 1); Date endTime = TimeUtil.getTime(info.getEndTime(), Calendar.DATE, 1);
......
...@@ -21,6 +21,7 @@ import org.redisson.api.RedissonClient; ...@@ -21,6 +21,7 @@ import org.redisson.api.RedissonClient;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -67,7 +68,7 @@ public class AsyncFactory ...@@ -67,7 +68,7 @@ public class AsyncFactory
AtomicReference<Integer> num = new AtomicReference<>(info.getMaxApplicationCount()); AtomicReference<Integer> num = new AtomicReference<>(info.getMaxApplicationCount());
//已报名人数计算: 数据库+ redis【order:activity:${所有}】 value 【hash】未取消 的并集 //已报名人数计算: 数据库+ redis【order:activity:${所有}】 value 【hash】未取消 的并集
QueryWrapper<CmsOrder> wrapper = new QueryWrapper<>(); QueryWrapper<CmsOrder> wrapper = new QueryWrapper<>();
wrapper.eq("activity_id", id); wrapper.eq("goods_id", id);
wrapper.notIn("status", 1, 2, 3, 4, 5, 6, 7, 10); wrapper.notIn("status", 1, 2, 3, 4, 5, 6, 7, 10);
wrapper.eq("del_flag", 0); wrapper.eq("del_flag", 0);
List<CmsOrder> orderList = CySpringBeanComp.getBean(CmsOrderRepository.class).selectList(wrapper); List<CmsOrder> orderList = CySpringBeanComp.getBean(CmsOrderRepository.class).selectList(wrapper);
...@@ -75,7 +76,7 @@ public class AsyncFactory ...@@ -75,7 +76,7 @@ public class AsyncFactory
num.set(num.get() - orderInfo.getNum()); num.set(num.get() - orderInfo.getNum());
} }
List<Long> orderIds = orderList.stream().map(CmsOrder::getBusinessId).toList(); List<Long> orderIds = orderList.stream().map(CmsOrder::getBusinessId).toList();
Set<String> map = CySpringBeanComp.getBean(RedisTemplate.class).keys(RedisCons.ORDER_ACTIVITY + ":" + id + "*"); Set<String> map = CySpringBeanComp.getBean(StringRedisTemplate.class).keys(RedisCons.ORDER_ACTIVITY + ":" + id + "*");
if (CollectionUtils.isNotEmpty(map)) { if (CollectionUtils.isNotEmpty(map)) {
//遍历获取对应报名量 //遍历获取对应报名量
map.forEach(m -> { map.forEach(m -> {
......
...@@ -25,12 +25,14 @@ import org.redisson.api.RedissonClient; ...@@ -25,12 +25,14 @@ import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
...@@ -49,7 +51,7 @@ public class OrderSyncSchedule { ...@@ -49,7 +51,7 @@ public class OrderSyncSchedule {
private CyRedisService cyRedisServiceImpl; private CyRedisService cyRedisServiceImpl;
@Autowired @Autowired
private RedisTemplate redisTemplate; private StringRedisTemplate redisTemplate;
// @Autowired // @Autowired
// private CouponInfoRepository couponInfoRepository; // private CouponInfoRepository couponInfoRepository;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment