From c802d5151f9d16d6fbd2a754013e41737362cc00 Mon Sep 17 00:00:00 2001
From: xiezhijun <15270898033@163.com>
Date: Tue, 18 May 2021 18:49:20 +0800
Subject: [PATCH 1/5] =?UTF-8?q?=E5=AF=BC=E7=B2=89=E8=AE=B0=E5=BD=95?=
 =?UTF-8?q?=E9=83=A8=E5=88=86=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../custom/SysImportFanRecordController.java  |  17 +
 .../custom/domain/SysWxSaleAccount.java       |   3 +
 .../custom/mapper/SysWxSaleAccountMapper.java |   7 +
 .../service/ISysWxSaleAccountService.java     |   7 +
 .../impl/SysCommissionDayServiceImpl.java     |   2 +-
 .../impl/SysWxSaleAccountServiceImpl.java     |   9 +
 .../mapper/custom/SysWxSaleAccountMapper.xml  |  15 +
 stdiet-ui/src/api/custom/importFanRecord.js   |  61 ++++
 .../ImportFanRecord/ImportFan/index.vue       | 120 +++++++
 .../views/custom/importFanRecord/index.vue    | 336 ++++++++++++++++++
 10 files changed, 576 insertions(+), 1 deletion(-)
 create mode 100644 stdiet-ui/src/api/custom/importFanRecord.js
 create mode 100644 stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
 create mode 100644 stdiet-ui/src/views/custom/importFanRecord/index.vue

diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java
index e5add9b71..8d151231f 100644
--- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java
+++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java
@@ -1,6 +1,9 @@
 package com.stdiet.web.controller.custom;
 
 import java.util.List;
+
+import com.stdiet.custom.domain.SysWxSaleAccount;
+import com.stdiet.custom.service.ISysWxSaleAccountService;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -33,6 +36,9 @@ public class SysImportFanRecordController extends BaseController
     @Autowired
     private ISysImportFanRecordService sysImportFanRecordService;
 
+    @Autowired
+    private ISysWxSaleAccountService sysWxSaleAccountService;
+
     /**
      * 查询导粉管理列表
      */
@@ -100,4 +106,15 @@ public class SysImportFanRecordController extends BaseController
     {
         return toAjax(sysImportFanRecordService.deleteSysImportFanRecordByIds(ids));
     }
+
+    /**
+     * 获取可接粉的微信号以及对应销售
+     * @param sysWxSaleAccount
+     * @return
+     */
+    @PreAuthorize("@ss.hasPermi('custom:importFanRecord:add')")
+    @GetMapping(value = "/getWxAccountAndSale")
+    public TableDataInfo getWxAccountAndSale(SysWxSaleAccount sysWxSaleAccount){
+        return getDataTable(sysWxSaleAccountService.getWxAccountAndSale(sysWxSaleAccount));
+    }
 }
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysWxSaleAccount.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysWxSaleAccount.java
index 910ad7eaa..feabbfa5b 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysWxSaleAccount.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysWxSaleAccount.java
@@ -44,4 +44,7 @@ public class SysWxSaleAccount extends BaseEntity
     private Integer status;
 
     private Integer useCount;
+
+    //销售昵称
+    private String saleName;
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxSaleAccountMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxSaleAccountMapper.java
index 7835353f0..0901b5a37 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxSaleAccountMapper.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxSaleAccountMapper.java
@@ -71,4 +71,11 @@ public interface SysWxSaleAccountMapper
     SysWxSaleAccount selectWxAdId();
 
     int insertWxAdLog(SysWxAdLog sysWxAdLog);
+
+    /**
+     * 获取可接粉的微信号以及分配的销售昵称
+     * @param sysWxSaleAccount
+     * @return
+     */
+    List<SysWxSaleAccount> getWxAccountAndSale(SysWxSaleAccount sysWxSaleAccount);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxSaleAccountService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxSaleAccountService.java
index 88a4d16fd..5763bf238 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxSaleAccountService.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxSaleAccountService.java
@@ -72,4 +72,11 @@ public interface ISysWxSaleAccountService
     String getWxAdId(SysWxAdLog sysWxAdLog);
 
     Integer logWxAd(SysWxAdLog sysWxAdLog);
+
+    /**
+     * 获取可接粉的微信号以及分配的销售昵称
+     * @param sysWxSaleAccount
+     * @return
+     */
+    List<SysWxSaleAccount> getWxAccountAndSale(SysWxSaleAccount sysWxSaleAccount);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCommissionDayServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCommissionDayServiceImpl.java
index 90aa114ef..be05d3a8c 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCommissionDayServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCommissionDayServiceImpl.java
@@ -33,7 +33,7 @@ public class SysCommissionDayServiceImpl implements ISysCommissionDayService {
     private SysOrderMapper sysOrderMapper;
 
     @Autowired
-    private SysOrderPauseMapper sysOrderPauseMapper;
+    private SysOrderPauseMapper sysOrderPauseMapper    ;
 
     @Autowired
     private ISysOrderNutritionistReplaceRecordService sysOrderNutritionistReplaceRecordService;
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxSaleAccountServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxSaleAccountServiceImpl.java
index e060d7a45..0374d66db 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxSaleAccountServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxSaleAccountServiceImpl.java
@@ -128,4 +128,13 @@ public class SysWxSaleAccountServiceImpl implements ISysWxSaleAccountService {
     public Integer logWxAd(SysWxAdLog sysWxAdLog) {
         return sysWxSaleAccountMapper.insertWxAdLog(sysWxAdLog);
     }
+
+    /**
+     * 获取可接粉的微信号以及分配的销售昵称
+     * @param sysWxSaleAccount
+     * @return
+     */
+    public List<SysWxSaleAccount> getWxAccountAndSale(SysWxSaleAccount sysWxSaleAccount){
+        return sysWxSaleAccountMapper.getWxAccountAndSale(sysWxSaleAccount);
+    }
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml
index a5ceceaad..e8f32eb8b 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml
@@ -19,6 +19,9 @@
         <result property="delFlag" column="del_flag"/>
         <result property="status" column="status"/>
         <result property="useCount" column="use_count"/>
+
+        <!-- 销售 -->
+        <result property="saleName" column="sale_name"></result>
     </resultMap>
 
     <sql id="selectSysWxSaleAccountVo">
@@ -31,6 +34,7 @@
         <if test="wxNickName != null  and wxNickName != ''">and wx_nick_name like concat('%', #{wxNickName}, '%')</if>
         <if test="wxAccount != null  and wxAccount != ''">and wx_account like concat('%', #{wxAccount}, '%')</if>
         <if test="wxPhone != null  and wxPhone != ''">and wx_phone like concat('%', #{wxPhone}, '%')</if>
+        <if test="status != null">and status = #{status}</if>
         order by id desc
     </select>
 
@@ -134,4 +138,15 @@
         </trim>
     </insert>
 
+    <!-- 查询可以接粉的微信号以及对应销售,用于导粉记录管理 -->
+    <select id="getWxAccountAndSale" parameterType="SysWxSaleAccount" resultMap="SysWxSaleAccountResult">
+        select wa.id, wa.wx_account, su.nick_name as sale_name
+        from sys_wx_sale_account wa
+        left join sys_wx_distribution swd on wa.id = swd.wechat_account and swd.del_flag = 0
+        LEFT JOIN sys_user su ON su.user_id = swd.user_id AND su.del_flag = 0
+        where wa.del_flag = 0 and wa.status = 0
+        <if test="wxAccount != null  and wxAccount != ''">and wa.wx_account like concat('%', #{wxAccount}, '%')</if>
+        order by wa.id desc
+    </select>
+
 </mapper>
\ No newline at end of file
diff --git a/stdiet-ui/src/api/custom/importFanRecord.js b/stdiet-ui/src/api/custom/importFanRecord.js
new file mode 100644
index 000000000..68922e69b
--- /dev/null
+++ b/stdiet-ui/src/api/custom/importFanRecord.js
@@ -0,0 +1,61 @@
+import request from '@/utils/request'
+
+// 查询导粉管理列表
+export function listImportFanRecord(query) {
+  return request({
+    url: '/custom/importFanRecord/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询导粉管理详细
+export function getImportFanRecord(id) {
+  return request({
+    url: '/custom/importFanRecord/' + id,
+    method: 'get'
+  })
+}
+
+// 新增导粉管理
+export function addImportFanRecord(data) {
+  return request({
+    url: '/custom/importFanRecord',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改导粉管理
+export function updateImportFanRecord(data) {
+  return request({
+    url: '/custom/importFanRecord',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除导粉管理
+export function delImportFanRecord(id) {
+  return request({
+    url: '/custom/importFanRecord/' + id,
+    method: 'delete'
+  })
+}
+
+// 导出导粉管理
+export function exportImportFanRecord(query) {
+  return request({
+    url: '/custom/importFanRecord/export',
+    method: 'get',
+    params: query
+  })
+}
+
+export function getWxAccountAndSale(query){
+    return request({
+        url: '/custom/importFanRecord/getWxAccountAndSale',
+        method: 'get',
+        params: query
+      })
+}
\ No newline at end of file
diff --git a/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue b/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
new file mode 100644
index 000000000..eb5a9c28c
--- /dev/null
+++ b/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
@@ -0,0 +1,120 @@
+<template>
+    <!-- 添加或修改导粉管理对话框 -->
+    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
+        <div style="height: 500px; overflow: auto">
+            <el-table v-loading="loading" :data="wxAccountList">
+                <!--<el-table-column label="微信昵称" align="center" prop="wxNickName" />-->
+                <el-table-column label="微信号" align="center" prop="wxAccount" width="120"/>
+                <el-table-column label="销售" align="center" prop="saleName" width="120"/>
+                <el-table-column label="已导粉数量" align="center" prop="importFanNum" width="120"/>
+                <el-table-column label="进粉渠道" align="center" prop="fanChannel" >
+                    <template slot-scope="scope">
+                            <el-select
+                        v-model="scope.row.fanChannel"
+                        placeholder="请选择账号渠道"
+                        clearable
+                        filterable
+                        size="small"
+                        >
+                        <el-option
+                            v-for="dict in fanChanneloptions"
+                            :key="dict.dictValue"
+                            :label="dict.dictLabel"
+                            :value="parseInt(dict.dictValue)"
+                        />
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column label="导粉数量" align="center" prop="fanNum" width="200">
+                    <template slot-scope="scope">
+                            <el-input-number v-model="scope.row.fanNum" :min="1" :max="10000" label="导粉数量" style="width:160px"></el-input-number>
+                    </template>
+                </el-table-column>
+                <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+                    <template slot-scope="scope">
+                    <el-button
+                        size="mini"
+                        type="text"
+                        icon="el-icon-edit"
+                        @click="handleUpdate(scope.row)"
+                        v-hasPermi="['custom:importFanRecord:add']"
+                    >导粉</el-button>
+                    </template>
+                </el-table-column>
+            </el-table>
+        </div>
+       
+    </el-dialog>
+</template>
+<script>
+import { addImportFanRecord,getWxAccountAndSale } from "@/api/custom/importFanRecord";
+export default {
+  name: "ImportFan",
+  components: {
+      
+  },
+  data() {
+    return {
+        // 遮罩层
+      loading: true,
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 表单校验
+      rules: {
+        title: [
+          { required: true, message: "标题不能为空", trigger: "blur" },
+        ]
+      },
+      data: null,
+      callback: null,
+      //可接粉的微信号
+      wxAccountList:[],
+      fanChanneloptions:[]
+    };
+  },
+  created(){
+        
+  },
+  methods: {
+    showDialog(data, callback, fanChanneloptions) {
+      if(!data || data == undefined || data == null){
+          return;
+      }
+      this.fanChanneloptions = fanChanneloptions;
+      this.title = "「"+data.importFanDate+"」微信导粉(只显示可接粉微信号)";
+      this.reset();
+      this.callback = callback;
+      this.getListWxAccount();
+      this.open = true;
+    },
+    reset(){
+       
+    },
+    /** 提交按钮 */
+    submitForm() {
+       
+    },
+    onClosed() {
+      this.reset();
+    },
+    cancel(){
+        this.open = false;
+        this.reset();
+    },
+    //获取所有可接粉的微信号
+    getListWxAccount() {
+        this.loading = true;
+        getWxAccountAndSale().then((response) => {
+            this.wxAccountList = response.rows;
+            this.loading = false;
+        });
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+
+</style>
diff --git a/stdiet-ui/src/views/custom/importFanRecord/index.vue b/stdiet-ui/src/views/custom/importFanRecord/index.vue
new file mode 100644
index 000000000..fade5a25f
--- /dev/null
+++ b/stdiet-ui/src/views/custom/importFanRecord/index.vue
@@ -0,0 +1,336 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="导粉日期" prop="importFanDate">
+        <el-date-picker clearable size="small" style="width: 200px"
+          v-model="queryParams.importFanDate"
+          type="date"
+          value-format="yyyy-MM-dd"
+          placeholder="选择导粉日期">
+        </el-date-picker>
+      </el-form-item>
+      <el-form-item label="账号渠道" prop="importFanChannel">
+          <el-select
+              v-model="queryParams.importFanChannel"
+              placeholder="请选择账号渠道"
+              clearable
+              filterable
+              size="small"
+            >
+              <el-option
+                v-for="dict in fanChanneloptions"
+                :key="dict.dictValue"
+                :label="dict.dictLabel"
+                :value="parseInt(dict.dictValue)"
+              />
+            </el-select>
+        </el-form-item>
+      <!--<el-form-item label="进粉直播间" prop="importFanLive">
+        <el-input
+          v-model="queryParams.importFanLive"
+          placeholder="请输入进粉直播间"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </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-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          size="mini"
+          @click="showDialog(null)"
+          v-hasPermi="['custom:importFanRecord:add']"
+        >新增</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="success"
+          icon="el-icon-edit"
+          size="mini"
+          :disabled="single"
+          @click="handleUpdate"
+          v-hasPermi="['custom:importFanRecord:edit']"
+        >修改</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['custom:importFanRecord:remove']"
+        >删除</el-button>
+      </el-col>
+      <!--<el-col :span="1.5">
+        <el-button
+          type="warning"
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExport"
+          v-hasPermi="['custom:importFanRecord:export']"
+        >导出</el-button>
+      </el-col>-->
+	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="importFanRecordList" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="导粉日期" align="center" prop="importFanDate" width="180">
+        <template slot-scope="scope">
+          <span>{{ parseTime(scope.row.importFanDate, '{y}-{m}-{d}') }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="导粉渠道" align="center" prop="importFanChannel" />
+      <!--<el-table-column label="进粉直播间" align="center" prop="importFanLive" />-->
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['custom:importFanRecord:edit']"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['custom:importFanRecord:remove']"
+          >删除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <!-- 添加或修改导粉管理对话框 -->
+    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="导粉日期" prop="importFanDate">
+          <el-date-picker clearable size="small" style="width: 200px"
+            v-model="form.importFanDate"
+            type="date"
+            value-format="yyyy-MM-dd"
+            placeholder="选择导粉日期">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="导粉渠道" prop="importFanChannel">
+          <el-input v-model="form.importFanChannel" placeholder="请输入导粉渠道" />
+        </el-form-item>
+        <el-form-item label="进粉直播间" prop="importFanLive">
+          <el-input v-model="form.importFanLive" placeholder="请输入进粉直播间" />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+
+    <ImportFan ref="importFanRef"></ImportFan>
+  </div>
+</template>
+
+<script>
+import { listImportFanRecord, getImportFanRecord, delImportFanRecord, addImportFanRecord, updateImportFanRecord, exportImportFanRecord } from "@/api/custom/importFanRecord";
+import ImportFan from "@/components/ImportFanRecord/ImportFan";
+import dayjs from "dayjs";
+const nowDate = dayjs().format("YYYY-MM-DD");
+const nowTime = dayjs().format("YYYY-MM-DD HH:mm");
+export default {
+  name: "ImportFanRecord",
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 导粉管理表格数据
+      importFanRecordList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        importFanDate: nowDate,
+        importFanChannel: null,
+        importFanLive: null,
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+      },
+      //导粉账号渠道
+      fanChanneloptions:[]
+    };
+  },
+  created() {
+    this.getList();
+    this.getDicts("cus_account").then((response) => {
+      this.fanChanneloptions = response.data;
+    });
+  },
+  components:{
+      ImportFan
+  },
+  methods: {
+    /** 查询导粉管理列表 */
+    getList() {
+      this.loading = true;
+      listImportFanRecord(this.queryParams).then(response => {
+        this.importFanRecordList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        id: null,
+        importFanDate: null,
+        importFanChannel: null,
+        importFanLive: null,
+        createTime: null,
+        createBy: null,
+        updateTime: null,
+        updateBy: null,
+        delFlag: null
+      };
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.id)
+      this.single = selection.length!==1
+      this.multiple = !selection.length
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.title = "添加导粉管理";
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.reset();
+      const id = row.id || this.ids
+      getImportFanRecord(id).then(response => {
+        this.form = response.data;
+        this.open = true;
+        this.title = "修改导粉管理";
+      });
+    },
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          if (this.form.id != null) {
+            updateImportFanRecord(this.form).then(response => {
+              if (response.code === 200) {
+                this.msgSuccess("修改成功");
+                this.open = false;
+                this.getList();
+              }
+            });
+          } else {
+            addImportFanRecord(this.form).then(response => {
+              if (response.code === 200) {
+                this.msgSuccess("新增成功");
+                this.open = false;
+                this.getList();
+              }
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const ids = row.id || this.ids;
+      this.$confirm('是否确认删除导粉管理编号为"' + ids + '"的数据项?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(function() {
+          return delImportFanRecord(ids);
+        }).then(() => {
+          this.getList();
+          this.msgSuccess("删除成功");
+        }).catch(function() {});
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      const queryParams = this.queryParams;
+      this.$confirm('是否确认导出所有导粉管理数据项?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(function() {
+          return exportImportFanRecord(queryParams);
+        }).then(response => {
+          this.download(response.msg);
+        }).catch(function() {});
+    },
+    showDialog(data){
+        if(this.queryParams.importFanDate == undefined || this.queryParams.importFanDate == null){
+            this.$message({
+                type: 'warning',
+                message: '导粉日期不能为空',
+                center: true
+            });
+            return;
+        }
+        if(data == null){
+            data = {};
+        }
+        data.importFanDate = this.queryParams.importFanDate;
+        this.$refs.importFanRef.showDialog(data,()=>{
+            this.getList();
+        }, this.fanChanneloptions);
+    }
+  }
+};
+</script>
\ No newline at end of file

From 574c8b424e147d786c06df877d964e07ec580999 Mon Sep 17 00:00:00 2001
From: xiezhijun <15270898033@163.com>
Date: Wed, 19 May 2021 19:18:18 +0800
Subject: [PATCH 2/5] =?UTF-8?q?=E5=AF=BC=E7=B2=89=E7=BB=9F=E8=AE=A1?=
 =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E5=AE=A2=E6=88=B7=E6=89=8B=E6=9C=BA?=
 =?UTF-8?q?=E5=8F=B7=E6=97=B6=E6=9B=B4=E6=96=B0=E4=B8=8B=E5=BE=AE=E4=BF=A1?=
 =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=AF=B9=E5=BA=94=E7=9A=84=E5=AE=A2=E6=88=B7?=
 =?UTF-8?q?ID?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../custom/SysLiveSchedulController.java      |  9 ++
 .../custom/domain/SysImportFanRecord.java     | 19 +++++
 .../mapper/SysImportFanRecordMapper.java      |  7 ++
 .../mapper/SysImportFanWxAccountMapper.java   |  7 ++
 .../custom/mapper/SysWxUserInfoMapper.java    |  8 ++
 .../ISysImportFanWxAccountService.java        |  7 ++
 .../custom/service/ISysWxUserInfoService.java |  7 ++
 .../impl/SysCustomerHealthyServiceImpl.java   |  5 +-
 .../service/impl/SysCustomerServiceImpl.java  | 32 ++++++-
 .../impl/SysImportFanRecordServiceImpl.java   | 30 ++++++-
 .../SysImportFanWxAccountServiceImpl.java     |  9 ++
 .../impl/SysWxUserInfoServiceImpl.java        |  9 ++
 .../custom/SysImportFanRecordMapper.xml       | 57 +++++++++++--
 .../custom/SysImportFanWxAccountMapper.xml    |  5 ++
 .../mapper/custom/SysWxUserInfoMapper.xml     |  6 ++
 stdiet-ui/src/api/custom/liveSchedul.js       | 10 +++
 .../ImportFanRecord/ImportFan/index.vue       | 84 +++++++++++++++++--
 .../views/custom/importFanRecord/index.vue    |  8 +-
 18 files changed, 299 insertions(+), 20 deletions(-)

diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java
index 09a427db4..dff6fa13f 100644
--- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java
+++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysLiveSchedulController.java
@@ -233,4 +233,13 @@ public class SysLiveSchedulController extends BaseController
     public AjaxResult copyLastTimeLiveSchedul(){
         return sysLiveSchedulService.copyLastTimeLiveSchedul();
     }
+
+    /**
+     * 根据日期查询直播记录
+     */
+    @GetMapping(value = "/getAllLiveSchedulByDate")
+    public AjaxResult getAllLiveSchedulByDate(SysLiveSchedul sysLiveSchedul){
+        List<SysLiveSchedul> list = sysLiveSchedulService.selectSysLiveSchedulList(sysLiveSchedul);
+        return AjaxResult.success(list);
+    }
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysImportFanRecord.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysImportFanRecord.java
index cb51a6d31..7c9222937 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysImportFanRecord.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysImportFanRecord.java
@@ -1,9 +1,13 @@
 package com.stdiet.custom.domain;
 
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.stdiet.common.annotation.Excel;
 import com.stdiet.common.core.domain.BaseEntity;
+import lombok.Data;
 
 /**
  * 导粉管理对象 sys_import_fan_record
@@ -11,6 +15,7 @@ import com.stdiet.common.core.domain.BaseEntity;
  * @author xzj
  * @date 2021-05-17
  */
+@Data
 public class SysImportFanRecord extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -33,4 +38,18 @@ public class SysImportFanRecord extends BaseEntity
 
     /** 删除标识,0未删除 1已删除 */
     private Long delFlag;
+
+    //微信ID
+    private Long wxAccountId;
+
+    //进粉数量
+    private Long fanNum;
+
+    private String importFanChannelName;
+
+    private String liveRoomName;
+
+    private String liveNutritionistName;
+
+    private List<Map<String,Object>> wxAccountList;
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanRecordMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanRecordMapper.java
index 6b1c809a2..eb430d355 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanRecordMapper.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanRecordMapper.java
@@ -58,4 +58,11 @@ public interface SysImportFanRecordMapper
      * @return 结果
      */
     public int deleteSysImportFanRecordByIds(Long[] ids);
+
+    /**
+     * 根据日期渠道、直播间获取进粉记录
+     * @param sysImportFanRecord
+     * @return
+     */
+    public SysImportFanRecord getFanRecordByChannelLive(SysImportFanRecord sysImportFanRecord);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanWxAccountMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanWxAccountMapper.java
index cce3cd805..0d441f291 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanWxAccountMapper.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanWxAccountMapper.java
@@ -58,4 +58,11 @@ public interface SysImportFanWxAccountMapper
      * @return 结果
      */
     public int deleteSysImportFanWxAccountByIds(Long[] ids);
+
+    /**
+     * 根据导粉记录ID、微信ID查询对应微信记录
+     * @param sysImportFanWxAccount
+     * @return
+     */
+    public SysImportFanWxAccount getWxAccountByFanRecordId(SysImportFanWxAccount sysImportFanWxAccount);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxUserInfoMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxUserInfoMapper.java
index 7081917fb..724fa532a 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxUserInfoMapper.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxUserInfoMapper.java
@@ -2,6 +2,7 @@ package com.stdiet.custom.mapper;
 
 import java.util.List;
 import com.stdiet.custom.domain.SysWxUserInfo;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 微信用户Mapper接口
@@ -62,4 +63,11 @@ public interface SysWxUserInfoMapper
      * @return 结果
      */
     public int deleteSysWxUserInfoByIds(String[] openids);
+
+    /**
+     * 根据手机号查询微信用户
+     * @param phone
+     * @return
+     */
+    public SysWxUserInfo getSysWxUserInfoByPhone(@Param("phone")String phone);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanWxAccountService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanWxAccountService.java
index 435c2a990..1b0a3f36c 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanWxAccountService.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanWxAccountService.java
@@ -58,4 +58,11 @@ public interface ISysImportFanWxAccountService
      * @return 结果
      */
     public int deleteSysImportFanWxAccountById(Long id);
+
+    /**
+     * 根据导粉记录ID、微信ID查询对应微信记录
+     * @param sysImportFanWxAccount
+     * @return
+     */
+    public SysImportFanWxAccount getWxAccountByFanRecordId(SysImportFanWxAccount sysImportFanWxAccount);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxUserInfoService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxUserInfoService.java
index 3dc8acb61..f009113f0 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxUserInfoService.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxUserInfoService.java
@@ -63,5 +63,12 @@ public interface ISysWxUserInfoService
      */
     public int deleteSysWxUserInfoById(String openid);
 
+    /**
+     * 根据手机号查询微信用户
+     * @param phone
+     * @return
+     */
+    public SysWxUserInfo getSysWxUserInfoByPhone(String phone);
+
 
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerHealthyServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerHealthyServiceImpl.java
index 8170cd5db..123a546d7 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerHealthyServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerHealthyServiceImpl.java
@@ -14,6 +14,7 @@ import com.stdiet.custom.domain.SysCustomer;
 import com.stdiet.custom.domain.SysCustomerPhysicalSigns;
 import com.stdiet.custom.dto.request.HealthyDetailRequest;
 import com.stdiet.custom.dto.response.NutritionalCalories;
+import com.stdiet.custom.mapper.SysCustomerMapper;
 import com.stdiet.custom.service.ISysCustomerService;
 import com.stdiet.custom.utils.NutritionalUtils;
 import com.stdiet.custom.utils.PdfUtils;
@@ -36,7 +37,7 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService
     private SysCustomerHealthyMapper sysCustomerHealthyMapper;
 
     @Autowired
-    private ISysCustomerService sysCustomerService;
+    private SysCustomerMapper sysCustomerMapper;
 
     public static final String reportDownFileNameFormat = "%s超重%s斤%s";
 
@@ -78,7 +79,7 @@ public class SysCustomerHealthyServiceImpl implements ISysCustomerHealthyService
             return AjaxResult.error("客户不存在");
         }
         //判断客户是否存在
-        SysCustomer sysCustomer = sysCustomerService.selectSysCustomerById(Long.parseLong(customerId));
+        SysCustomer sysCustomer = sysCustomerMapper.selectSysCustomerById(Long.parseLong(customerId));
         if(sysCustomer == null){
             return AjaxResult.error("客户不存在");
         }
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerServiceImpl.java
index eb3851d4c..3bc9a37d9 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerServiceImpl.java
@@ -6,10 +6,14 @@ import com.stdiet.common.utils.sign.AesUtils;
 import com.stdiet.custom.domain.SysCustomer;
 import com.stdiet.custom.domain.SysCustomerHealthy;
 import com.stdiet.custom.domain.SysCustomerPhysicalSigns;
+import com.stdiet.custom.domain.SysWxUserInfo;
 import com.stdiet.custom.mapper.SysCustomerMapper;
 import com.stdiet.custom.mapper.SysCustomerPhysicalSignsMapper;
+import com.stdiet.custom.mapper.SysWxUserInfoMapper;
 import com.stdiet.custom.service.ISysCustomerService;
+import com.stdiet.custom.service.ISysWxUserInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -38,6 +42,9 @@ public class SysCustomerServiceImpl implements ISysCustomerService {
     @Autowired
     private SysCustomerPhysicalSignsServiceImpl sysCustomerPhysicalSignsService;
 
+    @Autowired
+    private ISysWxUserInfoService sysWxUserInfoService;
+
     /**
      * 查询客户信息
      *
@@ -69,7 +76,11 @@ public class SysCustomerServiceImpl implements ISysCustomerService {
     @Override
     public int insertSysCustomer(SysCustomer sysCustomer) {
         sysCustomer.setCreateTime(DateUtils.getNowDate());
-        return sysCustomerMapper.insertSysCustomer(sysCustomer);
+        int row = sysCustomerMapper.insertSysCustomer(sysCustomer);
+        if(row > 0){
+            updateWxInfoMessage(sysCustomer);
+        }
+        return row;
     }
 
     /**
@@ -81,7 +92,11 @@ public class SysCustomerServiceImpl implements ISysCustomerService {
     @Override
     public int updateSysCustomer(SysCustomer sysCustomer) {
         sysCustomer.setUpdateTime(DateUtils.getNowDate());
-        return sysCustomerMapper.updateSysCustomer(sysCustomer);
+        int row = sysCustomerMapper.updateSysCustomer(sysCustomer);
+        if(row > 0){
+            updateWxInfoMessage(sysCustomer);
+        }
+        return row;
     }
 
     /**
@@ -177,4 +192,17 @@ public class SysCustomerServiceImpl implements ISysCustomerService {
     public SysCustomer getCustomerByOpenId(String openid){
         return sysCustomerMapper.getCustomerByOpenId(openid);
     }
+
+    @Async
+    public void updateWxInfoMessage(SysCustomer newCustomer){
+        if(newCustomer == null || newCustomer.getId() == null || StringUtils.isEmpty(newCustomer.getPhone())){
+            return;
+        }
+        //根据手机号查询微信用户记录
+        SysWxUserInfo wxUserInfo = sysWxUserInfoService.getSysWxUserInfoByPhone(newCustomer.getPhone());
+        if(wxUserInfo != null && (wxUserInfo.getCusId() == null || wxUserInfo.getCusId().longValue() != newCustomer.getId())){
+            wxUserInfo.setCusId(newCustomer.getId());
+            sysWxUserInfoService.updateSysWxUserInfo(wxUserInfo);
+        }
+    }
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanRecordServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanRecordServiceImpl.java
index 4c034568a..8ccb0d8e8 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanRecordServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanRecordServiceImpl.java
@@ -1,7 +1,10 @@
 package com.stdiet.custom.service.impl;
 
+import java.util.Date;
 import java.util.List;
 import com.stdiet.common.utils.DateUtils;
+import com.stdiet.custom.domain.SysImportFanWxAccount;
+import com.stdiet.custom.service.ISysImportFanWxAccountService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.stdiet.custom.mapper.SysImportFanRecordMapper;
@@ -20,6 +23,9 @@ public class SysImportFanRecordServiceImpl implements ISysImportFanRecordService
     @Autowired
     private SysImportFanRecordMapper sysImportFanRecordMapper;
 
+    @Autowired
+    private ISysImportFanWxAccountService sysImportFanWxAccountService;
+
     /**
      * 查询导粉管理
      *
@@ -54,7 +60,29 @@ public class SysImportFanRecordServiceImpl implements ISysImportFanRecordService
     public int insertSysImportFanRecord(SysImportFanRecord sysImportFanRecord)
     {
         sysImportFanRecord.setCreateTime(DateUtils.getNowDate());
-        return sysImportFanRecordMapper.insertSysImportFanRecord(sysImportFanRecord);
+        //根据账号渠道、直播间判断是否已存在该渠道的导粉记录
+        SysImportFanRecord record = sysImportFanRecordMapper.getFanRecordByChannelLive(sysImportFanRecord);
+        int row = 0;
+        if(record == null){
+            row = sysImportFanRecordMapper.insertSysImportFanRecord(sysImportFanRecord);
+        }
+        if(record != null || row > 0){
+            //添加微信号对应记录
+            SysImportFanWxAccount sysImportFanWxAccount = new SysImportFanWxAccount();
+            sysImportFanWxAccount.setImportFanRecordId(record != null ? record.getId() : sysImportFanRecord.getId());
+            sysImportFanWxAccount.setImportWxAccountId(sysImportFanRecord.getWxAccountId());
+            sysImportFanWxAccount.setImportFanNum(sysImportFanRecord.getFanNum());
+            sysImportFanWxAccount.setCreateTime(new Date());
+            //根据微信号、导粉记录查询是否存在
+            SysImportFanWxAccount oldFanWxAccount = sysImportFanWxAccountService.getWxAccountByFanRecordId(sysImportFanWxAccount);
+            if(oldFanWxAccount == null){
+                row = sysImportFanWxAccountService.insertSysImportFanWxAccount(sysImportFanWxAccount);
+            }else{
+                oldFanWxAccount.setImportFanNum((oldFanWxAccount.getImportFanNum() == null ? 0 : oldFanWxAccount.getImportFanNum()) + sysImportFanWxAccount.getImportFanNum());
+                row = sysImportFanWxAccountService.updateSysImportFanWxAccount(oldFanWxAccount);
+            }
+        }
+        return row;
     }
 
     /**
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanWxAccountServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanWxAccountServiceImpl.java
index 23741a849..44e904a99 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanWxAccountServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanWxAccountServiceImpl.java
@@ -93,4 +93,13 @@ public class SysImportFanWxAccountServiceImpl implements ISysImportFanWxAccountS
     {
         return sysImportFanWxAccountMapper.deleteSysImportFanWxAccountById(id);
     }
+
+    /**
+     * 根据导粉记录ID、微信ID查询对应微信记录
+     * @param sysImportFanWxAccount
+     * @return
+     */
+    public SysImportFanWxAccount getWxAccountByFanRecordId(SysImportFanWxAccount sysImportFanWxAccount){
+        return sysImportFanWxAccountMapper.getWxAccountByFanRecordId(sysImportFanWxAccount);
+    }
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxUserInfoServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxUserInfoServiceImpl.java
index 94f1ffb95..bef991ad0 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxUserInfoServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxUserInfoServiceImpl.java
@@ -97,4 +97,13 @@ public class SysWxUserInfoServiceImpl implements ISysWxUserInfoService {
     public int deleteSysWxUserInfoById(String openid) {
         return sysWxUserInfoMapper.deleteSysWxUserInfoById(openid);
     }
+
+    /**
+     * 根据手机号查询微信用户
+     * @param phone
+     * @return
+     */
+    public SysWxUserInfo getSysWxUserInfoByPhone(String phone){
+        return sysWxUserInfoMapper.getSysWxUserInfoByPhone(phone);
+    }
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml
index 83e5fa780..b99b2fd55 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml
@@ -14,18 +14,47 @@
         <result property="updateTime"    column="update_time"    />
         <result property="updateBy"    column="update_by"    />
         <result property="delFlag"    column="del_flag"    />
+
+        <result property="importFanChannelName" column="import_fan_channel_name"></result>
+        <result property="liveRoomName" column="live_room_name"></result>
+        <result property="liveNutritionistName" column="live_nutritionist_name"></result>
+    </resultMap>
+
+    <resultMap type="SysImportFanRecord" id="SysImportFanRecordResultExtended">
+        <result property="id"    column="id"    />
+        <result property="importFanDate"    column="import_fan_date"    />
+        <result property="importFanChannel"    column="import_fan_channel"    />
+        <result property="importFanLive"    column="import_fan_live"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="delFlag"    column="del_flag"    />
+
+        <result property="importFanChannelName" column="import_fan_channel_name"></result>
+        <result property="liveRoomName" column="live_room_name"></result>
+        <result property="liveNutritionistName" column="live_nutritionist_name"></result>
+
+        <!-- 查询该渠道已导粉的微信号 -->
+        <association property="wxAccountList" column="id" select="getWxAccountListByFanRecordId"/>
     </resultMap>
 
     <sql id="selectSysImportFanRecordVo">
         select id, import_fan_date, import_fan_channel, import_fan_live, create_time, create_by, update_time, update_by, del_flag from sys_import_fan_record
     </sql>
 
-    <select id="selectSysImportFanRecordList" parameterType="SysImportFanRecord" resultMap="SysImportFanRecordResult">
-        <include refid="selectSysImportFanRecordVo"/>
-        where del_flag = 0
-        <if test="importFanDate != null "> and import_fan_date = #{importFanDate}</if>
-        <if test="importFanChannel != null "> and import_fan_channel = #{importFanChannel}</if>
-        <if test="importFanLive != null "> and import_fan_live = #{importFanLive}</if>
+    <select id="selectSysImportFanRecordList" parameterType="SysImportFanRecord" resultMap="SysImportFanRecordResultExtended">
+        select fc.id, fc.import_fan_date, fc.import_fan_channel, fc.import_fan_live, fc.create_time,
+        ca.dict_label as import_fan_channel_name, slt.dict_label as live_room_name,su_nutritionist.nick_name as live_nutritionist_name
+        from sys_import_fan_record as fc
+        left join (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_account') AS ca ON ca.dict_value = fc.import_fan_channel
+        left join sys_live_schedul as slc on slc.id = fc.import_fan_live and slc.del_flag = 0
+        left join (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'sys_live_type') AS slt ON slt.dict_value = slc.live_room
+        left join sys_user as su_nutritionist on su_nutritionist.user_id = slc.live_nutritionist_id and su_nutritionist.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>
+        <if test="importFanLive != null "> and fc.import_fan_live = #{importFanLive}</if>
     </select>
 
     <select id="selectSysImportFanRecordById" parameterType="Long" resultMap="SysImportFanRecordResult">
@@ -83,4 +112,20 @@
         </foreach>
     </update>
 
+    <select id="getFanRecordByChannelLive" parameterType="SysImportFanRecord" resultMap="SysImportFanRecordResult">
+        select * from sys_import_fan_record where del_flag = 0 and import_fan_date = #{importFanDate} and import_fan_channel = #{importFanChannel}
+        and import_fan_live = #{importFanLive}
+        order by id desc limit 1
+    </select>
+
+    <select id="getWxAccountListByFanRecordId" parameterType="Long" resultType="Map">
+        select fwc.id, fwc.import_fan_record_id as importFanRecordId, fwc.import_wx_account_id as importWxAccountId, fwc.import_fan_num as importFanNum,
+        su.nick_name as saleName,wa.wx_account as wxAccount
+        from sys_import_fan_wx_account fwc
+        left join sys_wx_sale_account wa on wa.id = fwc.import_wx_account_id and wa.del_flag = 0
+        left join sys_wx_distribution swd on swd.wechat_account = wa.id and swd.del_flag = 0
+        left join sys_user su on swd.user_id = su.id and su.del_flag = 0
+        where fwc.del_flag = 0
+    </select>
+
 </mapper>
\ No newline at end of file
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml
index 9df906444..c3127ce6d 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml
@@ -82,4 +82,9 @@
         </foreach>
     </update>
 
+    <select id="getWxAccountByFanRecordId" parameterType="SysImportFanWxAccount" resultMap="SysImportFanWxAccountResult">
+        select * from sys_import_fan_wx_account where del_flag = 0 and import_fan_record_id = #{importFanRecordId}
+        and import_wx_account_id = #{importWxAccountId} order by id desc limit 1
+    </select>
+
 </mapper>
\ No newline at end of file
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml
index f5d31376b..795a64be2 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml
@@ -129,4 +129,10 @@
         </foreach>
     </delete>
 
+    <!-- 根据手机号查询微信用户 -->
+    <select id="getSysWxUserInfoByPhone" parameterType="String" resultMap="SysWxUserInfoResult">
+        <include refid="selectSysWxUserInfoVo"/>
+        where phone = #{phone} order by create_time desc limit 1
+    </select>
+
 </mapper>
\ No newline at end of file
diff --git a/stdiet-ui/src/api/custom/liveSchedul.js b/stdiet-ui/src/api/custom/liveSchedul.js
index 716796df0..61318fca8 100644
--- a/stdiet-ui/src/api/custom/liveSchedul.js
+++ b/stdiet-ui/src/api/custom/liveSchedul.js
@@ -71,4 +71,14 @@ export function copyLastTimeLiveSchedul() {
   })
 }
 
+// 根据日期查询直播记录
+export function getAllLiveSchedulByDate(data) {
+  return request({
+    url: '/custom/liveSchedul/getAllLiveSchedulByDate',
+    method: 'get',
+    params: data
+  })
+}
+
+
 
diff --git a/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue b/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
index eb5a9c28c..ff32af561 100644
--- a/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
+++ b/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
@@ -1,16 +1,16 @@
 <template>
     <!-- 添加或修改导粉管理对话框 -->
-    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
+    <el-dialog :title="title" :visible.sync="open" width="1100px" :close-on-click-modal="false" append-to-body>
         <div style="height: 500px; overflow: auto">
             <el-table v-loading="loading" :data="wxAccountList">
                 <!--<el-table-column label="微信昵称" align="center" prop="wxNickName" />-->
                 <el-table-column label="微信号" align="center" prop="wxAccount" width="120"/>
                 <el-table-column label="销售" align="center" prop="saleName" width="120"/>
                 <el-table-column label="已导粉数量" align="center" prop="importFanNum" width="120"/>
-                <el-table-column label="进粉渠道" align="center" prop="fanChannel" >
+                <el-table-column label="进粉渠道" align="center" prop="importFanChannel" >
                     <template slot-scope="scope">
                             <el-select
-                        v-model="scope.row.fanChannel"
+                        v-model="scope.row.importFanChannel"
                         placeholder="请选择账号渠道"
                         clearable
                         filterable
@@ -25,6 +25,24 @@
                         </el-select>
                     </template>
                 </el-table-column>
+                <el-table-column label="直播间" align="center" prop="importFanLive" >
+                    <template slot-scope="scope">
+                        <el-select
+                          v-model="scope.row.importFanLive"
+                          placeholder="请选择直播间"
+                          clearable
+                          filterable
+                          size="small"
+                        >
+                        <el-option
+                            v-for="dict in liveSchedukList"
+                            :key="dict.id"
+                            :label="dict.liveRoomName"
+                            :value="parseInt(dict.id)"
+                        />
+                        </el-select>
+                    </template>
+                </el-table-column>
                 <el-table-column label="导粉数量" align="center" prop="fanNum" width="200">
                     <template slot-scope="scope">
                             <el-input-number v-model="scope.row.fanNum" :min="1" :max="10000" label="导粉数量" style="width:160px"></el-input-number>
@@ -33,10 +51,9 @@
                 <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                     <template slot-scope="scope">
                     <el-button
-                        size="mini"
+                        size="normal"
                         type="text"
-                        icon="el-icon-edit"
-                        @click="handleUpdate(scope.row)"
+                        @click="addImportFanRecord(scope.row)"
                         v-hasPermi="['custom:importFanRecord:add']"
                     >导粉</el-button>
                     </template>
@@ -48,6 +65,7 @@
 </template>
 <script>
 import { addImportFanRecord,getWxAccountAndSale } from "@/api/custom/importFanRecord";
+import { getAllLiveSchedulByDate } from "@/api/custom/liveSchedul";
 export default {
   name: "ImportFan",
   components: {
@@ -71,10 +89,13 @@ export default {
       callback: null,
       //可接粉的微信号
       wxAccountList:[],
-      fanChanneloptions:[]
+      fanChanneloptions:[],
+      //当日直播间
+      liveSchedukList:[]
     };
   },
   created(){
+    
         
   },
   methods: {
@@ -82,11 +103,13 @@ export default {
       if(!data || data == undefined || data == null){
           return;
       }
+      this.data = data;
       this.fanChanneloptions = fanChanneloptions;
       this.title = "「"+data.importFanDate+"」微信导粉(只显示可接粉微信号)";
       this.reset();
       this.callback = callback;
       this.getListWxAccount();
+      this.getAllLiveSchedulByDate();
       this.open = true;
     },
     reset(){
@@ -107,10 +130,57 @@ export default {
     getListWxAccount() {
         this.loading = true;
         getWxAccountAndSale().then((response) => {
+            response.rows.forEach((item,index) => {
+                item.fanNum = 1;
+            })
             this.wxAccountList = response.rows;
             this.loading = false;
         });
     },
+    getAllLiveSchedulByDate(){
+      console.log("--");
+      getAllLiveSchedulByDate({'liveSchedulDate':this.data.importFanDate}).then((response) => {
+          response.data.forEach((item,index) => {
+            item.liveRoomName = item.liveNutritionistName + " " + item.liveRoomName;
+          });
+          this.liveSchedukList = response.data;  
+      });
+    },
+    addImportFanRecord(row){
+        //账号渠道、进粉数量不能为空
+        if(row.importFanChannel == undefined || row.importFanChannel == null){
+          this.$message({
+                type: 'warning',
+                message: '进粉渠道不能为空',
+                center: true
+          });
+          return;
+        }
+        if(row.fanNum == undefined || row.fanNum == null){
+          this.$message({
+                type: 'warning',
+                message: '进粉数量不能为空',
+                center: true
+          });
+          return;
+        }
+        let param = {
+          'importFanDate': this.data.importFanDate,
+          'importFanChannel': row.importFanChannel,
+          'importFanLive': row.importFanLive,
+          'wxAccountId': row.id,
+          'fanNum': row.fanNum
+        }
+        addImportFanRecord(param).then((response) => {
+            if(response.code == 200){
+                this.msgSuccess("导粉成功");
+                row.importFanChannel = null;
+                row.fanNum = 1;
+                row.importFanLive = null;
+            }
+        });
+        
+    }
   },
 };
 </script>
diff --git a/stdiet-ui/src/views/custom/importFanRecord/index.vue b/stdiet-ui/src/views/custom/importFanRecord/index.vue
index fade5a25f..6eec62021 100644
--- a/stdiet-ui/src/views/custom/importFanRecord/index.vue
+++ b/stdiet-ui/src/views/custom/importFanRecord/index.vue
@@ -89,8 +89,12 @@
           <span>{{ parseTime(scope.row.importFanDate, '{y}-{m}-{d}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="导粉渠道" align="center" prop="importFanChannel" />
-      <!--<el-table-column label="进粉直播间" align="center" prop="importFanLive" />-->
+      <el-table-column label="进粉账号渠道" align="center" prop="importFanChannelName" />
+      <el-table-column label="所属直播间" align="center" prop="liveRoomName" >
+        <template slot-scope="scope">
+            {{scope.row.liveRoomName + "—" + scope.row.liveNutritionistName}}
+        </template>
+      </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button

From 17df1db9e226940fb352f68d286591bf8277f314 Mon Sep 17 00:00:00 2001
From: xiezhijun <15270898033@163.com>
Date: Thu, 20 May 2021 18:59:03 +0800
Subject: [PATCH 3/5] =?UTF-8?q?=E5=AF=BC=E7=B2=89=E8=AE=B0=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../custom/SysCustomerController.java         |  2 +-
 .../custom/SysImportFanRecordController.java  | 17 ++++++++--
 .../custom/domain/SysImportFanWxAccount.java  |  7 ++++
 .../mapper/SysImportFanWxAccountMapper.java   |  9 +++++
 .../custom/mapper/SysWxSaleAccountMapper.java |  3 +-
 .../ISysImportFanWxAccountService.java        |  9 +++++
 .../service/ISysWxSaleAccountService.java     |  3 +-
 .../SysImportFanWxAccountServiceImpl.java     | 12 +++++++
 .../impl/SysWxSaleAccountServiceImpl.java     |  6 ++--
 .../custom/SysImportFanRecordMapper.xml       |  4 +--
 .../custom/SysImportFanWxAccountMapper.xml    | 18 ++++++++++
 .../mapper/custom/SysWxSaleAccountMapper.xml  |  5 ++-
 .../ImportFanRecord/ImportFan/index.vue       | 32 ++++++++++++-----
 .../views/custom/importFanRecord/index.vue    | 34 +++++++++++++++++--
 14 files changed, 135 insertions(+), 26 deletions(-)

diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerController.java
index 020053bea..c30f5e2c4 100644
--- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerController.java
+++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerController.java
@@ -79,8 +79,8 @@ public class SysCustomerController extends BaseController {
             for (SysCustomer sysCus : list) {
                 if (StringUtils.isNotEmpty(sysCus.getPhone())) {
                     sysCus.setPhone(StringUtils.hiddenPhoneNumber(sysCus.getPhone()));
-                    sysCus.setEncId(sysCus.getId() != null ? AesUtils.encrypt(sysCus.getId() + "", null) : "");
                 }
+                sysCus.setEncId(sysCus.getId() != null ? AesUtils.encrypt(sysCus.getId() + "", null) : "");
             }
         }
         return getDataTable(list);
diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java
index 8d151231f..3e1202771 100644
--- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java
+++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java
@@ -1,8 +1,12 @@
 package com.stdiet.web.controller.custom;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+import com.stdiet.custom.domain.SysImportFanWxAccount;
 import com.stdiet.custom.domain.SysWxSaleAccount;
+import com.stdiet.custom.service.ISysImportFanWxAccountService;
 import com.stdiet.custom.service.ISysWxSaleAccountService;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,6 +43,9 @@ public class SysImportFanRecordController extends BaseController
     @Autowired
     private ISysWxSaleAccountService sysWxSaleAccountService;
 
+    @Autowired
+    private ISysImportFanWxAccountService sysImportFanWxAccountService;
+
     /**
      * 查询导粉管理列表
      */
@@ -109,12 +116,16 @@ public class SysImportFanRecordController extends BaseController
 
     /**
      * 获取可接粉的微信号以及对应销售
-     * @param sysWxSaleAccount
      * @return
      */
     @PreAuthorize("@ss.hasPermi('custom:importFanRecord:add')")
     @GetMapping(value = "/getWxAccountAndSale")
-    public TableDataInfo getWxAccountAndSale(SysWxSaleAccount sysWxSaleAccount){
-        return getDataTable(sysWxSaleAccountService.getWxAccountAndSale(sysWxSaleAccount));
+    public AjaxResult getWxAccountAndSale(SysImportFanWxAccount sysImportFanWxAccount){
+        Map<String, Object> result = new HashMap<>();
+        List<SysWxSaleAccount> list = sysWxSaleAccountService.getWxAccountAndSale();
+        List<Map<String,Object>> fanNumList = sysImportFanWxAccountService.getTotalImportFanNum(sysImportFanWxAccount);
+        result.put("wxSaleAccountList", list);
+        result.put("fanNumList", fanNumList);
+        return AjaxResult.success(result);
     }
 }
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysImportFanWxAccount.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysImportFanWxAccount.java
index 6aad5277c..16befd66d 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysImportFanWxAccount.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysImportFanWxAccount.java
@@ -1,9 +1,12 @@
 package com.stdiet.custom.domain;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import com.stdiet.common.annotation.Excel;
 import com.stdiet.common.core.domain.BaseEntity;
 
+import java.util.Date;
+
 /**
  * 导粉记录中对应微信记录对象 sys_import_fan_wx_account
  *
@@ -32,4 +35,8 @@ public class SysImportFanWxAccount extends BaseEntity
 
     /** 删除标识 0未删除 1已删除 */
     private Long delFlag;
+
+    //导粉日期
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date importFanDate;
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanWxAccountMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanWxAccountMapper.java
index 0d441f291..eaef49511 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanWxAccountMapper.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanWxAccountMapper.java
@@ -1,6 +1,8 @@
 package com.stdiet.custom.mapper;
 
 import java.util.List;
+import java.util.Map;
+
 import com.stdiet.custom.domain.SysImportFanWxAccount;
 
 /**
@@ -65,4 +67,11 @@ public interface SysImportFanWxAccountMapper
      * @return
      */
     public SysImportFanWxAccount getWxAccountByFanRecordId(SysImportFanWxAccount sysImportFanWxAccount);
+
+    /**
+     * 根据微信号查询
+     * @param sysImportFanWxAccount
+     * @return
+     */
+    List<Map<String,Object>> getTotalImportFanNum(SysImportFanWxAccount sysImportFanWxAccount);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxSaleAccountMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxSaleAccountMapper.java
index 0901b5a37..dc613d255 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxSaleAccountMapper.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxSaleAccountMapper.java
@@ -74,8 +74,7 @@ public interface SysWxSaleAccountMapper
 
     /**
      * 获取可接粉的微信号以及分配的销售昵称
-     * @param sysWxSaleAccount
      * @return
      */
-    List<SysWxSaleAccount> getWxAccountAndSale(SysWxSaleAccount sysWxSaleAccount);
+    List<SysWxSaleAccount> getWxAccountAndSale();
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanWxAccountService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanWxAccountService.java
index 1b0a3f36c..78277a5dd 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanWxAccountService.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanWxAccountService.java
@@ -1,7 +1,10 @@
 package com.stdiet.custom.service;
 
 import java.util.List;
+import java.util.Map;
+
 import com.stdiet.custom.domain.SysImportFanWxAccount;
+import com.stdiet.custom.domain.SysWxSaleAccount;
 
 /**
  * 导粉记录中对应微信记录Service接口
@@ -65,4 +68,10 @@ public interface ISysImportFanWxAccountService
      * @return
      */
     public SysImportFanWxAccount getWxAccountByFanRecordId(SysImportFanWxAccount sysImportFanWxAccount);
+
+    /**
+     * 根据日期统计微信号导粉数量
+     * @return
+     */
+    List<Map<String,Object>> getTotalImportFanNum(SysImportFanWxAccount sysImportFanWxAccount);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxSaleAccountService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxSaleAccountService.java
index 5763bf238..ae48aebdc 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxSaleAccountService.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxSaleAccountService.java
@@ -75,8 +75,7 @@ public interface ISysWxSaleAccountService
 
     /**
      * 获取可接粉的微信号以及分配的销售昵称
-     * @param sysWxSaleAccount
      * @return
      */
-    List<SysWxSaleAccount> getWxAccountAndSale(SysWxSaleAccount sysWxSaleAccount);
+    List<SysWxSaleAccount> getWxAccountAndSale();
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanWxAccountServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanWxAccountServiceImpl.java
index 44e904a99..ba564cfd4 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanWxAccountServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanWxAccountServiceImpl.java
@@ -1,7 +1,10 @@
 package com.stdiet.custom.service.impl;
 
 import java.util.List;
+import java.util.Map;
+
 import com.stdiet.common.utils.DateUtils;
+import com.stdiet.custom.domain.SysWxSaleAccount;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.stdiet.custom.mapper.SysImportFanWxAccountMapper;
@@ -102,4 +105,13 @@ public class SysImportFanWxAccountServiceImpl implements ISysImportFanWxAccountS
     public SysImportFanWxAccount getWxAccountByFanRecordId(SysImportFanWxAccount sysImportFanWxAccount){
         return sysImportFanWxAccountMapper.getWxAccountByFanRecordId(sysImportFanWxAccount);
     }
+
+
+    /**
+     * 根据日期统计微信号导粉数量
+     * @return
+     */
+    public List<Map<String,Object>> getTotalImportFanNum(SysImportFanWxAccount sysImportFanWxAccount){
+        return sysImportFanWxAccountMapper.getTotalImportFanNum(sysImportFanWxAccount);
+    }
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxSaleAccountServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxSaleAccountServiceImpl.java
index 0374d66db..6177b16b2 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxSaleAccountServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxSaleAccountServiceImpl.java
@@ -9,7 +9,9 @@ import com.stdiet.custom.service.ISysWxSaleAccountService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 微信账号Service业务层处理
@@ -134,7 +136,7 @@ public class SysWxSaleAccountServiceImpl implements ISysWxSaleAccountService {
      * @param sysWxSaleAccount
      * @return
      */
-    public List<SysWxSaleAccount> getWxAccountAndSale(SysWxSaleAccount sysWxSaleAccount){
-        return sysWxSaleAccountMapper.getWxAccountAndSale(sysWxSaleAccount);
+    public List<SysWxSaleAccount> getWxAccountAndSale(){
+        return sysWxSaleAccountMapper.getWxAccountAndSale();
     }
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml
index b99b2fd55..4f6ea7699 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml
@@ -124,8 +124,8 @@
         from sys_import_fan_wx_account fwc
         left join sys_wx_sale_account wa on wa.id = fwc.import_wx_account_id and wa.del_flag = 0
         left join sys_wx_distribution swd on swd.wechat_account = wa.id and swd.del_flag = 0
-        left join sys_user su on swd.user_id = su.id and su.del_flag = 0
-        where fwc.del_flag = 0
+        left join sys_user su on swd.user_id = su.user_id and su.del_flag = 0
+        where fwc.del_flag = 0 and fwc.import_fan_record_id = #{id}
     </select>
 
 </mapper>
\ No newline at end of file
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml
index c3127ce6d..4f0d7bfbb 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml
@@ -87,4 +87,22 @@
         and import_wx_account_id = #{importWxAccountId} order by id desc limit 1
     </select>
 
+    <!-- 根据微信号ID查询导粉多少 -->
+    <select id="getTotalImportFanNum" parameterType="SysImportFanWxAccount" resultType="Map">
+        select w.import_wx_account_id as wxAccountId,sum(w.import_fan_num) as fanNum
+        from
+        (
+          select fwa.import_wx_account_id,fwa.import_fan_num from  sys_import_fan_wx_account fwa
+          left join sys_import_fan_record ifr on fwa.import_fan_record_id = ifr.id and ifr.del_flag = 0
+          where fwa.del_flag = 0
+          <if test="importFanDate != null">
+            and ifr.import_fan_date = #{importFanDate}
+          </if>
+          <if test="importWxAccountId != null">
+            and fwa.import_wx_account_id = #{importWxAccountId}
+          </if>
+        ) w
+        group by w.import_wx_account_id order by w.import_wx_account_id desc
+    </select>
+
 </mapper>
\ No newline at end of file
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml
index e8f32eb8b..5d424ca73 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml
@@ -139,14 +139,13 @@
     </insert>
 
     <!-- 查询可以接粉的微信号以及对应销售,用于导粉记录管理 -->
-    <select id="getWxAccountAndSale" parameterType="SysWxSaleAccount" resultMap="SysWxSaleAccountResult">
+    <select id="getWxAccountAndSale" resultMap="SysWxSaleAccountResult">
         select wa.id, wa.wx_account, su.nick_name as sale_name
         from sys_wx_sale_account wa
         left join sys_wx_distribution swd on wa.id = swd.wechat_account and swd.del_flag = 0
         LEFT JOIN sys_user su ON su.user_id = swd.user_id AND su.del_flag = 0
         where wa.del_flag = 0 and wa.status = 0
-        <if test="wxAccount != null  and wxAccount != ''">and wa.wx_account like concat('%', #{wxAccount}, '%')</if>
-        order by wa.id desc
+        order by su.user_id asc
     </select>
 
 </mapper>
\ No newline at end of file
diff --git a/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue b/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
index ff32af561..b4a9e248a 100644
--- a/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
+++ b/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
@@ -4,7 +4,7 @@
         <div style="height: 500px; overflow: auto">
             <el-table v-loading="loading" :data="wxAccountList">
                 <!--<el-table-column label="微信昵称" align="center" prop="wxNickName" />-->
-                <el-table-column label="微信号" align="center" prop="wxAccount" width="120"/>
+                <el-table-column label="微信号" align="center" prop="wxAccount" width="160"/>
                 <el-table-column label="销售" align="center" prop="saleName" width="120"/>
                 <el-table-column label="已导粉数量" align="center" prop="importFanNum" width="120"/>
                 <el-table-column label="进粉渠道" align="center" prop="importFanChannel" >
@@ -48,7 +48,7 @@
                             <el-input-number v-model="scope.row.fanNum" :min="1" :max="10000" label="导粉数量" style="width:160px"></el-input-number>
                     </template>
                 </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" width="100">
                     <template slot-scope="scope">
                     <el-button
                         size="normal"
@@ -91,7 +91,9 @@ export default {
       wxAccountList:[],
       fanChanneloptions:[],
       //当日直播间
-      liveSchedukList:[]
+      liveSchedukList:[],
+      //总导粉统计
+      fanNumList:[]
     };
   },
   created(){
@@ -129,16 +131,17 @@ export default {
     //获取所有可接粉的微信号
     getListWxAccount() {
         this.loading = true;
-        getWxAccountAndSale().then((response) => {
-            response.rows.forEach((item,index) => {
+        getWxAccountAndSale({'importFanDate': this.data.importFanDate}).then((response) => {
+            response.data.wxSaleAccountList.forEach((item,index) => {
                 item.fanNum = 1;
-            })
-            this.wxAccountList = response.rows;
+                item.importFanNum =  this.getTotalFanNum(response.data.fanNumList, item.id);
+            });
+            this.wxAccountList = response.data.wxSaleAccountList;
+            this.fanNumList = response.data.fanNumList;
             this.loading = false;
         });
     },
     getAllLiveSchedulByDate(){
-      console.log("--");
       getAllLiveSchedulByDate({'liveSchedulDate':this.data.importFanDate}).then((response) => {
           response.data.forEach((item,index) => {
             item.liveRoomName = item.liveNutritionistName + " " + item.liveRoomName;
@@ -146,6 +149,18 @@ export default {
           this.liveSchedukList = response.data;  
       });
     },
+    getTotalFanNum(fanNumList, wxAccountId){
+        if(wxAccountId == null || fanNumList == null){
+          return 0;
+        }
+        let num = 0;
+        fanNumList.forEach((item,index) => {
+            if(item.wxAccountId == wxAccountId){
+                num = item.fanNum;
+            }
+        });
+        return num;
+    },
     addImportFanRecord(row){
         //账号渠道、进粉数量不能为空
         if(row.importFanChannel == undefined || row.importFanChannel == null){
@@ -177,6 +192,7 @@ export default {
                 row.importFanChannel = null;
                 row.fanNum = 1;
                 row.importFanLive = null;
+                row.importFanNum += row.fanNum;
             }
         });
         
diff --git a/stdiet-ui/src/views/custom/importFanRecord/index.vue b/stdiet-ui/src/views/custom/importFanRecord/index.vue
index 6eec62021..79bd025fc 100644
--- a/stdiet-ui/src/views/custom/importFanRecord/index.vue
+++ b/stdiet-ui/src/views/custom/importFanRecord/index.vue
@@ -92,10 +92,29 @@
       <el-table-column label="进粉账号渠道" align="center" prop="importFanChannelName" />
       <el-table-column label="所属直播间" align="center" prop="liveRoomName" >
         <template slot-scope="scope">
-            {{scope.row.liveRoomName + "—" + scope.row.liveNutritionistName}}
+            {{(scope.row.liveRoomName != null || scope.row.liveNutritionistName != null) ? (scope.row.liveRoomName + "—" + scope.row.liveNutritionistName) : ""}}
         </template>
       </el-table-column>
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+      <el-table-column label="导粉总数" align="center" prop="wxAccountList" :formatter="getTotalFanNum">
+      </el-table-column>
+      <el-table-column label="导粉微信号" align="center" prop="wxAccountList" >
+        <template slot-scope="scope">
+          <el-popover
+          placement="left"
+          width="390"
+          trigger="click">
+          <el-table :data="scope.row.wxAccountList" style="width:370;height: 400px;overflow: auto;">
+            <el-table-column width="100" property="saleName" label="销售" align="center"></el-table-column>
+            <el-table-column width="160" property="wxAccount" label="微信号" align="center"></el-table-column>
+            <el-table-column width="80" property="importFanNum" label="导粉数量" align="center"></el-table-column>
+          </el-table>
+          <el-button slot="reference">详情</el-button>
+          </el-popover>
+        </template>
+      </el-table-column>
+      
+      
+     <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
             size="mini"
@@ -112,7 +131,7 @@
             v-hasPermi="['custom:importFanRecord:remove']"
           >删除</el-button>
         </template>
-      </el-table-column>
+      </el-table-column>-->
     </el-table>
     
     <pagination
@@ -334,6 +353,15 @@ export default {
         this.$refs.importFanRef.showDialog(data,()=>{
             this.getList();
         }, this.fanChanneloptions);
+    },
+    getTotalFanNum(row, column){
+      let fanNum = 0;
+      if(row.wxAccountList != null){
+        row.wxAccountList.forEach((item,index) => {
+          fanNum += item.importFanNum == null ? 0 : item.importFanNum;
+        });
+      }
+      return fanNum;
     }
   }
 };

From f9137740251090ed0eaa0c3b0cb7cd196e795ee3 Mon Sep 17 00:00:00 2001
From: xiezhijun <15270898033@163.com>
Date: Fri, 21 May 2021 18:59:26 +0800
Subject: [PATCH 4/5] =?UTF-8?q?=E5=AF=BC=E7=B2=89=E8=AE=B0=E5=BD=95?=
 =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E4=BB=A5=E5=8F=8A=E6=8E=A5=E5=8F=A3=E4=BF=AE?=
 =?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../custom/SysImportFanRecordController.java  |  36 +++++-
 .../custom/domain/SysImportFanRecord.java     |  13 +++
 .../mapper/SysImportFanRecordMapper.java      |   3 +
 .../mapper/SysImportFanWxAccountMapper.java   |   7 ++
 .../service/ISysImportFanRecordService.java   |   3 +
 .../ISysImportFanWxAccountService.java        |   7 ++
 .../impl/SysImportFanRecordServiceImpl.java   |  18 ++-
 .../SysImportFanWxAccountServiceImpl.java     |   9 ++
 .../custom/SysImportFanRecordMapper.xml       |  11 +-
 .../custom/SysImportFanWxAccountMapper.xml    |   8 ++
 .../ImportFanRecord/ImportFan/index.vue       | 109 ++++++++++++++++--
 .../views/custom/importFanRecord/index.vue    |  47 ++++++--
 12 files changed, 250 insertions(+), 21 deletions(-)

diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java
index 3e1202771..e85a65438 100644
--- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java
+++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java
@@ -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);
     }
 
     /**
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysImportFanRecord.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysImportFanRecord.java
index 7c9222937..bd3480d6c 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysImportFanRecord.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysImportFanRecord.java
@@ -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;
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanRecordMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanRecordMapper.java
index eb430d355..42a83f3c9 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanRecordMapper.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanRecordMapper.java
@@ -65,4 +65,7 @@ public interface SysImportFanRecordMapper
      * @return
      */
     public SysImportFanRecord getFanRecordByChannelLive(SysImportFanRecord sysImportFanRecord);
+
+    //查询总导粉数量
+    int selectTotalSysImportFanNum(SysImportFanRecord sysImportFanRecord);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanWxAccountMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanWxAccountMapper.java
index eaef49511..1a87c2f4a 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanWxAccountMapper.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysImportFanWxAccountMapper.java
@@ -74,4 +74,11 @@ public interface SysImportFanWxAccountMapper
      * @return
      */
     List<Map<String,Object>> getTotalImportFanNum(SysImportFanWxAccount sysImportFanWxAccount);
+
+    /**
+     * 根据记录ID删除对应所有微信
+     * @param ids
+     * @return
+     */
+    int deleteSysImportFanWxAccountByFanRecordIds(Long[] ids);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanRecordService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanRecordService.java
index 70ece7c90..d2b370823 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanRecordService.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanRecordService.java
@@ -58,4 +58,7 @@ public interface ISysImportFanRecordService
      * @return 结果
      */
     public int deleteSysImportFanRecordById(Long id);
+
+    //查询总导粉数量
+    int selectTotalSysImportFanNum(SysImportFanRecord sysImportFanRecord);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanWxAccountService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanWxAccountService.java
index 78277a5dd..4686fc880 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanWxAccountService.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysImportFanWxAccountService.java
@@ -74,4 +74,11 @@ public interface ISysImportFanWxAccountService
      * @return
      */
     List<Map<String,Object>> getTotalImportFanNum(SysImportFanWxAccount sysImportFanWxAccount);
+
+    /**
+     * 根据记录ID删除对应所有微信
+     * @param ids
+     * @return
+     */
+    int deleteSysImportFanWxAccountByFanRecordIds(Long[] ids);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanRecordServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanRecordServiceImpl.java
index 8ccb0d8e8..9c5fb2be2 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanRecordServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanRecordServiceImpl.java
@@ -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);
     }
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanWxAccountServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanWxAccountServiceImpl.java
index ba564cfd4..ff8d52037 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanWxAccountServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysImportFanWxAccountServiceImpl.java
@@ -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);
+    }
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml
index 4f6ea7699..f7966e605 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml
@@ -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">
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml
index 4f0d7bfbb..3696cf7eb 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml
@@ -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>
\ No newline at end of file
diff --git a/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue b/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
index b4a9e248a..7fa8f0234 100644
--- a/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
+++ b/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
@@ -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;
+                    }
+                  });
+              }
+            }
+        } 
     }
   },
 };
diff --git a/stdiet-ui/src/views/custom/importFanRecord/index.vue b/stdiet-ui/src/views/custom/importFanRecord/index.vue
index 79bd025fc..da4c33811 100644
--- a/stdiet-ui/src/views/custom/importFanRecord/index.vue
+++ b/stdiet-ui/src/views/custom/importFanRecord/index.vue
@@ -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;

From ddd4b3763cfd034040ea4b867863850e091c46aa Mon Sep 17 00:00:00 2001
From: xiezhijun <15270898033@163.com>
Date: Mon, 24 May 2021 16:41:11 +0800
Subject: [PATCH 5/5] =?UTF-8?q?=E5=AF=BC=E7=B2=89=E8=AE=B0=E5=BD=95?=
 =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=8C=E9=87=87=E8=B4=AD=E8=AE=A1=E5=88=92?=
 =?UTF-8?q?SQL=E4=BC=98=E5=8C=96=EF=BC=8C=E5=90=8E=E7=BB=AD=E5=BB=BA?=
 =?UTF-8?q?=E7=AB=8B=E7=B4=A2=E5=BC=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../custom/SysImportFanRecordController.java  | 22 ++++++
 .../service/impl/SysRecipesServiceImpl.java   |  5 +-
 .../mapper/custom/SysLiveSchedulMapper.xml    | 23 +++---
 .../mapper/custom/SysRecipesMapper.xml        | 10 ++-
 stdiet-ui/src/api/custom/importFanRecord.js   | 19 ++++-
 .../views/custom/importFanRecord/index.vue    | 75 +++++++++++++++++--
 .../src/views/custom/liveSchedul/index.vue    | 10 +--
 7 files changed, 137 insertions(+), 27 deletions(-)

diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java
index e85a65438..eacf08a14 100644
--- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java
+++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysImportFanRecordController.java
@@ -162,4 +162,26 @@ public class SysImportFanRecordController extends BaseController
         result.put("fanNumList", fanNumList);
         return AjaxResult.success(result);
     }
+
+    /**
+     * 删除导粉记录中对应微信记录
+     */
+    @PreAuthorize("@ss.hasPermi('custom:importFanRecord:remove')")
+    @Log(title = "删除导粉记录中对应微信记录", businessType = BusinessType.DELETE)
+    @GetMapping("/removeFanWxAccount/{ids}")
+    public AjaxResult removeFanWxAccount(@PathVariable Long[] ids)
+    {
+        return toAjax(sysImportFanWxAccountService.deleteSysImportFanWxAccountByIds(ids));
+    }
+
+    /**
+     * 删除导粉记录中对应微信记录
+     */
+    @PreAuthorize("@ss.hasPermi('custom:importFanRecord:edit')")
+    @GetMapping("/saveWxAccountFanNum")
+    public AjaxResult saveWxAccountFanNum(SysImportFanWxAccount sysImportFanWxAccount)
+    {
+        return toAjax(sysImportFanWxAccountService.updateSysImportFanWxAccount(sysImportFanWxAccount));
+    }
+
 }
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesServiceImpl.java
index e11568e7a..021166223 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesServiceImpl.java
@@ -64,7 +64,10 @@ public class SysRecipesServiceImpl implements ISysRecipesService {
 
     @Override
     public List<SysRecipes> selectSysRecipesByRecipesId(Long id) {
-        return sysRecipesMapper.selectSysRecipesByRecipesId(id);
+        long t = System.currentTimeMillis();
+        List<SysRecipes> list = sysRecipesMapper.selectSysRecipesByRecipesId(id);
+        System.out.println(System.currentTimeMillis() - t);
+        return list;
     }
 
     @Override
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml
index e7b0e32ef..2b309d9cd 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysLiveSchedulMapper.xml
@@ -28,7 +28,7 @@
         <result property="fanChannelName"  column="fan_channel_name"></result>
 
         <!-- 根据渠道查询对应微信号(微信账号分配表中) -->
-        <!--<association property="wxAccountList" column="fan_channel" select="getWxAccountListByFanChannel"/>-->
+        <association property="wxAccountList" column="id" select="getWxAccountListByLiveId"/>
     </resultMap>
 
     <resultMap type="SysLiveSchedul" id="SysLiveSchedulResultSigle">
@@ -74,9 +74,9 @@
         <if test="fanChannel != null">
             and slc.fan_channel = #{fanChannel}
         </if>
-        <if test="wxAccountId != null">
+        <!--<if test="wxAccountId != null">
             and slc.fan_channel = (SELECT swd.account_id FROM sys_wx_distribution AS swd where swd.wechat_account = #{wxAccountId} and swd.del_flag = 0 limit 1)
-        </if>
+        </if>-->
         order by slc.live_schedul_date desc,slc.live_start_time desc ,slc.live_room asc
     </select>
 
@@ -162,14 +162,15 @@
         </foreach>
     </update>
 
-    <!-- 根据渠道查询该渠道下分配的微信号 -->
-    <select id="getWxAccountListByFanChannel" parameterType="Integer" resultType="Map">
-      SELECT su.nick_name as nickName,swsa.wx_account as wxAccount,asg.dict_label as saleGroupName
-      FROM sys_wx_distribution AS swd
-      lEFT JOIN sys_wx_sale_account swsa ON swsa.id = swd.wechat_account and swsa.del_flag = 0
-      LEFT JOIN sys_user su ON su.user_id = swd.user_id AND su.del_flag = 0
-      LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'sale_group') AS asg ON asg.dict_value = swd.sale_group_id
-      where swd.account_id = #{fan_channel} and swd.del_flag = 0
+    <!-- 根据直播ID查询该渠道下分配的微信号 -->
+    <select id="getWxAccountListByLiveId" parameterType="Long" resultType="Map">
+      SELECT su.nick_name as saleName,w.wx_account as wxAccount, sum(wa.import_fan_num) as fanNum from sys_import_fan_record as fc
+      left join sys_import_fan_wx_account as wa on wa.import_fan_record_id =  fc.id and wa.del_flag = 0
+      left join sys_wx_sale_account as w on w.id = wa.import_wx_account_id and w.del_flag = 0
+      left join sys_wx_distribution swd on swd.wechat_account = w.id and swd.del_flag = 0
+      left join sys_user su on swd.user_id = su.user_id and su.del_flag = 0
+      where fc.import_fan_live = #{id} and fc.del_flag = 0
+      group by w.wx_account,su.nick_name
     </select>
 
     <!-- 查询直播时间范围是否重叠 -->
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesMapper.xml
index ad69948f1..549ae9e2a 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesMapper.xml
@@ -198,12 +198,16 @@
     </select>
 
     <select id="selectDishesByMenuIdShow" parameterType="Long" resultMap="SysDishesResultShow">
-        SELECT * FROM (SELECT id, menu_id, dishes_id, type, detail, remark FROM sys_customer_menu_dishes WHERE menu_id = #{id}) AS menu
-        LEFT JOIN sys_dishes ON menu.dishes_id = sys_dishes.id
+        SELECT
+        menu.id, menu.menu_id, menu.dishes_id, menu.type, menu.detail, menu.remark, sd.is_main,sd.name,sd.methods
+        FROM (SELECT id, menu_id, dishes_id, type, detail, remark FROM sys_customer_menu_dishes WHERE menu_id = #{id}) AS menu
+        LEFT JOIN sys_dishes as sd ON menu.dishes_id = sd.id
     </select>
 
     <select id="selectIngredientsByDishesIdShow" parameterType="Long" resultMap="SysIgdsResultShow">
-       SELECT * FROM(
+       SELECT
+       ing.id,ing.name,ing.type.ing.protein_ratio,ing.fat_ratio,ing.carbon_ratio.ing.area,dishes.cus_weight,dishes.cus_unit,dishes.weight
+       FROM(
             SELECT ingredient_id AS id, ingredient_weight AS weight, cus_weight, cus_unit, remark
             FROM sys_dishes_ingredient
             WHERE dishes_id = #{id}
diff --git a/stdiet-ui/src/api/custom/importFanRecord.js b/stdiet-ui/src/api/custom/importFanRecord.js
index 68922e69b..47e0b9485 100644
--- a/stdiet-ui/src/api/custom/importFanRecord.js
+++ b/stdiet-ui/src/api/custom/importFanRecord.js
@@ -58,4 +58,21 @@ export function getWxAccountAndSale(query){
         method: 'get',
         params: query
       })
-}
\ No newline at end of file
+}
+
+// 删除导粉记录中对应的微信记录
+export function removeFanWxAccount(id) {
+  return request({
+    url: '/custom/importFanRecord/removeFanWxAccount/' + id,
+    method: 'get'
+  })
+}
+
+
+export function saveWxAccountFanNum(data){
+  return request({
+    url: '/custom/importFanRecord/saveWxAccountFanNum',
+    method: 'get',
+    params: data
+  })
+}
diff --git a/stdiet-ui/src/views/custom/importFanRecord/index.vue b/stdiet-ui/src/views/custom/importFanRecord/index.vue
index da4c33811..f5f0b373a 100644
--- a/stdiet-ui/src/views/custom/importFanRecord/index.vue
+++ b/stdiet-ui/src/views/custom/importFanRecord/index.vue
@@ -104,12 +104,48 @@
         <template slot-scope="scope">
           <el-popover
           placement="left"
-          width="390"
+          width="520"
           trigger="click">
-          <el-table :data="scope.row.wxAccountList" style="width:370;height: 400px;overflow: auto;">
-            <el-table-column width="100" property="saleName" label="销售" align="center"></el-table-column>
+          <el-table :data="scope.row.wxAccountList" style="width:450;height: 400px;overflow: auto;">
+            <el-table-column width="80" property="saleName" label="销售" align="center"></el-table-column>
             <el-table-column width="160" property="wxAccount" label="微信号" align="center"></el-table-column>
-            <el-table-column width="80" property="importFanNum" label="导粉数量" align="center"></el-table-column>
+            <el-table-column width="120" property="importFanNum" label="导粉数量" align="center">
+                <template slot-scope="scope">
+                  <div v-if="scope.row.updateFlag">
+                    <el-input-number v-model="scope.row.importFanNum" controls-position="right" :min="1" :max="10000" style="width:100px"></el-input-number>
+                  </div>
+                  <div v-else>
+                    {{scope.row.importFanNum}}
+                  </div>
+                </template>
+            </el-table-column>
+            <el-table-column width="120" label="操作" align="center">
+              <template slot-scope="scope">
+                <el-button
+                    v-if="scope.row.updateFlag"
+                    size="mini"
+                    type="text"
+                    icon="el-icon-check"
+                    @click="saveWxAccountFanNum(scope.row)"
+                    v-hasPermi="['custom:importFanRecord:edit']"
+                  >保存</el-button>
+                  <el-button 
+                    v-else
+                    size="mini"
+                    type="text"
+                    icon="el-icon-edit"
+                    @click="scope.row.updateFlag = true"
+                    v-hasPermi="['custom:importFanRecord:edit']"
+                  >修改</el-button>
+                  <el-button
+                    size="mini"
+                    type="text"
+                    icon="el-icon-delete"
+                    @click="removeWxAccount(scope.row.id)"  
+                    v-hasPermi="['custom:importFanRecord:remove']"
+                  >移除</el-button>
+              </template>
+            </el-table-column>
           </el-table>
           <el-button slot="reference">详情</el-button>
           </el-popover>
@@ -158,7 +194,7 @@
       :layout="`${'total, slot, sizes, prev, pager, next, jumper'}`"
       @pagination="getList"
     >
-      <span style="margin-right: 12px" v-if="!isMobile"
+      <span style="margin-right: 12px"
         >总计导粉量:{{
           totalFanNum
         }}
@@ -195,7 +231,7 @@
 </template>
 
 <script>
-import { listImportFanRecord, getImportFanRecord, delImportFanRecord, addImportFanRecord, updateImportFanRecord, exportImportFanRecord } from "@/api/custom/importFanRecord";
+import { listImportFanRecord, getImportFanRecord, delImportFanRecord, addImportFanRecord, updateImportFanRecord, exportImportFanRecord,removeFanWxAccount,saveWxAccountFanNum } from "@/api/custom/importFanRecord";
 import ImportFan from "@/components/ImportFanRecord/ImportFan";
 import dayjs from "dayjs";
 const nowDate = dayjs().format("YYYY-MM-DD");
@@ -257,6 +293,13 @@ export default {
       listImportFanRecord(this.queryParams).then(response => {
         if(response.rows != null && response.rows.length > 0){
           this.totalFanNum = response.rows[0].totalFanNum;
+          response.rows.forEach((item,index) => {
+              if(item.wxAccountList != null && item.wxAccountList.length > 0){
+                 item.wxAccountList.forEach((wx,i) => {
+                    wx.updateFlag = false;
+                 })
+              }
+          });
         }else{
           this.totalFanNum = 0;
         }
@@ -393,6 +436,26 @@ export default {
         });
       }
       return fanNum;
+    },
+    removeWxAccount(id){
+       removeFanWxAccount(id).then(response => {
+          if (response.code === 200) {
+              this.msgSuccess("移除成功");
+              this.getList();
+          }
+      });
+    },
+    saveWxAccountFanNum(row){
+        let param = {
+          id: row.id,
+          importFanNum: row.importFanNum
+        };
+        saveWxAccountFanNum(param).then(response => {
+          if (response.code === 200) {
+              this.msgSuccess("保存成功");
+              this.getList();
+          }
+        });
     }
   }
 };
diff --git a/stdiet-ui/src/views/custom/liveSchedul/index.vue b/stdiet-ui/src/views/custom/liveSchedul/index.vue
index 6fbfc3537..303499622 100644
--- a/stdiet-ui/src/views/custom/liveSchedul/index.vue
+++ b/stdiet-ui/src/views/custom/liveSchedul/index.vue
@@ -144,12 +144,12 @@
         <template slot-scope="scope">
           <el-popover
           placement="left"
-          width="390"
+          width="370"
           trigger="click">
-          <el-table :data="scope.row.wxAccountList" style="width:370;height: 400px;overflow: auto;">
-            <el-table-column width="100" property="nickName" label="销售"></el-table-column>
-            <el-table-column width="120" property="wxAccount" label="微信号"></el-table-column>
-            <el-table-column width="120" property="saleGroupName" label="销售组别"></el-table-column>
+          <el-table :data="scope.row.wxAccountList" style="width:360;height: 300px;overflow: auto;">
+            <el-table-column width="80" property="saleName" label="销售"></el-table-column>
+            <el-table-column width="180" property="wxAccount" label="微信号" align="center"></el-table-column>
+            <el-table-column width="80" property="fanNum" label="导粉量" align="center"></el-table-column>
           </el-table>
           <el-button slot="reference">详情</el-button>
           </el-popover>