提成优化,视频页面

This commit is contained in:
xiezhijun
2021-05-06 17:08:55 +08:00
parent 7236ef518e
commit 79f1b9b23c
12 changed files with 219 additions and 30 deletions

View File

@ -1,5 +1,6 @@
package com.stdiet.custom.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -7,6 +8,7 @@ import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity;
import java.math.BigDecimal;
import java.util.Date;
/**
* 业务提成比例对象 sys_commision
@ -54,6 +56,11 @@ public class SysCommision extends BaseEntity {
@Excel(name = "比例", suffix = "%")
private Float rate;
/** 比例开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date startTime;
/**
* 提成
*/

View File

@ -66,4 +66,13 @@ public interface SysNutritionalVideoMapper
* @return
*/
public SysNutritionalVideo selectSysNutritionalVideByVideoId(@Param("videoId")String videoId);
/**
* 更新微信展示状态
* @param wxShow
* @param ids
* @return
*/
public int updateWxshowByIds(@Param("wxShow")Integer wxShow, @Param("array") Long[] ids);
}

View File

@ -73,4 +73,12 @@ public interface ISysNutritionalVideoService
* @return
*/
public Map<String,Object> searchVideo(String key, Integer status, Integer pageNo, Integer pageSize, String scrollToken);
/**
* 更新微信展示状态
* @param wxShow
* @param ids
* @return
*/
public int updateWxshowByIds(Integer wxShow, Long[] ids);
}

View File

@ -296,7 +296,7 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
//该笔订单当月的成交总额
sysOrderCommisionDayDetail.setMonthOrderTotalAmount(everyMonthTotalAmountMap.get(yearMonth));
//该笔订单对应提成比例
sysOrderCommisionDayDetail.setCommissionRate(rateMap.get(yearMonth) == null ? rateMap.get("190001") : rateMap.get(yearMonth));
sysOrderCommisionDayDetail.setCommissionRate(rateMap.get(yearMonth) == null ? rateMap.get("19001") : rateMap.get(yearMonth));
//计算该笔订单总提成
sysOrderCommisionDayDetail.setOrderCommission(getMoney(sysOrderCommisionDayDetail.getOrderAmount().doubleValue() * sysOrderCommisionDayDetail.getCommissionRate() / 100D));
//每年每月提成
@ -358,25 +358,42 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
List<SysCommision> tmpComList = sysCommisionMapper.selectSysCommisionList(tmpQueryCom);
Map<String, Float> rateMap = new TreeMap<>(new MyComparator());
//取第一个区间为默认提成比例
rateMap.put("190001", (tmpComList != null && tmpComList.size() > 0) ? tmpComList.get(0).getRate() : 0.0F);
rateMap.put("19001", (tmpComList != null && tmpComList.size() > 0) ? tmpComList.get(0).getRate() : 0.0F);
//按比例开始时间分类
Map<String, List<SysCommision>> rateYearMonthMap = getRateMapByStartTime(tmpComList);
for(String yearMonth : amountMap.keySet()){
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);
List<SysCommision> yearMonthRateList = null;
for (String rateMonth : rateYearMonthMap.keySet()) {
if(Long.parseLong(yearMonth) >= Long.parseLong(rateMonth)){
yearMonthRateList = rateYearMonthMap.get(rateMonth);
}else{
break;
}
}
if(yearMonthRateList != null && yearMonthRateList.size() > 0){
for (int i = 0; i < yearMonthRateList.size(); i++) {
SysCommision com = yearMonthRateList.get(i);
double cAmount = com.getAmount().floatValue();
if (orderAmount.floatValue() <= cAmount && i == 0) {
Long rateStartYearMonth = null;
if(com.getStartTime() != null){
rateStartYearMonth = Long.parseLong(DateUtils.dateToLocalDate(com.getStartTime()).getYear() + "" + DateUtils.dateToLocalDate(com.getStartTime()).getMonth().getValue());
}else{
rateStartYearMonth = 19001L;
}
if (orderAmount.floatValue() <= cAmount && i == 0 && Long.parseLong(yearMonth) >= rateStartYearMonth) {
// 第一条规则
rateMap.put(yearMonth,com.getRate());
break;
} else if (i == tmpComList.size() - 1 && orderAmount.floatValue() > cAmount) {
} else if (i == yearMonthRateList.size() - 1 && orderAmount.floatValue() > cAmount && Long.parseLong(yearMonth) >= rateStartYearMonth) {
// 最后一条规则
rateMap.put(yearMonth,com.getRate());
break;
} else if (cAmount < orderAmount.floatValue() && orderAmount.floatValue() <= tmpComList.get(i + 1).getAmount().floatValue()) {
} else if (cAmount < orderAmount.floatValue() && orderAmount.floatValue() <= yearMonthRateList.get(i + 1).getAmount().floatValue() && Long.parseLong(yearMonth) >= rateStartYearMonth) {
// 中间规则
rateMap.put(yearMonth,tmpComList.get(i + 1).getRate());
rateMap.put(yearMonth,yearMonthRateList.get(i + 1).getRate());
break;
}
}
@ -385,6 +402,32 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
return rateMap;
}
/**
* 根据比例开始执行时间进行分类
* @param tmpComList
* @return
*/
public Map<String, List<SysCommision>> getRateMapByStartTime(List<SysCommision> tmpComList){
Map<String, List<SysCommision>> result = new TreeMap<>(new MyComparator());
for (SysCommision sysCommision : tmpComList) {
String rateStartYearMonth = null;
if(sysCommision.getStartTime() != null){
rateStartYearMonth = DateUtils.dateToLocalDate(sysCommision.getStartTime()).getYear() + "" + DateUtils.dateToLocalDate(sysCommision.getStartTime()).getMonth().getValue();
}else{
rateStartYearMonth = 19001+"";
}
if(result.containsKey(rateStartYearMonth)){
result.get(rateStartYearMonth).add(sysCommision);
}else{
List<SysCommision> list = new ArrayList<>();
list.add(sysCommision);
result.put(rateStartYearMonth, list);
}
}
return result;
}
/**
* 查询2021年1月份之后所有订单对订单进行处理得出每笔订单的相关信息
* @param sysCommision 是否
@ -549,12 +592,12 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
}
}
}
for (SysOrderCommisionDayDetail c : sysOrderCommisionDayDetailList) {
/**for (SysOrderCommisionDayDetail c : sysOrderCommisionDayDetailList) {
System.out.println(c.getOrderId() + "-" + c.getNutritionistId() + "-" + c.getAfterSaleId() + "-"+
DateUtils.localDateToString(c.getServerStartDate(),"yyyy-MM-dd") + "-" +
DateUtils.localDateToString(c.getServerEndDate(),"yyyy-MM-dd") +
"-" + c.getDayMoney().doubleValue() + "-" + c.getOrderAmount().doubleValue());
}
}**/
return sysOrderCommisionDayDetailList;
}

View File

@ -180,4 +180,14 @@ public class SysNutritionalVideoServiceImpl implements ISysNutritionalVideoServi
return "Normal".equals(status) ? 1 : 0;
}
/**
* 更新微信展示状态
* @param wxShow
* @param ids
* @return
*/
public int updateWxshowByIds(Integer wxShow, Long[] ids){
return sysNutritionalVideoMapper. updateWxshowByIds(wxShow, ids);
}
}

View File

@ -12,6 +12,7 @@
<result property="postName" column="post_name"/>
<result property="amount" column="amount"/>
<result property="rate" column="rate"/>
<result property="startTime" column="start_time" />
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
@ -136,6 +137,8 @@
<if test="userId != null ">and user_id = #{userId}</if>
<if test="postId != null ">and post_id = #{postId}</if>
</where>
<!-- 请勿随意修改排序方式,会影响提成计算 -->
order by user_id asc,amount asc,start_time asc
</select>
<select id="selectSysCommisionById" parameterType="SysCommision" resultMap="SysCommisionResult">
@ -152,6 +155,7 @@
<if test="postId != null">post_id,</if>
<if test="amount != null">amount,</if>
<if test="rate != null">rate,</if>
<if test="startTime != null">start_time,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
@ -163,6 +167,7 @@
<if test="postId != null">#{postId},</if>
<if test="amount != null">#{amount},</if>
<if test="rate != null">#{rate},</if>
<if test="startTime != null">#{startTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
@ -178,6 +183,7 @@
<if test="postId != null">post_id = #{postId},</if>
<if test="amount != null">amount = #{amount},</if>
<if test="rate != null">rate = #{rate},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>

View File

@ -43,6 +43,9 @@
<if test="cateId != null">
and snv.cate_id = #{cateId}
</if>
<if test="payLevel != null">
and snv.pay_level = #{payLevel}
</if>
<if test="key != null and key != ''">
and (snv.title like concat('%',#{key},'%') or snv.description like concat('%',#{key},'%'))
</if>
@ -129,4 +132,11 @@
<include refid="selectSysNutritionalVideoVo"/> where video_id = #{videoId} and del_flag = 0 limit 1
</select>
<update id="updateWxshowByIds" parameterType="String">
update sys_nutritional_video set show_flag = #{wxShow} where del_flag = 0 and id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>