532 lines
30 KiB
XML
532 lines
30 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
||
<!DOCTYPE mapper
|
||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
<mapper namespace="com.stdiet.custom.mapper.SysOrderMapper">
|
||
|
||
<resultMap type="SysOrder" id="SysOrderResult">
|
||
<result property="orderId" column="order_id"/>
|
||
<result property="customer" column="customer"/>
|
||
<result property="cusId" column="cus_id"/>
|
||
<result property="phone" column="phone"/>
|
||
<result property="amount" column="amount"/>
|
||
<result property="weight" column="weight"/>
|
||
<result property="startTime" column="start_time"/>
|
||
<result property="pauseTime" column="pause_time"/>
|
||
<result property="status" column="status"/>
|
||
<result property="payTypeId" column="pay_type_id"/>
|
||
<result property="payType" column="pay_type"/>
|
||
<result property="preSaleId" column="pre_sale_id"/>
|
||
<result property="createBy" column="create_by"/>
|
||
<result property="createTime" column="create_time"/>
|
||
<result property="afterSaleId" column="after_sale_id"/>
|
||
<result property="updateBy" column="update_by"/>
|
||
<result property="updateTime" column="update_time"/>
|
||
<result property="nutritionistId" column="nutritionist_id"/>
|
||
<result property="remark" column="remark"/>
|
||
<result property="nutriAssisId" column="nutri_assis_id"/>
|
||
<result property="accountId" column="account_id"/>
|
||
<result property="account" column="account"/>
|
||
<result property="plannerId" column="planner_id"/>
|
||
<result property="plannerAssisId" column="planner_assis_id"/>
|
||
<result property="operatorId" column="operator_id"/>
|
||
<result property="operatorAssisId" column="operator_assis_id"/>
|
||
<result property="recommender" column="recommender"/>
|
||
<result property="orderTime" column="order_time"/>
|
||
<result property="serveTime" column="serve_time"/>
|
||
<result property="serveTimeId" column="serve_time_id"/>
|
||
<result property="reviewStatus" column="review_status"/>
|
||
<result property="giveServeDay" column="give_serve_day"/>
|
||
<result property="conditioningProjectId" column="conditioning_project_id"/>
|
||
<result property="serverEndTime" column="server_end_time"/>
|
||
<result property="becomeFanTime" column="become_fan_time"/>
|
||
|
||
<result property="onSaleId" column="on_sale_id"/>
|
||
<result property="orderType" column="order_type"/>
|
||
<result property="orderCountType" column="order_count_type"/>
|
||
<result property="orderMoneyType" column="order_money_type"/>
|
||
<result property="mainOrderId" column="main_order_id"/>
|
||
<result property="afterSaleCommissOrder" column="after_sale_commiss_order"/>
|
||
<result property="commissStartTime" column="commiss_start_time"/>
|
||
<result property="recipesPlanContinue" column="recipes_plan_continue" />
|
||
<result property="delFlag" column="del_flag"/>
|
||
<result property="counted" column="counted"/>
|
||
|
||
<!-- 非持久化字段 -->
|
||
<result property="afterSale" column="afterSale_name"></result><!-- 售后名称 -->
|
||
<result property="nutritionist" column="nutritionist_name"></result><!-- 营养师名称 -->
|
||
<result property="conditioningProject" column="conditioning_project"></result><!-- 调理项目 -->
|
||
</resultMap>
|
||
|
||
<sql id="selectSysOrderVo">
|
||
select o.order_id, o.review_status, o.cus_id, sc.name as customer, sc.phone, sc.fans_time as become_fan_time, o.amount, o.start_time, o.pause_time, o.status, o.weight, ser.dict_label as serve_time,
|
||
o.serve_time_id, o.pay_type_id, pay.dict_label as pay_type, o.pre_sale_id, o.create_by, o.create_time, o.after_sale_id, o.update_by, o.update_time,
|
||
o.nutritionist_id, o.remark, o.nutri_assis_id, o.account_id, acc.dict_label as account, o.planner_id, o.planner_assis_id, o.operator_id, o.operator_assis_id,
|
||
o.recommender, o.order_time,o.give_serve_day,o.conditioning_project_id,cp.dict_label as conditioning_project,o.server_end_time,
|
||
o.on_sale_id,o.order_type,o.order_count_type,o.order_money_type,o.main_order_id,o.after_sale_commiss_order,o.commiss_start_time, o.counted
|
||
from sys_order o
|
||
LEFT JOIN sys_customer sc ON sc.id = o.cus_id
|
||
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_pay_type') AS pay ON pay.dict_value = o.pay_type_id
|
||
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_account') AS acc ON acc.dict_value = o.account_id
|
||
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_serve_time') AS ser ON ser.dict_value = o.serve_time_id
|
||
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'conditioning_project') AS cp ON cp.dict_value = o.conditioning_project_id
|
||
</sql>
|
||
|
||
<sql id="searchOrderType">
|
||
<if test="searchOrderTypeArray != null">
|
||
<trim prefix="AND (" suffix=")" suffixOverrides="or">
|
||
<foreach collection="searchOrderTypeArray" separator="or" item="typeArray" index="i">
|
||
(
|
||
<foreach collection="typeArray" separator="and" item="type" index="j">
|
||
<if test="j == 0">
|
||
order_type = #{type}
|
||
</if>
|
||
<if test="j == 1">
|
||
order_count_type = #{type}
|
||
</if>
|
||
<if test="j == 2">
|
||
order_money_type = #{type}
|
||
</if>
|
||
</foreach>
|
||
)
|
||
</foreach>
|
||
</trim>
|
||
</if>
|
||
</sql>
|
||
|
||
<select id="selectAllOrderAmount" parameterType="SysOrder" resultType="BigDecimal">
|
||
SELECT SUM(amount) FROM sys_order
|
||
<where>
|
||
<if test="orderId != null and orderId != ''">and order_id = #{orderId}</if>
|
||
<if test="customer != null and customer != ''">
|
||
and (customer like concat('%',#{customer},'%') or phone like concat('%',#{customer},'%'))
|
||
</if>
|
||
<if test="accRange != null">
|
||
and account_id in
|
||
<foreach collection="accRange" separator="," item="acc" open="(" close=")" >
|
||
#{acc}
|
||
</foreach>
|
||
</if>
|
||
<if test="cusId != null and cusId != ''">and cus_id = #{cusId}</if>
|
||
<!-- <if test="phone != null and phone != ''">and phone = #{phone}</if>-->
|
||
<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="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>
|
||
<if test="accountId != null ">and account_id = #{accountId}</if>
|
||
<if test="plannerId != null ">and planner_id = #{plannerId}</if>
|
||
<if test="plannerAssisId != null ">and planner_assis_id = #{plannerAssisId}</if>
|
||
<if test="operatorId != null ">and operator_id = #{operatorId}</if>
|
||
<if test="operatorAssisId != null ">and operator_assis_id = #{operatorAssisId}</if>
|
||
<if test="recommender != null and recommender != ''">and recommender = #{recommender}</if>
|
||
<if test="beginTime != null and beginTime != ''">and date_format(order_time,'%y%m%d') >=
|
||
date_format(#{beginTime},'%y%m%d')
|
||
</if>
|
||
<if test="endTime != null and endTime != ''">and date_format(order_time,'%y%m%d') <=
|
||
date_format(#{endTime},'%y%m%d')
|
||
</if>
|
||
<if test="serveTimeId != null ">and serve_time_id = #{serveTimeId}</if>
|
||
<if test="reviewStatus != null ">and review_status = #{reviewStatus}</if>
|
||
<if test="amountFlag != null">
|
||
<if test="amountFlag == 0">
|
||
and amount >= 0
|
||
</if>
|
||
<if test="amountFlag == 1">
|
||
and 0 > amount
|
||
</if>
|
||
</if>
|
||
<include refid="searchOrderType">
|
||
<property name="reviewStatus" value="#{searchOrderTypeArray}"/>
|
||
</include>
|
||
<if test="true">and del_flag = 0</if>
|
||
<!-- 计算总额时需要除去二开售后提成单 -->
|
||
AND after_sale_commiss_order = 0
|
||
</where>
|
||
</select>
|
||
|
||
<select id="selectSysOrderList" parameterType="SysOrder" resultMap="SysOrderResult">
|
||
<include refid="selectSysOrderVo"/>
|
||
<where>
|
||
<if test="orderId != null and orderId != ''">and order_id = #{orderId}</if>
|
||
<if test="customer != null and customer != ''">
|
||
and (sc.name like concat('%',#{customer},'%') or sc.phone like concat('%',#{customer},'%'))
|
||
</if>
|
||
<if test="accRange != null">
|
||
and account_id in
|
||
<foreach collection="accRange" separator="," item="acc" open="(" close=")">
|
||
#{acc}
|
||
</foreach>
|
||
</if>
|
||
<if test="cusId != null and cusId != ''">and cus_id = #{cusId}</if>
|
||
<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="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>
|
||
<if test="nutriAssisId != null ">and nutri_assis_id = #{nutriAssisId}</if>
|
||
<if test="accountId != null ">and account_id = #{accountId}</if>
|
||
<if test="plannerId != null ">and planner_id = #{plannerId}</if>
|
||
<if test="plannerAssisId != null ">and planner_assis_id = #{plannerAssisId}</if>
|
||
<if test="operatorId != null ">and operator_id = #{operatorId}</if>
|
||
<if test="operatorAssisId != null ">and operator_assis_id = #{operatorAssisId}</if>
|
||
<if test="recommender != null and recommender != ''">and recommender = #{recommender}</if>
|
||
<if test="beginTime != null and beginTime != ''">and date_format(order_time,'%y%m%d') >=
|
||
date_format(#{beginTime},'%y%m%d')
|
||
</if>
|
||
<if test="endTime != null and endTime != ''">and date_format(order_time,'%y%m%d') <=
|
||
date_format(#{endTime},'%y%m%d')
|
||
</if>
|
||
<if test="serveTimeId != null ">and serve_time_id = #{serveTimeId}</if>
|
||
<if test="reviewStatus != null ">and review_status = #{reviewStatus}</if>
|
||
<if test="amountFlag != null">
|
||
<if test="amountFlag == 0">
|
||
and amount >= 0
|
||
</if>
|
||
<if test="amountFlag == 1">
|
||
and 0 > amount
|
||
</if>
|
||
</if>
|
||
<include refid="searchOrderType">
|
||
<property name="reviewStatus" value="#{searchOrderTypeArray}"/>
|
||
</include>
|
||
<if test="true">and o.del_flag = 0</if>
|
||
</where>
|
||
order by order_time desc
|
||
</select>
|
||
|
||
<select id="selectSysOrderById" parameterType="Long" resultMap="SysOrderResult">
|
||
<include refid="selectSysOrderVo"/>
|
||
where order_id = #{orderId} and o.del_flag = 0
|
||
</select>
|
||
|
||
<insert id="insertSysOrder" parameterType="SysOrder" useGeneratedKeys="true" keyProperty="orderId">
|
||
insert into sys_order
|
||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
<if test="orderId != null">order_id,</if>
|
||
<if test="customer != null and customer != ''">customer,</if>
|
||
<if test="cusId != null">cus_id,</if>
|
||
<if test="phone != null">phone,</if>
|
||
<if test="payTypeId != null">pay_type_id,</if>
|
||
<if test="reviewStatus != null">review_status,</if>
|
||
<if test="preSaleId != null">pre_sale_id,</if>
|
||
<if test="status != null">status,</if>
|
||
<if test="weight != null">weight,</if>
|
||
<if test="afterSaleId != null">after_sale_id,</if>
|
||
<if test="startTime != null">start_time,</if>
|
||
<if test="pauseTime != null">pause_time,</if>
|
||
<if test="nutritionistId != null">nutritionist_id,</if>
|
||
<if test="nutriAssisId != null">nutri_assis_id,</if>
|
||
<if test="onSaleId != null">on_sale_id,</if>
|
||
<if test="accountId != null">account_id,</if>
|
||
<if test="plannerId != null">planner_id,</if>
|
||
<if test="plannerAssisId != null">planner_assis_id,</if>
|
||
<if test="operatorAssisId != null">operator_assis_id,</if>
|
||
<if test="operatorId != null">operator_id,</if>
|
||
<if test="serveTimeId != null">serve_time_id,</if>
|
||
<if test="recommender != null">recommender,</if>
|
||
<if test="amount != null">amount,</if>
|
||
<if test="orderTime != null">order_time,</if>
|
||
<if test="createBy != null">create_by,</if>
|
||
<if test="createTime != null">create_time,</if>
|
||
<if test="updateBy != null">update_by,</if>
|
||
<if test="updateTime != null">update_time,</if>
|
||
<if test="remark != null">remark,</if>
|
||
<if test="giveServeDay != null">give_serve_day,</if>
|
||
<if test="conditioningProjectId != null">conditioning_project_id,</if>
|
||
<if test="serverEndTime != null">server_end_time,</if>
|
||
<if test="becomeFanTime != null">become_fan_time,</if>
|
||
<if test="orderType != null">order_type,</if>
|
||
<if test="orderCountType != null">order_count_type,</if>
|
||
<if test="orderMoneyType != null">order_money_type,</if>
|
||
<if test="mainOrderId != null">main_order_id,</if>
|
||
<if test="afterSaleCommissOrder != null">after_sale_commiss_order,</if>
|
||
<if test="commissStartTime != null">commiss_start_time,</if>
|
||
<if test="delFlag != null">del_flag,</if>
|
||
<if test="counted != null">counted,</if>
|
||
</trim>
|
||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
<if test="orderId != null">#{orderId},</if>
|
||
<if test="customer != null and customer != ''">#{customer},</if>
|
||
<if test="cusId != null">#{cusId},</if>
|
||
<if test="phone != null">#{phone},</if>
|
||
<if test="payTypeId != null">#{payTypeId},</if>
|
||
<if test="reviewStatus != null">#{reviewStatus},</if>
|
||
<if test="preSaleId != null">#{preSaleId},</if>
|
||
<if test="status != null">#{status},</if>
|
||
<if test="weight != null">#{weight},</if>
|
||
<if test="afterSaleId != null">#{afterSaleId},</if>
|
||
<if test="startTime != null">#{startTime},</if>
|
||
<if test="pauseTime != null">#{pauseTime},</if>
|
||
<if test="nutritionistId != null">#{nutritionistId},</if>
|
||
<if test="nutriAssisId != null">#{nutriAssisId},</if>
|
||
<if test="onSaleId != null">#{onSaleId},</if>
|
||
<if test="accountId != null">#{accountId},</if>
|
||
<if test="plannerId != null">#{plannerId},</if>
|
||
<if test="plannerAssisId != null">#{plannerAssisId},</if>
|
||
<if test="operatorAssisId != null">#{operatorAssisId},</if>
|
||
<if test="operatorId != null">#{operatorId},</if>
|
||
<if test="serveTimeId != null">#{serveTimeId},</if>
|
||
<if test="recommender != null">#{recommender},</if>
|
||
<if test="amount != null">#{amount},</if>
|
||
<if test="orderTime != null">#{orderTime},</if>
|
||
<if test="createBy != null">#{createBy},</if>
|
||
<if test="createTime != null">#{createTime},</if>
|
||
<if test="updateBy != null">#{updateBy},</if>
|
||
<if test="updateTime != null">#{updateTime},</if>
|
||
<if test="remark != null">#{remark},</if>
|
||
<if test="giveServeDay != null">#{giveServeDay},</if>
|
||
<if test="conditioningProjectId != null">#{conditioningProjectId},</if>
|
||
<if test="serverEndTime != null">#{serverEndTime},</if>
|
||
<if test="becomeFanTime != null">#{becomeFanTime},</if>
|
||
<if test="orderType != null">#{orderType},</if>
|
||
<if test="orderCountType != null">#{orderCountType},</if>
|
||
<if test="orderMoneyType != null">#{orderMoneyType},</if>
|
||
<if test="mainOrderId != null">#{mainOrderId},</if>
|
||
<if test="afterSaleCommissOrder != null">#{afterSaleCommissOrder},</if>
|
||
<if test="commissStartTime != null">#{commissStartTime},</if>
|
||
<if test="delFlag != null">#{delFlag},</if>
|
||
<if test="counted != null">#{counted},</if>
|
||
</trim>
|
||
</insert>
|
||
|
||
<update id="updateSysOrder" parameterType="SysOrder">
|
||
update sys_order
|
||
<trim prefix="SET" suffixOverrides=",">
|
||
<if test="customer != null and customer != ''">customer = #{customer},</if>
|
||
<if test="cusId != null">cus_id = #{cusId},</if>
|
||
<if test="phone != null">phone = #{phone},</if>
|
||
<if test="payTypeId != null">pay_type_id = #{payTypeId},</if>
|
||
<if test="reviewStatus != null">review_status = #{reviewStatus},</if>
|
||
<if test="preSaleId != null">pre_sale_id = #{preSaleId},</if>
|
||
<if test="status != null">status = #{status},</if>
|
||
<if test="weight != null">weight = #{weight},</if>
|
||
<if test="afterSaleId != null">after_sale_id = #{afterSaleId},</if>
|
||
<if test="startTime != null">start_time = #{startTime},</if>
|
||
<if test="pauseTime != null">pause_time = #{pauseTime},</if>
|
||
<if test="nutritionistId != null">nutritionist_id = #{nutritionistId},</if>
|
||
<if test="nutriAssisId != null">nutri_assis_id = #{nutriAssisId},</if>
|
||
<if test="onSaleId != null">on_sale_id = #{onSaleId},</if>
|
||
<if test="accountId != null">account_id = #{accountId},</if>
|
||
<if test="plannerId != null">planner_id = #{plannerId},</if>
|
||
<if test="plannerAssisId != null">planner_assis_id = #{plannerAssisId},</if>
|
||
<if test="operatorAssisId != null">operator_assis_id = #{operatorAssisId},</if>
|
||
<if test="operatorId != null">operator_id = #{operatorId},</if>
|
||
<if test="serveTimeId != null">serve_time_id = #{serveTimeId},</if>
|
||
<if test="recommender != null">recommender = #{recommender},</if>
|
||
<if test="amount != null">amount = #{amount},</if>
|
||
<if test="orderTime != null">order_time = #{orderTime},</if>
|
||
<if test="createBy != null">create_by = #{createBy},</if>
|
||
<if test="createTime != null">create_time = #{createTime},</if>
|
||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||
<if test="remark != null">remark = #{remark},</if>
|
||
<if test="giveServeDay != null">give_serve_day = #{giveServeDay},</if>
|
||
<if test="conditioningProjectId != null">conditioning_project_id = #{conditioningProjectId},</if>
|
||
<if test="serverEndTime != null">server_end_time = #{serverEndTime},</if>
|
||
<if test="becomeFanTime != null">become_fan_time = #{becomeFanTime},</if>
|
||
<if test="orderType != null">order_type = #{orderType},</if>
|
||
<if test="orderCountType != null">order_count_type = #{orderCountType},</if>
|
||
<if test="orderMoneyType != null">order_money_type = #{orderMoneyType},</if>
|
||
<if test="mainOrderId != null">main_order_id = #{mainOrderId},</if>
|
||
<if test="afterSaleCommissOrder != null">after_sale_commiss_order = #{afterSaleCommissOrder},</if>
|
||
<if test="commissStartTime != null">commiss_start_time = #{commissStartTime},</if>
|
||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||
<if test="counted != null">counted = #{counted},</if>
|
||
</trim>
|
||
where order_id = #{orderId}
|
||
</update>
|
||
|
||
<delete id="deleteSysOrderById" parameterType="Long">
|
||
update sys_order set del_flag = 1 where order_id = #{orderId}
|
||
</delete>
|
||
|
||
<delete id="deleteSysOrderByIds" parameterType="String">
|
||
<!-- delete from sys_order where order_id in-->
|
||
<!-- <foreach item="orderId" collection="array" open="(" separator="," close=")">-->
|
||
<!-- #{orderId}-->
|
||
<!-- </foreach>-->
|
||
</delete>
|
||
|
||
<resultMap type="SysOrder" id="SysOrderResultExtended">
|
||
<result property="orderId" column="order_id"/>
|
||
<result property="customer" column="customer"/>
|
||
<result property="cusId" column="cus_id"/>
|
||
<result property="phone" column="phone"/>
|
||
<result property="amount" column="amount"/>
|
||
<result property="weight" column="weight"/>
|
||
<result property="startTime" column="start_time"/>
|
||
<result property="pauseTime" column="pause_time"/>
|
||
<result property="status" column="status"/>
|
||
<result property="payTypeId" column="pay_type_id"/>
|
||
<result property="payType" column="pay_type"/>
|
||
<result property="preSaleId" column="pre_sale_id"/>
|
||
<result property="createBy" column="create_by"/>
|
||
<result property="createTime" column="create_time"/>
|
||
<result property="afterSaleId" column="after_sale_id"/>
|
||
<result property="updateBy" column="update_by"/>
|
||
<result property="updateTime" column="update_time"/>
|
||
<result property="nutritionistId" column="nutritionist_id"/>
|
||
<result property="remark" column="remark"/>
|
||
<result property="nutriAssisId" column="nutri_assis_id"/>
|
||
<result property="accountId" column="account_id"/>
|
||
<result property="account" column="account"/>
|
||
<result property="plannerId" column="planner_id"/>
|
||
<result property="plannerAssisId" column="planner_assis_id"/>
|
||
<result property="operatorId" column="operator_id"/>
|
||
<result property="operatorAssisId" column="operator_assis_id"/>
|
||
<result property="recommender" column="recommender"/>
|
||
<result property="orderTime" column="order_time"/>
|
||
<result property="serveTime" column="serve_time"/>
|
||
<result property="serveTimeId" column="serve_time_id"/>
|
||
<result property="reviewStatus" column="review_status"/>
|
||
<result property="giveServeDay" column="give_serve_day"/>
|
||
<result property="conditioningProjectId" column="conditioning_project_id"/>
|
||
<result property="serverEndTime" column="server_end_time"/>
|
||
<result property="becomeFanTime" column="become_fan_time"/>
|
||
|
||
<result property="onSaleId" column="on_sale_id"/>
|
||
<result property="orderType" column="order_type"/>
|
||
<result property="orderCountType" column="order_count_type"/>
|
||
<result property="orderMoneyType" column="order_money_type"/>
|
||
<result property="mainOrderId" column="main_order_id"/>
|
||
<result property="afterSaleCommissOrder" column="after_sale_commiss_order"/>
|
||
<result property="commissStartTime" column="commiss_start_time"/>
|
||
<result property="recipesPlanContinue" column="recipes_plan_continue" />
|
||
<result property="delFlag" column="del_flag"/>
|
||
|
||
<!-- 非持久化字段 -->
|
||
<result property="afterSale" column="afterSale_name"></result><!-- 售后名称 -->
|
||
<result property="nutritionist" column="nutritionist_name"></result><!-- 营养师名称 -->
|
||
<!--<association property="orderPauseList" column="order_id" select="getOrderPauseByOrderId"/>-->
|
||
</resultMap>
|
||
|
||
<resultMap type="SysOrderPause" id="SysOrderPauseResult">
|
||
<result property="id" column="id"/>
|
||
<result property="orderId" column="order_id"/>
|
||
<result property="pauseStartDate" column="pause_start_date"/>
|
||
<result property="pauseEndDate" column="pause_end_date"/>
|
||
<result property="reason" column="reason"/>
|
||
<result property="remarks" column="remarks"/>
|
||
<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"/>
|
||
</resultMap>
|
||
|
||
<select id="getOrderPauseByOrderId" parameterType="Long" resultMap="SysOrderPauseResult">
|
||
select id, order_id, pause_start_date, pause_end_date, reason, remarks, create_time, create_by, update_time, update_by, del_flag from sys_recipes_pause sop
|
||
where del_flag = 0 and order_id = #{order_id}
|
||
</select>
|
||
|
||
<!-- 查询2021年开始的已审核的订单信息(用于计算提成,请勿随意改动) -->
|
||
<select id="selectSimpleOrderMessage" resultMap="SysOrderResultExtended" parameterType="SysCommision">
|
||
select
|
||
o.order_id,o.order_time,o.commiss_start_time,o.server_end_time,o.customer,o.review_status,o.amount,o.serve_time_id,o.give_serve_day,o.after_sale_id,su_sale.nick_name
|
||
as afterSale_name,o.nutritionist_id,su_nutritionist.nick_name as nutritionist_name
|
||
from sys_order o
|
||
left join sys_user su_sale on su_sale.user_id = o.after_sale_id and su_sale.del_flag = 0
|
||
left join sys_user su_nutritionist on su_nutritionist.user_id = o.nutritionist_id and su_nutritionist.del_flag =
|
||
0
|
||
where o.order_time >= '2021-01-01' and o.del_flag = 0 and (su_sale.user_id is not null OR
|
||
su_nutritionist.user_id is not null)
|
||
and o.amount is not null
|
||
<if test="reviewStatus != null and reviewStatus != ''">
|
||
and review_status = #{reviewStatus}
|
||
</if>
|
||
<if test="userId != null"><!-- 限于营养师、售后不可能同一个的情况下 -->
|
||
and (su_sale.user_id = #{userId} or su_nutritionist.user_id = #{userId})
|
||
</if>
|
||
<if test="endTime != null and endTime != ''">
|
||
AND DATE_FORMAT(o.order_time,'%Y-%m-%d') <= #{endTime}
|
||
</if>
|
||
<if test="serverScopeEndTime != null and serverScopeEndTime != ''">
|
||
AND #{serverScopeEndTime} >= DATE_FORMAT(o.commiss_start_time,'%Y-%m-%d')
|
||
</if>
|
||
order by o.order_time desc
|
||
</select>
|
||
|
||
<!-- 查询2021年开始的已审核的订单信息的总条数(用于计算提成,请勿随意改动) -->
|
||
<select id="selectSimpleOrderMessageCount" resultType="int" parameterType="SysCommision">
|
||
select count(o.order_id) as orderCount
|
||
from sys_order o
|
||
left join sys_user su_sale on su_sale.user_id = o.after_sale_id and su_sale.del_flag = 0
|
||
left join sys_user su_nutritionist on su_nutritionist.user_id = o.nutritionist_id and su_nutritionist.del_flag =
|
||
0
|
||
where o.order_time >= '2021-01-01' and o.del_flag = 0 and (su_sale.user_id is not null OR
|
||
su_nutritionist.user_id is not null)
|
||
and o.amount is not null
|
||
<if test="reviewStatus != null and reviewStatus != ''">
|
||
and review_status = #{reviewStatus}
|
||
</if>
|
||
<if test="userId != null"><!-- 限于营养师、售后不可能同一个的情况下 -->
|
||
and (su_sale.user_id = #{userId} or su_nutritionist.user_id = #{userId})
|
||
</if>
|
||
<if test="endTime != null and endTime != ''">
|
||
AND DATE_FORMAT(o.order_time,'%Y-%m-%d') <= #{endTime}
|
||
</if>
|
||
<if test="serverScopeEndTime != null and serverScopeEndTime != ''">
|
||
AND #{serverScopeEndTime} >= DATE_FORMAT(o.commiss_start_time,'%Y-%m-%d')
|
||
</if>
|
||
order by o.order_time desc
|
||
</select>
|
||
|
||
<!-- 查询售后、营养师的每个月服务总金额 -->
|
||
<select id="getTotalAmountByUserId" parameterType="SysCommision"
|
||
resultType="com.stdiet.custom.dto.response.EveryMonthTotalAmount">
|
||
SELECT s.yearMonth,SUM(s.amount) AS totalAmount FROM
|
||
(
|
||
SELECT CONCAT(YEAR(o.order_time),'',MONTH(o.order_time)) AS yearMonth,o.amount
|
||
FROM sys_order o
|
||
LEFT JOIN sys_user su_sale ON su_sale.user_id = o.after_sale_id AND su_sale.del_flag = 0
|
||
LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = o.nutritionist_id AND su_nutritionist.del_flag =
|
||
0
|
||
where o.order_time >= '2021-01-01' and o.del_flag = 0 and (su_sale.user_id is not null OR
|
||
su_nutritionist.user_id is not null)
|
||
and o.amount is not null
|
||
<if test="reviewStatus != null and reviewStatus != ''">
|
||
and o.review_status = #{reviewStatus}
|
||
</if>
|
||
<if test="userId != null"><!-- 限于营养师、售后不可能同一个的情况下 -->
|
||
and (su_sale.user_id = #{userId} or su_nutritionist.user_id = #{userId})
|
||
</if>
|
||
<if test="endTime != null and endTime != ''">
|
||
AND DATE_FORMAT(o.order_time,'%Y-%m-%d') <= #{endTime}
|
||
</if>
|
||
ORDER BY o.order_time ASC
|
||
) s
|
||
GROUP BY s.yearMonth
|
||
</select>
|
||
|
||
<!-- 根据客户信息查询客户的订单列表数量 -->
|
||
<select id="getOrderCountByCustomer" parameterType="SysCustomer" resultType="int">
|
||
SELECT count(so.order_id) FROM sys_order so LEFT JOIN sys_customer sc ON sc.id = so.cus_id AND sc.del_flag = 0
|
||
WHERE so.del_flag = 0
|
||
<if test="phone != null and phone != ''">
|
||
and sc.phone = #{phone}
|
||
</if>
|
||
<if test="id != null">
|
||
and sc.id = #{id}
|
||
</if>
|
||
</select>
|
||
|
||
<!-- 根据客户ID查询该客户下所有订单 -->
|
||
<select id="getAllOrderByCusId" parameterType="Long" resultMap="SysOrderResult">
|
||
select * from sys_order where del_flag = 0 and cus_id = #{cusId} order by order_time asc
|
||
</select>
|
||
|
||
<!-- 根据微信openId查询客户订单数量 -->
|
||
<select id="getOrderCountByOpenId" parameterType="String" resultType="int">
|
||
select count(so.order_id) from sys_order so
|
||
where so.del_flag = 0 and so.cus_id is not null and so.cus_id = (select su.cus_id from sys_wx_user_info su where su.openid = #{openid} limit 1)
|
||
</select>
|
||
|
||
<!-- 根据营养师ID查询最后一单的情况 -->
|
||
<select id="getLastOrderByNutritionistId" parameterType="Long" resultMap="SysOrderResult">
|
||
select * from sys_order so
|
||
where del_flag = 0 and nutritionist_id = #{nutritionistId} order by order_id desc limit 1
|
||
</select>
|
||
</mapper> |