md
This commit is contained in:
parent
4f2260b237
commit
619deac335
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -70,6 +70,14 @@ public interface EmisCommissionDtlMapper extends BaseMapper<EmisCommissionDtl>
|
|||||||
*/
|
*/
|
||||||
public int deleteEmisCommissionDtlById(Long id);
|
public int deleteEmisCommissionDtlById(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据运单号删除
|
||||||
|
* @param billCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int deleteEmisCommissionDtlByBillCode(String billCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除
|
* 批量删除
|
||||||
*
|
*
|
||||||
|
|||||||
@ -150,6 +150,12 @@ public interface EmisWaybillMapper extends BaseMapper<EmisWaybill>
|
|||||||
// 取消出账标识
|
// 取消出账标识
|
||||||
public int cancelHasDoBill(EmisWaybill emisWaybill);
|
public int cancelHasDoBill(EmisWaybill emisWaybill);
|
||||||
|
|
||||||
|
// 打提成标识
|
||||||
|
public int updateHasDoProfit(EmisWaybill emisWaybill);
|
||||||
|
|
||||||
|
// 取消出账标识
|
||||||
|
public int cancelHasDoProfit(EmisWaybill emisWaybill);
|
||||||
|
|
||||||
// 更新问题件状态
|
// 更新问题件状态
|
||||||
public int updateProblemStatus(EmisWaybill emisWaybill);
|
public int updateProblemStatus(EmisWaybill emisWaybill);
|
||||||
|
|
||||||
|
|||||||
@ -10,16 +10,24 @@
|
|||||||
|
|
||||||
package com.xdadan.erp.emis.service.impl;
|
package com.xdadan.erp.emis.service.impl;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.xdadan.erp.emis.domain.EmisCommissionExpression;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.xdadan.erp.emis.domain.EmisCommissionQuote;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.xdadan.erp.emis.domain.EmisWaybill;
|
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.EmisCommissionQuoteMapper;
|
||||||
|
import com.xdadan.erp.emis.mapper.EmisWaybillMapper;
|
||||||
import com.xdadan.erp.emis.service.EmisBaseService;
|
import com.xdadan.erp.emis.service.EmisBaseService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.xdadan.erp.emis.domain.EmisCommissionProfit;
|
|
||||||
import com.xdadan.erp.emis.mapper.EmisCommissionProfitMapper;
|
import com.xdadan.erp.emis.mapper.EmisCommissionProfitMapper;
|
||||||
import com.xdadan.erp.emis.service.IEmisCommissionProfitService;
|
import com.xdadan.erp.emis.service.IEmisCommissionProfitService;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -31,6 +39,7 @@ import org.springframework.util.CollectionUtils;
|
|||||||
* @author linfso
|
* @author linfso
|
||||||
* @date 2024-10-24 01:46:36
|
* @date 2024-10-24 01:46:36
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class EmisCommissionProfitServiceImpl extends EmisBaseService implements IEmisCommissionProfitService
|
public class EmisCommissionProfitServiceImpl extends EmisBaseService implements IEmisCommissionProfitService
|
||||||
{
|
{
|
||||||
@ -40,6 +49,11 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
|||||||
@Autowired
|
@Autowired
|
||||||
private EmisCommissionQuoteMapper emisCommissionQuoteMapper;
|
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);
|
EmisWaybill waybill = getWaybillByBillCode(billCode);
|
||||||
|
|
||||||
// 取件方式
|
// 先删除该运单已经计算的提成
|
||||||
String pickUpMethod=waybill.getPickupMethod();
|
emisCommissionDtlMapper.deleteEmisCommissionDtlByBillCode(billCode);
|
||||||
String takePieceEmployeeCode=waybill.getTakePieceEmployeeCode();
|
|
||||||
String operateEmployeeCode=waybill.getOperateEmployeeCode();
|
|
||||||
String country=waybill.getReceiveCountry();
|
|
||||||
String fromCountry=waybill.getSendCountry();
|
|
||||||
|
|
||||||
// 计算每个岗位的提成方案
|
// 计算每个岗位的提成方案
|
||||||
/*
|
/*
|
||||||
@ -71,9 +81,62 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// 根据不同岗位计算
|
// 根据不同岗位计算
|
||||||
for(int i=1;i<=8;i++) {
|
for(int postTypeIndex=1;postTypeIndex<=8;postTypeIndex++) {
|
||||||
// 网点客服 1
|
// 1.网点客服
|
||||||
if(i==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 emisCommissionQuote = new EmisCommissionQuote();
|
||||||
emisCommissionQuote.setPostType("1");
|
emisCommissionQuote.setPostType("1");
|
||||||
emisCommissionQuote.setCountry(country);
|
emisCommissionQuote.setCountry(country);
|
||||||
@ -83,20 +146,852 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
|||||||
if(!CollectionUtils.isEmpty(listQuote)){
|
if(!CollectionUtils.isEmpty(listQuote)){
|
||||||
for (EmisCommissionQuote quoteItem:listQuote) {
|
for (EmisCommissionQuote quoteItem:listQuote) {
|
||||||
List<EmisCommissionExpression> exprList=quoteItem.getExprList();
|
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())) {
|
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("网点客服无报价");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
|
||||||
|
/**
|
||||||
|
* 计算快件单证提成
|
||||||
|
* @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("网点客服无报价");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2753,8 +2753,6 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
* @param emisWaybillSave
|
* @param emisWaybillSave
|
||||||
* @throws EmisBizError
|
* @throws EmisBizError
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reUpdateWayBill(EmisWaybill oldEmisWaybill,EmisWaybill emisWaybillSave) throws EmisBizError {
|
public void reUpdateWayBill(EmisWaybill oldEmisWaybill,EmisWaybill emisWaybillSave) throws EmisBizError {
|
||||||
|
|
||||||
|
|||||||
@ -104,7 +104,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<insert id="insertEmisCommissionDtl" parameterType="EmisCommissionDtl" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertEmisCommissionDtl" parameterType="EmisCommissionDtl" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into emis_commission_dtl
|
insert into emis_commission_dtl
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">id,</if>
|
|
||||||
<if test="feeType != null and feeType != ''">fee_type,</if>
|
<if test="feeType != null and feeType != ''">fee_type,</if>
|
||||||
<if test="money != null">money,</if>
|
<if test="money != null">money,</if>
|
||||||
<if test="billMonth != null and billMonth != ''">bill_month,</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>
|
<if test="updateSite != null and updateSite != ''">update_site,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">#{id},</if>
|
|
||||||
<if test="feeType != null and feeType != ''">#{feeType},</if>
|
<if test="feeType != null and feeType != ''">#{feeType},</if>
|
||||||
<if test="money != null">#{money},</if>
|
<if test="money != null">#{money},</if>
|
||||||
<if test="billMonth != null and billMonth != ''">#{billMonth},</if>
|
<if test="billMonth != null and billMonth != ''">#{billMonth},</if>
|
||||||
@ -193,12 +191,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</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 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>
|
||||||
|
|
||||||
<delete id="deleteEmisCommissionDtlByIds" parameterType="String">
|
<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=")">
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|||||||
@ -2630,17 +2630,33 @@
|
|||||||
<update id="updateHasDoBill" parameterType="String">
|
<update id="updateHasDoBill" parameterType="String">
|
||||||
update emis_waybill set
|
update emis_waybill set
|
||||||
bl_bill = '1',produce_bill_date=now(),produce_bill_site_code='88888',produce_bill_man_code='0'
|
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>
|
||||||
|
|
||||||
<!-- 取消出账标识 -->
|
<!-- 取消出账标识 -->
|
||||||
<update id="cancelHasDoBill" parameterType="String">
|
<update id="cancelHasDoBill" parameterType="String">
|
||||||
update emis_waybill set
|
update emis_waybill set
|
||||||
bl_bill = '0',produce_bill_date=null,produce_bill_site_code=null,produce_bill_man_code=null
|
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>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 打提成标识 -->
|
||||||
|
<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 id="updateUnSignStatus" parameterType="EmisWaybill">
|
||||||
update emis_waybill
|
update emis_waybill
|
||||||
set sign_man=null,
|
set sign_man=null,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user