|
|
@@ -48,10 +48,12 @@
|
|
|
<result property="refundPrice" column="refund_price" />
|
|
|
<result property="returnPrice" column="return_price" />
|
|
|
<result property="refundTime" column="refund_time" />
|
|
|
+ <result property="rejectReturnTime" column="reject_return_time" />
|
|
|
<result property="orderType" column="order_type" />
|
|
|
<result property="auditor" column="auditor" />
|
|
|
<result property="auditTime" column="audit_time" />
|
|
|
<result property="diseaseName" column="disease_name" />
|
|
|
+ <result property="isReturnGoods" column="is_return_goods" />
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectFsExternalOrderVo">
|
|
|
@@ -62,7 +64,7 @@
|
|
|
remark, external_create_time, is_sync, sync_msg, create_time, create_by, update_time, update_by,
|
|
|
extend_order_id, store_id, receiver_phone,
|
|
|
collection_price, follow_time,
|
|
|
- refund_price, return_price, refund_time, order_type, auditor, audit_time, disease_name
|
|
|
+ refund_price, return_price, refund_time, reject_return_time, order_type, auditor, audit_time, disease_name, is_return_goods
|
|
|
from fs_external_order
|
|
|
</sql>
|
|
|
|
|
|
@@ -143,10 +145,12 @@
|
|
|
<if test="refundPrice != null">refund_price,</if>
|
|
|
<if test="returnPrice != null">return_price,</if>
|
|
|
<if test="refundTime != null">refund_time,</if>
|
|
|
+ <if test="rejectReturnTime != null">reject_return_time,</if>
|
|
|
<if test="orderType != null">order_type,</if>
|
|
|
<if test="auditor != null and auditor != ''">auditor,</if>
|
|
|
<if test="auditTime != null">audit_time,</if>
|
|
|
<if test="diseaseName != null and diseaseName != ''">disease_name,</if>
|
|
|
+ <if test="isReturnGoods != null">is_return_goods,</if>
|
|
|
create_by,
|
|
|
create_time
|
|
|
</trim>
|
|
|
@@ -189,10 +193,12 @@
|
|
|
<if test="refundPrice != null">#{refundPrice},</if>
|
|
|
<if test="returnPrice != null">#{returnPrice},</if>
|
|
|
<if test="refundTime != null">#{refundTime},</if>
|
|
|
+ <if test="rejectReturnTime != null">#{rejectReturnTime},</if>
|
|
|
<if test="orderType != null">#{orderType},</if>
|
|
|
<if test="auditor != null and auditor != ''">#{auditor},</if>
|
|
|
<if test="auditTime != null">#{auditTime},</if>
|
|
|
<if test="diseaseName != null and diseaseName != ''">#{diseaseName},</if>
|
|
|
+ <if test="isReturnGoods != null">#{isReturnGoods},</if>
|
|
|
#{createBy},
|
|
|
sysdate()
|
|
|
</trim>
|
|
|
@@ -239,10 +245,12 @@
|
|
|
<if test="refundPrice != null">refund_price = #{refundPrice},</if>
|
|
|
<if test="returnPrice != null">return_price = #{returnPrice},</if>
|
|
|
<if test="refundTime != null">refund_time = #{refundTime},</if>
|
|
|
+ <if test="rejectReturnTime != null">reject_return_time = #{rejectReturnTime},</if>
|
|
|
<if test="orderType != null">order_type = #{orderType},</if>
|
|
|
<if test="auditor != null and auditor != ''">auditor = #{auditor},</if>
|
|
|
<if test="auditTime != null">audit_time = #{auditTime},</if>
|
|
|
<if test="diseaseName != null">disease_name = #{diseaseName},</if>
|
|
|
+ <if test="isReturnGoods != null">is_return_goods = #{isReturnGoods},</if>
|
|
|
update_by = #{updateBy},
|
|
|
update_time = #{updateTime}
|
|
|
</trim>
|
|
|
@@ -301,6 +309,7 @@
|
|
|
o.deposit_return_time AS depositReturnTime,
|
|
|
o.refund_price AS refundPrice,
|
|
|
o.refund_time AS refundTime,
|
|
|
+ o.reject_return_time AS rejectReturnTime,
|
|
|
o.remark,
|
|
|
o.auditor,
|
|
|
o.audit_time AS auditTime,
|
|
|
@@ -397,9 +406,11 @@
|
|
|
o.deposit_return_time AS depositReturnTime,
|
|
|
o.refund_price AS refundPrice,
|
|
|
o.refund_time AS refundTime,
|
|
|
+ o.reject_return_time AS rejectReturnTime,
|
|
|
o.auditor,
|
|
|
o.audit_time AS auditTime,
|
|
|
o.disease_name AS diseaseName,
|
|
|
+ o.is_return_goods AS isReturnGoods,
|
|
|
o.external_create_time AS externalCreateTime,
|
|
|
o.create_time AS createTime,
|
|
|
c.company_name AS companyName,
|
|
|
@@ -468,11 +479,235 @@
|
|
|
</if>
|
|
|
<if test="deliveryStartTime != null and deliveryStartTime != ''"> AND o.delivery_time >= #{deliveryStartTime}</if>
|
|
|
<if test="deliveryEndTime != null and deliveryEndTime != ''"> AND o.delivery_time <= #{deliveryEndTime}</if>
|
|
|
- ${params.dataScope}
|
|
|
</where>
|
|
|
GROUP BY o.order_id
|
|
|
ORDER BY o.create_time DESC
|
|
|
</select>
|
|
|
|
|
|
+ <!-- 回款明细报表 - 回款时间维度 -->
|
|
|
+ <select id="selectReturnOrderReport" parameterType="FsExternalOrder" resultType="com.fs.his.domain.vo.FsReturnOrderReportVO">
|
|
|
+ SELECT
|
|
|
+ o.order_code AS orderCode,
|
|
|
+ o.delivery_sn AS deliverySn,
|
|
|
+ o.user_name AS userName,
|
|
|
+ o.user_address AS userAddress,
|
|
|
+ o.create_time AS externalCreateTime,
|
|
|
+ o.pay_price AS payPrice,
|
|
|
+ o.total_price AS totalPrice,
|
|
|
+ o.delivery_name AS deliveryName,
|
|
|
+ o.update_by AS returnUser,
|
|
|
+ o.update_time AS returnTime,
|
|
|
+ o.user_phone AS userPhone,
|
|
|
+ o.receiver_phone AS memberPhone,
|
|
|
+ cu.nick_name AS companyUserName,
|
|
|
+ d.dept_name AS deptName,
|
|
|
+ GROUP_CONCAT(oi.product_name SEPARATOR ',') AS productNames,
|
|
|
+ o.delivery_time AS deliveryTime
|
|
|
+ FROM fs_external_order o
|
|
|
+ LEFT JOIN company c ON o.company_id = c.company_id
|
|
|
+ LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
|
|
|
+ LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
|
|
|
+ LEFT JOIN fs_external_order_item oi ON o.order_id = oi.order_id
|
|
|
+ LEFT JOIN fs_user u ON o.user_id = u.user_id
|
|
|
+ <where>
|
|
|
+ o.status = 4
|
|
|
+ <if test="orderCode != null and orderCode != ''"> AND o.order_code = #{orderCode}</if>
|
|
|
+ <if test="deliverySn != null and deliverySn != ''"> AND o.delivery_sn = #{deliverySn}</if>
|
|
|
+ <if test="userName != null and userName != ''"> AND o.user_name LIKE CONCAT('%', #{userName}, '%')</if>
|
|
|
+ <if test="userAddress != null and userAddress != ''">
|
|
|
+ AND o.user_address LIKE CONCAT('%', #{userAddress}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="deliveryStartTime != null and deliveryStartTime != ''"> AND o.delivery_time >= #{deliveryStartTime}</if>
|
|
|
+ <if test="deliveryEndTime != null and deliveryEndTime != ''"> AND o.delivery_time <= #{deliveryEndTime}</if>
|
|
|
+ <if test="companyId != null"> AND o.company_id = #{companyId}</if>
|
|
|
+ </where>
|
|
|
+ GROUP BY o.order_id,o.update_time
|
|
|
+ ORDER BY o.order_id DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 回款明细报表 - 回款产品维度 -->
|
|
|
+ <select id="selectReturnProductReport" parameterType="FsExternalOrder" resultType="com.fs.his.domain.vo.FsReturnProductReportVO">
|
|
|
+ SELECT
|
|
|
+ d.dept_name AS deptName,
|
|
|
+ o.delivery_name AS deliveryName,
|
|
|
+ oi.product_name AS productName,
|
|
|
+ oi.product_id AS productId,
|
|
|
+ SUM(oi.num) AS num,
|
|
|
+ SUM(oi.price * oi.num) AS totalPrice
|
|
|
+ FROM fs_external_order o
|
|
|
+ LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
|
|
|
+ LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
|
|
|
+ INNER JOIN fs_external_order_item oi ON o.order_id = oi.order_id
|
|
|
+ <where>
|
|
|
+ o.status = 4
|
|
|
+ <if test="productName != null and productName != ''"> AND oi.product_name LIKE CONCAT('%', #{productName}, '%')</if>
|
|
|
+ </where>
|
|
|
+ GROUP BY d.dept_name, o.delivery_name, oi.product_id, oi.product_name
|
|
|
+ ORDER BY d.dept_name, o.delivery_name, oi.product_name
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 拒收明细报表 - 拒收退回日期时间维度 -->
|
|
|
+ <select id="selectRejectOrderReport" parameterType="FsExternalOrder" resultType="com.fs.his.domain.vo.FsRejectOrderReportVO">
|
|
|
+ SELECT
|
|
|
+ o.order_code AS orderCode,
|
|
|
+ o.delivery_sn AS deliverySn,
|
|
|
+ o.user_name AS userName,
|
|
|
+ o.create_time AS externalCreateTime,
|
|
|
+ o.delivery_time AS deliveryTime,
|
|
|
+ o.total_price AS totalPrice,
|
|
|
+ o.delivery_name AS deliveryName,
|
|
|
+ o.follow_time AS followTime,
|
|
|
+ o.reject_return_time AS rejectReturnTime,
|
|
|
+ o.update_by AS rejectUser,
|
|
|
+ o.user_phone AS userPhone,
|
|
|
+ o.receiver_phone AS memberPhone,
|
|
|
+ cu.nick_name AS companyUserName,
|
|
|
+ GROUP_CONCAT(oi.product_name SEPARATOR ',') AS productNames,
|
|
|
+ o.user_address AS userAddress
|
|
|
+ FROM fs_external_order o
|
|
|
+ LEFT JOIN company c ON o.company_id = c.company_id
|
|
|
+ LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
|
|
|
+ LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
|
|
|
+ LEFT JOIN fs_external_order_item oi ON o.order_id = oi.order_id
|
|
|
+ LEFT JOIN fs_user u ON o.user_id = u.user_id
|
|
|
+ <where>
|
|
|
+ o.delivery_status IN (4, 5, 6)
|
|
|
+ <if test="orderCode != null and orderCode != ''"> AND o.order_code = #{orderCode}</if>
|
|
|
+ <if test="deliverySn != null and deliverySn != ''"> AND o.delivery_sn = #{deliverySn}</if>
|
|
|
+ <if test="userName != null and userName != ''"> AND o.user_name LIKE CONCAT('%', #{userName}, '%')</if>
|
|
|
+ <if test="userAddress != null and userAddress != ''">
|
|
|
+ AND o.user_address LIKE CONCAT('%', #{userAddress}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="deliveryStartTime != null and deliveryStartTime != ''"> AND o.delivery_time >= #{deliveryStartTime}</if>
|
|
|
+ <if test="deliveryEndTime != null and deliveryEndTime != ''"> AND o.delivery_time <= #{deliveryEndTime}</if>
|
|
|
+ <if test="companyId != null"> AND o.company_id = #{companyId}</if>
|
|
|
+ </where>
|
|
|
+ GROUP BY o.order_id,o.reject_return_time
|
|
|
+ ORDER BY o.order_id DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 拒收明细报表 - 拒收产品维度 -->
|
|
|
+ <select id="selectRejectProductReport" parameterType="FsExternalOrder" resultType="com.fs.his.domain.vo.FsRejectProductReportVO">
|
|
|
+ SELECT
|
|
|
+ oi.product_name AS productName,
|
|
|
+ o.delivery_name AS deliveryName,
|
|
|
+ SUM(oi.num) AS num,
|
|
|
+ SUM(oi.price * oi.num) AS totalPrice,
|
|
|
+ oi.product_id AS productId
|
|
|
+ FROM fs_external_order o
|
|
|
+ LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
|
|
|
+ LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
|
|
|
+ INNER JOIN fs_external_order_item oi ON o.order_id = oi.order_id
|
|
|
+ <where>
|
|
|
+ o.delivery_status IN (4, 5, 6)
|
|
|
+ <if test="productName != null and productName != ''"> AND oi.product_name LIKE CONCAT('%', #{productName}, '%')</if>
|
|
|
+ <if test="companyId != null"> AND o.company_id = #{companyId}</if>
|
|
|
+ </where>
|
|
|
+ GROUP BY o.delivery_name, oi.product_id, oi.product_name
|
|
|
+ ORDER BY o.delivery_name, oi.product_name
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 签收未回款报表 -->
|
|
|
+ <select id="selectSignOrderReport" parameterType="FsExternalOrder" resultType="com.fs.his.domain.vo.FsSignOrderReportVO">
|
|
|
+ SELECT
|
|
|
+ o.order_code AS orderCode,
|
|
|
+ o.delivery_sn AS deliverySn,
|
|
|
+ o.user_name AS userName,
|
|
|
+ o.user_address AS userAddress,
|
|
|
+ o.delivery_time AS deliveryTime,
|
|
|
+ o.pay_price AS payPrice,
|
|
|
+ o.collection_price AS collectionPrice,
|
|
|
+ o.total_price AS totalPrice,
|
|
|
+ o.follow_time AS followTime,
|
|
|
+ o.delivery_name AS deliveryName,
|
|
|
+ d.dept_name AS deptName,
|
|
|
+ c.company_name AS companyName
|
|
|
+ FROM fs_external_order o
|
|
|
+ LEFT JOIN company c ON o.company_id = c.company_id
|
|
|
+ LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
|
|
|
+ LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
|
|
|
+ <where>
|
|
|
+ o.delivery_status = 3 AND o.status != 4
|
|
|
+ <if test="orderCode != null and orderCode != ''"> AND o.order_code = #{orderCode}</if>
|
|
|
+ <if test="deliverySn != null and deliverySn != ''"> AND o.delivery_sn = #{deliverySn}</if>
|
|
|
+ <if test="userName != null and userName != ''"> AND o.user_name LIKE CONCAT('%', #{userName}, '%')</if>
|
|
|
+ <if test="userAddress != null and userAddress != ''"> AND o.user_address LIKE CONCAT('%', #{userAddress}, '%')</if>
|
|
|
+ <if test="deliveryStartTime != null and deliveryStartTime != ''"> AND o.delivery_time >= #{deliveryStartTime}</if>
|
|
|
+ <if test="deliveryEndTime != null and deliveryEndTime != ''"> AND o.delivery_time <= #{deliveryEndTime}</if>
|
|
|
+ <if test="companyId != null"> AND o.company_id = #{companyId}</if>
|
|
|
+ </where>
|
|
|
+ ORDER BY o.order_id DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 拒收未还货报表 -->
|
|
|
+ <select id="selectRejectNoReturnReport" parameterType="FsExternalOrder" resultType="com.fs.his.domain.vo.FsRejectNoReturnReportVO">
|
|
|
+ SELECT
|
|
|
+ o.order_code AS orderCode,
|
|
|
+ o.delivery_sn AS deliverySn,
|
|
|
+ o.user_name AS userName,
|
|
|
+ o.user_address AS userAddress,
|
|
|
+ o.delivery_time AS deliveryTime,
|
|
|
+ o.total_price AS totalPrice,
|
|
|
+ o.follow_time AS followTime,
|
|
|
+ o.delivery_name AS deliveryName
|
|
|
+ FROM fs_external_order o
|
|
|
+ LEFT JOIN company c ON o.company_id = c.company_id
|
|
|
+ LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
|
|
|
+ LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
|
|
|
+ <where>
|
|
|
+ o.delivery_status = 4 AND (o.is_return_goods IS NULL OR o.is_return_goods = 2)
|
|
|
+ <if test="orderCode != null and orderCode != ''"> AND o.order_code = #{orderCode}</if>
|
|
|
+ <if test="deliverySn != null and deliverySn != ''"> AND o.delivery_sn = #{deliverySn}</if>
|
|
|
+ <if test="userName != null and userName != ''"> AND o.user_name LIKE CONCAT('%', #{userName}, '%')</if>
|
|
|
+ <if test="userAddress != null and userAddress != ''"> AND o.user_address LIKE CONCAT('%', #{userAddress}, '%')</if>
|
|
|
+ <if test="deliveryStartTime != null and deliveryStartTime != ''"> AND o.delivery_time >= #{deliveryStartTime}</if>
|
|
|
+ <if test="deliveryEndTime != null and deliveryEndTime != ''"> AND o.delivery_time <= #{deliveryEndTime}</if>
|
|
|
+ <if test="companyId != null"> AND o.company_id = #{companyId}</if>
|
|
|
+ </where>
|
|
|
+ ORDER BY o.order_id DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 签收情况明细表 -->
|
|
|
+ <select id="selectSignDetailReport" parameterType="FsExternalOrder" resultType="com.fs.his.domain.vo.FsSignDetailReportVO">
|
|
|
+ SELECT
|
|
|
+ t.order_type AS orderType,
|
|
|
+ t.delivery_count AS deliveryCount,
|
|
|
+ t.delivery_amount AS deliveryAmount,
|
|
|
+ t.sign_count AS signCount,
|
|
|
+ t.sign_amount AS signAmount,
|
|
|
+ CASE WHEN t.delivery_count > 0
|
|
|
+ THEN CONCAT(ROUND(t.sign_count * 100.0 / t.delivery_count, 2), '%')
|
|
|
+ ELSE '0%' END AS orderSignRate,
|
|
|
+ CASE WHEN t.delivery_amount > 0
|
|
|
+ THEN CONCAT(ROUND(t.sign_amount * 100.0 / t.delivery_amount, 2), '%')
|
|
|
+ ELSE '0%' END AS amountSignRate,
|
|
|
+ t.dept_name AS deptName,
|
|
|
+ t.company_name AS companyName
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ o.order_type AS order_type,
|
|
|
+ COUNT(o.order_id) AS delivery_count,
|
|
|
+ COALESCE(SUM(o.total_price), 0) AS delivery_amount,
|
|
|
+ COUNT(CASE WHEN o.delivery_status = 3 THEN 1 END) AS sign_count,
|
|
|
+ COALESCE(SUM(CASE WHEN o.delivery_status = 3 THEN o.total_price ELSE 0 END), 0) AS sign_amount,
|
|
|
+ d.dept_name AS dept_name,
|
|
|
+ c.company_name AS company_name
|
|
|
+ FROM fs_external_order o
|
|
|
+ LEFT JOIN company c ON o.company_id = c.company_id
|
|
|
+ LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
|
|
|
+ LEFT JOIN company_dept d ON cu.dept_id = d.dept_id
|
|
|
+ <where>
|
|
|
+ o.status >= 3
|
|
|
+ <if test="orderType != null"> AND o.order_type = #{orderType}</if>
|
|
|
+ <if test="companyId != null"> AND o.company_id = #{companyId}</if>
|
|
|
+ <if test="deptId != null"> AND cu.dept_id = #{deptId}</if>
|
|
|
+ <if test="sTime != null and sTime != ''"> AND o.external_create_time >= #{sTime}</if>
|
|
|
+ <if test="eTime != null and eTime != ''"> AND o.external_create_time <= #{eTime}</if>
|
|
|
+ </where>
|
|
|
+ GROUP BY d.dept_id, d.dept_name, c.company_id, c.company_name
|
|
|
+ ) t
|
|
|
+ ORDER BY t.company_name, t.dept_name, t.order_type
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|
|
|
|