记得上下班打卡 | git大法好,push需谨慎

Commit 70f3e5a0 authored by 胡佳晨's avatar 胡佳晨

修改 消费端

parent 220f28e9
......@@ -101,6 +101,11 @@ spring:
codec:
class: "org.redisson.codec.JsonJacksonCodec"
transportMode: "NIO"
data:
mongodb:
uri: mongodb://${liquidnet.mongodb.user}:${liquidnet.mongodb.pwd}@${liquidnet.mongodb.host}/?authSource=admin&maxPoolSize=2000&waitQueueMultiple=100
sslEnabled: ${liquidnet.mongodb.sslEnabled}
database: ${liquidnet.mongodb.database}
datasource:
name: ${liquidnet.mysql.database-name}
url: jdbc:mysql://${liquidnet.mysql.urlHostAndPort}/${liquidnet.mysql.database-name}?serverTimezone=UTC&characterEncoding=utf-8&useSSL=false
......
......@@ -41,6 +41,10 @@
<artifactId>liquidnet-service-kylin-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>
<build>
......
......@@ -20,9 +20,6 @@ import java.net.UnknownHostException;
import java.util.Arrays;
@Slf4j
@EnableAutoConfiguration(
exclude = {BusAutoConfiguration.class, MongoAutoConfiguration.class}
)
@SpringBootApplication(scanBasePackages = {"com.liquidnet"})
public class ServiceConsumerApplication implements CommandLineRunner {
@Autowired
......
......@@ -9,6 +9,9 @@ import com.liquidnet.service.kylin.dto.vo.mongo.KylinPerformanceVo;
import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderListVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
......@@ -20,6 +23,8 @@ public class KylinUtils {
@Autowired
private RedisUtil redisUtil;
@Autowired
private MongoTemplate mongoTemplate;
/**
* @param userId 用户id
......@@ -30,12 +35,7 @@ public class KylinUtils {
List<KylinOrderListVo> vo = new ArrayList<>();
List<KylinOrderListVo> redisVo = new ArrayList();
KylinOrderListVo voItem = new KylinOrderListVo();
KylinOrderTicketVo data;
if (dataSingle == null) {
data = (KylinOrderTicketVo) redisUtil.get(KylinRedisConst.ORDER + orderId);
} else {
data = dataSingle;
}
KylinOrderTicketVo data = dataSingle;
BeanUtils.copyProperties(data, voItem);
List<KylinOrderListVo> redisData = (List<KylinOrderListVo>) redisUtil.get(KylinRedisConst.ORDER_LIST + userId);
if (type == 1) {
......@@ -86,7 +86,7 @@ public class KylinUtils {
public void changeBuyInfo(String userId, String idCard, String performanceId, String ticketId, int buyCount) {
String redisKey;
KylinPerformanceVo vo = (KylinPerformanceVo) redisUtil.get(KylinRedisConst.PERFORMANCES + performanceId);
KylinPerformanceVo vo = getPerformanceVo(performanceId);
int isTrueName = vo.getIsTrueName();
String useTime = "";
HashMap<String, ArrayList<String>> allTicketId = new HashMap<>();
......@@ -123,57 +123,20 @@ public class KylinUtils {
redisUtil.decr(ticketIdKey, Math.abs(buyCount));
redisUtil.decr(performanceIdKey, Math.abs(buyCount));
}
}
// if (buyCount > 0) {
// redisUtil.incr(ticketIdKey, buyCount);
// if (1 == ticketType) {
// int count = 0;
// for (int i = 0; i < allTicketId.get(useTime).size(); i++) {
// String item = allTicketId.get(useTime).get(i);
// if (allTicketId.get(useTime).size() == 1) {
// redisUtil.incr(performanceIdKey, buyCount);
// break;
// }
// if (null == redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item)) {
// redisUtil.set(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item, 0);
// }
// if (i == 0) {
// count = (int) redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item);
// } else {
// if (count != (int) redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item)) {
// redisUtil.incr(performanceIdKey, buyCount);
// break;
// }
// }
// }
// } else {
// redisUtil.incr(performanceIdKey, buyCount);
// }
// } else {
// redisUtil.decr(ticketIdKey, Math.abs(buyCount));
// if (1 == ticketType) {
// int count = 0;
// for (int i = 0; i < allTicketId.get(useTime).size(); i++) {
// String item = allTicketId.get(useTime).get(i);
// if (allTicketId.get(useTime).size() == 1) {
// redisUtil.decr(performanceIdKey, Math.abs(buyCount));
// break;
// }
// if (null == redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item)) {
// redisUtil.set(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item, 0);
// }
// if (i == 0) {
// count = (int) redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item);
// } else {
// if (count != (int) redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item)) {
// redisUtil.decr(performanceIdKey, Math.abs(buyCount));
// break;
// }
// }
// }
// } else {
// redisUtil.decr(performanceIdKey, Math.abs(buyCount));
// }
// }
/**
* 根据演出id 获取 演出vo 详情
*
* @param performanceId
* @return
*/
public KylinPerformanceVo getPerformanceVo(String performanceId) {
if (redisUtil.hasKey(KylinRedisConst.PERFORMANCES + performanceId)) {
} else {
KylinPerformanceVo performanceData = mongoTemplate.findOne(Query.query(Criteria.where("performancesId").is(performanceId)), KylinPerformanceVo.class, KylinPerformanceVo.class.getSimpleName());
redisUtil.set(KylinRedisConst.PERFORMANCES + performanceId, performanceData);
}
return (KylinPerformanceVo) redisUtil.get(KylinRedisConst.PERFORMANCES + performanceId);
}
}
......@@ -111,7 +111,7 @@ public class ConsumerProcessor {
// redis 限购
for (int i = 0; i < vo.getEntitiesVoList().size(); i++) {
KylinOrderTicketEntitiesVo items = vo.getEntitiesVoList().get(i);
kylinUtils.changeBuyInfo(items.getUserId(), items.getEnterIdCode(), vo.getPerformanceId(), vo.getTicketId(), -1);
kylinUtils.changeBuyInfo(items.getUserId(), items.getEnterIdCode(), items.getPerformanceId(), items.getTicketId(), -1);
}
}
channel.basicAck(deliveryTag, false);
......
......@@ -437,7 +437,6 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
LinkedList<Object[]> sqlsDataD = null;
sqlsDataD = new LinkedList<Object[]>();
sqls.add(SqlMapping.get("kylin_order_ticket_entities.add"));
List<KylinOrderTicketEntitiesVo> entitiesVos = new ArrayList<>();
if (isTrueName == 1) {
for (AdamEntersVo enters : entersVoList) {
String orderTicketEntitiesId = IDGenerator.nextSnowId().toString();
......@@ -474,7 +473,6 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
orderTicketEntitiesVo.setChangeDate(orderTicketEntities.getCreatedAt());
currentTime = System.currentTimeMillis();
mongoTemplate.insert(orderTicketEntitiesVo, KylinOrderTicketEntitiesVo.class.getSimpleName());
entitiesVos.add(orderTicketEntitiesVo);
currentTime = System.currentTimeMillis() - currentTime;
log.debug("mongo 添加入场人 -> time:" + (currentTime) + "毫秒");
currentTime = System.currentTimeMillis();
......@@ -517,7 +515,6 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
orderTicketEntitiesVo.setChangeDate(orderTicketEntities.getCreatedAt());
currentTime = System.currentTimeMillis();
mongoTemplate.insert(orderTicketEntitiesVo, KylinOrderTicketEntitiesVo.class.getSimpleName());
entitiesVos.add(orderTicketEntitiesVo);
currentTime = System.currentTimeMillis() - currentTime;
log.debug("mongo 添加入场人 -> time:" + (currentTime) + "毫秒");
currentTime = System.currentTimeMillis();
......@@ -581,7 +578,6 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
orderTicketVo.setCreatedAt(orderTickets.getCreatedAt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
orderTicketVo.setChangeDate(orderTickets.getCreatedAt());
currentTime = System.currentTimeMillis();
orderTicketVo.setEntitiesVoList(entitiesVos);
mongoTemplate.insert(orderTicketVo, KylinOrderTicketVo.class.getSimpleName());
currentTime = System.currentTimeMillis() - currentTime;
log.debug("mongo 添加 订单 -> time:" + (currentTime) + "毫秒");
......
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