| 
					
				 | 
			
			
				@@ -543,4 +543,221 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             and company_user_id = #{companyUserId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="selectOrderDimensionStatisticsList" resultType="com.fs.store.vo.OrderStatisticsVo"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.groupType == 2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fsp.cate_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fspc.cate_name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.groupType == 3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fsoi.product_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fsp.product_name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        COUNT(*) orderNum 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FROM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        company_user cu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        INNER JOIN company c ON cu.company_id = c.company_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        INNER JOIN fs_store_order fso ON cu.user_id = fso.company_user_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        INNER JOIN fs_store_order_item fsoi ON fso.id = fsoi.order_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        INNER JOIN fs_store_product fsp ON fsoi.product_id = fsp.product_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        INNER JOIN fs_store_product_category fspc ON fspc.cate_id = fsp.cate_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        WHERE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        fso.is_del = '0' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AND fso.`status` > 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.companyId != null and 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},'%') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.companyUser != null and param.companyUser != ''"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND cu.nick_name Like CONCAT('%',#{param.companyUser},'%') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.productName != null and param.productName != ''"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND fsp.product_name Like CONCAT('%',#{param.productName},'%') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <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 test="param.startDate != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND DATE_FORMAT(fso.pay_time,'%Y-%m') >= DATE_FORMAT(#{param.startDate},'%Y-%m') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.endDate != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND DATE_FORMAT(fso.pay_time,'%Y-%m') <= DATE_FORMAT(#{param.endDate},'%Y-%m') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        GROUP BY 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.groupType == 2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fsp.cate_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.groupType == 3"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            fsoi.product_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ORDER BY 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cu.company_id DESC 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="selectOrderSaleStatisticsList" resultType="com.fs.store.vo.OrderStatisticsVo"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FROM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        company_user cu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        INNER JOIN company c ON cu.company_id = c.company_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LEFT JOIN fs_store_order fso ON cu.user_id = fso.company_user_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        INNER JOIN fs_store_order_item fsoi ON fso.id = fsoi.order_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        INNER JOIN fs_store_product fsp ON fsoi.product_id = fsp.product_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        INNER JOIN fs_store_product_category fspc ON fspc.cate_id = fsp.cate_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        WHERE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        fso.is_del = '0' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AND fso.`status` != 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.companyId != null and 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},'%') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.companyUser != null and 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> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.productName != null and param.productName != ''"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND fsp.product_name Like CONCAT('%',#{param.productName},'%') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.cateName != null and param.cateName != ''"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND fspc.cate_name Like CONCAT('%',#{param.cateName},'%') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.cateId != null and param.cateId != ''"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND fspc.cate_id = #{param.cateId} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.startDate != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND DATE_FORMAT(fso.pay_time,'%Y-%m') >= DATE_FORMAT(#{param.startDate},'%Y-%m') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="param.endDate != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND DATE_FORMAT(fso.pay_time,'%Y-%m') <= DATE_FORMAT(#{param.endDate},'%Y-%m') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        GROUP BY 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cu.user_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ) a ORDER BY 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        a.company_id DESC,a.totalNum DESC 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 </mapper> 
			 |