wangming 1 주 전
부모
커밋
bcbc78b57a

+ 1 - 1
yami-shop-bean/src/main/java/com/yami/shop/bean/po/EnterpriseUserPo.java

@@ -14,6 +14,6 @@ public class EnterpriseUserPo {
 
     private String realName;
 
-    private String phone;
+    private String userMobile;
 
 }

+ 2 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/vo/EnterpriseUserVo.java

@@ -17,6 +17,8 @@ public class EnterpriseUserVo {
 
     private String userId;
 
+    private Long channelId;
+
     private Integer status;
 
     private String channelName;

+ 3 - 8
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/UserController.java

@@ -12,8 +12,6 @@ package com.yami.shop.platform.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yami.shop.bean.model.User;
-import com.yami.shop.bean.po.EnterpriseUserPo;
-import com.yami.shop.bean.vo.EnterpriseUserVo;
 import com.yami.shop.bean.vo.UserPointsVO;
 import com.yami.shop.common.util.PageParam;
 import com.yami.shop.common.util.R;
@@ -55,14 +53,11 @@ public class UserController {
     @Autowired
     private TokenStore tokenStore;
 
-    @GetMapping("/enterpriseUserList")
-    @PreAuthorize("@pms.hasPermission('plateform:user:page')")
-    public R<IPage<EnterpriseUserVo>> enterpriseUserList(EnterpriseUserPo po, PageParam<EnterpriseUserPo> page) {
-        IPage<EnterpriseUserVo> userPage =  userService.enterpriseUserList(page,po);
-        return R.SUCCESS(userPage);
+    @GetMapping("/userList")
+    public R<IPage<User>> userList(User user,PageParam<User> page) {
+        return R.SUCCESS(userService.userList(page,user));
     }
 
-
     /**
      * 分页获取
      */

+ 3 - 8
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/UserEnterpriseController.java

@@ -12,7 +12,6 @@ import com.yami.shop.service.UserService;
 import io.swagger.annotations.ApiOperation;
 import lombok.SneakyThrows;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -65,7 +64,7 @@ public class UserEnterpriseController {
     @PostMapping("/addUser")
     @ApiOperation("新增企业员工")
     public R<Void> addUser(@RequestBody EnterpriseUserPo po) {
-        userService.addUser(po);
+        userService.addUser2(po);
         return R.SUCCESS();
     }
 
@@ -77,15 +76,11 @@ public class UserEnterpriseController {
     }
 
     @GetMapping("/info/{userId}")
-    @PreAuthorize("@pms.hasPermission('plateform:user:info')")
     public R<User> info(@PathVariable("userId") String userId) {
-        User user = userService.getById(userId);
-        user.setNickName(user.getNickName());
-        return R.SUCCESS(user);
+        return R.SUCCESS(userService.getById(userId));
     }
 
     @PutMapping
-    @PreAuthorize("@pms.hasPermission('plateform:user:update')")
     public R<Void> update(@RequestBody User user) {
         User updateUser = new User();
         updateUser.setModifyTime(new Date());
@@ -93,8 +88,8 @@ public class UserEnterpriseController {
         updateUser.setUserName(user.getUserMobile());
         updateUser.setUserMobile(user.getUserMobile());
         updateUser.setChannelId(user.getChannelId());
-        updateUser.setPlatform(Integer.valueOf(user.getChannelId().toString()));
         updateUser.setUserId(user.getUserId());
+        updateUser.setStatus(user.getStatus());
         userService.updateById(updateUser);
         return R.SUCCESS();
     }

+ 3 - 0
yami-shop-service/src/main/java/com/yami/shop/dao/UserMapper.java

@@ -44,4 +44,7 @@ public interface UserMapper extends BaseMapper<User> {
     void addUserLog(@Param("operator") String operator, @Param("result") String result);
 
     IPage<EnterpriseUserLogPo> enterpriseUserLogList(@Param("page") PageParam<EnterpriseUserLogPo> page);
+
+    IPage<User> userList(@Param("page") PageParam<User> page, @Param("user") User user);
+
 }

+ 4 - 0
yami-shop-service/src/main/java/com/yami/shop/service/UserService.java

@@ -55,5 +55,9 @@ public interface UserService extends IService<User> {
 
     void addUser(EnterpriseUserPo po);
 
+    void addUser2(EnterpriseUserPo po);
+
     IPage<EnterpriseUserLogPo> enterpriseUserLogList(PageParam<EnterpriseUserLogPo> page);
+
+    IPage<User> userList(PageParam<User> page, User user);
 }

+ 34 - 5
yami-shop-service/src/main/java/com/yami/shop/service/impl/UserServiceImpl.java

@@ -144,12 +144,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 
     @Override
     public void addUser(EnterpriseUserPo po) {
-        if (userMapper.selectCount(Wrappers.<User>lambdaQuery().eq(User::getUserMobile, po.getPhone())) == 0) {
+        if (userMapper.selectCount(Wrappers.<User>lambdaQuery().eq(User::getUserMobile, po.getUserMobile())) == 0) {
             User user = new User();
-            user.setUserName(po.getPhone());
+            user.setUserName(po.getUserMobile());
             user.setNickName("企业用户");
             user.setRealName(po.getRealName());
-            user.setUserMobile(po.getPhone());
+            user.setUserMobile(po.getUserMobile());
             user.setModifyTime(new Date());
             user.setUserRegtime(new Date());
             user.setUserRegip(IPHelper.getIpAddr());
@@ -157,9 +157,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             user.setStatus(1);
             user.setLevel(1);
             user.setLevelType(0);
-            user.setPlatform(0);
-            user.setChannelId(po.getChannelId());
             user.setPlatform(Integer.valueOf(po.getChannelId().toString()));
+            user.setChannelId(po.getChannelId());
             user.setUserId(IdUtil.simpleUUID());
             save(user);
         }else {
@@ -167,11 +166,41 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         }
     }
 
+    @Override
+    public void addUser2(EnterpriseUserPo po) {
+        if (userMapper.selectCount(Wrappers.<User>lambdaQuery().eq(User::getUserMobile, po.getUserMobile())) == 0) {
+            User user = new User();
+            user.setUserName(po.getUserMobile());
+            user.setNickName("企业用户");
+            user.setRealName(po.getRealName());
+            user.setUserMobile(po.getUserMobile());
+            user.setModifyTime(new Date());
+            user.setUserRegtime(new Date());
+            user.setUserRegip(IPHelper.getIpAddr());
+            user.setPic("https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132");
+            user.setStatus(1);
+            user.setLevel(1);
+            user.setLevelType(0);
+            user.setPlatform(Integer.valueOf(po.getChannelId().toString()));
+            user.setChannelId(po.getChannelId());
+            user.setUserId(IdUtil.simpleUUID());
+            save(user);
+        }else {
+            throw new GlobalException("系统已存在该员工,请勿重复添加...");
+        }
+    }
+
+
     @Override
     public IPage<EnterpriseUserLogPo> enterpriseUserLogList(PageParam<EnterpriseUserLogPo> page) {
         return userMapper.enterpriseUserLogList(page);
     }
 
+    @Override
+    public IPage<User> userList(PageParam<User> page, User user) {
+        return userMapper.userList(page, user);
+    }
+
     private Long getChannel(String channel) {
         List<Channel> channelList = channelMapper.selectList(new LambdaQueryWrapper<Channel>().like(Channel::getChannelName, channel));
         CullenUtils.validateDataThrowException(channelList.isEmpty(), "没有该渠道,请检查后重试...");

+ 13 - 2
yami-shop-service/src/main/resources/mapper/UserMapper.xml

@@ -105,7 +105,7 @@
 
 
     <select id="enterpriseUserList" resultType="com.yami.shop.bean.vo.EnterpriseUserVo">
-        SELECT a.user_id,a.`status`,a.real_name,a.user_mobile,
+        SELECT a.user_id,a.`status`,a.real_name,a.user_mobile,a.channel_id,
         (SELECT channel_name FROM tz_channel WHERE id= a.channel_id) channelName,
         IFNULL((SELECT SUM(points) FROM tz_points_recharge WHERE user_id=a.user_id),0) total,
         IFNULL((SELECT SUM(points) FROM tz_points_recharge WHERE user_id=a.user_id and recharge_status=1),0) available,
@@ -115,13 +115,14 @@
         IFNULL((SELECT SUM(points) FROM tz_points_record WHERE user_id = a.user_id AND points_type = 3), 0))) used
         FROM tz_user a
         <where>
+            a.channel_id in(SELECT id FROM tz_channel)
             <if test="po.channelId != null">
                 AND a.channel_id = #{po.channelId}
             </if>
             <if test="po.realName != null and po.realName != ''">
                 AND a.real_name LIKE CONCAT("%",#{po.realName},"%")
             </if>
-            <if test="po.phone != null and po.phone != ''">
+            <if test="po.userMobile != null and po.userMobile != ''">
                 AND a.user_mobile LIKE CONCAT("%",#{phone},"%")
             </if>
         </where>
@@ -137,4 +138,14 @@
         SELECT * FROM `tz_user_add_log` ORDER BY complete_time desc
     </select>
 
+
+    <select id="userList" resultType="com.yami.shop.bean.model.User">
+        select * from tz_user
+        <where>
+            <if test="nickName != null and nickName != ''">
+                AND nick_name LIKE CONCAT("%",#{nickName},"%")
+            </if>
+        </where>
+    </select>
+
 </mapper>