导粉记录页面以及接口修改

This commit is contained in:
xiezhijun 2021-05-21 18:59:26 +08:00
parent 17df1db9e2
commit f913774025
12 changed files with 250 additions and 21 deletions
stdiet-admin/src/main/java/com/stdiet/web/controller/custom
stdiet-custom/src/main
stdiet-ui/src
components/ImportFanRecord/ImportFan
views/custom/importFanRecord

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.stdiet.common.utils.StringUtils;
import com.stdiet.custom.domain.SysImportFanWxAccount;
import com.stdiet.custom.domain.SysWxSaleAccount;
import com.stdiet.custom.service.ISysImportFanWxAccountService;
@ -55,6 +56,12 @@ public class SysImportFanRecordController extends BaseController
{
startPage();
List<SysImportFanRecord> list = sysImportFanRecordService.selectSysImportFanRecordList(sysImportFanRecord);
SysImportFanWxAccount sysImportFanWxAccount = new SysImportFanWxAccount();
if(list != null && list.size() > 0){
//总导粉量
int totalNum = sysImportFanRecordService.selectTotalSysImportFanNum(sysImportFanRecord);
list.get(0).setTotalFanNum(totalNum);
}
return getDataTable(list);
}
@ -89,7 +96,34 @@ public class SysImportFanRecordController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody SysImportFanRecord sysImportFanRecord)
{
return toAjax(sysImportFanRecordService.insertSysImportFanRecord(sysImportFanRecord));
if(sysImportFanRecord.getImportFanDate() == null){
return AjaxResult.error("导入日期不存在");
}
int row = 0;
//批量保存
if(StringUtils.isNotEmpty(sysImportFanRecord.getImportFanChannels() )){
String[] importFanChannelArray = sysImportFanRecord.getImportFanChannels().split(",");
String[] importFanLiveArray = sysImportFanRecord.getImportFanLives().split(",");
String[] wxAccountIdArray = sysImportFanRecord.getWxAccountIds().split(",");
String[] fanNumArray = sysImportFanRecord.getFanNums().split(",");
int index = -1;
for (String importFanChannel : importFanChannelArray) {
index++;
if(StringUtils.isEmpty(importFanChannel)){
continue;
}
sysImportFanRecord.setImportFanChannel(Long.parseLong(importFanChannel));
sysImportFanRecord.setImportFanLive(StringUtils.isEmpty(importFanLiveArray[index]) ? 0L : Long.parseLong(importFanLiveArray[index]));
sysImportFanRecord.setWxAccountId(Long.parseLong(wxAccountIdArray[index]));
sysImportFanRecord.setFanNum(Long.parseLong(fanNumArray[index]));
row = sysImportFanRecordService.insertSysImportFanRecord(sysImportFanRecord);
}
}else{
if(sysImportFanRecord.getImportFanChannel() != null){
row = sysImportFanRecordService.insertSysImportFanRecord(sysImportFanRecord);
}
}
return toAjax(row);
}
/**

@ -52,4 +52,17 @@ public class SysImportFanRecord extends BaseEntity
private String liveNutritionistName;
private List<Map<String,Object>> wxAccountList;
private String importFanChannels;
private String importFanLives;
private String wxAccountIds;
private String fanNums;
//总进粉数量
private Integer totalFanNum;
}

@ -65,4 +65,7 @@ public interface SysImportFanRecordMapper
* @return
*/
public SysImportFanRecord getFanRecordByChannelLive(SysImportFanRecord sysImportFanRecord);
//查询总导粉数量
int selectTotalSysImportFanNum(SysImportFanRecord sysImportFanRecord);
}

@ -74,4 +74,11 @@ public interface SysImportFanWxAccountMapper
* @return
*/
List<Map<String,Object>> getTotalImportFanNum(SysImportFanWxAccount sysImportFanWxAccount);
/**
* 根据记录ID删除对应所有微信
* @param ids
* @return
*/
int deleteSysImportFanWxAccountByFanRecordIds(Long[] ids);
}

@ -58,4 +58,7 @@ public interface ISysImportFanRecordService
* @return 结果
*/
public int deleteSysImportFanRecordById(Long id);
//查询总导粉数量
int selectTotalSysImportFanNum(SysImportFanRecord sysImportFanRecord);
}

@ -74,4 +74,11 @@ public interface ISysImportFanWxAccountService
* @return
*/
List<Map<String,Object>> getTotalImportFanNum(SysImportFanWxAccount sysImportFanWxAccount);
/**
* 根据记录ID删除对应所有微信
* @param ids
* @return
*/
int deleteSysImportFanWxAccountByFanRecordIds(Long[] ids);
}

@ -107,7 +107,11 @@ public class SysImportFanRecordServiceImpl implements ISysImportFanRecordService
@Override
public int deleteSysImportFanRecordByIds(Long[] ids)
{
return sysImportFanRecordMapper.deleteSysImportFanRecordByIds(ids);
int row = sysImportFanRecordMapper.deleteSysImportFanRecordByIds(ids);
if(row > 0){
sysImportFanWxAccountService.deleteSysImportFanWxAccountByFanRecordIds(ids);
}
return row;
}
/**
@ -119,6 +123,16 @@ public class SysImportFanRecordServiceImpl implements ISysImportFanRecordService
@Override
public int deleteSysImportFanRecordById(Long id)
{
return sysImportFanRecordMapper.deleteSysImportFanRecordById(id);
int row = sysImportFanRecordMapper.deleteSysImportFanRecordById(id);
if(row > 0){
Long[] ids = {id};
sysImportFanWxAccountService.deleteSysImportFanWxAccountByFanRecordIds(ids);
}
return row;
}
//查询总导粉数量
public int selectTotalSysImportFanNum(SysImportFanRecord sysImportFanRecord){
return sysImportFanRecordMapper.selectTotalSysImportFanNum(sysImportFanRecord);
}
}

@ -114,4 +114,13 @@ public class SysImportFanWxAccountServiceImpl implements ISysImportFanWxAccountS
public List<Map<String,Object>> getTotalImportFanNum(SysImportFanWxAccount sysImportFanWxAccount){
return sysImportFanWxAccountMapper.getTotalImportFanNum(sysImportFanWxAccount);
}
/**
* 根据记录ID删除对应所有微信
* @param ids
* @return
*/
public int deleteSysImportFanWxAccountByFanRecordIds(Long[] ids){
return sysImportFanWxAccountMapper.deleteSysImportFanWxAccountByFanRecordIds(ids);
}
}

@ -54,7 +54,16 @@
where fc.del_flag = 0
<if test="importFanDate != null "> and fc.import_fan_date = #{importFanDate}</if>
<if test="importFanChannel != null "> and fc.import_fan_channel = #{importFanChannel}</if>
<if test="importFanLive != null "> and fc.import_fan_live = #{importFanLive}</if>
order by fc.import_fan_date desc,fc.import_fan_channel asc
</select>
<select id="selectTotalSysImportFanNum" parameterType="SysImportFanRecord" resultType="int">
select sum(fwa.import_fan_num)
from sys_import_fan_record as fc
left join sys_import_fan_wx_account fwa on fwa.import_fan_record_id = fc.id and fwa.del_flag = 0
where fc.del_flag = 0
<if test="importFanDate != null "> and fc.import_fan_date = #{importFanDate}</if>
<if test="importFanChannel != null "> and fc.import_fan_channel = #{importFanChannel}</if>
</select>
<select id="selectSysImportFanRecordById" parameterType="Long" resultMap="SysImportFanRecordResult">

@ -105,4 +105,12 @@
group by w.import_wx_account_id order by w.import_wx_account_id desc
</select>
<!-- 根据导粉ID删除对应所有微信记录 -->
<update id="deleteSysImportFanWxAccountByFanRecordIds" parameterType="String">
update sys_import_fan_wx_account set del_flag = 1 where import_fan_record_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>

@ -1,6 +1,7 @@
<template>
<!-- -->
<!-- 添加或修改导粉管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1100px" :close-on-click-modal="false" append-to-body>
<el-dialog :title="title" :visible.sync="open" width="1100px" :close-on-click-modal="false" append-to-body @closed="cancel">
<div style="height: 500px; overflow: auto">
<el-table v-loading="loading" :data="wxAccountList">
<!--<el-table-column label="微信昵称" align="center" prop="wxNickName" />-->
@ -15,6 +16,7 @@
clearable
filterable
size="small"
@change="autoSelectLive(scope.row)"
>
<el-option
v-for="dict in fanChanneloptions"
@ -55,17 +57,26 @@
type="text"
@click="addImportFanRecord(scope.row)"
v-hasPermi="['custom:importFanRecord:add']"
>导粉</el-button>
>保存</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div slot="footer" class="dialog-footer">
<el-button
type="primary"
@click="addMuchImport"
v-hasPermi="['custom:importFanRecord:add']"
>全部保存</el-button>
<el-button @click="cancel">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import { addImportFanRecord,getWxAccountAndSale } from "@/api/custom/importFanRecord";
import { getAllLiveSchedulByDate } from "@/api/custom/liveSchedul";
import dayjs from "dayjs";
const nowTime = dayjs().format("YYYY-MM-DD HH:mm");
export default {
name: "ImportFan",
components: {
@ -93,7 +104,9 @@ export default {
//
liveSchedukList:[],
//
fanNumList:[]
fanNumList:[],
//
importFanFlag: false
};
},
created(){
@ -105,6 +118,7 @@ export default {
if(!data || data == undefined || data == null){
return;
}
this.importFanFlag = false;
this.data = data;
this.fanChanneloptions = fanChanneloptions;
this.title = "「"+data.importFanDate+"」微信导粉(只显示可接粉微信号)";
@ -126,6 +140,9 @@ export default {
},
cancel(){
this.open = false;
if(this.importFanFlag){
this.callback && this.callback();
}
this.reset();
},
//
@ -135,6 +152,8 @@ export default {
response.data.wxSaleAccountList.forEach((item,index) => {
item.fanNum = 1;
item.importFanNum = this.getTotalFanNum(response.data.fanNumList, item.id);
item.importFanChannel = null;
item.importFanLive = null;
});
this.wxAccountList = response.data.wxSaleAccountList;
this.fanNumList = response.data.fanNumList;
@ -163,7 +182,7 @@ export default {
},
addImportFanRecord(row){
//
if(row.importFanChannel == undefined || row.importFanChannel == null){
if(row.importFanChannel == undefined || row.importFanChannel == null || row.importFanChannel == ""){
this.$message({
type: 'warning',
message: '进粉渠道不能为空',
@ -171,7 +190,7 @@ export default {
});
return;
}
if(row.fanNum == undefined || row.fanNum == null){
if(row.fanNum == undefined || row.fanNum == null || row.fanNum == ""){
this.$message({
type: 'warning',
message: '进粉数量不能为空',
@ -188,14 +207,86 @@ export default {
}
addImportFanRecord(param).then((response) => {
if(response.code == 200){
this.msgSuccess("导粉成功");
this.msgSuccess("保存成功");
row.importFanChannel = null;
row.fanNum = 1;
row.importFanLive = null;
row.importFanNum += row.fanNum;
row.fanNum = 1;
this.importFanFlag = true;
}
});
},
addMuchImport(){
if(this.wxAccountList == null || this.wxAccountList.length == 0){
this.$message({
type: 'warning',
message: '微信号不存在',
center: true
});
return;
}
let param = {
'importFanDate': this.data.importFanDate,
'importFanChannels': null,
'importFanLives': null,
'wxAccountIds': null,
'fanNums': null
}
this.wxAccountList.forEach((item,index) => {
if(item.importFanChannel != undefined && item.importFanChannel != null && item.importFanChannel != ""){
param.importFanChannels += param.importFanChannels != null ? (","+this.nullToString(item.importFanChannel)) : item.importFanChannel;
param.importFanLives += param.importFanLives != null ? (","+this.nullToString(item.importFanLive)) : item.importFanLive;
param.wxAccountIds += param.wxAccountIds != null ? (","+this.nullToString(item.id)) : item.id;
param.fanNums += param.fanNums != null ? (","+this.nullToString(item.fanNum)) : item.fanNum;
}
if(index == this.wxAccountList.length -1){
if(param.importFanChannels == null){
this.$message({
type: 'warning',
message: '请至少存在一条数据',
center: true
});
}else{
addImportFanRecord(param).then((response) => {
if(response.code == 200){
this.msgSuccess("全部保存成功");
this.importFanFlag = true;
for(let i=0; i < this.wxAccountList.length; i++){
this.wxAccountList[i].importFanLive = null;
this.wxAccountList[i].importFanChannel = null;
this.wxAccountList[i].importFanNum += this.wxAccountList[i].fanNum;
this.wxAccountList[i].fanNum = 1;
//this.$set('wxAccountList', index, item);
}
}
});
}
}
});
},
nullToString(value){
return (value == undefined || value == null || value == "") ? "" : value;
},
autoSelectLive(row){
if(row.importFanLive == undefined || row.importFanLive == null || row.importFanLive == ""){
if(row.importFanChannel == undefined || row.importFanChannel == null || row.importFanChannel == ""){
row.importFanLive = null;
}else{
let now = dayjs();//"2021-05-19 16:42"
//console.log(now.unix());
if(this.liveSchedukList != null){
this.liveSchedukList.forEach((item,index) => {
if(item.fanChannel == row.importFanChannel && now.unix() >= dayjs(item.liveStartTime).unix() && dayjs(item.liveEndTime).unix() >= now.unix()){
row.importFanLive = item.id;
return;
}
if(index == this.liveSchedukList.length - 1){
row.importFanLive = null;
}
});
}
}
}
}
},
};

@ -5,7 +5,7 @@
<el-date-picker clearable size="small" style="width: 200px"
v-model="queryParams.importFanDate"
type="date"
value-format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
placeholder="选择导粉日期">
</el-date-picker>
</el-form-item>
@ -79,6 +79,9 @@
v-hasPermi="['custom:importFanRecord:export']"
>导出</el-button>
</el-col>-->
<el-col :span="1.5">
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -114,15 +117,15 @@
</el-table-column>
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
<!--<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['custom:importFanRecord:edit']"
>修改</el-button>
>修改</el-button>-->
<el-button
size="mini"
type="text"
@ -131,16 +134,37 @@
v-hasPermi="['custom:importFanRecord:remove']"
>删除</el-button>
</template>
</el-table-column>-->
</el-table-column>
</el-table>
<pagination
<!--<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
:layout="'total, slot, sizes, prev, pager, next, jumper'"
@pagination="getList"
<span style="margin-right: 12px"
>总计导粉量{{totalFanNum}}
</span
>
</pagination>-->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
:layout="`${'total, slot, sizes, prev, pager, next, jumper'}`"
@pagination="getList"
/>
>
<span style="margin-right: 12px" v-if="!isMobile"
>总计导粉量{{
totalFanNum
}}
</span
>
</pagination>
<!-- 添加或修改导粉管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
@ -212,7 +236,9 @@ export default {
rules: {
},
//
fanChanneloptions:[]
fanChanneloptions:[],
//
totalFanNum:0
};
},
created() {
@ -229,6 +255,11 @@ export default {
getList() {
this.loading = true;
listImportFanRecord(this.queryParams).then(response => {
if(response.rows != null && response.rows.length > 0){
this.totalFanNum = response.rows[0].totalFanNum;
}else{
this.totalFanNum = 0;
}
this.importFanRecordList = response.rows;
this.total = response.total;
this.loading = false;