ソースを参照

财务-查询账户及图片数量

yangzian 4 年 前
コミット
c9c5f6c01b

+ 3 - 3
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsSaleAssistantInfoMapper.xml

@@ -36,7 +36,7 @@
                 d.id
         )
         ORDER BY
-            create_time
+            create_time DESC;
     </select>
 
 <!--查询对应销售 -->
@@ -55,7 +55,7 @@
         <if test="userId !=null and userId != ''">
             OR u.id = #{userId}
         </if>
-        GROUP BY u.create_time DESC;
+        GROUP BY u.create_time;
 
 
     </select>
@@ -75,7 +75,7 @@
         <if test="userId !=null and userId != ''">
             OR u.id = #{userId}
         </if>
-        GROUP BY u.create_time DESC;
+        GROUP BY u.create_time;
     </select>
 
 

+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java

@@ -43,7 +43,7 @@ public interface ReportSettlementMapper {
      * 查询 账户id
      * @return
      */
-   List<String> getAccountIdBytedance(@Param("sales") Set<String> sales, @Param("mediaId")String mediaId, @Param("advertiserId")String advertiserId, @Param("productId")String productId);
+   List<String> getAccountIdBytedance(@Param("sales") Set<String> sales, @Param("mediaId")String mediaId, @Param("advertiserId")String advertiserId, @Param("productId")String productId,@Param("projectId")String projectId);
    List<String> getAccountIdBytedanceRepeat(@Param("accountIds") List<String> accountIds,@Param("uploadYears")String uploadYears);
    List<String> getAccountIdKuaiShouRepeat(@Param("accountIds") List<String> accountIds,@Param("uploadYears")String uploadYears);
 

+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementFileInfoMapper.java

@@ -36,7 +36,7 @@ public interface SettlementFileInfoMapper extends BaseMapper<CtopCwjsSettlementF
 
 
     /**
-     * 查询账户数量以及图片数量
+     * 查询图片数量
      * @param paramsVo
      * @return
      */

+ 10 - 5
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/ReportSettlementMapper.xml

@@ -41,15 +41,20 @@
     <!-- 查询 头条 账户id-->
     <select id="getAccountIdBytedance" resultType="java.lang.String">
         SELECT
-         account_id as accountId
+        c.account_id AS accountId
         FROM
-        ctop_cwjs_settlement_info
-        where del_flag = 0
+        ctop_cwjs_settlement_info c
+        LEFT JOIN ctop_user_allocation u ON c.account_id = u.account_id
+        WHERE
+        del_flag = 0
         <if test="advertiserId !=null and advertiserId != ''">
-            AND advertiser_id = #{advertiserId}
+            AND c.advertiser_id = #{advertiserId}
         </if>
         <if test="productId !=null and productId != ''">
-            AND product_id = #{productId}
+            AND c.product_id = #{productId}
+        </if>
+        <if test="projectId !=null and projectId != ''">
+            AND u.project_id = #{projectId}
         </if>
         <if test="mediaId !=null and mediaId != ''">
             AND media_id = #{mediaId}

+ 23 - 37
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementFileInfoMapper.xml

@@ -194,43 +194,29 @@
 
     <!-- 查询账户数量以及图片数量 -->
     <select id="getAccountNumAndImgNum" resultType="java.util.Map">
-        SELECT * from
-                     (
-                    SELECT
-                    COUNT(c.account_id) as accountNum
-                    FROM
-                    ctop_cwjs_settlement_info c
-                    LEFT JOIN ctop_user_allocation u on c.account_id = u.account_id
-                    where del_flag = 0
-                        <if test="advertiserId !=null and advertiserId != ''">
-                            AND c.advertiser_id = #{advertiserId}
-                        </if>
-                        <if test="productId !=null and productId != ''">
-                            AND c.product_id = #{productId}
-                        </if>
-                        <if test="mediaId !=null and mediaId != ''">
-                            AND c.media_id = #{mediaId}
-                        </if>
-                         ) t1,
-                     (
-                         SELECT
-                                COUNT(DISTINCT account_id) as imageNum
-                            FROM
-                                 ctop_cwjs_settlement_file_info
-                         where del_flag = 0
-                        <if test="advertiserId !=null and advertiserId != ''">
-                            AND advertiser_id = #{advertiserId}
-                        </if>
-                        <if test="productId !=null and productId != ''">
-                            AND product_id = #{productId}
-                        </if>
-                        <if test="mediaId !=null and mediaId != ''">
-                            AND media_id = #{mediaId}
-                        </if>
-                           <if test="uploadYears !=null and uploadYears != ''">
-                            AND upload_years = #{uploadYears}
-                        </if>
-                     ) t2
+
+        SELECT
+        COUNT( DISTINCT c.account_id ) AS imageNum
+        FROM
+        ctop_cwjs_settlement_file_info c
+        LEFT JOIN ctop_user_allocation u ON c.account_id = u.account_id
+        WHERE
+        del_flag = 0
+        <if test="advertiserId !=null and advertiserId != ''">
+            AND c.advertiser_id = #{advertiserId}
+        </if>
+        <if test="productId !=null and productId != ''">
+            AND c.product_id = #{productId}
+        </if>
+        <if test="mediaId !=null and mediaId != ''">
+            AND c.media_id = #{mediaId}
+        </if>
+        <if test="projectId !=null and projectId != ''">
+            AND u.project_id = #{projectId}
+        </if>
+       <if test="uploadYears !=null and uploadYears != ''">
+            AND c.upload_years = #{uploadYears}
+        </if>
     </select>
 
 

+ 17 - 12
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java

@@ -30,6 +30,7 @@ import org.jeecg.ctop.finance.policy.entity.CwjsPolicyProduct;
 import org.jeecg.ctop.finance.policy.mapper.CwjsCompanySubjectMapper;
 import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyInfoMapper;
 import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyProductMapper;
+import org.jeecg.ctop.finance.policy.service.impl.CwjsSaleAssistantInfoServiceImpl;
 import org.jeecg.ctop.finance.policy.utils.Check;
 import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementInfo;
 import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSlettementReport;
@@ -82,6 +83,9 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     @Resource
     private SysLogMapper sysLogMapper;
 
+    @Autowired
+    private CwjsSaleAssistantInfoServiceImpl cwjsSaleAssistantInfoService;
+
 
     @Override
     public List<SettlementReportBytedanceVo> getAccountTransactionDayBytedance() {
@@ -276,30 +280,30 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
         String uploadYears = paramsVo.getUploadYears();
         //1:区分媒体(头条:1 快手:2)
         Integer mediaId = paramsVo.getMediaId();
-
         String roleCode = roleMapper.getRoleCodeByUserId(user.getId());
         Set<String>sales = new HashSet<>();
+        List<String> userIds = new ArrayList<>();
         List<UserAllocation>allocations ;
         if("admin".equals(roleCode)|| "finance".equals(roleCode)){
             //查询所有可用的账户
-        }else if("saleDirector".equals(roleCode)){
-            //查询自己下辖的所有销售绑定的账户
-            sales = materialReportOverViewService.recursiveQuerySubordinate(paramsVo.getCreateUserId());
-        }else if("saleAssistant".equals(roleCode)|| "sale".equals(roleCode)|| "saleAm".equals(roleCode)){
-            //查询自己名绑定下的账户
-            sales.add(user.getId());
-        }
-        if(sales.isEmpty()){
             sales = null;
+        }else {
+            //查询 销售及助理 关联对应的人员
+            userIds = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(user.getId());
+            sales.addAll(new HashSet<>(userIds));
         }
-        List<String> settlementAccountList = reportSettlementMapper.getAccountIdBytedance(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId());
-        allocations = userAllocationMapper.getAccountInfoBySalesId(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId());
+        //查询财务模块中已上传的账户
+        List<String> settlementAccountList = reportSettlementMapper.getAccountIdBytedance(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId(),paramsVo.getProjectId());
+        //查询已绑定账户
+        allocations = userAllocationMapper.getAccountInfoBySalesId(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId(),paramsVo.getProjectId());
         return mergeAccountId(settlementAccountList,allocations,uploadYears);
     }
 
+    //账户处理
     private List<String> mergeAccountId(List<String> settlementAccountList, List<UserAllocation> allocations,String downloadYear) {
         List<String>salesAccount = new ArrayList<>();
-        for(UserAllocation allocation:allocations){
+        // 账户状态 0 启动 1 禁用
+        for(UserAllocation allocation : allocations){
             if(allocation.getAccountStatus() == 0){
                 salesAccount.add(allocation.getAccountId()+"");
             }
@@ -313,6 +317,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 }
             }
         }
+        //去重
         settlementAccountList.removeAll(salesAccount);
         settlementAccountList.addAll(salesAccount);
         return settlementAccountList;

+ 2 - 4
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementFileInfoServiceImpl.java

@@ -125,7 +125,6 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
             settlementFileInfoQw.eq("advertiser_id",map.get("advertiserId"));
             //产品id
             settlementFileInfoQw.eq("product_id",map.get("productId"));
-
             settlementFileInfoQw.eq("account_id",map.get("accountId"));
             //媒体类型 1-头条 2-快手 3-头条内广 4-快手内广
             settlementFileInfoQw.eq("media_id",map.get("mediaId"));
@@ -135,10 +134,7 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
             settlementFileInfoQw.eq("del_flag",0);
             List<CtopCwjsSettlementFileInfo> settlementFileList =  settlementFileInfoMapper.selectList(settlementFileInfoQw);
             map.put("imgNum",Check.isNull(settlementFileList) ? "0" : String.valueOf(settlementFileList.size()));
-
         }
-
-
         PageInfo<Map<String,String>> pageInfo = new PageInfo<>(list);
         return Result.successMsg("财务结算-结算单列表查询成功", pageInfo);
     }
@@ -197,7 +193,9 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
      */
     @Override
     public Result getAccountNumAndImgNum(SettlementFileParamsVo paramsVo, SysUser user) {
+        //查询图片数量
         Map<String,String> map =  settlementFileInfoMapper.getAccountNumAndImgNum(paramsVo);
+        //查询账户数量
         List<String>accountIds = reportSettlementService.getAccountId(paramsVo,user);
         if (Check.isNull(accountIds)){
             map.put("accountNum","0");

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -68,7 +68,7 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
 
     void updCwjsSettlementStatus(@Param("id") String id, @Param("status") Integer status);
 
-    List<UserAllocation> getAccountInfoBySalesId(@Param("sales") Set<String> sales, @Param("mediaId") String mediaId, @Param("advertiserId") String advertiserId, @Param("productId") String productId);
+    List<UserAllocation> getAccountInfoBySalesId(@Param("sales") Set<String> sales, @Param("mediaId") String mediaId, @Param("advertiserId") String advertiserId, @Param("productId") String productId,@io.lettuce.core.dynamic.annotation.Param("projectId")String projectId);
 
     List<JSONObject> getAccountListByProjectListV2(@Param("list") List list);
 

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -290,6 +290,9 @@ ORDER BY
         <if test="productId!=null and productId!= '' ">
             and cp.product_id = #{productId}
         </if>
+        <if test="projectId!=null and projectId!= '' ">
+            and cp.id = #{projectId}
+        </if>
         <if test="sales !=null and sales.size() > 0">
             AND cp.sale_id in
             <foreach collection="sales" item="item" separator=","