Browse Source

财务结算-结算单

yangzian 4 năm trước cách đây
mục cha
commit
1fa04be202

+ 2 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/JeecgBootFinanceApplication.java

@@ -7,6 +7,7 @@ import org.apache.shiro.spring.boot.autoconfigure.ShiroBeanAutoConfiguration;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.annotation.ComponentScan;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 /**
  * zian Y
@@ -16,6 +17,7 @@ import org.springframework.context.annotation.ComponentScan;
 @SpringBootApplication(exclude = {ShiroAnnotationProcessorAutoConfiguration.class, ShiroAutoConfiguration.class, ShiroBeanAutoConfiguration.class})
 @EnableDubbo
 @ComponentScan(basePackages = {"org.jeecg", "cn.com.ctop"})
+@EnableTransactionManagement
 public class JeecgBootFinanceApplication {
 
     public static void main(String[] args) {

+ 10 - 3
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java

@@ -53,11 +53,18 @@ public class SettlementFileController {
         //查询用户角色
         String roleCode = sysRoleService.getRoleCodeByUserId(paramsVo.getCreateUserId());
 
-        if ("admin".equals(roleCode)){
+        //管理员 || 财务
+        if ("admin".equals(roleCode) || "finance".equals(roleCode)){
             paramsVo.setOperatorUserIds(null);
             paramsVo.setSaleUserIds(null);
-         //运营经理   touTiaoOperationManager-头条运营经理   kuaishouOperationManager-快手运营经理
-        }else if (roleCode.contains("OperationManager")){
+         //运营经理
+        }else if ("kuaishou_operations_director".equals(roleCode) || //快手运营总监
+                "toutiao_operations_manager".equals(roleCode) || // 头条运营经理
+                "externalOperationManager".equals(roleCode) || //外部运营经理
+                "genera_manager_of_operations".equals(roleCode) || //运营总经理
+                "toutiao_operations_director".equals(roleCode) || //头条运营总监
+                "kuaishou_operations_manager".equals(roleCode)) //快手运营经理
+         {
             //查询所有包含自己的下级
             Set<String> operatorUserIds= materialReportOverViewService.recursiveQuerySubordinate(paramsVo.getCreateUserId());
             paramsVo.setOperatorUserIds(operatorUserIds);

+ 2 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/pojo/ctopCwjsSettlementInfo.java

@@ -102,9 +102,11 @@ public class ctopCwjsSettlementInfo implements Serializable {
     /**
      * 更新时间
      */
+    @TableField(exist = false)
     private Date updateTime;
 
 
+    @TableField(exist = false)
     private Set<String> userIds;
 
 }

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

@@ -42,4 +42,12 @@ public interface SettlementFileInfoMapper extends BaseMapper<ctopCwjsSettlementF
      * @return
      */
     Map<String,String> getAccountNumAndImgNum(SettlementFileParamsVo paramsVo);
+
+
+    /**
+     * 查询该账户是否已绑定 或开户
+     * @param accountId
+     * @return
+     */
+    Map<String,String> getSettlementAccount(String accountId);
 }

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

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.ctop.finance.settlement.mapper.SettlementFileInfoMapper">
 
-    <!-- 查询 财务结算-结算单列表-->
+    <!-- 查询 财务结算-结算单列表
     <select id="getSettlementSheetList" resultType="java.util.LinkedHashMap">
         SELECT
            t.*,
@@ -53,9 +53,6 @@
             <if test="accountName !=null and accountName != ''">
                 AND accountName like concat ('%',#{accountName},'%')
             </if>
-            <if test="createUserId !=null and createUserId != ''">
-                AND saleUserId = #{createUserId}
-            </if>
             <if test="mediaId !=null and mediaId != ''">
                 AND media_id = #{mediaId}
             </if>
@@ -89,6 +86,78 @@
         ORDER BY imageCreateTIme DESC
 
     </select>
+-->
+
+    <!-- 查询 财务结算-结算单列表-->
+    <select id="getSettlementSheetList" resultType="java.util.LinkedHashMap">
+        SELECT * FROM
+        (
+        SELECT
+        f.id,
+        f.upload_years as uploadYears,
+        f.media_id as mediaId,
+        f.advertiser_id as advertiserId,
+        ( SELECT ad.NAME FROM ctop_advertiser ad WHERE ad.id = cwjs.advertiser_id LIMIT 1 ) advertiserName,
+        f.product_id as productId,
+        ( SELECT cp.product_name FROM ctop_product cp WHERE cp.id = cwjs.product_id LIMIT 1 ) productName,
+        cwjs.project_id as projectId,
+        ( SELECT project.project_name FROM ctop_project project WHERE project.id = cwjs.project_id LIMIT 1 ) projectName,
+        cwjs.account_id as accountId,
+        cwjs.account_name as accountName,
+        f.del_flag,
+        cwjs.create_user_id as saleUserId,
+        ( SELECT su.realname FROM sys_user su WHERE su.id = cwjs.create_user_id LIMIT 1 ) saleUserName,
+        f.create_user_id as operateUserId,
+        ( SELECT su.realname FROM sys_user su WHERE su.id = f.create_user_id LIMIT 1 ) operateUserName
+        FROM ctop_cwjs_settlement_file_info f
+        LEFT JOIN ctop_cwjs_settlement_info cwjs on f.account_id = cwjs.account_id
+        where f.del_flag = 0
+        GROUP BY f.account_id,f.upload_years,f.create_user_id
+        ORDER BY f.upload_years DESC
+        ) t
+        <where>
+            <if test="advertiserName !=null and advertiserName != ''">
+                AND advertiserName like concat ('%',#{advertiserName},'%')
+            </if>
+            <if test="productName !=null and productName != ''">
+                AND productName like concat ('%',#{productName},'%')
+            </if>
+            <if test="projectName !=null and projectName != ''">
+                AND projectName like concat ('%',#{projectName},'%')
+            </if>
+            <if test="accountName !=null and accountName != ''">
+                AND accountName like concat ('%',#{accountName},'%')
+            </if>
+            <if test="mediaId !=null and mediaId != ''">
+                AND mediaId = #{mediaId}
+            </if>
+            <if test="startTime !=null and startTime != ''">
+                AND uploadYears &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND uploadYears &lt;= #{endTime}
+            </if>
+            <if test="createUserName !=null and createUserName != ''">
+                AND operateUserId like concat ('%',#{createUserName},'%')
+            </if>
+            <if test="operatorUserIds !=null and operatorUserIds != ''">
+                AND operateUserId in
+                <foreach collection="operatorUserIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="saleUserIds !=null and saleUserIds != ''">
+                AND saleUserId in
+                <foreach collection="saleUserIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+        </where>
+    </select>
 
 
 
@@ -98,6 +167,7 @@
         SET del_flag = 1
         WHERE advertiser_id = #{advertiserId}
           and product_id = #{productId}
+          and account_id = #{accountId}
           and media_id = #{mediaId}
           and upload_years = #{uploadYears}
           and create_user_id = #{createUserId}
@@ -138,12 +208,26 @@
                             AND media_id = #{mediaId}
                         </if>
                      ) t2
+    </select>
 
 
 
-    </select>
 
+    <!-- 查询该账户是否已绑定 或开户-->
+    <select id="getSettlementAccount" resultType="java.util.Map">
+        SELECT
+            u.account_id AS accountId,
+            u.auth_name AS accountName
+        FROM
+            ctop_cwjs_settlement_info f,
+            ctop_user_allocation u
+        WHERE
+            f.account_id = u.account_id
+          AND u.account_status = 0
+          AND u.account_id = #{accountId}
+            LIMIT 1
 
+    </select>
 
 
 

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

@@ -28,6 +28,8 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mapping.AccessOptions;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
@@ -56,7 +58,7 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
      * @return: org.jeecg.common.api.vo.Result
      * @author: zianY
      */
-    @Override
+   /* @Override
     public Result<PageInfo<Map<String,String>>> getSettlementSheetList(SettlementFileParamsVo paramsVo, Integer pageNo, Integer pageSize) {
         Set accountSet = new HashSet();
         Set imageSet = new HashSet();
@@ -110,6 +112,46 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
         PageInfo<Map<String,String>> pageInfo = new PageInfo<>(list);
         return Result.successMsg("财务结算-结算单列表查询成功。", pageInfo);
     }
+*/
+
+    /**
+     *
+     * @description: 查询 财务结算-结算单列表
+     *
+     * @param paramsVo
+     * @param pageNo
+     * @param pageSize
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    @Override
+    public Result<PageInfo<Map<String,String>>> getSettlementSheetList(SettlementFileParamsVo paramsVo, Integer pageNo, Integer pageSize) {
+        PageHelper.startPage(pageNo, pageSize);
+        List<Map<String,String>> list = settlementFileInfoMapper.getSettlementSheetList(paramsVo);
+        for (Map<String, String> map : list) {
+            //图片数量
+            QueryWrapper<ctopCwjsSettlementFileInfo> settlementFileInfoQw = new QueryWrapper<>();
+            //广告主id
+            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"));
+            //上传人 (运营)
+            settlementFileInfoQw.eq("create_user_id",map.get("operateUserId"));
+            //(0,正常,1已删除)
+            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);
+    }
 
 
     /**
@@ -134,13 +176,21 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
      * @author: zianY
      */
     @Override
+    @Transactional
     public Result insertAccountImages(ctopCwjsSettlementFileInfo settlementFileInfo) {
-        settlementFileInfo.getSettlementList().forEach(settlement -> {
+
+        for (ctopCwjsSettlementFileInfo settlement : settlementFileInfo.getSettlementList()) {
+
             settlement.setAccountId(SettlementUtil.subAccountName(settlement.getFileName()));
-            //BeanUtils.copyProperties(settlementFileInfo,settlement,true,CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
+
+            Map<String,String> map = settlementFileInfoMapper.getSettlementAccount(settlement.getFileName());
+            if (Check.isNull(map)){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return Result.errorMsg("无法查询到账户【"+settlement.getAccountId()+"】开户信息,请联系销售绑定账户。");
+            }
             BeanUtils.copyProperties(settlementFileInfo,settlement,SettlementUtil.getNullPropertyNames(settlementFileInfo));
             settlementFileInfoMapper.insert(settlement);
-        });
+        }
         return Result.successMsg("账户截图上传成功。",null);
     }
 

+ 19 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/utils/SettlementUtil.java

@@ -1,5 +1,6 @@
 package org.jeecg.ctop.finance.utils;
 
+import org.jeecg.ctop.finance.policy.utils.Check;
 import org.springframework.beans.BeanWrapper;
 import org.springframework.beans.BeanWrapperImpl;
 
@@ -20,6 +21,16 @@ import java.util.Set;
 public class SettlementUtil {
 
 
+    public static String getFileNameNoEx(String filename) {
+        if ((filename != null) && (filename.length() > 0)) {
+            int dot = filename.lastIndexOf('.');
+            if ((dot >-1) && (dot < (filename.length()))) {
+                return filename.substring(0, dot);
+            }
+        }
+        return filename;
+    }
+
     /**
      * 格式:123456-1
      * 截取 账户 id
@@ -27,7 +38,14 @@ public class SettlementUtil {
      * @return
      */
     public static String subAccountName(String str){
-        return str.substring(0, str.indexOf("-"));
+        if (!Check.isNull(str)){
+            if (str.contains("-")){
+                return str.substring(0, str.indexOf("-"));
+            }
+        }
+        return getFileNameNoEx(str);
+
+
     }
 
     /**