|
@@ -836,6 +836,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="companyId != null ">
|
|
|
AND so.company_id = #{companyId}
|
|
|
</if>
|
|
|
+ <if test="orderType != null and orderType != ''">
|
|
|
+ AND so.order_type = #{orderType}
|
|
|
+ </if>
|
|
|
+ <if test="orderMedium != null and orderMedium != ''">
|
|
|
+ AND so.order_medium = #{orderMedium}
|
|
|
+ </if>
|
|
|
|
|
|
) o GROUP BY o.company_user_id
|
|
|
</select>
|
|
@@ -865,8 +871,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
(
|
|
|
SELECT o.id, o.order_type,i.json_info,i.item_id
|
|
|
FROM
|
|
|
- fs_store_order_item i
|
|
|
- LEFT JOIN fs_store_order o ON o.id = i.order_id
|
|
|
+ fs_store_order_item_scrm i
|
|
|
+ LEFT JOIN fs_store_order_scrm o ON o.id = i.order_id
|
|
|
LEFT JOIN company_user u ON o.company_user_id = u.user_id
|
|
|
where i.product_id = #{productId}
|
|
|
and o.`status` = 3
|
|
@@ -883,90 +889,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
) t
|
|
|
GROUP BY t.order_type
|
|
|
- HAVING t.order_type > 0
|
|
|
</select>
|
|
|
|
|
|
<update id="batchUpdateInOrderCode">
|
|
|
UPDATE fs_store_order_scrm
|
|
|
- <set>
|
|
|
- delivery_sn = CASE
|
|
|
- <foreach collection="list" item="item">
|
|
|
- WHEN order_code = #{item.orderNumber} THEN #{item.deliverySn}
|
|
|
- </foreach>
|
|
|
- ELSE delivery_sn
|
|
|
- END,
|
|
|
- delivery_name = CASE
|
|
|
- <foreach collection="list" item="item">
|
|
|
- WHEN order_code = #{item.orderNumber} THEN #{item.deliveryName}
|
|
|
- </foreach>
|
|
|
- ELSE delivery_name
|
|
|
- END,
|
|
|
- delivery_id = CASE
|
|
|
- <foreach collection="list" item="item">
|
|
|
- WHEN order_code = #{item.orderNumber} THEN #{item.deliveryId}
|
|
|
- </foreach>
|
|
|
- ELSE delivery_id
|
|
|
- END,
|
|
|
-
|
|
|
- delivery_status = CASE
|
|
|
- <foreach collection="list" item="item">
|
|
|
- WHEN order_code = #{item.orderNumber} THEN #{item.deliveryStatus}
|
|
|
- </foreach>
|
|
|
- ELSE delivery_status
|
|
|
- END,
|
|
|
-
|
|
|
- status = CASE
|
|
|
- WHEN status = 1 THEN 2
|
|
|
- ELSE status
|
|
|
- END,
|
|
|
-
|
|
|
- <if test="list != null and list.size() > 0 and list[0].deliveryPayMoney != null">
|
|
|
- delivery_pay_money = CASE
|
|
|
- <foreach collection="list" item="item">
|
|
|
- WHEN order_code = #{item.orderNumber} THEN #{item.deliveryPayMoney}
|
|
|
- </foreach>
|
|
|
- ELSE delivery_pay_money
|
|
|
- END,
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="list != null and list.size() > 0 and list[0].deliveryType != null">
|
|
|
- delivery_type = CASE
|
|
|
- <foreach collection="list" item="item">
|
|
|
- WHEN order_code = #{item.orderNumber} THEN #{item.deliveryType}
|
|
|
- </foreach>
|
|
|
- ELSE delivery_type
|
|
|
- END,
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="list != null and list.size() > 0 and list[0].deliveryPayStatus != null">
|
|
|
- delivery_pay_status = CASE
|
|
|
- <foreach collection="list" item="item">
|
|
|
- WHEN order_code = #{item.orderNumber} THEN #{item.deliveryPayStatus}
|
|
|
- </foreach>
|
|
|
- ELSE delivery_pay_status
|
|
|
- END,
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="list != null and list.size() > 0 and list[0].deliveryTime != null">
|
|
|
- delivery_time = CASE
|
|
|
- <foreach collection="list" item="item">
|
|
|
- WHEN order_code = #{item.orderNumber} THEN #{item.deliveryTime}
|
|
|
- </foreach>
|
|
|
- ELSE delivery_time
|
|
|
- END,
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="list != null and list.size() > 0 and list[0].deliveryPayTime != null">
|
|
|
- delivery_pay_time = CASE
|
|
|
- <foreach collection="list" item="item">
|
|
|
- WHEN order_code = #{item.orderNumber} THEN #{item.deliveryPayTime}
|
|
|
- </foreach>
|
|
|
- ELSE delivery_pay_time
|
|
|
- END
|
|
|
- </if>
|
|
|
- </set>
|
|
|
+ SET status = CASE
|
|
|
+ <foreach collection="dtoList" item="item" separator="">
|
|
|
+ WHEN order_code = #{item.orderNumber} THEN #{item.deliveryNoteStatus}
|
|
|
+ </foreach>
|
|
|
+ END
|
|
|
WHERE order_code IN
|
|
|
- <foreach collection="list" item="item" open="(" separator="," close=")">
|
|
|
+ <foreach collection="dtoList" item="item" open="(" separator="," close=")">
|
|
|
#{item.orderNumber}
|
|
|
</foreach>
|
|
|
</update>
|
|
@@ -977,4 +910,164 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</select>
|
|
|
+ <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 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 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.pay_type = 1 then
|
|
|
+ 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
|
|
|
+ else case when o.status=3 then 1 else 0 end
|
|
|
+ end) AS completeOrders,
|
|
|
+ sum(case when o.pay_type = 1 then
|
|
|
+ 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
|
|
|
+ else case when o.status=3 then o.pay_price else 0 end
|
|
|
+ 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 ELSE 0 END) AS shippedAmount,
|
|
|
+
|
|
|
+ COUNT(CASE WHEN o.status = 2 and o.pay_type != 1 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 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 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>
|