Authored by chenchao

fix

... ... @@ -218,9 +218,14 @@ public class SellerOrderController {
public ApiResponse computeChangePrice(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "storage_id", required = true)int storage_id,
@RequestParam(name="price", required = true)String price,
@RequestParam(name = "batchNo", required = false)String batchNo,
@RequestParam(name = "skupList", required = false)String skupList,
@RequestParam(name="num", defaultValue = "1", required = false)int num) throws GatewayException {
SellerOrderComputeReq req = SellerOrderComputeReq.builder().uid(uid).storageId(storage_id).price(price)
.num(num).build();
BatchChangePriceReq req = BatchChangePriceReq.builder()
.storageId(storage_id)
.uid(uid).price(price)
.batchNo(batchNo).skupList(skupList)
.build();
logger.info("in ufo.sellerOrder.computeChangePrice, req {}", req);
SoldPrdComputeBo computeBo = sellerOrderService.computeChangePrice(req);
return new ApiResponse.ApiResponseBuilder().code(200).data(computeBo).message("算费成功").build();
... ...
... ... @@ -2,6 +2,8 @@ package com.yohoufo.order.model.response;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class GoodsInfo {
... ... @@ -44,4 +46,6 @@ public class GoodsInfo {
* 同一个批次的数量
*/
private Integer storageNum;
private BigDecimal leastPrice;
}
... ...
... ... @@ -5,6 +5,8 @@ import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.SellerType;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.product.response.StorageDataResp;
import java.util.Arrays;
import java.util.List;
... ... @@ -13,9 +15,17 @@ import java.util.List;
* Created by chao.chen on 2018/11/26.
*/
public interface AbsSellerOrderViewService {
List<Integer> SHOW_OVER_FLOW_PRICE_STATUS = Arrays.asList(SkupStatus.CAN_SELL.getCode());
enum ViewType{
DETAIL, LIST
}
ProductProxyService getProductProxyService();
List<Integer> SHOW_OVER_FLOW_PRICE_STATUS = Arrays.asList(SkupStatus.CAN_SELL.getCode());
default List<ButtonShowBo> getButtons(Integer storageNum, SellerType st, Integer payment, SkupStatus skupStatus){
default List<ButtonShowBo> getButtons(ViewType viewType, Integer storageNum, SellerType st, Integer payment, SkupStatus skupStatus){
//异常扯淡,兼容老数据,
boolean isEntry = st == SellerType.ENTRY;
... ... @@ -23,6 +33,9 @@ public interface AbsSellerOrderViewService {
&& Payment.WALLET.getCode() == payment ;
//非入驻商家 或者支付方式不是钱包的订单,均为原先方式
SellerType lst = SellerType.COMMON;
if(isEntry && isWalletPay){//入驻商家,订单是钱包方式支付
if(storageNum > 1){
lst = SellerType.ENTRY;
... ... @@ -34,9 +47,30 @@ public interface AbsSellerOrderViewService {
}
// 按钮显示
List<ButtonShowBo> buttons;
buttons = skupStatus.getListButtons(lst);
List<ButtonShowBo> buttons = null;
if(ViewType.LIST == viewType){
buttons = skupStatus.getListButtons(lst);
}
if (ViewType.DETAIL == viewType){
buttons = skupStatus.getDetailButtons(lst);
}
return buttons;
}
default ProductProxyService.PrdPrice getPrdPrice(int storageId){
ProductProxyService.PrdPrice prdPrice;
try {
StorageDataResp storage = getProductProxyService().getStorageData(storageId);
prdPrice = new ProductProxyService.PrdPrice();
prdPrice.setLeastPrice(storage.getLeastPrice());
}catch (Exception ex){
prdPrice = new ProductProxyService.PrdPrice();
}
return prdPrice;
}
}
... ...
... ... @@ -332,7 +332,7 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
orderDetailInfo.setUid(order.getUid());
orderDetailInfo.setOrderCode(getOrderCode(skupStatus, order));
Integer storageNum = sellerOrderGoods.getNum();
List<ButtonShowBo> buttons = getButtons(storageNum, sellerType, order.getPayment(), skupStatus);
List<ButtonShowBo> buttons = getButtons(ViewType.DETAIL, storageNum, sellerType, order.getPayment(), skupStatus);
orderDetailInfo.setButtons(buttons);
orderDetailInfo.setSubmitOrderTimeStr(DateUtil.formatDate(order.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
orderDetailInfo.setUserAddress(addressInfo);
... ... @@ -349,6 +349,12 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
}
orderDetailInfo.setStatusDetail(statusDetail);
GoodsInfo goodsInfo = getGoodsInfo(sellerOrderGoods);
if(SkupStatus.CAN_SELL.getCode() == skupStatus.getCode()){
ProductProxyService.PrdPrice prdPrice = getPrdPrice(sellerOrderGoods.getStorageId());
if (goodsInfo!=null){
goodsInfo.setLeastPrice(prdPrice.getLeastPrice());
}
}
orderDetailInfo.setGoodsInfo(goodsInfo);
// 支付状态
... ... @@ -401,4 +407,9 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
orderDetailInfo.getStatusDetail().setLeftTime(leftTime);
}
@Override
public ProductProxyService getProductProxyService() {
return productProxyService;
}
}
... ...
... ... @@ -214,7 +214,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
// 按钮显示
List<ButtonShowBo> buttons;
buttons = getButtons(storageNum, st, sellerOrder.getPayment(), skupStatus);
buttons = getButtons(ViewType.LIST, storageNum, st, sellerOrder.getPayment(), skupStatus);
orderListInfo.setButtons(buttons);
// 当订单状态是待付款, 显示leftTime
if (sellerOrderGoods.getStatus() == SkupStatus.CAN_NOT_SELL.getCode()){
... ... @@ -235,6 +235,10 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
goodsInfo.setBatchNo(sellerOrderGoods.getBatchNo());
goodsInfo.setStorageNum(storageNum);
goodsInfo.setSkupList(sellerOrderGoods.getSkupList());
if(SkupStatus.CAN_SELL.getCode() == skupStatus.getCode()){
ProductProxyService.PrdPrice prdPrice = getPrdPrice(sellerOrderGoods.getStorageId());
goodsInfo.setLeastPrice(prdPrice.getLeastPrice());
}
orderListInfo.setGoodsInfo(goodsInfo);
orderListInfo.setSecendLevelCreateTime(sellerOrder.getCreateTime());
orderListInfo.setCreateTime(DateUtil.formatDate(sellerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
... ... @@ -287,4 +291,9 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
});
return sellerOrderGoodsList;
}
@Override
public ProductProxyService getProductProxyService() {
return productProxyService;
}
}
... ...
... ... @@ -132,6 +132,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
@Autowired
private PriceComputePrepareProcessor priceComputePrepareProcessor;
@Autowired
private ChangePricePrepareProcessor changePricePrepareProcessor;
@Autowired
private SellerFeeService sellerFeeService;
public SoldPrdComputeBo computePublishPrd(SellerOrderComputeReq req) throws GatewayException {
log.info("in computePublishPrd, req {}", req);
PriceComputePrepareProcessor.PriceComputeNode pcn = priceComputePrepareProcessor.checkBasePrice(req);
... ... @@ -155,35 +164,14 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
return spc;
}
public SoldPrdComputeBo computeChangePrice(SellerOrderComputeReq req) throws GatewayException {
public SoldPrdComputeBo computeChangePrice(BatchChangePriceReq req) throws GatewayException {
log.info("in computeChangePrice, req {}", req);
PriceComputePrepareProcessor.PriceComputeNode pcn = priceComputePrepareProcessor.checkBasePrice(req);
int uid = pcn.getUid();
Integer storageId = pcn.getStorageId();
int num = pcn.getNum();
BigDecimal prdPrice = pcn.getPrdPrice();
SellerOrderComputeResult computeResult = computeHandler.compute(prdPrice);
/**
* 验证是否是入驻商家
*/
if(sellerOrderPrepareProcessor.checkIsEntry(uid)){
sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, computeResult.getEarnestMoney().getEarnestMoney(), num, prdPrice);
ChangePricePrepareDTO pcn = changePricePrepareProcessor.checkAndAcquire(req);
if (pcn.getTips() != null){
throw new UfoServiceException(SellerOrderPrepareProcessor.TIPS_ERROR_CODE, pcn.getTips() );
}
SellerOrderComputeResult computeResult = pcn.getComputeResult();
SoldPrdComputeBo spc = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult);
String tips = null;
try {
sellerOrderPrepareProcessor.checkPrice(storageId, prdPrice, true);
}catch (Exception ex){
if (ex instanceof UfoServiceException && ((UfoServiceException) ex).getCode() == SellerOrderPrepareProcessor.TIPS_ERROR_CODE){
tips = ((UfoServiceException) ex).getMessage();
}else{
throw ex;
}
}
spc.setTips(tips);
return spc;
}
... ... @@ -551,11 +539,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
.actor(orderRequest.getTabType()).build();
}
@Autowired
private ChangePricePrepareProcessor changePricePrepareProcessor;
@Autowired
private SellerFeeService sellerFeeService;
/**
* 批量调价
* @param req
... ... @@ -563,11 +547,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
*/
public BatchChangePriceResp batchChangePrice(BatchChangePriceReq req) throws GatewayException {
ChangePricePrepareDTO cppDto = changePricePrepareProcessor.checkAndAcquire(req);
BigDecimal diffEarnestMoney = cppDto.getDiffEarnestMoney();
if (diffEarnestMoney.compareTo(BigDecimal.ZERO) == 0){
throw new UfoServiceException(401, "前后价格没有变化");
}
int uid = req.getUid();
Map<Integer, SkupDto> skupMap = cppDto.getSkupMap();
SellerOrderComputeResult computeResult = cppDto.getComputeResult();
//1 划账
BigDecimal diffEarnestMoney = cppDto.getDiffEarnestMoney();
BigDecimal totalDiffMoney = diffEarnestMoney.multiply(new BigDecimal(skupMap.size()));
SellerWalletDetail.Type swdType = SellerWalletDetail.Type.ADD_PRICE;
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(req.getUid())
... ...
... ... @@ -117,6 +117,7 @@ public class ChangePricePrepareProcessor {
//作为入驻商户 检查钱包
BigDecimal targetEM = computeResult.getEarnestMoney().getEarnestMoney();
BigDecimal diffEarnestMoney = calDiffOfEM(sourceEM,targetEM);
if (diffEarnestMoney.compareTo(BigDecimal.ZERO)>0){
sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, diffEarnestMoney, num, salePrice);
}
... ...