Browse Source

磁力金牛 初版0.2

zhaoxian 2 năm trước cách đây
mục cha
commit
a6d1f2eaeb

+ 11 - 0
ruixuan-live/src/main/java/com/ruixuan/jinniu/controller/KuaishouAccountController.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.ruixuan.common.core.controller.BaseController;
 import com.ruixuan.common.core.domain.AjaxResult;
 import com.ruixuan.common.core.page.TableDataInfo;
+import com.ruixuan.common.utils.Result;
 import com.ruixuan.jinniu.entity.KuaishouAccount;
 import com.ruixuan.jinniu.service.IKuaishouAccountService;
 import io.swagger.annotations.Api;
@@ -102,4 +103,14 @@ public class KuaishouAccountController extends BaseController {
         return toAjax(kuaishouAccountService.insertKuaishouAccount(o));
     }
 
+    /**
+     * 取消认领账户
+     */
+    @ApiOperation(value = "取消认领账户")
+    @PostMapping("/deleteClaimAccount")
+    public Result<Object> deleteClaimAccount(@ApiParam("accountId") @RequestParam(value = "accountId", required = true) Long accountId,
+                                             @ApiParam("userId") @RequestParam(value = "userId", required = true) Long userId) {
+        return kuaishouAccountService.deleteClaimAccount(accountId, userId);
+    }
+
 }

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

@@ -110,4 +110,14 @@ public class KuaishouProjectController extends BaseController {
     public Result<Object> addProjectUsers(@RequestBody JSONObject o) {
         return kuaishouProjectMemberService.addProjectUsers(o);
     }
+
+    /**
+     * 删除项目参与人员
+     */
+    @ApiOperation(value = "删除项目参与人员")
+    @PostMapping("/deleteProjectUsers")
+    public Result<Object> deleteProjectUsers(@ApiParam("项目ID") @RequestParam(value = "projectId", required = true) Long projectId,
+                                             @ApiParam("成员Id") @RequestParam(value = "userId", required = true) Long userId) {
+        return kuaishouProjectMemberService.deleteProjectUsers(projectId, userId);
+    }
 }

+ 1 - 0
ruixuan-live/src/main/java/com/ruixuan/jinniu/entity/KuaishouAdvertiser.java

@@ -36,6 +36,7 @@ public class KuaishouAdvertiser implements Serializable {
      */
     @ApiModelProperty(name = "负责人id")
     private Long userId;
+    private String userName;
 
     /**
      * 负责人手机

+ 9 - 0
ruixuan-live/src/main/java/com/ruixuan/jinniu/mapper/KuaishouAccountMapper.java

@@ -26,6 +26,14 @@ public interface KuaishouAccountMapper {
     public KuaishouAccount selectKuaishouAccountById(Long id);
 
     /**
+     * 查询账户
+     *
+     * @param id 账户主键
+     * @return 账户
+     */
+    public KuaishouAccount selectKuaishouAccountByAccountId(Long accountId);
+
+    /**
      * 新增账户
      *
      * @param kuaishouAccount 账户
@@ -61,4 +69,5 @@ public interface KuaishouAccountMapper {
 
     List<KuaishouAccount> getAccountByProjectId(@Param("projectId") Long projectId);
 
+    void insertRecord(JSONObject o);
 }

+ 2 - 1
ruixuan-live/src/main/java/com/ruixuan/jinniu/mapper/KuaishouProjectMemberMapper.java

@@ -1,6 +1,5 @@
 package com.ruixuan.jinniu.mapper;
 
-import com.ruixuan.common.utils.Result;
 import com.ruixuan.jinniu.entity.KuaishouProjectMember;
 import org.apache.ibatis.annotations.Param;
 
@@ -56,4 +55,6 @@ public interface KuaishouProjectMemberMapper {
     List<KuaishouProjectMember> queryProjectUsers(Long projectId);
 
     int replaceBatch(@Param("list") List<KuaishouProjectMember> list);
+
+    int deleteProjectUsers(@Param("projectId") Long projectId, @Param("userId") Long userId);
 }

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

@@ -2,6 +2,7 @@ package com.ruixuan.jinniu.service;
 
 
 import com.alibaba.fastjson.JSONObject;
+import com.ruixuan.common.utils.Result;
 import com.ruixuan.jinniu.entity.KuaishouAccount;
 
 import java.util.List;
@@ -57,4 +58,5 @@ public interface IKuaishouAccountService {
      */
     public int deleteKuaishouAccountById(Long id);
 
+    Result<Object> deleteClaimAccount(Long accountId, Long userId);
 }

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

@@ -56,4 +56,6 @@ public interface IKuaishouProjectMemberService {
     Result<Object> queryProjectUsers(Long projectId);
 
     Result<Object> addProjectUsers(JSONObject o);
+
+    Result<Object> deleteProjectUsers(Long projectId, Long userId);
 }

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

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.ruixuan.common.core.domain.entity.SysUser;
 import com.ruixuan.common.utils.DateUtils;
 import com.ruixuan.common.utils.PageUtils;
+import com.ruixuan.common.utils.Result;
 import com.ruixuan.jinniu.entity.KuaishouAccount;
 import com.ruixuan.jinniu.entity.KuaishouAgentAccountList;
 import com.ruixuan.jinniu.entity.KuaishouProject;
@@ -127,6 +128,7 @@ public class KuaishouAccountServiceImpl implements IKuaishouAccountService {
             mem.put("userIds", Arrays.asList(userId));
             kuaishouProjectMemberService.addProjectUsers(mem);
         }
+        insertAccountRecord(kuaishouAccount, userId, 1);//操作类型 1 绑定,2解绑
         return i;
     }
 
@@ -151,4 +153,21 @@ public class KuaishouAccountServiceImpl implements IKuaishouAccountService {
     public int deleteKuaishouAccountById(Long id) {
         return kuaishouAccountMapper.deleteKuaishouAccountById(id);
     }
+
+    @Override
+    public Result<Object> deleteClaimAccount(Long accountId, Long userId) {
+        KuaishouAccount account = kuaishouAccountMapper.selectKuaishouAccountByAccountId(accountId);
+        int i = kuaishouAccountMapper.deleteKuaishouAccountById(account.getId());
+        insertAccountRecord(account, userId, 2);//操作类型 1 绑定,2解绑
+        return Result.success();
+    }
+
+    private void insertAccountRecord(KuaishouAccount account, Long userId, int type) {
+        JSONObject o = new JSONObject();
+        o.put("accountId", account.getAccountId());
+        o.put("userId", userId);
+        o.put("bindUserId", account.getOperatorId());
+        o.put("bindType", type);//操作类型 1 绑定,2解绑
+        kuaishouAccountMapper.insertRecord(o);
+    }
 }

+ 9 - 1
ruixuan-live/src/main/java/com/ruixuan/jinniu/service/impl/KuaishouProjectMemberServiceImpl.java

@@ -115,7 +115,15 @@ public class KuaishouProjectMemberServiceImpl implements IKuaishouProjectMemberS
             projectMember.setRoleName(sysUser.getRoles().get(0).getRoleName());
             list.add(projectMember);
         }
-        kuaishouProjectMemberMapper.replaceBatch(list);
+        if (Check.isNotNull(list)) {
+            kuaishouProjectMemberMapper.replaceBatch(list);
+        }
+        return Result.success();
+    }
+
+    @Override
+    public Result<Object> deleteProjectUsers(Long projectId, Long userId) {
+        kuaishouProjectMemberMapper.deleteProjectUsers(projectId, userId);
         return Result.success();
     }
 }

+ 10 - 0
ruixuan-live/src/main/java/com/ruixuan/jinniu/service/impl/KuaishouTransferAccountServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruixuan.jinniu.service.impl;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.ruixuan.common.core.domain.entity.SysUser;
 import com.ruixuan.common.utils.DateUtils;
 import com.ruixuan.common.utils.PageUtils;
@@ -8,12 +9,14 @@ import com.ruixuan.jinniu.entity.KuaishouAccount;
 import com.ruixuan.jinniu.entity.KuaishouTransferAccount;
 import com.ruixuan.jinniu.mapper.KuaishouAccountMapper;
 import com.ruixuan.jinniu.mapper.KuaishouTransferAccountMapper;
+import com.ruixuan.jinniu.service.IKuaishouProjectMemberService;
 import com.ruixuan.jinniu.service.IKuaishouTransferAccountService;
 import com.ruixuan.system.service.ISysDeptService;
 import com.ruixuan.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
@@ -33,6 +36,8 @@ public class KuaishouTransferAccountServiceImpl implements IKuaishouTransferAcco
     private ISysUserService sysUserService;
     @Autowired
     private ISysDeptService deptService;
+    @Autowired
+    private IKuaishouProjectMemberService kuaishouProjectMemberService;
 
     /**
      * 查询账户转让记录
@@ -97,6 +102,11 @@ public class KuaishouTransferAccountServiceImpl implements IKuaishouTransferAcco
             kuaishouAccount.setOperatorId(sysUser.getUserId());
             kuaishouAccount.setOperatorName(sysUser.getNickName());
             kuaishouAccountMapper.updateKuaishouAccountByAccountId(kuaishouAccount);
+            //添加 参与项目人员
+            JSONObject mem = new JSONObject();
+            mem.put("projectId", transferAccount.getProjectId());
+            mem.put("userIds", Arrays.asList(sysUser.getUserId()));
+            kuaishouProjectMemberService.addProjectUsers(mem);
         }
         return i;
     }

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

@@ -84,6 +84,11 @@
         where id = #{id}
     </select>
 
+    <select id="selectKuaishouAccountByAccountId" parameterType="Long" resultMap="KuaishouAccountResult">
+        <include refid="selectKuaishouAccountVo"/>
+        where account_id = #{accountId}
+    </select>
+
     <insert id="insertKuaishouAccount" parameterType="com.ruixuan.jinniu.entity.KuaishouAccount" useGeneratedKeys="true"
             keyProperty="id">
         insert into kuaishou_account
@@ -290,4 +295,17 @@
         ) t
     </select>
 
+    <insert id="insertRecord">
+        insert into kuaishou_account_bind_record
+        (account_id,
+         bind_user_id,
+         user_id,
+         bind_type)
+            value ( #{accountId},
+            #{bindUserId},
+            #{userId},
+            #{bindType}
+            )
+    </insert>
+
 </mapper>

+ 25 - 19
ruixuan-live/src/main/resources/mapper/jinniu/KuaishouAdvertiserMapper.xml

@@ -8,6 +8,7 @@
         <result property="id" column="id"/>
         <result property="advertiserName" column="advertiser_name"/>
         <result property="userId" column="user_id"/>
+        <result property="userName" column="userName"/>
         <result property="mobile" column="mobile"/>
         <result property="email" column="email"/>
         <result property="createBy" column="create_by"/>
@@ -17,37 +18,42 @@
     </resultMap>
 
     <sql id="selectKuaishouAdvertiserVo">
-        select id,
-               advertiser_name,
-               user_id,
-               mobile,
-               email,
-               create_by,
-               create_time,
-               update_by,
-               update_time
-        from Kuaishou_advertiser
+        select t1.id,
+               t1.advertiser_name,
+               t1.user_id,
+               t2.nick_name as 'userName',
+               t1.mobile,
+               t1.mobile,
+               t1.email,
+               t1.create_by,
+               t1.create_time,
+               t1.update_by,
+               t1.update_time
+        from kuaishou_advertiser t1
+                 LEFT JOIN sys_user t2 ON t2.user_id = t1.user_id
+
     </sql>
 
-    <select id="selectKuaishouAdvertiserList" parameterType="com.ruixuan.jinniu.entity.KuaishouAdvertiser" resultMap="KuaishouAdvertiserResult">
+    <select id="selectKuaishouAdvertiserList" parameterType="com.ruixuan.jinniu.entity.KuaishouAdvertiser"
+            resultMap="KuaishouAdvertiserResult">
         <include refid="selectKuaishouAdvertiserVo"/>
         <where>
-            <if test="advertiserName != null  and advertiserName != ''">and advertiser_name like concat('%',
+            <if test="advertiserName != null  and advertiserName != ''">and t1.advertiser_name like concat('%',
                 #{advertiserName}, '%')
             </if>
-            <if test="userId != null  and userId != ''">and user_id = #{userId}</if>
-            <if test="mobile != null  and mobile != ''">and mobile = #{mobile}</if>
-            <if test="email != null  and email != ''">and email = #{email}</if>
+            <if test="userId != null  and userId != ''">and t1.user_id = #{userId}</if>
+            <if test="mobile != null  and mobile != ''">and t1.mobile = #{mobile}</if>
+            <if test="email != null  and email != ''">and t1.email = #{email}</if>
         </where>
     </select>
 
     <select id="selectKuaishouAdvertiserById" parameterType="Long" resultMap="KuaishouAdvertiserResult">
         <include refid="selectKuaishouAdvertiserVo"/>
-        where id = #{id}
+        where t1.id = #{id}
     </select>
 
     <insert id="insertKuaishouAdvertiser" parameterType="com.ruixuan.jinniu.entity.KuaishouAdvertiser">
-        insert into Kuaishou_advertiser
+        insert into kuaishou_advertiser
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="id != null">id,</if>
             <if test="advertiserName != null and advertiserName != ''">advertiser_name,</if>
@@ -73,7 +79,7 @@
     </insert>
 
     <update id="updateKuaishouAdvertiser" parameterType="com.ruixuan.jinniu.entity.KuaishouAdvertiser">
-        update Kuaishou_advertiser
+        update kuaishou_advertiser
         <trim prefix="SET" suffixOverrides=",">
             <if test="advertiserName != null and advertiserName != ''">advertiser_name = #{advertiserName},</if>
             <if test="userId != null">user_id = #{userId},</if>
@@ -89,7 +95,7 @@
 
     <delete id="deleteKuaishouAdvertiserById" parameterType="Long">
         delete
-        from Kuaishou_advertiser
+        from kuaishou_advertiser
         where id = #{id}
     </delete>
 

+ 7 - 0
ruixuan-live/src/main/resources/mapper/jinniu/KuaishouProjectMemberMapper.xml

@@ -122,4 +122,11 @@
         from kuaishou_project_member
         where id = #{id}
     </delete>
+
+    <delete id="deleteProjectUsers">
+        delete
+        from kuaishou_project_member
+        where project_id = #{projectId}
+          AND user_id = #{userId}
+    </delete>
 </mapper>