Browse Source

查询达人信息

zhaoxian 2 years ago
parent
commit
3976a786f9

+ 9 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouPromoterController.java

@@ -57,6 +57,15 @@ public class KuaishouPromoterController extends BaseController {
         return AjaxResult.success(kuaishouPromoterService.selectKuaishouPromoterById(id));
         return AjaxResult.success(kuaishouPromoterService.selectKuaishouPromoterById(id));
     }
     }
 
 
+    /**
+     * 获取快手达人信息
+     */
+    @GetMapping(value = "/getPromoterInfo")
+    @ApiOperation(value = "获取快手达人信息")
+    public AjaxResult getPromoterInfo(@ApiParam("主键") @RequestParam(value = "id", required = true) Long id) {
+        return kuaishouPromoterService.getPromoterInfo(id);
+    }
+
 
 
     /**
     /**
      * 新增快手达人 信息
      * 新增快手达人 信息

+ 3 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KuaishouPromoterMapper.java

@@ -1,5 +1,6 @@
 package com.ruixuan.isc.mapper;
 package com.ruixuan.isc.mapper;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.ruixuan.isc.entity.KuaishouPromoter;
 import com.ruixuan.isc.entity.KuaishouPromoter;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
@@ -55,4 +56,6 @@ public interface KuaishouPromoterMapper {
     public int deleteKuaishouPromoterByIds(Long[] ids);
     public int deleteKuaishouPromoterByIds(Long[] ids);
 
 
     KuaishouPromoter getOneByIdAndPromoterId(@Param("userId") Long userId, @Param("promoterId") Long promoterId);
     KuaishouPromoter getOneByIdAndPromoterId(@Param("userId") Long userId, @Param("promoterId") Long promoterId);
+
+    JSONObject getNearlyMonthGmv(@Param("promoterId") Long promoterId, @Param("start") String start, @Param("end") String end);
 }
 }

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

@@ -1,6 +1,7 @@
 package com.ruixuan.isc.service;
 package com.ruixuan.isc.service;
 
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.ruixuan.common.core.domain.AjaxResult;
 import com.ruixuan.isc.entity.KuaishouPromoter;
 import com.ruixuan.isc.entity.KuaishouPromoter;
 
 
 import java.util.List;
 import java.util.List;
@@ -60,4 +61,5 @@ public interface IKuaishouPromoterService {
      */
      */
     public int deleteKuaishouPromoterById(Long id);
     public int deleteKuaishouPromoterById(Long id);
 
 
+    AjaxResult getPromoterInfo(Long id);
 }
 }

+ 49 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouPromoterServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruixuan.isc.service.impl;
 package com.ruixuan.isc.service.impl;
 
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.ruixuan.common.core.domain.AjaxResult;
 import com.ruixuan.common.core.domain.entity.SysUser;
 import com.ruixuan.common.core.domain.entity.SysUser;
 import com.ruixuan.common.utils.Check;
 import com.ruixuan.common.utils.Check;
 import com.ruixuan.common.utils.DateUtils;
 import com.ruixuan.common.utils.DateUtils;
@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
@@ -206,4 +208,51 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
         return kuaishouPromoterMapper.deleteKuaishouPromoterById(id);
         return kuaishouPromoterMapper.deleteKuaishouPromoterById(id);
     }
     }
 
 
+    @Override
+    public AjaxResult getPromoterInfo(Long id) {
+        AjaxResult ajaxResult = null;
+        try {
+            KuaishouPromoter promoter = kuaishouPromoterMapper.selectKuaishouPromoterById(id);
+            JSONObject data = new JSONObject();
+            if (Check.isNotNull(promoter)) {
+                Thread thread = new Thread() {
+                    @Override
+                    public void run() {
+                        try {
+                            editPromoter(promoter.getId(), promoter.getPromoterId());
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                };
+                thread.start();
+                Long startTime = System.currentTimeMillis();
+                String content = HttpUtil.httpGetRequest(internalIpPath + "kuaiShou/promoter/getPromoterVideoInfo?promoterId=" + promoter.getPromoterId());
+                JSONObject result = JSONObject.parseObject(content);
+                log.info("获取达人视频销售数据,用时:{}s", (System.currentTimeMillis() - startTime) / 1000);
+
+                String start = DateUtils.getSubtractTime(new Date(), 31);
+                String end = DateUtils.getDate();
+                JSONObject info = kuaishouPromoterMapper.getNearlyMonthGmv(promoter.getPromoterId(), start, end);
+
+                if (Check.isNotNull(info)) {
+                    data.put("orderAmount", info.getString("orderAmount"));
+                    data.put("operationCompletionRate", info.getString("operationCompletionRate"));
+                }
+                if (Check.isNotNull(result)) {
+                    data.put("avgVideoSales", result.getString("avgVideoSales"));
+                    data.put("videoSales", result.getString("videoSales"));
+                }
+                data.put("promoterId", promoter.getPromoterId());
+                data.put("promoterUrl", promoter.getPromoterUrl());
+            }
+            ajaxResult = new AjaxResult(200, "查询成功", data);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("获取达人详情数据异常");
+            ajaxResult = new AjaxResult(500, "查询失败");
+        }
+        return ajaxResult;
+    }
+
 }
 }

+ 14 - 0
ruixuan-live/src/main/resources/mapper/isc/KuaishouPromoterMapper.xml

@@ -152,4 +152,18 @@
         </foreach>
         </foreach>
     </delete>
     </delete>
 
 
+    <select id="getNearlyMonthGmv" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT SUM(order_amount) as 'orderAmount', CONCAT(IFNULL(ROUND((SELECT COUNT(1)
+                                                                        FROM kuaishou_item_collect_samples
+                                                                        WHERE collect_sample_status = 7
+                                                                          AND promoter_id = #{promoterId})
+            / (SELECT COUNT(1)
+               FROM kuaishou_item_collect_samples
+               WHERE collect_sample_status!=1 AND collect_sample_status!=2 AND promoter_id = #{promoterId})*100,2), 0),
+                                                          '%') as 'operationCompletionRate'
+        FROM kuaishou_supply_chain
+        WHERE promoter_id = #{promoterId}
+          AND FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') >= #{start}
+          AND FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') &lt;= #{end}
+    </select>
 </mapper>
 </mapper>