Authored by sailing-PC\sailing

optimized code

... ... @@ -202,7 +202,7 @@ public class SellerOrderService {
//
UserAddressRspBO addressRspBO = userProxyService.getAddressInfo(uid, req.getAddressId());
backAddress.setAddress(addressRspBO.getAddress());
backAddress.setConsignee(addressRspBO.getUid());
backAddress.setConsignee(addressRspBO.getAddresseeName());
backAddress.setPhone(addressRspBO.getPhone());
backAddress.setZipCode(addressRspBO.getZipCode());
... ... @@ -274,7 +274,7 @@ public class SellerOrderService {
String earnestMoneyStr = formatFee(earnestMoney);
String bankTransferFeeStr = buildSubtractFee(formatFee(bankTransferfee));
SoldPrdComputeBo computeBo = SoldPrdComputeBo.builder()
.earnestMoney(earnestMoney.setScale(2).doubleValue())
.earnestMoney(earnestMoney.doubleValue())
.earnestMoneyStr(earnestMoneyStr)
.bankTransferFee(bankTransferFeeStr)
.platformFee(platformFeeWrapper)
... ...
... ... @@ -22,9 +22,7 @@ public class SellerOrderComputeHandler {
BigDecimal bankTransferfee = calBankTransferFee(prdPrice);
PlatformFeeDto platformFeeDto = calPlatformFee();
BigDecimal income = calIncome(prdPrice, platformFeeDto.getTotal(), bankTransferfee);
//set
SellerOrderComputeResult result = new SellerOrderComputeResult();
result.setEarnestMoney(earnestMoney);
result.setBankTransferfee(bankTransferfee);
... ... @@ -35,13 +33,18 @@ public class SellerOrderComputeHandler {
private BigDecimal calBankTransferFee(BigDecimal prdPrice){
//银行转账费(0.65%+¥1.00)
return prdPrice.multiply(new BigDecimal(0.0065)).add(new BigDecimal(1));
return halfUp(prdPrice.multiply(new BigDecimal(0.0065)).add(new BigDecimal(1)));
}
private BigDecimal calIncome(BigDecimal prdPrice,BigDecimal platformFee,BigDecimal bankTransferfee){
return prdPrice.subtract(platformFee).subtract(bankTransferfee);
return halfUp(prdPrice.subtract(platformFee).subtract(bankTransferfee));
}
/**
* 通过相加得出的数据
* TODO 服务费参与计算后需要考虑精度问题(四舍五入)
* @return
*/
private PlatformFeeDto calPlatformFee(){
BigDecimal appraiseFee = new BigDecimal(10);;
... ... @@ -57,19 +60,25 @@ public class SellerOrderComputeHandler {
return platformFee;
}
/**
* 相对独立 不涉及到计算其他费用
* @param prdPrice
* @return
*/
private BigDecimal calEarnestMoney(BigDecimal prdPrice){
BigDecimal real = prdPrice.multiply(new BigDecimal(0.05));
BigDecimal real = halfUp(prdPrice.multiply(new BigDecimal(0.05)));
final BigDecimal min = EARNESTMONEYRANGE[0];
final BigDecimal max = EARNESTMONEYRANGE[1];
if(real.subtract(min).doubleValue() < 0D){
return min;
}
if (real.subtract(max).doubleValue() > 0D){
return max;
}
return real;
}
private BigDecimal halfUp(BigDecimal fee){
return fee.setScale(2, BigDecimal.ROUND_HALF_UP);
}
}
... ...
... ... @@ -4,7 +4,6 @@ import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.service.model.request.UserAddressReqBO;
import com.yoho.service.model.response.UserAddressRspBO;
import com.yohoufo.order.constants.OrderConstant;
import com.yohoufo.order.request.ShoppingRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ...