提成优化修改、订单列表增加进粉字段、调理项目

This commit is contained in:
xiezhijun 2021-01-12 18:35:06 +08:00
parent 64cda6be9e
commit 355dff1ede
10 changed files with 333 additions and 224 deletions

View File

@ -79,6 +79,9 @@ public class SysCustomer extends BaseEntity
@Excel(name = "跟进状态")
private Long followStatus;
/** 删除标识(0 未删除 1已删除) */
private Integer delFlag;
/** 体征数据,非持久化字段 */
private SysCustomerPhysicalSigns sign;
@ -226,6 +229,14 @@ public class SysCustomer extends BaseEntity
this.sign = sign;
}
public Integer getDelFlag() {
return delFlag;
}
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -108,8 +108,8 @@ public class SysCustomerPhysicalSigns extends BaseEntity
@Excel(name = "联系沟通时间", readConverterExp = "2=4小时制")
private Integer connectTime;
/** 备注 */
@Excel(name = "备注")
/** 饮食备注 */
@Excel(name = "饮食备注")
private String remarks;
/** 湿气数据 */
@ -132,6 +132,13 @@ public class SysCustomerPhysicalSigns extends BaseEntity
@Excel(name = "减脂经历")
private String experience;
/** 备注 */
@Excel(name = "备注")
private String comments;
/** 删除标识(0 未删除 1已删除) */
private Integer delFlag;
/** 体征对象集合 **/
private List<SysPhysicalSigns> signList;
@ -402,6 +409,22 @@ public class SysCustomerPhysicalSigns extends BaseEntity
this.signList = signList;
}
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
public Integer getDelFlag() {
return delFlag;
}
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -440,5 +463,4 @@ public class SysCustomerPhysicalSigns extends BaseEntity
.append("updateBy", getUpdateBy())
.toString();
}
}

View File

@ -188,6 +188,31 @@ public class SysOrder extends BaseEntity {
@Excel(name = "成交时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date orderTime;
/**
* 调理项目id
*/
private Integer conditioningProjectId;
/**
* 调理项目
*/
@Excel(name = "调理项目", width = 30)
private String conditioningProject;
/**
* 服务结束时间根据开始日期服务月份暂停记录计算而来
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "服务结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date serverEndTime;
/**
* 进粉时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "进粉时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date becomeFanTime;
/**
* 订单暂停记录 非持久化字段
* */
@ -476,6 +501,30 @@ public class SysOrder extends BaseEntity {
this.orderPauseList = orderPauseList;
}
public Integer getConditioningProjectId() {
return conditioningProjectId;
}
public void setConditioningProjectId(Integer conditioningProjectId) {
this.conditioningProjectId = conditioningProjectId;
}
public Date getServerEndTime() {
return serverEndTime;
}
public void setServerEndTime(Date serverEndTime) {
this.serverEndTime = serverEndTime;
}
public Date getBecomeFanTime() {
return becomeFanTime;
}
public void setBecomeFanTime(Date becomeFanTime) {
this.becomeFanTime = becomeFanTime;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
@ -519,4 +568,12 @@ public class SysOrder extends BaseEntity {
.append("weight", getWeight())
.toString();
}
public String getConditioningProject() {
return conditioningProject;
}
public void setConditioningProject(String conditioningProject) {
this.conditioningProject = conditioningProject;
}
}

View File

@ -2,8 +2,10 @@ package com.stdiet.custom.service;
import com.stdiet.custom.domain.SysCommision;
import com.stdiet.custom.domain.SysCommissionDayDetail;
import com.stdiet.custom.domain.SysOrder;
import com.stdiet.custom.domain.SysOrderCommisionDayDetail;
import java.util.Date;
import java.util.List;
import java.util.Map;

View File

@ -1,21 +1,16 @@
package com.stdiet.custom.service.impl;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.StringUtils;
import com.stdiet.custom.domain.*;
import com.stdiet.custom.mapper.SysCommisionMapper;
import com.stdiet.custom.mapper.SysOrderMapper;
import com.stdiet.custom.mapper.SysOrderPauseMapper;
import com.stdiet.custom.service.ISysCommisionService;
import com.stdiet.custom.service.ISysCommissionDayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
@ -38,7 +33,7 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
//查询用户
List<SysCommision> list = sysCommisionMapper.selectSysCommisionDayDetail(sysCommision);
if(list != null && list.size() > 0){
Map<Long, List<SysOrderCommisionDayDetail>> orderDetailMap = getOrderByList(null);
Map<Long, List<SysOrderCommisionDayDetail>> orderDetailMap = getOrderByList(sysCommision.getUserId());
SysCommissionDayDetail sysCommissionDayDetail = null;
for(SysCommision commision : list){
sysCommissionDayDetail = new SysCommissionDayDetail();
@ -48,9 +43,8 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
sysCommissionDayDetail.setPostName(commision.getPostName());
sysCommissionDayDetail.setOrderTotalAmount(commision.getAmount());
//获取查询时间
LocalDate localDate = StringUtils.isEmpty(sysCommision.getBeginTime()) ? LocalDate.now() : LocalDate.parse(sysCommision.getBeginTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
//dealServerOrderCommissionDetail2(orderDetailMap.get(sysCommissionDayDetail.getUserId()), sysCommissionDayDetail, localDate.getYear()+""+localDate.getMonth().getValue());
dealServerOrderCommissionDetail2(orderDetailMap.get(sysCommissionDayDetail.getUserId()), sysCommissionDayDetail);
//LocalDate localDate = StringUtils.isEmpty(sysCommision.getBeginTime()) ? LocalDate.now() : LocalDate.parse(sysCommision.getBeginTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
dealServerOrderCommissionDetail(orderDetailMap.get(sysCommissionDayDetail.getUserId()), sysCommissionDayDetail);
result.add(sysCommissionDayDetail);
}
}
@ -61,103 +55,110 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
/**
* 根据用户ID统计出该用户在该月所有订单的服务数量服务总天数服务订单总额暂停总天数
* **/
public void dealServerOrderCommissionDetail2(List<SysOrderCommisionDayDetail> orderDetailList, SysCommissionDayDetail sysCommissionDayDetail){
public void dealServerOrderCommissionDetail(List<SysOrderCommisionDayDetail> orderDetailList, SysCommissionDayDetail sysCommissionDayDetail){
//总提成
double totalCommissionAmount = 0.0;
BigDecimal totalCommissionAmount = new BigDecimal(0);
//已发放提成
double totalHasSentCommissionAmount = 0.0;
BigDecimal totalHasSentCommissionAmount = new BigDecimal(0);
//未发放提成
double totalNotSentCommissionAmount = 0.0;
BigDecimal totalNotSentCommissionAmount = new BigDecimal(0);
//未发放提成记录
List<Map<String, Object>> sendDetailList = new ArrayList<>();
if(orderDetailList != null){
//获取每个月的成交总额度
Map<String, Double> orderAmount = new TreeMap<>(new MyComparator());
Map<String, BigDecimal> orderAmount = new TreeMap<>(new MyComparator());
Set<String> commissionMonthSet = new TreeSet<>(new MyComparator());
for (SysOrderCommisionDayDetail sysOrderCommisionDayDetail : orderDetailList) {
String yearMonth = sysOrderCommisionDayDetail.getOrderTime().getYear()+""+sysOrderCommisionDayDetail.getOrderTime().getMonth().getValue();
if(orderAmount.containsKey(yearMonth)){
orderAmount.put(yearMonth, orderAmount.get(yearMonth) + sysOrderCommisionDayDetail.getOrderAmount().doubleValue());
orderAmount.put(yearMonth, orderAmount.get(yearMonth).add(sysOrderCommisionDayDetail.getOrderAmount()));
}else{
orderAmount.put(yearMonth, sysOrderCommisionDayDetail.getOrderAmount().doubleValue());
orderAmount.put(yearMonth, sysOrderCommisionDayDetail.getOrderAmount());
}
commissionMonthSet.addAll(sysOrderCommisionDayDetail.getEveryYearMonthServerMoney().keySet());
}
//获取提成比例以及计算提成
Map<String, Float> rateMap = getRateByAmount2(sysCommissionDayDetail.getUserId(), sysCommissionDayDetail.getPostId(), orderAmount);
Map<String, Float> rateMap = getRateByAmount(sysCommissionDayDetail.getUserId(), sysCommissionDayDetail.getPostId(), orderAmount);
int i = 1;
double commissionA = 0D;
BigDecimal commissionA = new BigDecimal(0);
for (String ym : commissionMonthSet) {
double ym_mession = 0;
BigDecimal ym_mession = new BigDecimal(0);
if(orderAmount.containsKey(ym)){
totalCommissionAmount += orderAmount.get(ym) * rateMap.get(ym) / 100D;
totalCommissionAmount = totalCommissionAmount.add(getMoney(orderAmount.get(ym).doubleValue() * rateMap.get(ym) / 100D, 1));
}
for (SysOrderCommisionDayDetail sysOrderCommisionDayDetail : orderDetailList) {
Map<String, BigDecimal> everyYearMonthServerMoney = sysOrderCommisionDayDetail.getEveryYearMonthServerMoney();
if(everyYearMonthServerMoney.containsKey(ym)){
String orderYearMonth = sysOrderCommisionDayDetail.getOrderTime().getYear()+""+sysOrderCommisionDayDetail.getOrderTime().getMonth().getValue();
double m = (everyYearMonthServerMoney.get(ym) == null) ? 0 : everyYearMonthServerMoney.get(ym).doubleValue();
ym_mession += m * rateMap.get(orderYearMonth) / 100D;
BigDecimal m = (everyYearMonthServerMoney.get(ym) == null) ? new BigDecimal(0) : everyYearMonthServerMoney.get(ym);
ym_mession = ym_mession.add(getMoney(m.doubleValue() * rateMap.get(orderYearMonth) / 100D, 1));
}
}
if(isSendCommissionByYearMonth(ym)){
totalHasSentCommissionAmount += ym_mession;
totalHasSentCommissionAmount = totalHasSentCommissionAmount.add(ym_mession);
}else{
Map<String, Object> map = new HashMap<>();
map.put("yearMonth", ym);
if(i++ != commissionMonthSet.size()){
map.put("yearMonthCommission", getMoney(ym_mession, 1));
if(i != commissionMonthSet.size()){
//计算未发放的提成除最后一个月
commissionA = commissionA.add(ym_mession);
map.put("yearMonthCommission", ym_mession);
}else{
System.out.println("最后:"+commissionA);
map.put("yearMonthCommission", getMoney(totalCommissionAmount - commissionA, 1));
//最后一个月除去已发放的月份的提成再减去前面未发放提成防止出现误差
map.put("yearMonthCommission", totalCommissionAmount.subtract(totalHasSentCommissionAmount).subtract(commissionA));
}
sendDetailList.add(map);
}
commissionA += getMoney(ym_mession, 1).doubleValue();
i++;
}
}
sysCommissionDayDetail.setTotalCommissionAmount(getMoney(totalCommissionAmount,1));
sysCommissionDayDetail.setTotalHasSentCommissionAmount(getMoney(totalHasSentCommissionAmount,1));
sysCommissionDayDetail.setTotalNotSentCommissionAmount(getMoney(totalCommissionAmount - totalHasSentCommissionAmount,1));
sysCommissionDayDetail.setTotalCommissionAmount(totalCommissionAmount);
sysCommissionDayDetail.setTotalHasSentCommissionAmount(totalHasSentCommissionAmount);
sysCommissionDayDetail.setTotalNotSentCommissionAmount(totalCommissionAmount.subtract(totalHasSentCommissionAmount));
sysCommissionDayDetail.setSendDetailList(sendDetailList);
}
/**判断该月提成是否已发放*/
public boolean isSendCommissionByYearMonth(String yearMonth){
LocalDate localDate = LocalDate.of(Integer.parseInt(yearMonth.substring(0,4)), Integer.parseInt(yearMonth.substring(4)), 1);
LocalDate nowDate = LocalDate.now();
if(localDate.getMonth().getValue() >= 0){
return false;
long betweenMonth = ChronoUnit.MONTHS.between(localDate, nowDate);
if(betweenMonth > 1){
return true;
}else if(betweenMonth == 1){
//判断目前是否大于15号
return nowDate.getDayOfMonth() > 15 ? true : false;
}
return true;
return false;
}
/**
* 根据用户成交总额获取对应比例再计算提成
* */
public Map<String, Float> getRateByAmount2(Long userId, Long postId, Map<String, Double> amountMap){
public Map<String, Float> getRateByAmount(Long userId, Long postId, Map<String, BigDecimal> amountMap){
SysCommision tmpQueryCom = new SysCommision();
tmpQueryCom.setUserId(userId);
tmpQueryCom.setPostId(postId);
List<SysCommision> tmpComList = sysCommisionMapper.selectSysCommisionList(tmpQueryCom);
Map<String, Float> rateMap = new TreeMap<>(new MyComparator());
for(String yearMonth : amountMap.keySet()){
double orderAmount = amountMap.get(yearMonth);
BigDecimal orderAmount = amountMap.get(yearMonth);
rateMap.put(yearMonth, 0F);
if(tmpComList != null && tmpComList.size() > 0){
for (int i = 0; i < tmpComList.size(); i++) {
SysCommision com = tmpComList.get(i);
double cAmount = com.getAmount().floatValue();
if (orderAmount <= cAmount && i == 0) {
if (orderAmount.floatValue() <= cAmount && i == 0) {
// 第一条规则
rateMap.put(yearMonth,com.getRate());
break;
} else if (i == tmpComList.size() - 1 && orderAmount > cAmount) {
} else if (i == tmpComList.size() - 1 && orderAmount.floatValue() > cAmount) {
// 最后一条规则
rateMap.put(yearMonth,com.getRate());
break;
} else if (cAmount < orderAmount && orderAmount <= tmpComList.get(i + 1).getAmount().floatValue()) {
} else if (cAmount < orderAmount.floatValue() && orderAmount.floatValue() <= tmpComList.get(i + 1).getAmount().floatValue()) {
// 中间规则
rateMap.put(yearMonth,tmpComList.get(i + 1).getRate());
break;
@ -168,79 +169,6 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
return rateMap;
}
/**
* 根据用户ID统计出该用户在该月所有订单的服务数量服务总天数服务订单总额暂停总天数
* **/
public void dealServerOrderCommissionDetail(List<SysOrderCommisionDayDetail> orderDetailList, SysCommissionDayDetail sysCommissionDayDetail, String yearMonth){
//服务订单数量
int serverOrderCount = 0;
//服务总天数
int serverTotalDay = 0;
//服务订单总金额
double serverTotalAmount = 0.0;
//暂停总天数
int pauseTotalDay = 0;
if(orderDetailList != null){
for (SysOrderCommisionDayDetail sysOrderCommisionDayDetail : orderDetailList) {
//Map<String, Integer> dayMap = ((Map<String, Integer>)orderMap.get("everyYearMonthServerDay"));
if(sysOrderCommisionDayDetail.getEveryYearMonthServerDay() != null && sysOrderCommisionDayDetail.getEveryYearMonthServerDay().containsKey(yearMonth)){
int day = sysOrderCommisionDayDetail.getEveryYearMonthServerDay().get(yearMonth).intValue();
serverTotalDay += day;
serverOrderCount += day > 0 ? 1 : 0;
}
if(sysOrderCommisionDayDetail.getEveryYearMonthServerMoney() != null && sysOrderCommisionDayDetail.getEveryYearMonthServerMoney().containsKey(yearMonth)){
serverTotalAmount += sysOrderCommisionDayDetail.getEveryYearMonthServerMoney().get(yearMonth).doubleValue();
}
//dayMap = ((Map<String, Integer>)orderMap.get("everyYearMonthPauseDay"));
if(sysOrderCommisionDayDetail.getEveryYearMonthPauseDay() != null && sysOrderCommisionDayDetail.getEveryYearMonthPauseDay().containsKey(yearMonth)){
pauseTotalDay += sysOrderCommisionDayDetail.getEveryYearMonthPauseDay().get(yearMonth).intValue();
}
}
}
sysCommissionDayDetail.setServerOrderTotalCount(serverOrderCount);
sysCommissionDayDetail.setServerTotalDay(serverTotalDay);
sysCommissionDayDetail.setServerTotalAmount(getMoney(serverTotalAmount, 1));
sysCommissionDayDetail.setServerOrderPauseTotalDay(pauseTotalDay);
//获取提成比例以及计算提成
getRateByAmount(sysCommissionDayDetail);
}
/**
* 根据用户成交总额获取对应比例再计算提成
* */
public void getRateByAmount(SysCommissionDayDetail sysCommissionDayDetail){
SysCommision tmpQueryCom = new SysCommision();
tmpQueryCom.setUserId(sysCommissionDayDetail.getUserId());
tmpQueryCom.setPostId(sysCommissionDayDetail.getPostId());
List<SysCommision> tmpComList = sysCommisionMapper.selectSysCommisionList(tmpQueryCom);
double orderAmount = sysCommissionDayDetail.getOrderTotalAmount().doubleValue();
sysCommissionDayDetail.setRate(0F);
sysCommissionDayDetail.setCommissionTotalAmount(getMoney(0.0D, 1));
if(tmpComList != null && tmpComList.size() > 0){
for (int i = 0; i < tmpComList.size(); i++) {
SysCommision com = tmpComList.get(i);
double cAmount = com.getAmount().floatValue();
if (orderAmount <= cAmount && i == 0) {
// 第一条规则
sysCommissionDayDetail.setRate(com.getRate());
break;
} else if (i == tmpComList.size() - 1 && orderAmount > cAmount) {
// 最后一条规则
sysCommissionDayDetail.setRate(com.getRate());
break;
} else if (cAmount < orderAmount && orderAmount <= tmpComList.get(i + 1).getAmount().floatValue()) {
// 中间规则
sysCommissionDayDetail.setRate(tmpComList.get(i + 1).getRate());
break;
}
}
}
double serverAmount = sysCommissionDayDetail.getServerTotalAmount().doubleValue();
serverAmount = serverAmount * sysCommissionDayDetail.getRate() / 100D;
sysCommissionDayDetail.setCommissionTotalAmount(getMoney(serverAmount, 1));
}
/**
* 查询2021年1月份之后所有订单对订单进行处理得出每笔订单的相关信息
* */
@ -251,15 +179,20 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
Map<Long, List<SysOrderCommisionDayDetail>> userOrderResultMap = new HashMap<>();
for (SysOrder sysOrder : orderList) {
//建档时间为空售后人员ID为空营养师ID为空订单金额为空或小于0都视为异常订单
if(sysOrder.getStartTime() == null || sysOrder.getAfterSaleId() == null || sysOrder.getNutritionistId() == null
if(sysOrder.getOrderTime() == null || sysOrder.getStartTime() == null || sysOrder.getServeTimeId() == null
|| (sysOrder.getAfterSaleId() == null && sysOrder.getNutritionistId() == null)
|| sysOrder.getAmount() == null || sysOrder.getAmount().doubleValue() < 0){
System.out.println("客户:"+ sysOrder.getCustomer() +",营养师:"+sysOrder.getNutritionist() + ",售后" + sysOrder.getAfterSale());
//System.out.println("客户:"+ sysOrder.getCustomer() +",营养师:"+sysOrder.getNutritionist() + ",售后" + sysOrder.getAfterSale());
continue;
}
//对每笔订单进行处理统计出该比订单在每年每月对应的服务天数金额暂停天数等
SysOrderCommisionDayDetail sysOrderCommisionDayDetail = statisticsOrderMessage(sysOrder);
addUserOrderResultMap(sysOrder.getAfterSaleId(), sysOrderCommisionDayDetail, userOrderResultMap);
addUserOrderResultMap(sysOrder.getNutritionistId(), sysOrderCommisionDayDetail, userOrderResultMap);
if(sysOrder.getAfterSaleId() != null && sysOrder.getAfterSaleId() > 0L){
addUserOrderResultMap(sysOrder.getAfterSaleId(), sysOrderCommisionDayDetail, userOrderResultMap);
}
if(sysOrder.getNutritionistId() != null && sysOrder.getNutritionistId() > 0L){
addUserOrderResultMap(sysOrder.getNutritionistId(), sysOrderCommisionDayDetail, userOrderResultMap);
}
}
return userOrderResultMap;
}
@ -433,8 +366,8 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
/**
* double转为BigDecimal保留一位小数向下舍去
* */
public BigDecimal getMoney(double money, int n){
return new BigDecimal(money).setScale(n, RoundingMode.DOWN);
public BigDecimal getMoney(Double money, int n){
return new BigDecimal(money).setScale(n, BigDecimal.ROUND_HALF_UP);
}
/**
@ -449,29 +382,20 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
}
public static void main(String[] args){
DecimalFormat df = new DecimalFormat("#.#");
BigDecimal money = new BigDecimal(3300.00/91);
System.out.println(Period.between(LocalDate.of(2020,2, 28), LocalDate.of(2020,1, 27)).getDays());
System.out.println(ChronoUnit.DAYS.between(LocalDate.of(2021,2, 28), LocalDate.of(2021,3, 1)));
System.out.println(LocalDate.of(2020,1, 20).getYear());
System.out.println(LocalDate.of(2021,1, 30).plusMonths(1));
Double s = 31190.1;
/* NumberFormat nf = NumberFormat.getNumberInstance();
// 保留小数位数
nf.setMaximumFractionDigits(1);
// 如果不需要四舍五入可以使用
nf.setRoundingMode(RoundingMode.DOWN);
System.out.println(Double.parseDouble(nf.format(s)));
System.out.println( new BigDecimal(nf.format(s)).doubleValue());*/
System.out.println(new BigDecimal(s).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
System.out.println("s" + LocalDate.of(2021,1, 30).getMonth().getValue());
System.out.println("----------------------------");
LocalDate server_end_date = LocalDate.now().plusMonths(3);
server_end_date = server_end_date.plusDays(7);
server_end_date = server_end_date.minusDays(7);
System.out.println(server_end_date);
System.out.println(LocalDate.now().getMonth().getValue());
Float f = 520.4F;
System.out.println(f * 1 / 100F);
System.out.println(new BigDecimal(f * 1 / 100F).setScale(1, RoundingMode.DOWN));
LocalDate localDate = LocalDate.of(2020, 1, 15);
System.out.println(ChronoUnit.MONTHS.between(localDate, LocalDate.now()));
System.out.println(localDate.getDayOfMonth());
System.out.println(localDate.getDayOfWeek());
System.out.println(localDate.getDayOfYear());
}
}

View File

@ -87,15 +87,14 @@
<select id="selectSysCustomerList" parameterType="SysCustomer" resultMap="SysCustomerResult">
<include refid="selectSysCustomerVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="phone != null and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
</where>
where del_flag = 0
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="phone != null and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
</select>
<select id="selectSysCustomerById" parameterType="Long" resultMap="SysCustomerResult">
<include refid="selectSysCustomerVo"/>
where id = #{id}
where id = #{id} and del_flag = 0
</select>
<insert id="insertSysCustomer" parameterType="SysCustomer" useGeneratedKeys="true" keyProperty="id">
@ -167,21 +166,21 @@
where id = #{id}
</update>
<delete id="deleteSysCustomerById" parameterType="Long">
delete from sys_customer where id = #{id}
</delete>
<update id="deleteSysCustomerById" parameterType="Long">
update sys_customer set del_flag = 1 where id = #{id}
</update>
<delete id="deleteSysCustomerByIds" parameterType="String">
delete from sys_customer where id in
<update id="deleteSysCustomerByIds" parameterType="String">
update sys_customer set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</update>
<!-- 根据手机号查询客户 -->
<select id="getCustomerByPhone" parameterType="String" resultMap="SysCustomerResult">
<include refid="selectSysCustomerVo"/>
where phone = #{phone}
where phone = #{phone} and del_flag = 0
</select>
<sql id="selectSysCustomerAndSign">
@ -190,7 +189,7 @@
select sc.id, sc.name, sc.phone, sc.create_time, sc.create_by, sc.update_time, sc.update_by,
<include refid="selectSysCustomerPhysicalSigns"></include>
from sys_customer sc
left join sys_customer_physical_signs scps on scps.customer_id = sc.id
left join sys_customer_physical_signs scps on scps.customer_id = sc.id and scps.del_flag = 0
</sql>
<sql id="selectSysCustomerPhysicalSigns">
@ -201,12 +200,10 @@
</sql>
<select id="selectSysCustomerAndSignList" parameterType="SysCustomer" resultMap="SysCustomerSignResult">
<include refid="selectSysCustomerAndSign"/>
<where>
<if test="id != null"> and sc.id = #{id} </if>
<if test="name != null and name != ''"> and sc.name like concat('%', #{name}, '%')</if>
<if test="phone != null and phone != ''"> and sc.phone like concat('%', #{phone}, '%')</if>
</where>
<include refid="selectSysCustomerAndSign"/> where sc.del_flag = 0
<if test="id != null"> and sc.id = #{id} </if>
<if test="name != null and name != ''"> and sc.name like concat('%', #{name}, '%')</if>
<if test="phone != null and phone != ''"> and sc.phone like concat('%', #{phone}, '%')</if>
order by sc.create_time desc
</select>

View File

@ -38,50 +38,49 @@
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="comments" column="comments"/>
</resultMap>
<sql id="selectSysCustomerPhysicalSignsVo">
select id, customer_id, sex, age, tall, weight, physical_signs_id, dishes_ingredient_id, photo, constipation, stayLate, motion, make_food_type, make_food_taste, walk, difficulty, weakness, rebound, crux, position, sleep_time, getup_time, connect_time, remarks, blood_data, moisture_date, vocation,
night, experience, create_time, create_by, update_time, update_by from sys_customer_physical_signs
night, experience, comments, create_time, create_by, update_time, update_by from sys_customer_physical_signs
</sql>
<select id="selectSysCustomerPhysicalSignsList" parameterType="SysCustomerPhysicalSigns" resultMap="SysCustomerPhysicalSignsResult">
<include refid="selectSysCustomerPhysicalSignsVo"/>
<where>
<if test="customerId != null "> and customer_id = #{customerId}</if>
<if test="sex != null "> and sex = #{sex}</if>
<if test="age != null "> and age = #{age}</if>
<if test="tall != null "> and tall = #{tall}</if>
<if test="weight != null "> and weight = #{weight}</if>
<if test="physicalSignsId != null and physicalSignsId != ''"> and physical_signs_id = #{physicalSignsId}</if>
<if test="dishesIngredientId != null and dishesIngredientId != ''"> and dishes_ingredient_id = #{dishesIngredientId}</if>
<if test="photo != null and photo != ''"> and photo = #{photo}</if>
<if test="constipation != null "> and constipation = #{constipation}</if>
<if test="staylate != null "> and stayLate = #{staylate}</if>
<if test="motion != null "> and motion = #{motion}</if>
<if test="makeFoodType != null "> and make_food_type = #{makeFoodType}</if>
<if test="makeFoodTaste != null "> and make_food_taste = #{makeFoodTaste}</if>
<if test="walk != null "> and walk = #{walk}</if>
<if test="difficulty != null and difficulty != ''"> and difficulty = #{difficulty}</if>
<if test="weakness != null "> and weakness = #{weakness}</if>
<if test="rebound != null "> and rebound = #{rebound}</if>
<if test="crux != null "> and crux = #{crux}</if>
<if test="position != null "> and position = #{position}</if>
<if test="sleepTime != null "> and sleep_time = #{sleepTime}</if>
<if test="getupTime != null "> and getup_time = #{getupTime}</if>
<if test="connectTime != null "> and connect_time = #{connectTime}</if>
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
<if test="bloodData != null and bloodData != ''"> and blood_data = #{bloodData}</if>
<if test="moistureDate != null and moistureDate != ''"> and moisture_date = #{moistureDate}</if>
<if test="vocation != null and vocation != ''"> and vocation = #{vocation}</if>
<if test="night != null "> and night = #{night}</if>
<if test="experience != null and experience != ''"> and experience = #{experience}</if>
</where>
<include refid="selectSysCustomerPhysicalSignsVo"/> where del_flag = 0
<if test="customerId != null "> and customer_id = #{customerId}</if>
<if test="sex != null "> and sex = #{sex}</if>
<if test="age != null "> and age = #{age}</if>
<if test="tall != null "> and tall = #{tall}</if>
<if test="weight != null "> and weight = #{weight}</if>
<if test="physicalSignsId != null and physicalSignsId != ''"> and physical_signs_id = #{physicalSignsId}</if>
<if test="dishesIngredientId != null and dishesIngredientId != ''"> and dishes_ingredient_id = #{dishesIngredientId}</if>
<if test="photo != null and photo != ''"> and photo = #{photo}</if>
<if test="constipation != null "> and constipation = #{constipation}</if>
<if test="staylate != null "> and stayLate = #{staylate}</if>
<if test="motion != null "> and motion = #{motion}</if>
<if test="makeFoodType != null "> and make_food_type = #{makeFoodType}</if>
<if test="makeFoodTaste != null "> and make_food_taste = #{makeFoodTaste}</if>
<if test="walk != null "> and walk = #{walk}</if>
<if test="difficulty != null and difficulty != ''"> and difficulty = #{difficulty}</if>
<if test="weakness != null "> and weakness = #{weakness}</if>
<if test="rebound != null "> and rebound = #{rebound}</if>
<if test="crux != null "> and crux = #{crux}</if>
<if test="position != null "> and position = #{position}</if>
<if test="sleepTime != null "> and sleep_time = #{sleepTime}</if>
<if test="getupTime != null "> and getup_time = #{getupTime}</if>
<if test="connectTime != null "> and connect_time = #{connectTime}</if>
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
<if test="bloodData != null and bloodData != ''"> and blood_data = #{bloodData}</if>
<if test="moistureDate != null and moistureDate != ''"> and moisture_date = #{moistureDate}</if>
<if test="vocation != null and vocation != ''"> and vocation = #{vocation}</if>
<if test="night != null "> and night = #{night}</if>
<if test="experience != null and experience != ''"> and experience = #{experience}</if>
</select>
<select id="selectSysCustomerPhysicalSignsById" parameterType="Long" resultMap="SysCustomerPhysicalSignsResult">
<include refid="selectSysCustomerPhysicalSignsVo"/>
where id = #{id}
where id = #{id} and del_flag = 0
</select>
<insert id="insertSysCustomerPhysicalSigns" parameterType="SysCustomerPhysicalSigns" useGeneratedKeys="true" keyProperty="id">
@ -113,10 +112,9 @@
<if test="bloodData != null">blood_data,</if>
<if test="moistureDate != null">moisture_date,</if>
<if test="vocation != null">vocation,</if>
<if test="
night != null">
night,</if>
<if test="night != null">night,</if>
<if test="experience != null">experience,</if>
<if test="comments != null">comments,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
@ -151,6 +149,7 @@ night != null">
<if test="vocation != null">#{vocation},</if>
<if test="night != null">#{night},</if>
<if test="experience != null">#{experience},</if>
<if test="comments != null">#{comments},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
@ -189,6 +188,7 @@ night != null">
<if test="vocation != null">vocation = #{vocation},</if>
<if test="night != null">night = #{night},</if>
<if test="experience != null">experience = #{experience},</if>
<if test="comments != null">comments = #{comments},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
@ -197,16 +197,16 @@ night != null">
where id = #{id}
</update>
<delete id="deleteSysCustomerPhysicalSignsById" parameterType="Long">
delete from sys_customer_physical_signs where id = #{id}
</delete>
<update id="deleteSysCustomerPhysicalSignsById" parameterType="Long">
update sys_customer_physical_signs set del_flag = 0 where id = #{id}
</update>
<delete id="deleteSysCustomerPhysicalSignsByIds" parameterType="String">
delete from sys_customer_physical_signs where id in
<update id="deleteSysCustomerPhysicalSignsByIds" parameterType="String">
update sys_customer_physical_signs set del_flag = 0 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</update>
<!-- 根据客户id更新体征信息 -->
<update id="updateSysCustomerPhysicalSignsByCustomerId" parameterType="SysCustomerPhysicalSigns">
@ -239,6 +239,7 @@ night != null">
<if test="vocation != null">vocation = #{vocation},</if>
<if test="night != null">night = #{night},</if>
<if test="experience != null">experience = #{experience},</if>
<if test="comments != null">comments = #{comments},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
@ -247,11 +248,11 @@ night != null">
where customer_id = #{customerId}
</update>
<delete id="deleteSysCustomerPhysicalSignsByCustomerIds" parameterType="String">
delete from sys_customer_physical_signs where customer_id in
<update id="deleteSysCustomerPhysicalSignsByCustomerIds" parameterType="String">
update sys_customer_physical_signs set del_flag = 0 where customer_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</update>
</mapper>

View File

@ -36,19 +36,24 @@
<result property="serveTimeId" column="serve_time_id"/>
<result property="reviewStatus" column="review_status"/>
<result property="giveServeDay" column="give_serve_day"/>
<result property="conditioningProjectId" column="conditioning_project_id"/>
<result property="serverEndTime" column="server_end_time"/>
<result property="becomeFanTime" column="become_fan_time"/>
<!-- 非持久化字段 -->
<result property="afterSale" column="afterSale_name"></result><!-- 售后名称 -->
<result property="nutritionist" column="nutritionist_name"></result><!-- 营养师名称 -->
<result property="conditioningProject" column="conditioning_project"></result><!-- 调理项目 -->
</resultMap>
<sql id="selectSysOrderVo">
select o.order_id, o.review_status, o.customer, o.phone, o.amount, o.start_time, o.pause_time, o.status, o.weight, ser.dict_label as serve_time,
o.serve_time_id, o.pay_type_id, pay.dict_label as pay_type, o.pre_sale_id, o.create_by, o.create_time, o.after_sale_id, o.update_by, o.update_time,
o.nutritionist_id, o.remark, o.nutri_assis_id, o.account_id, acc.dict_label as account, o.planner_id, o.planner_assis_id, o.operator_id, o.operator_assis_id,
o.recommender, o.order_time,o.give_serve_day from sys_order o
o.recommender, o.order_time,o.give_serve_day,o.conditioning_project_id,cp.dict_label as conditioning_project,o.server_end_time,o.become_fan_time from sys_order o
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_pay_type') AS pay ON pay.dict_value = o.pay_type_id
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_account') AS acc ON acc.dict_value = o.account_id
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_serve_time') AS ser ON ser.dict_value = o.serve_time_id
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'conditioning_project') AS cp ON cp.dict_value = o.conditioning_project_id
</sql>
<select id="selectAllOrderAmount" parameterType="SysOrder" resultType="BigDecimal">
@ -138,6 +143,9 @@
<if test="serveTimeId != null">serve_time_id,</if>
<if test="reviewStatus != null">review_status,</if>
<if test="giveServeDay != null">give_serve_day,</if>
<if test="conditioningProjectId != null">conditioning_project_id,</if>
<if test="serverEndTime != null">server_end_time,</if>
<if test="becomeFanTime != null">become_fan_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null and orderId != ''">#{orderId},</if>
@ -168,6 +176,9 @@
<if test="serveTimeId != null">#{serveTimeId},</if>
<if test="reviewStatus != null">#{reviewStatus},</if>
<if test="giveServeDay != null">#{giveServeDay},</if>
<if test="conditioningProjectId != null">#{conditioningProjectId},</if>
<if test="serverEndTime != null">#{serverEndTime},</if>
<if test="becomeFanTime != null">#{becomeFanTime},</if>
</trim>
</insert>
@ -201,6 +212,9 @@
<if test="serveTimeId != null">serve_time_id = #{serveTimeId},</if>
<if test="reviewStatus != null">review_status = #{reviewStatus},</if>
<if test="giveServeDay != null">give_serve_day = #{giveServeDay},</if>
<if test="conditioningProjectId != null">conditioning_project_id = #{conditioningProjectId},</if>
<if test="serverEndTime != null">server_end_time = #{serverEndTime},</if>
<if test="becomeFanTime != null">become_fan_time = #{becomeFanTime},</if>
</trim>
where order_id = #{orderId}
</update>
@ -248,6 +262,9 @@
<result property="serveTimeId" column="serve_time_id"/>
<result property="reviewStatus" column="review_status"/>
<result property="giveServeDay" column="give_serve_day"/>
<result property="conditioningProjectId" column="conditioning_project_id"/>
<result property="serverEndTime" column="server_end_time"/>
<result property="becomeFanTime" column="become_fan_time"/>
<!-- 非持久化字段 -->
<result property="afterSale" column="afterSale_name"></result><!-- 售后名称 -->
<result property="nutritionist" column="nutritionist_name"></result><!-- 营养师名称 -->
@ -275,11 +292,10 @@
<!-- 查询订单信息(用于计算提成) -->
<select id="selectSimpleOrderMessage" resultMap="SysOrderResultExtended">
select o.order_id,o.order_time,o.customer,o.review_status,o.amount,o.serve_time_id,o.give_serve_day,o.after_sale_id,su_sale.nick_name as afterSale_name,o.nutritionist_id,su_nutritionist.nick_name as nutritionist_name,sc.create_time as start_time
select o.order_id,o.order_time,o.start_time,o.customer,o.review_status,o.amount,o.serve_time_id,o.give_serve_day,o.after_sale_id,su_sale.nick_name as afterSale_name,o.nutritionist_id,su_nutritionist.nick_name as nutritionist_name
from sys_order o
left join sys_user su_sale on su_sale.user_id = o.after_sale_id and su_sale.del_flag = 0
left join sys_user su_nutritionist on su_nutritionist.user_id = o.nutritionist_id and su_nutritionist.del_flag = 0
left join sys_customer sc on sc.phone = o.phone and sc.del_flag = 0
where o.order_time >= '2021-01-01'
<if test="userId != null">
and (su_sale.user_id = #{userId} or su_nutritionist.user_id = #{userId})

View File

@ -76,7 +76,7 @@
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<template scope="scope">
<el-button type="text" @click="openFormDialog('查看发放计划', scope.row)">查看发放计划</el-button>
</template>
</el-table-column>
@ -94,10 +94,14 @@
/>
<el-dialog title="提成发放计划" :visible.sync="sendCommissionPlanTable" width="25%" align="center">
<el-table :data="sendCommissionPlan">
<el-dialog title="提成发放计划" :visible.sync="sendCommissionPlanTable" width="40%" align="center">
<el-table :data="sendCommissionPlan.list" show-summary :summary-method="getSummaries">
<el-table-column property="nickName" label="姓名" width="150"></el-table-column>
<el-table-column property="yearMonth" label="发放年月" width="200"></el-table-column>
<el-table-column property="yearMonth" label="提成月份" width="200">
<template scope="scope">
{{scope.row.yearMonth.substring(0, 4)}}{{scope.row.yearMonth.substring(4)}}
</template>
</el-table-column>
<el-table-column property="yearMonthCommission" label="提成金额" width="100"></el-table-column>
</el-table>
</el-dialog>
@ -154,7 +158,7 @@
postId: null,
},
sendCommissionPlanTable: false,
sendCommissionPlan:[]
sendCommissionPlan:{}
};
},
created() {
@ -249,15 +253,36 @@
this.queryParams.userId = null;
},
openFormDialog(title, row){
this.sendCommissionPlan = row.sendDetailList;
this.sendCommissionPlan = {};
var total = 0;
this.sendCommissionPlan.forEach(function(e){
e.nickName = row.nickName;
e.yearMonth = e.yearMonth.substring(0,4) + "年" + e.yearMonth.substring(4)+"月";
total += e.yearMonthCommission;
});
//this.sendCommissionPlan.push({'': })
if(row.sendDetailList != null){
row.sendDetailList.forEach(function (e) {
e.nickName = row.nickName;
total += e.yearMonthCommission;
});
}
this.sendCommissionPlan.list = row.sendDetailList;
this.sendCommissionPlan.total = row.totalNotSentCommissionAmount;
this.sendCommissionPlanTable = true;
},
getSummaries(param) {
//param columns data {columns: Array[4], data: Array[5]},
const { columns, data } = param;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计';
return;
}
if(index == 1){
sums[index] = data.length +"个月";
return
}
if(index == 2){
sums[index] = this.sendCommissionPlan.total;
}
});
return sums;
}
}
};

View File

@ -238,6 +238,7 @@
{{scope.row.giveServeDay ? `${scope.row.giveServeDay}` : '0天'}}
</template>
</el-table-column>
<el-table-column label="调理项目" align="center" prop="conditioningProject" width="120"/>
<el-table-column label="收款方式" align="center" prop="payType" width="120"/>
<el-table-column label="售前" align="center" prop="preSale" width="120"/>
<el-table-column label="售后" align="center" prop="afterSale" width="120"/>
@ -249,6 +250,11 @@
<el-table-column label="运营" align="center" prop="operator" width="120"/>
<el-table-column label="运营助理" align="center" prop="operatorAssis" width="120"/>
<el-table-column label="推荐人" align="center" prop="recommender" width="120"/>
<el-table-column label="进粉时间" align="center" prop="becomeFanTime" width="120">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.becomeFanTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" width="120"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="300" fixed="right">
<template slot-scope="scope">
@ -364,6 +370,18 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="调理项目" prop="conditioningProjectId">
<el-select v-model="form.conditioningProjectId" placeholder="请选择">
<el-option
v-for="dict in conditioningProjectIdOption"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="售前" prop="preSaleId">
<el-select v-model="form.preSaleId" placeholder="请选择">
@ -478,6 +496,21 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="进粉时间" prop="becomeFanTime">
<el-date-picker
style="width: 182.5px"
v-model="form.becomeFanTime"
type="date"
placeholder="选择进粉时间"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
:picker-options="fanPickerOptions"
>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item label="成交时间" prop="orderTime">
<el-date-picker
style="width: 182.5px"
@ -572,6 +605,8 @@
serveTimeIdOption: [],
//
giveTimeIdOption: [],
//
conditioningProjectIdOption:[],
//
reviewStatusOptions: [],
//
@ -618,7 +653,12 @@
],
startTime: [
{required: true, message: "开始时间不能为空", trigger: "blur"}
],
becomeFanTime: [
{required: true, message: "进粉时间不能为空", trigger: "blur"}
]
// payTypeId: [
// {required: true, message: "", trigger: "blur"}
// ],
@ -664,6 +704,11 @@
return time.getTime() > Date.now();
},
},
fanPickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
},
},
startPickerOptions: {
disabledDate(time) {
return time.getTime() < Date.now();
@ -702,6 +747,9 @@
this.getDicts("give_serve_daye_type").then(response => {
this.giveTimeIdOption = response.data;
});
this.getDicts("conditioning_project").then(response => {
this.conditioningProjectIdOption = response.data;
});
this.getDicts("cus_review_status").then(response => {
this.reviewStatusOptions = response.data;
})
@ -767,6 +815,7 @@
const defaultPayType = this.payTypeIdOptions.find(opt => opt.remark === 'default');
const defaultServeTime = this.serveTimeIdOption.find(opt => opt.remark === 'default');
const defaultGiveServeTime = this.giveTimeIdOption.find(opt => opt.remark === 'default');
const defaultConditioningProjectIdOption = this.conditioningProjectIdOption.find(opt => opt.remark === 'default');
const defaultAccount = this.accountIdOptions.find(opt => opt.remark === 'default');
const defaultOperator = this.operatorIdOptions.find(opt => opt.remark === 'default');
const defaultOperatorAssis = this.operatorAssisIdOptions.find(opt => opt.remark === 'default');
@ -803,7 +852,9 @@
orderTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
serveTimeId: defaultServeTime ? parseInt(defaultServeTime.dictValue) : null,
reviewStatus: this.review,
giveServeDay: defaultGiveServeTime ? parseInt(defaultGiveServeTime.dictValue) : null
giveServeDay: defaultGiveServeTime ? parseInt(defaultGiveServeTime.dictValue) : null,
conditioningProjectId: defaultConditioningProjectIdOption ? parseInt(defaultConditioningProjectIdOption.dictValue) : null,
becomeFanTime: dayjs().format("YYYY-MM-DD")
};
this.resetForm("form");
},
@ -837,6 +888,9 @@
getOrder(orderId).then(response => {
this.form = response.data;
this.form.giveServeDay = parseInt(this.form.giveServeDay+"");
if(this.form.becomeFanTime == null){
this.form.becomeFanTime = this.form.orderTime;
}
this.open = true;
this.title = "修改销售订单";
});