Sfoglia il codice sorgente

成本功能调整

yumeng 11 mesi fa
parent
commit
14dc6943ee

+ 109 - 4
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouRewardBaseInfoController.java

@@ -1,7 +1,11 @@
 package com.ruixuan.isc.controller;
 
 
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 
 import com.alibaba.fastjson.JSONObject;
@@ -43,9 +47,52 @@ public class KuaishouRewardBaseInfoController extends BaseController {
      * 查询【请填写功能名称】列表
      */
     @GetMapping("/list")
-    public TableDataInfo list(KuaishouRewardBaseInfo kuaishouRewardBaseInfo) {
+    public TableDataInfo list(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);
+        }
         startPage();
-        List<KuaishouRewardBaseInfo> list = kuaishouRewardBaseInfoService.selectKuaishouRewardBaseInfoList(kuaishouRewardBaseInfo);
+        List<KuaishouRewardBaseInfo> list = kuaishouRewardBaseInfoService.selectKuaishouRewardBaseInfoList(requestMap);
+        return getDataTable(list);
+    }
+
+
+    @GetMapping("/totalListInfo")
+    public TableDataInfo totalListInfo(Long itemId, String promoterId, 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(itemTitle)) {
+            requestMap.put("itemTitle", itemTitle);
+        }
+        if (!Check.isNull(promoterName)) {
+            requestMap.put("promoterName", promoterName);
+        }
+        startPage();
+        List<KuaishouRewardBaseInfo> list = kuaishouRewardBaseInfoService.totalListInfo(requestMap);
         return getDataTable(list);
     }
 
@@ -60,13 +107,13 @@ public class KuaishouRewardBaseInfoController extends BaseController {
     /**
      * 导出【请填写功能名称】列表
      */
-    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
+/*    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, KuaishouRewardBaseInfo kuaishouRewardBaseInfo) {
         List<KuaishouRewardBaseInfo> list = kuaishouRewardBaseInfoService.selectKuaishouRewardBaseInfoList(kuaishouRewardBaseInfo);
         ExcelUtil<KuaishouRewardBaseInfo> util = new ExcelUtil<KuaishouRewardBaseInfo>(KuaishouRewardBaseInfo.class);
         util.exportExcel(response, list, "【请填写功能名称】数据");
-    }
+    }*/
 
     /**
      * 获取【请填写功能名称】详细信息
@@ -76,6 +123,63 @@ public class KuaishouRewardBaseInfoController extends BaseController {
         return AjaxResult.success(kuaishouRewardBaseInfoService.selectKuaishouRewardBaseInfoById(id));
     }
 
+    @GetMapping(value = "/getItemName")
+    public String getItemName(Long itemId) {
+        if (Check.isNull(itemId)) {
+            return null;
+
+        }
+        return kuaishouRewardBaseInfoService.getItemName(itemId);
+    }
+
+
+    @GetMapping(value = "/getPromoterName")
+    public String getPromoterName(String promoterId) {
+        if (Check.isNull(promoterId)) {
+            return null;
+        }
+        return kuaishouRewardBaseInfoService.getPromoterName(promoterId);
+    }
+
+    @GetMapping(value = "/getTotalSettlementNum")
+    public Long getTotalSettlementNum(String promoterId, Long itemId, Long currentSettlementNum) {
+        if (Check.isNull(promoterId)) {
+            return 0L;
+        }
+        if (Check.isNull(itemId)) {
+            return 0L;
+        }
+        if (Check.isNull(currentSettlementNum)) {
+            return 0L;
+        }
+        Long lastTotalSettlementNum = kuaishouRewardBaseInfoService.getTotalSettlementNum(promoterId, itemId);
+        BigDecimal totalSettlementNum = new BigDecimal(currentSettlementNum).add(new BigDecimal(lastTotalSettlementNum));
+        return totalSettlementNum.longValue();
+    }
+
+
+    @GetMapping(value = "/getTotalAmount")
+    public BigDecimal getTotalAmount(String promoterId, Long itemId, BigDecimal anchorAmount, BigDecimal referenceAmount) {
+        if (Check.isNull(promoterId)) {
+            return BigDecimal.ZERO;
+        }
+        if (Check.isNull(itemId)) {
+            return BigDecimal.ZERO;
+        }
+
+        BigDecimal lastTotalAmount = kuaishouRewardBaseInfoService.getTotalAmount(promoterId, itemId);
+        if (!Check.isNull(anchorAmount) && anchorAmount.compareTo(BigDecimal.ZERO) != 0) {
+            lastTotalAmount = lastTotalAmount.add(anchorAmount);
+        }
+        if (!Check.isNull(referenceAmount) && anchorAmount.compareTo(referenceAmount.ZERO) != 0) {
+            lastTotalAmount = lastTotalAmount.add(referenceAmount);
+        }
+
+
+        return lastTotalAmount;
+    }
+
+
     /**
      * 新增【请填写功能名称】
      */
@@ -112,6 +216,7 @@ public class KuaishouRewardBaseInfoController extends BaseController {
                     kuaishouRewardBaseInfo.setPromoterName(promoterName);
                 }
             }
+            kuaishouRewardBaseInfo.setPromoterType(1);
             return toAjax(kuaishouRewardBaseInfoService.insertKuaishouRewardBaseInfo(kuaishouRewardBaseInfo));
         } catch (Exception e) {
             result.put("code", 500);

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

@@ -26,6 +26,7 @@ public class KuaishouRewardBaseInfo extends BaseEntity {
      * $column.columnComment
      */
     private Long id;
+    private Integer promoterType;
 
     /**
      * 商品id
@@ -88,6 +89,7 @@ public class KuaishouRewardBaseInfo extends BaseEntity {
     @Excel(name = "推荐人奖励金额")
     private BigDecimal referenceAmount;
 
+
     /**
      * 累计结算金额
      */
@@ -122,5 +124,6 @@ public class KuaishouRewardBaseInfo extends BaseEntity {
         this.setSettlementPrice(obj.getBigDecimal("7"));//结算单价
         this.setAnchorAmount(obj.getBigDecimal("8"));//奖励
         this.setStatDate(obj.getString("9"));//日期
+        this.setPromoterType(2);//日期
     }
 }

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

@@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSONObject;
 import com.ruixuan.isc.entity.KuaishouRewardBaseInfo;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 【请填写功能名称】Mapper接口
@@ -28,7 +30,7 @@ public interface KuaishouRewardBaseInfoMapper {
      * @param kuaishouRewardBaseInfo 【请填写功能名称】
      * @return 【请填写功能名称】集合
      */
-    public List<KuaishouRewardBaseInfo> selectKuaishouRewardBaseInfoList(KuaishouRewardBaseInfo kuaishouRewardBaseInfo);
+    public List<KuaishouRewardBaseInfo> selectKuaishouRewardBaseInfoList(Map<String,Object> map);
 
     /**
      * 新增【请填写功能名称】
@@ -71,5 +73,11 @@ public interface KuaishouRewardBaseInfoMapper {
     JSONObject getTotal(KuaishouRewardBaseInfo kuaishouRewardBaseInfo);
 
     void replaceBatchRewardBaseInfo(@Param("infoList") List<KuaishouRewardBaseInfo> infoList);
+
+    Long getTotalSettlementNum(@Param("promoterId") String promoterId, @Param("itemId") Long itemId);
+
+    BigDecimal getTotalAmount(@Param("promoterId") String promoterId, @Param("itemId") Long itemId);
+
+    List<KuaishouRewardBaseInfo> totalListInfo(Map<String, Object> requestMap);
 }
 

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

@@ -6,7 +6,9 @@ import com.ruixuan.common.core.domain.ResultResponse;
 import com.ruixuan.isc.entity.KuaishouRewardBaseInfo;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 【请填写功能名称】Service接口
@@ -29,7 +31,7 @@ public interface IKuaishouRewardBaseInfoService {
      * @param kuaishouRewardBaseInfo 【请填写功能名称】
      * @return 【请填写功能名称】集合
      */
-    public List<KuaishouRewardBaseInfo> selectKuaishouRewardBaseInfoList(KuaishouRewardBaseInfo kuaishouRewardBaseInfo);
+     List<KuaishouRewardBaseInfo> selectKuaishouRewardBaseInfoList(Map<String,Object> map );
 
     /**
      * 新增【请填写功能名称】
@@ -70,4 +72,14 @@ public interface IKuaishouRewardBaseInfoService {
     JSONObject getTotal(KuaishouRewardBaseInfo kuaishouRewardBaseInfo);
 
     ResultResponse insertRewardBaseInfoByExcel(MultipartFile file) throws Exception;
+
+    String getItemName(Long itemId);
+
+    String getPromoterName(String getPromoterId);
+
+    Long getTotalSettlementNum(String promoterId, Long itemId);
+
+    BigDecimal getTotalAmount(String promoterId, Long itemId);
+
+    List<KuaishouRewardBaseInfo> totalListInfo(Map<String, Object> requestMap);
 }

+ 31 - 3
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouRewardBaseInfoServiceImpl.java

@@ -13,8 +13,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 
 @Service
@@ -40,8 +42,8 @@ public class KuaishouRewardBaseInfoServiceImpl implements IKuaishouRewardBaseInf
      * @return 【请填写功能名称】
      */
     @Override
-    public List<KuaishouRewardBaseInfo> selectKuaishouRewardBaseInfoList(KuaishouRewardBaseInfo kuaishouRewardBaseInfo) {
-        return kuaishouRewardBaseInfoMapper.selectKuaishouRewardBaseInfoList(kuaishouRewardBaseInfo);
+    public List<KuaishouRewardBaseInfo> selectKuaishouRewardBaseInfoList(Map<String,Object> map) {
+        return kuaishouRewardBaseInfoMapper.selectKuaishouRewardBaseInfoList(map);
     }
 
     /**
@@ -125,7 +127,7 @@ public class KuaishouRewardBaseInfoServiceImpl implements IKuaishouRewardBaseInf
                     continue;
                 }
                 String itemId = o.getString("2");
-                if(Check.isNull(itemId)){
+                if (Check.isNull(itemId)) {
                     continue;
                 }
                 KuaishouRewardBaseInfo baseInfo = new KuaishouRewardBaseInfo(o);
@@ -137,5 +139,31 @@ public class KuaishouRewardBaseInfoServiceImpl implements IKuaishouRewardBaseInf
         }
         return ResultResponse.success();
     }
+
+    @Override
+    public String getItemName(Long itemId) {
+        return kuaishouRewardBaseInfoMapper.getItemName(itemId);
+    }
+
+    @Override
+    public String getPromoterName(String getPromoterId) {
+        String promoterName = kuaishouRewardBaseInfoMapper.getPromoterName(getPromoterId);
+        return promoterName;
+    }
+
+    @Override
+    public Long getTotalSettlementNum(String promoterId, Long itemId) {
+        return kuaishouRewardBaseInfoMapper.getTotalSettlementNum(promoterId, itemId);
+    }
+
+    @Override
+    public BigDecimal getTotalAmount(String promoterId, Long itemId) {
+        return kuaishouRewardBaseInfoMapper.getTotalAmount(promoterId, itemId);
+    }
+
+    @Override
+    public List<KuaishouRewardBaseInfo> totalListInfo(Map<String, Object> requestMap) {
+        return kuaishouRewardBaseInfoMapper.totalListInfo(requestMap);
+    }
 }
 

+ 72 - 6
ruixuan-live/src/main/resources/mapper/isc/KuaishouRewardBaseInfoMapper.xml

@@ -41,9 +41,10 @@
         FROM kuaishou_reward_base_info
     </sql>
 
-    <select id="selectKuaishouRewardBaseInfoList" parameterType="com.ruixuan.isc.entity.KuaishouRewardBaseInfo"
+    <select id="selectKuaishouRewardBaseInfoList"
             resultMap="KuaishouRewardBaseInfoResult">
         SELECT t1.id,
+        t1.promoter_type,
         t1.item_id,
         t1.item_title,
         t1.promoter_id,
@@ -69,14 +70,15 @@
         GROUP BY promoter_id
         ) t3 on t1.promoter_id = t3.promoter_id
         <where>
-            <if test="itemId != null ">and t1.item_id = #{itemId}</if>
+            <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="promoterId != null ">and t1.promoter_id = #{promoterId}</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},
                 '%')
             </if>
-            <if test="statDate != null ">and t1.stat_date = #{statDate}</if>
+            <if test="startDate != null and startDate != ''">and t1.stat_date &gt;= #{startDate}</if>
+            <if test="endDate != null and endDate != ''">and t1.stat_date &lt;= #{endDate}</if>
 
         </where>
         order by t1.create_time desc
@@ -129,17 +131,81 @@
         </where>
 
     </select>
+    <select id="getTotalSettlementNum" resultType="java.lang.Long">
+        SELECT ifnull(SUM(current_settlement_num), 0) AS totalSettlementNum
+        FROM kuaishou_reward_base_info
+        WHERE promoter_id = #{promoterId}
+          AND item_id = #{itemId}
+    </select>
+    <select id="getTotalAmount" resultType="java.math.BigDecimal">
+        SELECT ifnull(SUM(anchor_amount + reference_amount), 0) AS tatalAmount
+        FROM kuaishou_reward_base_info
+        WHERE promoter_id = #{promoterId}
+          AND item_id = #{itemId}
+    </select>
+    <select id="totalListInfo" resultMap="KuaishouRewardBaseInfoResult">
+
+        SELECT * from (
+        SELECT t1.id,
+        t1.item_id,
+        t1.item_title,
+        t1.promoter_id,
+        t1.promoter_name,
+        sum(t1.current_settlement_num) as 'total_settlement_num',
+        sum(t1.anchor_amount) as 'anchor_amount',
+        sum(t1.reference_amount) as 'reference_amount',
+        sum(t1.reference_amount + t1.anchor_amount ) as 'total_amount',
+        t2.user_name as 'itemCreateName',
+        t3.user_name as 'promoterCreateName',
+        max(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 (
+        SELECT promoter_id as 'promoter_id',
+        group_concat(user_name) as 'user_name'
+        from kuaishou_promoter WHERE media_id = '2'
+        GROUP BY promoter_id
+        ) 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="promoterId != null and promoterId != '' ">and t1.promoter_id = #{promoterId}</if>
+            <if test="promoterName != null  and promoterName != ''">and t1.promoter_name like concat('%',
+                #{promoterName},
+                '%')
+            </if>
+            <if test="startDate != null and startDate != ''">and t1.stat_date &gt;= #{startDate}</if>
+            <if test="endDate != null and endDate != ''">and t1.stat_date &lt;= #{endDate}</if>
+        </where>
+
+        <if test="itemId != null and promoterId != null">
+            group by t1.item_id,t1.promoter_id
+        </if>
+        <if test="itemId == null and promoterId == null">
+            group by t1.item_id,t1.promoter_id
+        </if>
+
+        <if test="itemId != null and  promoterId == null ">
+            group by t1.item_id
+        </if>
+        <if test="promoterId != null  and itemId == null ">
+            group by t1.promoter_id
+        </if>
+
+        ) t
+        order by t.createTime desc
+    </select>
 
 
     <insert id="insertKuaishouRewardBaseInfo" parameterType="com.ruixuan.isc.entity.KuaishouRewardBaseInfo"
             useGeneratedKeys="true" keyProperty="id">
         insert into kuaishou_reward_base_info
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="promoterType != null">promoter_type,</if>
             <if test="itemId != null">item_id,</if>
             <if test="itemTitle != null">item_title,</if>
             <if test="promoterId != null">promoter_id,</if>
             <if test="promoterName != null">promoter_name,</if>
-
             <if test="statDate != null">stat_date,</if>
             <if test="currentSettlementNum != null">current_settlement_num,</if>
             <if test="totalSettlementNum != null">total_settlement_num,</if>
@@ -152,11 +218,11 @@
             <if test="updateTime != null">update_time,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="promoterType != null">#{promoterType},</if>
             <if test="itemId != null">#{itemId},</if>
             <if test="itemTitle != null">#{itemTitle},</if>
             <if test="promoterId != null">#{promoterId},</if>
             <if test="promoterName != null">#{promoterName},</if>
-
             <if test="statDate != null">#{statDate},</if>
             <if test="currentSettlementNum != null">#{currentSettlementNum},</if>
             <if test="totalSettlementNum != null">#{totalSettlementNum},</if>