| @@ -7,7 +7,6 @@ import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.vo.WxShopVo; | import com.iformall.domain.vo.WxShopVo; | ||||
| import com.iformall.enums.EnumBusiness; | import com.iformall.enums.EnumBusiness; | ||||
| import com.iformall.enums.EnumSubBusiness; | import com.iformall.enums.EnumSubBusiness; | ||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| @@ -26,8 +25,6 @@ public class WxMerchant extends BaseEntity { | |||||
| protected Long id; | protected Long id; | ||||
| @ApiModelProperty(name = "ids", value = "商户ID数组") | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<Long> userids; | private List<Long> userids; | ||||
| @@ -44,5 +44,6 @@ public class WxPayAccount extends BaseEntity { | |||||
| return notifyUrl + "/subsidyPay"; | return notifyUrl + "/subsidyPay"; | ||||
| } | } | ||||
| public boolean checkShare() { return share > 0; } | |||||
| } | } | ||||
| @@ -241,16 +241,18 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| } | } | ||||
| } | } | ||||
| // 9. 分账 | |||||
| try { | |||||
| shareForCardPay(record.getTenantId(), record.getCardId(), record.getOrderId(), record.getId()); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| if(ErrorCode.PROFIT_SHARING_NUM_UP_LIMIT.getCode() == e.getErrorCode()) { | |||||
| // 分账已到20次限制,后面只记录,无法分账 | |||||
| logger.error("分账已到20次限制,后面只记录,无法分账"); | |||||
| } else { | |||||
| throw new MallinkException(e.getErrorCode(), e.getMessage()); | |||||
| if (payAccount.checkShare()) { | |||||
| // 9. 分账 | |||||
| try { | |||||
| shareForCardPay(record.getTenantId(), record.getCardId(), record.getOrderId(), record.getId()); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| if (ErrorCode.PROFIT_SHARING_NUM_UP_LIMIT.getCode() == e.getErrorCode()) { | |||||
| // 分账已到20次限制,后面只记录,无法分账 | |||||
| logger.error("分账已到20次限制,后面只记录,无法分账"); | |||||
| } else { | |||||
| throw new MallinkException(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -705,6 +705,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| cardInfo.setRemainingAmount(coupon.getPrice()); | cardInfo.setRemainingAmount(coupon.getPrice()); | ||||
| if (!coupon.checkIsFree()) { | if (!coupon.checkIsFree()) { | ||||
| // 有价卡 | |||||
| try { | try { | ||||
| WxPayOrder payOrderQ = new WxPayOrder(); | WxPayOrder payOrderQ = new WxPayOrder(); | ||||
| payOrderQ.setTenantId(user.getTenantId()); | payOrderQ.setTenantId(user.getTenantId()); | ||||
| @@ -714,12 +715,36 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("payOrder not found:" + e.getMessage()); | logger.error("payOrder not found:" + e.getMessage()); | ||||
| } | } | ||||
| fee = payOrder.getPayAmount() - payOrder.getShareAmount(); | |||||
| cardInfo.setTransactionId(payOrder.getTransactionId()); | cardInfo.setTransactionId(payOrder.getTransactionId()); | ||||
| cardInfo.setShareFeeAmount(payOrder.getShareAmount()); | |||||
| cardInfo.setRemainingShareFeeAmount(payOrder.getShareAmount()); | |||||
| cardInfo.setRateAmount(payOrder.getRateAmount()); | |||||
| if (payOrder.getShareAmount() != null) { | |||||
| // 开启分账 | |||||
| fee = payOrder.getPayAmount() - payOrder.getShareAmount(); | |||||
| cardInfo.setShareFeeAmount(payOrder.getShareAmount()); | |||||
| cardInfo.setRemainingShareFeeAmount(payOrder.getShareAmount()); | |||||
| cardInfo.setRateAmount(payOrder.getRateAmount()); | |||||
| } else { | |||||
| // 未开启分账 | |||||
| WxPayAccount payAccount = null; | |||||
| WxPayAccount payAccountQ = new WxPayAccount(); | |||||
| payAccountQ.setTenantId(cardInfo.getTenantId()); | |||||
| try { | |||||
| payAccount = wxPayAccountMapper.selectOne(new QueryWrapper<>(payAccountQ)); | |||||
| fee = PayUtils.getPayRate(payOrder.getPayAmount(), payAccount.getRate(), false); | |||||
| Integer shareAmount = payOrder.getPayAmount() - fee; | |||||
| cardInfo.setShareFeeAmount(shareAmount); | |||||
| cardInfo.setRemainingShareFeeAmount(shareAmount); | |||||
| if(payAccount.getRealRate() != null) { | |||||
| int iRealChargeFee = PayUtils.getPayRate(payOrder.getPayAmount(), payAccount.getRealRate(), true); | |||||
| if(fee > iRealChargeFee) { | |||||
| cardInfo.setRateAmount(fee - iRealChargeFee); | |||||
| } | |||||
| } | |||||
| } catch (Exception e) { | |||||
| logger.error("获取payAccount error: " + cardInfo.getTenantId()); | |||||
| } | |||||
| } | |||||
| } else { | } else { | ||||
| // 免费卡 | |||||
| cardInfo.setShareFeeAmount(0); | cardInfo.setShareFeeAmount(0); | ||||
| cardInfo.setRemainingShareFeeAmount(0); | cardInfo.setRemainingShareFeeAmount(0); | ||||
| cardInfo.setRateAmount(0); | cardInfo.setRateAmount(0); | ||||
| @@ -169,7 +169,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); | return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); | ||||
| } | } | ||||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | ||||
| if (payAccount.getShare().intValue() > 0) { | |||||
| if (payAccount.checkShare()) { | |||||
| isShare = EnumPayShare.YES; | isShare = EnumPayShare.YES; | ||||
| } | } | ||||
| @@ -433,7 +433,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); | return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); | ||||
| } | } | ||||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | ||||
| if (payAccount.getShare().intValue() > 0) { | |||||
| if (payAccount.checkShare()) { | |||||
| isShare = EnumPayShare.YES; | isShare = EnumPayShare.YES; | ||||
| } | } | ||||
| @@ -91,7 +91,7 @@ public class WxSubsidyServiceImpl implements WxSubsidyService { | |||||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(user.getTenantId()); | WxAppinfo appInfo = wxAppinfoService.getCAppInfo(user.getTenantId()); | ||||
| // 2. 获取payAccount | // 2. 获取payAccount | ||||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | ||||
| if (payAccount.getShare().intValue() > 0) { | |||||
| if (payAccount.checkShare()) { | |||||
| isShare = EnumPayShare.YES; | isShare = EnumPayShare.YES; | ||||
| } | } | ||||
| // 3. 补贴订单 | // 3. 补贴订单 | ||||