| | |
| | | package com.matrix.system.shopXcx.mqTask; |
| | | |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.matrix.biz.bean.BizUser; |
| | | import com.matrix.biz.service.BizUserService; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.fenxiao.constant.FenxiaoSettingConstant; |
| | | import com.matrix.system.fenxiao.dao.ShopSalesmanGradeDao; |
| | | import com.matrix.system.fenxiao.dao.ShopSalesmanOrderDao; |
| | | import com.matrix.system.fenxiao.entity.ShopSalesmanGrade; |
| | |
| | | import com.matrix.system.hive.service.SysOrderService; |
| | | import com.matrix.system.shopXcx.bean.ShopOrder; |
| | | import com.matrix.system.shopXcx.bean.ShopOrderDetails; |
| | | import com.matrix.system.shopXcx.bean.ShopProduct; |
| | | import com.matrix.system.shopXcx.dao.ShopOrderDao; |
| | | import com.matrix.system.shopXcx.dao.ShopOrderDetailsDao; |
| | | import com.matrix.system.shopXcx.dao.ShopSkuDao; |
| | |
| | | salesmanOrder.setRevenueType(ShopSalesmanOrder.REVENUE_TYPE_SALES); |
| | | salesmanOrder.setOrderStatus(ShopSalesmanOrder.STATUS_DJS); |
| | | Double salesAmount=0D; |
| | | Double selfAmount=0D; |
| | | Double invitationAmount=0D; |
| | | Double orderTotal=0D; |
| | | Double zk=1D; |
| | |
| | | BizUser invitationMan=null; |
| | | ShopSalesmanOrder invitationOrder=null; |
| | | boolean hasInvitationMan=StringUtils.isNotBlank(salesMan.getParentOpenId()); |
| | | |
| | | |
| | | //判断推广员是否还存在上级,存在则计算邀请收益 |
| | | if(hasInvitationMan){ |
| | | invitationMan=bizUserService.findByOpenId(salesMan.getParentOpenId()); |
| | |
| | | //收益计算 |
| | | for (ShopOrderDetails item:order.getDetails() ){ |
| | | if(StringUtils.isNotBlank(item.getShopProduct().getAttrValues()) |
| | | && item.getShopProduct().getAttrValues().contains("分销商城")){ |
| | | && item.getShopProduct().getAbleSales()==ShopProduct.ABLE_SALES){ |
| | | if(item.getShopSku().getSealesPrice()==null |
| | | ||item.getShopSku().getSealesPrice().doubleValue()==0){ |
| | | //按分销等级计算 |
| | |
| | | invitationAmount+=item.getShopSku().getInvitationPrice().doubleValue()*item.getCount(); |
| | | } |
| | | } |
| | | //分销规则是否开启自购返佣 |
| | | BusParameterSettings zgfy = parameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_ZGFY, bizUser.getCompanyId()); |
| | | 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 { |
| | | //按产品设置的自购返佣金额计算 |
| | | selfAmount+=item.getShopSku().getSelfPrice().doubleValue()*item.getCount(); |
| | | } |
| | | } |
| | | } |
| | | orderTotal+=item.getTotalPrice().doubleValue(); |
| | | } |
| | | } |
| | | //自购返佣记录生成 |
| | | if(selfAmount > 0) { |
| | | //整体的优惠金额折算成折扣,* 佣金 |
| | | zk=order.getOrderMoney().doubleValue()/orderTotal; |
| | | selfAmount=selfAmount*zk; |
| | | salesmanOrder.setAmount(selfAmount); |
| | | shopSalesmanOrderDao.insert(salesmanOrder); |
| | | } |
| | | if(salesAmount>0){ |
| | | //整体的优惠金额折算成折扣,* 佣金 |
| | | zk=order.getOrderMoney().doubleValue()/orderTotal; |