提成加上合计、Excel导出;打卡记录加上姓名、营养师;体征调查加上备注项
This commit is contained in:
		| @@ -1,5 +1,6 @@ | ||||
| package com.stdiet.custom.domain; | ||||
|  | ||||
| import com.stdiet.common.annotation.Excel; | ||||
| import com.stdiet.common.core.domain.BaseEntity; | ||||
|  | ||||
| import java.math.BigDecimal; | ||||
| @@ -14,6 +15,7 @@ public class SysCommissionDayDetail extends BaseEntity { | ||||
|     private Long userId; | ||||
|  | ||||
|     //用户姓名 | ||||
|     @Excel(name = "业务员") | ||||
|     private String nickName; | ||||
|  | ||||
|     //用户账户 | ||||
| @@ -23,38 +25,20 @@ public class SysCommissionDayDetail extends BaseEntity { | ||||
|     private Long postId; | ||||
|  | ||||
|     //岗位名称 | ||||
|     @Excel(name = "岗位名称") | ||||
|     private String postName; | ||||
|  | ||||
|     @Excel(name = "总提成") | ||||
|     private BigDecimal totalCommissionAmount; | ||||
|  | ||||
|     @Excel(name = "已发放提成") | ||||
|     private BigDecimal totalHasSentCommissionAmount; | ||||
|  | ||||
|     @Excel(name = "未发放提成") | ||||
|     private BigDecimal totalNotSentCommissionAmount; | ||||
|  | ||||
|     private List<Map<String, Object>> sendDetailList; | ||||
|  | ||||
|  | ||||
|     //提成比例 | ||||
|     private Float rate; | ||||
|  | ||||
|     //订单成交总额 | ||||
|     private BigDecimal orderTotalAmount; | ||||
|  | ||||
|     //服务总天数 | ||||
|     private Integer serverTotalDay; | ||||
|  | ||||
|     //服务总额(每笔订单的服务天数 * 每天金额,相加) | ||||
|     private BigDecimal serverTotalAmount; | ||||
|  | ||||
|     //服务订单总数量 | ||||
|     private Integer serverOrderTotalCount; | ||||
|  | ||||
|     //服务暂停总天数 | ||||
|     private Integer serverOrderPauseTotalDay; | ||||
|  | ||||
|     //服务提成金额 | ||||
|     private BigDecimal commissionTotalAmount; | ||||
|  | ||||
|     public Long getUserId() { | ||||
|         return userId; | ||||
|     } | ||||
| @@ -71,68 +55,12 @@ public class SysCommissionDayDetail extends BaseEntity { | ||||
|         this.nickName = nickName; | ||||
|     } | ||||
|  | ||||
|     public String getPostName() { | ||||
|         return postName; | ||||
|     public String getUserName() { | ||||
|         return userName; | ||||
|     } | ||||
|  | ||||
|     public void setPostName(String postName) { | ||||
|         this.postName = postName; | ||||
|     } | ||||
|  | ||||
|     public Float getRate() { | ||||
|         return rate; | ||||
|     } | ||||
|  | ||||
|     public void setRate(Float rate) { | ||||
|         this.rate = rate; | ||||
|     } | ||||
|  | ||||
|     public BigDecimal getOrderTotalAmount() { | ||||
|         return orderTotalAmount; | ||||
|     } | ||||
|  | ||||
|     public void setOrderTotalAmount(BigDecimal orderTotalAmount) { | ||||
|         this.orderTotalAmount = orderTotalAmount; | ||||
|     } | ||||
|  | ||||
|     public Integer getServerTotalDay() { | ||||
|         return serverTotalDay; | ||||
|     } | ||||
|  | ||||
|     public void setServerTotalDay(Integer serverTotalDay) { | ||||
|         this.serverTotalDay = serverTotalDay; | ||||
|     } | ||||
|  | ||||
|     public BigDecimal getServerTotalAmount() { | ||||
|         return serverTotalAmount; | ||||
|     } | ||||
|  | ||||
|     public void setServerTotalAmount(BigDecimal serverTotalAmount) { | ||||
|         this.serverTotalAmount = serverTotalAmount; | ||||
|     } | ||||
|  | ||||
|     public Integer getServerOrderTotalCount() { | ||||
|         return serverOrderTotalCount; | ||||
|     } | ||||
|  | ||||
|     public void setServerOrderTotalCount(Integer serverOrderTotalCount) { | ||||
|         this.serverOrderTotalCount = serverOrderTotalCount; | ||||
|     } | ||||
|  | ||||
|     public Integer getServerOrderPauseTotalDay() { | ||||
|         return serverOrderPauseTotalDay; | ||||
|     } | ||||
|  | ||||
|     public void setServerOrderPauseTotalDay(Integer serverOrderPauseTotalDay) { | ||||
|         this.serverOrderPauseTotalDay = serverOrderPauseTotalDay; | ||||
|     } | ||||
|  | ||||
|     public BigDecimal getCommissionTotalAmount() { | ||||
|         return commissionTotalAmount; | ||||
|     } | ||||
|  | ||||
|     public void setCommissionTotalAmount(BigDecimal commissionTotalAmount) { | ||||
|         this.commissionTotalAmount = commissionTotalAmount; | ||||
|     public void setUserName(String userName) { | ||||
|         this.userName = userName; | ||||
|     } | ||||
|  | ||||
|     public Long getPostId() { | ||||
| @@ -143,12 +71,12 @@ public class SysCommissionDayDetail extends BaseEntity { | ||||
|         this.postId = postId; | ||||
|     } | ||||
|  | ||||
|     public String getUserName() { | ||||
|         return userName; | ||||
|     public String getPostName() { | ||||
|         return postName; | ||||
|     } | ||||
|  | ||||
|     public void setUserName(String userName) { | ||||
|         this.userName = userName; | ||||
|     public void setPostName(String postName) { | ||||
|         this.postName = postName; | ||||
|     } | ||||
|  | ||||
|     public BigDecimal getTotalCommissionAmount() { | ||||
|   | ||||
| @@ -68,6 +68,21 @@ public class SysWxUserLog extends BaseEntity | ||||
|     @JsonFormat(pattern = "yyyy-MM-dd") | ||||
|     private Date logTime; | ||||
|  | ||||
|     /** 非持久字段,客户姓名 + 营养师姓名,使用 , 隔开,用于接收sql查询返回字段 */ | ||||
|     private String customerMessage; | ||||
|  | ||||
|     /** | ||||
|      * 非持久化字段,营养师 | ||||
|      */ | ||||
|     @Excel(name = "姓名") | ||||
|     private String customer; | ||||
|  | ||||
|     /** | ||||
|      * 非持久化字段,营养师 | ||||
|      */ | ||||
|     @Excel(name = "营养师") | ||||
|     private String nutritionist; | ||||
|  | ||||
|     public void setLogTime(Date logTime) { | ||||
|         this.logTime = logTime; | ||||
|     } | ||||
| @@ -185,6 +200,30 @@ public class SysWxUserLog extends BaseEntity | ||||
|         return water; | ||||
|     } | ||||
|  | ||||
|     public String getCustomerMessage() { | ||||
|         return customerMessage; | ||||
|     } | ||||
|  | ||||
|     public void setCustomerMessage(String customerMessage) { | ||||
|         this.customerMessage = customerMessage; | ||||
|     } | ||||
|  | ||||
|     public String getCustomer() { | ||||
|         return customer; | ||||
|     } | ||||
|  | ||||
|     public void setCustomer(String customer) { | ||||
|         this.customer = customer; | ||||
|     } | ||||
|  | ||||
|     public String getNutritionist() { | ||||
|         return nutritionist; | ||||
|     } | ||||
|  | ||||
|     public void setNutritionist(String nutritionist) { | ||||
|         this.nutritionist = nutritionist; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String toString() { | ||||
|         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | ||||
|   | ||||
| @@ -144,6 +144,10 @@ public class CustomerInvestigateRequest extends BaseEntity | ||||
|     @Excel(name = "减脂经历") | ||||
|     private String experience; | ||||
|  | ||||
|     /** 备注 */ | ||||
|     @Excel(name = "备注") | ||||
|     private String comments; | ||||
|  | ||||
|     public Long getId() { | ||||
|         return id; | ||||
|     } | ||||
| @@ -399,4 +403,12 @@ public class CustomerInvestigateRequest extends BaseEntity | ||||
|     public void setExperience(String experience) { | ||||
|         this.experience = experience; | ||||
|     } | ||||
|  | ||||
|     public String getComments() { | ||||
|         return comments; | ||||
|     } | ||||
|  | ||||
|     public void setComments(String comments) { | ||||
|         this.comments = comments; | ||||
|     } | ||||
| } | ||||
| @@ -136,6 +136,10 @@ public class CustomerListResponse extends BaseEntity | ||||
|     @Excel(name = "减脂遇到的困难") | ||||
|     private String difficulty; | ||||
|  | ||||
|     /** 备注 */ | ||||
|     @Excel(name = "备注") | ||||
|     private String comments; | ||||
|  | ||||
|     public Long getId() { | ||||
|         return id; | ||||
|     } | ||||
| @@ -377,4 +381,12 @@ public class CustomerListResponse extends BaseEntity | ||||
|     public void setCreateTime(Date createTime) { | ||||
|         this.createTime = createTime; | ||||
|     } | ||||
|  | ||||
|     public String getComments() { | ||||
|         return comments; | ||||
|     } | ||||
|  | ||||
|     public void setComments(String comments) { | ||||
|         this.comments = comments; | ||||
|     } | ||||
| } | ||||
| @@ -5,6 +5,7 @@ import com.stdiet.custom.domain.SysCommissionDayDetail; | ||||
| import com.stdiet.custom.domain.SysOrder; | ||||
| import com.stdiet.custom.domain.SysOrderCommisionDayDetail; | ||||
|  | ||||
| import java.time.LocalDate; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| @@ -17,6 +18,18 @@ import java.util.Map; | ||||
|  */ | ||||
| public interface ISysCommissionDayService { | ||||
|  | ||||
|     /** | ||||
|      * 根据订单列表按天计算营养师、售后提成 | ||||
|      * @param sysCommision | ||||
|      * @return | ||||
|      */ | ||||
|     List<SysCommissionDayDetail> calculateCommissionByDay(SysCommision sysCommision); | ||||
|  | ||||
|     /** | ||||
|      * 根据订单ID计算该笔订单的服务到期时间 | ||||
|      * @param orderId | ||||
|      * @return | ||||
|      */ | ||||
|     LocalDate getServerEndDate(Long orderId); | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -32,6 +32,11 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService { | ||||
|         List<SysCommissionDayDetail> result = new ArrayList<>(); | ||||
|         //查询用户 | ||||
|         List<SysCommision> list = sysCommisionMapper.selectSysCommisionDayDetail(sysCommision); | ||||
|         //合计 | ||||
|         SysCommissionDayDetail total = new SysCommissionDayDetail(); | ||||
|         total.setTotalCommissionAmount(new BigDecimal(0)); | ||||
|         total.setTotalHasSentCommissionAmount(new BigDecimal(0)); | ||||
|         total.setTotalNotSentCommissionAmount(new BigDecimal(0)); | ||||
|         if(list != null && list.size() > 0){ | ||||
|             Map<Long, List<SysOrderCommisionDayDetail>> orderDetailMap = getOrderByList(sysCommision.getUserId()); | ||||
|             SysCommissionDayDetail sysCommissionDayDetail = null; | ||||
| @@ -41,16 +46,37 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService { | ||||
|                 sysCommissionDayDetail.setNickName(commision.getUserName()); | ||||
|                 sysCommissionDayDetail.setPostId(commision.getPostId()); | ||||
|                 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")); | ||||
|                 dealServerOrderCommissionDetail(orderDetailMap.get(sysCommissionDayDetail.getUserId()), sysCommissionDayDetail); | ||||
|                 result.add(sysCommissionDayDetail); | ||||
|                 //统计所以用户总提成、已发放提成、未发放提成 | ||||
|                 total.setTotalCommissionAmount(total.getTotalCommissionAmount().add(sysCommissionDayDetail.getTotalCommissionAmount())); | ||||
|                 total.setTotalHasSentCommissionAmount(total.getTotalHasSentCommissionAmount().add(sysCommissionDayDetail.getTotalHasSentCommissionAmount())); | ||||
|                 total.setTotalNotSentCommissionAmount(total.getTotalNotSentCommissionAmount().add(sysCommissionDayDetail.getTotalNotSentCommissionAmount())); | ||||
|             } | ||||
|         } | ||||
|         total.setPostName("胜唐体控"); | ||||
|         total.setNickName("合计"); | ||||
|         result.add(total); | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public LocalDate getServerEndDate(Long orderId){ | ||||
|         SysOrder sysOrder = sysOrderMapper.selectSysOrderById(orderId); | ||||
|         if(sysOrder != null){ | ||||
|             SysOrderPause sysOrderPause = new SysOrderPause(); | ||||
|             sysOrderPause.setOrderId(orderId); | ||||
|             List<SysOrderPause> pausesList = sysOrderPauseMapper.selectSysOrderPauseList(sysOrderPause); | ||||
|             //每年每月暂停天数,key为年份加月份,如:2021年1月=20211 | ||||
|             Map<String, Integer> everyYearMonthPauseDay = getEveryYearMonthPauseDay(pausesList); | ||||
|             //该笔订单暂停总天数 | ||||
|             int pauseTotalDay = getTotalByMap(everyYearMonthPauseDay); | ||||
|  | ||||
|             return getServerEndDate(DateUtils.dateToLocalDate(sysOrder.getStartTime()), sysOrder.getServeTimeId().intValue()/30, sysOrder.getGiveServeDay(), pauseTotalDay); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 根据用户ID统计出该用户在该月所有订单的服务数量、服务总天数、服务订单总额、暂停总天数 | ||||
| @@ -60,8 +86,6 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService { | ||||
|         BigDecimal totalCommissionAmount = new BigDecimal(0); | ||||
|         //已发放提成 | ||||
|         BigDecimal totalHasSentCommissionAmount = new BigDecimal(0); | ||||
|         //未发放提成 | ||||
|         BigDecimal totalNotSentCommissionAmount = new BigDecimal(0); | ||||
|         //未发放提成记录 | ||||
|         List<Map<String, Object>> sendDetailList = new ArrayList<>(); | ||||
|         if(orderDetailList != null){ | ||||
| @@ -116,6 +140,7 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService { | ||||
|         } | ||||
|         sysCommissionDayDetail.setTotalCommissionAmount(totalCommissionAmount); | ||||
|         sysCommissionDayDetail.setTotalHasSentCommissionAmount(totalHasSentCommissionAmount); | ||||
|         //未发放提成 = 总提成 - 已发放提成 | ||||
|         sysCommissionDayDetail.setTotalNotSentCommissionAmount(totalCommissionAmount.subtract(totalHasSentCommissionAmount)); | ||||
|         sysCommissionDayDetail.setSendDetailList(sendDetailList); | ||||
|     } | ||||
|   | ||||
| @@ -76,6 +76,7 @@ | ||||
|             <result property="vocation"    column="vocation"    /> | ||||
|             <result property="night"    column="night"    /> | ||||
|             <result property="experience"    column="experience"    /> | ||||
|             <result property="comments" column="comments"/> | ||||
|             <!-- column是传的参数, select是调用的查询 --> | ||||
|             <association property="signList" column="physical_signs_id" select="getSignByIds"/> | ||||
|         </association> | ||||
| @@ -196,7 +197,7 @@ | ||||
|         scps.sex, scps.age, scps.tall, scps.weight, scps.physical_signs_id, scps.dishes_ingredient_id, scps.photo, scps.constipation, | ||||
|         scps.stayLate, scps.motion, scps.make_food_type, scps.make_food_taste, scps.walk, scps.difficulty, scps.weakness, scps.rebound, scps.crux, scps.position, | ||||
|         scps.sleep_time, scps.getup_time, scps.connect_time, scps.remarks, scps.blood_data, scps.moisture_date, scps.vocation, | ||||
|         scps.night, scps.experience | ||||
|         scps.night, scps.experience, scps.comments | ||||
|     </sql> | ||||
|  | ||||
|     <select id="selectSysCustomerAndSignList" parameterType="SysCustomer" resultMap="SysCustomerSignResult"> | ||||
|   | ||||
| @@ -24,6 +24,8 @@ | ||||
|         <result property="updateBy" column="update_by"/> | ||||
|         <result property="updateTime" column="update_time"/> | ||||
|         <result property="remark" column="remark"/> | ||||
|         <!-- 非持久字段 --> | ||||
|         <result property="customerMessage" column="customer_message"></result> | ||||
|     </resultMap> | ||||
|  | ||||
|     <resultMap type="com.stdiet.custom.page.WxLogInfo" id="WxLogInfo"> | ||||
| @@ -42,15 +44,23 @@ | ||||
|         select openid, weight, appid, phone, log_time, sleep_time, wakeup_time, sport, avatar_url, diet, insomnia, defecation, water, create_by, create_time, update_by, update_time, remark from sys_wx_user_log | ||||
|     </sql> | ||||
|  | ||||
|     <sql id="selectBaseField"> | ||||
|         swul.openid, swul.weight, swul.appid, swul.phone, swul.log_time, swul.sleep_time, swul.wakeup_time, swul.sport, swul.avatar_url, swul.diet, swul.insomnia, | ||||
|         swul.defecation, swul.water, swul.create_by, swul.create_time, swul.update_by, swul.update_time, swul.remark | ||||
|     </sql> | ||||
|  | ||||
|     <select id="checkWxLogInfoCount" parameterType="String" resultType="Integer"> | ||||
|         select count(*) from sys_wx_user_log where to_days(log_time) = to_days(now()) and openid = #{openid} | ||||
|     </select> | ||||
|  | ||||
|     <select id="selectSysWxUserLogList" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult"> | ||||
|         <include refid="selectSysWxUserLogVo"/> | ||||
|         select <include refid="selectBaseField"></include>, | ||||
|         (select CONCAT(IFNULL(so.customer,''),',',IFNULL(su.nick_name,'')) from (select * from sys_order s where s.phone = swul.phone order by order_id desc limit 1) as so | ||||
|         left join sys_user su on su.user_id = so.nutritionist_id and su.del_flag = 0) as customer_message | ||||
|         from sys_wx_user_log swul | ||||
|         <where> | ||||
|             <if test="openid != null  and openid != ''">and openid = #{openid}</if> | ||||
|             <if test="phone != null  and phone != ''">or phone = #{phone}</if> | ||||
|             <if test="openid != null  and openid != ''">and swul.openid = #{openid}</if> | ||||
|             <if test="phone != null  and phone != ''">or swul.phone = #{phone}</if> | ||||
|         </where> | ||||
|         order by create_time desc | ||||
|     </select> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user