浏览代码

Merge branch 'test' of http://git.tjyourong.com.cn/ctop/adsp-boot into test

syh 4 年之前
父节点
当前提交
007246376b

+ 16 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProductController.java

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.service.IProductService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+
 import cn.com.ctop.common.module.vo.ProductInfoDto;
 import cn.com.ctop.common.module.vo.ProductVO;
 import cn.com.ctop.common.module.vo.ProjectVO;
@@ -21,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -146,6 +148,20 @@ public class ProductController {
         log.info("/ctop/product/insertOrUpdateProduct 方法开始");
         Result result = new Result();
 
+        if(vo==null || vo.getId() == null){
+            if(StringUtils.isBlank(vo.getProductName())){
+                result.setSuccess(false);
+                result.setMessage("产品不能为空");
+                return result;
+            }
+            Integer count = productService.getProductNameCount(vo.getProductName());
+            if(count != 0){
+                result.setSuccess(false);
+                result.setMessage("产品名字不正确");
+                return result;
+            }
+        }
+
         try {
             productService.insertOrUpdateProduct(vo);
         }catch (Exception e){

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MediaReportMapper.xml

@@ -468,7 +468,7 @@
                         AND a.advertiser_id = #{advertiserId}
                     </if>
                     <if test="companyId != null and companyId != ''">
-                        AND a.company_id = #{companyId}
+                        AND d.company_id = #{companyId}
                     </if>
                     <if test="productId != null and productId != ''">
                         AND a.id = #{productId}

+ 19 - 9
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -2,6 +2,8 @@ package org.jeecg;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRefreshTokenService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
@@ -23,28 +25,36 @@ public class SampleTest {
     private ICtopOauthTokenService oauthTokenService;
     @Autowired
     private IByteDanceCreativeService creativeService;
-	@Autowired
+    @Autowired
     private IByteDanceCampaignService campaignService;
     @Autowired
     private IKuaishouReportDailyAgentService kuaishouReportDailyAgentService;
+    @Autowired
+    private IKuaiShouDailyAgentService kuaiShouDailyAgentService;
+    @Autowired
+    private IRefreshTokenService refreshTokenService;
 
     @Test
     public void loadBytedanceCreativeData() {
-        CtopOauthToken token = oauthTokenService.getTokenByAccountId(1649600126891015L);
-        creativeService.getAdvertiserCreative(token,null,null);
+
+     //   refreshTokenService.getKuaiShouAgentRefresh();
+
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        kuaiShouDailyAgentService.getAgentReportByPage(nowDate, nowDate);
     }
 
     @Test
-    public void testLoadBytedanceData(){
+    public void testLoadBytedanceData() {
         CtopOauthToken token = oauthTokenService.getTokenByAccountId(1673731621920840L);
-       campaignService.getAdvertiserCampaign(token,null,null);
+        campaignService.getAdvertiserCampaign(token, null, null);
     }
 
     @Test
-    public void loadKuaishouAgentData(){
-        for(int i=0;i<30;i++){
-            String currentDate = DateUtils.formatDate(DateUtils.addDay(new Date(),-i));
-            kuaishouReportDailyAgentService.getReport(currentDate,DateUtils.getNowDate("yyyy-MM-dd"));
+    public void loadKuaishouAgentData() {
+        for (int i = 0; i < 30; i++) {
+            String currentDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
+            kuaishouReportDailyAgentService.getReport(currentDate, DateUtils.getNowDate("yyyy-MM-dd"));
         }
     }
 }

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/ProductMapper.java

@@ -28,6 +28,8 @@ public interface ProductMapper extends BaseMapper<Product> {
 
     void insertProductProjectMap(@Param("projectIds")List<Long> projectIds, @Param("productId")Long productId);
 
+    Integer getProductNameCount(@Param("productName")String productName);
+
     void updateProduct(@Param("product")ProductVO product);
 
     Product getProductInfo(@Param("id")Long id);

+ 10 - 3
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/ProductMapper.xml

@@ -58,9 +58,7 @@
 
     <select id="getSaleListByProjectIds" resultType="cn.com.ctop.common.module.vo.ProductDto">
         select
-        a.id as projectId,
-        a.project_name as projectName,
-        a.sale_id as saleId,
+        distinct a.sale_id as saleId,
         b.realname as saleName
         from
         ctop_project a
@@ -105,6 +103,15 @@
         </foreach>
     </insert>
 
+    <select id="getProductNameCount" resultType="integer">
+        select
+        count(1)
+        from
+        ctop_product
+        where
+        product_name = #{productName}
+    </select>
+
     <update id="updateProduct">
         update
         ctop_product

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IProductService.java

@@ -7,6 +7,7 @@ import cn.com.ctop.common.module.vo.ProductVO;
 import cn.com.ctop.common.module.vo.ProjectVO;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.github.pagehelper.PageInfo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -30,6 +31,8 @@ public interface IProductService extends IService<Product> {
 
     void insertOrUpdateProduct(ProductVO product);
 
+    Integer getProductNameCount(String productName);
+
     void insertProductProjectMap(Long productId, List<Long> projectIds);
 
     Map<String, Object> getProductInfo(Long productId);

+ 6 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/ProductServiceImpl.java

@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.vo.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import org.apache.ibatis.annotations.Param;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -75,6 +76,11 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
     }
 
     @Override
+    public Integer getProductNameCount(String productName){
+        return productMapper.getProductNameCount(productName);
+    }
+
+    @Override
     public void insertProductProjectMap(Long productId, List<Long> projectIds){
         productMapper.insertProductProjectMap(projectIds, productId);
     }

+ 0 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaiShouDailyAgentServiceImpl.java

@@ -65,7 +65,6 @@ public class KuaiShouDailyAgentServiceImpl extends ServiceImpl<KuaiShouDailyAgen
 
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
-            System.err.println(resultJson);
             if (Check.isNull(resultJson)) {
                 log.info("代理商数据返回为空");
                 return;