|
|
@@ -323,6 +323,7 @@
|
|
|
WHEN 2 THEN '审核通过'
|
|
|
WHEN 3 THEN '已发货'
|
|
|
WHEN 4 THEN '已回款'
|
|
|
+ WHEN -4 THEN '订单拒收'
|
|
|
WHEN -3 THEN '已取消'
|
|
|
ELSE '未知'
|
|
|
END AS statusDesc,
|
|
|
@@ -830,5 +831,338 @@
|
|
|
ORDER BY t.company_name, t.dept_name, t.order_type
|
|
|
</select>
|
|
|
|
|
|
+ <!-- ========== 合计行查询(整个数据集汇总,非当前页) ========== -->
|
|
|
+
|
|
|
+ <select id="selectExternalOrderListVOSum" parameterType="FsExternalOrder" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ SUM(t.totalPrice) AS totalPrice,
|
|
|
+ SUM(t.receivablePrice) AS receivablePrice,
|
|
|
+ SUM(t.payPrice) AS payPrice,
|
|
|
+ SUM(t.collectionPrice) AS collectionPrice,
|
|
|
+ SUM(t.refundPrice) AS refundPrice,
|
|
|
+ SUM(t.memberBuyCount) AS memberBuyCount
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ o.total_price AS totalPrice,
|
|
|
+ IFNULL(o.total_price, SUM(oi.price * oi.num)) AS receivablePrice,
|
|
|
+ o.pay_price AS payPrice,
|
|
|
+ o.collection_price AS collectionPrice,
|
|
|
+ o.refund_price AS refundPrice,
|
|
|
+ (SELECT COUNT(DISTINCT o2.order_id) FROM fs_external_order o2
|
|
|
+ WHERE o2.user_id = o.user_id AND o2.company_id = o.company_id AND o2.status != -3) AS memberBuyCount
|
|
|
+ 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_store_order_finance_audit fa ON fa.order_id = o.order_id AND fa.order_type = 0 AND fa.audit_status = 0
|
|
|
+ LEFT JOIN fs_user u ON o.user_id = u.user_id
|
|
|
+ LEFT JOIN fs_user_address ua ON ua.address_id = (
|
|
|
+ SELECT ua2.address_id
|
|
|
+ FROM fs_user_address ua2
|
|
|
+ WHERE ua2.user_id = o.user_id AND IFNULL(ua2.is_del, 0) = 0
|
|
|
+ ORDER BY ua2.is_default DESC, ua2.update_time DESC, ua2.create_time DESC, ua2.address_id DESC
|
|
|
+ LIMIT 1
|
|
|
+ )
|
|
|
+ <where>
|
|
|
+ <if test="orderCode != null and orderCode != ''"> AND o.order_code = #{orderCode}</if>
|
|
|
+ <if test="userId != null"> AND o.user_id = #{userId}</if>
|
|
|
+ <if test="companyUserId != null"> AND o.company_user_id = #{companyUserId}</if>
|
|
|
+ <if test="companyUserName != null and companyUserName != ''"> AND cu.user_name LIKE CONCAT('%', #{companyUserName}, '%')</if>
|
|
|
+ <if test="deptId != null"> AND cu.dept_id = #{deptId}</if>
|
|
|
+ <if test="userName != null and userName != ''"> AND o.user_name LIKE CONCAT('%', #{userName}, '%')</if>
|
|
|
+ <if test="userPhone != null and userPhone != ''"> AND o.user_phone = #{userPhone}</if>
|
|
|
+ <if test="memberPhone != null and memberPhone != ''"> AND u.phone = #{memberPhone}</if>
|
|
|
+ <if test="memberName != null and memberName != ''"> AND u.nick_name LIKE CONCAT('%', #{memberName}, '%')</if>
|
|
|
+ <if test="memberSex != null"> AND u.sex = #{memberSex}</if>
|
|
|
+ <if test="memberAge != null"> AND TIMESTAMPDIFF(YEAR, FROM_UNIXTIME(u.birthday), CURDATE()) = #{memberAge}</if>
|
|
|
+ <if test="isPay != null"> AND o.is_pay = #{isPay}</if>
|
|
|
+ <if test="status != null"> AND o.status = #{status}</if>
|
|
|
+ <if test="deliveryStatus != null"> AND o.delivery_status = #{deliveryStatus}</if>
|
|
|
+ <if test="companyId != null"> AND o.company_id = #{companyId}</if>
|
|
|
+ <if test="isSync != null"> AND o.is_sync = #{isSync}</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 <= CONCAT(#{eTime},' 23:59:59')</if>
|
|
|
+ <if test="address != null and address != ''"> AND (ua.province LIKE CONCAT('%', #{address}, '%') OR ua.city LIKE CONCAT('%', #{address}, '%') OR ua.district LIKE CONCAT('%', #{address}, '%') OR ua.detail LIKE CONCAT('%', #{address}, '%'))</if>
|
|
|
+ <if test="province != null and province != ''"> AND ua.province = #{province}</if>
|
|
|
+ <if test="city != null and city != ''"> AND ua.city = #{city}</if>
|
|
|
+ <if test="district != null and district != ''"> AND ua.district = #{district}</if>
|
|
|
+ <if test="township != null and township != ''"> AND ua.town_ship = #{township}</if>
|
|
|
+ <if test="productName != null and productName != ''"> AND oi.product_name LIKE CONCAT('%', #{productName}, '%')</if>
|
|
|
+ <if test="payPrice != null"> AND o.pay_price = #{payPrice}</if>
|
|
|
+ <if test="totalPrice != null"> AND o.total_price = #{totalPrice}</if>
|
|
|
+ <if test="collectionPrice != null"> AND o.collection_price = #{collectionPrice}</if>
|
|
|
+ <if test="refundPrice != null"> AND o.refund_price = #{refundPrice}</if>
|
|
|
+ <if test="remark != null and remark != ''"> AND o.remark LIKE CONCAT('%', #{remark}, '%')</if>
|
|
|
+ <if test="deliverySn != null and deliverySn != ''"> AND o.delivery_sn = #{deliverySn}</if>
|
|
|
+ <if test="deliveryCode != null and deliveryCode != ''"> AND o.delivery_code = #{deliveryCode}</if>
|
|
|
+ <if test="deliveryName != null and deliveryName != ''"> AND o.delivery_name LIKE CONCAT('%', #{deliveryName}, '%')</if>
|
|
|
+ <if test="deliveryStartTime != null and deliveryStartTime != ''"> AND o.delivery_time >= #{deliveryStartTime}</if>
|
|
|
+ <if test="deliveryEndTime != null and deliveryEndTime != ''"> AND o.delivery_time <= CONCAT(#{deliveryEndTime},' 23:59:59')</if>
|
|
|
+ <if test="depositReturnTimeStart != null and depositReturnTimeStart != ''"> AND o.update_time >= #{depositReturnTimeStart}</if>
|
|
|
+ <if test="depositReturnTimeEnd != null and depositReturnTimeEnd != ''"> AND o.update_time <= CONCAT(#{depositReturnTimeEnd},' 23:59:59')</if>
|
|
|
+ <if test="followTimeStart != null and followTimeStart != ''"> AND o.follow_time >= #{followTimeStart}</if>
|
|
|
+ <if test="followTimeEnd != null and followTimeEnd != ''"> AND o.follow_time <= CONCAT(#{followTimeEnd},' 23:59:59')</if>
|
|
|
+ <if test="refundTimeStart != null and refundTimeStart != ''"> AND o.refund_time >= #{refundTimeStart}</if>
|
|
|
+ <if test="refundTimeEnd != null and refundTimeEnd != ''"> AND o.refund_time <= CONCAT(#{refundTimeEnd},' 23:59:59')</if>
|
|
|
+ <if test="auditor != null and auditor != ''"> AND o.auditor LIKE CONCAT('%', #{auditor}, '%')</if>
|
|
|
+ <if test="auditTimeStart != null and auditTimeStart != ''"> AND o.audit_time >= #{auditTimeStart}</if>
|
|
|
+ <if test="auditTimeEnd != null and auditTimeEnd != ''"> AND o.audit_time <= CONCAT(#{auditTimeEnd},' 23:59:59')</if>
|
|
|
+ <if test="diseaseName != null and diseaseName != ''"> AND o.disease_name LIKE CONCAT('%', #{diseaseName}, '%')</if>
|
|
|
+ <if test="memberBuyCountMin != null">
|
|
|
+ AND (SELECT COUNT(DISTINCT o2.order_id) FROM fs_external_order o2 WHERE o2.user_id = o.user_id AND o2.company_id = o.company_id AND o2.status != -3) >= #{memberBuyCountMin}
|
|
|
+ </if>
|
|
|
+ <if test="memberBuyCount != null">
|
|
|
+ AND (SELECT COUNT(DISTINCT o2.order_id) FROM fs_external_order o2 WHERE o2.user_id = o.user_id AND o2.company_id = o.company_id AND o2.status != -3) = #{memberBuyCount}
|
|
|
+ </if>
|
|
|
+ ${params.dataScope}
|
|
|
+ </where>
|
|
|
+ GROUP BY o.order_id
|
|
|
+ <if test="receivablePrice != null">
|
|
|
+ HAVING IFNULL(o.total_price, SUM(oi.price * oi.num)) = #{receivablePrice}
|
|
|
+ </if>
|
|
|
+ ) t
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectFinanceOrderListVOSum" parameterType="FsExternalOrder" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ SUM(t.totalPrice) AS totalPrice,
|
|
|
+ SUM(t.collectionPrice) AS collectionPrice,
|
|
|
+ SUM(t.returnPrice) AS returnPrice
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ o.total_price AS totalPrice,
|
|
|
+ o.collection_price AS collectionPrice,
|
|
|
+ o.return_price AS returnPrice
|
|
|
+ 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
|
|
|
+ <where>
|
|
|
+ o.delivery_sn is not null and o.delivery_sn !=''
|
|
|
+ <if test="orderCode != null and orderCode != ''"> AND o.order_code = #{orderCode}</if>
|
|
|
+ <if test="userName != null and userName != ''"> AND o.user_name LIKE CONCAT('%', #{userName}, '%')</if>
|
|
|
+ <if test="userPhone != null and userPhone != ''"> AND o.user_phone LIKE CONCAT('%', #{userPhone}, '%')</if>
|
|
|
+ <if test="deliverySn != null and deliverySn != ''"> AND o.delivery_sn = #{deliverySn}</if>
|
|
|
+ <if test="deliveryName != null and deliveryName != ''"> AND o.delivery_name LIKE CONCAT('%', #{deliveryName}, '%')</if>
|
|
|
+ <if test="status != null"> AND o.status = #{status}</if>
|
|
|
+ <if test="companyId != null"> AND o.company_id = #{companyId}</if>
|
|
|
+ <if test="returnStatus != null">
|
|
|
+ <if test="returnStatus == 1"> AND o.status = 4</if>
|
|
|
+ <if test="returnStatus == 0"> AND o.status != 4</if>
|
|
|
+ </if>
|
|
|
+ <if test="returnUser != null and returnUser != ''"> AND o.update_by LIKE CONCAT('%', #{returnUser}, '%')</if>
|
|
|
+ <if test="returnTimeStart != null and returnTimeStart != ''"> AND o.update_time >= #{returnTimeStart}</if>
|
|
|
+ <if test="returnTimeEnd != null and returnTimeEnd != ''"> AND o.update_time <= #{returnTimeEnd}</if>
|
|
|
+ <if test="totalPrice != null"> AND o.total_price = #{totalPrice}</if>
|
|
|
+ <if test="collectionPrice != null"> AND o.collection_price = #{collectionPrice}</if>
|
|
|
+ <if test="receiverPhone != null and receiverPhone != ''"> AND o.receiver_phone LIKE CONCAT('%', #{receiverPhone}, '%')</if>
|
|
|
+ <if test="remark != null and remark != ''"> AND o.remark LIKE CONCAT('%', #{remark}, '%')</if>
|
|
|
+ <if test="payType != null"> AND o.pay_type = #{payType}</if>
|
|
|
+ <if test="companyUserName != null and companyUserName != ''"> AND cu.user_name LIKE CONCAT('%', #{companyUserName}, '%')</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>
|
|
|
+ <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="memberBuyCount != null">
|
|
|
+ AND (SELECT COUNT(DISTINCT o2.order_id) FROM fs_external_order o2 WHERE o2.user_id = o.user_id AND o2.company_id = o.company_id AND o2.status != -3) = #{memberBuyCount}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY o.order_id
|
|
|
+ <if test="productName != null and productName != '' or receivablePrice != null">
|
|
|
+ HAVING 1=1
|
|
|
+ <if test="productName != null and productName != ''"> AND GROUP_CONCAT(oi.product_name SEPARATOR ',') LIKE CONCAT('%', #{productName}, '%')</if>
|
|
|
+ <if test="receivablePrice != null"> AND IFNULL(o.total_price, SUM(oi.price * oi.num)) = #{receivablePrice}</if>
|
|
|
+ </if>
|
|
|
+ ) t
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectRejectNoReturnReportSum" parameterType="FsExternalOrder" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ SUM(o.total_price) AS totalPrice
|
|
|
+ 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="totalPrice != null"> AND o.total_price = #{totalPrice}</if>
|
|
|
+ <if test="followTimeStart != null and followTimeStart != ''"> AND o.follow_time >= #{followTimeStart}</if>
|
|
|
+ <if test="followTimeEnd != null and followTimeEnd != ''"> AND o.follow_time <= #{followTimeEnd}</if>
|
|
|
+ <if test="deliveryName != null and deliveryName != ''"> AND o.delivery_name LIKE CONCAT('%', #{deliveryName}, '%')</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>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectRejectOrderReportSum" parameterType="FsExternalOrder" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ SUM(t.totalPrice) AS totalPrice
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ o.total_price AS totalPrice
|
|
|
+ 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="sTime != null and sTime != ''"> AND o.create_time >= #{sTime}</if>
|
|
|
+ <if test="eTime != null and eTime != ''"> AND o.create_time <= #{eTime}</if>
|
|
|
+ <if test="totalPrice != null"> AND o.total_price = #{totalPrice}</if>
|
|
|
+ <if test="deliveryName != null and deliveryName != ''"> AND o.delivery_name LIKE CONCAT('%', #{deliveryName}, '%')</if>
|
|
|
+ <if test="rejectReturnTimeStart != null and rejectReturnTimeStart != ''"> AND o.reject_return_time >= #{rejectReturnTimeStart}</if>
|
|
|
+ <if test="rejectReturnTimeEnd != null and rejectReturnTimeEnd != ''"> AND o.reject_return_time <= #{rejectReturnTimeEnd}</if>
|
|
|
+ <if test="returnUser != null and returnUser != ''"> AND o.update_by LIKE CONCAT('%', #{returnUser}, '%')</if>
|
|
|
+ <if test="userPhone != null and userPhone != ''"> AND o.user_phone LIKE CONCAT('%', #{userPhone}, '%')</if>
|
|
|
+ <if test="memberPhone != null and memberPhone != ''"> AND o.receiver_phone LIKE CONCAT('%', #{memberPhone}, '%')</if>
|
|
|
+ <if test="companyUserName != null and companyUserName != ''"> AND cu.user_name LIKE CONCAT('%', #{companyUserName}, '%')</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
|
|
|
+ <if test="productName != null and productName != ''">
|
|
|
+ HAVING GROUP_CONCAT(oi.product_name SEPARATOR ',') LIKE CONCAT('%', #{productName}, '%')
|
|
|
+ </if>
|
|
|
+ ) t
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectRejectProductReportSum" parameterType="FsExternalOrder" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ SUM(t.num) AS num,
|
|
|
+ SUM(t.totalPrice) AS totalPrice
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ 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.delivery_status IN (4, 5, 6)
|
|
|
+ <if test="productName != null and productName != ''"> AND oi.product_name LIKE CONCAT('%', #{productName}, '%')</if>
|
|
|
+ <if test="deliveryName != null and deliveryName != ''"> AND o.delivery_name LIKE CONCAT('%', #{deliveryName}, '%')</if>
|
|
|
+ <if test="companyId != null"> AND o.company_id = #{companyId}</if>
|
|
|
+ </where>
|
|
|
+ GROUP BY o.delivery_name, oi.product_id, oi.product_name
|
|
|
+ <if test="totalNum != null or totalPrice != null">
|
|
|
+ HAVING 1=1
|
|
|
+ <if test="totalNum != null"> AND SUM(oi.num) = #{totalNum}</if>
|
|
|
+ <if test="totalPrice != null"> AND SUM(oi.price * oi.num) = #{totalPrice}</if>
|
|
|
+ </if>
|
|
|
+ ) t
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectReturnOrderReportSum" parameterType="FsExternalOrder" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ SUM(t.payPrice) AS payPrice,
|
|
|
+ SUM(t.totalPrice) AS totalPrice
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ o.pay_price AS payPrice,
|
|
|
+ o.total_price AS totalPrice
|
|
|
+ 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="sTime != null and sTime != ''"> AND o.create_time >= #{sTime}</if>
|
|
|
+ <if test="eTime != null and eTime != ''"> AND o.create_time <= #{eTime}</if>
|
|
|
+ <if test="payPrice != null"> AND o.pay_price = #{payPrice}</if>
|
|
|
+ <if test="totalPrice != null"> AND o.total_price = #{totalPrice}</if>
|
|
|
+ <if test="deliveryName != null and deliveryName != ''"> AND o.delivery_name LIKE CONCAT('%', #{deliveryName}, '%')</if>
|
|
|
+ <if test="returnUser != null and returnUser != ''"> AND o.update_by LIKE CONCAT('%', #{returnUser}, '%')</if>
|
|
|
+ <if test="returnTimeStart != null and returnTimeStart != ''"> AND o.update_time >= #{returnTimeStart}</if>
|
|
|
+ <if test="returnTimeEnd != null and returnTimeEnd != ''"> AND o.update_time <= #{returnTimeEnd}</if>
|
|
|
+ <if test="userPhone != null and userPhone != ''"> AND o.user_phone LIKE CONCAT('%', #{userPhone}, '%')</if>
|
|
|
+ <if test="memberPhone != null and memberPhone != ''"> AND o.receiver_phone LIKE CONCAT('%', #{memberPhone}, '%')</if>
|
|
|
+ <if test="companyUserName != null and companyUserName != ''"> AND cu.user_name LIKE CONCAT('%', #{companyUserName}, '%')</if>
|
|
|
+ <if test="deptId != null"> AND cu.dept_id = #{deptId}</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
|
|
|
+ <if test="productName != null and productName != ''">
|
|
|
+ HAVING GROUP_CONCAT(oi.product_name SEPARATOR ',') LIKE CONCAT('%', #{productName}, '%')
|
|
|
+ </if>
|
|
|
+ ) t
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectReturnProductReportSum" parameterType="FsExternalOrder" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ SUM(t.num) AS num,
|
|
|
+ SUM(t.totalPrice) AS totalPrice
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ 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>
|
|
|
+ <if test="deliveryName != null and deliveryName != ''"> AND o.delivery_name LIKE CONCAT('%', #{deliveryName}, '%')</if>
|
|
|
+ <if test="deptId != null"> AND cu.dept_id = #{deptId}</if>
|
|
|
+ <if test="returnTimeStart != null and returnTimeStart != ''"> AND o.update_time >= #{returnTimeStart}</if>
|
|
|
+ <if test="returnTimeEnd != null and returnTimeEnd != ''"> AND o.update_time <= #{returnTimeEnd}</if>
|
|
|
+ <if test="companyId != null"> AND o.company_id = #{companyId}</if>
|
|
|
+ </where>
|
|
|
+ GROUP BY d.dept_name, o.delivery_name, oi.product_id, oi.product_name
|
|
|
+ ) t
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectSignOrderReportSum" parameterType="FsExternalOrder" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ SUM(o.pay_price) AS payPrice,
|
|
|
+ SUM(o.collection_price) AS collectionPrice,
|
|
|
+ SUM(o.total_price) AS totalPrice
|
|
|
+ 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="payPrice != null"> AND o.pay_price = #{payPrice}</if>
|
|
|
+ <if test="collectionPrice != null"> AND o.collection_price = #{collectionPrice}</if>
|
|
|
+ <if test="totalPrice != null"> AND o.total_price = #{totalPrice}</if>
|
|
|
+ <if test="followTimeStart != null and followTimeStart != ''"> AND o.follow_time >= #{followTimeStart}</if>
|
|
|
+ <if test="followTimeEnd != null and followTimeEnd != ''"> AND o.follow_time <= #{followTimeEnd}</if>
|
|
|
+ <if test="deliveryName != null and deliveryName != ''"> AND o.delivery_name LIKE CONCAT('%', #{deliveryName}, '%')</if>
|
|
|
+ <if test="deptId != null"> AND cu.dept_id = #{deptId}</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>
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|
|
|
|