提成优化,视频页面

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

@ -6,6 +6,7 @@ import java.util.List;
import com.aliyun.vod20170321.models.CreateUploadVideoResponse;
import com.stdiet.common.core.page.TableDataInfo;
import com.stdiet.common.utils.AliyunVideoUtils;
import com.stdiet.common.utils.StringUtils;
import com.stdiet.common.utils.oss.AliyunOSSUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
@ -113,4 +114,20 @@ public class SysNutritionalVideoController extends BaseController
{
return toAjax(sysNutritionalVideoService.deleteSysNutritionalVideoByIds(ids));
}
/**
* 修改营养小知识是否微信展示状态
*/
@PreAuthorize("@ss.hasPermi('custom:nutritionalVideo:edit')")
@Log(title = "微信展示状态修改", businessType = BusinessType.UPDATE)
@GetMapping("/updateWxShow")
public AjaxResult updateWxShow(@RequestParam("id")String id, @RequestParam("showFlag")Integer showFlag)
{
if(StringUtils.isEmpty(id) || showFlag == null){
return AjaxResult.error();
}
Long[] ids = {Long.parseLong(id)};
return toAjax(sysNutritionalVideoService.updateWxshowByIds(showFlag, ids));
}
}

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>

View File

@ -60,3 +60,12 @@ export function getUploadVideoAuth(data) {
data: data
})
}
// 修改视频展示状态
export function updateWxShow(data){
return request({
url: '/custom/nutritionalVideo/updateWxShow',
method: 'get',
params: data
})
}

View File

@ -12,6 +12,7 @@
v-model="queryParams.postId"
placeholder="请选择岗位"
clearable
filterable
size="small"
@change="searchPostChange"
>
@ -28,6 +29,7 @@
v-model="queryParams.userId"
placeholder="请选择业务员"
clearable
filterable
size="small"
>
<el-option
@ -119,6 +121,7 @@
{{ scope.row.rate + "%" }}
</template>
</el-table-column>
<el-table-column label="开始时间" align="center" prop="startTime"/>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column
label="操作"
@ -196,6 +199,16 @@
<el-input v-model="form.rate" placeholder="请输入比例" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="开始时间" prop="startTime">
<el-date-picker
v-model="form.startTime"
value-format="yyyy-MM-dd"
type="month"
placeholder="选择开始时间">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input
@ -240,7 +253,7 @@ export default {
//
multiple: true,
//
showSearch: false,
showSearch: true,
//
total: 0,
//
@ -282,6 +295,9 @@ export default {
rate: [
{ required: true, message: "分成比例不能为空", trigger: "blur" },
],
startTime: [
{ required: true, message: "开始时间不能为空", trigger: "blur" },
],
},
};
},
@ -396,6 +412,7 @@ export default {
userName: null,
amount: null,
rate: null,
startTime: null,
createBy: null,
createTime: null,
updateBy: null,

View File

@ -9,7 +9,7 @@
size="small"
/>
</el-form-item>
<el-form-item label="展示状态" prop="showFlag">
<el-form-item label="小程序展示状态" prop="showFlag" label-width="200">
<el-select
v-model="queryParams.showFlag"
placeholder="请选择展示状态"

View File

@ -1,7 +1,7 @@
<template>
<div class="app-container">
<!--<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="关键词" prop="title">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="关键词" prop="key">
<el-input
v-model="queryParams.key"
placeholder="请输入关键词"
@ -9,22 +9,42 @@
size="small"
/>
</el-form-item>
<el-form-item label="状态" prop="showFlag">
<el-form-item label="小程序展示状态" prop="showFlag" label-width="200">
<el-select
v-model="queryParams.showFlag"
placeholder="请选示状态"
clearable
size="small"
>
<el-option key="0" label="屏蔽" value="0"/>
<el-option key="1" label="正常" value="1"/>
<el-option key="0" label="不展示" value="0"/>
<el-option key="1" label="展示" value="1"/>
</el-select>
</el-form-item>
<el-form-item label="视频类别" prop="cateId">
<el-select v-model="queryParams.cateId" clearable filterable placeholder="请选择类别">
<el-option
v-for="classify in classifyList"
:key="classify.id"
:label="classify.cateName"
:value="classify.id"
/>
</el-select>
</el-form-item>
<el-form-item label="视频权限" prop="payLevel">
<el-select v-model="queryParams.payLevel" clearable filterable placeholder="请选择权限">
<el-option
v-for="dict in payVideoLevelList"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>-->
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
@ -36,7 +56,7 @@
v-hasPermi="['custom:nutritionalVideo:add']"
>视频上传</el-button>
</el-col>
<!--<el-col :span="1.5">
<el-col :span="1.5">
<el-button
type="success"
icon="el-icon-edit"
@ -56,6 +76,7 @@
v-hasPermi="['custom:nutritionalVideo:remove']"
>删除</el-button>
</el-col>
<!--
<el-col :span="1.5">
<el-button
type="warning"
@ -82,15 +103,21 @@
</el-table-column>
<el-table-column label="标题" align="center" prop="title" width="200"/>
<el-table-column label="描述" align="center" prop="description" />
<el-table-column label="标签" align="center" prop="tags" width="100"/>
<!--<el-table-column label="标签" align="center" prop="tags" width="100"/>-->
<el-table-column label="分类" align="center" prop="cateName" width="100"/>
<el-table-column label="权限等级" align="center" prop="payLevelName" width="100"/>
<el-table-column label="显示状态" align="center" prop="showFlag" width="100">
<template slot-scope="scope">
{{scope.row.showFlag == 1 ? '正常' : '不显示'}}
<el-table-column label="小程序展示状态" align="center" prop="showFlag" width="200">
<template slot-scope="scope" >
<el-switch
v-model="scope.row.wxShow"
active-text="展示"
inactive-text="不展示"
@change="handleWxShow($event, scope.row)"
>
</el-switch>
</template>
</el-table-column>
<!--<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" width="200">
<template slot-scope="scope">
<el-button
size="mini"
@ -107,9 +134,11 @@
v-hasPermi="['custom:nutritionalVideo:remove']"
>删除</el-button>
</template>
</el-table-column>-->
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
@ -158,8 +187,8 @@
</template>
<script>
import { listNutritionalVideo, getNutritionalVideo, delNutritionalVideo, addNutritionalVideo, updateNutritionalVideo, exportNutritionalVideo,getUploadVideoAuth } from "@/api/custom/nutritionalVideo";
import { listNutritionalVideo, getNutritionalVideo, delNutritionalVideo, addNutritionalVideo, updateNutritionalVideo, exportNutritionalVideo, updateWxShow } from "@/api/custom/nutritionalVideo";
import {getAllClassify } from "@/api/custom/videoClassify";
import UploadVideo from "@/components/UploadVideo";
export default {
name: "NutritionalVideo",
@ -188,18 +217,32 @@
pageNum: 1,
pageSize: 5,
key: null,
showFlag: null
showFlag: null,
cateId: null,
payLevel: null
},
//
form: {},
//
rules: {
},
coverImageList:[]
coverImageList:[],
//
classifyList:[],
//
payVideoLevelList:[]
};
},
created() {
this.getList();
getAllClassify().then(response => {
if(response.code == 200){
this.classifyList = response.data;
}
});
this.getDicts("video_pay_level").then((response) => {
this.payVideoLevelList = response.data;
});
},
components: {
UploadVideo
@ -209,6 +252,9 @@
getList() {
this.loading = true;
listNutritionalVideo(this.queryParams).then(response => {
response.rows.forEach(element => {
element.wxShow = element.showFlag == 1 ? true : false;
});
this.nutritionalVideoList = response.rows;
this.total = response.total;
this.loading = false;
@ -300,6 +346,13 @@
}
});
},
handleWxShow(newWxshow, row){
let param = {
id: row.id,
showFlag: newWxshow ? 1 : 0
};
updateWxShow(param);
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;