| | |
| | | for (ShopOrderDetails item:order.getDetails() ){ |
| | | if(StringUtils.isNotBlank(item.getShopProduct().getAttrValues()) |
| | | && item.getShopProduct().getAbleSales()==ShopProduct.ABLE_SALES){ |
| | | if(item.getShopSku().getSealesPrice()==null |
| | | ||item.getShopSku().getSealesPrice().doubleValue()==0){ |
| | | //按分销等级计算 |
| | | ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectById(salesMan.getSalesmanGrade()); |
| | | salesAmount+=item.getTotalPrice().doubleValue()*(shopSalesmanGrade.getSealesCommission()/100); |
| | | |
| | | if(hasInvitationMan){ |
| | | ShopSalesmanGrade invitationManGrade = shopSalesmanGradeDao.selectById(invitationMan.getSalesmanGrade()); |
| | | invitationAmount+=item.getTotalPrice().doubleValue()*(invitationManGrade.getInvitationCommission()/100); |
| | | } |
| | | |
| | | }else{ |
| | | //按产品设置的推广金额计算 |
| | | salesAmount+=item.getShopSku().getSealesPrice().doubleValue()*item.getCount(); |
| | | if(hasInvitationMan){ |
| | | invitationAmount+=item.getShopSku().getInvitationPrice().doubleValue()*item.getCount(); |
| | | } |
| | | } |
| | | //分销规则是否开启自购返佣 |
| | | BusParameterSettings zgfy = parameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_ZGFY, bizUser.getCompanyId()); |
| | | //按分销等级计算 |
| | | ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectById(salesMan.getSalesmanGrade()); |
| | | if(ObjectUtil.isNotEmpty(zgfy)) { |
| | | //获取商品的自购返佣价格,如果没有设置,在去获取当前推广人的等级的自购返佣比例 |
| | | if(StrUtil.isNotEmpty(zgfy.getParamValue()) && |
| | | FenxiaoSettingConstant.FX_ZGFY_YES.equals(zgfy.getParamValue())) { |
| | | if(item.getShopSku().getSelfPrice() == null |
| | | ||item.getShopSku().getSealesPrice().doubleValue() == 0){ |
| | | //按分销等级计算 |
| | | ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectById(salesMan.getSalesmanGrade()); |
| | | selfAmount+=item.getTotalPrice().doubleValue()*(shopSalesmanGrade.getSelfCommission()/100); |
| | | }else { |
| | | //按产品设置的自购返佣金额计算 |
| | |
| | | } |
| | | } |
| | | } |
| | | //推广提成,按分销等级计算或者按产品设置的推广金额计算 |
| | | if(item.getShopSku().getSealesPrice()==null |
| | | ||item.getShopSku().getSealesPrice().doubleValue()==0){ |
| | | salesAmount+=item.getTotalPrice().doubleValue()*(shopSalesmanGrade.getSealesCommission()/100); |
| | | }else{ |
| | | salesAmount+=item.getShopSku().getSealesPrice().doubleValue()*item.getCount(); |
| | | } |
| | | //邀请提成,获取商品的邀请提成价格和是否有上级推广人,如果没有设置,在去获取当前推广人的等级的自购返佣比例 |
| | | if(hasInvitationMan) { |
| | | if(item.getShopSku().getInvitationPrice() == null |
| | | ||item.getShopSku().getInvitationPrice().doubleValue() == 0){ |
| | | //获取上级的推广等级设置 |
| | | ShopSalesmanGrade invitationManGrade = shopSalesmanGradeDao.selectById(invitationMan.getSalesmanGrade()); |
| | | invitationAmount+=item.getTotalPrice().doubleValue()*(invitationManGrade.getInvitationCommission()/100); |
| | | }else { |
| | | //按产品设置的邀请提成价格计算 |
| | | invitationAmount+=item.getShopSku().getInvitationPrice().doubleValue()*item.getCount(); |
| | | } |
| | | } |
| | | |
| | | orderTotal+=item.getTotalPrice().doubleValue(); |
| | | } |
| | | } |
| | | //自购返佣记录生成 |
| | | //自购返佣记录 |
| | | if(selfAmount > 0) { |
| | | //整体的优惠金额折算成折扣,* 佣金 |
| | | zk=order.getOrderMoney().doubleValue()/orderTotal; |
| | |
| | | salesmanOrder.setAmount(selfAmount); |
| | | shopSalesmanOrderDao.insert(salesmanOrder); |
| | | } |
| | | //推广提成记录 |
| | | if(salesAmount>0){ |
| | | //整体的优惠金额折算成折扣,* 佣金 |
| | | zk=order.getOrderMoney().doubleValue()/orderTotal; |
| | | salesAmount=salesAmount*zk; |
| | | salesmanOrder.setAmount(salesAmount); |
| | | shopSalesmanOrderDao.insert(salesmanOrder); |
| | | if(hasInvitationMan){ |
| | | invitationAmount=invitationAmount*zk; |
| | | invitationOrder.setAmount(invitationAmount); |
| | | shopSalesmanOrderDao.insert(invitationOrder); |
| | | } |
| | | //整体的优惠金额折算成折扣,* 佣金 |
| | | zk=order.getOrderMoney().doubleValue()/orderTotal; |
| | | salesAmount=salesAmount*zk; |
| | | salesmanOrder.setAmount(salesAmount); |
| | | shopSalesmanOrderDao.insert(salesmanOrder); |
| | | } |
| | | //邀请提成记录 |
| | | if(invitationAmount > 0) { |
| | | //整体的优惠金额折算成折扣,* 佣金 |
| | | invitationAmount=invitationAmount*zk; |
| | | invitationOrder.setAmount(invitationAmount); |
| | | shopSalesmanOrderDao.insert(invitationOrder); |
| | | } |
| | | }else{ |
| | | LogUtil.debug("重复订单id={}",order.getId()); |
| | | } |