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

Commit 15946514 authored by 姜秀龙's avatar 姜秀龙

场次限购-order 实名限购逻辑

parent 37e2bb64
......@@ -62,6 +62,7 @@ public class KylinRedisConst {
public static final String IDCARD_BUY_INFO = "kylin:buy:idCard:";
public static final String PERFORMANCE_ID = "performanceId";
public static final String TICKET_ID = "ticketId";
public static final String TIME_ID = "timeId";
public static final String USE_TIME = "useTime";
public static final String BUY_COUNT = "buyCount";
......
......@@ -255,6 +255,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
}
// 获取限购 实名
Integer timeRealNameLimit = ticketTimesData.getRealNameLimit();
int ticketLimit = 1;
int ticketMemberLimit = ticketData.getLimitCountMember();//会员票种限购
int ticketIdCount = ticketData.getIdCount();//实名票种限购
......@@ -399,11 +400,11 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
//限购判断 如果实名 则身份证维度限购 如果不实名则数量限购
if (entersVoList.size() > 0) {
for (int i = 0; i < entersVoList.size(); i++) {
dataUtils.changeBuyInfo(uid, entersVoList.get(i).getIdCard(), performanceData.getPerformancesId(), ticketData.getTicketsId(), 1);
String res1 = orderUtils.judgeOrderLimit(uid, entersVoList.get(i).getIdCard(), payOrderParam.getPerformanceId(), payOrderParam.getTicketId(), performanceLimit, performanceMemberLimit, performanceIdCount, ticketLimit, ticketMemberLimit, ticketIdCount, memberType, isTrueName);
dataUtils.changeBuyInfo(uid, entersVoList.get(i).getIdCard(), performanceData.getPerformancesId(), ticketData.getTicketsId(), payOrderParam.getTimeId(), 1);
String res1 = orderUtils.judgeOrderLimit(uid, entersVoList.get(i).getIdCard(), payOrderParam.getPerformanceId(), payOrderParam.getTicketId(), payOrderParam.getTimeId(), performanceLimit, performanceMemberLimit, performanceIdCount, ticketLimit, ticketMemberLimit, ticketIdCount, timeRealNameLimit, memberType, isTrueName);
if (!res1.equals("")) {
for (int x = 0; x <= i; x++) {
dataUtils.changeBuyInfo(uid, entersVoList.get(x).getIdCard(), performanceData.getPerformancesId(), ticketData.getTicketsId(), -1);
dataUtils.changeBuyInfo(uid, entersVoList.get(x).getIdCard(), performanceData.getPerformancesId(), ticketData.getTicketsId(), payOrderParam.getTimeId(), -1);
}
orderUtils.changeSurplus(isPay, payOrderParam.getTicketId(), payOrderParam.getNumber());
orderUtils.backAdvanceCoupon(payOrderParam.getAdvanceCode(), uid);
......@@ -411,10 +412,10 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
}
}
} else {
dataUtils.changeBuyInfo(uid, "", performanceData.getPerformancesId(), ticketData.getTicketsId(), payOrderParam.getNumber());
String res1 = orderUtils.judgeOrderLimit(uid, "", payOrderParam.getPerformanceId(), payOrderParam.getTicketId(), performanceLimit, performanceMemberLimit, performanceIdCount, ticketLimit, ticketMemberLimit, ticketIdCount, memberType, isTrueName);
dataUtils.changeBuyInfo(uid, "", performanceData.getPerformancesId(), ticketData.getTicketsId(), payOrderParam.getTimeId(), payOrderParam.getNumber());
String res1 = orderUtils.judgeOrderLimit(uid, "", payOrderParam.getPerformanceId(), payOrderParam.getTicketId(), payOrderParam.getTimeId(), performanceLimit, performanceMemberLimit, performanceIdCount, ticketLimit, ticketMemberLimit, ticketIdCount, timeRealNameLimit, memberType, isTrueName);
if (!res1.equals("")) {
dataUtils.changeBuyInfo(uid, "", performanceData.getPerformancesId(), ticketData.getTicketsId(), -payOrderParam.getNumber());
dataUtils.changeBuyInfo(uid, "", performanceData.getPerformancesId(), ticketData.getTicketsId(), payOrderParam.getTimeId(), -payOrderParam.getNumber());
orderUtils.changeSurplus(isPay, payOrderParam.getTicketId(), payOrderParam.getNumber());
orderUtils.backAdvanceCoupon(payOrderParam.getAdvanceCode(), uid);
return ResponseDto.failure(res1);//乱七八糟异常
......@@ -435,11 +436,11 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsOrderServ
dataUtils.decrUseCouponCount(uid, performanceId);
}
for (AdamEntersVo enters : entersVoList) {
dataUtils.changeBuyInfo(uid, enters.getIdCard(), payOrderParam.getPerformanceId(), payOrderParam.getTicketId(), -1);
dataUtils.changeBuyInfo(uid, enters.getIdCard(), payOrderParam.getPerformanceId(), payOrderParam.getTicketId(), payOrderParam.getTimeId(), -1);
}
if (entersVoList.size() == 0) {
for (int i = 0; i < payOrderParam.getNumber(); i++) {
dataUtils.changeBuyInfo(uid, "", payOrderParam.getPerformanceId(), payOrderParam.getTicketId(), -1);
dataUtils.changeBuyInfo(uid, "", payOrderParam.getPerformanceId(), payOrderParam.getTicketId(), payOrderParam.getTimeId(), -1);
}
}
}
......
......@@ -130,11 +130,12 @@ public class DataUtils {
* @param ticketId 票种id
* @param buyCount 购买数量 大于 0 增加 小于 0 减少 对应 支付 退款表
*/
public void changeBuyInfo(String userId, String idCard, String performanceId, String ticketId, int buyCount) {
public void changeBuyInfo(String userId, String idCard, String performanceId, String ticketId, String timeId, int buyCount) {
String redisKeyUid;
String redisKeyIdCard;
String performanceIdKeyIdCard = "";
String ticketIdKeyIdCard = "";
String timeIdKeyIdCard = "";
int isTrueName = getPerformanceIsTrueName(performanceId);
......@@ -146,6 +147,7 @@ public class DataUtils {
performanceIdKeyIdCard = redisKeyIdCard + ":" + KylinRedisConst.PERFORMANCE_ID + ":" + performanceId;
ticketIdKeyIdCard = redisKeyIdCard + ":" + KylinRedisConst.TICKET_ID + ":" + ticketId;
}
timeIdKeyIdCard = redisKeyIdCard + ":" + KylinRedisConst.TIME_ID + ":" + timeId;
if (buyCount > 0) {
redisUtil.incr(ticketIdKeyUid, buyCount);
......@@ -154,7 +156,9 @@ public class DataUtils {
redisUtil.incr(ticketIdKeyIdCard, buyCount);
redisUtil.incr(performanceIdKeyIdCard, buyCount);
}
redisUtil.incr(timeIdKeyIdCard, buyCount);
} else {
redisUtil.decr(timeIdKeyIdCard, Math.abs(buyCount));
if (isTrueName != 0) {
redisUtil.decr(ticketIdKeyIdCard, Math.abs(buyCount));
redisUtil.decr(performanceIdKeyIdCard, Math.abs(buyCount));
......@@ -202,6 +206,15 @@ public class DataUtils {
}
}
// 获取 证件维度 场次购买数量
public int getIdCardMBuyCount(String idCard, String timeId) {
try {
return (int) redisUtil.get(KylinRedisConst.IDCARD_BUY_INFO + idCard + ":" + KylinRedisConst.TIME_ID + ":" + timeId);
} catch (Exception e) {
return 0;
}
}
/**
* 删除订单redis
*
......
......@@ -51,19 +51,22 @@ public class OrderUtils {
String idCard,
String performanceId,
String ticketId,
String timeId,
int performanceLimitCount,
int performanceMemberLimitCount,
int performanceLimitIdCard,
int ticketLimitCount,
int ticketMemberLimitCount,
int ticketLimitIdCard,
int timeRealNameLimit,
int memberType,
int isTrueName
) {
Integer[] integers = orderLimit(userId, idCard, performanceId, ticketId, isTrueName);
Integer[] integers = orderLimit(userId, idCard, performanceId, ticketId, timeId, isTrueName);
return judgeMemberType(performanceLimitCount, performanceMemberLimitCount, performanceLimitIdCard,
ticketLimitCount, ticketMemberLimitCount, ticketLimitIdCard,
memberType, integers[0], integers[1], integers[2], integers[3], isTrueName);
ticketLimitCount, ticketMemberLimitCount, ticketLimitIdCard, timeRealNameLimit,
memberType, integers[0], integers[1], integers[2], integers[3], integers[4], isTrueName);
}
public Integer[] orderLimit(
......@@ -71,34 +74,46 @@ public class OrderUtils {
String idCard,
String performanceId,
String ticketId,
String timeId,
int isTrueName
) {
int performanceBuyCountUid = 0;
int ticketBuyCountUid = 0;
int performanceBuyCountIdCard = 0;
int ticketBuyCountIdCard = 0;
int timeBuyCountIdCard = 0;
if (1 == isTrueName) {//实名
performanceBuyCountIdCard = dataUtils.getIdCardPBuyCount(idCard, performanceId);
ticketBuyCountIdCard = dataUtils.getIdCardTBuyCount(idCard, ticketId);
performanceBuyCountUid = dataUtils.getUserPBuyCount(userId, performanceId);
ticketBuyCountUid = dataUtils.getUserTBuyCount(userId, ticketId);
timeBuyCountIdCard = dataUtils.getIdCardMBuyCount(idCard, timeId);
} else {//非实名
performanceBuyCountUid = dataUtils.getUserPBuyCount(userId, performanceId);
ticketBuyCountUid = dataUtils.getUserTBuyCount(userId, ticketId);
}
Integer[] array = new Integer[4];
Integer[] array = new Integer[5];
array[0] = performanceBuyCountUid;
array[1] = ticketBuyCountUid;
array[2] = performanceBuyCountIdCard;
array[3] = ticketBuyCountIdCard;
array[4] = timeBuyCountIdCard;
return array;
}
public String judgeMemberType(int performanceLimitCount, int performanceMemberLimitCount, int performanceLimitIdCard,
int ticketLimitCount, int ticketMemberLimitCount, int ticketLimitIdCard, int memberType,
int performanceBuyCountUid, int ticketBuyCountUid, int performanceBuyCountIdCard, int ticketBuyCountIdCard, int isTrueName) {
int ticketLimitCount, int ticketMemberLimitCount, int ticketLimitIdCard, int timeRealNameLimit, int memberType,
int performanceBuyCountUid, int ticketBuyCountUid, int performanceBuyCountIdCard, int ticketBuyCountIdCard,
int timeBuyCountIdCard,
int isTrueName) {
if (isTrueName == 1 && timeRealNameLimit == 1) {
if (timeBuyCountIdCard > timeRealNameLimit) {
return "实名制场次限购" + timeRealNameLimit + "张,已超出";//超过场次维度购买量
}
}
if (memberType == 1 || memberType == 2) {
if (isTrueName == 1) {
......
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