yumeng vor 2 Jahren
Ursprung
Commit
7e0726cb3c

+ 88 - 18
ruixuan-live/src/main/java/com/ruixuan/isc/controller/SupplyChainController.java

@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.text.SimpleDateFormat;
@@ -649,7 +650,7 @@ public class SupplyChainController extends BaseController {
             }
         }
 
-        String[] headers = {"达人ID", "达人名称", "订单数", "有效订单数", "有效订单率", "发货数", "发货率","未发货数"};
+        String[] headers = {"达人ID", "达人名称", "订单数", "有效订单数", "有效订单率", "发货数", "发货率", "未发货数"};
         OutputStream os = response.getOutputStream();
         ExportExcelUtils eeu = new ExportExcelUtils();
         XSSFWorkbook workbook = new XSSFWorkbook();
@@ -779,23 +780,6 @@ public class SupplyChainController extends BaseController {
     }
 
 
-    //发送响应流方法
-    public void setResponseHeader(HttpServletResponse response, String fileName) {
-        try {
-            try {
-                fileName = new String(fileName.getBytes(), "ISO8859-1");
-            } catch (UnsupportedEncodingException e) {
-                e.printStackTrace();
-            }
-            response.setContentType("application/octet-stream;charset=ISO8859-1");
-            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
-            response.addHeader("Pargam", "no-cache");
-            response.addHeader("Cache-Control", "no-cache");
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-    }
-
     /**
      * 获取供应链人员列表
      *
@@ -1012,6 +996,73 @@ public class SupplyChainController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 认领商品列表导出
+     *
+     * @return
+     */
+    @PostMapping("/exportUserItemDetail")
+    @ApiOperation(value = "认领商品列表")
+    @ResponseBody
+    public void exportUserItemDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
+
+
+        Map<String, Object> requestMap = new HashMap<>();
+
+        if (!Check.isNull(requestJson.getLong("userId"))) {
+            requestMap.put("userId", requestJson.getLong("userId"));
+        }
+        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.getLong("itemId"))) {
+            requestMap.put("itemId", requestJson.getLong("itemId"));
+        }
+        if (!Check.isNull(requestJson.getString("itemTitle"))) {
+            requestMap.put("itemTitle", requestJson.getString("itemTitle"));
+        }
+
+        List<JSONObject> list = supplyChainService.exportUserItemDetail(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.getLong("itemId"));
+                export.add(date.getString("itemTitle"));
+                export.add(date.getString("reservePrice"));
+                export.add(date.getString("itemCommissionRate"));
+                export.add(date.getString("orderNum"));
+                export.add(date.getString("validOrderNUm"));
+                export.add(date.getString("validRadio"));
+                export.add(date.getString("invalidOrderNUm"));
+                export.add(date.getString("deliveryNum"));
+                export.add(date.getString("deliveryRadio"));
+                export.add(date.getString("notDeliveryNum"));
+                export.add(date.getString("payAmount"));
+                export.add(date.getString("regimentalPromotionRate"));
+                export.add(date.getString("regimentalPromotionAmount"));
+                export.add(date.getString("imageUrl"));
+                exportList.add(export);
+            }
+        }
+        String[] headers = {"所属人", "商品ID", "商品名称", "商品单价", "佣金率", "订单数", "有效订单数", "有效订单率", "失效订单数", "发货数", "发货率", "未发货数", "付款金额", "服务费率", "预估服务费收入", "商品封面"};
+        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();
+    }
+
 
     @GetMapping("/userItemTotal")
     @ApiOperation(value = "认领商品列表汇总")
@@ -1142,4 +1193,23 @@ public class SupplyChainController extends BaseController {
         List<JSONObject> list = supplyChainService.indexStatistics(requestMap);
         return list;
     }
+
+
+    //发送响应流方法
+    public void setResponseHeader(HttpServletResponse response, String fileName) {
+        try {
+            try {
+                fileName = new String(fileName.getBytes(), "ISO8859-1");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            response.setContentType("application/octet-stream;charset=ISO8859-1");
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
+            response.addHeader("Pargam", "no-cache");
+            response.addHeader("Cache-Control", "no-cache");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+
 }

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

@@ -68,4 +68,6 @@ public interface SupplyChainMapper {
     JSONObject itemBindSummary();
 
     JSONObject userItemTotal(Map<String, Object> requestMap);
+
+    List<JSONObject> exportUserItemDetail(Map<String, Object> requestMap);
 }

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

@@ -92,4 +92,7 @@ public interface ISupplyChainService {
 
     // 商品绑定人员汇总
     JSONObject userItemTotal(Map<String, Object> requestMap);
+
+    //认领列表导出
+    List<JSONObject> exportUserItemDetail(Map<String, Object> requestMap);
 }

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

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

+ 99 - 0
ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

@@ -933,6 +933,105 @@
             and t1.user_id = #{userId}
         </if>
     </select>
+    <select id="exportUserItemDetail" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        *
+        FROM
+        (
+        SELECT
+        t1.user_id as 'user_id',
+        t1.user_name AS 'userName',
+        t2.item_id AS 'itemId',
+        t2.item_title AS 'itemTitle',
+        t2.image_url AS 'imageUrl',
+        t2.reserve_price AS 'reservePrice',
+        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) * 100,
+        2
+        ) 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
+        ) *  100,
+        2
+        ) AS 'deliveryRadio',
+        sum(
+        CASE
+        WHEN t2.order_status = 80 THEN 1
+        ELSE 0
+        END
+        ) AS 'invalidOrderNUm',
+        sum(
+        CASE
+        WHEN t2.order_status != 80 THEN t2.pay_amount
+        ELSE 0
+        END
+        ) AS 'payAmount',
+        t2.regimental_promotion_rate AS 'regimentalPromotionRate',
+        sum(
+        CASE
+        WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
+        ELSE 0
+        END
+        ) AS 'regimentalPromotionAmount',
+        sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
+        'totalRegimentalSettleAmount',
+        t2.item_commission_rate as 'itemCommissionRate'
+        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>
+        <if test="itemId != null and itemId != ''">
+            and t1.item_id = #{itemId}
+        </if>
+        <if test="itemTitle != null and itemTitle != ''">
+            and t1.item_title like concat(concat('%',#{itemTitle}),'%')
+        </if>
+        GROUP BY
+        t1.item_id
+        ) t
+        where 1 = 1
+        <if test="userId != null and userId != ''">
+            and t.user_id = #{userId}
+        </if>
+    </select>
 
 
 </mapper>