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

Commit 51fa87e4 authored by 胡佳晨's avatar 胡佳晨

优化 下单接口数据

parent d1eed510
...@@ -4,12 +4,15 @@ import com.baomidou.mybatisplus.annotation.IdType; ...@@ -4,12 +4,15 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil; import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.goblin.entity.GoblinOrderAttr;
import com.liquidnet.service.goblin.entity.GoblinOrderSku;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/** /**
* <p> * <p>
...@@ -21,7 +24,7 @@ import java.time.LocalDateTime; ...@@ -21,7 +24,7 @@ import java.time.LocalDateTime;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class GoblinOrderAttrVo implements Serializable,Cloneable { public class GoblinOrderAttrVo implements Serializable, Cloneable {
@ApiModelProperty(value = " 主键id") @ApiModelProperty(value = " 主键id")
private String orderAttrId; private String orderAttrId;
@ApiModelProperty(value = " 订单id") @ApiModelProperty(value = " 订单id")
...@@ -41,6 +44,20 @@ public class GoblinOrderAttrVo implements Serializable,Cloneable { ...@@ -41,6 +44,20 @@ public class GoblinOrderAttrVo implements Serializable,Cloneable {
@ApiModelProperty(value = " 创建时间") @ApiModelProperty(value = " 创建时间")
private String createdAt; private String createdAt;
public GoblinOrderAttrVo copy(GoblinOrderAttr source) {
if (null == source) return this;
this.setOrderAttrId(source.getOrderAttrId());
this.setOrderId(source.getOrderId());
this.setExpressContacts(source.getExpressContacts());
this.setExpressAddress(source.getExpressAddress());
this.setExpressAddressDetail(source.getExpressAddressDetail());
this.setExpressPhone(source.getExpressPhone());
this.setExpressType(source.getExpressType());
this.setGiftInfos(source.getGiftInfos());
this.setCreatedAt(source.getCreatedAt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
return this;
}
private static final GoblinOrderAttrVo obj = new GoblinOrderAttrVo(); private static final GoblinOrderAttrVo obj = new GoblinOrderAttrVo();
public static GoblinOrderAttrVo getNew() { public static GoblinOrderAttrVo getNew() {
......
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil; import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.goblin.entity.GoblinOrderSku;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
...@@ -11,6 +12,9 @@ import lombok.EqualsAndHashCode; ...@@ -11,6 +12,9 @@ import lombok.EqualsAndHashCode;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS;
/** /**
* <p> * <p>
...@@ -59,8 +63,31 @@ public class GoblinOrderSkuVo implements Serializable, Cloneable { ...@@ -59,8 +63,31 @@ public class GoblinOrderSkuVo implements Serializable, Cloneable {
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private String createdAt; private String createdAt;
public GoblinOrderSkuVo copy(GoblinOrderSku source) {
if (null == source) return this;
this.setOrderSkuId(source.getOrderSkuId());
this.setOrderId(source.getOrderSkuId());
this.setSpuId(source.getSpuId());
this.setSpuName(source.getSpuName());
this.setSkuId(source.getSkuId());
this.setNum(source.getNum());
this.setStatus(source.getStatus());
this.setSkuPrice(source.getSkuPrice());
this.setSkuPriceActual(source.getSkuPriceActual());
this.setPriceRefund(source.getPriceRefund());
this.setSkuName(source.getSkuName());
this.setSkuNo(source.getSkuNo());
this.setSkuImage(source.getSkuImage());
this.setSkuSpecs(source.getSkuSpecs());
this.setPriceModify(source.getPriceModify());
this.setPriceVoucher(source.getPriceVoucher());
this.setCreatedAt(source.getCreatedAt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
return this;
}
public BigDecimal getPriceRefund() { public BigDecimal getPriceRefund() {
return priceRefund==null?BigDecimal.ZERO:priceRefund; return priceRefund == null ? BigDecimal.ZERO : priceRefund;
} }
private static final GoblinOrderSkuVo obj = new GoblinOrderSkuVo(); private static final GoblinOrderSkuVo obj = new GoblinOrderSkuVo();
......
package com.liquidnet.service.goblin.dto.vo; package com.liquidnet.service.goblin.dto.vo;
import com.liquidnet.service.goblin.entity.GoblinOrderAttr;
import com.liquidnet.service.goblin.entity.GoblinStoreOrder;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
/** /**
...@@ -132,6 +135,57 @@ public class GoblinStoreOrderVo implements Serializable, Cloneable { ...@@ -132,6 +135,57 @@ public class GoblinStoreOrderVo implements Serializable, Cloneable {
return priceVoucher; return priceVoucher;
} }
public GoblinStoreOrderVo copy(GoblinStoreOrder source) {
if (null == source) return this;
this.setOrderId(source.getOrderId());
this.setStoreId(source.getStoreId());
this.setStoreName(source.getStoreName());
this.setMasterOrderCode(source.getMasterOrderCode());
this.setOrderCode(source.getOrderCode());
this.setPayCode(source.getPayCode());
this.setUserId(source.getUserId());
this.setUserName(source.getUserName());
this.setUserMobile(source.getUserMobile());
this.setPriceTotal(source.getPriceTotal());
this.setPriceActual(source.getPriceActual());
this.setPriceRefund(source.getPriceRefund());
this.setPriceExpress(source.getPriceExpress());
this.setPriceModify(source.getPriceModify());
this.setPriceCoupon(source.getPriceCoupon());
this.setStorePriceCoupon(source.getStorePriceCoupon());
this.setPriceVoucher(source.getPriceVoucher());
this.setStatus(source.getStatus());
this.setZhengzaiStatus(source.getZhengzaiStatus());
this.setUcouponId(source.getUcouponId());
this.setStoreCouponId(source.getStoreCouponId());
this.setPayType(source.getPayType());
this.setDeviceFrom(source.getDeviceFrom());
this.setCancelReason(source.getCancelReason());
this.setSource(source.getSource());
this.setVersion(source.getVersion());
this.setIsMember(source.getIsMember());
this.setOrderType(source.getOrderType());
// this.setPayTime(source.getPayTime());
// this.setCancelTime(source.getCancelTime());
// this.setModifyTime(source.getModifyTime());
this.setLotteryStatus(source.getLotteryStatus());
this.setWriteOffCode(source.getWriteOffCode());
this.setPayCountdownMinute(source.getPayCountdownMinute());
this.setMailNo(source.getMailNo());
// this.setDeliveryTime(source.getDeliveryTime());
this.setLogisticsCompany(source.getLogisticsCompany());
this.setLogisticsCode(source.getLogisticsCode());
this.setIpAddress(source.getIpAddress());
this.setPaymentId(source.getPaymentId());
this.setPaymentType(source.getPaymentType());
this.setMarketType(source.getMarketType());
this.setMarketId(source.getMarketId());
// this.setRandomKey(source.getrad());
this.setCreatedAt(source.getCreatedAt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
return this;
}
private static final GoblinStoreOrderVo obj = new GoblinStoreOrderVo(); private static final GoblinStoreOrderVo obj = new GoblinStoreOrderVo();
public static GoblinStoreOrderVo getNew() { public static GoblinStoreOrderVo getNew() {
......
...@@ -100,7 +100,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -100,7 +100,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
if (noZhengzaiOrder(uid)) { if (noZhengzaiOrder(uid)) {
long time1 = System.currentTimeMillis(); long time1 = System.currentTimeMillis();
userVo = orderUtils.adamAddressEnterMember(uid, null, addressId); userVo = orderUtils.adamAddressEnterMember(uid, null, addressId);
log.info("adam接口调用:"+(System.currentTimeMillis()-time1)+"秒"); log.info("adam接口调用:" + (System.currentTimeMillis() - time1) + "秒");
} }
AdamAddressesVo addressesVo; AdamAddressesVo addressesVo;
boolean isMember; boolean isMember;
...@@ -349,7 +349,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -349,7 +349,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
} }
long time1 = System.currentTimeMillis(); long time1 = System.currentTimeMillis();
ResponseDto<GoblinUseResultVo> storeCouponVo = feignGoblinBaseClient.useCoupon(storeVoucherCode, "购买商品[" + orderCode + "]", storeTotalPrice, spuIds, uid); ResponseDto<GoblinUseResultVo> storeCouponVo = feignGoblinBaseClient.useCoupon(storeVoucherCode, "购买商品[" + orderCode + "]", storeTotalPrice, spuIds, uid);
log.info("goblin接口调用:"+(System.currentTimeMillis()-time1)+"秒"); log.info("goblin接口调用:" + (System.currentTimeMillis() - time1) + "秒");
String typeVoucher; String typeVoucher;
if (!(storeCouponVo == null || storeCouponVo.getData() == null)) { if (!(storeCouponVo == null || storeCouponVo.getData() == null)) {
storeVoucherPrice = storeCouponVo.getData().getValue(); storeVoucherPrice = storeCouponVo.getData().getValue();
...@@ -425,7 +425,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -425,7 +425,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
preParam.setStoreOrder(storeOrder); preParam.setStoreOrder(storeOrder);
preParam.setOrderAttr(orderAttr); preParam.setOrderAttr(orderAttr);
preParam.setOrderSkuList(goblinOrderSkuList); preParam.setOrderSkuList(goblinOrderSkuList);
log.info("订单生成耗时:"+(System.currentTimeMillis()-timeAll)+"秒"); log.info("订单生成耗时:" + (System.currentTimeMillis() - timeAll) + "秒");
return preParam; return preParam;
} }
...@@ -523,23 +523,22 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -523,23 +523,22 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
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"));
sqls.add(SqlMapping.get("goblin.order.create.attr_insert")); sqls.add(SqlMapping.get("goblin.order.create.attr_insert"));
List<String> goblinOrderSkuIdList = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlDataSku = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> sqlDataOrder = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> sqlDataAttr = CollectionUtil.linkedListObjectArr();
for (GoblinOrderSqlParam item : sqlParams) { for (GoblinOrderSqlParam item : sqlParams) {
List<String> goblinOrderSkuIdList = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlDataSku = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> sqlDataOrder = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> sqlDataAttr = CollectionUtil.linkedListObjectArr();
for (GoblinOrderSku orderSku : item.getOrderSkuList()) { for (GoblinOrderSku orderSku : item.getOrderSkuList()) {
sqlDataSku.add(new Object[]{ sqlDataSku.add(new Object[]{
orderSku.getOrderSkuId(), orderSku.getOrderId(), orderSku.getSpuId(), orderSku.getSpuName(), orderSku.getSpuPic(), orderSku.getSkuId(), orderSku.getNum(), orderSku.getSkuPrice(), orderSku.getSkuPriceActual(), orderSku.getSkuName(), orderSku.getOrderSkuId(), orderSku.getOrderId(), orderSku.getSpuId(), orderSku.getSpuName(), orderSku.getSpuPic(), orderSku.getSkuId(), orderSku.getNum(), orderSku.getSkuPrice(), orderSku.getSkuPriceActual(), orderSku.getSkuName(),
orderSku.getSkuNo(), orderSku.getSkuImage(), orderSku.getSkuSpecs(), orderSku.getPriceVoucher(), orderSku.getCreatedAt() orderSku.getSkuNo(), orderSku.getSkuImage(), orderSku.getSkuSpecs(), orderSku.getPriceVoucher(), orderSku.getCreatedAt()
}); });
//订单 orderSku Vo //订单 orderSku Vo
GoblinOrderSkuVo orderSkuVo = GoblinOrderSkuVo.getNew(); GoblinOrderSkuVo orderSkuVo = GoblinOrderSkuVo.getNew().copy(orderSku);
BeanUtils.copyProperties(orderSku, orderSkuVo);
redisUtils.setGoblinOrderSku(orderSkuVo.getOrderSkuId(), orderSkuVo); redisUtils.setGoblinOrderSku(orderSkuVo.getOrderSkuId(), orderSkuVo);
long time2 = System.currentTimeMillis(); long time2 = System.currentTimeMillis();
mongoUtils.insertGoblinOrderSkuVo(orderSkuVo); mongoUtils.insertGoblinOrderSkuVo(orderSkuVo);
log.info("mongo新增订单:"+(System.currentTimeMillis()-time2)+"秒"); log.info("mongo新增订单:" + (System.currentTimeMillis() - time2) + "秒");
goblinOrderSkuIdList.add(orderSkuVo.getOrderSkuId()); goblinOrderSkuIdList.add(orderSkuVo.getOrderSkuId());
} }
GoblinStoreOrder storeOrder = item.getStoreOrder(); GoblinStoreOrder storeOrder = item.getStoreOrder();
...@@ -553,13 +552,10 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -553,13 +552,10 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
sqlDataAttr.add(new Object[]{ sqlDataAttr.add(new Object[]{
orderAttr.getOrderAttrId(), orderAttr.getOrderId(), orderAttr.getExpressContacts(), orderAttr.getExpressAddress(), orderAttr.getExpressAddressDetail(), orderAttr.getExpressPhone(), orderAttr.getExpressType(), orderAttr.getCreatedAt() orderAttr.getOrderAttrId(), orderAttr.getOrderId(), orderAttr.getExpressContacts(), orderAttr.getExpressAddress(), orderAttr.getExpressAddressDetail(), orderAttr.getExpressPhone(), orderAttr.getExpressType(), orderAttr.getCreatedAt()
}); });
//订单vo //订单vo
GoblinStoreOrderVo orderVo = GoblinStoreOrderVo.getNew(); GoblinStoreOrderVo orderVo = GoblinStoreOrderVo.getNew().copy(storeOrder);
BeanUtils.copyProperties(storeOrder, orderVo);
//订单attr vo //订单attr vo
GoblinOrderAttrVo orderAttrVo = GoblinOrderAttrVo.getNew(); GoblinOrderAttrVo orderAttrVo = GoblinOrderAttrVo.getNew().copy(orderAttr);
BeanUtils.copyProperties(orderAttr, orderAttrVo);
//redis 添加未支付列表 //redis 添加未支付列表
int randomKey = redisUtils.addUnPayOrder(orderVo.getOrderId()); int randomKey = redisUtils.addUnPayOrder(orderVo.getOrderId());
//redis 赋值 //redis 赋值
...@@ -569,9 +565,9 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -569,9 +565,9 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
orderVo.setCreatedAt(getNowTime()); orderVo.setCreatedAt(getNowTime());
redisUtils.setGoblinOrder(orderVo.getOrderId(), orderVo); redisUtils.setGoblinOrder(orderVo.getOrderId(), orderVo);
redisUtils.setMasterCode(preParam.getOrderMasterCode(), preParam.getOrderIdList().substring(1)); redisUtils.setMasterCode(preParam.getOrderMasterCode(), preParam.getOrderIdList().substring(1));
long time3=System.currentTimeMillis(); long time3 = System.currentTimeMillis();
mongoUtils.insertGoblinStoreOrderVo(orderVo); mongoUtils.insertGoblinStoreOrderVo(orderVo);
log.info("mongo新增子订单:"+(System.currentTimeMillis()-time3)+"秒"); log.info("mongo新增子订单:" + (System.currentTimeMillis() - time3) + "秒");
//redis 订单列表 //redis 订单列表
if (noZhengzaiOrder(uid)) { if (noZhengzaiOrder(uid)) {
if (orderVo.getMarketType() == null) { if (orderVo.getMarketType() == null) {
...@@ -580,11 +576,13 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -580,11 +576,13 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
redisUtils.addZhengzaiOrderList(uid, orderVo.getOrderId()); redisUtils.addZhengzaiOrderList(uid, orderVo.getOrderId());
} }
} }
//mysql 执行sql
String sqlData = SqlMapping.gets(sqls, sqlDataSku, sqlDataOrder, sqlDataAttr);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_ORDER_CREATE_PAY.getKey(), sqlData);
} }
//mysql 执行sql
String sqlData = SqlMapping.gets(sqls, sqlDataSku, sqlDataOrder, sqlDataAttr);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_ORDER_CREATE_PAY.getKey(), sqlData);
log.info(UserPathDto.setData("下单(唤起支付)", preParam, payInnerResultVo)); log.info(UserPathDto.setData("下单(唤起支付)", preParam, payInnerResultVo));
log.info("支付单接口耗时:" + (System.currentTimeMillis() - timeAll) + "秒");
if (isFree && preParam.getPayType().equals("huifu")) { if (isFree && preParam.getPayType().equals("huifu")) {
return ResponseDto.success(payInnerResultVo); return ResponseDto.success(payInnerResultVo);
} else if (isFree) { } else if (isFree) {
...@@ -597,7 +595,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -597,7 +595,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
syncOrderParam.setPaymentType(null); syncOrderParam.setPaymentType(null);
syncOrderParam.setStatus(1); syncOrderParam.setStatus(1);
syncOrder(syncOrderParam); syncOrder(syncOrderParam);
log.info("支付单接口耗时:"+(System.currentTimeMillis()-timeAll)+"秒");
return ResponseDto.success(payInnerResultVo); return ResponseDto.success(payInnerResultVo);
} else { } else {
return ResponseDto.success(payInnerResultVo); return ResponseDto.success(payInnerResultVo);
......
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