Authored by chenchao

optimized

... ... @@ -40,7 +40,7 @@ public class GoodsInfoConvertor {
//最关键的两个数据项
sellerOrderGoods.setUid(goodsInfo.getUid());
sellerOrderGoods.setStorageId(goodsInfo.getStorageId());
sellerOrderGoods.setStatus(SkupStatus.CAN_NOT_SELL.getCode());
sellerOrderGoods.setStatus(goodsInfo.getTargetSkupStatus().getCode());
sellerOrderGoods.setGoodsPrice(goodsInfo.getPrice());
//if not exist ,not
sellerOrderGoods.setProductId(goodsInfo.getProductId());
... ...
... ... @@ -2,8 +2,14 @@ package com.yohoufo.order.convert;
import com.yohobuy.ufo.model.order.bo.PlatformFee;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.SellerOrderStatus;
import com.yohoufo.common.utils.BigDecimalHelper;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.common.utils.PriceFormater;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.model.dto.EarnestMoney;
import com.yohoufo.order.model.dto.PlatformFeeDto;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
... ... @@ -114,6 +120,43 @@ public final class SellerOrderConvertor {
}
public static SellerOrder buildSellerOrder4EntrySeller(long orderCode,
int uid,
int skupId,
SellerOrderComputeResult sellerOrderComputeResult){
Integer currentTiem = DateUtil.getCurrentTimeSecond();
SellerOrder condition = new SellerOrder();
condition.setOrderCode(orderCode);
condition.setUid(uid);
condition.setSkup(skupId);
condition.setIsDel(DelStatus.NOT_DEL.getCode());
condition.setCreateTime(currentTiem);
condition.setUpdateTime(currentTiem);
condition.setStatus(SellerOrderStatus.HAS_PAYED.getCode());
condition.setEarnestMoney(sellerOrderComputeResult.getEarnestMoney().getEarnestMoney());
condition.setIncome(sellerOrderComputeResult.getIncome());
condition.setPayment(Payment.WALLET.getCode());
return condition;
}
public static SellerOrder buildSellerOrder4NotEntrySeller(long orderCode,
int uid,
int skupId,
SellerOrderComputeResult sellerOrderComputeResult){
int currentTiem = DateUtil.getCurrentTimeSecond();
SellerOrder condition = new SellerOrder();
condition.setOrderCode(orderCode);
condition.setUid(uid);
condition.setSkup(skupId);
condition.setIsDel(DelStatus.NOT_DEL.getCode());
condition.setCreateTime(currentTiem);
condition.setStatus(SellerOrderStatus.WAITING_PAY.getCode());
condition.setEarnestMoney(sellerOrderComputeResult.getEarnestMoney().getEarnestMoney());
condition.setIncome(sellerOrderComputeResult.getIncome());
return condition;
}
public static String buildSubtractFee(String fmtFee){
if (null == fmtFee){
return null;
... ...
package com.yohoufo.order.model;
import com.yohobuy.ufo.model.order.bo.ImperfectGoodsInfo;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import lombok.Data;
/**
... ... @@ -11,5 +12,4 @@ public class ImperfectOrderContext extends SellerOrderContext {
private ImperfectGoodsInfo imperfectGoodsInfo;
}
... ...
package com.yohoufo.order.model;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.dal.order.model.SellerOrderGoods;
... ... @@ -56,4 +57,6 @@ public class SellerOrderContext {
private SkupType skupType;
private SellerTypeNode sellerTypeNode;
}
... ...
... ... @@ -2,17 +2,14 @@ package com.yohoufo.order.service.impl;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.SellerOrderStatus;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
... ... @@ -39,24 +36,22 @@ public class SellerOrderCreateService {
public int createOrder(SellerOrderContext context){
logger.info("create seller Order, uid {} storage id {} order code {} skup {}",
context.getUid(), context.getStorageId(), context.getOrderCode(), context.getSoldProduct().getSkup());
int currentTiem = DateUtil.getCurrentTimeSecond();
SellerOrder condition = new SellerOrder();
condition.setOrderCode(context.getOrderCode());
condition.setUid(context.getUid());
condition.setSkup(context.getSoldProduct().getSkup());
condition.setIsDel(DelStatus.NOT_DEL.getCode());
condition.setCreateTime(currentTiem);
condition.setStatus(SellerOrderStatus.WAITING_PAY.getCode());
condition.setEarnestMoney(context.getSellerOrderComputeResult().getEarnestMoney().getEarnestMoney());
condition.setIncome(context.getSellerOrderComputeResult().getIncome());
SellerOrder condition ;
long orderCode = context.getOrderCode();
int uid = context.getUid();
int skup = context.getSoldProduct().getSkup();
SellerOrderComputeResult computeResult = context.getSellerOrderComputeResult();
if (context.isEntryShop()){
condition = SellerOrderConvertor.buildSellerOrder4EntrySeller(orderCode, uid, skup, computeResult);
}else {
condition = SellerOrderConvertor.buildSellerOrder4NotEntrySeller(orderCode, uid, skup, computeResult);
}
return sellerOrderMapper.insertSelective(condition);
}
public List<SellerOrder> createBatchOrder(SellerOrderContext context, List<Integer> skupIdList){
int currentTiem = DateUtil.getCurrentTimeSecond();
List<SellerOrder> list = new ArrayList<>(skupIdList.size());
for(Integer skupId : skupIdList){
SellerOrder condition = new SellerOrder();
long orderCode = orderCodeGenerator.generate(OrderCodeType.SELLER_TYPE);
if (orderCode <= 0L){
logger.warn("in createBatchOrder storageId not exist in prd , uid {}, storageId {} skup {}, compute result {}",
... ... @@ -64,16 +59,8 @@ public class SellerOrderCreateService {
//todo alarm event
continue;
}
condition.setOrderCode(orderCode);
condition.setUid(context.getUid());
condition.setSkup(skupId);
condition.setIsDel(DelStatus.NOT_DEL.getCode());
condition.setCreateTime(currentTiem);
condition.setStatus(SellerOrderStatus.HAS_PAYED.getCode());
condition.setEarnestMoney(context.getSellerOrderComputeResult().getEarnestMoney().getEarnestMoney());
condition.setIncome(context.getSellerOrderComputeResult().getIncome());
condition.setPayment(Payment.WALLET.getCode());
SellerOrder condition = SellerOrderConvertor.buildSellerOrder4EntrySeller(orderCode, context.getUid(),
skupId, context.getSellerOrderComputeResult());
list.add(condition);
}
if (!list.isEmpty()){
... ... @@ -81,4 +68,6 @@ public class SellerOrderCreateService {
}
return list;
}
}
... ...
... ... @@ -253,7 +253,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
* @throws GatewayException
*/
public OrderSubmitResp publishPrd(SellerOrderSubmitReq req) throws GatewayException {
SellerOrderContext context = sellerOrderPrepareProcessor.buildPublishPrdCtx(req);
SellerOrderContext context = sellerOrderPrepareProcessor.buildPublishCtx(req);
boolean isEntryShop = context.isEntryShop();
OrderSubmitResp resp ;
if(isEntryShop){
... ...
... ... @@ -100,10 +100,9 @@ public class ImperfectGoodsPublishExcutor implements PublishExcutor<ImperfectOrd
int uid = ctx.getUid();
int storageId = ctx.getStorageId();
BigDecimal salePrice = ctx.getSalePrice();
logger.info("in ImperfectGoodsPublishExcutor.publish by common entry, uid {} storageId {} salePrice {}");
logger.info("in ImperfectGoodsPublishExcutor.publish by common entry, uid {} storageId {} salePrice {}", uid, storageId, salePrice);
SellerOrderComputeResult computeResult = ctx.getSellerOrderComputeResult();
BigDecimal earestMoney = computeResult.getEarnestMoney().getEarnestMoney();
SellerWalletDetail.Type swdType = SellerWalletDetail.Type.PUBLISH;
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid)
.storageId(storageId).earnestMoney(earestMoney)
... ... @@ -115,10 +114,12 @@ public class ImperfectGoodsPublishExcutor implements PublishExcutor<ImperfectOrd
uid, storageId, earestMoney);
throw new ServiceException(ServiceError.WALLET_EARNESTMONEY_PAY_FAIL);
}
logger.info("in ImperfectGoodsPublishExcutor.publish by common entry paid by waller, uid {} storageId {} salePrice {} paySuccess {}",
uid, storageId, salePrice, paySuccess);
//给入驻卖家发消息
inBoxFacade.sellerPaidEarnestMoney(uid, ctx.getSoldProduct().getProductName(),ctx.getSoldProduct().getSizeName(),ctx.getSoldProduct().getProductId());
//
OrderSubmitResp resp = doPublish(ctx);
return resp;
}
... ... @@ -128,21 +129,20 @@ public class ImperfectGoodsPublishExcutor implements PublishExcutor<ImperfectOrd
BigDecimal salePrice = ctx.getSalePrice();
logger.info("in ImperfectGoodsPublishExcutor.publish by super, uid {} storageId {} salePrice {}",
uid, storageId, salePrice);
inBoxFacade.sellerPaidEarnestMoney(uid, ctx.getSoldProduct().getProductName(),ctx.getSoldProduct().getSizeName(),ctx.getSoldProduct().getProductId());
OrderSubmitResp resp = doPublish(ctx);
return resp;
}
public OrderSubmitResp doPublish(ImperfectOrderContext context){
private OrderSubmitResp doPublish(ImperfectOrderContext context){
int storageId = context.getStorageId();
int uid = context.getUid();
BigDecimal salePrice = context.getSalePrice();
// step 2: create order, set status(not pay)
// generate a new real code
long orderCode = orderCodeGenerator.generate(OrderCodeType.SELLER_TYPE);
if (orderCode <= 0L){
logger.warn("in publish imperfect Prd generate fail , uid {}, storageId {}", uid, storageId);
logger.warn("in publish imperfect Prd generate fail , uid {}, storageId {} salePrice {}",
uid, storageId, salePrice);
throw new ServiceException(ServiceError.EARNESTMONEY_ORDER_CREATE_FAIL);
}
//允许入驻商家后,对于个体户而言,也需要批次号(1:1这种,直接使用订单号,若以后有变化 用skup_batch表自增)
... ... @@ -152,6 +152,8 @@ public class ImperfectGoodsPublishExcutor implements PublishExcutor<ImperfectOrd
//all include : 1. skup, 2. order , 3. 寄回地址
try{
orderSubmitHandler.submit(context);
logger.info("in ImperfectGoodsPublishExcutor.publish finish main local persistent, uid {} storageId {} salePrice {} orderCode {}",
uid, storageId, salePrice, orderCode);
}catch (Exception ex){
String content = "用户"+ uid + "发布瑕疵(或二手)商品"+storageId + "失败";
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("sellerOrder.create", "create", content);
... ... @@ -159,23 +161,28 @@ public class ImperfectGoodsPublishExcutor implements PublishExcutor<ImperfectOrd
logger.warn("in publish imperfect Prd create order fail , uid {}, storageId {}", uid, storageId);
throw new ServiceException(ServiceError.EARNESTMONEY_ORDER_CREATE_FAIL);
}
syncPrd(context);
SellerOrderGoods psog = context.getSellerOrderGoods();
int skup = psog.getId();
GoodsInfo goodsInfo = context.getSoldProduct();
OrderSubmitResp resp = OrderSubmitResp.builder()
.orderCode(orderCode)
.skup(skup)
.productId(goodsInfo.getProductId()).build();
return resp;
}
private void syncPrd(ImperfectOrderContext context){
long orderCode = context.getOrderCode();
SellerOrderGoods psog = context.getSellerOrderGoods();
int skup = psog.getId();
ImperfectGoodsInfo imperfectGoodsInfo = context.getImperfectGoodsInfo();
GoodsInfo goodsInfo = context.getSoldProduct();
SecondhandInfoReqBo secondhandInfoReqBo = buildSecondhandInfo(psog, imperfectGoodsInfo);
SecondhandInfoReqBo secondhandInfoReqBo = buildSecondhandInfo(goodsInfo.getTargetSkupStatus(), psog, imperfectGoodsInfo);
boolean syncPrdFlag = productProxyService.createImperfectGoods(secondhandInfoReqBo);
logger.info("publish imperfect Prd finish, createImperfectGoods {}, skup {}, orderCode {}",
syncPrdFlag, skup, orderCode);
// TODO 给入驻卖家发消息
OrderSubmitResp resp = OrderSubmitResp.builder()
.orderCode(orderCode)
.skup(psog.getId())
.productId(goodsInfo.getProductId()).build();
return resp;
}
private StoragePriceBo buildNewSkupReq(SellerOrderGoods goods,SkupStatus skupStatus){
... ... @@ -187,14 +194,14 @@ public class ImperfectGoodsPublishExcutor implements PublishExcutor<ImperfectOrd
skupReq.setStorageId(goods.getStorageId());
skupReq.setPrice(goods.getGoodsPrice());
skupReq.setSellerUid(goods.getUid());
//瑕疵和二手 prd & order 是一致
skupReq.setPreSaleFlag(goods.getAttributes());
return skupReq;
}
private SecondhandInfoReqBo buildSecondhandInfo(SellerOrderGoods goods, ImperfectGoodsInfo imperfectGoodsInfo){
private SecondhandInfoReqBo buildSecondhandInfo(SkupStatus skupStatus, SellerOrderGoods goods, ImperfectGoodsInfo imperfectGoodsInfo){
int skup = goods.getId();
final SkupStatus skupStatus = SkupStatus.CAN_NOT_SELL;
StoragePriceBo spb = buildNewSkupReq(goods, skupStatus);
SecondhandInfoReqBo sirb = new SecondhandInfoReqBo();
sirb.setSkupBo(spb);
sirb.setSkup(skup);
... ...
... ... @@ -7,6 +7,7 @@ import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.ImperfectGoodsImage;
import com.yohobuy.ufo.model.order.bo.ImperfectGoodsInfo;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.ImperfectOrderSubmitReq;
import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
... ... @@ -98,7 +99,13 @@ public class ImperfectPublishProcessor implements PublishProcessor<ImperfectOrde
SellerTypeNode sellerTypeNode = icpNode.getSellerTypeNode();
boolean isEntryShop = sellerTypeNode.isCommonEntry() || sellerTypeNode.isSuper();
SkupStatus tss;
if (isEntryShop){
tss = SkupStatus.WAITING_AUDIT;
}else{
tss = SkupStatus.CAN_NOT_SELL;
}
goodsInfo.setTargetSkupStatus(tss);
//
ImperfectOrderContext context = new ImperfectOrderContext();
context.setUid(uid);
... ...
... ... @@ -4,6 +4,7 @@ import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.PrdPrice;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.common.exception.UfoServiceException;
... ... @@ -94,6 +95,7 @@ public class ImportPublishProcessor
logger.warn("in buildImportPrdCxt storageId not exist in prd service , uid {}, storageId {}", uid, storageId);
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
}
goodsInfo.setTargetSkupStatus(SkupStatus.CAN_SELL);
context.setSoldProduct(goodsInfo);
if (storageNum <=0){
logger.warn("in buildBatchSellerOrderContext storageNum illegal , uid {}, storageId {} storageNum {}",
... ...
... ... @@ -4,6 +4,7 @@ import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.PrdPrice;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.NESChangePriceReq;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
... ... @@ -147,6 +148,7 @@ public class NESChangePricePublishProcessor
logger.warn("in buildSellerOrderContext storageId not exist in prd service , uid {}, storageId {}", uid, storageId);
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
}
goodsInfo.setTargetSkupStatus(SkupStatus.CAN_NOT_SELL);
context.setSoldProduct(goodsInfo);
logger.info("in build not entry Seller Order Context , uid {}, storageId {}, price {}, computeResult {}", uid, storageId,
... ...
... ... @@ -4,6 +4,7 @@ import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.PrdPrice;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
... ... @@ -48,7 +49,7 @@ public class SellerOrderPrepareProcessor
@Autowired
private OrderComputeProvider orderComputeProvider;
public SellerOrderContext buildPublishPrdCtx(SellerOrderSubmitReq req) {
private SellerOrderContext buildPublishPrdCtx(SellerOrderSubmitReq req) {
SellerOrderContext ctx = buildSellerOrderContext(req);
int uid = ctx.getUid();
boolean isEntryShop = userProxyService.isEntryShop(uid);
... ... @@ -75,7 +76,7 @@ public class SellerOrderPrepareProcessor
//ufo.product.storage.data
GoodsInfo goodsInfo = ctx.getSoldProduct();
goodsInfo.setStorageNum(storageNum);
goodsInfo.setTargetSkupStatus(SkupStatus.CAN_SELL);
}
... ... @@ -127,6 +128,7 @@ public class SellerOrderPrepareProcessor
log.warn("in buildSellerOrderContext storageId not exist in prd service , uid {}, storageId {}", uid, storageId);
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
}
goodsInfo.setTargetSkupStatus(SkupStatus.CAN_NOT_SELL);
context.setSoldProduct(goodsInfo);
PrdQueryReq pqr = PrdQueryReq.builder()
.uid(uid).prdPrice(salePrice).storageId(storageId).build();
... ...