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

Commit 5eaaf8dd authored by 胡佳晨's avatar 胡佳晨

库存回滚逻辑

parent f47abae7
...@@ -20,4 +20,5 @@ public class OrderScriptDto { ...@@ -20,4 +20,5 @@ public class OrderScriptDto {
String userId; String userId;
Integer number; Integer number;
String couponCode; String couponCode;
Integer couponType;
} }
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
<result column="number" property="number"/> <result column="number" property="number"/>
<result column="user_id" property="userId"/> <result column="user_id" property="userId"/>
<result column="coupon_code" property="couponCode"/> <result column="coupon_code" property="couponCode"/>
<result column="coupon_type" property="couponType"/>
</resultMap> </resultMap>
<select id="getPerformanceRefundOrderStatis" resultType="java.util.HashMap"> <select id="getPerformanceRefundOrderStatis" resultType="java.util.HashMap">
...@@ -267,7 +268,8 @@ ...@@ -267,7 +268,8 @@
ticket_id, ticket_id,
number, number,
user_id, user_id,
oc.coupon_code oc.coupon_code,
oc.coupon_tpye
from (SELECT ot.mid, from (SELECT ot.mid,
order_tickets_id, order_tickets_id,
order_code, order_code,
...@@ -279,8 +281,7 @@ ...@@ -279,8 +281,7 @@
inner JOIN kylin_order_ticket_status AS ots ON ots.order_id = ot.order_tickets_id inner JOIN kylin_order_ticket_status AS ots ON ots.order_id = ot.order_tickets_id
inner JOIN kylin_order_ticket_relations AS otr ON otr.order_id = ot.order_tickets_id inner JOIN kylin_order_ticket_relations AS otr ON otr.order_id = ot.order_tickets_id
WHERE status = 0 AND NOW() > DATE_SUB(ot.created_at,INTERVAL -(pay_countdown_minute+1) MINUTE)) as s WHERE status = 0 AND NOW() > DATE_SUB(ot.created_at,INTERVAL -(pay_countdown_minute+1) MINUTE)) as s
left JOIN kylin_order_coupons AS oc ON oc.order_id = s.order_tickets_id where oc.coupon_type != 101 or left JOIN kylin_order_coupons AS oc ON oc.order_id = s.order_tickets_id
oc.coupon_code is null
<if test="userId!=''"> <if test="userId!=''">
AND user_id = #{userId} AND user_id = #{userId}
</if> </if>
......
...@@ -15,13 +15,11 @@ import com.liquidnet.service.kylin.mapper.KylinOrderTaskMapper; ...@@ -15,13 +15,11 @@ import com.liquidnet.service.kylin.mapper.KylinOrderTaskMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketRelationsMapper; import com.liquidnet.service.kylin.mapper.KylinOrderTicketRelationsMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketStatusMapper; import com.liquidnet.service.kylin.mapper.KylinOrderTicketStatusMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketsMapper; import com.liquidnet.service.kylin.mapper.KylinOrderTicketsMapper;
import com.liquidnet.service.platform.service.impl.candy.PlatformCandyCouponService;
import com.liquidnet.service.platform.service.impl.candy.PlatformCandyUserCouponService; import com.liquidnet.service.platform.service.impl.candy.PlatformCandyUserCouponService;
import com.liquidnet.service.platform.utils.DataUtils; import com.liquidnet.service.platform.utils.DataUtils;
import com.liquidnet.service.platform.utils.QueueUtils; import com.liquidnet.service.platform.utils.QueueUtils;
import com.mongodb.BasicDBObject; import com.mongodb.BasicDBObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.MongoConverter; import org.springframework.data.mongodb.core.convert.MongoConverter;
...@@ -71,7 +69,8 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K ...@@ -71,7 +69,8 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K
HashMap<String, Integer> mapSurplusGeneral = new HashMap<>(); HashMap<String, Integer> mapSurplusGeneral = new HashMap<>();
ArrayList<String> orderDataList = CollectionUtil.arrayListString(); ArrayList<String> orderDataList = CollectionUtil.arrayListString();
ArrayList<String> orderIdList = CollectionUtil.arrayListString(); ArrayList<String> orderIdList = CollectionUtil.arrayListString();
HashMap<String, Object> mapMongo = new HashMap<>(); HashMap<String, Object> mapMongo = CollectionUtil.mapStringObject();
HashMap<String, String> orderTicketId = CollectionUtil.mapStringString();
ArrayList<String> couponDataList = CollectionUtil.arrayListString(); ArrayList<String> couponDataList = CollectionUtil.arrayListString();
ArrayList<String> couponIdList = CollectionUtil.arrayListString(); ArrayList<String> couponIdList = CollectionUtil.arrayListString();
...@@ -82,11 +81,17 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K ...@@ -82,11 +81,17 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K
mapMongo.put("status", KylinTableStatusConst.ORDER_STATUS2); mapMongo.put("status", KylinTableStatusConst.ORDER_STATUS2);
mapMongo.put("updatedAt", DateUtil.Formatter.yyyyMMddHHmmssSSS.format(now)); mapMongo.put("updatedAt", DateUtil.Formatter.yyyyMMddHHmmssSSS.format(now));
mapMongo.put("changeDate", now); mapMongo.put("changeDate", now);
orderDataList.add(item.getOrderTicketsId() + "," + item.getUserId()); if (!orderTicketId.containsKey(item.getOrderTicketsId())) {
orderIdList.add(item.getOrderTicketsId()); orderTicketId.put(item.getOrderTicketsId(), item.getOrderTicketsId())
couponDataList.add(item.getCouponCode() + "," + item.getUserId()); orderDataList.add(item.getOrderTicketsId() + "," + item.getUserId());
couponIdList.add(item.getCouponCode()); orderIdList.add(item.getOrderTicketsId());
mapSurplusGeneral.put(item.getTicketId(), mapSurplusGeneral.get(item.getTicketId()) == null ? item.getNumber() : mapSurplusGeneral.get(item.getTicketId()) + item.getNumber()); mapSurplusGeneral.put(item.getTicketId(), mapSurplusGeneral.get(item.getTicketId()) == null ? item.getNumber() : mapSurplusGeneral.get(item.getTicketId()) + item.getNumber());
}
if (item.getCouponType() != 101) {
couponDataList.add(item.getCouponCode() + "," + item.getUserId());
couponIdList.add(item.getCouponCode());
}
} catch (Exception e) { } catch (Exception e) {
log.debug("CHECK TIME SYNC = " + e.getMessage()); log.debug("CHECK TIME SYNC = " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
...@@ -159,7 +164,7 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K ...@@ -159,7 +164,7 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K
public boolean checkTransferOrder(Integer minute) { public boolean checkTransferOrder(Integer minute) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
List<KylinOrderTask> task = orderTaskMapper.selectList( List<KylinOrderTask> task = orderTaskMapper.selectList(
Wrappers.lambdaQuery(KylinOrderTask.class).eq(KylinOrderTask::getStatus, 10).last("and NOW() > DATE_SUB(created_at,INTERVAL -("+minute+") MINUTE)") Wrappers.lambdaQuery(KylinOrderTask.class).eq(KylinOrderTask::getStatus, 10).last("and NOW() > DATE_SUB(created_at,INTERVAL -(" + minute + ") MINUTE)")
); );
ArrayList<String> orderIdList = CollectionUtil.arrayListString(); ArrayList<String> orderIdList = CollectionUtil.arrayListString();
for (KylinOrderTask item : task) { for (KylinOrderTask item : task) {
...@@ -190,7 +195,7 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K ...@@ -190,7 +195,7 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K
orderTicketRelations.setUpdatedAt(now); orderTicketRelations.setUpdatedAt(now);
orderTicketRelationsMapper.update(orderTicketRelations, new UpdateWrapper<KylinOrderTicketRelations>().in("order_id", orderIdList)); orderTicketRelationsMapper.update(orderTicketRelations, new UpdateWrapper<KylinOrderTicketRelations>().in("order_id", orderIdList));
// mysql 删除持久化数据 // mysql 删除持久化数据
orderTaskMapper.delete(Wrappers.lambdaQuery(KylinOrderTask.class).eq(KylinOrderTask::getStatus, 10).last("and NOW() > DATE_SUB(created_at,INTERVAL -("+minute+") MINUTE)")); orderTaskMapper.delete(Wrappers.lambdaQuery(KylinOrderTask.class).eq(KylinOrderTask::getStatus, 10).last("and NOW() > DATE_SUB(created_at,INTERVAL -(" + minute + ") MINUTE)"));
//处理原订单redis //处理原订单redis
int forSize = 500; int forSize = 500;
int forCount = orderIdList.size() % forSize == 0 ? orderIdList.size() / forSize : (orderIdList.size() / forSize) + 1; int forCount = orderIdList.size() % forSize == 0 ? orderIdList.size() / forSize : (orderIdList.size() / forSize) + 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