导粉记录,订单条件筛选,食谱计划生成优化

This commit is contained in:
xiezhijun
2021-06-07 19:11:44 +08:00
parent 06d62ea4a0
commit 669bbfbf23
14 changed files with 190 additions and 53 deletions

View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -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