| @@ -675,13 +675,41 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||
| if(wxCoupon.getSalePrice() == 0 || wxCoupon.checkIsCard()){ | |||
| return new ResultData(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED); | |||
| } | |||
| TtPoiTakeRate ttPoiTakeRate = ttPoiTakeRateMapper.selectByCoupon(tenantInfo.getTenantId(), couponId,EnumCpsPlanType.ALL.getCode(),null); | |||
| Map<String,Object> map = new HashMap<>(); | |||
| if(ttPoiTakeRate != null){ | |||
| map.put("mallRate",ttPoiTakeRate.getTakeRate()); | |||
| } | |||
| WxAppinfo couponAppInfo = wxAppinfoService.getCouponAppInfo(wxCoupon); | |||
| if(couponAppInfo == null || couponAppInfo.getPayId() == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountService.getById(couponAppInfo.getPayId()); | |||
| if(payAccount == null){ | |||
| return new ResultData(ErrorCode.API_KEY_NOT_FOUND); | |||
| } | |||
| map.put("realRate",payAccount.getRealRate()); | |||
| map.put("systemRate",payAccount.getSystemRate()+payAccount.getSellRate()); | |||
| int rate = payAccount.getRealRate()+payAccount.getSystemRate()+payAccount.getSellRate(); | |||
| if(EnumAppPlat.TOUTIAO.getCode().equals(couponAppInfo.getPlat())){ | |||
| if(wxCoupon.getCategoryId() == null){ | |||
| return new ResultData(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED.getCode(),"卡券信息错误"); | |||
| } | |||
| TtGoodsCategory ttGoodsCategory = ttGoodsCategoryMapper.selectById(wxCoupon.getCategoryId()); | |||
| map.put("serviceFeeRate",ttGoodsCategory.getServiceFee()-payAccount.getRealRate()); | |||
| rate = rate-payAccount.getRealRate()+ttGoodsCategory.getServiceFee(); | |||
| Integer maxTakeRate = ttPoiTakeRateMapper.getMaxTakeRate(wxCoupon.getTenantId(), wxCoupon.getId()); | |||
| if(maxTakeRate != null){ | |||
| rate += maxTakeRate; | |||
| } | |||
| rate += getRateMin(); | |||
| } | |||
| map.put("mallMax",getAllMax()); | |||
| map.put("mallMin",getAllMin(wxCoupon)); | |||
| map.put("mallMin",rate); | |||
| return new ResultData(map); | |||
| } | |||
| @@ -130,7 +130,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| // 4. 扣减计算 | |||
| Double paymentD = 1.0 * cardInfo.getSaleAmount() * record.getDeductionAmount() / cardInfo.getAmount(); | |||
| Integer payment = paymentD.intValue(); | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate(), false); | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRealRate(), false); | |||
| Integer real_payment = payment - iChargeFee; | |||
| Integer remain_real_pament = cardInfo.getRemainingShareFeeAmount() - real_payment; | |||
| Integer remaingAmount = cardInfo.getRemainingAmount() - record.getDeductionAmount(); | |||
| @@ -210,7 +210,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| logger.info("补贴额: " + subsidyFee); | |||
| if (cardInfo.getSaleAmount().equals(0) || subsidyFee > 0) { | |||
| // 有补贴时入库, 免费卡消费时, 或者有补贴金额时 | |||
| int iSubChargeFee = PayUtils.getPayRate(subsidyFee, payAccount.getRate(), false); | |||
| int iSubChargeFee = PayUtils.getPayRate(subsidyFee, payAccount.getRealRate(), false); | |||
| Integer realSubsidyFee = subsidyFee - iSubChargeFee; | |||
| WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy(); | |||
| merchantSubsidy.setId(idWorker.nextId()); | |||
| @@ -680,7 +680,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| // 4. 扣减计算 | |||
| Double paymentD = 1.0 * cardInfo.getSaleAmount() * record.getDeductionAmount() / cardInfo.getAmount(); | |||
| Integer payment = paymentD.intValue(); | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate(), false); | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRealRate(), false); | |||
| Integer real_payment = payment - iChargeFee; | |||
| Integer remain_real_pament = cardInfo.getRemainingShareFeeAmount() - real_payment; | |||
| Integer remaingAmount = cardInfo.getRemainingAmount() - record.getDeductionAmount(); | |||
| @@ -761,7 +761,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| // 4. 增加计算 | |||
| Double paymentD = 1.0 * cardInfo.getSaleAmount() * record.getDeductionAmount() / cardInfo.getAmount(); | |||
| Integer payment = paymentD.intValue(); | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate(), false); | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRealRate(), false); | |||
| Integer real_payment = payment - iChargeFee; | |||
| Integer remain_real_pament = cardInfo.getRemainingShareFeeAmount() + real_payment; | |||
| Integer remaingAmount = cardInfo.getRemainingAmount() + record.getDeductionAmount(); | |||
| @@ -855,7 +855,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| logger.info("补贴额: " + subsidyFee); | |||
| if (subsidyFee > 0) { | |||
| // 有补贴时入库 | |||
| int iSubChargeFee = PayUtils.getPayRate(subsidyFee, payAccount.getRate(), false); | |||
| int iSubChargeFee = PayUtils.getPayRate(subsidyFee, payAccount.getRealRate(), false); | |||
| Integer realSubsidyFee = subsidyFee - iSubChargeFee; | |||
| WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy(); | |||
| merchantSubsidy.setId(idWorker.nextId()); | |||
| @@ -1825,11 +1825,11 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| subsidyNum = subsidyNum * couponOrder.getCouponNumber(); | |||
| // 新补贴入库 | |||
| int iSubChargeFee = OrderHelper.getMallCharge(subsidyNum, payAccount); | |||
| int iSubChargeFee = OrderHelper.getRealRateAmount(subsidyNum, payAccount); | |||
| Integer realSubsidyFee = subsidyNum - iSubChargeFee; | |||
| WxOrder order = wxOrderMapper.selectById(couponOrder.getOrderId(), couponOrder.getTenantId()); | |||
| int iPriceChargeFee = OrderHelper.getMallCharge(coupon.getSalePrice(), payAccount); | |||
| int iPriceChargeFee = OrderHelper.getRealRateAmount(order.getPayment(), payAccount); | |||
| Integer realPayment = coupon.getSalePrice() - iPriceChargeFee; | |||
| WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy(); | |||
| @@ -1465,24 +1465,12 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| }else { | |||
| // 有价卡 | |||
| cardInfo.setTransactionId(payOrder.getTransactionId()); | |||
| if (payOrder.getShareAmount() != null) { | |||
| // 开启分账 | |||
| WxComposeChildOrderShare share = payOrder.getChildOrderShare(order.getId()); | |||
| fee = share.getRealPayMent() - share.getShareAmount(); | |||
| cardInfo.setShareFeeAmount(share.getShareAmount()); | |||
| cardInfo.setRemainingShareFeeAmount(share.getShareAmount()); | |||
| cardInfo.setRateAmount(share.getRateAmount()); | |||
| } else { | |||
| // 未开启分账 | |||
| WxComposeChildOrderShare share = payOrder.getChildOrderShare(order.getId()); | |||
| Integer orderRealPayMent = share.getRealPayMent(); | |||
| fee = OrderHelper.getMallCharge(orderRealPayMent, payAccount); | |||
| Integer shareAmount = orderRealPayMent - fee; | |||
| cardInfo.setShareFeeAmount(shareAmount); | |||
| cardInfo.setRemainingShareFeeAmount(shareAmount); | |||
| int systemAmount = OrderHelper.getAmount(orderRealPayMent, payAccount.getSystemRate());//系统扣点 | |||
| cardInfo.setRateAmount(OrderHelper.getMallRateAmount(orderRealPayMent, fee,systemAmount, payAccount)); | |||
| } | |||
| WxComposeChildOrderShare share = payOrder.getChildOrderShare(order.getId()); | |||
| fee = OrderHelper.getRealRateAmount(share.getRealPayMent(), payAccount); | |||
| Integer shareAmount = share.getRealPayMent() - fee; | |||
| cardInfo.setShareFeeAmount(shareAmount); | |||
| cardInfo.setRemainingShareFeeAmount(shareAmount); | |||
| cardInfo.setRateAmount(0); | |||
| } | |||
| } else { | |||
| // 免费卡 | |||
| @@ -220,6 +220,8 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| wxComposeChildOrderShare.setCommissionAmount(commissionAmount); | |||
| int surplus = 0;//当广场抽成帐号与收款帐号相等,无法添加分账方,计入商管商户中 | |||
| if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType())){ | |||
| //销售抽点+系统抽点 | |||
| int selSysAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), payAccount.getSellRate()+payAccount.getSystemRate(), false); | |||
| //销售抽点 | |||
| int sellerAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), payAccount.getSellRate(), false); | |||
| wxComposeChildOrderShare.setSellerAmount(sellerAmount); | |||
| @@ -239,7 +241,8 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| } | |||
| } | |||
| //系统抽成 | |||
| int systemAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), payAccount.getSystemRate(), false); | |||
| // int systemAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), payAccount.getSystemRate(), false); | |||
| int systemAmount = selSysAmount - sellerAmount; | |||
| wxComposeChildOrderShare.setSystemAmount(systemAmount); | |||
| if(sellerAmount > 0 && receivers.isEmpty()){ | |||
| systemAmount += systemAmount; | |||
| @@ -57,18 +57,18 @@ public class OrderHelper { | |||
| } | |||
| //商场总包费用,扣掉商场设置的手续费率,默认取最小整数,不四舍五入 | |||
| public static int getMallCharge(Integer payment,WxPayAccount payAccount) { | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate(), false); | |||
| return iChargeFee; | |||
| } | |||
| //商场总包费用,扣掉商场设置的手续费率,是否四舍五入 | |||
| public static int getMallCharge(Integer payment,WxPayAccount payAccount,boolean round) { | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate(), round); | |||
| return iChargeFee; | |||
| } | |||
| // public static int getMallCharge(Integer payment,WxPayAccount payAccount) { | |||
| // int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate(), false); | |||
| // return iChargeFee; | |||
| // } | |||
| // //商场总包费用,扣掉商场设置的手续费率,是否四舍五入 | |||
| // public static int getMallCharge(Integer payment,WxPayAccount payAccount,boolean round) { | |||
| // int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate(), round); | |||
| // return iChargeFee; | |||
| // } | |||
| public static void main(String[] args) { | |||
| System.out.println(getMallCharge(null, null)); | |||
| // System.out.println(getMallCharge(null, null)); | |||
| } | |||
| //微信、支付宝交易的手续费. | |||
| @@ -80,15 +80,15 @@ public class OrderHelper { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"支付通道费率未设置."); | |||
| } | |||
| //费率差. iChargeFee:商场扣掉的手续费 | |||
| public static Integer getMallRateAmount(Integer payment,int mallCharge,int systemAmount, WxPayAccount payAccount) { | |||
| int iRealChargeFee = getRealRateAmount(payment, payAccount); | |||
| if (iRealChargeFee < 0) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"支付通道费率设置非法."); | |||
| } | |||
| if(mallCharge > (iRealChargeFee + systemAmount)) { | |||
| return mallCharge - iRealChargeFee - systemAmount; | |||
| }else { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"支付费率设置非法:商场总扣点小于支付通道和系统扣点之和."); | |||
| } | |||
| } | |||
| // public static Integer getMallRateAmount(Integer payment,int mallCharge,int systemAmount, WxPayAccount payAccount) { | |||
| // int iRealChargeFee = getRealRateAmount(payment, payAccount); | |||
| // if (iRealChargeFee < 0) { | |||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"支付通道费率设置非法."); | |||
| // } | |||
| // if(mallCharge > (iRealChargeFee + systemAmount)) { | |||
| // return mallCharge - iRealChargeFee - systemAmount; | |||
| // }else { | |||
| // throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"支付费率设置非法:商场总扣点小于支付通道和系统扣点之和."); | |||
| // } | |||
| // } | |||
| } | |||