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

Commit a7ed200f authored by 胡佳晨's avatar 胡佳晨

拆单

parent 52bc19ae
...@@ -51,6 +51,7 @@ public class GoblinRedisConst { ...@@ -51,6 +51,7 @@ public class GoblinRedisConst {
public static final String REDIS_GOBLIN_BUY_COUNT = PREFIX.concat("uid:");//用户sku购买数量 key:uid:skuId:$skuId public static final String REDIS_GOBLIN_BUY_COUNT = PREFIX.concat("uid:");//用户sku购买数量 key:uid:skuId:$skuId
public static final String REDIS_GOBLIN_SALE_COUNT = PREFIX.concat("sale:skuId:");//用户sku购买数量 key:sale:skuId:$skuId public static final String REDIS_GOBLIN_SALE_COUNT = PREFIX.concat("sale:skuId:");//用户sku购买数量 key:sale:skuId:$skuId
public static final String REDIS_GOBLIN_ORDER = PREFIX.concat("order:");//用户sku购买数量 key:$orderId public static final String REDIS_GOBLIN_ORDER = PREFIX.concat("order:");//用户sku购买数量 key:$orderId
public static final String REDIS_GOBLIN_ORDER_SKU = PREFIX.concat("orderSku:");//用户sku购买数量 key:$orderSkuId
public static final String REDIS_GOBLIN_ORDER_UN_PAY = PREFIX.concat("order:un:pay:");//未支付订单id列表 key:$randomKey public static final String REDIS_GOBLIN_ORDER_UN_PAY = PREFIX.concat("order:un:pay:");//未支付订单id列表 key:$randomKey
public static final String REDIS_GOBLIN_ORDER_LIST = PREFIX.concat("order:id:list:");//用户订单id列表 key:$uid public static final String REDIS_GOBLIN_ORDER_LIST = PREFIX.concat("order:id:list:");//用户订单id列表 key:$uid
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
......
...@@ -107,8 +107,8 @@ public class GoblinStoreOrderVo implements Serializable, Cloneable { ...@@ -107,8 +107,8 @@ public class GoblinStoreOrderVo implements Serializable, Cloneable {
@ApiModelProperty(value = "orderAttr") @ApiModelProperty(value = "orderAttr")
private GoblinOrderAttrVo orderAttrVo; private GoblinOrderAttrVo orderAttrVo;
@ApiModelProperty(value = "orderSku") @ApiModelProperty(value = "orderSkuId")
private List<GoblinOrderSkuVo> orderSkuVos; private List<String> orderSkuVoIds;
private static final GoblinStoreOrderVo obj = new GoblinStoreOrderVo(); private static final GoblinStoreOrderVo obj = new GoblinStoreOrderVo();
......
...@@ -354,7 +354,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -354,7 +354,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
payInnerResultVo.setPayType(preParam.getPayType()); payInnerResultVo.setPayType(preParam.getPayType());
} }
List<GoblinOrderSkuVo> goblinOrderSkuVoList = ObjectUtil.getGoblinOrderSkuVoArrayList(); List<String> goblinOrderSkuIdList = CollectionUtil.linkedListString();
LinkedList<String> sqls = CollectionUtil.linkedListString(); LinkedList<String> sqls = CollectionUtil.linkedListString();
sqls.add(SqlMapping.get("goblin.order.create.sku_insert")); sqls.add(SqlMapping.get("goblin.order.create.sku_insert"));
sqls.add(SqlMapping.get("goblin.order.create.order_insert")); sqls.add(SqlMapping.get("goblin.order.create.order_insert"));
...@@ -371,7 +371,9 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -371,7 +371,9 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
//订单 orderSku Vo //订单 orderSku Vo
GoblinOrderSkuVo orderSkuVo = GoblinOrderSkuVo.getNew(); GoblinOrderSkuVo orderSkuVo = GoblinOrderSkuVo.getNew();
BeanUtils.copyProperties(orderSku, orderSkuVo); BeanUtils.copyProperties(orderSku, orderSkuVo);
goblinOrderSkuVoList.add(orderSkuVo); redisUtils.setGoblinOrderSku(orderSkuVo.getOrderSkuId(), orderSkuVo);
mongoUtils.insertGoblinOrderSkuVo(orderSkuVo);
goblinOrderSkuIdList.add(orderSkuVo.getOrderSkuId());
} }
GoblinStoreOrder storeOrder = item.getStoreOrder(); GoblinStoreOrder storeOrder = item.getStoreOrder();
sqlDataOrder.add(new Object[]{ sqlDataOrder.add(new Object[]{
...@@ -392,8 +394,9 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -392,8 +394,9 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
BeanUtils.copyProperties(orderAttr, orderAttrVo); BeanUtils.copyProperties(orderAttr, orderAttrVo);
//redis 赋值 //redis 赋值
orderVo.setOrderAttrVo(orderAttrVo); orderVo.setOrderAttrVo(orderAttrVo);
orderVo.setOrderSkuVos(goblinOrderSkuVoList); orderVo.setOrderSkuVoIds(goblinOrderSkuIdList);
redisUtils.setGoblinOrder(orderVo.getOrderId(), orderVo); redisUtils.setGoblinOrder(orderVo.getOrderId(), orderVo);
mongoUtils.insertGoblinStoreOrderVo(orderVo);
//redis 添加未支付列表 //redis 添加未支付列表
redisUtils.addUnPayOrder(orderVo.getOrderId()); redisUtils.addUnPayOrder(orderVo.getOrderId());
//redis 订单列表 //redis 订单列表
...@@ -560,11 +563,16 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -560,11 +563,16 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
orderId, now, now orderId, now, now
}); });
sqls.add(SqlMapping.get("goblin_order.pay.sku")); sqls.add(SqlMapping.get("goblin_order.pay.sku"));
List<GoblinOrderSkuVo> skuList = orderVo.getOrderSkuVos(); List<String> skuList = orderVo.getOrderSkuVoIds();
for (GoblinOrderSkuVo orderSkuVo : skuList) { for (String orderSkuVoIds : skuList) {
GoblinOrderSkuVo orderSkuVo = redisUtils.getGoblinOrderSkuVo(orderSkuVoIds);
//增加销量 //增加销量
redisUtils.incrSkuSaleCount(orderSkuVo.getSkuId(), orderSkuVo.getNum()); redisUtils.incrSkuSaleCount(orderSkuVo.getSkuId(), orderSkuVo.getNum());
orderSkuVo.setStatus(GoblinStatusConst.OrderStatus.ORDER_STATUS_2.getValue()); orderSkuVo.setStatus(GoblinStatusConst.OrderStatus.ORDER_STATUS_2.getValue());
//redis
redisUtils.setGoblinOrderSku(orderSkuVo.getOrderSkuId(), orderSkuVo);
//mongo
mongoUtils.updateGoblinOrderSkuVo(orderSkuVo.getOrderSkuId(), orderSkuVo);
sqlDataSku.add(new Object[]{ sqlDataSku.add(new Object[]{
GoblinStatusConst.OrderStatus.ORDER_STATUS_2.getValue(), now, GoblinStatusConst.OrderStatus.ORDER_STATUS_2.getValue(), now,
orderSkuVo.getOrderSkuId(), now, now orderSkuVo.getOrderSkuId(), now, now
...@@ -575,12 +583,12 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -575,12 +583,12 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
orderVo.setPayTime(storeOrder.getPayTime()); orderVo.setPayTime(storeOrder.getPayTime());
orderVo.setWriteOffCode(storeOrder.getWriteOffCode()); orderVo.setWriteOffCode(storeOrder.getWriteOffCode());
orderVo.setStatus(storeOrder.getStatus()); orderVo.setStatus(storeOrder.getStatus());
orderVo.setOrderSkuVos(skuList); orderVo.setOrderSkuVoIds(skuList);
redisUtils.setGoblinOrder(orderId, orderVo); redisUtils.setGoblinOrder(orderId, orderVo);
//删除未支付订单 //删除未支付订单
redisUtils.removeGoblinOrder(null, orderId); redisUtils.removeGoblinOrder(null, orderId);
//mongo //mongo
mongoUtils.insertGoblinStoreOrderVo(orderVo); mongoUtils.updateGoblinStoreOrderVo(orderId, orderVo);
//mysql //mysql
queueUtils.sendMsgByRedis(MQConst.KylinQueue.SQL_ORDER_CREATE.getKey(), queueUtils.sendMsgByRedis(MQConst.KylinQueue.SQL_ORDER_CREATE.getKey(),
SqlMapping.gets(sqls, sqlDataOrder, sqlDataSku)); SqlMapping.gets(sqls, sqlDataOrder, sqlDataSku));
......
...@@ -59,7 +59,7 @@ public class GoblinMongoUtils { ...@@ -59,7 +59,7 @@ public class GoblinMongoUtils {
public List<GoblinServiceSupportVo> getServiceSupportVos(List<String> ssids) { public List<GoblinServiceSupportVo> getServiceSupportVos(List<String> ssids) {
if (CollectionUtils.isEmpty(ssids)) return ObjectUtil.getGoblinServiceSupportVoArrayList(); if (CollectionUtils.isEmpty(ssids)) return ObjectUtil.getGoblinServiceSupportVoArrayList();
return mongoTemplate.find(Query.query(Criteria.where("ssid").in(ssids)), return mongoTemplate.find(Query.query(Criteria.where("ssid").in(ssids)),
GoblinServiceSupportVo.class,GoblinServiceSupportVo.class.getSimpleName()); GoblinServiceSupportVo.class, GoblinServiceSupportVo.class.getSimpleName());
} }
public List<GoblinServiceSupportVo> getMgtServiceSupportVos() { public List<GoblinServiceSupportVo> getMgtServiceSupportVos() {
...@@ -337,4 +337,23 @@ public class GoblinMongoUtils { ...@@ -337,4 +337,23 @@ public class GoblinMongoUtils {
public GoblinStoreOrderVo insertGoblinStoreOrderVo(GoblinStoreOrderVo vo) { public GoblinStoreOrderVo insertGoblinStoreOrderVo(GoblinStoreOrderVo vo) {
return mongoTemplate.insert(vo, GoblinStoreOrderVo.class.getSimpleName()); return mongoTemplate.insert(vo, GoblinStoreOrderVo.class.getSimpleName());
} }
public UpdateResult updateGoblinStoreOrderVo(String orderId, GoblinStoreOrderVo data) {
BasicDBObject object = ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(data));
return mongoTemplate.getCollection(GoblinStoreMarketVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderId").is(orderId)).getQueryObject(),
object);
}
//添加 订单SkuVo全量
public GoblinOrderSkuVo insertGoblinOrderSkuVo(GoblinOrderSkuVo vo) {
return mongoTemplate.insert(vo, GoblinOrderSkuVo.class.getSimpleName());
}
public UpdateResult updateGoblinOrderSkuVo(String orderSkuId, GoblinOrderSkuVo data) {
BasicDBObject object = ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(data));
return mongoTemplate.getCollection(GoblinStoreMarketVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderSkuId").is(orderSkuId)).getQueryObject(),
object);
}
} }
...@@ -426,7 +426,14 @@ public class GoblinRedisUtils { ...@@ -426,7 +426,14 @@ public class GoblinRedisUtils {
redisUtil.set(redisKey, vo); redisUtil.set(redisKey, vo);
} }
// 赋值 订单相关vo
// 赋值 订单相关Skuvo
public void setGoblinOrderSku(String orderSkuId, GoblinOrderSkuVo vo) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER_SKU.concat(orderSkuId);
redisUtil.set(redisKey, vo);
}
// 获取 订单相关vo
public GoblinStoreOrderVo getGoblinOrder(String orderId) { public GoblinStoreOrderVo getGoblinOrder(String orderId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER.concat(orderId); String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER.concat(orderId);
Object obj = redisUtil.get(redisKey); Object obj = redisUtil.get(redisKey);
...@@ -437,6 +444,17 @@ public class GoblinRedisUtils { ...@@ -437,6 +444,17 @@ public class GoblinRedisUtils {
} }
} }
// 获取 订单相关Skuvo
public GoblinOrderSkuVo getGoblinOrderSkuVo(String orderSkuId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_ORDER_SKU.concat(orderSkuId);
Object obj = redisUtil.get(redisKey);
if (obj == null) {
return null;
} else {
return (GoblinOrderSkuVo) obj;
}
}
// 获取 未支付订单id列表 // 获取 未支付订单id列表
public List<String> getUnPayOrder() { public List<String> getUnPayOrder() {
int randomKey = RandomUtil.getRandomInt(0, 100); int randomKey = RandomUtil.getRandomInt(0, 100);
......
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