...
|
...
|
@@ -5,6 +5,7 @@ import com.yoho.core.rest.client.hystrix.AsyncFuture; |
|
|
import com.yohobuy.ufo.model.order.bo.PlatformFee;
|
|
|
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
|
|
|
import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
|
|
|
import com.yohoufo.common.caller.UfoServiceCaller;
|
|
|
import com.yohoufo.common.exception.GatewayException;
|
|
|
import com.yohoufo.common.http.URLHolder;
|
|
|
import com.yohoufo.common.utils.BigDecimalHelper;
|
...
|
...
|
@@ -14,6 +15,8 @@ import com.yohoufo.order.model.dto.PlatformFeeDto; |
|
|
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
|
|
|
import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
|
|
|
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
|
|
|
import com.yohoufo.order.service.support.codegenerator.OrderCodeType;
|
|
|
import com.yohoufo.product.response.StorageDataResp;
|
|
|
import com.yohoufo.product.response.StorageLeastPriceResp;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
...
|
...
|
@@ -38,22 +41,32 @@ public class SellerOrderService { |
|
|
private ServiceCaller serviceCaller;
|
|
|
|
|
|
@Autowired
|
|
|
private UfoServiceCaller ufoServiceCaller;
|
|
|
|
|
|
@Autowired
|
|
|
private URLHolder urlHolder;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerOrderComputeHandler computeHandler;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private OrderCodeGenerator orderCodeGenerator;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private SkupService skupService;
|
|
|
|
|
|
public SoldPrdComputeBo computePublishPrd(SellerOrderComputeReq req) throws GatewayException {
|
|
|
log.info("in computePublishPrd, req {}", req);
|
|
|
|
|
|
//
|
|
|
String baseUrl = urlHolder.getUrl();
|
|
|
String apiParam = "?method=ufo.product.storage.leastprice";
|
|
|
String fullUrl = baseUrl + apiParam;
|
|
|
Object params = new Object();
|
|
|
AsyncFuture<StorageLeastPriceResp.StorageLeastPrice> future = serviceCaller.post("product.getFloorPrice", fullUrl, params,
|
|
|
StorageLeastPriceResp.StorageLeastPrice.class, null);
|
|
|
StorageLeastPriceResp.StorageLeastPrice resp = future.get();
|
|
|
Integer storageId = req.getStorageId();
|
|
|
if (storageId <=0 ){
|
|
|
log.warn("in computePublishPrd storageId illegal , req {}", req);
|
|
|
throw new GatewayException(400, "storageId 错误");
|
|
|
}
|
|
|
StorageLeastPriceResp resp = ufoServiceCaller.call("ufo.product.storage.leastprice", storageId);
|
|
|
BigDecimal leastPrice;
|
|
|
if (Objects.isNull(resp) || Objects.isNull(leastPrice = resp.getLeastPrice()) || leastPrice.doubleValue() == 0D){
|
|
|
throw new GatewayException(501, "暂无商品");
|
...
|
...
|
@@ -84,20 +97,26 @@ public class SellerOrderService { |
|
|
return buildSoldPrdComputeBo(prdPrice);
|
|
|
}
|
|
|
|
|
|
public Long publishPrd(SellerOrderComputeReq req){
|
|
|
|
|
|
//TODO step 1: rpc get product detail by storage id
|
|
|
public Long publishPrd(SellerOrderComputeReq req) throws GatewayException {
|
|
|
Integer storageId = req.getStorageId();
|
|
|
if (storageId <=0 ){
|
|
|
log.warn("in computePublishPrd storageId illegal , req {}", req);
|
|
|
throw new GatewayException(400, "storageId 错误");
|
|
|
}
|
|
|
//step 1: rpc get product detail by storage id
|
|
|
//ufo.product.storage.data
|
|
|
StorageDataResp prdResp = ufoServiceCaller.call("ufo.product.storage.data", storageId);
|
|
|
//getProductDetail()
|
|
|
//TODO step 2: generate skup ,action :set price status(unsaleable)
|
|
|
//createSkup()
|
|
|
//step 2: generate skup ,action :set price status(unsaleable)
|
|
|
if (Objects.isNull(prdResp)){
|
|
|
log.warn("in computePublishPrd storageId not exist in prd , req {}", req);
|
|
|
throw new GatewayException(400, "商品不存在");
|
|
|
}
|
|
|
int skup = skupService.addSkup(prdResp);
|
|
|
|
|
|
//TODO step 2: create order, set status(not pay)
|
|
|
//TODO generate a new real code
|
|
|
long orderCode = new OrderCodeGenerator(){
|
|
|
@Override
|
|
|
public long generate() {
|
|
|
return new Random(10000000).nextLong();
|
|
|
}
|
|
|
}.generate();
|
|
|
long orderCode = orderCodeGenerator.generate(OrderCodeType.SELLER_TYPE);
|
|
|
//createOrder()
|
|
|
return orderCode;
|
|
|
}
|
...
|
...
|
@@ -132,7 +151,7 @@ public class SellerOrderService { |
|
|
String bankTransferFeeStr = formatFee(bankTransferfee);
|
|
|
SoldPrdComputeBo computeBo = SoldPrdComputeBo.builder()
|
|
|
.earnestMoney(earnestMoneyStr)
|
|
|
//.bankTransferFee(bankTransferFeeStr) 编译问题先注释
|
|
|
.bankTransferFee(bankTransferFeeStr)
|
|
|
.platformFee(platformFeeWrapper)
|
|
|
.income(incomeStr)
|
|
|
.build();
|
...
|
...
|
|