| | |
| | | package com.matrix.system.hive.service.imp; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | |
| | | import com.matrix.system.common.dao.SysUsersDao; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.hive.bean.*; |
| | | import com.matrix.system.hive.dao.AchieveNewDao; |
| | | import com.matrix.system.hive.dao.ShoppingGoodsDao; |
| | | import com.matrix.system.hive.dao.SysBeauticianStateDao; |
| | | import com.matrix.system.hive.dao.SysProjUseDao; |
| | | import com.matrix.system.hive.dao.*; |
| | | import com.matrix.system.hive.plugin.util.CollectionUtils; |
| | | import com.matrix.system.hive.service.AchieveNewService; |
| | | import com.matrix.system.hive.service.SysProjServicesService; |
| | | import com.matrix.system.hiveErp.pojo.AchieveRuleItem; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | // 是否为赠送业绩 |
| | | if (Dictionary.TAOCAN_SOURCE_ZS.equals(projUse.getSource())) { |
| | | achieveNew.setFreeConsume(projUse.getPrice()*beauticianState.getCount()); |
| | | //计算提成 |
| | | achieveNew.setProjPercentage( |
| | | calculationProjPercentage(AchieveRuleItem.ACHIEVE_TYPE_ZS,achieveNew.getFreeConsume(),beauticianState.getProjId())); |
| | | } else { |
| | | achieveNew.setHisConsume(projUse.getPrice()*beauticianState.getCount()); |
| | | //计算提成 |
| | | achieveNew.setProjPercentage( |
| | | calculationProjPercentage(AchieveRuleItem.ACHIEVE_TYPE_BJ,achieveNew.getHisConsume(),beauticianState.getProjId())); |
| | | } |
| | | achieveNew.setT2(projUse.getSource()); |
| | | achieveNew.setDatatime(new Date()); |
| | |
| | | |
| | | } |
| | | |
| | | @Autowired |
| | | AchieveRuleDao achieveRuleDao; |
| | | |
| | | private Double calculationProjPercentage(int type, Double consume, Long goodsId) { |
| | | ShoppingGoods shoppingGoods = shoppingGoodsDao.selectById(goodsId); |
| | | if(shoppingGoods.getAchieveRuleId()!=null){ |
| | | |
| | | AchieveRule achieveRule = achieveRuleDao.selectById(shoppingGoods.getAchieveRuleId()); |
| | | if(achieveRule!=null){ |
| | | List<AchieveRuleItem> achieveRuleItems = JSONUtil.toList(JSONUtil.parseArray(achieveRule.getRules()), AchieveRuleItem.class); |
| | | double percentage=0D; |
| | | for(AchieveRuleItem item:achieveRuleItems){ |
| | | if(item.getAchieveType()==type |
| | | && (item.getLower() == consume |
| | | || (item.getLower()< consume && consume < item.getUpper() ))){ |
| | | |
| | | if(AchieveRuleItem.ACHIEVE_TYPE_FIXED==item.getCalculationType()){ |
| | | percentage=item.getAchieve(); |
| | | }else{ |
| | | percentage= consume * (item.getAchieve()/100); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | return percentage; |
| | | } |
| | | } |
| | | return 0D; |
| | | } |
| | | |
| | | /** |
| | | * 顾问人头业绩 |
| | | * @param achieveNew |
| | |
| | | for (AchieveNew achieveNew : orderItem.getAchieveList()) { |
| | | if (achieveNew !=null && achieveNew.getGoodsCash()!=null) { |
| | | buildAchieve(pageOrder, orderItem, achieveNew); |
| | | // 新增美疗师业绩 |
| | | achieveNewList.add(achieveNew); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | achieveNew.setVipId(pageOrder.getVipId()); |
| | | if(achieveNew.getSaleId()==null){ |
| | | achieveNew.setSaleId(pageOrder.getStaffId()); |
| | | } |
| | | |
| | | |
| | | if (pageOrder.getPayTime() != null) { |
| | | achieveNew.setDatatime(pageOrder.getPayTime()); |