| @@ -341,52 +341,24 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxCouponOrderCVo wxCouponOrderCVo = null; | |||
| String couponTenantId = paramMap.get("couponTenantId"); | |||
| TenantEntity couponOrderTenantEntity = getCouponOrderTenantEntity(couponTenantId); | |||
| wxCouponOrderCVo = wxCouponOrderService.detailCUserVo(couponOrderIdStr,couponOrderTenantEntity); | |||
| if (wxCouponOrderCVo == null) | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(wxCouponOrderCVo.getcUserId(),wxCouponOrderCVo.getFinalTenantId()); | |||
| if (wxCUserBasicInfo != null && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { | |||
| return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | |||
| } | |||
| Date now = new Date(); | |||
| if (wxCouponOrderCVo.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())){ | |||
| // && !wxCouponOrderCVo.getType().equals(EnumCouponType.COUPON_PREORDER.getCode())) { | |||
| if (wxCouponOrderCVo.getValidStartDate().after(now)) { | |||
| logger.error("此券有效期未开始:" + couponOrderIdStr); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | |||
| } | |||
| if (wxCouponOrderCVo.getValidEndDate().before(now)) { | |||
| logger.error("此券有效期已结束:" + couponOrderIdStr); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_LATER_THAN_VALIDDATE); | |||
| } | |||
| } else if(wxCouponOrderCVo.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode())){ | |||
| if (wxCouponOrderCVo.getExpiredTime().before(now)) { | |||
| logger.error("此券已过期:" + couponOrderIdStr); | |||
| return new ResultData(ErrorCode.COUPON_IS_EXPIRED); | |||
| } | |||
| } | |||
| WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(couponOrderId,couponOrderTenantEntity.getTenantId()); | |||
| if (wxCouponOrder == null) { | |||
| logger.error("券ID不存在:" + couponOrderId); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(wxCouponOrder.getcUserId(),wxCouponOrder.getFinalTenantId()); | |||
| if (wxCUserBasicInfo != null && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { | |||
| return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | |||
| } | |||
| WxMerchantBUser wxMerchantBUser = getLoginBUser(); | |||
| if (wxMerchantBUser == null) { | |||
| logger.error("核销员ID不存在:" + getLoginBUser().getId()); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "核销员ID不存在或者无权限"); | |||
| } | |||
| Long bUserId = getWxBuserId(); | |||
| if (null != bUserId) { | |||
| wxMerchantBUser.setBuserId(bUserId); | |||
| } | |||
| WxCouponOrder couponOrder = null; | |||
| try { | |||
| @@ -1,21 +1,31 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCouponOrderReservation; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.enums.EnumCouponOrderReservationStatus; | |||
| import com.iformall.service.WxCouponOrderReservationService; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("/api/wxCouponOrderReservation") | |||
| @Api(description = "查询预约接口") | |||
| @@ -25,6 +35,17 @@ public class WxCouponOrderReservationController extends BaseController { | |||
| @Autowired | |||
| private WxCouponOrderReservationService wxCouponOrderReservationService; | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| private WxMerchantRelationService wxMerchantRelationService; | |||
| @Autowired | |||
| private WxCouponOrderService wxCouponOrderService; | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @@ -117,5 +138,76 @@ public class WxCouponOrderReservationController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| /** | |||
| * 预约单核销 | |||
| * @param reservation | |||
| * @return | |||
| */ | |||
| @ApiOperation(value = "核销接口", notes = "{\"couponOrderId\":\"string\",\"couponTenantId\":\"string\"}") | |||
| @PostMapping("verify") | |||
| public ResultData verify(@RequestBody WxCouponOrderReservation reservation) { | |||
| logger.info("WxCouponOrderReservationController.verify:"); | |||
| WxMerchantBUser loginBUser = getLoginBUser(); | |||
| if(reservation.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"id is null"); | |||
| } | |||
| WxCouponOrderReservation sortReservation = wxCouponOrderReservationService.getSortById(reservation.getId(), reservation.getTenantId()); | |||
| if(sortReservation == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"id is error"); | |||
| } | |||
| if(EnumCouponOrderReservationStatus.getReservationFinish().contains(sortReservation.getStatus())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"预约单已完成"); | |||
| } | |||
| if(!EnumCouponOrderReservationStatus.getReservationIng().contains(sortReservation.getStatus())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"预约单状态不支持核销"); | |||
| } | |||
| if(sortReservation.getReservationMerchantId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"预约门店未找到"); | |||
| } | |||
| //登陆商户 | |||
| Long merchantId = loginBUser.getMerchantId(); | |||
| //核销商户 | |||
| WxMerchant merchant = null; | |||
| if(!sortReservation.getReservationMerchantId().equals(merchantId)){ | |||
| WxMerchant loginMerchant = wxMerchantService.selectById(merchantId); | |||
| if(!EnumMerchantAdmin.REGIONAL.getCode().equals(loginMerchant.getIsAdmin())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"非区域商户,核销失败"); | |||
| } | |||
| List<Long> subMerchantIds = wxMerchantRelationService.getRelationByRegionId(merchant.getId()); | |||
| if(!subMerchantIds.contains(sortReservation.getReservationMerchantId())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"区域门店不匹配,核销失败"); | |||
| } | |||
| merchant = wxMerchantService.selectById(sortReservation.getReservationMerchantId()); | |||
| } | |||
| WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(sortReservation.getCouponOrderId(),sortReservation.getTenantId()); | |||
| if (wxCouponOrder == null) { | |||
| logger.error("券ID不存在:" + sortReservation.getCouponOrderId()); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(wxCouponOrder.getcUserId(),wxCouponOrder.getFinalTenantId()); | |||
| if (wxCUserBasicInfo != null && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { | |||
| return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | |||
| } | |||
| WxCouponOrder couponOrder = null; | |||
| try { | |||
| wxCouponOrder.setVerifyRemark(EnumCouponVerifyType.VERIFY_B_13.getMessage()); | |||
| couponOrder = wxCouponOrderService.verify(wxCouponOrder, merchant, EnumCouponVerifyType.VERIFY_B,loginBUser); | |||
| } catch (MallinkException e) { | |||
| logger.error("核销异常: " + e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| logger.error("核销异常: " + e.getMessage()); | |||
| return new ResultData(ErrorCode.VERIFY_ERROR, e.getMessage()); | |||
| } | |||
| if (couponOrder != null) { | |||
| wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder.getId(), couponOrder, couponOrder.getBMerchantId(), loginBUser); | |||
| } | |||
| return new ResultData(couponOrder); | |||
| } | |||
| } | |||
| @@ -515,11 +515,6 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderService.detailCUserVo(couponOrderIdStr,getTenantInfo()); | |||
| if (wxCouponOrderCVo == null) | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| WxCUserBasicInfo member; | |||
| try { | |||
| member = getCacheMember(); | |||
| @@ -527,25 +522,6 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| Date now = new Date(); | |||
| if (wxCouponOrderCVo.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())){ | |||
| // && !wxCouponOrderCVo.getType().equals(EnumCouponType.COUPON_PREORDER.getCode())) { | |||
| if (wxCouponOrderCVo.getValidStartDate().after(now)) { | |||
| logger.error("此券有效期未开始:" + couponOrderIdStr); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | |||
| } | |||
| if (wxCouponOrderCVo.getValidEndDate().before(now)) { | |||
| logger.error("此券有效期已结束:" + couponOrderIdStr); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_LATER_THAN_VALIDDATE); | |||
| } | |||
| } else if(wxCouponOrderCVo.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode())){ | |||
| if (wxCouponOrderCVo.getExpiredTime().before(now)) { | |||
| logger.error("此券已过期:" + couponOrderIdStr); | |||
| return new ResultData(ErrorCode.COUPON_IS_EXPIRED); | |||
| } | |||
| } | |||
| WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(couponOrderId,getTenantInfo().getTenantId()); | |||
| if (wxCouponOrder == null) { | |||
| logger.error("券ID不存在:" + couponOrderId); | |||
| @@ -80,6 +80,9 @@ public class WxCouponOrderReservation extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private Date serchEndDate; | |||
| @TableField(exist = false) | |||
| private List<Integer> statusList; | |||
| @TableField(exist = false) | |||
| private List<Long> reservationMerchantIdList; | |||
| @@ -11,6 +11,7 @@ public enum EnumCouponVerifyType { | |||
| VERIFY_B_10(10,"B端收银核销"), | |||
| VERIFY_B_11(11,"B端券码核销"), | |||
| VERIFY_B_12(12,"B端扫码核销"), | |||
| VERIFY_B_13(13,"B端预约单核销"), | |||
| VERIFY_POS_INDEPENDENT(1, "POS独立核销"), | |||
| VERIFY_POS_PAY(2, "POS交易核销"), | |||
| @@ -1402,7 +1402,24 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrder.getId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| Date now = new Date(); | |||
| if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())){ | |||
| // && !wxCouponOrderCVo.getType().equals(EnumCouponType.COUPON_PREORDER.getCode())) { | |||
| if (wxCoupon.getValidStartDate().after(now)) { | |||
| logger.error("此券有效期未开始:" + couponOrder.getId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | |||
| } | |||
| if (wxCoupon.getValidEndDate().before(now)) { | |||
| logger.error("此券有效期已结束:" + couponOrder.getId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_LATER_THAN_VALIDDATE); | |||
| } | |||
| } | |||
| // 3. 券包状态检查 | |||
| if(couponOrder.getExpiredTime() != null && couponOrder.getExpiredTime().before(now)){ | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_LATER_THAN_VALIDDATE); | |||
| } | |||
| if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) { | |||
| logger.error("已过期: couponOrder-" + couponOrder.getId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); | |||
| @@ -1483,14 +1500,12 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| couponOrder.setBMerchantId(merchantId==null?0l:merchantId); | |||
| couponOrder.setBTenantId(mallTenantEntity.getTenantId()); | |||
| couponOrder.setVerifyType(couponVerifyType.getCode()); | |||
| if(EnumCouponVerifyType.VERIFY_B.equals(couponVerifyType) | |||
| && StringUtils.isNotBlank(couponOrder.getVerifyRemark())){ | |||
| if(couponOrder.getVerifyRemark().equals(EnumCouponVerifyType.VERIFY_B_11.getCode().toString())){ | |||
| couponOrder.setVerifyRemark(EnumCouponVerifyType.VERIFY_B_11.getMessage()); | |||
| }else if(couponOrder.getVerifyRemark().equals(EnumCouponVerifyType.VERIFY_B_12.getCode().toString())){ | |||
| couponOrder.setVerifyRemark(EnumCouponVerifyType.VERIFY_B_12.getMessage()); | |||
| } | |||
| } | |||
| if(EnumCouponVerifyType.VERIFY_B.equals(couponVerifyType) && StringUtils.isNotBlank(couponOrder.getVerifyRemark())){ | |||
| try{ | |||
| int subVerifyType = Integer.parseInt(couponOrder.getVerifyRemark()); | |||
| couponOrder.setVerifyRemark(EnumCouponVerifyType.getEnum(subVerifyType).getMessage()); | |||
| }catch(Exception e){} | |||
| } | |||
| if(EnumOrderShopingType.SELF_MENTION.getCode().equals(couponOrder.getShippingType())){ | |||
| couponOrder.setShippingStatus(EnumOrderShopingStatus.ALREADY_SELF_MENTION.getCode()); | |||
| }else if(EnumOrderShopingType.DISTRIBUTION.getCode().equals(couponOrder.getShippingType())){ | |||
| @@ -1551,37 +1566,16 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| TenantEntity tenantEntity = new TenantEntity(); | |||
| tenantEntity.setTenantId(tenantId); | |||
| tenantEntity.setParentTenantId(parentTenantId); | |||
| WxCouponOrder wxCouponOrder = this.getById(couponOrderId,tenantEntity.getTenantId()); | |||
| if (wxCouponOrder == null) { | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| WxCouponOrderCVo wxCouponOrderCVo = this.detailCUserVo(String.valueOf(couponOrderId),tenantEntity); | |||
| if (wxCouponOrderCVo == null) { | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(wxCouponOrderCVo.getcUserId(),wxCouponOrderCVo.getFinalTenantId()); | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(wxCouponOrder.getcUserId(),wxCouponOrder.getFinalTenantId()); | |||
| if (wxCUserBasicInfo != null && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { | |||
| throw new MallinkException(ErrorCode.MEMBER_IS_LOCKED); | |||
| } | |||
| Date now = new Date(); | |||
| if (wxCouponOrderCVo.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())){ | |||
| // && !wxCouponOrderCVo.getType().equals(EnumCouponType.COUPON_PREORDER.getCode())) { | |||
| if (wxCouponOrderCVo.getValidStartDate().after(now)) { | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | |||
| } | |||
| if (wxCouponOrderCVo.getValidEndDate().before(now)) { | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_LATER_THAN_VALIDDATE); | |||
| } | |||
| } else if(wxCouponOrderCVo.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode())){ | |||
| if (wxCouponOrderCVo.getExpiredTime().before(now)) { | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED); | |||
| } | |||
| } | |||
| WxCouponOrder wxCouponOrder = this.getById(couponOrderId,tenantEntity.getTenantId()); | |||
| if (wxCouponOrder == null) { | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| SysConfig sysConfig = sysConfigService.getByKey(SysConfigConstant.default_merchant_b_user, tenantEntity); | |||
| if (null == sysConfig) { | |||
| @@ -157,20 +157,6 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| return null; | |||
| } | |||
| private int getMallSumRate(TenantEntity tenantEntity,Long orderId){ | |||
| WxOrder o = wxOrderMapper.selectById(orderId, tenantEntity.getTenantId()); | |||
| if(!EnumOrderType.COUPON.getCode().equals(o.getType())){ | |||
| return 0; | |||
| } | |||
| Long couponId = wxCouponChannelMapper.findCouponIdById(o.getCouponChannelId(), o.getTenantId()); | |||
| TtPoiTakeRate ttPoiTakeRate = ttPoiTakeRateMapper.selectByCoupon(tenantEntity.getTenantId(), couponId, EnumCpsPlanType.ALL.getCode()); | |||
| if(ttPoiTakeRate != null){ | |||
| return ttPoiTakeRate.getTakeRate(); | |||
| }else{ | |||
| return 0; | |||
| } | |||
| } | |||
| @Override | |||
| // @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||
| public ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder,WxPayOrder payOrder) { | |||
| @@ -178,8 +164,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| if(!EnumProfitSharingOrderStatus.shareStatus().contains(sharingOrder.getSharingStatus())){ | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"分账状态不允许"); | |||
| } | |||
| //核销商户 | |||
| WxMerchant merchant = wxMerchantService.selectById(sharingOrder.getMerchantId()); | |||
| Date currentDate = new Date(); | |||
| @@ -188,19 +173,6 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| PayShareResult shareResult = null; | |||
| //获取达人佣金 | |||
| int cpsCommission = payShareAdapterService.getCPSCommission(sharingOrder,sharingOrder.getSingleOrderId()); | |||
| if(cpsCommission < 0){ | |||
| WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder(); | |||
| updSharingOrder.updateTenantInfo(sharingOrder); | |||
| updSharingOrder.setId(sharingOrder.getId()); | |||
| updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); | |||
| updSharingOrder.setErrorMsg("未获取到达人佣金"); | |||
| updSharingOrder.setUpdateTime(currentDate); | |||
| wxProfitSharingOrderMapper.updateById(updSharingOrder); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"未获取到达人佣金");//等待重试 | |||
| } | |||
| JSONArray receivers = new JSONArray();//分账参数json | |||
| EnumPayWay enumPayWay = EnumPayWay.getEnum(payOrder.getPayVendor()); | |||
| EnumAppPlat enumPlat = enumPayWay.getPlat(); | |||
| @@ -216,113 +188,85 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| }else{ | |||
| wxComposeChildOrderShare = payOrder.getSingleChildOrderShare(); | |||
| } | |||
| wxComposeChildOrderShare.setCpsCommission(cpsCommission); | |||
| //官方手续费---千6 | |||
| int realRate = serviceFeeService.getRealRate(payAccount); | |||
| int realRateAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), realRate, true); | |||
| wxComposeChildOrderShare.setRealRateAmount(realRateAmount); | |||
| //官方平台抽佣 | |||
| int rate = serviceFeeService.getOfficialCommissionByOrder(wxComposeChildOrderShare.getOrderId(),payAccount); | |||
| int commissionAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), rate, true); | |||
| wxComposeChildOrderShare.setCommissionAmount(commissionAmount); | |||
| int surplus = 0;//无法获取到各分账帐号时,计入收款帐号 | |||
| //只有抖音才有抽成 | |||
| //微信缺少流程(分账帐号绑定) 无法抽成 | |||
| if(EnumPayWay.PAY_WAY_TT.getCode().equals(payOrder.getPayVendor()) | |||
| && EnumYesOrNo.YES.getCode().equals(payAccount.getIsCommission())){ | |||
| //销售抽点+系统抽点 | |||
| int systemCommission = serviceFeeService.getSystemCommissionByOrder(wxComposeChildOrderShare.getOrderId(), payAccount); | |||
| int sellCommission = serviceFeeService.getSellCommission(payAccount); | |||
| int selSysAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), systemCommission+sellCommission, false); | |||
| //销售抽点 | |||
| int sellerAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), sellCommission, false); | |||
| wxComposeChildOrderShare.setSellerAmount(sellerAmount); | |||
| boolean isSeller = false; | |||
| if(sellerAmount > 0){ | |||
| WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PRIVATE_SELL,payOrder.getTtPayWay(), payOrder.getMchType()); | |||
| if(receiver != null){ | |||
| try{ | |||
| //处理所有的佣金 | |||
| boolean flag = serviceFeeService.handleShareServiceAmount(cAppInfo, payAccount, payOrder,wxComposeChildOrderShare); | |||
| if(!flag){ | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"未获取到服务费"); | |||
| } | |||
| //微信缺少流程(分账帐号绑定) 无法抽成 | |||
| if(EnumYesOrNo.YES.getCode().equals(payAccount.getIsCommission())){ | |||
| //系统 | |||
| if(wxComposeChildOrderShare.getSystemAmount() > 0){ | |||
| WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PRIVATE_SYSTEM,payOrder.getTtPayWay(), payOrder.getMchType()); | |||
| if(receiver == null){ | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"未获取到系统帐号2"); | |||
| } | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("type",EnumProfitPaymentReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||
| jo.put("account",receiver.getReceiverAccount()); | |||
| jo.put("amount", sellerAmount); | |||
| jo.put("amount", wxComposeChildOrderShare.getSystemAmount()); | |||
| jo.put("merchantId",receiver.getMerchantId()); | |||
| jo.put("bTenantId",receiver.getTenantId()); | |||
| jo.put("description",receiver.getId()); | |||
| jo.put("isPrivate",EnumYesOrNo.YES.getCode()); | |||
| receivers.add(jo); | |||
| }else{ | |||
| isSeller = true; | |||
| } | |||
| } | |||
| //系统抽成 | |||
| // int systemAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), payAccount.getSystemRate(), false); | |||
| int systemAmount = selSysAmount - sellerAmount; | |||
| wxComposeChildOrderShare.setSystemAmount(systemAmount); | |||
| if(isSeller){//未找到销售帐号时转入到系统帐号中 | |||
| systemAmount += sellerAmount; | |||
| } | |||
| boolean isSystem = false; | |||
| if(systemAmount > 0){ | |||
| WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PRIVATE_SYSTEM,payOrder.getTtPayWay(), payOrder.getMchType()); | |||
| if(receiver != null){ | |||
| //销售 | |||
| if(wxComposeChildOrderShare.getSellerAmount() > 0){ | |||
| WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PRIVATE_SELL,payOrder.getTtPayWay(), payOrder.getMchType()); | |||
| if(receiver == null){ | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"未获取到系统帐号3"); | |||
| } | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("type",EnumProfitPaymentReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||
| jo.put("account",receiver.getReceiverAccount()); | |||
| jo.put("amount", systemAmount); | |||
| jo.put("amount", wxComposeChildOrderShare.getSellerAmount()); | |||
| jo.put("merchantId",receiver.getMerchantId()); | |||
| jo.put("bTenantId",receiver.getTenantId()); | |||
| jo.put("description",receiver.getId()); | |||
| jo.put("isPrivate",EnumYesOrNo.YES.getCode()); | |||
| receivers.add(jo); | |||
| }else{ | |||
| isSystem = true; | |||
| } | |||
| } | |||
| //总分佣 | |||
| int mallRate = getMallSumRate(payOrder,wxComposeChildOrderShare.getOrderId()); | |||
| int serviceAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), mallRate, true); | |||
| wxComposeChildOrderShare.setServiceAmount(serviceAmount); | |||
| //商场分成 | |||
| int mallAmount = wxComposeChildOrderShare.getRateAmount(); | |||
| if(isSystem){//未找到系统帐号时转入商管商户中 | |||
| mallAmount += systemAmount; | |||
| } | |||
| boolean isMall = false; | |||
| if(mallAmount > 0){ | |||
| WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PUBLIC_ADMIN,payOrder.getTtPayWay(), payOrder.getMchType()); | |||
| if(receiver != null){ | |||
| //商管 | |||
| if(wxComposeChildOrderShare.getRateAmount() > 0){ | |||
| WxProfitSharingReceiver receiver = getByMerchantAdmin(sharingOrder,payShareAdapterService,wxComposeChildOrderShare.getMerchantId(),EnumMerchantAdmin.PUBLIC_ADMIN,payOrder.getTtPayWay(), payOrder.getMchType()); | |||
| if(receiver == null){ | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"未获取到商管帐号"); | |||
| } | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("type",EnumProfitPaymentReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||
| jo.put("account",receiver.getReceiverAccount()); | |||
| jo.put("amount", mallAmount); | |||
| jo.put("amount", wxComposeChildOrderShare.getRateAmount()); | |||
| jo.put("merchantId",receiver.getMerchantId()); | |||
| jo.put("bTenantId",receiver.getTenantId()); | |||
| jo.put("description",receiver.getId()); | |||
| jo.put("isPrivate",EnumYesOrNo.YES.getCode()); | |||
| receivers.add(jo); | |||
| }else{ | |||
| isMall = true; | |||
| } | |||
| } | |||
| if(isMall){ | |||
| surplus += mallAmount; | |||
| } | |||
| }else{ | |||
| wxComposeChildOrderShare.setServiceAmount(null); | |||
| }catch(Exception e){ | |||
| WxProfitSharingOrder updSharingOrder = new WxProfitSharingOrder(); | |||
| updSharingOrder.updateTenantInfo(sharingOrder); | |||
| updSharingOrder.setId(sharingOrder.getId()); | |||
| updSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); | |||
| updSharingOrder.setErrorMsg(e.getMessage()); | |||
| updSharingOrder.setUpdateTime(currentDate); | |||
| wxProfitSharingOrderMapper.updateById(updSharingOrder); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),e.getMessage()); | |||
| } | |||
| //商户所得 | |||
| int shareAmount = wxComposeChildOrderShare.getShareAmount(); | |||
| boolean isCallSharing = false;//是否调用分账 | |||
| boolean isCreateSubsidy = false;//是否需要记账 | |||
| boolean isSharingResult = false;//是否需要记录Result | |||
| boolean isSharingResult = false;//是否需要记录Result 解冻给收款方 | |||
| if(EnumPayWay.PAY_WAY_WECHAT.getCode().equals(payOrder.getPayVendor()) | |||
| && DateUtils.daysBetween(payOrder.getCreateTime(),currentDate) > 30){ | |||
| isCallSharing = false; | |||
| if(EnumPayShare.YES.getCode().equals(payOrder.getShare())){ | |||
| if(!sharingOrder.getMerchantId().equals(wxComposeChildOrderShare.getMerchantId())){ | |||
| isCreateSubsidy = true; | |||
| } | |||
| isSharingResult = true; | |||
| @@ -356,9 +300,11 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| receivers.add(jo); | |||
| }else if(EnumPayMchType.DIRECT.getCode().equals(payOrder.getMchType()) | |||
| && !sharingOrder.getMerchantId().equals(wxComposeChildOrderShare.getMerchantId())){ | |||
| //微信 直连 多商户 分不了账 记账 | |||
| isCreateSubsidy = true; | |||
| isSharingResult = true; | |||
| }else{ | |||
| //总分不分账 已经记过账了 | |||
| isSharingResult = true; | |||
| } | |||
| } | |||
| @@ -413,7 +359,6 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| if(isCreateSubsidy){ | |||
| try { | |||
| // 微信超过30天无法分账的, | |||
| WxOrder order = wxOrderMapper.selectById(sharingOrder.getSingleOrderId(), sharingOrder.getTenantId()); | |||
| wxCouponOrderService.recordAfterVerified(order, merchant); | |||
| } catch (Exception e) { | |||
| @@ -422,13 +367,12 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| } | |||
| if(isSharingResult){ | |||
| int sharingSubsidyAmount = shareAmount+surplus; | |||
| if(EnumPayMchType.TOTAL.getCode().equals(payOrder.getMchType())){ | |||
| //解冻给收款方(广场) +抽成没抽过去的。surplus | |||
| JSONObject jo = new JSONObject(); | |||
| // jo.put("type",EnumProfitPaymentReceiverType.wx_special_merchant_number.getMessage()); | |||
| jo.put("account",payAccount.getSubMchId()); | |||
| jo.put("amount", sharingSubsidyAmount); | |||
| jo.put("amount", shareAmount); | |||
| jo.put("merchantId",0); | |||
| jo.put("bTenantId",payOrder.getTenantId()); | |||
| jo.put("description",0); | |||
| @@ -440,13 +384,13 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| if(receiver != null && receiver.getReceiverAccount().equals(wxComposeChildOrderShare.getMerchantUid())){ | |||
| jo.put("type",EnumProfitPaymentReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||
| jo.put("account",receiver.getReceiverAccount()); | |||
| jo.put("amount", sharingSubsidyAmount); | |||
| jo.put("amount", shareAmount); | |||
| jo.put("merchantId",receiver.getMerchantId()); | |||
| jo.put("bTenantId",receiver.getTenantId()); | |||
| jo.put("description",receiver.getId()); | |||
| }else{ | |||
| jo.put("account",wxComposeChildOrderShare.getMerchantUid()); | |||
| jo.put("amount", sharingSubsidyAmount); | |||
| jo.put("amount", shareAmount); | |||
| jo.put("merchantId",wxComposeChildOrderShare.getMerchantId()); | |||
| jo.put("bTenantId",payOrder.getTenantId()); | |||
| jo.put("description",0); | |||
| @@ -72,30 +72,36 @@ public class WxComposeChildOrderShare { | |||
| private String merchantUid;//收款商户 | |||
| public void setServiceAmount(Integer serviceAmount){ | |||
| if(this.realPayMent == null){ | |||
| return; | |||
| } | |||
| if(this.realRateAmount == null){ | |||
| return; | |||
| } | |||
| int sumAmount = this.realRateAmount.intValue();//支付通道费 | |||
| int sumAmount = 0; | |||
| if(this.realRateAmount != null){ | |||
| sumAmount += this.realRateAmount;//支付通道费 | |||
| } | |||
| if(this.commissionAmount != null){ | |||
| sumAmount += this.commissionAmount.intValue();//平台服务费 | |||
| sumAmount += this.commissionAmount;//平台服务费 | |||
| } | |||
| if(this.cpsCommission != null){ | |||
| sumAmount += this.cpsCommission.intValue();//达人佣金 | |||
| } | |||
| if(this.systemAmount != null){ | |||
| sumAmount += this.systemAmount;//系统扣点 | |||
| sumAmount += this.cpsCommission;//达人佣金 | |||
| } | |||
| if(this.sellerAmount != null){ | |||
| sumAmount += this.sellerAmount;//销售扣点 | |||
| } | |||
| if(this.systemAmount != null){ | |||
| sumAmount += this.systemAmount;//系统扣点 | |||
| } | |||
| if(serviceAmount == null || serviceAmount.intValue() < sumAmount){ | |||
| if(serviceAmount == null || serviceAmount < sumAmount){ | |||
| this.serviceAmount = sumAmount; | |||
| }else{ | |||
| this.serviceAmount = serviceAmount;//一笔订单总扣除手续费 | |||
| } | |||
| this.rateAmount = this.serviceAmount.intValue() - sumAmount;//剩下的就是给商场的 | |||
| this.shareAmount = this.realPayMent.intValue() - this.serviceAmount.intValue();//这就是给商户的 | |||
| this.rateAmount = this.serviceAmount - sumAmount;//剩下的就是给商场的 | |||
| this.shareAmount = this.realPayMent - this.serviceAmount;//这就是给商户的 | |||
| } | |||
| } | |||
| @@ -3,7 +3,9 @@ package com.iformall.service.pay.service.fee; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxCashOut; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.WxPayOrder; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.service.order.entity.WxComposeChildOrderShare; | |||
| import com.iformall.service.pay.service.cashout.entity.CashOutAdapterResult; | |||
| /** | |||
| @@ -49,7 +51,10 @@ public interface ServiceFeeAdapterService { | |||
| * 获取所有的总抽佣费率 | |||
| * 如过设置了就返回,没设置返回0 | |||
| */ | |||
| public int getAllCommission(Long couponId, WxPayAccount payAccount); | |||
| public int getAllCommission(TenantEntity tenantEntity, Long orderId); | |||
| boolean handleShareServiceAmount(WxAppinfo cAppInfo, WxPayAccount payAccount, WxPayOrder payOrder, WxComposeChildOrderShare wxComposeChildOrderShare); | |||
| /** | |||
| * 获取商场抽佣费率 | |||
| @@ -1,11 +1,10 @@ | |||
| package com.iformall.service.pay.service.fee; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.TtPoiTakeRate; | |||
| import com.iformall.domain.po.WxMallVersion; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.douyin.pay.DouYinPayHelper; | |||
| import com.iformall.douyin.pay.orderQuery.QueryUnsettleAmount; | |||
| import com.iformall.enums.EnumCpsPlanType; | |||
| import com.iformall.enums.EnumDouyinApplicationVersion; | |||
| import com.iformall.enums.EnumOrderType; | |||
| @@ -19,6 +18,8 @@ import com.iformall.service.TtMallGoodsCategoryService; | |||
| import com.iformall.service.WxCouponService; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.service.order.entity.WxComposeChildOrderShare; | |||
| import com.iformall.utils.PayUtils; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Lazy; | |||
| @@ -104,16 +105,45 @@ public class TtServiceFeeService implements ServiceFeeAdapterService{ | |||
| // } | |||
| @Override | |||
| public int getAllCommission(Long couponId, WxPayAccount payAccount) { | |||
| int allRate = 0; | |||
| if(EnumYesOrNo.YES.getCode().equals(payAccount.getIsCommission())){ | |||
| TtPoiTakeRate ttPoiTakeRate = ttPoiTakeRateMapper.selectByCoupon(payAccount.getTenantId(), couponId, EnumCpsPlanType.ALL.getCode()); | |||
| if(ttPoiTakeRate != null && ttPoiTakeRate.getTakeRate() != null){ | |||
| allRate = ttPoiTakeRate.getTakeRate().intValue(); | |||
| } | |||
| public int getAllCommission(TenantEntity tenantEntity, Long orderId) { | |||
| WxOrder o = wxOrderMapper.selectById(orderId, tenantEntity.getTenantId()); | |||
| if(!EnumOrderType.COUPON.getCode().equals(o.getType())){ | |||
| return 0; | |||
| } | |||
| TtPoiTakeRate ttPoiTakeRate = ttPoiTakeRateMapper.selectByCoupon(tenantEntity.getTenantId(), o.getProductId(), EnumCpsPlanType.ALL.getCode()); | |||
| if(ttPoiTakeRate != null){ | |||
| return ttPoiTakeRate.getTakeRate(); | |||
| }else{ | |||
| return 0; | |||
| } | |||
| } | |||
| return allRate; | |||
| @Override | |||
| public boolean handleShareServiceAmount(WxAppinfo cAppInfo, WxPayAccount payAccount,WxPayOrder payOrder, WxComposeChildOrderShare wxComposeChildOrderShare) { | |||
| QueryUnsettleAmount queryUnsettleAmount = DouYinPayHelper.unsettleAmount(cAppInfo.getAppId(), payAccount.getMerchantApiKey(), payOrder.getOrderId().toString(), null); | |||
| if(queryUnsettleAmount == null){ | |||
| return false; | |||
| } | |||
| wxComposeChildOrderShare.setRealRateAmount(queryUnsettleAmount.getPaymentRake()); | |||
| wxComposeChildOrderShare.setCommissionAmount(queryUnsettleAmount.getLifeRake()); | |||
| wxComposeChildOrderShare.setCpsCommission(queryUnsettleAmount.getCommission()); | |||
| //销售 | |||
| int sellCommission = getSellCommission(payAccount); | |||
| int sellerAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), sellCommission, false); | |||
| wxComposeChildOrderShare.setSellerAmount(sellerAmount); | |||
| //系统 先计算销售+系统 然后再减去销售 | |||
| int systemCommission = getSystemCommission(null, payAccount); | |||
| int selSysAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), systemCommission+sellCommission, false); | |||
| int systemAmount = selSysAmount - sellerAmount; | |||
| wxComposeChildOrderShare.setSystemAmount(systemAmount); | |||
| //商品设置的总分佣率 | |||
| int allCommission = getAllCommission(payAccount,wxComposeChildOrderShare.getOrderId()); | |||
| int serviceAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), allCommission, true); | |||
| wxComposeChildOrderShare.setServiceAmount(serviceAmount); | |||
| return true; | |||
| } | |||
| // @Override | |||
| @@ -1,35 +1,13 @@ | |||
| package com.iformall.service.pay.service.fee; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxAppinfoMapper; | |||
| import com.iformall.mapper.WxPayAccountMapper; | |||
| import com.iformall.mapper.WxPayOrderMapper; | |||
| import com.iformall.pay.*; | |||
| import com.iformall.service.WxProfitPaymentReceiverService; | |||
| import com.iformall.service.WxProfitSharingReceiverService; | |||
| import com.iformall.service.pay.service.share.PayShareBaseAdapterService; | |||
| import com.iformall.service.pay.service.share.entity.PayShareQueryResult; | |||
| import com.iformall.service.pay.service.share.entity.PayShareResult; | |||
| import com.iformall.service.pay.service.share.entity.ShareAccountResult; | |||
| import com.iformall.service.pay.service.share.entity.ShareNotifyAdapterResult; | |||
| import com.iformall.utils.BeanUtils; | |||
| import com.iformall.utils.Utility; | |||
| import com.iformall.utils.XmlUtil; | |||
| import com.iformall.service.order.entity.WxComposeChildOrderShare; | |||
| import com.iformall.utils.PayUtils; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.text.ParseException; | |||
| import java.util.*; | |||
| @Slf4j | |||
| @Service | |||
| public class WxServiceFeeService implements ServiceFeeAdapterService{ | |||
| @@ -87,12 +65,40 @@ public class WxServiceFeeService implements ServiceFeeAdapterService{ | |||
| // } | |||
| @Override | |||
| public int getAllCommission(Long couponId, WxPayAccount payAccount) { | |||
| public int getAllCommission(TenantEntity tenantEntity, Long orderId) { | |||
| return 0; | |||
| } | |||
| @Override | |||
| public boolean handleShareServiceAmount(WxAppinfo cAppInfo, WxPayAccount payAccount, WxPayOrder payOrder, WxComposeChildOrderShare wxComposeChildOrderShare) { | |||
| int realRate = getRealRate(payAccount); | |||
| int payRate = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), realRate, true); | |||
| wxComposeChildOrderShare.setRealRateAmount(payRate); | |||
| wxComposeChildOrderShare.setCommissionAmount(0); | |||
| wxComposeChildOrderShare.setCpsCommission(0); | |||
| //销售 | |||
| int sellCommission = getSellCommission(payAccount); | |||
| int sellerAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), sellCommission, false); | |||
| wxComposeChildOrderShare.setSellerAmount(sellerAmount); | |||
| //系统 先计算销售+系统 然后再减去销售 | |||
| int systemCommission = getSystemCommission(null, payAccount); | |||
| int selSysAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), systemCommission+sellCommission, false); | |||
| int systemAmount = selSysAmount - sellerAmount; | |||
| wxComposeChildOrderShare.setSystemAmount(systemAmount); | |||
| //商品设置的总分佣率 | |||
| int allCommission = getAllCommission(payAccount,wxComposeChildOrderShare.getOrderId()); | |||
| int serviceAmount = PayUtils.getPayRate(wxComposeChildOrderShare.getRealPayMent(), allCommission, true); | |||
| wxComposeChildOrderShare.setServiceAmount(serviceAmount); | |||
| return true; | |||
| } | |||
| // @Override | |||
| // public int getMallCommission(Long couponId, WxPayAccount payAccount) { | |||
| // return 0; | |||
| // } | |||
| } | |||
| @@ -22,7 +22,7 @@ public class PayUtils { | |||
| Double dBaseAmount = 5.0D * 1000 / rate; | |||
| // 基础分 千分之6 83分 | |||
| if (isReal) { | |||
| // 小于基础分,四舍五入 | |||
| //四舍五入 | |||
| Double dPayRate = 1.0D * payAmount * rate / 10000; | |||
| long dChargeFee = Math.round(dPayRate); | |||
| return Long.valueOf(dChargeFee).intValue(); | |||
| @@ -106,6 +106,12 @@ | |||
| <if test=" null != status "> | |||
| and `status` = #{status} | |||
| </if> | |||
| <if test=" null != statusList and statusList.size > 0 "> | |||
| and `status` in | |||
| <foreach collection="statusList" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != btenantId and '' != btenantId"> | |||
| and `btenant_id` = #{btenantId} | |||
| @@ -164,13 +170,13 @@ | |||
| </select> | |||
| <select id="getSortById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select `id`,`tenant_id`,`parent_tenant_id`,`reservation_merchant_id`,`status` | |||
| select `id`,`tenant_id`,`parent_tenant_id`,`coupon_order_id`,`reservation_merchant_id`,`status` | |||
| from wx_coupon_order_reservation | |||
| where `id` = #{id} and tenant_id=#{tenantId} | |||
| </select> | |||
| <select id="getSortByCouponOrder" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select `id`,`tenant_id`,`parent_tenant_id`,`reservation_merchant_id`,`status` | |||
| select `id`,`tenant_id`,`parent_tenant_id`,`coupon_order_id`,`reservation_merchant_id`,`status` | |||
| from wx_coupon_order_reservation | |||
| where `coupon_order_id` = #{couponOrderId} and tenant_id=#{tenantId} | |||
| </select> | |||