This commit is contained in:
linfso 2024-11-13 23:42:30 +08:00
parent 4f2260b237
commit 619deac335
7 changed files with 998 additions and 38 deletions

View File

@ -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;
}
}

View File

@ -70,6 +70,14 @@ public interface EmisCommissionDtlMapper extends BaseMapper<EmisCommissionDtl>
*/
public int deleteEmisCommissionDtlById(Long id);
/**
* 根据运单号删除
* @param billCode
* @return
*/
public int deleteEmisCommissionDtlByBillCode(String billCode);
/**
* 批量删除
*

View File

@ -150,6 +150,12 @@ public interface EmisWaybillMapper extends BaseMapper<EmisWaybill>
// 取消出账标识
public int cancelHasDoBill(EmisWaybill emisWaybill);
// 打提成标识
public int updateHasDoProfit(EmisWaybill emisWaybill);
// 取消出账标识
public int cancelHasDoProfit(EmisWaybill emisWaybill);
// 更新问题件状态
public int updateProblemStatus(EmisWaybill emisWaybill);

View File

@ -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<EmisCommissionQuote> listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote);
if(!CollectionUtils.isEmpty(listQuote)){
for (EmisCommissionQuote quoteItem:listQuote) {
List<EmisCommissionExpression> 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<EmisCommissionQuote> listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote);
if(!CollectionUtils.isEmpty(listQuote)){
for (EmisCommissionQuote quoteItem:listQuote) {
List<EmisCommissionExpression> 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<empCodeArr.length;i++) {
EmisCommissionDtl emisCommissionDtl = new EmisCommissionDtl();
emisCommissionDtl.setBillCode(waybill.getBillCode());
emisCommissionDtl.setFeeType(quoteItem.getFeeType());
emisCommissionDtl.setBillMonth(billMonth);
emisCommissionDtl.setMoney(BigDecimal.valueOf(profitMoney));
emisCommissionDtl.setEmpCode(empCodeArr[i]);
emisCommissionDtl.setEmpName(empNameArr[i]);
emisCommissionDtl.setFeeRemark(calcExprStr);
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
}
}else{
log.error("计算提成费用为0");
}
}
}else{
log.error("网点客服未配置表达式");
}
}
}else{
log.error("网点客服无报价");
}
}
/**
* 计算快件单证提成
* @param waybill
*/
private void calcKjdzProfit(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<EmisCommissionQuote> listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote);
if(!CollectionUtils.isEmpty(listQuote)){
for (EmisCommissionQuote quoteItem:listQuote) {
List<EmisCommissionExpression> 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<empCodeArr.length;i++) {
EmisCommissionDtl emisCommissionDtl = new EmisCommissionDtl();
emisCommissionDtl.setBillCode(waybill.getBillCode());
emisCommissionDtl.setFeeType(quoteItem.getFeeType());
emisCommissionDtl.setBillMonth(billMonth);
emisCommissionDtl.setMoney(BigDecimal.valueOf(profitMoney));
emisCommissionDtl.setEmpCode(empCodeArr[i]);
emisCommissionDtl.setEmpName(empNameArr[i]);
emisCommissionDtl.setFeeRemark(calcExprStr);
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
}
}else{
log.error("计算提成费用为0");
}
}
}else{
log.error("网点客服未配置表达式");
}
}
}else{
log.error("网点客服无报价");
}
}
/**
* 计算取件员提成
* @param waybill
*/
private void calcTakeProfit(EmisWaybill waybill){
String pickUpMethod=waybill.getPickupMethod();
// 只有上门取件方式才有取件员提成
if(!"2".equals(pickUpMethod)){
return;
}
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);
emisCommissionQuote.setEmpCode(takePieceEmployeeCode);
// 获取提成方案
List<EmisCommissionQuote> listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote);
if(!CollectionUtils.isEmpty(listQuote)){
for (EmisCommissionQuote quoteItem:listQuote) {
List<EmisCommissionExpression> 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<empCodeArr.length;i++) {
EmisCommissionDtl emisCommissionDtl = new EmisCommissionDtl();
emisCommissionDtl.setBillCode(waybill.getBillCode());
emisCommissionDtl.setFeeType(quoteItem.getFeeType());
emisCommissionDtl.setBillMonth(billMonth);
emisCommissionDtl.setMoney(BigDecimal.valueOf(profitMoney));
emisCommissionDtl.setEmpCode(empCodeArr[i]);
emisCommissionDtl.setEmpName(empNameArr[i]);
emisCommissionDtl.setFeeRemark(calcExprStr);
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
}
}else{
log.error("计算提成费用为0");
}
}
}else{
log.error("网点客服未配置表达式");
}
}
}else{
log.error("网点客服无报价");
}
}
/**
* 计算操作员提成
* @param waybill
*/
private void calcOpProfit(EmisWaybill waybill){
String pickUpMethod=waybill.getPickupMethod();
// 只有参考收货方式才有操作员提成
if(!"1".equals(pickUpMethod)){
return;
}
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<EmisCommissionQuote> listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote);
if(!CollectionUtils.isEmpty(listQuote)){
for (EmisCommissionQuote quoteItem:listQuote) {
List<EmisCommissionExpression> 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<EmisCommissionQuote> listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote);
if(!CollectionUtils.isEmpty(listQuote)){
for (EmisCommissionQuote quoteItem:listQuote) {
List<EmisCommissionExpression> 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<empCodeArr.length;i++) {
EmisCommissionDtl emisCommissionDtl = new EmisCommissionDtl();
emisCommissionDtl.setBillCode(waybill.getBillCode());
emisCommissionDtl.setFeeType(quoteItem.getFeeType());
emisCommissionDtl.setBillMonth(billMonth);
emisCommissionDtl.setMoney(BigDecimal.valueOf(profitMoney));
emisCommissionDtl.setEmpCode(empCodeArr[i]);
emisCommissionDtl.setEmpName(empNameArr[i]);
emisCommissionDtl.setFeeRemark(calcExprStr);
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
}
}else{
log.error("计算提成费用为0");
}
}
}else{
log.error("网点客服未配置表达式");
}
}
}else{
log.error("网点客服无报价");
}
}
/**
* 计算销售员提成
* @param waybill
*/
private void calcSalesProfit(EmisWaybill waybill){
String pickUpMethod=waybill.getPickupMethod();
String takePieceEmployeeCode=waybill.getTakePieceEmployeeCode();
String operateEmployeeCode=waybill.getOperateEmployeeCode();
String salesmen=waybill.getSalesmen();
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);
// emisCommissionQuote.setEmpCode();
// 获取提成方案
List<EmisCommissionQuote> listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote);
if(!CollectionUtils.isEmpty(listQuote)){
for (EmisCommissionQuote quoteItem:listQuote) {
List<EmisCommissionExpression> 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<empCodeArr.length;i++) {
EmisCommissionDtl emisCommissionDtl = new EmisCommissionDtl();
emisCommissionDtl.setBillCode(waybill.getBillCode());
emisCommissionDtl.setFeeType(quoteItem.getFeeType());
emisCommissionDtl.setBillMonth(billMonth);
emisCommissionDtl.setMoney(BigDecimal.valueOf(profitMoney));
emisCommissionDtl.setEmpCode(empCodeArr[i]);
emisCommissionDtl.setEmpName(empNameArr[i]);
emisCommissionDtl.setFeeRemark(calcExprStr);
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
}
}else{
log.error("计算提成费用为0");
}
}
}else{
log.error("网点客服未配置表达式");
}
}
}else{
log.error("网点客服无报价");
}
}
/**
* 计算中转操作提成
* @param waybill
*/
private void calcMidOpProfit(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<EmisCommissionQuote> listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote);
if(!CollectionUtils.isEmpty(listQuote)){
for (EmisCommissionQuote quoteItem:listQuote) {
List<EmisCommissionExpression> 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<empCodeArr.length;i++) {
EmisCommissionDtl emisCommissionDtl = new EmisCommissionDtl();
emisCommissionDtl.setBillCode(waybill.getBillCode());
emisCommissionDtl.setFeeType(quoteItem.getFeeType());
emisCommissionDtl.setBillMonth(billMonth);
emisCommissionDtl.setMoney(BigDecimal.valueOf(profitMoney));
emisCommissionDtl.setEmpCode(empCodeArr[i]);
emisCommissionDtl.setEmpName(empNameArr[i]);
emisCommissionDtl.setFeeRemark(calcExprStr);
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
}
}else{
log.error("计算提成费用为0");
}
}
}else{
log.error("网点客服未配置表达式");
}
}
}else{
log.error("网点客服无报价");
}
}
/**
* 计算单证提成
* @param waybill
*/
private void calcDzProfit(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<EmisCommissionQuote> listQuote = emisCommissionQuoteMapper.selectEmisCommissionQuoteList(emisCommissionQuote);
if(!CollectionUtils.isEmpty(listQuote)){
for (EmisCommissionQuote quoteItem:listQuote) {
List<EmisCommissionExpression> 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<empCodeArr.length;i++) {
EmisCommissionDtl emisCommissionDtl = new EmisCommissionDtl();
emisCommissionDtl.setBillCode(waybill.getBillCode());
emisCommissionDtl.setFeeType(quoteItem.getFeeType());
emisCommissionDtl.setBillMonth(billMonth);
emisCommissionDtl.setMoney(BigDecimal.valueOf(profitMoney));
emisCommissionDtl.setEmpCode(empCodeArr[i]);
emisCommissionDtl.setEmpName(empNameArr[i]);
emisCommissionDtl.setFeeRemark(calcExprStr);
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
}
}else{
log.error("计算提成费用为0");
}
}
}else{
log.error("网点客服未配置表达式");
}
}
}else{
log.error("网点客服无报价");
}
}
/**
* 查询员工提成表
*

View File

@ -2753,8 +2753,6 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
* @param emisWaybillSave
* @throws EmisBizError
*/
@Override
public void reUpdateWayBill(EmisWaybill oldEmisWaybill,EmisWaybill emisWaybillSave) throws EmisBizError {

View File

@ -104,7 +104,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertEmisCommissionDtl" parameterType="EmisCommissionDtl" useGeneratedKeys="true" keyProperty="id">
insert into emis_commission_dtl
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="feeType != null and feeType != ''">fee_type,</if>
<if test="money != null">money,</if>
<if test="billMonth != null and billMonth != ''">bill_month,</if>
@ -132,7 +131,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateSite != null and updateSite != ''">update_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="feeType != null and feeType != ''">#{feeType},</if>
<if test="money != null">#{money},</if>
<if test="billMonth != null and billMonth != ''">#{billMonth},</if>
@ -193,12 +191,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<delete id="deleteEmisCommissionDtlByBillCode" parameterType="String">
update emis_commission_dtl set del_flag='1' where bill_code = #{billCode}
</delete>
<delete id="deleteEmisCommissionDtlById" parameterType="Long">
delete from emis_commission_dtl where id = #{id}
update emis_commission_dtl set del_flag='1' where id = #{id}
</delete>
<delete id="deleteEmisCommissionDtlByIds" parameterType="String">
delete from emis_commission_dtl where id in
update emis_commission_dtl set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

View File

@ -2630,17 +2630,33 @@
<update id="updateHasDoBill" parameterType="String">
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>
<!-- 取消出账标识 -->
<update id="cancelHasDoBill" parameterType="String">
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>
<!-- 打提成标识 -->
<update id="updateHasDoProfit" parameterType="String">
update emis_waybill set
bl_profit = '1'
where bill_code=#{billCode}
</update>
<!-- 取消提成标识 -->
<update id="cancelHasDoProfit" parameterType="String">
update emis_waybill set
bl_profit = '0'
where bill_code=#{billCode}
</update>
<update id="updateUnSignStatus" parameterType="EmisWaybill">
update emis_waybill
set sign_man=null,