Authored by chenchao

fix payment show tariff amount when goods in hk

... ... @@ -4,6 +4,7 @@ import com.yoho.core.common.utils.YHMath;
import com.yohobuy.ufo.model.order.bo.AmountCutPolicy;
import com.yohobuy.ufo.model.order.constants.AmountCutType;
import com.yohobuy.ufo.model.order.constants.DeliveryWayEnum;
import com.yohobuy.ufo.model.order.constants.RegionEnum;
import com.yohobuy.ufo.model.promotion.UserCouponsBo;
import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum;
import com.yohoufo.common.exception.UfoServiceException;
... ... @@ -125,11 +126,11 @@ public class ChargeService {
}
SingleFeeDetail tariffDetail = SingleFeeDetail.builder()
SingleFeeDetail feeDetail = SingleFeeDetail.builder()
.amount(initAmount)
.cutAmount(cutAmount)
.finalAmount(finalAmount).build();
return tariffDetail;
return feeDetail;
}
... ... @@ -168,21 +169,23 @@ public class ChargeService {
double oldFinalAmount = chargeResult.getFinalAmount();
double newFinalAmount = Math.max(0, YHMath.sub(oldFinalAmount, realCutPrice.doubleValue()));
double tariffAmount = 0D;
//税费
BigDecimal goodsPrice = chargeGoods.getGoodsPrice();
AmountCutPolicy tariffCutPolicy = chargeContext.getChargeParam().getTariffCutPolicy();
SingleFeeDetail tariffFeeDetail = calculateTariffAmount(goodsPrice, tariffRate, tariffCutPolicy);
chargeResult.setTariffFee(tariffFeeDetail);
//加上税费
double tariffAmount = tariffFeeDetail.getAmount();
double finalTariffAmount = tariffFeeDetail.getFinalAmount();
if (finalTariffAmount > 0D){
//calculate final amount of goods
newFinalAmount = YHMath.add(finalTariffAmount, newFinalAmount);
}
if (chargeGoods.getRegion().equals(RegionEnum.HONGKONG)) {
BigDecimal goodsPrice = chargeGoods.getGoodsPrice();
AmountCutPolicy tariffCutPolicy = chargeContext.getChargeParam().getTariffCutPolicy();
SingleFeeDetail tariffFeeDetail = calculateTariffAmount(goodsPrice, tariffRate, tariffCutPolicy);
chargeResult.setTariffFee(tariffFeeDetail);
//加上税费
tariffAmount = tariffFeeDetail.getAmount();
double finalTariffAmount = tariffFeeDetail.getFinalAmount();
if (finalTariffAmount > 0D) {
//calculate final amount of goods
newFinalAmount = YHMath.add(finalTariffAmount, newFinalAmount);
}
chargeResult.setFinalAmount(newFinalAmount);
chargeResult.setFinalAmount(newFinalAmount);
}
ActivityCutResult activityCutResult = ActivityCutResult.builder()
.userActivityId(activityPrice.getUserActivityId())
... ...
... ... @@ -628,10 +628,12 @@ public class ShoppingServiceImpl implements IShoppingService {
amountDetailBo.setActivityCutAmount(chargeResult.getActivityCutResult().getActivityCutAmount());
//税费
amountDetailBo.setTariffRate(chargeResult.getTariffFee().getRate());
amountDetailBo.setTariffAmount(chargeResult.getTariffFee().getAmount());
amountDetailBo.setTariffCutAmount(chargeResult.getTariffFee().getCutAmount());
SingleFeeDetail tariffFee;
if (Objects.nonNull(tariffFee = chargeResult.getTariffFee())) {
amountDetailBo.setTariffRate(tariffFee.getRate());
amountDetailBo.setTariffAmount(tariffFee.getAmount());
amountDetailBo.setTariffCutAmount(tariffFee.getCutAmount());
}
//活动券减免金额
chargeResult.getCouponPayResultList().getCouponPayResultByCouponType(CouponTypeEnum.ACTIVITY_COUPON.getCode()).
ifPresent(tempPayResult -> amountDetailBo.setCouponCutAmount(tempPayResult.getCouponAmount()));
... ...