Browse Source

增加招商管理发样数和导出功能

yumeng 2 years ago
parent
commit
0c5af9be2f

+ 52 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/controller/SupplyChainController.java

@@ -665,7 +665,7 @@ public class SupplyChainController extends BaseController {
                 export.add(date.getString("validRadio"));
                 export.add(date.getString("validRadio"));
                 export.add(date.getString("payAmount"));
                 export.add(date.getString("payAmount"));
                 export.add(date.getString("validPayAmount"));
                 export.add(date.getString("validPayAmount"));
-             //   export.add(date.getString("regimentalPromotionAmount"));
+                //   export.add(date.getString("regimentalPromotionAmount"));
                 export.add(date.getString("deliveryNum"));
                 export.add(date.getString("deliveryNum"));
                 export.add(date.getString("deliveryRadio"));
                 export.add(date.getString("deliveryRadio"));
                 export.add(date.getString("notDeliveryNum"));
                 export.add(date.getString("notDeliveryNum"));
@@ -971,6 +971,57 @@ public class SupplyChainController extends BaseController {
     }
     }
 
 
 
 
+    @PostMapping("/exportAdminReportList")
+    @ApiOperation(value = "供应链管理员统计列表")
+    public void exportAdminReportList(
+            HttpServletRequest request, HttpServletResponse response,
+            @RequestBody JSONObject requestJson
+    ) throws IOException {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(requestJson.getString("orderStartDate"))) {
+            Long start = DateUtils.getStartLongTime(requestJson.getString("orderStartDate"));
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(requestJson.getString("orderEndDate"))) {
+            Long end = DateUtils.getEndLongTime(requestJson.getString("orderEndDate"));
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(requestJson.getString("userId"))) {
+            requestMap.put("userId", requestJson.getString("userId"));
+        }
+        List<JSONObject> list = supplyChainService.exportAdminReportList(requestMap);
+        List<List<Object>> exportList = new ArrayList<>();
+        if (!Check.isNull(list)) {
+            for (int i = 0; i < list.size(); i++) {
+                JSONObject date = list.get(i);
+                List<Object> export = new ArrayList();
+                export.add(date.getString("userName"));
+                export.add(date.getString("itemCount"));
+                export.add(date.getString("sendSampleCount"));
+                export.add(date.getString("orderNum"));
+                export.add(date.getString("validOrderNUm"));
+                export.add(date.getString("validRadio"));
+                export.add(date.getString("deliveryNum"));
+                export.add(date.getString("notDeliveryNum"));
+                export.add(date.getString("deliveryRadio"));
+                export.add(date.getString("payAmount"));
+                export.add(date.getString("regimentalPromotionAmount"));
+                export.add(date.getString("totalRegimentalSettleAmount"));
+                exportList.add(export);
+            }
+        }
+        String[] headers = {"招商", "商品数", "发样数", "订单数", "有效订单数", "有效率", "发货数", "未发货数", "发货率", "实付金额", "预估服务费收入", "结算服务费收入"};
+        OutputStream os = response.getOutputStream();
+        ExportExcelUtils eeu = new ExportExcelUtils();
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        eeu.exportExcel(workbook, 0, "订单信息", headers, exportList);
+        this.setResponseHeader(response, "订单信息.xls");
+        workbook.write(os);
+        os.flush();
+        os.close();
+    }
+
+
     /**
     /**
      * 认领商品列表
      * 认领商品列表
      *
      *

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/SupplyChainMapper.java

@@ -100,4 +100,6 @@ public interface SupplyChainMapper {
     String getUserName(@Param("promoterId") Long promoterId);
     String getUserName(@Param("promoterId") Long promoterId);
 
 
     List<JSONObject> exportBdReportList(Map<String, Object> requestMap);
     List<JSONObject> exportBdReportList(Map<String, Object> requestMap);
+
+    List<JSONObject> exportAdminReportList(Map<String, Object> requestMap);
 }
 }

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/ISupplyChainService.java

@@ -121,4 +121,6 @@ public interface ISupplyChainService {
     String getUserName(Long promoterId);
     String getUserName(Long promoterId);
 
 
     List<JSONObject> exportBdReportList(Map<String, Object> requestMap);
     List<JSONObject> exportBdReportList(Map<String, Object> requestMap);
+
+    List<JSONObject> exportAdminReportList(Map<String, Object> requestMap);
 }
 }

+ 5 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/SupplyChainServiceImpl.java

@@ -269,4 +269,9 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
     public List<JSONObject> exportBdReportList(Map<String, Object> requestMap) {
     public List<JSONObject> exportBdReportList(Map<String, Object> requestMap) {
         return supplyChainMapper.exportBdReportList(requestMap);
         return supplyChainMapper.exportBdReportList(requestMap);
     }
     }
+
+    @Override
+    public List<JSONObject> exportAdminReportList(Map<String, Object> requestMap) {
+        return supplyChainMapper.exportAdminReportList(requestMap);
+    }
 }
 }

+ 54 - 2
ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

@@ -516,7 +516,8 @@
         then 1 else 0 end) * 100,2) as 'deliveryRadio',
         then 1 else 0 end) * 100,2) as 'deliveryRadio',
         round(sum(pay_amount) / 100,2) as 'payAmount',
         round(sum(pay_amount) / 100,2) as 'payAmount',
         round(sum(case when order_status != 80 then pay_amount else 0 end) / 100 , 2 ) as 'validPayAmount',
         round(sum(case when order_status != 80 then pay_amount else 0 end) / 100 , 2 ) as 'validPayAmount',
-        round(sum(case when order_status != 80 then regimental_promotion_amount else 0 end) / 100, 2) as 'regimentalPromotionAmount'
+        round(sum(case when order_status != 80 then regimental_promotion_amount else 0 end) / 100, 2) as
+        'regimentalPromotionAmount'
         from kuaishou_supply_chain
         from kuaishou_supply_chain
         where 1= 1
         where 1= 1
         <if test="start != null and start != ''">
         <if test="start != null and start != ''">
@@ -711,7 +712,13 @@
         <if test="end != null and end != ''">
         <if test="end != null and end != ''">
             and t2.order_create_time &lt;= #{end}
             and t2.order_create_time &lt;= #{end}
         </if>
         </if>
-        group by t1.user_id) t
+        group by t1.user_id) t left join (
+        select item_create_id,count(1) as 'sendSampleCount' from kuaishou_item_collect_samples
+        where courier_number_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
+        and courier_number_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
+        group by item_create_id
+
+        ) t1 on t.userId = t1.item_create_id
         where 1 =1
         where 1 =1
         <if test="userId != null and userId != ''">
         <if test="userId != null and userId != ''">
             and t.userId = #{userId}
             and t.userId = #{userId}
@@ -1596,4 +1603,49 @@
         order by t1.orderNum desc
         order by t1.orderNum desc
 
 
     </select>
     </select>
+    <select id="exportAdminReportList" resultType="com.alibaba.fastjson.JSONObject">
+        select *
+        from (select t1.user_id as 'userId',
+        t1.user_name as 'userName',
+        count(distinct t2.item_id) as 'itemCount',
+        count(t2.oid) as 'orderNum',
+        sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
+        round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid),4) as 'validRadio',
+        sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
+        sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
+        round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
+        when t2.order_status != 80
+        then 1
+        else 0 end),
+        4) as 'deliveryRadio',
+        sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
+        round(sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) / 100 , 2) as 'payAmount',
+        round(sum(case
+        when t2.order_status != 80 then t2.regimental_promotion_amount
+        else 0 end) / 100, 2 )as 'regimentalPromotionAmount',
+        round(sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100 , 2) as
+        'totalRegimentalSettleAmount'
+        from kuaishou_item_bind_user t1
+        left join kuaishou_supply_chain t2
+        on t1.item_id = t2.item_id
+        where 1= 1
+        <if test="start != null and start != ''">
+            and t2.order_create_time &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and t2.order_create_time &lt;= #{end}
+        </if>
+        group by t1.user_id) t left join (
+        select item_create_id,count(1) as 'sendSampleCount' from kuaishou_item_collect_samples
+        where courier_number_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
+        and courier_number_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
+        group by item_create_id
+
+        ) t1 on t.userId = t1.item_create_id
+        where 1 =1
+        <if test="userId != null and userId != ''">
+            and t.userId = #{userId}
+        </if>
+        order by t.orderNum desc
+    </select>
 </mapper>
 </mapper>