|
@@ -782,7 +782,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
) a ORDER BY
|
|
|
a.company_id DESC,a.totalNum DESC
|
|
|
</select>
|
|
|
- <select id="selectFsStoreOrderCountsByDept" resultType="com.fs.hisStore.vo.FsStoreOrderCountsVO">
|
|
|
+
|
|
|
+ <select id="selectFsStoreOrderGroupByCompanyUserId" resultType="com.fs.hisStore.vo.FsStoreOrderCountsVO">
|
|
|
SELECT
|
|
|
o.dept_id,
|
|
|
CONCAT(o.nick_name, '[', o.company_user_id, ']') AS name,
|
|
@@ -891,6 +892,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
GROUP BY t.order_type
|
|
|
</select>
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
<update id="batchUpdateInOrderCode">
|
|
|
UPDATE fs_store_order_scrm
|
|
|
SET status = CASE
|
|
@@ -904,8 +908,158 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</foreach>
|
|
|
</update>
|
|
|
|
|
|
+ <select id="selectFsStoreOrderGroupByCompanyId" resultType="com.fs.hisStore.vo.FsStoreOrderCountsVO">
|
|
|
+ SELECT
|
|
|
+ company_company_id AS id,
|
|
|
+ COALESCE(NULLIF(company_name, ''),'客户自购') AS name,
|
|
|
+ <include refid="selectFsStoreOrderConditions" />
|
|
|
+
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT so.*,c.company_name,a.audit_status,u.company_id as company_company_id
|
|
|
+ FROM
|
|
|
+ fs_store_order_scrm AS so
|
|
|
+ LEFT JOIN company_user u ON so.company_user_id = u.user_id
|
|
|
+ left join company c ON u.company_id = c.company_id
|
|
|
+ left join fs_store_order_audit_scrm a on a.order_id=so.id
|
|
|
+ where 1=1
|
|
|
+ <include refid="selectFsStoreOrderWhere" />
|
|
|
+
|
|
|
+
|
|
|
+ <if test="companyId != null ">
|
|
|
+ AND u.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+
|
|
|
+ ) o GROUP BY o.company_company_id
|
|
|
+ </select>
|
|
|
+ <select id="selectFsStoreOrderGroupByDeptId" resultType="com.fs.hisStore.vo.FsStoreOrderCountsVO">
|
|
|
+ SELECT
|
|
|
+ company_dept_id AS id,
|
|
|
+ COALESCE(NULLIF(dept_name, ''),'客户自购') AS name,
|
|
|
+ <include refid="selectFsStoreOrderConditions" />
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT so.*,d.dept_id as company_dept_id,d.dept_name,a.audit_status
|
|
|
+ FROM
|
|
|
+ fs_store_order_scrm AS so
|
|
|
+ LEFT JOIN company_user u ON so.company_user_id = u.user_id
|
|
|
+ left join company_dept d ON d.dept_id = u.dept_id
|
|
|
+ left join fs_store_order_audit_scrm a on a.order_id=so.id
|
|
|
+ where 1=1
|
|
|
+ <include refid="selectFsStoreOrderWhere" />
|
|
|
+ <if test="companyId != null ">
|
|
|
+ AND u.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
+ AND so.order_type = #{orderType}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ ) o GROUP BY o.company_dept_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectFsStoreOrderGroupByUserId" resultType="com.fs.hisStore.vo.FsStoreOrderCountsVO">
|
|
|
+ SELECT
|
|
|
+ company_user_id AS id,
|
|
|
+ COALESCE(NULLIF(nick_name, ''),'客户自购') AS name,
|
|
|
+
|
|
|
+ <include refid="selectFsStoreOrderConditions" />
|
|
|
+
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT so.*,u.nick_name,u.dept_id company_dept_id,a.audit_status
|
|
|
+ FROM
|
|
|
+ fs_store_order_scrm AS so
|
|
|
+ LEFT JOIN company_user u ON so.company_user_id = u.user_id
|
|
|
+ left join fs_store_order_audit_scrm a on a.order_id=so.id
|
|
|
+ where 1=1
|
|
|
+ <include refid="selectFsStoreOrderWhere" />
|
|
|
+ <if test="companyUserId != null ">
|
|
|
+ AND so.company_user_id = #{companyUserId}
|
|
|
+ </if>
|
|
|
+ <if test="deptId != null">
|
|
|
+ AND u.dept_id = #{deptId}
|
|
|
+ </if>
|
|
|
+ <if test="companyId != null ">
|
|
|
+ AND u.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ ) o GROUP BY o.company_user_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 总金额totalAmount 不包括取消金额和 退款金额 待支付-->
|
|
|
+ <!-- 待支付-0 待发货-1 待收货-2 交易完成-3 ;退款中-(-1); 已退款-(-2) ;已取消- (-3); -->
|
|
|
+ <!-- 成单金额 = 总金额 审核通过的,没有审核就是支付成功的 -->
|
|
|
+ <!-- 待审金额 (a.audit_status is null or a.audit_status = 4) null 审核未开启 4 审核成功-->
|
|
|
+ <!-- waitingOrders 待审核 -->
|
|
|
+ <!-- unPassedOrders 审核未过 -->
|
|
|
+ <!-- cancelAmount 取消 -->
|
|
|
+ <!-- unshippedAmount 成交未发货金额 -->
|
|
|
+ <!-- shippedAmount 发货金额 = 总金额 -->
|
|
|
+ <!-- 在途金额 transitAmount 货到付款订单 -->
|
|
|
+ <!-- 成交金额=实际支付金额 -->
|
|
|
+ <sql id="selectFsStoreOrderConditions">
|
|
|
+ sum(case when o.status in (1,2,3,-1) and (o.audit_status is null or o.audit_status = 4) then 1 else 0 end) AS totalCalls,
|
|
|
+ sum(case when o.status in (1,2,3,-1) and (o.audit_status is null or o.audit_status = 4) then o.pay_price+o.pay_delivery else 0 end) AS totalAmount,
|
|
|
+
|
|
|
+ SUM(CASE WHEN o.status IN (1,2,3,-1) and (o.audit_status is null or o.audit_status = 4) THEN o.pay_price+o.pay_delivery ELSE 0 END) AS validAmount,
|
|
|
+
|
|
|
+ COUNT(CASE WHEN o.audit_status in (0,2) THEN 1 END) AS waitingOrders,
|
|
|
+ SUM(CASE WHEN o.audit_status in (0,2) THEN o.pay_price ELSE 0 END) AS waitingAmount,
|
|
|
+
|
|
|
+ COUNT(CASE WHEN o.audit_status in (1,3) THEN 1 END) AS unPassedOrders,
|
|
|
+ SUM(CASE WHEN o.audit_status in (1,3) THEN o.pay_price ELSE 0 END) AS unPassedAmount,
|
|
|
+
|
|
|
+ COUNT(CASE WHEN o.status IN (-3) THEN 1 END) AS cancelOrders,
|
|
|
+ SUM(CASE WHEN o.status IN (-3) THEN o.pay_price ELSE 0 END) AS cancelAmount,
|
|
|
+
|
|
|
+ sum(case when o.status in (1,2,3,-1) and (o.audit_status is null or o.audit_status = 4) then 1 else 0 end) AS completeOrders,
|
|
|
+ sum(case when o.status in (1,2,3,-1) and (o.audit_status is null or o.audit_status = 4) then o.pay_price else 0 end) AS completeAmount,
|
|
|
|
|
|
+ COUNT(CASE WHEN o.status = 1 THEN 1 END) AS unshippedOrders,
|
|
|
+ SUM(CASE WHEN o.status = 1 THEN o.pay_price ELSE 0 END) AS unshippedAmount,
|
|
|
|
|
|
+ COUNT(CASE WHEN o.status in (1,2,3,-1) and (o.audit_status is null or o.audit_status = 4) THEN 1 END) AS shippedOrders,
|
|
|
+ SUM(CASE WHEN o.status in (1,2,3,-1) and (o.audit_status is null or o.audit_status = 4) THEN o.pay_price+o.pay_delivery ELSE 0 END) AS shippedAmount,
|
|
|
+
|
|
|
+ COUNT(CASE WHEN o.status = 2 THEN 1 END) AS transitOrders,
|
|
|
+ SUM(CASE WHEN o.status = 2 THEN o.pay_delivery ELSE 0 END) AS transitAmount,
|
|
|
+
|
|
|
+ COUNT(CASE WHEN o.status = 3 THEN 1 END) AS receivedOrders,
|
|
|
+ SUM(CASE WHEN o.status = 3 THEN o.pay_price+o.pay_delivery ELSE 0 END) AS receivedAmount,
|
|
|
+
|
|
|
+ COUNT(CASE WHEN o.refund_status = -2 THEN 1 END) AS returnOrders,
|
|
|
+ SUM(CASE WHEN o.refund_status = -2 THEN o.refund_price ELSE 0 END) AS returnAmount,
|
|
|
+
|
|
|
+ COUNT(CASE WHEN o.status = 3 THEN 1 END) AS paybackOrders,
|
|
|
+ SUM(CASE WHEN o.status = 3 THEN o.pay_price+o.pay_delivery ELSE 0 END) AS paybackAmount
|
|
|
+ </sql>
|
|
|
+
|
|
|
+
|
|
|
+ <sql id="selectFsStoreOrderWhere">
|
|
|
+ <choose>
|
|
|
+ <when test="queryType != null and queryType==1">
|
|
|
+ and (DATE_FORMAT(so.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
|
|
|
+ </when>
|
|
|
+ <when test="queryType != null and queryType==2">
|
|
|
+ and (DATE_FORMAT(so.delivery_send_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ <choose>
|
|
|
+ <when test="amountType != null and amountType==1">
|
|
|
+ and so.pay_price=0
|
|
|
+ </when>
|
|
|
+ <when test="amountType != null and amountType==2">
|
|
|
+ and so.pay_price > 0
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
+ AND so.order_type = #{orderType}
|
|
|
+ </if>
|
|
|
+ <if test="orderMedium != null and orderMedium != ''">
|
|
|
+ AND so.order_medium = #{orderMedium}
|
|
|
+ </if>
|
|
|
+ </sql>
|
|
|
|
|
|
|
|
|
</mapper>
|