yumeng пре 6 месеци
родитељ
комит
a80b0a9eb9

+ 186 - 16
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouRewardBaseInfoController.java

@@ -1,11 +1,12 @@
 package com.ruixuan.isc.controller;
 
 
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import com.alibaba.fastjson.JSONObject;
@@ -17,18 +18,14 @@ import com.ruixuan.common.enums.BusinessType;
 import com.ruixuan.common.utils.Check;
 import com.ruixuan.common.utils.DateUtils;
 import com.ruixuan.common.utils.poi.ExcelUtil;
+import com.ruixuan.data.utils.ExportExcelUtils;
 import com.ruixuan.isc.entity.KuaishouRewardBaseInfo;
 import com.ruixuan.isc.service.IKuaishouRewardBaseInfoService;
+import io.swagger.annotations.ApiOperation;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
 /**
@@ -47,7 +44,7 @@ public class KuaishouRewardBaseInfoController extends BaseController {
      * 查询【请填写功能名称】列表
      */
     @GetMapping("/list")
-    public TableDataInfo list(Long itemId, String promoterId, String startDate, String endDate, String itemTitle, String promoterName) {
+    public TableDataInfo list(Long itemId, String promoterId, String startDate, String endDate, String itemTitle, String promoterName,Integer status) {
 
         Map<String, Object> requestMap = new HashMap<>();
         if (!Check.isNull(itemId)) {
@@ -68,12 +65,91 @@ public class KuaishouRewardBaseInfoController extends BaseController {
         if (!Check.isNull(promoterName)) {
             requestMap.put("promoterName", promoterName);
         }
+        if (!Check.isNull(status)) {
+            requestMap.put("status", status);
+        }
         startPage();
         List<KuaishouRewardBaseInfo> list = kuaishouRewardBaseInfoService.selectKuaishouRewardBaseInfoList(requestMap);
         return getDataTable(list);
     }
 
 
+    @PostMapping("/exportDetail")
+    @ResponseBody
+    public void exportDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
+        Map<String, Object> requestMap = new HashMap<>();
+
+        Long itemId = requestJson.getLong("itemId");
+
+        if (!Check.isNull(itemId)) {
+            requestMap.put("itemId", itemId);
+        }
+        Long promoterId = requestJson.getLong("promoterId");
+
+        if (!Check.isNull(promoterId)) {
+            requestMap.put("promoterId", promoterId);
+        }
+
+        String itemTitle = requestJson.getString("itemTitle");
+        if (!Check.isNull(itemTitle)) {
+            requestMap.put("itemTitle", itemTitle);
+        }
+        String promoterName = requestJson.getString("promoterName");
+        if (!Check.isNull(promoterName)) {
+            requestMap.put("promoterName", promoterName);
+        }
+        String startDate = requestJson.getString("startDate");
+        if (!Check.isNull(startDate)) {
+            requestMap.put("startDate", startDate);
+        }
+
+        String endDate = requestJson.getString("endDate");
+        if (!Check.isNull(endDate)) {
+            requestMap.put("endDate", endDate);
+        }
+
+        List<KuaishouRewardBaseInfo> list = kuaishouRewardBaseInfoService.selectKuaishouRewardBaseInfoList(requestMap);
+        List<List<Object>> exportList = new ArrayList<>();
+        if (!Check.isNull(list)) {
+            for (int i = 0; i < list.size(); i++) {
+                KuaishouRewardBaseInfo data = list.get(i);
+                List<Object> export = new ArrayList();
+                export.add(data.getItemId());
+                export.add(data.getItemTitle());
+                export.add(data.getItemCreateName());
+                export.add(data.getPromoterId());
+                export.add(data.getPromoterName());
+                export.add(data.getPromoterCreateName());
+                export.add(data.getStatDate());
+                export.add(data.getCurrentSettlementNum());
+                export.add(data.getTotalSettlementNum());
+                export.add(data.getSettlementPrice());
+                export.add(data.getAnchorAmount());
+                export.add(data.getReferenceAmount());
+                export.add(data.getTotalAmount());
+                Integer status = data.getStatus();
+                if (status == 1) {
+                    export.add("未结算");
+                } else if (status == 2) {
+                    export.add("已结算");
+                } else {
+                    export.add("-");
+                }
+                exportList.add(export);
+            }
+        }
+        String[] headers = {"商品ID", "商品名称", "招商", "达人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("/totalListInfo")
     public TableDataInfo totalListInfo(Long itemId, String promoterId, String itemTitle, String promoterName) {
 
@@ -96,14 +172,92 @@ public class KuaishouRewardBaseInfoController extends BaseController {
         return getDataTable(list);
     }
 
+    @PostMapping("/exportTotal")
+    @ResponseBody
+    public void exportTotal(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws IOException {
+        Map<String, Object> requestMap = new HashMap<>();
 
-    @GetMapping("/getTotal")
-    public JSONObject getTotal(KuaishouRewardBaseInfo kuaishouRewardBaseInfo) {
+        Long itemId = requestJson.getLong("itemId");
+
+        if (!Check.isNull(itemId)) {
+            requestMap.put("itemId", itemId);
+        }
+        Long promoterId = requestJson.getLong("promoterId");
+
+        if (!Check.isNull(promoterId)) {
+            requestMap.put("promoterId", promoterId);
+        }
 
-        JSONObject json = kuaishouRewardBaseInfoService.getTotal(kuaishouRewardBaseInfo);
+        String itemTitle = requestJson.getString("itemTitle");
+        if (!Check.isNull(itemTitle)) {
+            requestMap.put("itemTitle", itemTitle);
+        }
+        String promoterName = requestJson.getString("promoterName");
+        if (!Check.isNull(promoterName)) {
+            requestMap.put("promoterName", promoterName);
+        }
+
+
+        List<JSONObject> list = kuaishouRewardBaseInfoService.totalListInfo(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("itemId"));
+                export.add(date.getString("itemTitle"));
+                export.add(date.getString("itemCreateName"));
+                export.add(date.getString("promoterId"));
+                export.add(date.getString("promoterName"));
+                export.add(date.getString("promoterCreateName"));
+                export.add(date.getString("totalSettlementNum"));
+                export.add(date.getString("maxDate"));
+                exportList.add(export);
+            }
+        }
+        String[] headers = {"商品ID", "商品名称", "招商", "达人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("/getTotal")
+    public JSONObject getTotal(Long itemId, String promoterId, String startDate, String endDate, String itemTitle, String promoterName) {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(itemId)) {
+            requestMap.put("itemId", itemId);
+        }
+        if (!Check.isNull(promoterId)) {
+            requestMap.put("promoterId", promoterId);
+        }
+        if (!Check.isNull(startDate)) {
+            requestMap.put("startDate", startDate);
+        }
+        if (!Check.isNull(endDate)) {
+            requestMap.put("endDate", endDate);
+        }
+        if (!Check.isNull(itemTitle)) {
+            requestMap.put("itemTitle", itemTitle);
+        }
+        if (!Check.isNull(promoterName)) {
+            requestMap.put("promoterName", promoterName);
+        }
+        JSONObject json = kuaishouRewardBaseInfoService.getTotal(requestMap);
         return json;
     }
 
+
+    @PostMapping("/updateStatus")
+    public AjaxResult updateStatus(@RequestBody JSONObject jsonObject) {
+        return toAjax(kuaishouRewardBaseInfoService.updateStatus(jsonObject.getLong("id")));
+    }
+
     /**
      * 导出【请填写功能名称】列表
      */
@@ -243,5 +397,21 @@ public class KuaishouRewardBaseInfoController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(kuaishouRewardBaseInfoService.deleteKuaishouRewardBaseInfoByIds(ids));
     }
+
+    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();
+        }
+    }
 }
 

+ 1 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouRewardBaseInfo.java

@@ -102,6 +102,7 @@ public class KuaishouRewardBaseInfo extends BaseEntity {
      */
     @Excel(name = "备注")
     private String remarks;
+    private Integer status;
 
 
     @Transient

+ 3 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KuaishouRewardBaseInfoMapper.java

@@ -70,7 +70,7 @@ public interface KuaishouRewardBaseInfoMapper {
 
     String getPromoterName(@Param("promoterId") String promoterId);
 
-    JSONObject getTotal(KuaishouRewardBaseInfo kuaishouRewardBaseInfo);
+    JSONObject getTotal(Map<String, Object> requestMap);
 
     void replaceBatchRewardBaseInfo(@Param("infoList") List<KuaishouRewardBaseInfo> infoList);
 
@@ -79,5 +79,7 @@ public interface KuaishouRewardBaseInfoMapper {
     BigDecimal getTotalAmount(@Param("promoterId") String promoterId, @Param("itemId") Long itemId);
 
     List<JSONObject> totalListInfo(Map<String, Object> requestMap);
+
+    int updateStatus(@Param("id") Long id);
 }
 

+ 3 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouRewardBaseInfoService.java

@@ -69,7 +69,7 @@ public interface IKuaishouRewardBaseInfoService {
 
     JSONObject getInfo(Long itemId, String promoterId);
 
-    JSONObject getTotal(KuaishouRewardBaseInfo kuaishouRewardBaseInfo);
+    JSONObject getTotal( Map<String, Object> requestMap);
 
     ResultResponse insertRewardBaseInfoByExcel(MultipartFile file) throws Exception;
 
@@ -82,4 +82,6 @@ public interface IKuaishouRewardBaseInfoService {
     BigDecimal getTotalAmount(String promoterId, Long itemId);
 
     List<JSONObject> totalListInfo(Map<String, Object> requestMap);
+
+    int updateStatus(Long id);
 }

+ 7 - 2
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouRewardBaseInfoServiceImpl.java

@@ -108,8 +108,8 @@ public class KuaishouRewardBaseInfoServiceImpl implements IKuaishouRewardBaseInf
     }
 
     @Override
-    public JSONObject getTotal(KuaishouRewardBaseInfo kuaishouRewardBaseInfo) {
-        return kuaishouRewardBaseInfoMapper.getTotal(kuaishouRewardBaseInfo);
+    public JSONObject getTotal( Map<String, Object> requestMap) {
+        return kuaishouRewardBaseInfoMapper.getTotal(requestMap);
     }
 
     @Override
@@ -166,5 +166,10 @@ public class KuaishouRewardBaseInfoServiceImpl implements IKuaishouRewardBaseInf
     public List<JSONObject> totalListInfo(Map<String, Object> requestMap) {
         return kuaishouRewardBaseInfoMapper.totalListInfo(requestMap);
     }
+
+    @Override
+    public int updateStatus(Long id) {
+        return kuaishouRewardBaseInfoMapper.updateStatus(id);
+    }
 }
 

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KwaiJSTServiceImpl.java

@@ -451,7 +451,7 @@ public class KwaiJSTServiceImpl implements IKwaiJSTService {
             log.info("{},suk数据处理最终清洗完成", skuNick);
         } catch (Exception e) {
             e.printStackTrace();
-            this.send("快手小店成本数据清洗失败,请处理,序号:2,sukId:" + skuNick);
+            this.send("快手小店成本数据清洗失败,请处理,序号:2,sukId:" + skuNick + "  ," + e.getMessage());
         }
 
         return null;

+ 21 - 5
ruixuan-live/src/main/resources/mapper/isc/KuaishouRewardBaseInfoMapper.xml

@@ -18,6 +18,7 @@
         <result property="referenceAmount" column="reference_amount"/>
         <result property="totalAmount" column="total_amount"/>
         <result property="remarks" column="remarks"/>
+        <result property="status" column="status"/>
         <result property="createTime" column="create_time"/>
         <result property="updateTime" column="update_time"/>
     </resultMap>
@@ -57,6 +58,7 @@
         t1.reference_amount,
         t1.total_amount,
         t1.remarks,
+        t1.status,
         ifnull(t2.user_name,'-') as 'itemCreateName',
         ifnull(t3.user_name,'-') as 'promoterCreateName',
         t1.create_time,
@@ -71,6 +73,7 @@
         ) t3 on t1.promoter_id = t3.promoter_id
         <where>
             <if test="itemId != null  and itemId != '' ">and t1.item_id = #{itemId}</if>
+            <if test="status != null  and status != '' ">and t1.status = #{status}</if>
             <if test="itemTitle != null  and itemTitle != ''">and t1.item_title like concat('%',
                 #{itemTitle},
                 '%')
@@ -84,7 +87,7 @@
             <if test="endDate != null and endDate != ''">and t1.stat_date &lt;= #{endDate}</if>
 
         </where>
-        order by t1.stat_date desc
+        order by t1.create_time
     </select>
 
     <select id="selectKuaishouRewardBaseInfoById" parameterType="java.lang.Long"
@@ -112,6 +115,9 @@
     <select id="getTotal" resultType="com.alibaba.fastjson.JSONObject"
             parameterType="com.ruixuan.isc.entity.KuaishouRewardBaseInfo">
         SELECT
+        '-' as 'promoterId',
+        '-' as 'promoterName',
+        '-' as 'promoterCreateName',
         '-' as 'itemCreateName',
         '-' as 'statDate',
         '-' as 'settlementPrice',
@@ -130,7 +136,8 @@
                 #{promoterName},
                 '%')
             </if>
-            <if test="statDate != null ">and stat_date = #{statDate}</if>
+            <if test="startDate != null ">and stat_date &gt;= #{startDate}</if>
+            <if test="endDate != null ">and stat_date &lt;= #{endDate}</if>
         </where>
 
     </select>
@@ -157,7 +164,8 @@
         sum(t1.current_settlement_num) as 'totalSettlementNum',
         max(t1.stat_date) as 'maxDate',
         ifnull(t2.user_name,'-') as 'itemCreateName',
-        ifnull(t3.user_name,'-') as 'promoterCreateName'
+        ifnull(t3.user_name,'-') as 'promoterCreateName',
+        t1.create_time as 'createTime'
         FROM kuaishou_reward_base_info t1 LEFT JOIN kuaishou_item_list t2
         on t1.item_id = t2.item_id
         LEFT JOIN (
@@ -168,7 +176,10 @@
         ) t3 on t1.promoter_id = t3.promoter_id
         <where>
             <if test="itemId != null  and itemId != '' ">and t1.item_id = #{itemId}</if>
-            <if test="itemTitle != null  and itemTitle != ''">and t1.item_title = #{itemTitle}</if>
+            <if test="itemTitle != null  and itemTitle != ''">and t1.item_title like concat('%',
+                #{itemTitle},
+                '%')
+            </if>
             <if test="promoterId != null and promoterId != '' ">and t1.promoter_id = #{promoterId}</if>
             <if test="promoterName != null  and promoterName != ''">and t1.promoter_name like concat('%',
                 #{promoterName},
@@ -178,7 +189,7 @@
         and t1.promoter_type = 1
         group by t1.promoter_id,t1.item_id
         ) t
-        order by t.maxDate desc
+        order by t.createTime
     </select>
 
 
@@ -241,6 +252,11 @@
         </trim>
         where id = #{id}
     </update>
+    <update id="updateStatus" parameterType="java.lang.Long">
+        UPDATE kuaishou_reward_base_info
+        SET status = 2
+        WHERE id = #{id}
+    </update>
 
     <delete id="deleteKuaishouRewardBaseInfoById" parameterType="java.lang.Long">
         DELETE