Explorar el Código

1.添加机构员工、机构专辑时长赠送

yuanliang hace 1 año
padre
commit
15aac3aafe
Se han modificado 15 ficheros con 916 adiciones y 55 borrados
  1. 129 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/TenantStaffController.java
  2. 138 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/UserTenantAlbumRecordController.java
  3. 70 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/io/request/TenantStaffVo.java
  4. 131 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/io/request/UserTenantAlbumRecordVo.java
  5. 1 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/SourceTypeEnum.java
  6. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantStaffMapper.java
  7. 2 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/UserTenantAlbumRecordMapper.java
  8. 7 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TenantStaffService.java
  9. 4 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UserTenantAlbumRecordService.java
  10. 124 13
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantStaffServiceImpl.java
  11. 107 29
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserTenantAlbumRecordServiceImpl.java
  12. 108 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantStaffWrapper.java
  13. 28 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/UserTenantAlbumRecordWrapper.java
  14. 34 5
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantStaffMapper.xml
  15. 32 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/UserTenantAlbumRecordMapper.xml

+ 129 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/TenantStaffController.java

@@ -0,0 +1,129 @@
+package com.yonge.cooleshow.admin.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.microsvc.toolkit.common.response.template.R;
+import com.yonge.cooleshow.admin.io.request.TenantStaffVo;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
+import com.yonge.cooleshow.biz.dal.service.TenantStaffService;
+import com.yonge.cooleshow.biz.dal.wrapper.TenantStaffWrapper;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.toolset.base.page.PageInfo;
+import com.yonge.toolset.mybatis.support.PageUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("/tenantStaff")
+@Api(tags = "机构员工表")
+public class TenantStaffController extends BaseController {
+
+    @Autowired
+    private TenantStaffService tenantStaffService;
+
+    @Resource
+    private SysUserFeignService sysUserFeignService;
+
+    @ApiOperation(value = "详情", notes = "机构员工表-根据详情ID查询单条, 传入id")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "long")
+    })
+    @PreAuthorize("@pcs.hasPermissions('tenantStaff/detail', {'BACKEND'})")
+    @GetMapping("/detail/{id}")
+    public R<TenantStaffWrapper.TenantStaff> detail(@PathVariable("id") Long id) {
+        TenantStaff wrapper = tenantStaffService.detail(id);
+        if (wrapper == null) {
+            return R.from(new TenantStaffWrapper.TenantStaff());
+        }
+        TenantStaffWrapper.TenantStaff tenantStaff = TenantStaffWrapper.TenantStaff.from(JSON.toJSONString(wrapper));
+        SysUser sysUser = sysUserFeignService.queryUserById(wrapper.getUserId());
+        tenantStaff.setGender(sysUser.getGender());
+        tenantStaff.setNickname(sysUser.getUsername());
+        tenantStaff.setPhone(sysUser.getPhone());
+        tenantStaff.setBindStatus(StringUtils.isNotEmpty(tenantStaff.getWxOpenid()));
+        return R.from(tenantStaff);
+    }
+
+    @ApiOperation(value = "查询分页", notes = "机构员工表- 传入 TenantStaffVo.TenantStaffQuery")
+    @PreAuthorize("@pcs.hasPermissions('tenantStaff/page', {'BACKEND'})")
+    @PostMapping("/page")
+    public R<PageInfo<TenantStaffWrapper.TenantStaff>> page(@RequestBody TenantStaffWrapper.TenantStaffQuery query) {
+
+        // 查询数据
+        return R.from(PageUtil.pageInfo(tenantStaffService.selectPage(QueryInfo.getPage(query), query)));
+    }
+
+    @ApiOperation(value = "新增", notes = "机构员工表- 传入 TenantStaffVo.TenantStaff")
+    @PreAuthorize("@pcs.hasPermissions('tenantStaff/add', {'BACKEND'})")
+//    @PostMapping("/save")
+    public R<JSONObject> add(@Validated @RequestBody TenantStaffVo.TenantStaff tenantStaffVo) {
+
+        // 新增数据
+        tenantStaffService.save(JSON.parseObject(tenantStaffVo.jsonString(), TenantStaff.class));
+
+        return R.defaultR();
+    }
+
+    @ApiOperation(value = "修改", notes = "机构员工表- 传入 TenantStaffVo.TenantStaff")
+    @PreAuthorize("@pcs.hasPermissions('tenantStaff/update', {'BACKEND'})")
+    @PostMapping("/update")
+    public R<JSONObject> update(@Validated @RequestBody TenantStaffVo.TenantStaff tenantStaffVo) {
+
+        // 更新数据
+        tenantStaffService.update(JSON.parseObject(tenantStaffVo.jsonString(), TenantStaffWrapper.TenantStaffAdd.class));
+
+        return R.defaultR();
+    }
+
+    @ApiOperation(value = "启用/禁用", notes = "机构员工表- 传入 TenantStaff")
+    @PreAuthorize("@pcs.hasPermissions('tenantStaff/updateStatus', {'BACKEND'})")
+    @PostMapping("/updateStatus")
+    public R<JSONObject> updateStatus(@RequestBody TenantStaff vo) {
+
+        // 更新数据
+        tenantStaffService.updateStatus(vo.getId(), vo.getStatus());
+        return R.defaultR();
+    }
+
+    @ApiOperation(value = "清理wxOpenId")
+    @PreAuthorize("@pcs.hasPermissions('tenantStaff/clearWxOpenId', {'BACKEND'})")
+    @PostMapping("/clearWxOpenId")
+    public R<JSONObject> clearWxOpenId(@RequestBody TenantStaff vo) {
+
+        // 更新数据
+        tenantStaffService.clearWxOpenId(vo.getId());
+        return R.defaultR();
+    }
+
+    @ApiOperation(value = "删除", notes = "机构员工表- 传入id")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "long")
+    })
+    @PreAuthorize("@pcs.hasPermissions('tenantStaff/remove', {'BACKEND'})")
+//    @PostMapping("/remove")
+    public R<Boolean> remove(@RequestParam Long id) {
+
+        return R.from(tenantStaffService.removeById(id));
+    }
+}

+ 138 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/UserTenantAlbumRecordController.java

@@ -0,0 +1,138 @@
+package com.yonge.cooleshow.admin.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.microsvc.toolkit.common.response.template.R;
+import com.yonge.cooleshow.admin.io.request.UserTenantAlbumRecordVo;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.UserTenantAlbumRecord;
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
+import com.yonge.cooleshow.biz.dal.service.UserTenantAlbumRecordService;
+import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumWrapper;
+import com.yonge.cooleshow.biz.dal.wrapper.UserTenantAlbumRecordWrapper;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.toolset.base.exception.BizException;
+import com.yonge.toolset.base.page.PageInfo;
+import com.yonge.toolset.mybatis.support.PageUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.redisson.Redisson;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("/userTenantAlbumRecord")
+@Api(tags = "购买训练工具记录")
+public class UserTenantAlbumRecordController extends BaseController {
+
+    @Autowired
+    private UserTenantAlbumRecordService userTenantAlbumRecordService;
+
+    @Resource
+    private SysUserFeignService sysUserFeignService;
+
+    @Autowired
+    private RedissonClient redissonClient;
+
+    @ApiOperation(value = "详情", notes = "购买训练工具记录-根据详情ID查询单条, 传入id")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "long")
+    })
+    @PreAuthorize("@pcs.hasPermissions('userTenantAlbumRecord/detail', {'BACKEND'})")
+//    @GetMapping("/detail/{id}")
+    public R<UserTenantAlbumRecordVo.UserTenantAlbumRecord> detail(@PathVariable("id") Long id) {
+
+        UserTenantAlbumRecord wrapper = userTenantAlbumRecordService.detail(id);
+
+        return R.from(UserTenantAlbumRecordVo.UserTenantAlbumRecord.from(JSON.toJSONString(wrapper)));
+    }
+
+    @ApiOperation(value = "查询分页", notes = "购买训练工具记录- 传入 UserTenantAlbumRecordVo.UserTenantAlbumRecordQuery")
+    @PreAuthorize("@pcs.hasPermissions('userTenantAlbumRecord/page', {'BACKEND'})")
+    @PostMapping("/page")
+    public R<PageInfo<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord>> page(@RequestBody UserTenantAlbumRecordWrapper.UserTenantAlbumRecordQuery query) {
+        return R.from(PageUtil.pageInfo(userTenantAlbumRecordService.selectUserTenantAlbumRecordPage(QueryInfo.getPage(query), query)));
+    }
+
+    @ApiOperation(value = "新增", notes = "购买训练工具记录- 传入 UserTenantAlbumRecordVo.UserTenantAlbumRecord")
+    @PreAuthorize("@pcs.hasPermissions('userTenantAlbumRecord/save', {'BACKEND'})")
+    @PostMapping("/save")
+    public R<JSONObject> add(@Validated @RequestBody UserTenantAlbumRecordVo.UserTenantAlbumRecord userTenantAlbumRecordVo) {
+
+        // 新增数据
+        UserTenantAlbumRecord userTenantAlbumRecord = new UserTenantAlbumRecord();
+        userTenantAlbumRecord.setTenantId(userTenantAlbumRecordVo.getTenantId());
+        userTenantAlbumRecord.setTenantAlbumId(userTenantAlbumRecordVo.getTenantAlbumId());
+        userTenantAlbumRecord.setTimes(userTenantAlbumRecordVo.getTimes());
+        userTenantAlbumRecord.setType(userTenantAlbumRecordVo.getType());
+        userTenantAlbumRecord.setReason(userTenantAlbumRecordVo.getReason());
+        userTenantAlbumRecord.setUserId(userTenantAlbumRecordVo.getUserId());
+        userTenantAlbumRecord.setClientType(ClientEnum.STUDENT);
+        userTenantAlbumRecord.setSourceType(SourceTypeEnum.BACKEND_GIVE);
+
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        userTenantAlbumRecord.setCreateBy(sysUser.getId());
+
+        RLock lock = redissonClient.getLock("UserTenantAlbumRecord_" + userTenantAlbumRecordVo.getUserId() + "_" + userTenantAlbumRecordVo.getTenantAlbumId());
+        try {
+            boolean b = lock.tryLock(60, 60, TimeUnit.SECONDS);
+            if (b) {
+                userTenantAlbumRecordService.add(userTenantAlbumRecord);
+            } else {
+                throw new BizException("请勿重复点击");
+            }
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        } finally {
+            if (lock.getHoldCount() > 0) {
+                lock.unlock();
+            }
+        }
+        return R.defaultR();
+    }
+
+    @ApiOperation(value = "修改", notes = "购买训练工具记录- 传入 UserTenantAlbumRecordVo.UserTenantAlbumRecord")
+    @PreAuthorize("@pcs.hasPermissions('userTenantAlbumRecord/update', {'BACKEND'})")
+//    @PostMapping("/update")
+    public R<JSONObject> update(@Validated @RequestBody UserTenantAlbumRecordVo.UserTenantAlbumRecord userTenantAlbumRecordVo) {
+
+        // 更新数据
+        userTenantAlbumRecordService.updateById(JSON.parseObject(userTenantAlbumRecordVo.jsonString(), UserTenantAlbumRecord.class));
+
+        return R.defaultR();
+    }
+
+    @ApiOperation(value = "删除", notes = "购买训练工具记录- 传入id")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "long")
+    })
+    @PreAuthorize("@pcs.hasPermissions('userTenantAlbumRecord/remove', {'BACKEND'})")
+//    @PostMapping("/remove")
+    public R<Boolean> remove(@RequestParam Long id) {
+
+        return R.from(userTenantAlbumRecordService.removeById(id));
+    }
+}

+ 70 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/io/request/TenantStaffVo.java

@@ -0,0 +1,70 @@
+package com.yonge.cooleshow.admin.io.request;
+
+import com.alibaba.fastjson.JSON;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.Date;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * 机构员工表
+ * 2023-12-19 09:49:04
+ */
+@ApiModel(value = "TenantStaffVo对象", description = "机构员工表查询视图对象")
+public class TenantStaffVo {
+
+    @Data
+    @ApiModel(" TenantStaffQuery-机构员工表")
+    public static class TenantStaffQuery implements QueryInfo {
+
+        @ApiModelProperty("当前页")
+        private Integer page;
+
+        @ApiModelProperty("分页行数")
+        private Integer rows;
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static TenantStaffQuery from(String json) {
+            return JSON.parseObject(json, TenantStaffQuery.class);
+        }
+    }
+
+    @Data
+    @ApiModel(" TenantStaff-机构员工表")
+    public static class TenantStaff {
+
+        @ApiModelProperty("主键ID")
+        private Long id;
+
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
+
+        @ApiModelProperty("昵称")
+        private String nickname;
+
+        @ApiModelProperty("性别,0:女,1:男")
+        private Integer gender;
+
+        @ApiModelProperty("手机号")
+        private String phone;
+
+        @ApiModelProperty("是否是主管理员")
+        private Boolean manageAdmin;
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static TenantStaff from(String json) {
+            return JSON.parseObject(json, TenantStaff.class);
+        }
+    }
+
+}

+ 131 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/io/request/UserTenantAlbumRecordVo.java

@@ -0,0 +1,131 @@
+package com.yonge.cooleshow.admin.io.request;
+
+import com.alibaba.fastjson.JSON;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+import lombok.Data;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+
+/**
+ * 购买训练工具记录
+ * 2023-12-19 10:33:35
+ */
+@ApiModel(value = "UserTenantAlbumRecordVo对象", description = "购买训练工具记录查询视图对象")
+public class UserTenantAlbumRecordVo {
+
+    @Data
+    @ApiModel(" UserTenantAlbumRecordQuery-购买训练工具记录")
+    public static class UserTenantAlbumRecordQuery implements QueryInfo {
+
+        @ApiModelProperty("当前页")
+        private Integer page;
+
+        @ApiModelProperty("分页行数")
+        private Integer rows;
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static UserTenantAlbumRecordQuery from(String json) {
+            return JSON.parseObject(json, UserTenantAlbumRecordQuery.class);
+        }
+    }
+
+    @Data
+    @ApiModel(" UserTenantAlbumRecord-购买训练工具记录")
+    public static class UserTenantAlbumRecord {
+
+
+        @ApiModelProperty("记录id")
+        private Long id;
+
+
+        @ApiModelProperty(value = "用户id", required = true)
+        @NotNull
+        private Long userId;
+
+
+        @ApiModelProperty(value = "机构ID", required = true)
+        @NotNull
+        private Long tenantId;
+
+
+        @ApiModelProperty(value = "机构专辑ID", required = true)
+        @NotNull
+        private Long tenantAlbumId;
+
+
+        @ApiModelProperty("订单号")
+        private String orderNo;
+
+
+        @ApiModelProperty("ORDER:订单")
+        private String sourceType;
+
+
+        @ApiModelProperty("购买人员类型 TEACHRE :老师端 STUDNET : 学生端")
+        private String clientType;
+
+
+        @ApiModelProperty("订单详情号")
+        private String subOrderNo;
+
+
+        @ApiModelProperty("开始时间")
+        private Date startTime;
+
+
+        @ApiModelProperty("结束时间")
+        private Date endTime;
+
+
+        @ApiModelProperty("创建时间")
+        private Date createTime;
+
+
+        @ApiModelProperty("创建人")
+        private Long createBy;
+
+
+        @ApiModelProperty("更新时间")
+        private Date updateTime;
+
+
+        @ApiModelProperty(value = "时间类型 DAY:天 MONTH:月,YEAR:年", required = true)
+        @NotNull
+        @Pattern(regexp = "^DAY|MONTH|YEAR$")
+        private String type;
+
+
+        @ApiModelProperty(value = "添加时间数量", required = true)
+        @NotNull
+        @Max(value = 999)
+        private Integer times;
+
+
+        @ApiModelProperty("消息发送 0、未发送 1、已发送提前3天消息 2、已发送会员过期消息 暂时不用")
+        private Boolean msgStatus;
+
+
+        @ApiModelProperty("备注")
+        private String reason;
+
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static UserTenantAlbumRecord from(String json) {
+            return JSON.parseObject(json, UserTenantAlbumRecord.class);
+        }
+    }
+
+}

+ 1 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/SourceTypeEnum.java

@@ -18,6 +18,7 @@ public enum SourceTypeEnum implements BaseEnum<String, AuditStatusEnum> {
     PLATFORM("平台"),
     ACTIVITY("活动"),
     ORDER("订单"),
+    BACKEND_GIVE("后台赠送"),
 
 
     ;

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantStaffMapper.java

@@ -22,7 +22,7 @@ public interface TenantStaffMapper extends BaseMapper<TenantStaff> {
 	 * @param param TenantStaffWrapper.TenantStaffQuery
 	 * @return List<TenantStaffWrapper.TenantStaff>
 	 */
-	List<TenantStaff> selectPage(@Param("page") IPage<TenantStaff> page, @Param("param") TenantStaffWrapper.TenantStaffQuery param);
+	List<TenantStaffWrapper.TenantStaff> selectPage(@Param("page") IPage<TenantStaffWrapper.TenantStaff> page, @Param("param") TenantStaffWrapper.TenantStaffQuery param);
 
     TenantStaff getByPhone(@Param("phone") String phone);
 

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/UserTenantAlbumRecordMapper.java

@@ -28,6 +28,8 @@ public interface UserTenantAlbumRecordMapper extends BaseMapper<UserTenantAlbumR
      */
     List<TenantAlbumWrapper.TenantAlbum> selectPage(@Param("page") IPage<UserTenantAlbumRecord> page, @Param("param") UserTenantAlbumRecordWrapper.UserTenantAlbumRecordQuery param);
 
+    List<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> selectUserTenantAlbumRecordPage(@Param("page") IPage<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> page, @Param("param") UserTenantAlbumRecordWrapper.UserTenantAlbumRecordQuery param);
+
     List<Long> selectTenantIds(@Param("id") Long id);
 
     List<TenantAlbum> selectTenantAlbumInfo(@Param("tenantIds") List<Long> tenantIds);

+ 7 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TenantStaffService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantStaffWrapper;
+import com.yonge.cooleshow.common.enums.UserLockFlag;
 
 /**
  * 机构员工表
@@ -24,7 +25,7 @@ public interface TenantStaffService extends IService<TenantStaff>  {
      * @param query TenantStaffWrapper.TenantStaffQuery
      * @return IPage<TenantStaff>
      */
-    IPage<TenantStaff> selectPage(IPage<TenantStaff> page, TenantStaffWrapper.TenantStaffQuery query);
+    IPage<TenantStaffWrapper.TenantStaff> selectPage(IPage<TenantStaffWrapper.TenantStaff> page, TenantStaffWrapper.TenantStaffQuery query);
 	
     /**
      * 添加
@@ -38,7 +39,7 @@ public interface TenantStaffService extends IService<TenantStaff>  {
      * @param tenantStaff TenantStaffWrapper.TenantStaff
      * @return Boolean
      */
-     Boolean update(TenantStaffWrapper.TenantStaff tenantStaff);
+     Boolean update(TenantStaffWrapper.TenantStaffAdd tenantStaff);
 
     /**
      * 获取机构用户
@@ -54,4 +55,8 @@ public interface TenantStaffService extends IService<TenantStaff>  {
      * @return TenantStaff
      */
     TenantStaff getByUserId(Long userId);
+
+    void updateStatus(Long id, UserLockFlag status);
+
+    void clearWxOpenId(Long id);
 }

+ 4 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UserTenantAlbumRecordService.java

@@ -30,13 +30,15 @@ public interface UserTenantAlbumRecordService extends IService<UserTenantAlbumRe
      * @return IPage<UserTenantAlbumRecord>
      */
     IPage<TenantAlbumWrapper.TenantAlbum> selectPage(IPage<TenantAlbumWrapper.TenantAlbum> page, UserTenantAlbumRecordWrapper.UserTenantAlbumRecordQuery query);
-	
+
+    IPage<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> selectUserTenantAlbumRecordPage(IPage<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> page, UserTenantAlbumRecordWrapper.UserTenantAlbumRecordQuery query);
+
     /**
      * 添加
      * @param userTenantAlbumRecord UserTenantAlbumRecordWrapper.UserTenantAlbumRecord
      * @return Boolean
      */
-     Boolean add(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord userTenantAlbumRecord);   
+     Boolean add(UserTenantAlbumRecord userTenantAlbumRecord);
 
     /**
      * 更新

+ 124 - 13
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantStaffServiceImpl.java

@@ -1,14 +1,32 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
 import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
+import com.yonge.cooleshow.biz.dal.mapper.TenantInfoMapper;
 import com.yonge.cooleshow.biz.dal.mapper.TenantStaffMapper;
 import com.yonge.cooleshow.biz.dal.service.TenantStaffService;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantStaffWrapper;
+import com.yonge.cooleshow.common.enums.UserLockFlag;
+import com.yonge.toolset.base.exception.BizException;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 机构员工表
@@ -18,49 +36,124 @@ import org.springframework.stereotype.Service;
 @Service
 public class TenantStaffServiceImpl extends ServiceImpl<TenantStaffMapper, TenantStaff> implements TenantStaffService {
 
-	/**
+
+    @Autowired
+    private TenantInfoMapper tenantInfoMapper;
+
+    @Autowired
+    private SysUserMapper sysUserMapper;
+
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    /**
      * 查询详情
+     *
      * @param id 详情ID
      * @return TenantStaff
      */
-	@Override
+    @Override
     public TenantStaff detail(Long id) {
-        
+
         return baseMapper.selectById(id);
     }
-    
+
     /**
      * 分页查询
-     * @param page IPage<TenantStaff>
+     *
+     * @param page  IPage<TenantStaff>
      * @param query TenantStaffWrapper.TenantStaffQuery
      * @return IPage<TenantStaff>
      */
     @Override
-    public IPage<TenantStaff> selectPage(IPage<TenantStaff> page, TenantStaffWrapper.TenantStaffQuery query) {
-        
-        return page.setRecords(baseMapper.selectPage(page, query));
+    public IPage<TenantStaffWrapper.TenantStaff> selectPage(IPage<TenantStaffWrapper.TenantStaff> page, TenantStaffWrapper.TenantStaffQuery query) {
+        IPage<TenantStaffWrapper.TenantStaff> pageResult = page.setRecords(baseMapper.selectPage(page, query));
+        List<TenantStaffWrapper.TenantStaff> records = pageResult.getRecords();
+        if (CollectionUtils.isNotEmpty(records)) {
+            List<Long> tenantIdList = records.stream().map(TenantStaffWrapper.TenantStaff::getTenantId).distinct().collect(Collectors.toList());
+            QueryWrapper<TenantInfo> queryWrapper = new QueryWrapper<>();
+            queryWrapper.lambda().in(TenantInfo::getId, tenantIdList);
+            List<TenantInfo> tenantInfos = tenantInfoMapper.selectList(queryWrapper);
+            Map<Long, String> idNameMap = tenantInfos.stream().collect(Collectors.toMap(TenantInfo::getId, TenantInfo::getName));
+            records.forEach(next -> next.setTenantName(idNameMap.getOrDefault(next.getTenantId(), "")));
+        }
+        return pageResult;
     }
-	
+
     /**
      * 添加
+     *
      * @param tenantStaff TenantStaffWrapper.TenantStaff
      * @return Boolean
      */
     @Override
-    public Boolean add(TenantStaffWrapper.TenantStaff tenantStaff) {    	
-        
+    public Boolean add(TenantStaffWrapper.TenantStaff tenantStaff) {
+
         return this.save(JSON.parseObject(tenantStaff.jsonString(), TenantStaff.class));
     }
 
     /**
      * 更新
+     *
      * @param tenantStaff TenantStaffWrapper.TenantStaff
      * @return Boolean
      */
+    @Transactional(rollbackFor = Exception.class)
     @Override
-    public Boolean update(TenantStaffWrapper.TenantStaff tenantStaff){
+    public Boolean update(TenantStaffWrapper.TenantStaffAdd tenantStaff) {
+        TenantStaff staff = this.getById(tenantStaff.getId());
+        if (staff == null) {
+            throw new BizException("机构人员不存在");
+        }
+        staff.setNickname(tenantStaff.getNickname());
+        // 主管理员不能修改身份
+        if (Boolean.FALSE.equals(staff.getManageAdmin()) && Boolean.FALSE.equals(tenantStaff.getManageAdmin())) {
+            staff.setManageAdmin(tenantStaff.getManageAdmin());
+            // 更换了机构,清理wx关联ID
+            if (!staff.getTenantId().equals(tenantStaff.getTenantId())) {
+                staff.setTenantId(tenantStaff.getTenantId());
+                this.lambdaUpdate()
+                        .set(TenantStaff::getWxOpenid, null)
+                        .eq(TenantStaff::getId, staff.getId())
+                        .update();
+            }
+        }
+        Long userId = staff.getUserId();
+        com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = new com.yonge.cooleshow.biz.dal.entity.SysUser();
+        sysUser.setId(userId);
+        sysUser.setUsername(tenantStaff.getNickname());
+        sysUser.setGender(tenantStaff.getGender());
 
-        return this.updateById(JSON.parseObject(tenantStaff.jsonString(), TenantStaff.class));       
+        String phone = tenantStaff.getPhone();
+        // 修改手机号,处理账号
+        com.yonge.cooleshow.biz.dal.entity.SysUser oldUser = sysUserMapper.selectById(userId);
+        if (!oldUser.getPhone().equals(phone)) {
+            SysUser userByPhone = sysUserMapper.findUserByPhone(phone);
+            if (userByPhone != null) {
+                throw new BizException("该手机号已经注册账号");
+            } else {
+                sysUser.setPhone(phone);
+            }
+            String wxOpenid = staff.getWxOpenid();
+            // 存在值,说明登录并绑定过,执行退出登录
+            if (StringUtils.isNotEmpty(wxOpenid)) {
+                // 旧手机号退出登录
+                sysUserFeignService.exitByPhoneAndOpenId(ClientEnum.ORGANIZATION.getCode().toLowerCase(),
+                        sysUser.getPhone(), wxOpenid);
+                this.lambdaUpdate()
+                        .set(TenantStaff::getWxOpenid, null)
+                        .eq(TenantStaff::getId, staff.getId())
+                        .update();
+            }
+        }
+        sysUserMapper.updateById(sysUser);
+
+        tenantInfoMapper.update(null, Wrappers.<TenantInfo>lambdaUpdate()
+                .set(TenantInfo::getPhone, tenantStaff.getPhone())
+                .set(TenantInfo::getUsername, tenantStaff.getNickname())
+                .eq(TenantInfo::getUserId, staff.getUserId()));
+
+        return this.updateById(staff);
     }
 
     @Override
@@ -80,4 +173,22 @@ public class TenantStaffServiceImpl extends ServiceImpl<TenantStaffMapper, Tenan
 
         return lambdaQuery().eq(TenantStaff::getUserId, userId).last("LIMIT 1").one();
     }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void updateStatus(Long id, UserLockFlag status) {
+        this.lambdaUpdate()
+                .set(TenantStaff::getStatus, status)
+                .eq(TenantStaff::getId, id)
+                .update();
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void clearWxOpenId(Long id) {
+        this.lambdaUpdate()
+                .set(TenantStaff::getWxOpenid, null)
+                .eq(TenantStaff::getId, id)
+                .update();
+    }
 }

+ 107 - 29
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserTenantAlbumRecordServiceImpl.java

@@ -3,6 +3,7 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
@@ -26,12 +27,14 @@ import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
 import com.yonge.toolset.utils.obj.ObjectUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.BeanUtils;
 import lombok.extern.slf4j.Slf4j;
 import com.yonge.cooleshow.biz.dal.wrapper.UserTenantAlbumRecordWrapper;
 import com.yonge.cooleshow.biz.dal.mapper.UserTenantAlbumRecordMapper;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.*;
@@ -63,7 +66,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
     private MusicSheetService musicSheetService;
 
     @Autowired
-    private  StudentService studentService;
+    private StudentService studentService;
 
     @Autowired
     private TenantAlbumService tenantAlbumService;
@@ -92,12 +95,13 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 
     /**
      * 查询详情
+     *
      * @param id 详情ID
      * @return UserTenantAlbumRecord
      */
     @Override
     public UserTenantAlbumRecord detail(Long id) {
-        
+
         return baseMapper.selectById(id);
     }
 
@@ -107,7 +111,8 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 
     /**
      * 分页查询
-     * @param page IPage<UserTenantAlbumRecord>
+     *
+     * @param page  IPage<UserTenantAlbumRecord>
      * @param query UserTenantAlbumRecordWrapper.UserTenantAlbumRecordQuery
      * @return IPage<UserTenantAlbumRecord>
      */
@@ -119,15 +124,15 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 
         List<TenantAlbumWrapper.TenantAlbum> list = new ArrayList<>();
 
-            //查询生效的机构专辑id
-        if (id != null){
+        //查询生效的机构专辑id
+        if (id != null) {
             List<Long> tenantAlbumIds = baseMapper.selectTenantIds(id);
-            if (CollectionUtils.isEmpty(tenantAlbumIds)){
+            if (CollectionUtils.isEmpty(tenantAlbumIds)) {
                 return null;
             }
             List<TenantAlbum> tenantAlbums = baseMapper.selectTenantAlbumInfo(tenantAlbumIds);
 
-            tenantAlbums.stream().forEach(i->{
+            tenantAlbums.stream().forEach(i -> {
                 TenantAlbumWrapper.TenantAlbum vo = JSON.parseObject(JSON.toJSONString(i),
                         TenantAlbumWrapper.TenantAlbum.class);
 
@@ -192,26 +197,100 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
         return page.setRecords(list);
     }
 
+
+    /**
+     * 分页查询
+     *
+     * @param page  IPage<UserTenantAlbumRecord>
+     * @param query UserTenantAlbumRecordWrapper.UserTenantAlbumRecordQuery
+     * @return IPage<UserTenantAlbumRecord>
+     */
+    @Override
+    public IPage<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> selectUserTenantAlbumRecordPage(IPage<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> page,
+                                                                                                     UserTenantAlbumRecordWrapper.UserTenantAlbumRecordQuery query) {
+
+        IPage<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> records = page.setRecords(baseMapper.selectUserTenantAlbumRecordPage(page, query));
+        List<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> rows = records.getRecords();
+        if (CollectionUtils.isNotEmpty(rows)) {
+            List<Long> collect = rows.stream().map(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord::getTenantAlbumId).distinct().collect(Collectors.toList());
+            Map<Long, String> idNameMap = tenantAlbumService.lambdaQuery()
+                    .in(TenantAlbum::getId, collect)
+                    .list().stream().collect(Collectors.toMap(TenantAlbum::getId, TenantAlbum::getName));
+            rows.forEach(next -> next.setTenantAlbumName(idNameMap.getOrDefault(next.getTenantAlbumId(), "")));
+        }
+        return records;
+    }
+
     /**
      * 添加
+     *
      * @param userTenantAlbumRecord UserTenantAlbumRecordWrapper.UserTenantAlbumRecord
      * @return Boolean
      */
+    @Transactional(rollbackFor = Exception.class)
     @Override
-    public Boolean add(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord userTenantAlbumRecord) {
+    public Boolean add(UserTenantAlbumRecord userTenantAlbumRecord) {
+        Long tenantAlbumId = userTenantAlbumRecord.getTenantAlbumId();
+        TenantAlbum tenantAlbum = tenantAlbumMapper.selectById(tenantAlbumId);
+        if (tenantAlbum == null || Boolean.TRUE.equals(tenantAlbum.getDelFlag())) {
+            throw new BizException("专辑不存在");
+        }
+        if (Boolean.FALSE.equals(tenantAlbum.getStatus())) {
+            throw new BizException("专辑已经停用");
+        }
 
-        return this.save(JSON.parseObject(userTenantAlbumRecord.jsonString(), UserTenantAlbumRecord.class));
+        List<UserTenantAlbumRecord> userTenantAlbumRecords = this.getBaseMapper()
+                .selectList(Wrappers.<UserTenantAlbumRecord>lambdaQuery()
+                        .eq(UserTenantAlbumRecord::getTenantId, userTenantAlbumRecord.getTenantId())
+                        .eq(UserTenantAlbumRecord::getUserId, userTenantAlbumRecord.getUserId())
+                        .eq(UserTenantAlbumRecord::getTenantAlbumId, userTenantAlbumRecord.getTenantAlbumId())
+                        .eq(UserTenantAlbumRecord::getClientType, ClientEnum.STUDENT)
+                        .orderByDesc(UserTenantAlbumRecord::getEndTime));
+
+        Calendar instance = Calendar.getInstance();
+        instance.setTime(DateTime.now().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).toDate());
+        if (!userTenantAlbumRecords.isEmpty()) {
+            // 如果最后一次的时间的小于当前时间,则以当前时间为会员的开始时间
+            // 如果最后一次的时间的大于当前时间,则以最后一次的结束时间为记录的开始时间,相当会员续期
+            UserTenantAlbumRecord lastRecord = userTenantAlbumRecords.get(0);
+            Date lastEndTime = lastRecord.getEndTime();
+            if (lastEndTime.after(new Date())) {
+                instance.setTime(lastEndTime);
+            }
+        }
+        userTenantAlbumRecord.setStartTime(instance.getTime());
+
+        String type = userTenantAlbumRecord.getType();
+        if ("DAY".equals(type)) {
+            instance.add(Calendar.DAY_OF_MONTH, userTenantAlbumRecord.getTimes());
+        } else if ("MONTH".equals(type)) {
+            instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes());
+        } else if ("YEAR".equals(type)) {
+            instance.add(Calendar.YEAR, userTenantAlbumRecord.getTimes());
+        } else {
+            throw new BizException("不支持的周期类型");
+        }
+
+        instance.set(Calendar.HOUR_OF_DAY, 23);
+        instance.set(Calendar.MINUTE, 59);
+        instance.set(Calendar.SECOND, 59);
+        instance.set(Calendar.MILLISECOND, 0);
+        userTenantAlbumRecord.setEndTime(instance.getTime());
+        userTenantAlbumRecord.setCreateTime(new Date());
+        userTenantAlbumRecord.setUpdateTime(new Date());
+        return this.save(userTenantAlbumRecord);
     }
 
     /**
      * 更新
+     *
      * @param userTenantAlbumRecord UserTenantAlbumRecordWrapper.UserTenantAlbumRecord
      * @return Boolean
      */
     @Override
-    public Boolean update(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord userTenantAlbumRecord){
+    public Boolean update(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord userTenantAlbumRecord) {
 
-        return this.updateById(JSON.parseObject(userTenantAlbumRecord.jsonString(), UserTenantAlbumRecord.class));       
+        return this.updateById(JSON.parseObject(userTenantAlbumRecord.jsonString(), UserTenantAlbumRecord.class));
     }
 
 
@@ -230,6 +309,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
         }
         return recordList.get(0);
     }
+
     /**
      * 获取最新的购买记录
      *
@@ -246,14 +326,14 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
                 .eq(UserTenantAlbumRecord::getTenantId, tenantId)
                 .eq(UserTenantAlbumRecord::getUserId, userId)
                 .eq(UserTenantAlbumRecord::getClientType, clientType)
-                .in(CollectionUtils.isNotEmpty(tenantAlbumIds),UserTenantAlbumRecord::getTenantAlbumId,tenantAlbumIds)
+                .in(CollectionUtils.isNotEmpty(tenantAlbumIds), UserTenantAlbumRecord::getTenantAlbumId, tenantAlbumIds)
                 .ge(UserTenantAlbumRecord::getEndTime, new Date())
                 .orderByDesc(UserTenantAlbumRecord::getEndTime)
                 .list();
     }
 
     @Override
-    public List<Long> getUseAlbumIdsByUserId(Long userId,ClientEnum clientType) {
+    public List<Long> getUseAlbumIdsByUserId(Long userId, ClientEnum clientType) {
         if (userId == null) {
             return new ArrayList<>();
         }
@@ -281,7 +361,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
             throw new BizException("用户不存在");
         }
         Long tenantAlbumId;
-        if (StringUtils.isEmpty(albumId)){
+        if (StringUtils.isEmpty(albumId)) {
             Long id = sysUser.getId();
             List<Student> list = studentService.lambdaQuery().eq(Student::getUserId, id).list();
             if (CollectionUtils.isEmpty(list)) {
@@ -292,7 +372,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
             Long tenantId = student.getTenantId();
             //查询对应专辑id
             List<TenantAlbumMusic> tenantAlbumMusicList = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getTenantId, tenantId)
-                    .eq(TenantAlbumMusic::getDelFlag,false).list();
+                    .eq(TenantAlbumMusic::getDelFlag, false).list();
             if (CollectionUtils.isEmpty(tenantAlbumMusicList)) {
                 return null;
             }
@@ -304,7 +384,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
         }
         //获取对应机构专辑状态
         TenantAlbum one = tenantAlbumService.lambdaQuery().eq(TenantAlbum::getId, tenantAlbumId).last("limit 1").one();
-        if (!ObjectUtil.isEmpty(one)){
+        if (!ObjectUtil.isEmpty(one)) {
             album.setStatus(one.getStatus());
         }
 
@@ -321,7 +401,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
                 List<Long> albIds = albumRefs.stream().map(TenantAlbumRef::getTenantAlbumId).distinct().collect(Collectors.toList());
                 QueryWrapper<TenantAlbum> query = new QueryWrapper<>();
                 query.lambda().in(TenantAlbum::getId, albIds)
-                        .eq(TenantAlbum::getStatus,true);
+                        .eq(TenantAlbum::getStatus, true);
                 Integer count = tenantAlbumMapper.selectCount(query);
                 if (count > 0) {
                     album.setTenantAlbumStatus(1);
@@ -341,12 +421,10 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
         }
 
 
-
-
         //查询是否已经购买专辑
-        Long buyTenantAlbumId = userTenantAlbumRecordMapper.ifBuy(tenantAlbumId,sysUser.getId());
+        Long buyTenantAlbumId = userTenantAlbumRecordMapper.ifBuy(tenantAlbumId, sysUser.getId());
 
-        if (buyTenantAlbumId != null){
+        if (buyTenantAlbumId != null) {
             album.setIfBuy(true);
         } else {
             album.setIfBuy(false);
@@ -355,7 +433,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 
         //查询对应专辑的详情
         List<TenantAlbum> list = tenantAlbumService.lambdaQuery().eq(TenantAlbum::getId, tenantAlbumId).list();
-        if (CollectionUtils.isEmpty(list)){
+        if (CollectionUtils.isEmpty(list)) {
             throw new BizException("机构专辑不存在");
         }
         TenantAlbum tenantAlbum = list.get(0);
@@ -364,10 +442,10 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
         //机构专辑封面
         String coverImg = tenantAlbum.getCoverImg();
         //机构专辑曲目数
-        List<TenantAlbumMusic> tenantAlbumMusiclist = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId).eq(TenantAlbumMusic::getDelFlag,false).list();
+        List<TenantAlbumMusic> tenantAlbumMusiclist = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId).eq(TenantAlbumMusic::getDelFlag, false).list();
         List<Long> MusicSheetIds = tenantAlbumMusiclist.stream().map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList());
         //计算符合条件的个数
-        if (CollectionUtils.isNotEmpty(MusicSheetIds)){
+        if (CollectionUtils.isNotEmpty(MusicSheetIds)) {
             size = musicSheetService.lambdaQuery().in(MusicSheet::getId, MusicSheetIds).eq(MusicSheet::getState, true)
                     .eq(MusicSheet::getDelFlag, false).count();
         }
@@ -376,7 +454,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
         //获取合奏曲目数量
         List<TenantAlbumMusic> ensembleLits = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getSubjectType, "ENSEMBLE")
                 .eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId)
-                .eq(TenantAlbumMusic::getDelFlag,false).list();
+                .eq(TenantAlbumMusic::getDelFlag, false).list();
         List<Long> ensembleMusicSheetIds = ensembleLits.stream().map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList());
 
         album.setEnsembleCounts(ensembleMusicSheetIds.size());
@@ -384,7 +462,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
         //获取小曲目的曲目数量
         List<TenantAlbumMusic> musicLists = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getSubjectType, "MUSIC")
                 .eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId)
-                .eq(TenantAlbumMusic::getDelFlag,false).list();
+                .eq(TenantAlbumMusic::getDelFlag, false).list();
         List<Long> musicSheetIds = musicLists.stream().map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList());
 
         album.setMusicCounts(musicSheetIds.size());
@@ -392,7 +470,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
         //获取声部的曲目数量
         List<TenantAlbumMusic> subjectLists = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getSubjectType, "SUBJECT")
                 .eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId)
-                .eq(TenantAlbumMusic::getDelFlag,false).list();
+                .eq(TenantAlbumMusic::getDelFlag, false).list();
         List<Long> subjectSheetIds = subjectLists.stream().map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList());
 
         album.setSubjectCounts(subjectSheetIds.size());
@@ -459,7 +537,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
     }
 
 
-    private void temporarySend(Long userId,Long tenantAlbumId) {
+    private void temporarySend(Long userId, Long tenantAlbumId) {
         SysUser sysUser = sysUserFeignService.queryUserById(userId);
         if (null == sysUser) {
             return;
@@ -473,7 +551,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 
         try {
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TENANT_ALBUM_EXPIRE,
-                    receivers, null, 0, null, ClientEnum.TENANT_STUDENT.getCode(),tenantAlbum.getName());
+                    receivers, null, 0, null, ClientEnum.TENANT_STUDENT.getCode(), tenantAlbum.getName());
         } catch (Exception e) {
             log.error("机构学生训练教材过期", e);
         }

+ 108 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantStaffWrapper.java

@@ -1,9 +1,15 @@
 package com.yonge.cooleshow.biz.dal.wrapper;
 
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.yonge.cooleshow.common.enums.UserLockFlag;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
 import java.util.Optional;
 
 import lombok.AllArgsConstructor;
@@ -34,7 +40,19 @@ public class TenantStaffWrapper {
         
         @ApiModelProperty("关键字匹配")
 		private String keyword;
-        
+
+        @ApiModelProperty("机构ID")
+        private Integer tenantId;
+
+        @ApiModelProperty("账号状态,0:正常,1:锁定")
+        private UserLockFlag status;
+
+        @ApiModelProperty("是否是主管理员")
+        private Boolean manageAdmin;
+
+        @ApiModelProperty("绑定状态")
+        private Boolean bindStatus;
+
         public String getKeyword() {
             return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
         }
@@ -48,9 +66,64 @@ public class TenantStaffWrapper {
         }
     }  
 
+    @Data
 	@ApiModel(" TenantStaff-机构员工表")
     public static class TenantStaff {
-        
+
+        @ApiModelProperty("主键ID")
+        private Long id;
+
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
+
+        @ApiModelProperty("用户ID")
+        private Long userId;
+
+        @ApiModelProperty("头像")
+        private String avatar;
+
+        @ApiModelProperty("昵称")
+        private String nickname;
+
+        @ApiModelProperty("IM授权签名")
+        private String imToken;
+
+        @ApiModelProperty("微信ID")
+        private String wechatId;
+
+        @ApiModelProperty("微信OpenID")
+        private String wxOpenid;
+
+        @ApiModelProperty("公众号关注标识")
+        private Boolean subscribeFlag;
+
+        @ApiModelProperty("管理员标识")
+        private Boolean manageAdmin;
+
+        @ApiModelProperty("介绍")
+        private String introduction;
+
+        @ApiModelProperty("帐号状态(注销,冻结,激活)")
+        private UserLockFlag status;
+
+        @ApiModelProperty("更新时间")
+        private Date updateTime;
+
+        @ApiModelProperty("创建时间")
+        private Date createTime;
+
+        @ApiModelProperty("机构名称")
+        private String tenantName;
+
+        @ApiModelProperty("手机号")
+        private String phone;
+
+        @ApiModelProperty("绑定状态")
+        private Boolean bindStatus;
+
+        @ApiModelProperty("性别,0:女,1:男")
+        private Integer gender;
+
         public String jsonString() {
             return JSON.toJSONString(this);
         }
@@ -60,4 +133,37 @@ public class TenantStaffWrapper {
         }
 	}
 
+    @Data
+    @ApiModel(" TenantStaff-机构员工表")
+    public static class TenantStaffAdd {
+
+        @ApiModelProperty("主键ID")
+        private Long id;
+
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
+
+        @ApiModelProperty("用户ID")
+        private Long userId;
+
+        @ApiModelProperty("昵称")
+        private String nickname;
+
+        @ApiModelProperty("性别,0:女,1:男")
+        private Integer gender;
+
+        @ApiModelProperty("手机号")
+        private String phone;
+
+        @ApiModelProperty("是否是主管理员")
+        private Boolean manageAdmin;
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static TenantStaff from(String json) {
+            return JSON.parseObject(json, TenantStaff.class);
+        }
+    }
 }

+ 28 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/UserTenantAlbumRecordWrapper.java

@@ -45,6 +45,15 @@ public class UserTenantAlbumRecordWrapper {
         @ApiModelProperty("用户Id")
         private Long userId;
 
+        @ApiModelProperty("开始时间")
+        private Date startTime;
+
+        @ApiModelProperty("结束时间")
+        private Date endTime;
+
+        @ApiModelProperty("ORDER:激活码激活,TENANT:自行购买,BACKEND_GIVE:后台添加")
+        private SourceTypeEnum sourceType;
+
         
         public String getKeyword() {
             return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
@@ -59,6 +68,9 @@ public class UserTenantAlbumRecordWrapper {
         }
     }  
 
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
     @Data
 	@ApiModel(" UserTenantAlbumRecord-购买训练工具记录")
     public static class UserTenantAlbumRecord {
@@ -78,10 +90,13 @@ public class UserTenantAlbumRecordWrapper {
         @ApiModelProperty("机构专辑ID")
         private Long tenantAlbumId;
 
+        @ApiModelProperty("机构专辑ID")
+        private String tenantAlbumName;
+
         @ApiModelProperty("订单号")
         private String orderNo;
 
-        @ApiModelProperty("ORDER:订单")
+        @ApiModelProperty("ORDER:激活码激活,TENANT:自行购买,BACKEND_GIVE:后台添加")
         private SourceTypeEnum sourceType;
 
         @ApiModelProperty("购买人员类型 TEACHRE :老师端 STUDNET : 学生端")
@@ -108,6 +123,18 @@ public class UserTenantAlbumRecordWrapper {
         @ApiModelProperty("备注")
         private String reason;
 
+        @ApiModelProperty("创建时间")
+        private Date createTime;
+
+        @ApiModelProperty("创建人")
+        private Long createBy;
+
+        @ApiModelProperty("创建人")
+        private String createName;
+
+        @ApiModelProperty("更新时间")
+        private Date updateTime;
+
         public String jsonString() {
             return JSON.toJSONString(this);
         }

+ 34 - 5
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantStaffMapper.xml

@@ -27,13 +27,42 @@
 
     </update>
 
-    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.entity.TenantStaff">
-		SELECT         
-        	<include refid="baseColumns" />
+    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantStaffWrapper$TenantStaff">
+        SELECT
+        <include refid="baseColumns"/>
         ,su.avatar_ as avatar
-		FROM tenant_staff t
+        ,su.phone_ as phone
+        ,if(t.wx_openid_ is null,false,true) bindStatus
+        FROM tenant_staff t
         left join sys_user su on t.user_id_ = su.id_
-	</select>
+        <where>
+            <if test="param.keyword != null and param.keyword.trim() != ''">
+                and (
+                t.user_id_ like concat('%',#{param.keyword},'%')
+                or t.nickname_ like concat('%',#{param.keyword},'%')
+                or su.phone_ like concat('%',#{param.keyword},'%')
+                )
+            </if>
+            <if test="param.tenantId != null">
+                and t.tenant_id_ = #{param.tenantId}
+            </if>
+            <if test="param.status != null">
+                and t.status_ = #{param.status}
+            </if>
+            <if test="param.manageAdmin != null">
+                and t.manage_admin_ = #{param.manageAdmin}
+            </if>
+            <if test="param.bindStatus != null">
+                <if test="param.bindStatus == 1">
+                    and t.wx_openid_ is not null
+                </if>
+                <if test="param.bindStatus == 0">
+                    and t.wx_openid_ is null
+                </if>
+            </if>
+        </where>
+        order by t.id_ desc
+    </select>
 
     <select id="getByPhone" resultType="com.yonge.cooleshow.biz.dal.entity.TenantStaff">
         select

+ 32 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/UserTenantAlbumRecordMapper.xml

@@ -88,4 +88,36 @@
         and (msg_status_ = 0 or msg_status_ is null)
         order by end_time_ desc
     </select>
+
+    <select id="selectUserTenantAlbumRecordPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.UserTenantAlbumRecordWrapper$UserTenantAlbumRecord">
+        SELECT
+        <include refid="baseColumns" />
+        ,su.username_ createName
+        FROM user_tenant_album_record t
+        <if test="param.keyword != null and param.keyword.trim() != ''">
+            LEFT JOIN tenant_album ta on t.tenant_album_id_ = ta.id_
+        </if>
+        LEFT JOIN sys_user su on su.id_ = t.create_by_
+        <where>
+            <if test="param.keyword != null and param.keyword.trim() != ''">
+                AND (
+                su.username_ LIKE concat('%',#{param.keyword},'%')
+                OR ta.name_ LIKE concat('%',#{param.keyword},'%')
+                )
+            </if>
+            <if test="param.userId != null">
+                AND t.user_id_ = #{param.userId}
+            </if>
+            <if test="param.sourceType != null">
+                AND t.source_type_ = #{param.sourceType}
+            </if>
+            <if test="param.startTime != null">
+                AND t.create_time_ >= #{param.startTime}
+            </if>
+            <if test="param.endTime != null">
+                AND #{param.endTime} >= t.create_time_
+            </if>
+        </where>
+        ORDER BY t.id_ DESC
+    </select>
 </mapper>