From 669bbfbf232771d53c00e68462c5704530d17548 Mon Sep 17 00:00:00 2001
From: xiezhijun <15270898033@163.com>
Date: Mon, 7 Jun 2021 19:11:44 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E5=AF=BC=E7=B2=89=E8=AE=B0=E5=BD=95?=
 =?UTF-8?q?=EF=BC=8C=E8=AE=A2=E5=8D=95=E6=9D=A1=E4=BB=B6=E7=AD=9B=E9=80=89?=
 =?UTF-8?q?=EF=BC=8C=E9=A3=9F=E8=B0=B1=E8=AE=A1=E5=88=92=E7=94=9F=E6=88=90?=
 =?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../custom/SysImportFanRecordController.java  |  3 ++
 .../custom/domain/SysImportFanRecord.java     |  6 +++
 .../custom/domain/SysImportFanWxAccount.java  |  5 ++
 .../custom/mapper/SysRecipesPlanMapper.java   |  9 ++++
 .../service/ISysRecipesPlanService.java       |  8 +++
 .../impl/SysImportFanRecordServiceImpl.java   |  7 ++-
 .../impl/SysRecipesPlanServiceImpl.java       | 49 +++++++++++++++--
 .../custom/SysImportFanRecordMapper.xml       | 15 +++---
 .../custom/SysImportFanWxAccountMapper.xml    |  6 ++-
 .../mapper/custom/SysRecipesPlanMapper.xml    | 12 +++++
 .../mapper/custom/SysWxSaleAccountMapper.xml  |  3 +-
 .../ImportFanRecord/ImportFan/index.vue       | 52 +++++++++---------
 .../views/custom/importFanRecord/index.vue    | 15 ++++--
 stdiet-ui/src/views/custom/order/index.vue    | 53 ++++++++++++++++---
 14 files changed, 190 insertions(+), 53 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 c650fc92d..e9b01e4cf 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.DateUtils;
 import com.stdiet.common.utils.StringUtils;
 import com.stdiet.custom.domain.SysImportFanWxAccount;
 import com.stdiet.custom.domain.SysWxSaleAccount;
@@ -106,6 +107,7 @@ public class SysImportFanRecordController extends BaseController
             String[] importFanLiveArray = sysImportFanRecord.getImportFanLives().split(",");
             String[] wxAccountIdArray = sysImportFanRecord.getWxAccountIds().split(",");
             String[] fanNumArray = sysImportFanRecord.getFanNums().split(",");
+            String[] importTimeArray = sysImportFanRecord.getImportTimes().split(",");
             int index = -1;
             for (String importFanChannel : importFanChannelArray) {
                 index++;
@@ -116,6 +118,7 @@ public class SysImportFanRecordController extends BaseController
                 sysImportFanRecord.setImportFanLive(StringUtils.isEmpty(importFanLiveArray[index]) ? 0L : Long.parseLong(importFanLiveArray[index]));
                 sysImportFanRecord.setWxAccountId(Long.parseLong(wxAccountIdArray[index]));
                 sysImportFanRecord.setFanNum(Long.parseLong(fanNumArray[index]));
+                sysImportFanRecord.setImportTime(DateUtils.parseDate(importTimeArray[index]));
                 row = sysImportFanRecordService.insertSysImportFanRecord(sysImportFanRecord);
             }
         }else{
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 bd3480d6c..17b120ecd 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
@@ -39,6 +39,10 @@ public class SysImportFanRecord extends BaseEntity
     /** 删除标识,0未删除 1已删除 */
     private Long delFlag;
 
+    //导粉时间
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+    private Date importTime;
+
     //微信ID
     private Long wxAccountId;
 
@@ -62,6 +66,8 @@ public class SysImportFanRecord extends BaseEntity
 
     private String fanNums;
 
+    private String importTimes;
+
 
     //总进粉数量
     private Integer totalFanNum;
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 7ccf0a9ba..116f8fa7c 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
@@ -33,6 +33,11 @@ public class SysImportFanWxAccount extends BaseEntity
     @Excel(name = "导粉数量")
     private Long importFanNum;
 
+    /** 导粉时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+    @Excel(name = "导粉时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm")
+    private Date importTime;
+
     /** 删除标识 0未删除 1已删除 */
     private Long delFlag;
 
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanMapper.java
index 2b58ea0b1..65cb65f5d 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanMapper.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysRecipesPlanMapper.java
@@ -2,6 +2,8 @@ package com.stdiet.custom.mapper;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
+
 import com.stdiet.custom.domain.SysRecipesPlan;
 import com.stdiet.custom.domain.SysRecipesPlanListInfo;
 import org.apache.ibatis.annotations.Param;
@@ -117,4 +119,11 @@ public interface SysRecipesPlanMapper
      * @return
      */
     int updateMuchRecipesPlanDate(SysRecipesPlan sysRecipesPlan);
+
+    /**
+     * 查询食谱计划中对应食谱存在天数缺失的食谱计划
+     * @param cusId
+     * @return
+     */
+    List<Map<String,Object>> getNeedSupplyRecipesByCusId(@Param("cusId")Long cusId);
 }
\ No newline at end of file
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanService.java
index 8a86d0858..634f5cb07 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanService.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysRecipesPlanService.java
@@ -2,6 +2,7 @@ package com.stdiet.custom.service;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 import com.stdiet.custom.domain.SysRecipesPlan;
 import com.stdiet.custom.domain.SysRecipesPlanListInfo;
@@ -122,4 +123,11 @@ public interface ISysRecipesPlanService
      */
     List<SysRecipesPlan> selectPlanListByCusId(Long cusId);
 
+    /**
+     * 查询食谱计划中对应食谱存在天数缺失的食谱计划
+     * @param cusId
+     * @return
+     */
+    List<Map<String,Object>> getNeedSupplyRecipesByCusId(Long cusId);
+
 }
\ 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 9c5fb2be2..362353db3 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
@@ -72,15 +72,18 @@ public class SysImportFanRecordServiceImpl implements ISysImportFanRecordService
             sysImportFanWxAccount.setImportFanRecordId(record != null ? record.getId() : sysImportFanRecord.getId());
             sysImportFanWxAccount.setImportWxAccountId(sysImportFanRecord.getWxAccountId());
             sysImportFanWxAccount.setImportFanNum(sysImportFanRecord.getFanNum());
+            sysImportFanWxAccount.setImportTime(sysImportFanRecord.getImportTime());
             sysImportFanWxAccount.setCreateTime(new Date());
+            row = sysImportFanWxAccountService.insertSysImportFanWxAccount(sysImportFanWxAccount);
+
             //根据微信号、导粉记录查询是否存在
-            SysImportFanWxAccount oldFanWxAccount = sysImportFanWxAccountService.getWxAccountByFanRecordId(sysImportFanWxAccount);
+            /*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/SysRecipesPlanServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java
index dc91bcc46..8186cd083 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java
@@ -4,10 +4,8 @@ import com.stdiet.common.utils.DateUtils;
 import com.stdiet.common.utils.StringUtils;
 import com.stdiet.common.utils.SynchrolockUtil;
 import com.stdiet.common.utils.sign.Md5Utils;
-import com.stdiet.custom.domain.SysOrder;
-import com.stdiet.custom.domain.SysOrderPause;
-import com.stdiet.custom.domain.SysRecipesPlan;
-import com.stdiet.custom.domain.SysRecipesPlanListInfo;
+import com.stdiet.custom.domain.*;
+import com.stdiet.custom.mapper.SysRecipesMapper;
 import com.stdiet.custom.mapper.SysRecipesPlanMapper;
 import com.stdiet.custom.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,6 +41,8 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
     private IWechatAppletService wechatAppletService;
     @Autowired
     private ISysCustomerService sysCustomerService;
+    @Autowired
+    private SysRecipesMapper sysRecipesMapper;
 
     /**
      * 查询食谱计划
@@ -151,7 +151,7 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
     @Async
     public void regenerateRecipesPlan(Long cusId) {
         try {
-            Thread.sleep(5000);
+            Thread.sleep(3000);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -196,6 +196,8 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
                             }
                         }
                     }
+                    //食谱计划更新完成之后需要查询是否存在天数缺失情况,进行补充
+                    supplyRecipesBmenu(cusId);
                 }
             }
         } catch (Exception e) {
@@ -206,6 +208,34 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
         }
     }
 
+    /**
+     * 查询食谱计划中对应食谱存在天数缺失的食谱计划,食谱计划发生变化时,可能会导致sys_customer_daily_menu表中天数缺失,需要查询出来进行补充
+     * @param cusId 客户ID
+     */
+    private void supplyRecipesBmenu(Long cusId){
+        List<Map<String,Object>> list = getNeedSupplyRecipesByCusId(cusId);
+        if(list != null && list.size() > 0){
+            for (Map<String,Object> map : list) {
+                Long recipesId = (Long)map.get("recipesId");
+                Integer enNumDay = (Integer)map.get("enNumDay");
+                Integer maxNumDay = (Integer)map.get("maxNumDay");
+                if(recipesId != null && enNumDay != null && maxNumDay != null){
+                    List<SysRecipesDaily> menus = new ArrayList<>();
+                    for (int i = maxNumDay+1; i <= enNumDay; i++) {
+                        SysRecipesDaily daily = new SysRecipesDaily();
+                        daily.setCusId(cusId);
+                        daily.setNumDay(i);
+                        daily.setRecipesId(recipesId);
+                        menus.add(daily);
+                    }
+                    sysRecipesMapper.bashAddMenus(menus);
+                }
+            }
+        }
+    }
+
+
+
     /**
      * 更新食谱计划,删除旧食谱中多余的,添加新食谱中多的
      *
@@ -474,4 +504,13 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
         }
     }
 
+    /**
+     * 查询食谱计划中对应食谱存在天数缺失的食谱计划
+     * @param cusId
+     * @return
+     */
+    public List<Map<String,Object>> getNeedSupplyRecipesByCusId(Long cusId){
+        return sysRecipesPlanMapper.getNeedSupplyRecipesByCusId(cusId);
+    }
+
 }
\ 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 f7966e605..e8bf59c8b 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanRecordMapper.xml
@@ -58,12 +58,13 @@
     </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 ifnull(sum(fwa.import_fan_num),0) from sys_import_fan_wx_account fwa
+        where fwa.del_flag = 0 and fwa.import_fan_record_id in
+        (
+          select fc.id from sys_import_fan_record as fc 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">
@@ -129,7 +130,7 @@
 
     <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
+        DATE_FORMAT(fwc.import_time,'%Y-%m-%d %H:%i') as importTime,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
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml
index 3696cf7eb..071fa46dd 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysImportFanWxAccountMapper.xml
@@ -9,6 +9,7 @@
         <result property="importFanRecordId"    column="import_fan_record_id"    />
         <result property="importWxAccountId"    column="import_wx_account_id"    />
         <result property="importFanNum"    column="import_fan_num"    />
+        <result property="importTime"    column="import_time"    />
         <result property="createTime"    column="create_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateTime"    column="update_time"    />
@@ -17,7 +18,7 @@
     </resultMap>
 
     <sql id="selectSysImportFanWxAccountVo">
-        select id, import_fan_record_id, import_wx_account_id, import_fan_num, create_time, create_by, update_time, update_by, del_flag from sys_import_fan_wx_account
+        select id, import_fan_record_id, import_wx_account_id, import_fan_num,import_time, create_time, create_by, update_time, update_by, del_flag from sys_import_fan_wx_account
     </sql>
 
     <select id="selectSysImportFanWxAccountList" parameterType="SysImportFanWxAccount" resultMap="SysImportFanWxAccountResult">
@@ -38,6 +39,7 @@
             <if test="importFanRecordId != null">import_fan_record_id,</if>
             <if test="importWxAccountId != null">import_wx_account_id,</if>
             <if test="importFanNum != null">import_fan_num,</if>
+            <if test="importTime != null">import_time,</if>
             <if test="createTime != null">create_time,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateTime != null">update_time,</if>
@@ -48,6 +50,7 @@
             <if test="importFanRecordId != null">#{importFanRecordId},</if>
             <if test="importWxAccountId != null">#{importWxAccountId},</if>
             <if test="importFanNum != null">#{importFanNum},</if>
+            <if test="importTime != null">#{importTime},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
@@ -62,6 +65,7 @@
             <if test="importFanRecordId != null">import_fan_record_id = #{importFanRecordId},</if>
             <if test="importWxAccountId != null">import_wx_account_id = #{importWxAccountId},</if>
             <if test="importFanNum != null">import_fan_num = #{importFanNum},</if>
+            <if test="importTime != null">import_time = #{importTime},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml
index f503ec720..46680babf 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml
@@ -284,4 +284,16 @@
         update sys_recipes_plan set start_date = #{startDate},end_date = #{endDate},pause_date=#{pauseDate} where id =
         #{id}
     </update>
+
+    <!-- 查询食谱计划中对应食谱存在天数缺失的食谱计划,食谱计划发生变化时,可能会导致sys_customer_daily_menu表中天数缺失,需要查询出来进行补充 -->
+    <select id="getNeedSupplyRecipesByCusId" parameterType="Long" resultType="Map">
+        select plan.recipes_id as recipesId,plan.end_num_day as enNumDay,s.maxNumDay from sys_recipes_plan as plan left join
+
+        (
+          select recipes_id,count(1) as dayNum,max(num_day) as maxNumDay from sys_customer_daily_menu where cus_id = #{cusId} and recipes_id is not null group by recipes_id
+        )
+        as s on s.recipes_id = plan.recipes_id
+
+        where plan.cus_id = #{cusId} and plan.del_flag = 0 and plan.recipes_id is not null and plan.end_num_day > s.maxNumDay
+    </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 992f0268c..01e783407 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml
@@ -22,6 +22,7 @@
 
         <!-- 销售 -->
         <result property="saleName" column="sale_name"></result>
+        <result property="channel" column="channel"></result>
     </resultMap>
 
     <sql id="selectSysWxSaleAccountVo">
@@ -140,7 +141,7 @@
 
     <!-- 查询可以接粉的微信号以及对应销售,用于导粉记录管理 -->
     <select id="getWxAccountAndSale" resultMap="SysWxSaleAccountResult">
-        select wa.id, wa.wx_account, su.nick_name as sale_name
+        select wa.id, wa.wx_account, swd.account_id as channel, 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
diff --git a/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue b/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
index 5c7d93124..6b2b3df6c 100644
--- a/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
+++ b/stdiet-ui/src/components/ImportFanRecord/ImportFan/index.vue
@@ -4,7 +4,7 @@
     <el-dialog :title="title" :visible.sync="open" width="1050px" :close-on-click-modal="false" append-to-body @closed="cancel">
       <!--<div style="margin-bottom: 20px;color:red">1、添加导粉记录时会根据进粉渠道、当前时间来自动确定所属直播间,当前时间段没有直播,则取上一次直播,若账号从未直播过,则为空</div>-->
         <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
-      <!--<el-form-item label="账号渠道" prop="channel">
+      <el-form-item label="账号渠道" prop="channel">
           <el-select
               v-model="queryParams.channel"
               placeholder="请选择账号渠道"
@@ -19,7 +19,7 @@
                 :value="parseInt(dict.dictValue)"
               />
             </el-select>
-        </el-form-item>-->
+        </el-form-item>
         <el-form-item label="销售" prop="saleId" label-width="50px">
           <el-select
               v-model="queryParams.saleId"
@@ -89,20 +89,15 @@
                 </el-table-column>-->
                  <el-table-column label="导粉时间" align="center" prop="fanTime" width="240">
                    <template slot-scope="scope">
-                  <el-date-picker
-                    v-model="scope.row.fanTime"
-                    type="datetime"
-                    placeholder="选择导粉时间"
-                    format="yyyy-MM-dd HH:mm"
+                  <el-time-picker
                     value-format="yyyy-MM-dd HH:mm"
-                    :picker-options="fanPickerOptions"
+                    v-model="scope.row.fanTime"
+                    placeholder="选择导粉时间"
                     @change="autoSelectLive(scope.row)"
                   >
-                  </el-date-picker>
+                  </el-time-picker>
                    </template>
                 </el-table-column>
-                
-
                 <el-table-column label="导粉数量" align="center" prop="fanNum" width="180">
                     <template slot-scope="scope">
                             <el-input-number v-model="scope.row.fanNum" :min="1" :max="10000" label="导粉数量" style="width:160px"></el-input-number>
@@ -227,9 +222,9 @@ export default {
             response.data.wxSaleAccountList.forEach((item,index) => {
                 item.fanNum = 1;
                 //item.importFanNum =  this.getTotalFanNum(response.data.fanNumList, item.id);
-                item.importFanChannel = null;
+                item.importFanChannel = item.channel ? item.channel : null;
                 item.importFanLive = null;
-                item.fanTime = null;
+                item.fanTime = null;           
             });
             this.wxAccountList = response.data.wxSaleAccountList;
             //this.fanNumList = response.data.fanNumList;
@@ -297,14 +292,16 @@ export default {
           'importFanChannel': row.importFanChannel,
           'importFanLive': row.importFanLive,
           'wxAccountId': row.id,
-          'fanNum': row.fanNum
+          'fanNum': row.fanNum,
+          "importTime": row.fanTime
         }
         addImportFanRecord(param).then((response) => {
             if(response.code == 200){
                 this.msgSuccess("保存成功");
-                row.importFanChannel = null;
+                //row.importFanChannel = null;
                 row.importFanLive = null;
                 row.importFanNum += row.fanNum;
+                row.fanTime = null;
                 row.fanNum = 1;
                 this.importFanFlag = true;
             }
@@ -321,17 +318,19 @@ export default {
         }
         let param = {
           'importFanDate': this.data.importFanDate,
-          'importFanChannels': null,
-          'importFanLives': null,
-          'wxAccountIds': null,
-          'fanNums': null
+          'importFanChannels': "",
+          'importFanLives': "",
+          'wxAccountIds': "",
+          'fanNums': "",
+          "importTimes": ""
         }
         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(item.fanTime != undefined && item.fanTime != null && item.fanTime != ""){
+              param.importFanChannels += index != 0 ? (","+this.nullToString(item.importFanChannel)) : item.importFanChannel;
+              param.importFanLives += index != 0 ? (","+this.nullToString(item.importFanLive)) : item.importFanLive;
+              param.wxAccountIds += index != 0 ? (","+this.nullToString(item.id)) : item.id;
+              param.fanNums += index != 0 ? (","+this.nullToString(item.fanNum)) : item.fanNum;
+              param.importTimes += index != 0 ? (","+this.nullToString(item.fanTime)) : item.fanTime;
             }
             if(index == this.wxAccountList.length -1){
                 if(param.importFanChannels == null){
@@ -347,9 +346,10 @@ export default {
                             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].importFanChannel = null;
                                   this.wxAccountList[i].importFanNum += this.wxAccountList[i].fanNum;
                                   this.wxAccountList[i].fanNum = 1;
+                                  this.wxAccountList[i].fanTime = null;
                                   //this.$set('wxAccountList', index, item);
                             }
                         }
@@ -366,6 +366,8 @@ export default {
            row.importFanLive = null;
            return;
         }
+        row.fanTime = this.data.importFanDate + " " + row.fanTime.substring(row.fanTime.length - 5);
+        //console.log(row.fanTime);
         getLiveSchedulByTime({'fanChannel':row.importFanChannel,'liveStartTimeString':encodeURIComponent(row.fanTime)}).then((response) => {
               if (response.code === 200) {
                  let live = response.data;
diff --git a/stdiet-ui/src/views/custom/importFanRecord/index.vue b/stdiet-ui/src/views/custom/importFanRecord/index.vue
index a236280e7..56ce518c7 100644
--- a/stdiet-ui/src/views/custom/importFanRecord/index.vue
+++ b/stdiet-ui/src/views/custom/importFanRecord/index.vue
@@ -92,10 +92,15 @@
           <span>{{ parseTime(scope.row.importFanDate, '{y}-{m}-{d}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="进粉账号渠道" align="center" prop="importFanChannelName" />
+      <el-table-column label="账号渠道" align="center" prop="importFanChannelName" />
       <el-table-column label="所属直播间" align="center" prop="liveRoomName" >
         <template slot-scope="scope">
-            {{(scope.row.liveRoomName != null || scope.row.liveNutritionistName != null) ? (scope.row.liveRoomName + "—" + scope.row.liveNutritionistName) : ""}}
+            {{(scope.row.liveRoomName != null ? scope.row.liveRoomName : "无")}}
+        </template>
+      </el-table-column>
+      <el-table-column label="直播营养师" align="center" prop="liveNutritionistName" >
+        <template slot-scope="scope">
+            {{scope.row.liveNutritionistName != null ? scope.row.liveNutritionistName : "无"}}
         </template>
       </el-table-column>
       <el-table-column label="导粉总数" align="center" prop="wxAccountList" :formatter="getTotalFanNum">
@@ -104,9 +109,9 @@
         <template slot-scope="scope">
           <el-popover
           placement="left"
-          width="520"
+          width="700"
           trigger="click">
-          <el-table :data="scope.row.wxAccountList" style="width:450;height: 400px;overflow: auto;">
+          <el-table :data="scope.row.wxAccountList" style="width:700;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="120" property="importFanNum" label="导粉数量" align="center">
@@ -119,6 +124,8 @@
                   </div>
                 </template>
             </el-table-column>
+            <el-table-column width="160" property="importTime" label="导粉时间" align="center">     
+            </el-table-column>
             <el-table-column width="120" label="操作" align="center">
               <template slot-scope="scope">
                 <el-button
diff --git a/stdiet-ui/src/views/custom/order/index.vue b/stdiet-ui/src/views/custom/order/index.vue
index 16581d1f1..1973a1abb 100644
--- a/stdiet-ui/src/views/custom/order/index.vue
+++ b/stdiet-ui/src/views/custom/order/index.vue
@@ -88,6 +88,24 @@
             </el-select>
           </el-form-item>
         </el-col>
+        <el-col :span="6" v-if="!isPartner">
+          <el-form-item label="售中" prop="onSaleId">
+            <el-select
+              v-model="queryParams.onSaleId"
+              placeholder="请选择售中"
+              clearable
+              filterable
+              size="small"
+            >
+              <el-option
+                v-for="dict in onSaleIdOptions"
+                :key="dict.dictValue"
+                :label="dict.dictLabel"
+                :value="parseInt(dict.dictValue)"
+              />
+            </el-select>
+          </el-form-item>
+        </el-col>
         <el-col :span="6" v-if="!isPartner">
           <el-form-item label="售后" prop="afterSaleId">
             <el-select
@@ -248,7 +266,7 @@
             </el-select>
           </el-form-item>
         </el-col>
-        <el-col :span="12">
+        <el-col :span="6">
           <el-form-item label="订单类型" prop="searchOrderTypeArray">
             <el-cascader
               placeholder="请选择订单类型"
@@ -257,13 +275,13 @@
               :props="orderTypeProps"
               collapse-tags
               clearable
-              style="width: 300px"
             ></el-cascader> </el-form-item
           ><!--   -->
         </el-col>
-        <el-col :span="12">
+        <el-col :span="20">
           <el-form-item label="成交日期" prop="orderTime">
             <el-date-picker
+              style="width:300px"
               v-model="daterange"
               type="daterange"
               size="small"
@@ -276,10 +294,7 @@
             >
             </el-date-picker>
           </el-form-item>
-        </el-col>
-
-        <el-col>
-          <el-form-item>
+          <el-form-item style="margin-left:50px">
             <el-button
               type="cyan"
               icon="el-icon-search"
@@ -292,6 +307,20 @@
             </el-button>
           </el-form-item>
         </el-col>
+        <!--<el-col>
+          <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-col>-->
       </el-form>
     </el-row>
 
@@ -337,9 +366,11 @@
         width="100"
       >
         <template slot-scope="scope">
+          <div v-if="scope.row.orderTime != undefined && scope.row.orderTime != null">
           <div v-for="time in scope.row.orderTime.split(' ')" :key="time">
             {{ time }}
           </div>
+          </div>
         </template>
       </el-table-column>
       <el-table-column
@@ -362,7 +393,11 @@
         width="90"
       />
       <el-table-column label="服务时长" align="center" prop="serveTime" />
-      <el-table-column label="销售" align="center" prop="preSale" />
+      <el-table-column label="销售/售中" align="center" prop="preSale" >
+          <template slot-scope="scope">
+              {{ scope.row.preSaleId ? scope.row.preSale : scope.row.onSale }}
+          </template>
+      </el-table-column>
       <el-table-column
         v-if="!isMobile"
         label="售后"
@@ -561,6 +596,7 @@ export default {
         phone: null,
         payTypeId: null,
         preSaleId: null,
+        onSaleId: null,
         afterSaleId: null,
         nutritionistId: null,
         nutriAssisId: null,
@@ -592,6 +628,7 @@ export default {
     ...mapGetters([
       // 售前字典
       "preSaleIdOptions",
+      "onSaleIdOptions",
       // 售后字典
       "afterSaleIdOptions",
       // 主营养师字典

From bedd258c0461ceb456b91f28620e4feda8115ddf Mon Sep 17 00:00:00 2001
From: xiezhijun <15270898033@163.com>
Date: Mon, 7 Jun 2021 19:17:41 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=A2=E5=8D=95?=
 =?UTF-8?q?=E6=9F=A5=E8=AF=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../src/main/resources/mapper/custom/SysOrderMapper.xml     | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysOrderMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysOrderMapper.xml
index 0fcded09f..7ff8d86ec 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysOrderMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysOrderMapper.xml
@@ -113,6 +113,9 @@
             <if test="status != null ">and status = #{status}</if>
             <if test="payTypeId != null ">and pay_type_id = #{payTypeId}</if>
             <if test="preSaleId != null ">and pre_sale_id = #{preSaleId}</if>
+            <if test="onSaleId != null">
+                and on_sale_id = #{onSaleId}
+            </if>
             <if test="afterSaleId != null ">and after_sale_id = #{afterSaleId}</if>
             <if test="nutritionistId != null ">and nutritionist_id = #{nutritionistId}</if>
             <if test="nutriAssisId != null ">and nutri_assis_id = #{nutriAssisId}</if>
@@ -164,6 +167,9 @@
             <if test="phone != null  and phone != ''">and sc.phone = #{phone}</if>
             <if test="status != null ">and status = #{status}</if>
             <if test="payTypeId != null ">and pay_type_id = #{payTypeId}</if>
+            <if test="onSaleId != null">
+                and on_sale_id = #{onSaleId}
+            </if>
             <if test="preSaleId != null ">and pre_sale_id = #{preSaleId}</if>
             <if test="afterSaleId != null ">and after_sale_id = #{afterSaleId}</if>
             <if test="nutritionistId != null ">and nutritionist_id = #{nutritionistId}</if>