|
|
@@ -93,7 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectFsStoreOrderVo">
|
|
|
- select id, order_code,service_fee, extend_order_id,pay_order_id,bank_order_id, user_id,order_visit, real_name, user_phone, user_address, cart_id, freight_price, total_num, total_price, total_postage, pay_price, pay_postage,pay_delivery,pay_money, deduction_price, coupon_id, coupon_price, paid, pay_time, pay_type, create_time, update_time, status, refund_status, refund_reason_wap_img, refund_reason_wap_explain, refund_reason_time, refund_reason_wap, refund_reason, refund_price, delivery_sn, delivery_name, delivery_type, delivery_id, gain_integral, use_integral, pay_integral, back_integral, mark, is_del, remark, cost, verify_code, store_id, shipping_type, is_channel, is_remind, is_sys_del,is_prescribe,prescribe_id ,company_id,company_user_id,is_package,package_json,item_json,order_type,package_id,finish_time,delivery_status,delivery_pay_status,delivery_time,delivery_pay_time,delivery_pay_money,tui_money,tui_money_status,delivery_import_time,tui_user_id,tui_user_money_status,order_create_type,store_house_code,dept_id,is_edit_money,customer_id,is_pay_remain,delivery_send_time,certificates,schedule_id,backend_edit_product_type from fs_store_order_scrm
|
|
|
+ select id, order_code,service_fee, extend_order_id,pay_order_id,bank_order_id, user_id,order_visit, real_name, user_phone, user_address, cart_id, freight_price, total_num, total_price, total_postage, pay_price, pay_postage,pay_delivery,pay_money, deduction_price, coupon_id, coupon_price, paid, pay_time, pay_type, create_time, update_time, status, refund_status, refund_reason_wap_img, refund_reason_wap_explain, refund_reason_time, refund_reason_wap, refund_reason, refund_price, delivery_sn, delivery_name, delivery_type, delivery_id, gain_integral, use_integral, pay_integral, back_integral, mark, is_del, remark, cost, verify_code, store_id, shipping_type, is_channel, is_remind, is_sys_del,is_prescribe,prescribe_id ,company_id,company_user_id,is_package,package_json,item_json,order_type,package_id,finish_time,delivery_status,delivery_pay_status,delivery_time,delivery_pay_time,delivery_pay_money,tui_money,tui_money_status,delivery_import_time,tui_user_id,tui_user_money_status,order_create_type,store_house_code,dept_id,is_edit_money,customer_id,is_pay_remain,delivery_send_time,certificates,schedule_id,backend_edit_product_type,video_id,course_id from fs_store_order_scrm
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectFsStoreOrderList" parameterType="FsStoreOrderScrm" resultMap="FsStoreOrderResult">
|
|
|
@@ -660,153 +660,94 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</select>
|
|
|
|
|
|
<select id="selectOrderSaleStatisticsList" resultType="com.fs.hisStore.vo.OrderStatisticsVo">
|
|
|
- SELECT * FROM ( SELECT
|
|
|
+ SELECT * FROM (
|
|
|
+ SELECT
|
|
|
cu.user_id,
|
|
|
cu.user_name,
|
|
|
cu.nick_name,
|
|
|
c.company_name,
|
|
|
c.company_id,
|
|
|
- SUM(fso.`status` != 0) AS totalNum,
|
|
|
- SUM(
|
|
|
- CASE
|
|
|
- WHEN fso.`status` != 0 THEN
|
|
|
- fso.total_price
|
|
|
- ELSE
|
|
|
- 0
|
|
|
- END
|
|
|
- ) totalPrice,
|
|
|
- SUM(fso.`status` = 5) AS dealNum,
|
|
|
- SUM(
|
|
|
- CASE
|
|
|
- WHEN fso.`status` = 5 THEN
|
|
|
- fso.total_price
|
|
|
- ELSE
|
|
|
- 0
|
|
|
- END
|
|
|
- ) AS dealPrice,
|
|
|
- SUM(
|
|
|
- fso.`status` = 1
|
|
|
- OR fso.`status` = -2
|
|
|
- ) AS cancelNum,
|
|
|
- SUM(
|
|
|
- CASE
|
|
|
- WHEN fso.`status` = 1
|
|
|
- OR fso.`status` = -2 THEN
|
|
|
- fso.total_price
|
|
|
- ELSE
|
|
|
- 0
|
|
|
- END
|
|
|
- ) AS cancelPrice,
|
|
|
- SUM(
|
|
|
- fso.`status` = 2
|
|
|
- AND (
|
|
|
- fso.delivery_pay_status = 0
|
|
|
- OR fso.delivery_pay_status IS NULL
|
|
|
- )
|
|
|
- ) AS pendingNum,
|
|
|
- SUM(
|
|
|
- CASE
|
|
|
- WHEN fso.`status` = 2
|
|
|
- AND (
|
|
|
- fso.delivery_pay_status = 0
|
|
|
- OR fso.delivery_pay_status IS NULL
|
|
|
- ) THEN
|
|
|
- fso.total_price
|
|
|
- ELSE
|
|
|
- 0
|
|
|
- END
|
|
|
- ) AS pendingPrice,
|
|
|
- SUM(
|
|
|
- fso.`status` = 3
|
|
|
- AND fso.delivery_pay_status > 0
|
|
|
- ) AS invoiceNum,
|
|
|
- SUM(
|
|
|
- CASE
|
|
|
- WHEN fso.`status` = 3
|
|
|
- AND fso.delivery_pay_status > 0 THEN
|
|
|
- fso.total_price
|
|
|
- ELSE
|
|
|
- 0
|
|
|
- END
|
|
|
- ) AS invoicePrice,
|
|
|
- IFNULL(
|
|
|
- SUM(
|
|
|
- fso.`status` > 3
|
|
|
- AND fso.delivery_pay_status = 3
|
|
|
- ),
|
|
|
- 0
|
|
|
- ) AS signForNum,
|
|
|
- SUM(
|
|
|
- CASE
|
|
|
- WHEN fso.`status` > 3
|
|
|
- AND fso.delivery_pay_status = 3 THEN
|
|
|
- fso.total_price
|
|
|
- ELSE
|
|
|
- 0
|
|
|
- END
|
|
|
- ) AS signFPrice,
|
|
|
- SUM(
|
|
|
- fso.`status` = -1
|
|
|
- AND fso.refund_status = 2
|
|
|
- ) AS chargebackNum,
|
|
|
- SUM(
|
|
|
- CASE
|
|
|
- WHEN fso.`status` = -1
|
|
|
- AND fso.refund_status = 2 THEN
|
|
|
- fso.total_price
|
|
|
- ELSE
|
|
|
- 0
|
|
|
- END
|
|
|
- ) AS chargebackPrice
|
|
|
+ COUNT(DISTINCT fso.id) AS totalNum,
|
|
|
+ SUM(CASE WHEN fso.`status` != 0 THEN fso.total_price ELSE 0 END) AS totalPrice,
|
|
|
+ SUM(CASE WHEN fso.`status` != 0 THEN fso.pay_price ELSE 0 END) AS actualPaymentAmount,
|
|
|
+ SUM(CASE WHEN fso.`status` = 5 THEN 1 ELSE 0 END) AS dealNum,
|
|
|
+ SUM(CASE WHEN fso.`status` = 5 THEN fso.total_price ELSE 0 END) AS dealPrice,
|
|
|
+ SUM(CASE WHEN fso.`status` = 1 OR fso.`status` = -2 THEN 1 ELSE 0 END) AS cancelNum,
|
|
|
+ SUM(CASE WHEN fso.`status` = 1 OR fso.`status` = -2 THEN fso.total_price ELSE 0 END) AS cancelPrice,
|
|
|
+ SUM(CASE WHEN fso.`status` = 2 AND (fso.delivery_pay_status = 0 OR fso.delivery_pay_status IS NULL) THEN 1 ELSE 0 END) AS pendingNum,
|
|
|
+ SUM(CASE WHEN fso.`status` = 2 AND (fso.delivery_pay_status = 0 OR fso.delivery_pay_status IS NULL) THEN fso.total_price ELSE 0 END) AS pendingPrice,
|
|
|
+ SUM(CASE WHEN fso.`status` = 3 AND fso.delivery_pay_status > 0 THEN 1 ELSE 0 END) AS invoiceNum,
|
|
|
+ SUM(CASE WHEN fso.`status` = 3 AND fso.delivery_pay_status > 0 THEN fso.total_price ELSE 0 END) AS invoicePrice,
|
|
|
+ IFNULL(SUM(CASE WHEN fso.`status` > 3 AND fso.delivery_pay_status = 3 THEN 1 ELSE 0 END), 0) AS signForNum,
|
|
|
+ SUM(CASE WHEN fso.`status` > 3 AND fso.delivery_pay_status = 3 THEN fso.total_price ELSE 0 END) AS signFPrice,
|
|
|
+ SUM(CASE WHEN fso.`status` = -1 AND fso.refund_status = 2 THEN 1 ELSE 0 END) AS chargebackNum,
|
|
|
+ SUM(CASE WHEN fso.`status` = -1 AND fso.refund_status = 2 THEN fso.total_price ELSE 0 END) AS chargebackPrice
|
|
|
FROM
|
|
|
company_user cu
|
|
|
INNER JOIN company c ON cu.company_id = c.company_id
|
|
|
LEFT JOIN fs_store_order_scrm fso ON cu.user_id = fso.company_user_id
|
|
|
- INNER JOIN fs_store_order_item_scrm fsoi ON fso.id = fsoi.order_id
|
|
|
- INNER JOIN fs_store_product_scrm fsp ON fsoi.product_id = fsp.product_id
|
|
|
- INNER JOIN fs_store_product_category_scrm fspc ON fspc.cate_id = fsp.cate_id
|
|
|
WHERE
|
|
|
fso.is_del = '0'
|
|
|
AND fso.`status` != 0
|
|
|
+
|
|
|
+ <!-- 公司ID条件 -->
|
|
|
<if test="param.companyId != null and param.companyId != ''">
|
|
|
- AND c.company_id = #{param.companyId}
|
|
|
+ AND c.company_id = #{param.companyId}
|
|
|
</if>
|
|
|
|
|
|
+ <!-- 员工账号条件 -->
|
|
|
<if test="param.userName != null and param.userName != ''">
|
|
|
- AND cu.user_name Like CONCAT('%',#{param.userName},'%')
|
|
|
+ AND cu.user_name LIKE CONCAT('%', #{param.userName}, '%')
|
|
|
</if>
|
|
|
|
|
|
+ <!-- 销售名称条件 -->
|
|
|
<if test="param.companyUser != null and param.companyUser != ''">
|
|
|
- AND cu.nick_name Like CONCAT('%',#{param.companyUser},'%')
|
|
|
+ AND cu.nick_name LIKE CONCAT('%', #{param.companyUser}, '%')
|
|
|
</if>
|
|
|
|
|
|
- <if test="param.productId != null and param.productId != ''">
|
|
|
- AND fsp.product_id = #{param.productId}
|
|
|
+ <!-- 时间条件 -->
|
|
|
+ <if test="param.startDate != null">
|
|
|
+ AND DATE_FORMAT(fso.pay_time, '%Y-%m') >= DATE_FORMAT(#{param.startDate}, '%Y-%m')
|
|
|
</if>
|
|
|
-
|
|
|
- <if test="param.productName != null and param.productName != ''">
|
|
|
- AND fsp.product_name Like CONCAT('%',#{param.productName},'%')
|
|
|
+ <if test="param.endDate != null">
|
|
|
+ AND DATE_FORMAT(fso.pay_time, '%Y-%m') <= DATE_FORMAT(#{param.endDate}, '%Y-%m')
|
|
|
</if>
|
|
|
|
|
|
- <if test="param.cateName != null and param.cateName != ''">
|
|
|
- AND fspc.cate_name Like CONCAT('%',#{param.cateName},'%')
|
|
|
- </if>
|
|
|
+ <!-- 商品和标签筛选(使用EXISTS避免重复计算) -->
|
|
|
+ <if test="param.productId != null and param.productId != ''
|
|
|
+ or param.productName != null and param.productName != ''
|
|
|
+ or param.cateId != null and param.cateId != ''
|
|
|
+ or param.cateName != null and param.cateName != ''">
|
|
|
+ AND EXISTS (
|
|
|
+ SELECT 1
|
|
|
+ FROM fs_store_order_item_scrm fsoi
|
|
|
+ INNER JOIN fs_store_product_scrm fsp ON fsoi.product_id = fsp.product_id
|
|
|
+ LEFT JOIN fs_store_product_category_scrm fspc ON fspc.cate_id = fsp.cate_id
|
|
|
+ WHERE fsoi.order_id = fso.id
|
|
|
|
|
|
- <if test="param.cateId != null and param.cateId != ''">
|
|
|
- AND fspc.cate_id = #{param.cateId}
|
|
|
- </if>
|
|
|
+ <if test="param.productId != null and param.productId != ''">
|
|
|
+ AND fsp.product_id = #{param.productId}
|
|
|
+ </if>
|
|
|
|
|
|
- <if test="param.startDate != null">
|
|
|
- AND DATE_FORMAT(fso.pay_time,'%Y-%m') >= DATE_FORMAT(#{param.startDate},'%Y-%m')
|
|
|
- </if>
|
|
|
+ <if test="param.productName != null and param.productName != ''">
|
|
|
+ AND fsp.product_name LIKE CONCAT('%', #{param.productName}, '%')
|
|
|
+ </if>
|
|
|
|
|
|
- <if test="param.endDate != null">
|
|
|
- AND DATE_FORMAT(fso.pay_time,'%Y-%m') <= DATE_FORMAT(#{param.endDate},'%Y-%m')
|
|
|
+ <if test="param.cateId != null and param.cateId != ''">
|
|
|
+ AND fspc.cate_id = #{param.cateId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="param.cateName != null and param.cateName != ''">
|
|
|
+ AND fspc.cate_name LIKE CONCAT('%', #{param.cateName}, '%')
|
|
|
+ </if>
|
|
|
+ )
|
|
|
</if>
|
|
|
+
|
|
|
GROUP BY
|
|
|
- cu.user_id
|
|
|
- ) a ORDER BY
|
|
|
- a.company_id DESC,a.totalNum DESC
|
|
|
+ cu.user_id, cu.user_name, cu.nick_name, c.company_name, c.company_id
|
|
|
+ ) a
|
|
|
+ ORDER BY
|
|
|
+ a.company_id DESC, a.totalNum DESC
|
|
|
</select>
|
|
|
|
|
|
|
|
|
@@ -1213,10 +1154,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</if>
|
|
|
<if test="maps.isHealth != null and maps.isHealth != '' ">
|
|
|
and (o.company_id is null
|
|
|
- or o.order_type = 2)
|
|
|
+ or o.order_type = 2 or o.order_type = 3)
|
|
|
</if>
|
|
|
<if test="maps.notHealth != null ">
|
|
|
- and o.company_id is not null
|
|
|
+ and o.company_id is not null and o.order_type = 0
|
|
|
</if>
|
|
|
<if test="maps.companyUserId != null ">
|
|
|
and o.company_user_id =#{maps.companyUserId}
|
|
|
@@ -1233,9 +1174,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="maps.productName != null and maps.productName != '' ">
|
|
|
and fsp.product_name like concat('%', #{maps.productName}, '%')
|
|
|
</if>
|
|
|
- <if test="maps.orderType != null ">
|
|
|
+ <if test="maps.orderType != null and maps.orderType != -1">
|
|
|
and o.order_type =#{maps.orderType}
|
|
|
</if>
|
|
|
+ <if test="maps.orderType != null and maps.orderType == -1">
|
|
|
+ and o.order_type in (2, 3)
|
|
|
+ </if>
|
|
|
<if test="maps.payType != null ">
|
|
|
and o.pay_type =#{maps.payType}
|
|
|
</if>
|
|
|
@@ -1389,10 +1333,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</if>
|
|
|
<if test="maps.isHealth != null and maps.isHealth != '' ">
|
|
|
and (o.company_id is null
|
|
|
- or o.order_type = 2)
|
|
|
+ or o.order_type = 2 or o.order_type = 3)
|
|
|
</if>
|
|
|
<if test="maps.notHealth != null ">
|
|
|
- and o.company_id is not null
|
|
|
+ and o.company_id is not null and o.order_type = 0
|
|
|
</if>
|
|
|
<if test="maps.companyUserId != null ">
|
|
|
and o.company_user_id =#{maps.companyUserId}
|
|
|
@@ -1409,9 +1353,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="maps.productName != null and maps.productName != '' ">
|
|
|
and fsp.product_name like concat('%', #{maps.productName}, '%')
|
|
|
</if>
|
|
|
- <if test="maps.orderType != null ">
|
|
|
+ <if test="maps.orderType != null and maps.orderType != -1">
|
|
|
and o.order_type =#{maps.orderType}
|
|
|
</if>
|
|
|
+ <if test="maps.orderType != null and maps.orderType == -1">
|
|
|
+ and o.order_type in (2, 3)
|
|
|
+ </if>
|
|
|
<if test="maps.payType != null ">
|
|
|
and o.pay_type =#{maps.payType}
|
|
|
</if>
|
|
|
@@ -1542,10 +1489,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</if>
|
|
|
<if test="maps.isHealth != null and maps.isHealth != '' ">
|
|
|
and (o.company_id is null
|
|
|
- or o.order_type = 2)
|
|
|
+ or o.order_type = 2 or o.order_type = 3)
|
|
|
</if>
|
|
|
<if test="maps.notHealth != null ">
|
|
|
- and o.company_id is not null
|
|
|
+ and o.company_id is not null and o.order_type = 0
|
|
|
</if>
|
|
|
<if test="maps.companyUserId != null ">
|
|
|
and o.company_user_id =#{maps.companyUserId}
|
|
|
@@ -1562,9 +1509,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="maps.productName != null and maps.productName != '' ">
|
|
|
and fsp.product_name like concat('%', #{maps.productName}, '%')
|
|
|
</if>
|
|
|
- <if test="maps.orderType != null ">
|
|
|
+ <if test="maps.orderType != null and maps.orderType != -1">
|
|
|
and o.order_type =#{maps.orderType}
|
|
|
</if>
|
|
|
+ <if test="maps.orderType != null and maps.orderType == -1">
|
|
|
+ and o.order_type in (2, 3)
|
|
|
+ </if>
|
|
|
<if test="maps.payType != null ">
|
|
|
and o.pay_type =#{maps.payType}
|
|
|
</if>
|
|
|
@@ -1699,10 +1649,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</if>
|
|
|
<if test="maps.isHealth != null and maps.isHealth != '' ">
|
|
|
and (o.company_id is null
|
|
|
- or o.order_type = 2)
|
|
|
+ or o.order_type = 2 or o.order_type = 3)
|
|
|
</if>
|
|
|
<if test="maps.notHealth != null ">
|
|
|
- and o.company_id is not null
|
|
|
+ and o.company_id is not null and o.order_type = 0
|
|
|
</if>
|
|
|
<if test="maps.companyUserId != null ">
|
|
|
and o.company_user_id =#{maps.companyUserId}
|
|
|
@@ -1719,9 +1669,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="maps.productName != null and maps.productName != '' ">
|
|
|
and fsp.product_name like concat('%', #{maps.productName}, '%')
|
|
|
</if>
|
|
|
- <if test="maps.orderType != null ">
|
|
|
+ <if test="maps.orderType != null and maps.orderType != -1">
|
|
|
and o.order_type =#{maps.orderType}
|
|
|
</if>
|
|
|
+ <if test="maps.orderType != null and maps.orderType == -1">
|
|
|
+ and o.order_type in (2, 3)
|
|
|
+ </if>
|
|
|
<if test="maps.payType != null ">
|
|
|
and o.pay_type =#{maps.payType}
|
|
|
</if>
|
|
|
@@ -1852,10 +1805,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</if>
|
|
|
<if test="maps.isHealth != null and maps.isHealth != '' ">
|
|
|
and (o.company_id is null
|
|
|
- or o.order_type = 2)
|
|
|
+ or o.order_type = 2 or o.order_type = 3)
|
|
|
</if>
|
|
|
<if test="maps.notHealth != null ">
|
|
|
- and o.company_id is not null
|
|
|
+ and o.company_id is not null and o.order_type = 0
|
|
|
</if>
|
|
|
<if test="maps.companyUserId != null ">
|
|
|
and o.company_user_id =#{maps.companyUserId}
|
|
|
@@ -1872,9 +1825,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="maps.productName != null and maps.productName != '' ">
|
|
|
and fsp.product_name like concat('%', #{maps.productName}, '%')
|
|
|
</if>
|
|
|
- <if test="maps.orderType != null ">
|
|
|
+ <if test="maps.orderType != null and maps.orderType != -1">
|
|
|
and o.order_type =#{maps.orderType}
|
|
|
</if>
|
|
|
+ <if test="maps.orderType != null and maps.orderType == -1">
|
|
|
+ and o.order_type in (2, 3)
|
|
|
+ </if>
|
|
|
<if test="maps.payType != null ">
|
|
|
and o.pay_type =#{maps.payType}
|
|
|
</if>
|
|
|
@@ -2048,10 +2004,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</if>
|
|
|
<if test="maps.isHealth != null and maps.isHealth != '' ">
|
|
|
and (o.company_id is null
|
|
|
- or o.order_type = 2)
|
|
|
+ or o.order_type = 2 or o.order_type = 3)
|
|
|
</if>
|
|
|
<if test="maps.notHealth != null ">
|
|
|
- and o.company_id is not null
|
|
|
+ and o.company_id is not null and o.order_type = 0
|
|
|
</if>
|
|
|
<if test="maps.companyUserId != null ">
|
|
|
and o.company_user_id =#{maps.companyUserId}
|
|
|
@@ -2068,9 +2024,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="maps.productName != null and maps.productName != '' ">
|
|
|
and fsp.product_name like concat('%', #{maps.productName}, '%')
|
|
|
</if>
|
|
|
- <if test="maps.orderType != null ">
|
|
|
+ <if test="maps.orderType != null and maps.orderType != -1">
|
|
|
and o.order_type =#{maps.orderType}
|
|
|
</if>
|
|
|
+ <if test="maps.orderType != null and maps.orderType == -1">
|
|
|
+ and o.order_type in (2, 3)
|
|
|
+ </if>
|
|
|
<if test="maps.payType != null ">
|
|
|
and o.pay_type =#{maps.payType}
|
|
|
</if>
|
|
|
@@ -2242,9 +2201,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
|
|
|
AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
|
|
|
</if>
|
|
|
- <if test="maps.orderType != null">
|
|
|
+ <if test="maps.orderType != null and maps.orderType != -1">
|
|
|
AND o.order_type = #{maps.orderType}
|
|
|
</if>
|
|
|
+ <if test="maps.orderType != null and maps.orderType == -1">
|
|
|
+ AND o.order_type in (2, 3)
|
|
|
+ </if>
|
|
|
<if test="maps.payType != null">
|
|
|
AND o.pay_type = #{maps.payType}
|
|
|
</if>
|