Prechádzať zdrojové kódy

达人添加渠道权限, 账户添加主体ID

zhaoxian 2 rokov pred
rodič
commit
5b776afd2f

+ 3 - 0
ruixuan-common/src/main/java/com/ruixuan/common/core/controller/BaseController.java

@@ -132,6 +132,9 @@ public class BaseController {
             case 0:
                 result = result.error("该数据已存在,请重新输入");
                 break;
+            case 10:
+                result = result.error("吃点肉渠道");
+                break;
             case 1:
                 result = AjaxResult.success();
                 break;

+ 2 - 2
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouPromoterController.java

@@ -112,8 +112,8 @@ public class KuaishouPromoterController extends BaseController {
      */
     @PostMapping(value = "/add")
     @ApiOperation(value = "新增快手达人")
-    public AjaxResult add(@RequestBody KuaishouPromoter kuaishouPromoter) {
-        return toAjax2(kuaishouPromoterService.insertKuaishouPromoter(kuaishouPromoter));
+    public JSONObject add(@RequestBody KuaishouPromoter kuaishouPromoter) {
+        return kuaishouPromoterService.insertKuaishouPromoter(kuaishouPromoter);
     }
 
     /**

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KuaishouPromoterMapper.java

@@ -71,4 +71,6 @@ public interface KuaishouPromoterMapper {
     List<KuaishouPromoter> selectAllPromoterList(@Param("promoterId") Long promoterId, @Param("promoterNickName") String promoterNickName, @Param("parameter") String parameter, @Param("orderBy") String orderBy);
 
     List<KuaishouPromoter> getFailInfo();
+
+    List<JSONObject> getBoundPromoterRoleKey(@Param("promoterId") Long promoterId);
 }

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouPromoterService.java

@@ -35,7 +35,7 @@ public interface IKuaishouPromoterService {
      * @param kuaishouPromoter 快手达人 信息
      * @return 结果
      */
-    public int insertKuaishouPromoter(KuaishouPromoter kuaishouPromoter);
+    public JSONObject insertKuaishouPromoter(KuaishouPromoter kuaishouPromoter);
 
     /**
      * 修改快手达人 信息

+ 24 - 4
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouPromoterServiceImpl.java

@@ -152,18 +152,38 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
      * @param kuaishouPromoter 快手达人 信息
      */
     @Override
-    public int insertKuaishouPromoter(KuaishouPromoter promoter) {
+    public JSONObject insertKuaishouPromoter(KuaishouPromoter promoter) {
+        JSONObject result = new JSONObject();
         KuaishouPromoter one = kuaishouPromoterMapper.getOneByIdAndPromoterId(promoter.getUserId(), promoter.getPromoterId());
         if (Check.isNotNull(one)) {
-            return 0;
+            result.put("code", 500);
+            result.put("msg", "该数据已存在,请重新输入");
+            return result;
+        }
+        //同一达人ID 不能绑定到多个渠道角色用户上
+        String roleKey = sysUserService.getRoleKeyByUserId(promoter.getUserId());
+        if (roleKey.contains("bd")) {
+            List<JSONObject> keys = kuaishouPromoterMapper.getBoundPromoterRoleKey(promoter.getPromoterId());
+            if (Check.isNotNull(keys)) {
+                for (JSONObject key : keys) {
+                    String rKey = key.getString("role_key");
+                    if ("bd".equals(rKey) || "bdManager".equals(rKey)) {
+                        result.put("code", 500);
+                        result.put("msg", "该达人已被其他渠道人员绑定,绑定人:" + key.getString("user_name"));
+                        return result;
+                    }
+                }
+            }
         }
         SysUser sysUser = sysUserService.selectUserById(promoter.getUserId());
         if (Check.isNotNull(sysUser)) {
             promoter.setUserName(sysUser.getNickName());
         }
-        int i = kuaishouPromoterMapper.insertKuaishouPromoter(promoter);
+        kuaishouPromoterMapper.insertKuaishouPromoter(promoter);
         editPromoter(promoter.getId(), promoter.getPromoterId(), true);
-        return i;
+        result.put("code", 200);
+        result.put("msg", "success");
+        return result;
     }
 
     /**

+ 10 - 1
ruixuan-live/src/main/java/com/ruixuan/jinniu/controller/KuaishouAccountController.java

@@ -28,7 +28,7 @@ import java.util.List;
  * @author ruoyi
  * @date 2023-03-15
  */
-@Api(tags = "-------------磁力金牛------------- 账户Controller")
+@Api(tags = "账户Controller")
 @RestController
 @RequestMapping("/kuaishou/account")
 public class KuaishouAccountController extends BaseController {
@@ -110,4 +110,13 @@ public class KuaishouAccountController extends BaseController {
         return kuaishouAccountService.deleteClaimAccount(accountId, userId);
     }
 
+    /**
+     * 修改
+     */
+    @ApiOperation(value = "修改")
+    @GetMapping("/edit")
+    public Result<Object> edit(KuaishouAccount kuaishouAccount) {
+        return kuaishouAccountService.edit(kuaishouAccount);
+    }
+
 }

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/jinniu/controller/KuaishouAdvertiserController.java

@@ -25,7 +25,7 @@ import java.util.List;
  * @author ruoyi
  * @date 2023-03-14
  */
-@Api(tags = "-------------磁力金牛-------------广告主Controller")
+@Api(tags = "广告主Controller")
 @RestController
 @RequestMapping("/kuaishou/advertiser")
 public class KuaishouAdvertiserController extends BaseController {

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/jinniu/controller/KuaishouProjectController.java

@@ -29,7 +29,7 @@ import java.util.List;
  * @author ruoyi
  * @date 2023-03-14
  */
-@Api(tags = "-------------磁力金牛-------------项目信息Controller")
+@Api(tags = "项目信息Controller")
 @RestController
 @RequestMapping("/kuaishou/project")
 public class KuaishouProjectController extends BaseController {

+ 1 - 1
ruixuan-live/src/main/java/com/ruixuan/jinniu/controller/KuaishouTransferAccountController.java

@@ -26,7 +26,7 @@ import java.util.List;
  * @author ruoyi
  * @date 2023-03-16
  */
-@Api(tags = "-------------磁力金牛-------------账户转让记录Controller")
+@Api(tags = "账户转让记录Controller")
 @RestController
 @RequestMapping("/kuaishou/transfer")
 public class KuaishouTransferAccountController extends BaseController {

+ 6 - 0
ruixuan-live/src/main/java/com/ruixuan/jinniu/entity/KuaishouAccount.java

@@ -47,6 +47,12 @@ public class KuaishouAccount extends BaseEntity {
     private String projectName;
 
     /**
+     * 广告主ID
+     */
+    @ApiModelProperty(name = "广告主ID")
+    private String advertiserId;
+
+    /**
      * 媒体类型 磁力金牛、千川
      */
     @ApiModelProperty(name = "媒体类型 磁力金牛、千川")

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/jinniu/service/IKuaishouAccountService.java

@@ -59,4 +59,6 @@ public interface IKuaishouAccountService {
     public int deleteKuaishouAccountById(Long id);
 
     Result<Object> deleteClaimAccount(Long accountId, Long userId);
+
+    Result<Object> edit(KuaishouAccount kuaishouAccount);
 }

+ 7 - 0
ruixuan-live/src/main/java/com/ruixuan/jinniu/service/impl/KuaishouAccountServiceImpl.java

@@ -121,6 +121,7 @@ public class KuaishouAccountServiceImpl implements IKuaishouAccountService {
         kuaishouAccount.setProjectName(project.getProjectName());
         kuaishouAccount.setAccountCreateTime(DateUtils.formatDate(agentAccount.getAccountCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS));
         kuaishouAccount.setBindTime(DateUtils.getDate());
+        kuaishouAccount.setAdvertiserId(project.getAdvertiserId());
         int i = kuaishouAccountMapper.insertKuaishouAccount(kuaishouAccount);
         if (i > 0) {
             //添加 参与项目人员
@@ -164,6 +165,12 @@ public class KuaishouAccountServiceImpl implements IKuaishouAccountService {
         return Result.success();
     }
 
+    @Override
+    public Result<Object> edit(KuaishouAccount kuaishouAccount) {
+        int i = kuaishouAccountMapper.updateKuaishouAccountByAccountId(kuaishouAccount);
+        return Result.success();
+    }
+
     private void insertAccountRecord(KuaishouAccount account, Long userId, int type) {
         JSONObject o = new JSONObject();
         o.put("accountId", account.getAccountId());

+ 10 - 0
ruixuan-live/src/main/resources/mapper/isc/KuaishouPromoterMapper.xml

@@ -139,6 +139,16 @@
         where promoter_nick_name = '' or promoter_nick_name is null
     </select>
 
+    <select id="getBoundPromoterRoleKey" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT 	t1.user_id,
+                  t3.role_key,
+                  t1.user_name
+        FROM kuaishou_promoter t1
+                 LEFT JOIN sys_user_role t2 ON t1.user_id = t2.user_id
+                 LEFT JOIN sys_role t3 ON t2.role_id = t3.role_id
+        Where t1.promoter_id = #{promoterId}
+    </select>
+
     <select id="selectPromoterIdList" resultType="Long">
         select promoter_id
         from kuaishou_promoter

+ 6 - 0
ruixuan-live/src/main/resources/mapper/jinniu/KuaishouAccountMapper.xml

@@ -22,6 +22,7 @@
         <result property="accountStatus" column="account_status"/>
         <result property="accountType" column="account_type"/>
         <result property="bindTime" column="bind_time"/>
+        <result property="advertiserId" column="advertiser_id"/>
         <result property="accountCreateTime" column="account_create_time"/>
         <result property="createTime" column="create_time"/>
         <result property="updateTime" column="update_time"/>
@@ -44,6 +45,7 @@
                corporation_name,
                account_status,
                account_type,
+               advertiser_id,
                bind_time,
                account_create_time,
                create_time,
@@ -115,6 +117,7 @@
             <if test="accountStatus != null">account_status,</if>
             <if test="accountType != null">account_type,</if>
             <if test="bindTime != null">bind_time,</if>
+            <if test="advertiserId != null">advertiser_id,</if>
             <if test="accountCreateTime != null">account_create_time,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateTime != null">update_time,</if>
@@ -136,6 +139,7 @@
             <if test="accountStatus != null">#{accountStatus},</if>
             <if test="accountType != null">#{accountType},</if>
             <if test="bindTime != null">#{bindTime},</if>
+            <if test="advertiserId != null">#{advertiserId},</if>
             <if test="accountCreateTime != null">#{accountCreateTime},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateTime != null">#{updateTime},</if>
@@ -161,6 +165,7 @@
             <if test="accountStatus != null">account_status = #{accountStatus},</if>
             <if test="accountType != null">account_type = #{accountType},</if>
             <if test="bindTime != null">bind_time = #{bindTime},</if>
+            <if test="advertiserId != null">advertiser_id = #{advertiserId},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
         </trim>
@@ -186,6 +191,7 @@
             <if test="accountStatus != null">account_status = #{accountStatus},</if>
             <if test="accountType != null">account_type = #{accountType},</if>
             <if test="bindTime != null">bind_time = #{bindTime},</if>
+            <if test="advertiserId != null">advertiser_id = #{advertiserId},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
         </trim>