Authored by chenchao

change tips of compute

... ... @@ -7,23 +7,75 @@ import com.yohoufo.common.utils.PriceFormater;
import com.yohoufo.order.model.dto.EarnestMoney;
import com.yohoufo.order.model.dto.PlatformFeeDto;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.service.proxy.ResourcesProxyService;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.util.Map;
/**
* Created by chenchao on 2018/9/20.
*/
public final class SellerOrderConvertor {
public static SoldPrdComputeBo computeResult2SoldPrdComputeBo(SellerOrderComputeResult computeResult){
public static SoldPrdComputeBo pureComputeResult2SoldPrdComputeBo(SellerOrderComputeResult computeResult){
//保证金(28-200(按照卖家发布商品的货款金额5%计算,最低28,封顶200))
EarnestMoney earnestMoneyDTO = computeResult.getEarnestMoney();
BigDecimal earnestMoney = earnestMoneyDTO.getEarnestMoney();
PlatformFeeDto platformFeeDto = computeResult.getPlatformFee();
BigDecimal income = computeResult.getIncome();
//service tips
String serviceTipsDesc = null;
String serviceTipsSummary = null;
//
String payPersent = computeResult.getServiceFeeRate() != null ? computeResult.getServiceFeeRate().getPayChannelPercent() : "";
PlatformFee platformFeeWrapper = PlatformFee.builder()
.amount(buildSubtractFee(formatFee(platformFeeDto.getTotal())))
.appraiseFee(formatFee(platformFeeDto.getAppraiseFee()))
.packageFee(formatFee(platformFeeDto.getPackageFee()))
.serviceFee(formatFee(platformFeeDto.getServiceFee()))
.payChannelPercentage(payPersent)
.build();
//
String incomeStr = formatFee(income);
String earnestMoneyStr = formatFee(earnestMoney);
String bankTransferFeeStr = formatFee(computeResult.getBankTransferfee());
//
SoldPrdComputeBo computeBo = SoldPrdComputeBo.builder()
.earnestMoney(earnestMoney.doubleValue())
.earnestMoneyStr(earnestMoneyStr)
.platformFee(platformFeeWrapper)
.bankTransferFee(buildSubtractFee(bankTransferFeeStr))
.income(incomeStr)
.serviceTipsDesc(serviceTipsDesc)
.serviceTipsSummary(serviceTipsSummary)
.build();
return computeBo;
}
public static SoldPrdComputeBo computeResult2SoldPrdComputeBo(SellerOrderComputeResult computeResult,
Map<String,String> tipsConfig){
//保证金(28-200(按照卖家发布商品的货款金额5%计算,最低28,封顶200))
EarnestMoney earnestMoneyDTO = computeResult.getEarnestMoney();
BigDecimal earnestMoney = earnestMoneyDTO.getEarnestMoney();
PlatformFeeDto platformFeeDto = computeResult.getPlatformFee();
BigDecimal income = computeResult.getIncome();
//service tips
String serviceTipsDesc = null;
String serviceTipsSummary = null;
//
String payPersent = computeResult.getServiceFeeRate() != null ? computeResult.getServiceFeeRate().getPayChannelPercent() : "";
if (StringUtils.isNotBlank(payPersent)){
serviceTipsSummary = String.format("(%s)", payPersent);
}else{
if(tipsConfig!=null){
serviceTipsDesc = tipsConfig.get(ResourcesProxyService.KEY_SERVICETIPSDESC);
serviceTipsSummary = tipsConfig.get(ResourcesProxyService.KEY_SERVICETIPSSUMARY);
}
}
PlatformFee platformFeeWrapper = PlatformFee.builder()
.amount(buildSubtractFee(formatFee(platformFeeDto.getTotal())))
.appraiseFee(formatFee(platformFeeDto.getAppraiseFee()))
... ... @@ -35,12 +87,15 @@ public final class SellerOrderConvertor {
String incomeStr = formatFee(income);
String earnestMoneyStr = formatFee(earnestMoney);
String bankTransferFeeStr = formatFee(computeResult.getBankTransferfee());
//
SoldPrdComputeBo computeBo = SoldPrdComputeBo.builder()
.earnestMoney(earnestMoney.doubleValue())
.earnestMoneyStr(earnestMoneyStr)
.platformFee(platformFeeWrapper)
.bankTransferFee(buildSubtractFee(bankTransferFeeStr))
.income(incomeStr)
.serviceTipsDesc(serviceTipsDesc)
.serviceTipsSummary(serviceTipsSummary)
.build();
return computeBo;
... ...
... ... @@ -218,7 +218,7 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
SoldPrdComputeBo computeBo = null;
if(metaIsPresent){
SellerOrderComputeResult computeResult = JSONObject.parseObject(feeMeta.getMetaValue(), SellerOrderComputeResult.class);
computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult);
computeBo = SellerOrderConvertor.pureComputeResult2SoldPrdComputeBo(computeResult);
}
if(Objects.nonNull(computeBo)){
orderDetailInfo.setEarnestMoneyStr(computeBo.getEarnestMoneyStr());
... ...
... ... @@ -41,6 +41,7 @@ import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.concurrent.ThreadPoolFactory;
import com.yohoufo.order.service.handler.*;
import com.yohoufo.order.service.proxy.ResourcesProxyService;
import com.yohoufo.order.service.seller.processor.*;
import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase;
import com.yohoufo.order.service.impl.visitor.UserCancelCase;
... ... @@ -164,6 +165,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
@Autowired
private SellerBatchCancelPrepareProcessor sellerBatchCancelPrepareProcessor;
@Autowired
private ResourcesProxyService resourcesProxyService;
private static final int MAX_DEAL = 10;
... ... @@ -196,7 +199,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
log.info("in computeChangePrice, req {}", req);
ChangePricePrepareDTO pcn = changePricePrepareProcessor.checkAndAcquire(req);
SellerOrderComputeResult computeResult = pcn.getComputeResult();
SoldPrdComputeBo spc = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult);
Map<String,String> tipsConfig = resourcesProxyService.getServiceTipsConfig();
SoldPrdComputeBo spc = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult, tipsConfig);
spc.setTips(pcn.getTips());
return spc;
}
... ... @@ -205,7 +209,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
log.info("in computeAdjustPrice, req {}", req);
ChangePricePrepareDTO pcn = adjustPricePrepareProcessor.checkAndAcquire(req);
SellerOrderComputeResult computeResult = pcn.getComputeResult();
SoldPrdComputeBo spc = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult);
Map<String,String> tipsConfig = resourcesProxyService.getServiceTipsConfig();
SoldPrdComputeBo spc = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult, tipsConfig);
spc.setTips(pcn.getTips());
return spc;
}
... ... @@ -531,8 +536,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
priceComputePrepareProcessor.checkNGetMergeEarnestMoney(uid,
computeResult.getEarnestMoney().getEarnestMoney(), num, salePrice, isSuper);
}
SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult);
Map<String,String> tipsConfig = resourcesProxyService.getServiceTipsConfig();
SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult, tipsConfig);
return computeBo;
}
... ...
package com.yohoufo.order.service.proxy;
import com.yohoufo.common.caller.UfoServiceCaller;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Created by chao.chen on 2019/3/26.
*/
public class AbsProxyService {
@Autowired
UfoServiceCaller ufoServiceCaller;
}
... ...
... ... @@ -27,13 +27,10 @@ import java.util.stream.Collectors;
* Created by jiexiang.wu on 2018/11/19.
*/
@Service
public class CouponProxyService implements Compensator {
public class CouponProxyService extends AbsProxyService implements Compensator {
private final static Logger logger = LoggerUtils.getBuyerOrderLogger();
@Autowired
private UfoServiceCaller serviceCaller;
/**
* 查询用户可以使用的券
*
... ... @@ -43,7 +40,7 @@ public class CouponProxyService implements Compensator {
public List<UserCouponsBo> getUserAvailableCoupons(int uid) {
logger.info("[{}] getUserAvailableCoupons", uid);
//未使用的优惠券,包括还未生效的券
ApiResponse resp = serviceCaller.call("ufo.coupons.listNoUsed", uid);
ApiResponse resp = ufoServiceCaller.call("ufo.coupons.listNoUsed", uid);
UserCouponsListBo result = getResultFromApiResponse(resp);
if (Objects.isNull(result) || CollectionUtils.isEmpty(result.getCoupons())) {
return Lists.newArrayList();
... ... @@ -56,7 +53,7 @@ public class CouponProxyService implements Compensator {
public List<UserCouponsBo> checkAndGetCoupons(int uid, List<String> couponCodes) {
logger.info("[{}] checkAndGetCoupons:{}", uid, couponCodes);
//未使用的优惠券,包括还未生效的券
ApiResponse resp = serviceCaller.call("ufo.coupons.checkAndGet", uid, couponCodes);
ApiResponse resp = ufoServiceCaller.call("ufo.coupons.checkAndGet", uid, couponCodes);
UserCouponsListBo result = getResultFromApiResponse(resp);
if (Objects.isNull(result) || CollectionUtils.isEmpty(result.getCoupons())) {
return Lists.newArrayList();
... ... @@ -76,7 +73,7 @@ public class CouponProxyService implements Compensator {
public void orderUseCoupon(@TxCompensateArgs("uid") int uid, @TxCompensateArgs("orderCode") long orderCode,
@TxCompensateArgs("couponBo") CouponBo coupon) {
logger.info("[{}] request to use coupon,couponBo is {}", orderCode, coupon);
ApiResponse resp = serviceCaller.call("ufo.coupons.use", uid, orderCode, Lists.newArrayList(coupon.getCouponCode()));
ApiResponse resp = ufoServiceCaller.call("ufo.coupons.use", uid, orderCode, Lists.newArrayList(coupon.getCouponCode()));
Boolean result = getResultFromApiResponse(resp);
if (result == null || result.booleanValue() == false) {
logger.warn("[{}] use couponBo fail,coupons is {}", orderCode, coupon);
... ... @@ -95,7 +92,7 @@ public class CouponProxyService implements Compensator {
*/
public void orderCancelCoupon(int uid, long orderCode, CouponBo coupon) {
logger.info("[{}] request to cancel coupon,couponBo is {}", orderCode, coupon);
ApiResponse resp = serviceCaller.call("ufo.coupons.cancel", uid, orderCode, Lists.newArrayList(coupon.getCouponCode()));
ApiResponse resp = ufoServiceCaller.call("ufo.coupons.cancel", uid, orderCode, Lists.newArrayList(coupon.getCouponCode()));
Boolean result = getResultFromApiResponse(resp);
if (result == null || result.booleanValue() == false) {
logger.warn("[{}] cancel coupon fail,couponBo is {}", orderCode, coupon);
... ...
... ... @@ -29,17 +29,13 @@ import java.util.*;
* Created by chenchao on 2018/9/21.
*/
@Service
public class ProductProxyService {
public class ProductProxyService extends AbsProxyService{
final Logger logger = LoggerFactory.getLogger(getClass());
private static final int isAdvace = 1;
@Autowired
private UfoServiceCaller ufoServiceCaller;
public final static String syncSkup = "ufo.product.createSkup";
public final static String SYNC_SKUP_STATUS = "ufo.product.sellerUpdateStatus";
... ...
package com.yohoufo.order.service.proxy;
import com.yohoufo.common.ApiResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* Created by chao.chen on 2019/3/26.
*/
@Service
public class ResourcesProxyService extends AbsProxyService{
private final Logger logger = LoggerFactory.getLogger(getClass());
final static String configTypeList= "ufo.resource.configTypeList";
public static final String KEY_SERVICETIPSDESC = "serviceTipsDesc",
KEY_SERVICETIPSSUMARY = "serviceTipsSumary";
static final String[] cloneKeys = new String[]{KEY_SERVICETIPSDESC, KEY_SERVICETIPSSUMARY};
public Map<String,String> getServiceTipsConfig(){
final String method = configTypeList;
Map<String,String> data = new HashMap<>();
try {
logger.info("in ResourcesProxyService getServiceTipsConfig call {}", method);
ApiResponse resp = ufoServiceCaller.call(method);
if (resp!= null){
Map<String,String> rd = (Map<String,String>)resp.getData();
for(String key : cloneKeys){
data.put(key, rd.get(key));
}
}
}catch (Exception ex){
logger.warn("getServiceTipsConfig call {} fail, use default config value", method);
data.put(KEY_SERVICETIPSDESC, "活动期间平台服务费全免,何时收费,提前一个月另行通知");
}
return data;
}
}
... ...
... ... @@ -20,6 +20,7 @@ import com.yohoufo.order.model.dto.ChangePricePrepareDTO;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.impl.SellerOrderCancelService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.proxy.ResourcesProxyService;
import com.yohoufo.order.service.seller.SellerChangePriceRecordService;
import com.yohoufo.order.service.seller.processor.NESChangePricePrepareProcessor;
import com.yohoufo.order.service.seller.processor.NESChangePricePublishPrepareProcessor;
... ... @@ -31,6 +32,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
... ... @@ -81,6 +83,9 @@ public class NotEntrySellerChangePriceService{
@Autowired
private ProductProxyService productProxyService;
@Autowired
private ResourcesProxyService resourcesProxyService;
public boolean isChangePriceOrder(long orderCode){
//
... ... @@ -88,6 +93,7 @@ public class NotEntrySellerChangePriceService{
return Objects.nonNull(scpr);
}
/**
* compute Change Price4 NES(Not Entry Seller)
* @param req
... ... @@ -96,7 +102,9 @@ public class NotEntrySellerChangePriceService{
public SoldPrdComputeBo computeChangePrice(NESChangePriceReq req){
logger.info("in NotEntrySellerChangePriceService.computeChangePrice, req {}", req);
ChangePricePrepareDTO cppDto = nesChangePricePrepareProcessor.checkAndAcquire(req);
SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(cppDto.getComputeResult());
Map<String,String> tipsConfig = resourcesProxyService.getServiceTipsConfig();
SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(cppDto.getComputeResult(), tipsConfig);
return computeBo;
}
... ...