Selaa lähdekoodia

Merge remote-tracking branch 'origin/test' into test

syh 4 vuotta sitten
vanhempi
commit
e6ec23f682

+ 8 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java

@@ -347,9 +347,16 @@ public class ProjectMemberController {
      * @return
      */
     @PostMapping(value = "/getSaleOwnProjects")
-    public Result<List<ProjectMember>> getSaleOwnProjects(@RequestParam(required = true ,name = "mediaIds") List<Integer> mediaIds) {
+    public Result<List<ProjectMember>> getSaleOwnProjects(@RequestBody JSONObject data) {
         Result<List<ProjectMember>> result = new Result<>();
 
+        JSONArray ids = data.getJSONArray("mediaIds");
+        List<Integer> mediaIds = new ArrayList<>();
+        if(null!=ids&&!ids.isEmpty()){
+            for(int i=0;i<ids.size();i++){
+                mediaIds.add(ids.getIntValue(i));
+            }
+        }
         List<ProjectMember> projectMemberList = projectMemberService.getSaleOwnProjects(mediaIds);
         if (projectMemberList == null) {
             result.error500("未找到对应实体");

+ 4 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java

@@ -133,7 +133,7 @@ public class KuaiShouController {
         Result<PageInfo<KuaishouReportDailyAccountDTO>> result = new Result<>();
         result.setSuccess(true);
 
-        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getProjectId()==null){
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
             result.setSuccess(false);
             result.setMessage("参数有误");
             return result;
@@ -162,7 +162,7 @@ public class KuaiShouController {
         Result<PageInfo<KuaishouReportDailyAccountDTO>> result = new Result<>();
         result.setSuccess(true);
 
-        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getAccountId()==null){
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
             result.setSuccess(false);
             result.setMessage("参数有误");
             return result;
@@ -192,7 +192,7 @@ public class KuaiShouController {
         Result<PageInfo<KuaishouReportDailyAccountDTO>> result = new Result<>();
         result.setSuccess(true);
 
-        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getCampaignId()==null){
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
             result.setSuccess(false);
             result.setMessage("参数有误");
             return result;
@@ -220,7 +220,7 @@ public class KuaiShouController {
         Result<PageInfo<KuaishouReportDailyAccountDTO>> result = new Result<>();
         result.setSuccess(true);
 
-        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getUnitId()==null){
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
             result.setSuccess(false);
             result.setMessage("参数有误");
             return result;

+ 8 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java

@@ -20,11 +20,11 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
 
     ProjectAccountDTO getKuaishouProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
+    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId, @Param("accountIds")List<Long> accountIds);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("accountId")Long accountId);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("accountId")Long accountId, @Param("accountIds")List<Long> accountIds);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId);
+    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId, @Param("accountIds")List<Long> accountIds);
 
     List<ProjectAccountDTO> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
 
@@ -36,9 +36,13 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
 
     List<ProjectAccountDTO> queryProjectMemberByAdmins(@Param("mediaIds")List<Long> mediaIds);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("unitId")Long unitId);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("unitId")Long unitId, @Param("accountIds") List<Long> accoundIds);
 
     KuaishouVideoInfoDTO getVideoUrl(@Param("photoId")Long photoId);
 
     List<Long> getUserProjectAccountIds(@Param("userId")String userId);
+
+    List<Long> getUserProjectAccountIdsByAdmin();
+
+
 }

+ 48 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml

@@ -593,7 +593,14 @@
         <if test="projectId!=null and projectId != '' ">
             and
             b.project_id = #{projectId}
-        </if>>
+        </if>
+        <if test="accountIds !=null">
+            and a.account_id in
+            <foreach collection="accountIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
         group by a.account_id
         order by sum(a.charge) desc
     </select>
@@ -609,7 +616,7 @@
         (select responsible_name from ctop_project where id = (select project_id from ctop_user_allocation where
         					account_id = a.account_id limit 1
 					)) as 'responsibleName',
-        (select design_responsible_name from ctop_project where id = (select project_id from ctop_user_allocation where 					account_id = a.account_id limit 1
+        (select design_responsible_name from ctop_project where id = (select project_id from ctop_user_allocation where account_id = a.account_id limit 1
 					)) as 'designResponsibleName',
         ifnull(round(sum(a.charge),2),0) as 'charge',
         ifnull(sum(a.photo_show),0) as 'photoShow',  -- 封面曝光数
@@ -741,6 +748,14 @@
             and
             a.account_id = #{accountId}
         </if>
+        <if test="accountIds !=null">
+            and a.account_id in
+            <foreach collection="accountIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+
         group by a.campaign_id
     </select>
 
@@ -814,6 +829,13 @@
             and
             a.campaign_id = #{campaignId}
         </if>
+        <if test="accountIds !=null">
+            and a.account_id in
+            <foreach collection="accountIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
         group by unit_id
     </select>
 
@@ -1062,9 +1084,17 @@
             and
             a.unit_id = #{unitId}
         </if>
+        <if test="accountIds !=null">
+            and a.account_id in
+            <foreach collection="accountIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
         group by a.creative_id
     </select>
 
+    <!-- 获取项目成员所在所有项目下的所有账户id -->
     <select id="getVideoUrl" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoInfoDTO">
         select
         url as url,
@@ -1075,14 +1105,27 @@
         limit 1
     </select>
 
-    <!-- 获取项目成员所在所有项目下的所有账户id -->
     <select id="getUserProjectAccountIds" resultType="long">
         select
         a.account_id
         from
-        (select * from ctop_user_allocation  group by account_id) a
+        (select project_id,account_id,media_id from ctop_user_allocation  group by account_id) a
         left join ctop_project_member b on a.project_id=b.project_id
-        where b.user_id = #{userId}
+        where
+        and a.media_id in (2,4)
+        order by a.create_time desc
+        limit 50
+    </select>
+
+    <select id="getUserProjectAccountIdsByAdmin" resultType="long">
+        select
+        a.account_id
+        from
+        ctop_user_allocation a
+        left join ctop_project b on a.project_id = b.id
+        where
+        b.media_id in (2,4)
+        limit 50
     </select>
 
 </mapper>

+ 62 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java

@@ -31,6 +31,7 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         return dailyAccountMapper.selectCost(accountId, startDate, endDate);
     }
 
+    //获取快手参与的项目的信息
     @Override
     public PageInfo<ProjectAccountDTO> getKuaishouProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort ){
         List<ProjectAccountDTO> projectAccountDTOList = new ArrayList<>();
@@ -154,26 +155,83 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
 
     @Override
     public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //String userId = "e9ca23d68d884d4ebb19d07889727dae";
+        String userId = sysUser.getId();
+        String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
+
+        List<Long> accountIds = null;
+        if(projectId == null){
+            if("admin".equals(roleCode)){
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+            }else {
+                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId);
+            }
+        }
+
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId, accountIds));
     }
 
     @Override
     public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //String userId = "e9ca23d68d884d4ebb19d07889727dae";
+        String userId = sysUser.getId();
+        String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
+
+        List<Long> accountIds = null;
+        if(accountId == null){
+            if("admin".equals(roleCode)){
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+            }else {
+                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId);
+            }
+        }
+
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouCampaignInfoByAccountId(startDate, endDate, accountId));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouCampaignInfoByAccountId(startDate, endDate, accountId,accountIds));
     }
 
     @Override
     public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //String userId = "e9ca23d68d884d4ebb19d07889727dae";
+        String userId = sysUser.getId();
+        String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
+
+        List<Long> accountIds = null;
+        if(campaignId == null){
+            if("admin".equals(roleCode)){
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+            }else {
+                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId);
+            }
+        }
+
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouUnitInfoByCampaignId(startDate, endDate, campaignId));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouUnitInfoByCampaignId(startDate, endDate, campaignId,accountIds));
     }
 
     @Override
     public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //String userId = "e9ca23d68d884d4ebb19d07889727dae";
+        String userId = sysUser.getId();
+        String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
+
+        List<Long> accountIds = null;
+        if(unitId == null){
+            if("admin".equals(roleCode)){
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+            }else {
+                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId);
+            }
+        }
+
         PageHelper.startPage(pageNum,pageSize);
-        List<KuaishouReportDailyAccountDTO> kuaishouCreativeInfoList = dailyAccountMapper.getKuaishouCreativeInfoByUnitId(startDate, endDate, unitId);
+        List<KuaishouReportDailyAccountDTO> kuaishouCreativeInfoList = dailyAccountMapper.getKuaishouCreativeInfoByUnitId(startDate, endDate, unitId,accountIds);
         //for(KuaishouReportDailyAccountDTO creativeInfo:kuaishouCreativeInfoList){
         //    KuaishouVideoInfoDTO videoInfo = dailyAccountMapper.getVideoUrl(creativeInfo.getPhotoId());
         //    creativeInfo.setUrl(videoInfo.getUrl());

+ 5 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceAccountReportMapper.java

@@ -45,7 +45,7 @@ public interface BytedanceAccountReportMapper {
     //查询固定月的明细数据
     List<JSONObject> queryDetailGroupDayByMonth(@Param("month") String month);
 
-    List<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
+    List<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId, @Param("accountIds")List<Long> accountIds);
 
     ByteDanceReportAccountDailyDTO getBytedanceProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
 
@@ -59,4 +59,8 @@ public interface BytedanceAccountReportMapper {
 
     List<ByteDanceReportAccountDailyDTO> queryProjectMemberByIds(@Param("projectIds")List<Long> projectIds);
 
+    List<Long> getUserProjectAccountIds(@Param("userId")String userId);
+
+    List<Long> getUserProjectAccountIdsByAdmin();
+
 }

+ 28 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAccountReportMapper.xml

@@ -305,6 +305,13 @@
             and
             b.project_id = #{projectId}
         </if>
+        <if test="accountIds !=null">
+            and a.advertiser_id in
+            <foreach collection="accountIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
         group by a.advertiser_id
         -- order by sum(a.cost) desc
     </select>
@@ -391,6 +398,27 @@
         order by create_time desc
     </select>
 
+    <select id="getUserProjectAccountIds" resultType="long">
+        select
+        a.account_id
+        from
+        (select project_id,account_id,media_id from ctop_user_allocation  group by account_id) a
+        left join ctop_project_member b on a.project_id=b.project_id
+        where
+        and a.media_id in (1,3)
+        order by a.create_time desc
+        limit 50
+    </select>
 
+    <select id="getUserProjectAccountIdsByAdmin" resultType="long">
+        select
+        a.account_id
+        from
+        ctop_user_allocation a
+        left join ctop_project b on a.project_id = b.id
+        where
+        b.media_id in (1,3)
+        limit 50
+    </select>
 
 </mapper>

+ 16 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAccountReportServiceImpl.java

@@ -260,13 +260,28 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
 
     @Override
     public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort){
+
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //String userId = "e9ca23d68d884d4ebb19d07889727dae";
+        String userId = sysUser.getId();
+        String roleCode = bytedanceAccountReportMapper.getRoleCodeByUserId(userId);
+
+        List<Long> accountIds = null;
+        if(projectId == null){
+            if("admin".equals(roleCode)){
+                accountIds = bytedanceAccountReportMapper.getUserProjectAccountIdsByAdmin();
+            }else {
+                accountIds = bytedanceAccountReportMapper.getUserProjectAccountIds(userId);
+            }
+        }
+
         if(StringUtils.isBlank(sort)){
             sort = "cost-";
         }
         sort = sort.replace("-", " desc,").replace("+", " asc,");  //sort=id-name+age+
         sort = sort.substring(0, sort.length() - 1);
         PageHelper.startPage(pageNo,pageSize,sort);
-        return new PageInfo<>(bytedanceAccountReportMapper.getBytedanceAccountInfoByProjectId(startDate,endDate,projectId));
+        return new PageInfo<>(bytedanceAccountReportMapper.getBytedanceAccountInfoByProjectId(startDate,endDate,projectId,accountIds));
     }