yumeng 3 dienas atpakaļ
vecāks
revīzija
c7675450e8

+ 7 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/MailLogMapper.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -31,4 +32,10 @@ public interface MailLogMapper extends BaseMapper<MailLog> {
     List<JSONObject> getWChatIdByAccountId(@Param("accountId") Long accountId);
 
     List<JSONObject> getIllegalWChatId(@Param("accountId") Long accountId, @Param("userId") String userId);
+
+    JSONObject getAccountInfo(@Param("accountId") Long accountId);
+
+    BigDecimal getBytedanceCost(@Param("accountId") Long accountId);
+
+    BigDecimal getKuaishouCost(@Param("accountId") Long accountId);
 }

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

@@ -115,5 +115,27 @@
         WHERE
             wexin_email = #{mail}
     </select>
+    <select id="getAccountInfo" resultType="com.alibaba.fastjson.JSONObject">
+        select media_id as 'mediaId', (case
+                                           when media_id = 1
+                                               then 'b07f2bdd0f914f1dab2b4e841764911f'
+                                           when media_id = 2
+                                               then 'f6a6843879c949618e4a859140c8a127'
+                                           else ''
+            end) as 'leaderId'
+        from ctop_user_allocation
+        where account_id = #{accountId}
+    </select>
+    <select id="getBytedanceCost" resultType="java.math.BigDecimal">
+        select sum(cost)
+        from application.bytedance_advertiser_report_daily_dw
+        where account_id = #{accountId}
+          and stat_datetime >= DATE_FORMAT(CURDATE(), '%Y%m01')
+
+    </select>
+    <select id="getKuaishouCost" resultType="java.math.BigDecimal">
+        select  sum(charge) from application.kuaishou_account_report_daily_dw where stat_date >= DATE_FORMAT(CURDATE() ,'%Y%m01') and account_id = #{accountId}
+
+    </select>
 
 </mapper>

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/IMailLogService.java

@@ -3,6 +3,8 @@ package cn.com.ctop.common.module.service;
 import cn.com.ctop.common.module.entity.MailLog;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.math.BigDecimal;
+
 /**
  * 邮箱记录表
  *
@@ -24,4 +26,7 @@ public interface IMailLogService extends IService<MailLog> {
     void sendWeChat(String responsibleId, Long accountId, String projectName, String transferor, String assignee);
 
     void sendWeChatByStatus(String projectName, Integer status, String transferor, Long accountId);
+
+
+    void sendLeaderWeChat(String projectName, Integer status, String leaderId, Long accountId, String transferor, String assignee, BigDecimal cost);
 }

+ 19 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/MailLogServiceImpl.java

@@ -15,6 +15,7 @@ import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 
 /**
  * 邮箱记录表
@@ -80,4 +81,22 @@ public class MailLogServiceImpl extends ServiceImpl<MailLogMapper, MailLog> impl
             corpWexinUtils.sendMessageByWeChatId(weChatId, text.toString());
         }
     }
+
+    @Override
+    public void sendLeaderWeChat(String projectName, Integer status, String leaderId, Long accountId, String transferor, String assignee, BigDecimal cost) {
+        JSONObject weChatId = mailLogMapper.getWChatIdByUserId(leaderId);
+        if (!Check.isNull(weChatId)) {
+            String transferorName = mailLogMapper.getUserNameByUserId(transferor); // 转让人姓名
+            String assigneeName = mailLogMapper.getUserNameByUserId(assignee); // 转让人姓名
+            StringBuilder text = new StringBuilder();
+            text.append("转户审核通过通知").append("<br/>").
+                    append("项目:").append(projectName).append("<br/>")
+                    .append("账号:" + accountId).append("<br/>")
+                    .append("申请由:" + transferorName + "转户于:" + assigneeName).append("<br/>")
+                    .append("本月消耗:" + cost).append("<br/>")
+                    .append("审核结果为:通过,请知晓~");
+
+            corpWexinUtils.sendMessageByWeChatId(weChatId, text.toString());
+        }
+    }
 }

+ 6 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/finance/payment/controller/FinancePaymentApplicationController.java

@@ -54,7 +54,7 @@ public class FinancePaymentApplicationController {
         String roleCode = sysRoleService.getRoleCodeByUserId(application.getUserId());
 
         if ("saleAssistant".equals(roleCode)) {
-            if ("4f6454dbad954a8094013bf4c6d74796".equals(application.getUserId())) {
+            if ("4f6454dbad954a8094013bf4c6d74796".equals(application.getUserId())  || "163a4cc9a72c425e873d36d08e75f2cd".equals(application.getUserId())) {
                 List<String> userIds = new ArrayList<>();
                 userIds.add("4f6454dbad954a8094013bf4c6d74796");//曹媛 销售助理
                 userIds.add("42e137a90ca94cbfa89b21b306cb2e78");//侯加鑫
@@ -66,11 +66,14 @@ public class FinancePaymentApplicationController {
                 userIds.add("02afeb64079043e6b9d6c9581dcef164");//李小治
                 userIds.add("ec8f6954b6ae49e7a356d173dd6568d1");//王莹
                 userIds.add("96058e7c29f14e4380dfbdddde21175b");//杜鑫艳 销售助理
-                userIds.add("163a4cc9a72c425e873d36d08e75f2cd");//陈心瑞 销售助理
                 userIds.add("fe4965692844468798e4fc265e3cdfc8");//崔泽
                 userIds.add("9a99a2e906b64f5082f87c3a60a20b2e");//王明雨
                 userIds.add("e2d55e2888e849ed911bc89b72fc8211");//支一淼 销售助理
                 userIds.add("102f7edf378b42d2a730d28d11a8cc1e");//张鹤玲  销售助理
+                userIds.add("163a4cc9a72c425e873d36d08e75f2cd");//陈心瑞 销售助理
+                userIds.add("5398af2d95874451aa012ebb8a15c50d");//陈颖
+                userIds.add("b2b6f57dd1a848cd8397e319cd9db1fc");//周菁
+
                 queryWrapper.in("applicanter_id", userIds);
             } else if ("f33798b117a3486a9fae7ba0dab2e0be".equals(application.getUserId())
                     || "515b962ad5544991b17e744df2b87bab".equals(application.getUserId())
@@ -90,8 +93,7 @@ public class FinancePaymentApplicationController {
                 userIds.add("ec8f6954b6ae49e7a356d173dd6568d1");//王莹
                 userIds.add("96058e7c29f14e4380dfbdddde21175b");//杜鑫艳 销售助理
                 queryWrapper.in("applicanter_id", userIds);
-            } else if ("163a4cc9a72c425e873d36d08e75f2cd".equals(application.getUserId())
-                    || "e2d55e2888e849ed911bc89b72fc8211".equals(application.getUserId())
+            } else if ("e2d55e2888e849ed911bc89b72fc8211".equals(application.getUserId())
                     || "102f7edf378b42d2a730d28d11a8cc1e".equals(application.getUserId())
             ) {
                 /*销售助理 陈心瑞组:崔泽、王明雨                 */

+ 12 - 9
jeecg-boot-module-system/src/main/java/cn/com/ctop/finance/payment/controller/FinancePaymentRechargeApplicationController.java

@@ -57,7 +57,7 @@ public class FinancePaymentRechargeApplicationController {
             String roleCode = sysRoleService.getRoleCodeByUserId(recharge.getUserId());
             if ("saleAssistant".equals(roleCode)) {
                 //曹媛 可以看所有人的
-                if ("4f6454dbad954a8094013bf4c6d74796".equals(recharge.getUserId())) {
+                if ("4f6454dbad954a8094013bf4c6d74796".equals(recharge.getUserId()) || "163a4cc9a72c425e873d36d08e75f2cd".equals(recharge.getUserId())) {
                     List<String> userIds = new ArrayList<>();
                     userIds.add("4f6454dbad954a8094013bf4c6d74796");//曹媛 销售助理
                     userIds.add("42e137a90ca94cbfa89b21b306cb2e78");//侯加鑫
@@ -69,11 +69,13 @@ public class FinancePaymentRechargeApplicationController {
                     userIds.add("02afeb64079043e6b9d6c9581dcef164");//李小治
                     userIds.add("ec8f6954b6ae49e7a356d173dd6568d1");//王莹
                     userIds.add("96058e7c29f14e4380dfbdddde21175b");//杜鑫艳 销售助理
-                    userIds.add("163a4cc9a72c425e873d36d08e75f2cd");//陈心瑞 销售助理
                     userIds.add("fe4965692844468798e4fc265e3cdfc8");//崔泽
                     userIds.add("9a99a2e906b64f5082f87c3a60a20b2e");//王明雨
                     userIds.add("e2d55e2888e849ed911bc89b72fc8211");//支一淼 销售助理
                     userIds.add("102f7edf378b42d2a730d28d11a8cc1e");//张鹤玲  销售助理
+                    userIds.add("163a4cc9a72c425e873d36d08e75f2cd");//陈心瑞 销售助理
+                    userIds.add("5398af2d95874451aa012ebb8a15c50d");//陈颖
+                    userIds.add("b2b6f57dd1a848cd8397e319cd9db1fc");//周菁
                     recharge.setUserIds(userIds);
                 } else if ("f33798b117a3486a9fae7ba0dab2e0be".equals(recharge.getUserId())
                         || "515b962ad5544991b17e744df2b87bab".equals(recharge.getUserId())
@@ -94,8 +96,7 @@ public class FinancePaymentRechargeApplicationController {
                     userIds.add("ec8f6954b6ae49e7a356d173dd6568d1");//王莹
                     userIds.add("96058e7c29f14e4380dfbdddde21175b");//杜鑫艳 销售助理
                     recharge.setUserIds(userIds);
-                } else if ("163a4cc9a72c425e873d36d08e75f2cd".equals(recharge.getUserId())
-                        || "e2d55e2888e849ed911bc89b72fc8211".equals(recharge.getUserId())
+                } else if ("e2d55e2888e849ed911bc89b72fc8211".equals(recharge.getUserId())
                         || "102f7edf378b42d2a730d28d11a8cc1e".equals(recharge.getUserId())
                 ) {
                     /*销售助理 陈心瑞组:崔泽、王明雨                 */
@@ -280,7 +281,7 @@ public class FinancePaymentRechargeApplicationController {
             String roleCode = sysRoleService.getRoleCodeByUserId(recharge.getUserId());
             if ("saleAssistant".equals(roleCode)) {
                 //曹媛 可以看所有人的
-                if ("4f6454dbad954a8094013bf4c6d74796".equals(recharge.getUserId())) {
+                if ("4f6454dbad954a8094013bf4c6d74796".equals(recharge.getUserId()) || "163a4cc9a72c425e873d36d08e75f2cd".equals(recharge.getUserId())) {
                     List<String> userIds = new ArrayList<>();
                     userIds.add("4f6454dbad954a8094013bf4c6d74796");//曹媛 销售助理
                     userIds.add("42e137a90ca94cbfa89b21b306cb2e78");//侯加鑫
@@ -292,11 +293,13 @@ public class FinancePaymentRechargeApplicationController {
                     userIds.add("02afeb64079043e6b9d6c9581dcef164");//李小治
                     userIds.add("ec8f6954b6ae49e7a356d173dd6568d1");//王莹
                     userIds.add("96058e7c29f14e4380dfbdddde21175b");//杜鑫艳 销售助理
-                    userIds.add("163a4cc9a72c425e873d36d08e75f2cd");//陈心瑞 销售助理
                     userIds.add("fe4965692844468798e4fc265e3cdfc8");//崔泽
                     userIds.add("9a99a2e906b64f5082f87c3a60a20b2e");//王明雨
                     userIds.add("e2d55e2888e849ed911bc89b72fc8211");//支一淼 销售助理
                     userIds.add("102f7edf378b42d2a730d28d11a8cc1e");//张鹤玲  销售助理
+                    userIds.add("163a4cc9a72c425e873d36d08e75f2cd");//陈心瑞 销售助理
+                    userIds.add("5398af2d95874451aa012ebb8a15c50d");//陈颖
+                    userIds.add("b2b6f57dd1a848cd8397e319cd9db1fc");//周菁
                     recharge.setUserIds(userIds);
                 } else if ("f33798b117a3486a9fae7ba0dab2e0be".equals(recharge.getUserId())
                         || "515b962ad5544991b17e744df2b87bab".equals(recharge.getUserId())
@@ -317,9 +320,9 @@ public class FinancePaymentRechargeApplicationController {
                     userIds.add("ec8f6954b6ae49e7a356d173dd6568d1");//王莹
                     userIds.add("96058e7c29f14e4380dfbdddde21175b");//杜鑫艳 销售助理
                     recharge.setUserIds(userIds);
-                } else if ("163a4cc9a72c425e873d36d08e75f2cd".equals(recharge.getUserId())
-                        || "e2d55e2888e849ed911bc89b72fc8211".equals(recharge.getUserId())
-                        || "102f7edf378b42d2a730d28d11a8cc1e".equals(recharge.getUserId())
+                } else if (
+                        "e2d55e2888e849ed911bc89b72fc8211".equals(recharge.getUserId())
+                                || "102f7edf378b42d2a730d28d11a8cc1e".equals(recharge.getUserId())
                 ) {
                     /*销售助理 陈心瑞组:崔泽、王明雨                 */
                     List<String> userIds = new ArrayList<>();

+ 30 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TransferAccountController.java

@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.ISysRoleExtService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -23,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.List;
 
@@ -157,8 +159,8 @@ public class TransferAccountController {
                 updateQueryWrapper.eq("project_id", transferAccountEntity.getProjectId());
                 UserAllocation updateUserAllocation = new UserAllocation();
                 updateUserAllocation.setUserId(transferAccountEntity.getAssignee());
-                String userName = mailLogMapper.getUserNameByUserId(transferAccountEntity.getAssignee()); // 转让人姓名
-                updateUserAllocation.setUserName(userName);
+                String getAssigneeName = mailLogMapper.getUserNameByUserId(transferAccountEntity.getAssignee()); // 转让人姓名
+                updateUserAllocation.setUserName(getAssigneeName);
                 userAllocationService.update(updateUserAllocation, updateQueryWrapper);
                 QueryWrapper<ProjectMember> projectMemberQueryWrapper = new QueryWrapper<>();
                 projectMemberQueryWrapper.eq("project_id", transferAccountEntity.getProjectId());
@@ -170,11 +172,36 @@ public class TransferAccountController {
                     String roleCode = sysRoleService.getRoleCodeByUserId(transferAccountEntity.getAssignee());
                     addProjectMember.setRoleCode(roleCode);
                     addProjectMember.setUserId(transferAccountEntity.getAssignee());
-                    addProjectMember.setUserName(userName);
+                    addProjectMember.setUserName(getAssigneeName);
                     addProjectMember.setProjectId(project.getId());
                     addProjectMember.setProjectName(project.getProjectName());
                     projectMemberService.save(addProjectMember);
                 }
+
+                try {
+                    //根据账户ID获取总监
+                    JSONObject accountJson = mailLogMapper.getAccountInfo(transferAccountEntity.getAccountId());
+                    BigDecimal cost = new BigDecimal(0);
+                    if (!Check.isNull(accountJson)) {
+                        Integer mediaId = accountJson.getInteger("mediaId");
+                        if (!Check.isNull(mediaId)) {
+                            if (mediaId == 1) {
+                                cost = mailLogMapper.getBytedanceCost(transferAccountEntity.getAccountId());
+                            }
+                            if (mediaId == 2) {
+                                cost = mailLogMapper.getKuaishouCost(transferAccountEntity.getAccountId());
+                            }
+                        }
+                        if (cost.compareTo(BigDecimal.ZERO) > 0) {
+                            String leaderId = accountJson.getString("leaderId");
+                            mailLogService.sendLeaderWeChat(project.getProjectName(), status, leaderId, transferAccountEntity.getAccountId(), transferAccountEntity.getTransferor(), transferAccountEntity.getAssignee(), cost);
+                        }
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+
+
             }
             mailLogService.sendWeChatByStatus(project.getProjectName(), status, transferAccountEntity.getTransferor(), transferAccountEntity.getAccountId());
             mailLogService.sendWeChatByStatus(project.getProjectName(), status, transferAccountEntity.getAssignee(), transferAccountEntity.getAccountId());