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

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

库存回滚逻辑

parent f47abae7
......@@ -20,4 +20,5 @@ public class OrderScriptDto {
String userId;
Integer number;
String couponCode;
Integer couponType;
}
......@@ -54,6 +54,7 @@
<result column="number" property="number"/>
<result column="user_id" property="userId"/>
<result column="coupon_code" property="couponCode"/>
<result column="coupon_type" property="couponType"/>
</resultMap>
<select id="getPerformanceRefundOrderStatis" resultType="java.util.HashMap">
......@@ -267,7 +268,8 @@
ticket_id,
number,
user_id,
oc.coupon_code
oc.coupon_code,
oc.coupon_tpye
from (SELECT ot.mid,
order_tickets_id,
order_code,
......@@ -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_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
left JOIN kylin_order_coupons AS oc ON oc.order_id = s.order_tickets_id where oc.coupon_type != 101 or
oc.coupon_code is null
left JOIN kylin_order_coupons AS oc ON oc.order_id = s.order_tickets_id
<if test="userId!=''">
AND user_id = #{userId}
</if>
......
......@@ -15,13 +15,11 @@ import com.liquidnet.service.kylin.mapper.KylinOrderTaskMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketRelationsMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketStatusMapper;
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.utils.DataUtils;
import com.liquidnet.service.platform.utils.QueueUtils;
import com.mongodb.BasicDBObject;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.MongoConverter;
......@@ -71,7 +69,8 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K
HashMap<String, Integer> mapSurplusGeneral = new HashMap<>();
ArrayList<String> orderDataList = 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> couponIdList = CollectionUtil.arrayListString();
......@@ -82,11 +81,17 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K
mapMongo.put("status", KylinTableStatusConst.ORDER_STATUS2);
mapMongo.put("updatedAt", DateUtil.Formatter.yyyyMMddHHmmssSSS.format(now));
mapMongo.put("changeDate", now);
orderDataList.add(item.getOrderTicketsId() + "," + item.getUserId());
orderIdList.add(item.getOrderTicketsId());
couponDataList.add(item.getCouponCode() + "," + item.getUserId());
couponIdList.add(item.getCouponCode());
mapSurplusGeneral.put(item.getTicketId(), mapSurplusGeneral.get(item.getTicketId()) == null ? item.getNumber() : mapSurplusGeneral.get(item.getTicketId()) + item.getNumber());
if (!orderTicketId.containsKey(item.getOrderTicketsId())) {
orderTicketId.put(item.getOrderTicketsId(), item.getOrderTicketsId())
orderDataList.add(item.getOrderTicketsId() + "," + item.getUserId());
orderIdList.add(item.getOrderTicketsId());
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) {
log.debug("CHECK TIME SYNC = " + e.getMessage());
e.printStackTrace();
......@@ -159,7 +164,7 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K
public boolean checkTransferOrder(Integer minute) {
LocalDateTime now = LocalDateTime.now();
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();
for (KylinOrderTask item : task) {
......@@ -190,7 +195,7 @@ public class DMCheckOrderTimeImpl extends ServiceImpl<KylinOrderTicketsMapper, K
orderTicketRelations.setUpdatedAt(now);
orderTicketRelationsMapper.update(orderTicketRelations, new UpdateWrapper<KylinOrderTicketRelations>().in("order_id", orderIdList));
// 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
int forSize = 500;
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