diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/domain/enumtype/ProfitPostType.java b/emis-biz/src/main/java/com/xdadan/erp/emis/domain/enumtype/ProfitPostType.java new file mode 100644 index 000000000..f091f0f84 --- /dev/null +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/domain/enumtype/ProfitPostType.java @@ -0,0 +1,35 @@ +package com.xdadan.erp.emis.domain.enumtype; + +/** + * 提成计算岗位类型 + */ +public enum ProfitPostType { + + SITE_KEFU_EMP(1,"网点客服"), + KJDZ_EMP(2,"快件单证"), + TAKE_EMP(3,"取件员"), + SITE_OP_EMP(4,"网点操作员"), + DISPATCH_EMP(5,"派件员"), + SALES_EMP(6,"销售联系人"), + MID_OP_EMP(7,"中转操作员"), + DZ_EMP(8,"单证员"), + ; + + +// 网点客服 1 +// 快件单证 2 +// 取件员 3 +// 网点操作员 4 +// 派件员 5 +// 销售联系人 6 +// 中转操作员 7 +// 单证员 8 + + public Integer typeCode; + public String typeName; + + ProfitPostType(Integer typeCode, String typeName) { + this.typeCode = typeCode; + this.typeName = typeName; + } +} diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisCommissionDtlMapper.java b/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisCommissionDtlMapper.java index b00dac7d7..50d9c035f 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisCommissionDtlMapper.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisCommissionDtlMapper.java @@ -70,6 +70,14 @@ public interface EmisCommissionDtlMapper extends BaseMapper */ public int deleteEmisCommissionDtlById(Long id); + + /** + * 根据运单号删除 + * @param billCode + * @return + */ + public int deleteEmisCommissionDtlByBillCode(String billCode); + /** * 批量删除 * diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisWaybillMapper.java b/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisWaybillMapper.java index 44d98e4c0..0f631b947 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisWaybillMapper.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/mapper/EmisWaybillMapper.java @@ -150,6 +150,12 @@ public interface EmisWaybillMapper extends BaseMapper // 取消出账标识 public int cancelHasDoBill(EmisWaybill emisWaybill); + // 打提成标识 + public int updateHasDoProfit(EmisWaybill emisWaybill); + + // 取消出账标识 + public int cancelHasDoProfit(EmisWaybill emisWaybill); + // 更新问题件状态 public int updateProblemStatus(EmisWaybill emisWaybill); diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisCommissionProfitServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisCommissionProfitServiceImpl.java index 459b8dd9f..c241a2a4f 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisCommissionProfitServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisCommissionProfitServiceImpl.java @@ -10,16 +10,24 @@ package com.xdadan.erp.emis.service.impl; +import java.math.BigDecimal; +import java.util.Date; import java.util.List; -import com.xdadan.erp.emis.domain.EmisCommissionExpression; -import com.xdadan.erp.emis.domain.EmisCommissionQuote; -import com.xdadan.erp.emis.domain.EmisWaybill; +import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.googlecode.aviator.AviatorEvaluator; +import com.xdadan.erp.common.utils.DateUtils; +import com.xdadan.erp.common.utils.DictUtils; +import com.xdadan.erp.emis.domain.*; +import com.xdadan.erp.emis.domain.enumtype.ProfitPostType; +import com.xdadan.erp.emis.mapper.EmisCommissionDtlMapper; import com.xdadan.erp.emis.mapper.EmisCommissionQuoteMapper; +import com.xdadan.erp.emis.mapper.EmisWaybillMapper; import com.xdadan.erp.emis.service.EmisBaseService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.xdadan.erp.emis.domain.EmisCommissionProfit; import com.xdadan.erp.emis.mapper.EmisCommissionProfitMapper; import com.xdadan.erp.emis.service.IEmisCommissionProfitService; import org.springframework.transaction.annotation.Transactional; @@ -31,6 +39,7 @@ import org.springframework.util.CollectionUtils; * @author linfso * @date 2024-10-24 01:46:36 */ + @Slf4j @Service public class EmisCommissionProfitServiceImpl extends EmisBaseService implements IEmisCommissionProfitService { @@ -40,6 +49,11 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements @Autowired private EmisCommissionQuoteMapper emisCommissionQuoteMapper; + @Autowired + private EmisCommissionDtlMapper emisCommissionDtlMapper; + + @Autowired + protected EmisWaybillMapper emisWaybillMapper; /** * 根据单号重新计算提成 @@ -51,12 +65,8 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements // 获取运单信息 EmisWaybill waybill = getWaybillByBillCode(billCode); - // 取件方式 - String pickUpMethod=waybill.getPickupMethod(); - String takePieceEmployeeCode=waybill.getTakePieceEmployeeCode(); - String operateEmployeeCode=waybill.getOperateEmployeeCode(); - String country=waybill.getReceiveCountry(); - String fromCountry=waybill.getSendCountry(); + // 先删除该运单已经计算的提成 + emisCommissionDtlMapper.deleteEmisCommissionDtlByBillCode(billCode); // 计算每个岗位的提成方案 /* @@ -71,34 +81,919 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements */ // 根据不同岗位计算 - for(int i=1;i<=8;i++) { - // 网点客服 1 - if(i==1) { - EmisCommissionQuote emisCommissionQuote = new EmisCommissionQuote(); - emisCommissionQuote.setPostType("1"); - emisCommissionQuote.setCountry(country); - emisCommissionQuote.setFromCountry(fromCountry); - // 获取提成方案 - List listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote); - if(!CollectionUtils.isEmpty(listQuote)){ - for (EmisCommissionQuote quoteItem:listQuote) { - List exprList=quoteItem.getExprList(); - // 按票计算方式 - if("1".equals(quoteItem.getCalcType())){ - - - } - - } - } + for(int postTypeIndex=1;postTypeIndex<=8;postTypeIndex++) { + // 1.网点客服 + if(postTypeIndex == ProfitPostType.SITE_KEFU_EMP.typeCode) { + calcSiteFefuProfit(waybill); } + // 2.快件单证 + else if(postTypeIndex == ProfitPostType.KJDZ_EMP.typeCode) { + calcKjdzProfit(waybill); + } + // 3.取件员 + else if(postTypeIndex == ProfitPostType.TAKE_EMP.typeCode) { + calcTakeProfit(waybill); + } + // 4.网点操作员 + else if(postTypeIndex == ProfitPostType.SITE_OP_EMP.typeCode) { + calcOpProfit(waybill); + } + // 5.派件员 + else if(postTypeIndex == ProfitPostType.DISPATCH_EMP.typeCode) { + calcDispatchProfit(waybill); + } + // 6.销售联系人 + else if(postTypeIndex == ProfitPostType.SALES_EMP.typeCode) { + calcSalesProfit(waybill); + } + // 7.中转操作员 + else if(postTypeIndex == ProfitPostType.MID_OP_EMP.typeCode) { + calcMidOpProfit(waybill); + } + // 8.单证员 + else if(postTypeIndex == ProfitPostType.DZ_EMP.typeCode) { + calcDzProfit(waybill); + } + } + // 运单打上已计算提成标记 + emisWaybillMapper.updateHasDoProfit(waybill); + return 1; } + /** + * 计算客服提成 + * @param waybill + */ + private void calcSiteFefuProfit(EmisWaybill waybill){ + String pickUpMethod=waybill.getPickupMethod(); + String takePieceEmployeeCode=waybill.getTakePieceEmployeeCode(); + String operateEmployeeCode=waybill.getOperateEmployeeCode(); + String billMonth= DateUtils.parseDateToStr(DateUtils.YYYY_MM,waybill.getSendDate()); + String country=waybill.getReceiveCountry(); + String fromCountry=waybill.getSendCountry(); + + EmisCommissionQuote emisCommissionQuote = new EmisCommissionQuote(); + emisCommissionQuote.setPostType("1"); + emisCommissionQuote.setCountry(country); + emisCommissionQuote.setFromCountry(fromCountry); + // 获取提成方案 + List listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote); + if(!CollectionUtils.isEmpty(listQuote)){ + for (EmisCommissionQuote quoteItem:listQuote) { + List exprList=quoteItem.getExprList(); + if(!CollectionUtils.isEmpty(exprList)) { + + String calcExprStr=""; + for (EmisCommissionExpression exprItem : exprList) { + log.info("计算项目表达式:" + JSONObject.toJSONString(exprItem)); + + String calcExp = exprItem.getCalculateExpression(); + + double profitMoney = 0.0D; + // 按票计算 + if ("1".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按票计算:计算公式:" + calcExprStr + ",票数:1"); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 重量计算 + else if ("2".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + + } + // 体积计算 + else if ("3".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 包裹数 + else if ("4".equals(quoteItem.getCalcType())) { + + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按包裹数:计算公式:" + calcExprStr + ",包裹数:"+1); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + + // 插入参与分成人员 + String empCode=quoteItem.getEmpCode(); + String empName=quoteItem.getEmpName(); + + // 插入提成 + if(BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO)>0) { + + String[] empCodeArr = empCode.split(","); + String[] empNameArr = empName.split(","); + for(int i=0;i listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote); + if(!CollectionUtils.isEmpty(listQuote)){ + for (EmisCommissionQuote quoteItem:listQuote) { + List exprList=quoteItem.getExprList(); + if(!CollectionUtils.isEmpty(exprList)) { + + String calcExprStr=""; + for (EmisCommissionExpression exprItem : exprList) { + log.info("计算项目表达式:" + JSONObject.toJSONString(exprItem)); + + String calcExp = exprItem.getCalculateExpression(); + + double profitMoney = 0.0D; + // 按票计算 + if ("1".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按票计算:计算公式:" + calcExprStr + ",票数:1"); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 重量计算 + else if ("2".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + + } + // 体积计算 + else if ("3".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 包裹数 + else if ("4".equals(quoteItem.getCalcType())) { + + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按包裹数:计算公式:" + calcExprStr + ",包裹数:"+1); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + + // 插入参与分成人员 + String empCode=quoteItem.getEmpCode(); + String empName=quoteItem.getEmpName(); + + // 插入提成 + if(BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO)>0) { + + String[] empCodeArr = empCode.split(","); + String[] empNameArr = empName.split(","); + for(int i=0;i listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote); + if(!CollectionUtils.isEmpty(listQuote)){ + for (EmisCommissionQuote quoteItem:listQuote) { + List exprList=quoteItem.getExprList(); + if(!CollectionUtils.isEmpty(exprList)) { + + String calcExprStr=""; + for (EmisCommissionExpression exprItem : exprList) { + log.info("计算项目表达式:" + JSONObject.toJSONString(exprItem)); + + String calcExp = exprItem.getCalculateExpression(); + + double profitMoney = 0.0D; + // 按票计算 + if ("1".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按票计算:计算公式:" + calcExprStr + ",票数:1"); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 重量计算 + else if ("2".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + + } + // 体积计算 + else if ("3".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 包裹数 + else if ("4".equals(quoteItem.getCalcType())) { + + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按包裹数:计算公式:" + calcExprStr + ",包裹数:"+1); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + + // 插入参与分成人员 + String empCode=quoteItem.getEmpCode(); + String empName=quoteItem.getEmpName(); + + // 插入提成 + if(BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO)>0) { + + String[] empCodeArr = empCode.split(","); + String[] empNameArr = empName.split(","); + for(int i=0;i listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote); + if(!CollectionUtils.isEmpty(listQuote)){ + for (EmisCommissionQuote quoteItem:listQuote) { + List exprList=quoteItem.getExprList(); + if(!CollectionUtils.isEmpty(exprList)) { + + String calcExprStr=""; + for (EmisCommissionExpression exprItem : exprList) { + log.info("计算项目表达式:" + JSONObject.toJSONString(exprItem)); + + String calcExp = exprItem.getCalculateExpression(); + + double profitMoney = 0.0D; + // 按票计算 + if ("1".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按票计算:计算公式:" + calcExprStr + ",票数:1"); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 重量计算 + else if ("2".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + + } + // 体积计算 + else if ("3".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 包裹数 + else if ("4".equals(quoteItem.getCalcType())) { + + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按包裹数:计算公式:" + calcExprStr + ",包裹数:"+1); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + + // 插入参与分成人员 + String empCode=quoteItem.getEmpCode(); + String empName=quoteItem.getEmpName(); + + // 插入提成 + if(BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO)>0) { + EmisCommissionDtl emisCommissionDtl = new EmisCommissionDtl(); + emisCommissionDtl.setBillCode(waybill.getBillCode()); + emisCommissionDtl.setFeeType(quoteItem.getFeeType()); + + emisCommissionDtl.setBillMonth(billMonth); + emisCommissionDtl.setMoney(BigDecimal.valueOf(profitMoney)); + + emisCommissionDtl.setEmpCode(empCode); +// emisCommissionDtl.setEmpName(); + + emisCommissionDtl.setFeeRemark(calcExprStr); + + emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl); + + }else{ + log.error("计算提成费用为0"); + } + + } + }else{ + log.error("网点客服未配置表达式"); + } + + } + }else{ + log.error("网点客服无报价"); + } + } + + /** + * 计算派件员提成 + * @param waybill + */ + private void calcDispatchProfit(EmisWaybill waybill){ + String pickUpMethod=waybill.getPickupMethod(); + String takePieceEmployeeCode=waybill.getTakePieceEmployeeCode(); + String operateEmployeeCode=waybill.getOperateEmployeeCode(); + String billMonth= DateUtils.parseDateToStr(DateUtils.YYYY_MM,waybill.getSendDate()); + String country=waybill.getReceiveCountry(); + String fromCountry=waybill.getSendCountry(); + + EmisCommissionQuote emisCommissionQuote = new EmisCommissionQuote(); + emisCommissionQuote.setPostType("1"); + emisCommissionQuote.setCountry(country); + emisCommissionQuote.setFromCountry(fromCountry); + // 获取提成方案 + List listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote); + if(!CollectionUtils.isEmpty(listQuote)){ + for (EmisCommissionQuote quoteItem:listQuote) { + List exprList=quoteItem.getExprList(); + if(!CollectionUtils.isEmpty(exprList)) { + + String calcExprStr=""; + for (EmisCommissionExpression exprItem : exprList) { + log.info("计算项目表达式:" + JSONObject.toJSONString(exprItem)); + + String calcExp = exprItem.getCalculateExpression(); + + double profitMoney = 0.0D; + // 按票计算 + if ("1".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按票计算:计算公式:" + calcExprStr + ",票数:1"); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 重量计算 + else if ("2".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + + } + // 体积计算 + else if ("3".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 包裹数 + else if ("4".equals(quoteItem.getCalcType())) { + + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按包裹数:计算公式:" + calcExprStr + ",包裹数:"+1); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + + // 插入参与分成人员 + String empCode=quoteItem.getEmpCode(); + String empName=quoteItem.getEmpName(); + + // 插入提成 + if(BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO)>0) { + + String[] empCodeArr = empCode.split(","); + String[] empNameArr = empName.split(","); + for(int i=0;i listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote); + if(!CollectionUtils.isEmpty(listQuote)){ + for (EmisCommissionQuote quoteItem:listQuote) { + List exprList=quoteItem.getExprList(); + if(!CollectionUtils.isEmpty(exprList)) { + + String calcExprStr=""; + for (EmisCommissionExpression exprItem : exprList) { + log.info("计算项目表达式:" + JSONObject.toJSONString(exprItem)); + + String calcExp = exprItem.getCalculateExpression(); + + double profitMoney = 0.0D; + // 按票计算 + if ("1".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按票计算:计算公式:" + calcExprStr + ",票数:1"); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 重量计算 + else if ("2".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + + } + // 体积计算 + else if ("3".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 包裹数 + else if ("4".equals(quoteItem.getCalcType())) { + + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按包裹数:计算公式:" + calcExprStr + ",包裹数:"+1); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + + // 插入参与分成人员 + String empCode=quoteItem.getEmpCode(); + String empName=quoteItem.getEmpName(); + + // 插入提成 + if(BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO)>0) { + + String[] empCodeArr = empCode.split(","); + String[] empNameArr = empName.split(","); + for(int i=0;i listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote); + if(!CollectionUtils.isEmpty(listQuote)){ + for (EmisCommissionQuote quoteItem:listQuote) { + List exprList=quoteItem.getExprList(); + if(!CollectionUtils.isEmpty(exprList)) { + + String calcExprStr=""; + for (EmisCommissionExpression exprItem : exprList) { + log.info("计算项目表达式:" + JSONObject.toJSONString(exprItem)); + + String calcExp = exprItem.getCalculateExpression(); + + double profitMoney = 0.0D; + // 按票计算 + if ("1".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按票计算:计算公式:" + calcExprStr + ",票数:1"); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 重量计算 + else if ("2".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + + } + // 体积计算 + else if ("3".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 包裹数 + else if ("4".equals(quoteItem.getCalcType())) { + + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按包裹数:计算公式:" + calcExprStr + ",包裹数:"+1); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + + // 插入参与分成人员 + String empCode=quoteItem.getEmpCode(); + String empName=quoteItem.getEmpName(); + + // 插入提成 + if(BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO)>0) { + + String[] empCodeArr = empCode.split(","); + String[] empNameArr = empName.split(","); + for(int i=0;i listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote); + if(!CollectionUtils.isEmpty(listQuote)){ + for (EmisCommissionQuote quoteItem:listQuote) { + List exprList=quoteItem.getExprList(); + if(!CollectionUtils.isEmpty(exprList)) { + + String calcExprStr=""; + for (EmisCommissionExpression exprItem : exprList) { + log.info("计算项目表达式:" + JSONObject.toJSONString(exprItem)); + + String calcExp = exprItem.getCalculateExpression(); + + double profitMoney = 0.0D; + // 按票计算 + if ("1".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按票计算:计算公式:" + calcExprStr + ",票数:1"); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 重量计算 + else if ("2".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + + log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + + } + // 体积计算 + else if ("3".equals(quoteItem.getCalcType())) { + calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().toString()) + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().toString()); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + // 包裹数 + else if ("4".equals(quoteItem.getCalcType())) { + + calcExprStr = calcExp.replaceAll("w", "1") + .replaceAll("s", exprItem.getInitialWeight().toString()) + .replaceAll("d", exprItem.getAdditionalWeight().toString()); + log.info("按包裹数:计算公式:" + calcExprStr + ",包裹数:"+1); + profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString()); + } + + // 插入参与分成人员 + String empCode=quoteItem.getEmpCode(); + String empName=quoteItem.getEmpName(); + + // 插入提成 + if(BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO)>0) { + + String[] empCodeArr = empCode.split(","); + String[] empNameArr = empName.split(","); + for(int i=0;i insert into emis_commission_dtl - id, fee_type, money, bill_month, @@ -132,7 +131,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update_site, - #{id}, #{feeType}, #{money}, #{billMonth}, @@ -193,12 +191,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update emis_commission_dtl set del_flag='1' where bill_code = #{billCode} + + - delete from emis_commission_dtl where id = #{id} + update emis_commission_dtl set del_flag='1' where id = #{id} - delete from emis_commission_dtl where id in + update emis_commission_dtl set del_flag='1' where id in #{id} diff --git a/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml b/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml index 977596984..1b01ea45b 100644 --- a/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml @@ -2630,17 +2630,33 @@ update emis_waybill set bl_bill = '1',produce_bill_date=now(),produce_bill_site_code='88888',produce_bill_man_code='0' - where del_flag='0' and bill_code=#{billCode} + where bill_code=#{billCode} update emis_waybill set bl_bill = '0',produce_bill_date=null,produce_bill_site_code=null,produce_bill_man_code=null - where del_flag='0' and bill_code=#{billCode} + where bill_code=#{billCode} + + + update emis_waybill set + bl_profit = '1' + where bill_code=#{billCode} + + + + + update emis_waybill set + bl_profit = '0' + where bill_code=#{billCode} + + + + update emis_waybill set sign_man=null,