浏览代码

Merge remote-tracking branch 'origin/saas' into saas

zouxuan 3 年之前
父节点
当前提交
c4c0ae47c0
共有 46 个文件被更改,包括 887 次插入115 次删除
  1. 0 11
      mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/entity/SysRole.java
  2. 125 0
      mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/entity/TenantInfo.java
  3. 5 0
      mec-auth/mec-auth-server/pom.xml
  4. 5 0
      mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/config/WebMvcConfig.java
  5. 1 1
      mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/dal/dao/SysRoleDao.java
  6. 1 1
      mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/dal/dao/SysRoleMenuDao.java
  7. 9 0
      mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/dal/dao/TenantInfoDao.java
  8. 60 0
      mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/interceptor/TenantInterceptor.java
  9. 8 0
      mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/TenantInfoService.java
  10. 1 1
      mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/impl/SysRoleServiceImpl.java
  11. 23 0
      mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/impl/TenantInfoServiceImpl.java
  12. 7 6
      mec-auth/mec-auth-server/src/main/resources/config/mybatis/SysRoleMenuMapper.xml
  13. 94 0
      mec-auth/mec-auth-server/src/main/resources/config/mybatis/TenantInfoMapper.xml
  14. 21 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/RedemptionCodeDao.java
  15. 5 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TenantAssetsInfoDao.java
  16. 1 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TenantCloudCourseRecordDao.java
  17. 3 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderDto.java
  18. 110 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/AppRedemptionCode.java
  19. 0 10
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Organization.java
  20. 0 24
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/TenantCloudCourseRecord.java
  21. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/TemplateTypeEnum.java
  22. 21 0
      mec-biz/src/main/java/com/ym/mec/biz/service/AppRedemptionCodeService.java
  23. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/SysManualService.java
  24. 5 1
      mec-biz/src/main/java/com/ym/mec/biz/service/TenantAssetsInfoService.java
  25. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/service/TenantCloudCourseRecordService.java
  26. 93 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/AppRedemptionCodeServiceImpl.java
  27. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
  28. 31 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysManualServiceImpl.java
  29. 58 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantAssetsInfoServiceImpl.java
  30. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantCloudCourseRecordServiceImpl.java
  31. 1 1
      mec-biz/src/main/resources/config/mybatis/CooperationOrganLinkmanMapper.xml
  32. 1 1
      mec-biz/src/main/resources/config/mybatis/MusicGroupOrganizationCourseSettingsDetailMapper.xml
  33. 1 1
      mec-biz/src/main/resources/config/mybatis/OrganizationCourseUnitPriceSettingsMapper.xml
  34. 33 0
      mec-biz/src/main/resources/config/mybatis/RedemptionCodeMapper.xml
  35. 1 1
      mec-biz/src/main/resources/config/mybatis/SysUserCashAccountMapper.xml
  36. 14 1
      mec-biz/src/main/resources/config/mybatis/TenantAssetsInfoMapper.xml
  37. 14 3
      mec-biz/src/main/resources/config/mybatis/TenantCloudCourseRecordMapper.xml
  38. 0 16
      mec-biz/src/main/resources/rebel.xml
  39. 5 0
      mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java
  40. 5 0
      mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java
  41. 23 0
      mec-task/src/main/java/com/ym/mec/task/jobs/RedemptionCodeWarnTask.java
  42. 45 0
      mec-web/src/main/java/com/ym/mec/web/controller/AppRedemptionCodeController.java
  43. 17 0
      mec-web/src/main/java/com/ym/mec/web/controller/ImportController.java
  44. 15 10
      mec-web/src/main/java/com/ym/mec/web/controller/SysManualController.java
  45. 2 16
      mec-web/src/main/java/com/ym/mec/web/controller/TenantAssetsInfoController.java
  46. 4 0
      mec-web/src/main/resources/columnMapper.ini

+ 0 - 11
mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/entity/SysRole.java

@@ -40,9 +40,6 @@ public class SysRole extends BaseEntity {
 
 	private Integer organId;
 
-	@ApiModelProperty(value = "机构id")
-	private Integer tenantId;
-
 	@ApiModelProperty(value = "菜单列表",required = false)
 	private List<Integer> menuIds;
 
@@ -118,14 +115,6 @@ public class SysRole extends BaseEntity {
 		this.organId = organId;
 	}
 
-    public Integer getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(Integer tenantId) {
-        this.tenantId = tenantId;
-    }
-
     @Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 125 - 0
mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/entity/TenantInfo.java

@@ -0,0 +1,125 @@
+package com.ym.mec.auth.api.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(tenant_info):
+ */
+public class TenantInfo {
+
+	/**  */
+	private Integer id;
+	
+	/** 机构名称 */
+	private String name;
+	
+	/** 机构地址 */
+	private String address;
+	
+	/** 域名 */
+	private String domainName;
+	
+	/** logo链接 */
+	private String logoUrl;
+	
+	/** 联系人 */
+	private String contactName;
+	
+	/** 联系电话 */
+	private String contactPhone;
+	
+	/** 数据源 */
+	private String dataSource;
+	
+	/**  */
+	private java.util.Date createTime;
+	
+	/**  */
+	private java.util.Date updateTime;
+	
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setName(String name){
+		this.name = name;
+	}
+	
+	public String getName(){
+		return this.name;
+	}
+			
+	public void setAddress(String address){
+		this.address = address;
+	}
+	
+	public String getAddress(){
+		return this.address;
+	}
+			
+	public void setDomainName(String domainName){
+		this.domainName = domainName;
+	}
+	
+	public String getDomainName(){
+		return this.domainName;
+	}
+			
+	public void setLogoUrl(String logoUrl){
+		this.logoUrl = logoUrl;
+	}
+	
+	public String getLogoUrl(){
+		return this.logoUrl;
+	}
+			
+	public void setContactName(String contactName){
+		this.contactName = contactName;
+	}
+	
+	public String getContactName(){
+		return this.contactName;
+	}
+			
+	public void setContactPhone(String contactPhone){
+		this.contactPhone = contactPhone;
+	}
+	
+	public String getContactPhone(){
+		return this.contactPhone;
+	}
+			
+	public void setDataSource(String dataSource){
+		this.dataSource = dataSource;
+	}
+	
+	public String getDataSource(){
+		return this.dataSource;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 5 - 0
mec-auth/mec-auth-server/pom.xml

@@ -79,6 +79,11 @@
 			<groupId>com.yonge.log</groupId>
 			<artifactId>audit-log</artifactId>
 		</dependency>
+		
+		<dependency>
+			<groupId>com.yonge.datasource</groupId>
+			<artifactId>dynamic-datasource</artifactId>
+		</dependency>
 
 		<dependency>
 			<groupId>org.apache.commons</groupId>

+ 5 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/config/WebMvcConfig.java

@@ -13,6 +13,7 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
 import com.ym.mec.auth.interceptor.OperationLogInterceptor;
+import com.ym.mec.auth.interceptor.TenantInterceptor;
 import com.ym.mec.common.config.EnumConverterFactory;
 import com.ym.mec.common.config.LocalFastJsonHttpMessageConverter;
 
@@ -21,6 +22,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
 	
 	@Autowired
 	private OperationLogInterceptor operationLogInterceptor;
+	
+	@Autowired
+	private TenantInterceptor tenantInterceptor;
 
 	/**
 	 * 枚举类的转换器 addConverterFactory
@@ -32,6 +36,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
 	
 	@Override
 	public void addInterceptors(InterceptorRegistry registry) {
+		registry.addInterceptor(tenantInterceptor).addPathPatterns("/**");
 		registry.addInterceptor(operationLogInterceptor).addPathPatterns("/userDevice/unbind").excludePathPatterns("/*");
 	}
 	

+ 1 - 1
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/dal/dao/SysRoleDao.java

@@ -27,5 +27,5 @@ public interface SysRoleDao extends BaseDAO<Integer, SysRole> {
      * @param roleName
      * @return
      */
-    SysRole findByRoleName(String roleName, @Param("tenantId") Integer tenantId);
+    SysRole findByRoleName(@Param("roleName") String roleName, @Param("tenantId") Integer tenantId);
 }

+ 1 - 1
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/dal/dao/SysRoleMenuDao.java

@@ -40,5 +40,5 @@ public interface SysRoleMenuDao extends BaseDAO<Integer, SysRoleMenu> {
 	 * @param roleId
 	 * @param menuIds
 	 */
-    void batchAdd(@Param("roleId") Integer roleId,@Param("menuIds")  List<Integer> menuIds);
+    void batchAdd(@Param("roleId") Integer roleId,@Param("menuIds")  List<Integer> menuIds, @Param("tenantId") Integer tenantId);
 }

+ 9 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/dal/dao/TenantInfoDao.java

@@ -0,0 +1,9 @@
+package com.ym.mec.auth.dal.dao;
+
+import com.ym.mec.auth.api.entity.TenantInfo;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface TenantInfoDao extends BaseDAO<Integer, TenantInfo> {
+
+	
+}

+ 60 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/interceptor/TenantInterceptor.java

@@ -0,0 +1,60 @@
+package com.ym.mec.auth.interceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.auth.api.entity.TenantInfo;
+import com.ym.mec.auth.service.SysUserService;
+import com.ym.mec.auth.service.TenantInfoService;
+import com.ym.mec.common.security.AuthUser;
+import com.ym.mec.common.security.SecurityUtils;
+import com.ym.mec.common.tenant.TenantContextHolder;
+
+@Component
+public class TenantInterceptor extends HandlerInterceptorAdapter {
+
+	private static final String DATA_SOURCE_ID = "datasourceId";
+
+	@Autowired
+	private SysUserService userService;
+	
+	@Autowired
+	private TenantInfoService tenantInfoService;
+
+	@Override
+	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler){
+		String tenantId = request.getHeader("tenantId");
+		if(StringUtils.isEmpty(tenantId)){
+			AuthUser authUser = SecurityUtils.getUser();
+			SysUser sysUser = null;
+			if(authUser != null){
+				sysUser = userService.get(authUser.getUserId());
+			}
+			if(sysUser != null && sysUser.getTenantId() != null){
+				tenantId = sysUser.getTenantId().toString();
+			}
+		}
+		if(StringUtils.isNotEmpty(tenantId)){
+			TenantContextHolder.setTenantId(Integer.parseInt(tenantId));
+			TenantInfo tenantInfo = tenantInfoService.get(Integer.parseInt(tenantId));
+			if(tenantInfo != null){
+				request.setAttribute(DATA_SOURCE_ID, tenantInfo.getDataSource());
+			}
+		}
+		return true;
+	}
+
+	@Override
+	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
+		TenantContextHolder.clearTenantId();
+	}
+
+}

+ 8 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/TenantInfoService.java

@@ -0,0 +1,8 @@
+package com.ym.mec.auth.service;
+
+import com.ym.mec.auth.api.entity.TenantInfo;
+import com.ym.mec.common.service.BaseService;
+
+public interface TenantInfoService extends BaseService<Integer, TenantInfo> {
+
+}

+ 1 - 1
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/impl/SysRoleServiceImpl.java

@@ -79,7 +79,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<Integer, SysRole>  imple
 		List<Integer> menuIds = sysRole.getMenuIds();
 		if(menuIds != null && menuIds.size() > 0){
 //			SysRoleMenu sysRoleMenu = new SysRoleMenu(sysRole.getId(),null);
-			sysRoleMenuDao.batchAdd(sysRole.getId(),menuIds);
+			sysRoleMenuDao.batchAdd(sysRole.getId(),menuIds, sysRole.getTenantId());
 //			menuIds.forEach(e->{
 //				sysRoleMenu.setMenuId(e);
 //				sysRoleMenuDao.insert(sysRoleMenu);

+ 23 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/impl/TenantInfoServiceImpl.java

@@ -0,0 +1,23 @@
+package com.ym.mec.auth.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.ym.mec.auth.api.entity.TenantInfo;
+import com.ym.mec.auth.dal.dao.TenantInfoDao;
+import com.ym.mec.auth.service.TenantInfoService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+
+@Service
+public class TenantInfoServiceImpl extends BaseServiceImpl<Integer, TenantInfo>  implements TenantInfoService {
+	
+	@Autowired
+	private TenantInfoDao tenantInfoDao;
+
+	@Override
+	public BaseDAO<Integer, TenantInfo> getDAO() {
+		return tenantInfoDao;
+	}
+	
+}

+ 7 - 6
mec-auth/mec-auth-server/src/main/resources/config/mybatis/SysRoleMenuMapper.xml

@@ -9,6 +9,7 @@
 	<resultMap type="com.ym.mec.auth.api.entity.SysRoleMenu" id="SysRoleMenu">
 		<result column="role_id_" property="roleId" />
 		<result column="menu_id_" property="menuId" />
+		<result column="tenant_id_" property="tenantId" />
 	</resultMap>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -18,7 +19,7 @@
 	
 	<!-- 全查询 -->
 	<select id="findAll" resultMap="SysRoleMenu">
-		SELECT * FROM sys_role_menu ORDER BY role_id_,menu_id_
+		SELECT * FROM sys_role_menu where tenant_id_ = #{tenantId} ORDER BY role_id_,menu_id_
 	</select>
 	
 	<!-- 向数据库增加一条记录 -->
@@ -28,12 +29,12 @@
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
 		</selectKey>
 		-->
-		INSERT INTO sys_role_menu (role_id_,menu_id_) VALUES(#{roleId},#{menuId})
+		INSERT INTO sys_role_menu (role_id_,menu_id_,tenant_id_) VALUES(#{roleId},#{menuId},#{tenantId})
 	</insert>
     <insert id="batchAdd">
-		INSERT INTO sys_role_menu (role_id_,menu_id_) VALUES
+		INSERT INTO sys_role_menu (role_id_,menu_id_,tenant_id_) VALUES
 		<foreach collection="menuIds" item="item" index="index" separator=",">
-			(#{roleId},#{item})
+			(#{roleId},#{item},#{tenantId})
 		</foreach>
 	</insert>
 
@@ -47,12 +48,12 @@
 
     <!-- 分页查询 -->
 	<select id="queryPage" resultMap="SysRoleMenu" parameterType="map">
-		SELECT * FROM sys_role_menu ORDER BY role_id_,menu_id_ <include refid="global.limit"/>
+		SELECT * FROM sys_role_menu where tenant_id_ = #{tenantId} ORDER BY role_id_,menu_id_ <include refid="global.limit"/>
 	</select>
 	
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM sys_role_menu
+		SELECT COUNT(*) FROM sys_role_menu where tenant_id_ = #{tenantId}
 	</select>
 	
 	<select id="queryPermissionsByRoleId" resultType="string" parameterType="int">

+ 94 - 0
mec-auth/mec-auth-server/src/main/resources/config/mybatis/TenantInfoMapper.xml

@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
+<mapper namespace="com.ym.mec.auth.dal.dao.TenantInfoDao">
+
+	<resultMap type="com.ym.mec.auth.api.entity.TenantInfo" id="TenantInfo">
+		<result column="id_" property="id" />
+		<result column="name_" property="name" />
+		<result column="address_" property="address" />
+		<result column="domain_name_" property="domainName" />
+		<result column="logo_url_" property="logoUrl" />
+		<result column="contact_name_" property="contactName" />
+		<result column="contact_phone_" property="contactPhone" />
+		<result column="data_source_" property="dataSource" />
+		<result column="create_time_" property="createTime" />
+		<result column="update_time_" property="updateTime" />
+	</resultMap>
+
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="TenantInfo">
+		SELECT * FROM
+		tenant_info WHERE id_ = #{id}
+	</select>
+
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="TenantInfo">
+		SELECT * FROM tenant_info ORDER
+		BY id_
+	</select>
+
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.auth.api.entity.TenantInfo"
+		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
+			AS ID FROM DUAL </selectKey> -->
+		INSERT INTO tenant_info
+		(id_,name_,address_,domain_name_,logo_url_,contact_name_,contact_phone_,data_source_,create_time_,update_time_)
+		VALUES(#{id},#{name},#{address},#{domainName},#{logoUrl},#{contactName},#{contactPhone},#{dataSource},#{createTime},#{updateTime})
+	</insert>
+
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.auth.api.entity.TenantInfo">
+		UPDATE tenant_info
+		<set>
+			<if test="address != null">
+				address_ = #{address},
+			</if>
+			<if test="dataSource != null">
+				data_source_ = #{dataSource},
+			</if>
+			<if test="id != null">
+				id_ = #{id},
+			</if>
+			<if test="updateTime != null">
+				update_time_ = #{updateTime},
+			</if>
+			<if test="logoUrl != null">
+				logo_url_ = #{logoUrl},
+			</if>
+			<if test="contactPhone != null">
+				contact_phone_ = #{contactPhone},
+			</if>
+			<if test="domainName != null">
+				domain_name_ = #{domainName},
+			</if>
+			<if test="contactName != null">
+				contact_name_ = #{contactName},
+			</if>
+			<if test="name != null">
+				name_ = #{name},
+			</if>
+			<if test="createTime != null">
+				create_time_ = #{createTime},
+			</if>
+		</set>
+		WHERE id_ = #{id}
+	</update>
+
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete">
+		DELETE FROM tenant_info WHERE id_ = #{id}
+	</delete>
+
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="TenantInfo" parameterType="map">
+		SELECT * FROM tenant_info ORDER BY id_
+		<include refid="global.limit" />
+	</select>
+
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM tenant_info
+	</select>
+</mapper>

+ 21 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/RedemptionCodeDao.java

@@ -0,0 +1,21 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ym.mec.biz.dal.entity.AppRedemptionCode;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 兑换码分配表(RedemptionCode)表数据库访问层
+ *
+ * @author makejava
+ * @since 2021-12-27 14:27:57
+ */
+public interface RedemptionCodeDao extends BaseMapper<AppRedemptionCode> {
+
+   int insertBatch(@Param("entities") List<AppRedemptionCode> entities);
+
+    AppRedemptionCode findFirstNull();
+}
+

+ 5 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TenantAssetsInfoDao.java

@@ -17,6 +17,10 @@ public interface TenantAssetsInfoDao extends BaseMapper<TenantAssetsInfo> {
 
     int insertBatch(@Param("entities") List<TenantAssetsInfo> entities);
 
-    int updateAmount(BigDecimal frozenAmount);
+    int frozenAmount(BigDecimal frozenAmount);
+
+    int recoverAmount(BigDecimal recoverAmount);
+
+    int deductAmount(BigDecimal deductAmount);
 }
 

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TenantCloudCourseRecordDao.java

@@ -18,5 +18,6 @@ public interface TenantCloudCourseRecordDao extends BaseMapper<TenantCloudCourse
 
     <T> IPage<T> queryPage(Page<T> page, @Param("param") Map<String, Object> param);
 
+    TenantCloudCourseRecord queryLastRecord(Integer courseId);
 }
 

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderDto.java

@@ -10,9 +10,11 @@ import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderStudentDetail;
+import com.ym.mec.common.entity.BaseEntity;
+
 import io.swagger.annotations.ApiModelProperty;
 
-public class MusicGroupPaymentCalenderDto {
+public class MusicGroupPaymentCalenderDto extends BaseEntity {
 
 	private String musicGroupId;
 

+ 110 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/AppRedemptionCode.java

@@ -0,0 +1,110 @@
+package com.ym.mec.biz.dal.entity;
+
+
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.io.Serializable;
+
+/**
+ * 兑换码分配表(RedemptionCode)表实体类
+ *
+ * @author makejava
+ * @since 2021-12-27 14:27:57
+ */
+@ApiModel(value = "redemption_code-兑换码分配表")
+public class AppRedemptionCode implements Serializable {
+    @TableId(value = "id_", type = IdType.AUTO)
+    @ApiModelProperty(value = "${column.comment}")
+    private Integer id;
+
+    @TableField("url_")
+    @ApiModelProperty(value = "兑换url")
+    private String url;
+
+    @TableField("code_")
+    @ApiModelProperty(value = "兑换码")
+    private String code;
+
+    @TableField("user_id_")
+    @ApiModelProperty(value = "分配用户")
+    private Integer userId;
+
+    @TableField("import_time_")
+    @ApiModelProperty(value = "导入时间")
+    private Date importTime;
+
+    @TableField("update_time_")
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+
+    @TableField("status_")
+    @ApiModelProperty(value = "状态 1-已导入未分配 2-预分配 3-已分配")
+    private String status;
+
+    private static final long serialVersionUID = 1L;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Date getImportTime() {
+        return importTime;
+    }
+
+    public void setImportTime(Date importTime) {
+        this.importTime = importTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+
+}
+

+ 0 - 10
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Organization.java

@@ -83,9 +83,6 @@ public class Organization extends BaseEntity {
 	@ApiModelProperty(value = "衔接老师",required = false)
 	private String joinTeacherName;
 
-	@ApiModelProperty(value = "机构id",required = false)
-    private Integer tenantId;
-
 	public String getJoinTeacherId() {
 		return joinTeacherId;
 	}
@@ -259,11 +256,4 @@ public class Organization extends BaseEntity {
 		this.gradeType = gradeType;
 	}
 
-    public Integer getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(Integer tenantId) {
-        this.tenantId = tenantId;
-    }
 }

+ 0 - 24
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/TenantCloudCourseRecord.java

@@ -48,14 +48,6 @@ public class TenantCloudCourseRecord implements Serializable {
     @ApiModelProperty(value = "创建时间")
     private Date createdTime;
 
-    @TableField("updated_by_")
-    @ApiModelProperty(value = "更新人")
-    private Integer updatedBy;
-
-    @TableField("updated_time_")
-    @ApiModelProperty(value = "更新时间")
-    private Date updatedTime;
-
     private static final long serialVersionUID = 1L;
 
     public Integer getId() {
@@ -114,21 +106,5 @@ public class TenantCloudCourseRecord implements Serializable {
         this.createdTime = createdTime;
     }
 
-    public Integer getUpdatedBy() {
-        return updatedBy;
-    }
-
-    public void setUpdatedBy(Integer updatedBy) {
-        this.updatedBy = updatedBy;
-    }
-
-    public Date getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Date updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
 }
 

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/TemplateTypeEnum.java

@@ -5,7 +5,8 @@ import com.ym.mec.common.enums.BaseEnum;
 public enum TemplateTypeEnum implements BaseEnum<String, TemplateTypeEnum> {
     GOODS("GOODS","商品导入模板"),
     ROUTE_ORDER("ROUTE_ORDER","财务管理导入模板"),
-    FINANCIAL_EXPENDITURE("FINANCIAL_EXPENDITURE","财务支出导入模板");
+    FINANCIAL_EXPENDITURE("FINANCIAL_EXPENDITURE","财务支出导入模板"),
+    REDEMPTIONCODE("REDEMPTION_CODE", "兑换码分配模板表");
 
     private String code;
 

+ 21 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/AppRedemptionCodeService.java

@@ -0,0 +1,21 @@
+package com.ym.mec.biz.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.biz.dal.entity.AppRedemptionCode;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+/**
+ * 兑换码分配表(RedemptionCode)表服务接口
+ *
+ * @author makejava
+ * @since 2021-12-27 14:27:57
+ */
+public interface AppRedemptionCodeService extends IService<AppRedemptionCode> {
+
+    List<AppRedemptionCode> importRedemptionCode(MultipartFile file) throws Exception;
+
+    AppRedemptionCode allocation(Integer userId);
+}
+

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysManualService.java

@@ -2,6 +2,8 @@ package com.ym.mec.biz.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ym.mec.biz.dal.entity.SysManual;
+import com.ym.mec.biz.dal.page.SysManualQueryInfo;
+import com.ym.mec.common.page.PageInfo;
 
 /**
  * (SysManual)表服务接口
@@ -10,5 +12,11 @@ import com.ym.mec.biz.dal.entity.SysManual;
  * @since 2021-12-20 13:46:08
  */
 public interface SysManualService extends IService<SysManual> {
+
+    PageInfo<SysManual> query(SysManualQueryInfo queryInfo);
+
+    Boolean add(SysManual sysManual, Integer userId);
+
+    Boolean update(SysManual sysManual, Integer userId);
 }
 

+ 5 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/TenantAssetsInfoService.java

@@ -14,6 +14,10 @@ import java.util.List;
  */
 public interface TenantAssetsInfoService extends IService<TenantAssetsInfo> {
 
-    void courseDeductionRules(List<CourseSchedule> dto);
+    void courseFrozenAmount(List<CourseSchedule> dto);
+
+    void courseRecoverAmount(Integer courseId);
+
+    void courseDeductAmount(Integer courseId);
 }
 

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/TenantCloudCourseRecordService.java

@@ -17,5 +17,7 @@ public interface TenantCloudCourseRecordService extends IService<TenantCloudCour
 
     PageInfo<TenantCloudCourseRecordVo> queryPage(Map<String,Object> param);
 
+    TenantCloudCourseRecord queryLastRecord(Integer courseId);
+
 }
 

+ 93 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/AppRedemptionCodeServiceImpl.java

@@ -0,0 +1,93 @@
+package com.ym.mec.biz.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.biz.dal.dao.RedemptionCodeDao;
+import com.ym.mec.biz.dal.entity.AppRedemptionCode;
+import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.biz.service.AppRedemptionCodeService;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.page.WrapperUtil;
+import com.ym.mec.util.excel.POIUtil;
+import com.ym.mec.util.ini.IniFileUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.stereotype.Service;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.*;
+
+/**
+ * 兑换码分配表(RedemptionCode)表服务实现类
+ *
+ * @author makejava
+ * @since 2021-12-27 14:27:57
+ */
+@Service("redemptionCodeService")
+public class AppRedemptionCodeServiceImpl extends ServiceImpl<RedemptionCodeDao, AppRedemptionCode> implements AppRedemptionCodeService {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(AppRedemptionCodeServiceImpl.class);
+
+    @Autowired
+    private RedemptionCodeDao redemptionCodeDao;
+
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    private final static Logger logger = LoggerFactory.getLogger(AppRedemptionCodeServiceImpl.class);
+
+    @Override
+    public List<AppRedemptionCode> importRedemptionCode(MultipartFile file) throws Exception {
+        Map<String, List<Map<String, Object>>> sheetsListMap = POIUtil.importExcel(new ByteArrayInputStream(file.getBytes()), 2, file.getOriginalFilename());
+        
+        InputStream inputStream = new ClassPathResource("columnMapper.ini").getInputStream();
+        Map<String,String> columns = IniFileUtil.readIniFile(inputStream, TemplateTypeEnum.REDEMPTIONCODE.getMsg());
+
+        List<AppRedemptionCode> redemptionCodesList = new ArrayList<>();
+        for (String e : sheetsListMap.keySet()) {
+            List<Map<String, Object>> sheet = sheetsListMap.get(e);
+            for (Map<String, Object> row : sheet) {
+                if (row.size() == 0) {
+                    continue;
+                }
+
+                JSONObject objectMap = new JSONObject();
+                for (String s : row.keySet()) {
+                    if(!columns.containsKey(s)){
+                        continue;
+                    }
+                    String columnValue = columns.get(s);
+                    if(null == row.get(s) || StringUtils.isBlank(row.get(s).toString())){
+                        LOGGER.error("导入异常:参数{}不可为空 param:{}",columnValue,objectMap);
+                        continue ;
+                    }
+                    objectMap.put(columnValue, row.get(s));
+                }
+                try {
+                    AppRedemptionCode redemptionCode = JSONObject.parseObject(objectMap.toJSONString(),AppRedemptionCode.class);
+                    redemptionCodesList.add(redemptionCode);
+                    redemptionCodeDao.insert(redemptionCode);
+                } catch (Exception ex) {
+                    throw new BizException("导入数据出错", ex);
+                }
+            }
+        }
+        return redemptionCodesList;
+    }
+
+    @Override
+    public AppRedemptionCode allocation(Integer userId) {
+        AppRedemptionCode redemptionCode = redemptionCodeDao.findFirstNull();
+        redemptionCode.setUserId(userId);
+        redemptionCodeDao.update(redemptionCode, new WrapperUtil<AppRedemptionCode>().queryWrapper());
+        return redemptionCode;
+    }
+}
+

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -1881,6 +1881,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         if (CollectionUtils.isEmpty(courseSchedules)) {
             return false;
         }
+        //
+
         List<String> classDates = courseSchedules.stream().map(courseSchedule -> DateUtil.dateToString(courseSchedule.getClassDate(), "yyyy-MM-dd"))
                 .collect(Collectors.toList());
 

+ 31 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysManualServiceImpl.java

@@ -1,14 +1,23 @@
 package com.ym.mec.biz.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ym.mec.biz.dal.dao.SysManualDao;
 import com.ym.mec.biz.dal.entity.SysManual;
+import com.ym.mec.biz.dal.page.SysManualQueryInfo;
 import com.ym.mec.biz.service.SysManualService;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.PageUtil;
+import com.ym.mec.common.page.WrapperUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Date;
+
 /**
  * (SysManual)表服务实现类
  *
@@ -19,5 +28,27 @@ import org.slf4j.LoggerFactory;
 public class SysManualServiceImpl extends ServiceImpl<SysManualDao, SysManual> implements SysManualService {
 
     private final static Logger logger = LoggerFactory.getLogger(SysManualServiceImpl.class);
+
+    public PageInfo<SysManual> query(SysManualQueryInfo queryInfo) {
+        QueryWrapper<SysManual> queryWrapper = new WrapperUtil<SysManual>().hasEq("menu_id_", queryInfo.getMenuId()).queryWrapper();
+        Page<SysManual> pageInfo = PageUtil.getPage(queryInfo.getPage(), queryInfo.getRows());
+
+        return PageUtil.pageInfo(this.page(pageInfo, queryWrapper));
+    }
+
+    public Boolean add(SysManual sysManual, Integer userId) {
+        logger.info("sysManual save");
+        sysManual.setOperatorId(userId);
+        sysManual.setCreateTime(new Date());
+        sysManual.setUpdateTime(new Date());
+        return this.save(sysManual);
+    }
+
+    public Boolean update(SysManual sysManual, Integer userId) {
+        logger.info("sysManual save");
+        sysManual.setOperatorId(userId);
+        sysManual.setUpdateTime(new Date());
+        return this.save(sysManual);
+    }
 }
 

+ 58 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantAssetsInfoServiceImpl.java

@@ -16,7 +16,6 @@ import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.yqpay.DateUtils;
 import org.apache.commons.collections.CollectionUtils;
-import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -47,8 +46,53 @@ public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private TenantCloudCourseRecordService tenantCloudCourseRecordService;
-    @Autowired
-    private RedissonClient redissonClient;
+
+    /**
+     * 扣除冻结的金额
+     *
+     * @param courseId 课程id
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void courseDeductAmount(Integer courseId){
+        TenantCloudCourseRecord lastRecord = checkLastRecord(courseId);
+        //写入流水
+        lastRecord.setDeductState(1);
+        tenantCloudCourseRecordService.save(lastRecord);
+        if (baseMapper.deductAmount(lastRecord.getAmount()) != 1) {
+            throw new BizException("解除冻结金额失败!");
+        }
+    }
+
+    /**
+     * 恢复/取消 冻结的金额
+     *
+     * @param courseId 课程id
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void courseRecoverAmount(Integer courseId) {
+        TenantCloudCourseRecord lastRecord = checkLastRecord(courseId);
+        //写入流水
+        lastRecord.setDeductState(2);
+        tenantCloudCourseRecordService.save(lastRecord);
+        //解除冻结金额,恢复余额
+        if (baseMapper.recoverAmount(lastRecord.getAmount()) != 1) {
+            throw new BizException("解除冻结金额失败!");
+        }
+    }
+
+    private TenantCloudCourseRecord checkLastRecord(Integer courseId) {
+        TenantCloudCourseRecord lastRecord = tenantCloudCourseRecordService.queryLastRecord(courseId);
+        //判断是否是冻结的状态
+        if (Objects.nonNull(lastRecord) && lastRecord.getDeductState() != 0) {
+            //只有冻结的才能取消冻结 或者 扣费
+            throw new BizException("该课程非线上课!");
+        }
+        lastRecord.setCreatedBy(getUserId());
+        lastRecord.setCreatedTime(new Date());
+        return lastRecord;
+    }
 
     /**
      * 排课扣费计算
@@ -57,7 +101,7 @@ public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void courseDeductionRules(List<CourseSchedule> dto) {
+    public void courseFrozenAmount(List<CourseSchedule> dto) {
         Integer tenantId = TenantContextHolder.getTenantId();
 
         //校验课程 筛选出线上课
@@ -76,12 +120,19 @@ public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao
         Map<String, BigDecimal> rule = getRule(tenantId);
         BigDecimal frozenAmount = BigDecimal.ZERO;
 
-        for (CourseSchedule course : dto) {//获取总人数 ,+1是算上老师
+        for (CourseSchedule course : dto) {
+            TenantCloudCourseRecord lastRecord = tenantCloudCourseRecordService.queryLastRecord(course.getId().intValue());
+            if (Objects.nonNull(lastRecord) && lastRecord.getDeductState() == 0) {
+                //该课程id最后一条记录也是冻结状态
+                throw new BizException("该课程已是线上课!");
+            }
+
+            //获取总人数 ,+1是算上老师
             Integer totalPeople = course.getStudentNum() + 1;
             //获取每分钟扣费标准
             BigDecimal minutePrice = rule.get(String.valueOf(totalPeople));
             if (Objects.isNull(minutePrice)) {
-                //实际上是没有这个扣费标准
+                //没有这个扣费标准
                 throw new BizException("课程人数已达上限,请联系教务老师!");
             }
             //计算总上课时间
@@ -102,7 +153,7 @@ public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao
         }
 
         //直接修改余额,利用数据库的规则来防ABA的出现
-        if (baseMapper.updateAmount(frozenAmount) != 1) {
+        if (baseMapper.frozenAmount(frozenAmount) != 1) {
             //可能是余额不足
             throw new BizException("线上课预约火爆,请联系教务老师!");
         }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantCloudCourseRecordServiceImpl.java

@@ -32,5 +32,10 @@ public class TenantCloudCourseRecordServiceImpl extends ServiceImpl<TenantCloudC
         return PageUtil.pageInfo(baseMapper.queryPage(pageInfo, param));
 
     }
+
+    @Override
+    public TenantCloudCourseRecord queryLastRecord(Integer courseId) {
+        return baseMapper.queryLastRecord(courseId);
+    }
 }
 

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/CooperationOrganLinkmanMapper.xml

@@ -41,7 +41,7 @@
 		(id_,cooperation_organ_id_,linkman_,mobile_no_,job_,create_time_,tenant_id_)
 		VALUES
 		<foreach collection="list" item="item" separator=",">
-		(#{item.id},#{item.cooperationOrganId},#{item.linkman},#{item.mobileNo},#{item.job},#{item.createTime},#{itemm.tenantId})
+		(#{item.id},#{item.cooperationOrganId},#{item.linkman},#{item.mobileNo},#{item.job},#{item.createTime},#{item.tenantId})
 		</foreach>
 	</insert>
 

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/MusicGroupOrganizationCourseSettingsDetailMapper.xml

@@ -94,7 +94,7 @@
             #{settingDetail.courseTotalMinuties},
             #{settingDetail.unitPrice}, #{settingDetail.courseOriginalPrice}, #{settingDetail.courseCurrentPrice},
             #{settingDetail.isStudentOptional},
-            NOW(),NOW(),#{tenantId})
+            NOW(),NOW(),#{settingDetail.tenantId})
         </foreach>
     </insert>
 

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/OrganizationCourseUnitPriceSettingsMapper.xml

@@ -40,7 +40,7 @@
 		(id_,organ_id_,course_type_,charge_type_id_,unit_price_,create_time_,update_time_,tenant_id_)
 		VALUES
 		<foreach collection="list" item="item" separator=",">
-		(#{item.id},#{item.organId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.chargeTypeId},#{item.unitPrice},now(),now(),#{tenantId})
+		(#{item.id},#{item.organId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.chargeTypeId},#{item.unitPrice},now(),now(),#{item.tenantId})
 		</foreach>
 	</insert>
 

+ 33 - 0
mec-biz/src/main/resources/config/mybatis/RedemptionCodeMapper.xml

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ym.mec.biz.dal.dao.RedemptionCodeDao">
+  <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.AppRedemptionCode">
+                       <id column="id_" jdbcType="INTEGER" property="id"/>
+                                  <result column="url_" jdbcType="VARCHAR" property="url"/>
+                                  <result column="code_" jdbcType="VARCHAR" property="code"/>
+                                  <result column="user_id_" jdbcType="INTEGER" property="userId"/>
+                                  <result column="import_time_" jdbcType="TIMESTAMP" property="importTime"/>
+                                  <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
+                                  <result column="status_" jdbcType="VARCHAR" property="status"/>
+                </resultMap>
+  
+  <sql id="Base_Column_List">    
+                                        id_, url_, code_, user_id_, import_time_, update_time_, status_
+  </sql>
+  
+   <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
+            parameterType="com.ym.mec.biz.dal.entity.AppRedemptionCode">
+       insert into app_redemption_code(url_, code_, user_id_, import_time_, update_time_, status_)
+       values
+       <foreach collection="entities" item="entity" separator=",">
+       (#{entity.url}, #{entity.code}, #{entity.userId}, #{entity.importTime}, #{entity.updateTime}, #{entity.status})
+       </foreach>
+   </insert>
+
+    <select id="findFirstNull" resultType="com.ym.mec.biz.dal.entity.AppRedemptionCode">
+        select * from app_redemption_code rc where rc.user_id_ is null
+        order by rc.import_time_ desc
+        limit 1 for update;
+    </select>
+
+</mapper>

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/SysUserCashAccountMapper.xml

@@ -102,7 +102,7 @@
         <where>
         suca.tenant_id_ = #{tenantId}
         <if test="organId != null">
-            FIND_IN_SET(su.organ_id_,#{organId})
+            and FIND_IN_SET(su.organ_id_,#{organId})
         </if>
         </where>
     </select>

+ 14 - 1
mec-biz/src/main/resources/config/mybatis/TenantAssetsInfoMapper.xml

@@ -25,11 +25,24 @@
         </foreach>
     </insert>
 
-    <update id="updateAmount" parameterType="decimal">
+    <update id="frozenAmount" parameterType="decimal">
         update tenant_assets_info
         set balance_       = balance_ - #{frozenAmount},
             frozen_amount_ = frozen_amount_ + #{frozenAmount}
         where balance_  <![CDATA[ >= ]]> #{frozenAmount}
     </update>
 
+    <update id="recoverAmount" parameterType="decimal">
+        update tenant_assets_info
+        set balance_       = balance_ + #{recoverAmount},
+            frozen_amount_ = frozen_amount_ - #{recoverAmount}
+        where frozen_amount_  <![CDATA[ >= ]]> #{recoverAmount}
+    </update>
+
+    <update id="deductAmount" parameterType="decimal">
+        update tenant_assets_info
+        set frozen_amount_ = frozen_amount_ - #{deductAmount}
+        where frozen_amount_  <![CDATA[ >= ]]> #{deductAmount}
+    </update>
+
 </mapper>

+ 14 - 3
mec-biz/src/main/resources/config/mybatis/TenantCloudCourseRecordMapper.xml

@@ -10,13 +10,11 @@
         <result column="amount_" jdbcType="VARCHAR" property="amount"/>
         <result column="created_by_" jdbcType="INTEGER" property="createdBy"/>
         <result column="created_time_" jdbcType="TIMESTAMP" property="createdTime"/>
-        <result column="updated_by_" jdbcType="INTEGER" property="updatedBy"/>
-        <result column="updated_time_" jdbcType="TIMESTAMP" property="updatedTime"/>
     </resultMap>
 
     <sql id="Base_Column_List">
         id_
-        , tenant_id_, course_id_, deduct_state_, amount_, created_by_, created_time_, updated_by_, updated_time_
+        , tenant_id_, course_id_, deduct_state_, amount_, created_by_, created_time_
     </sql>
 
     <select id="queryPage" parameterType="map" resultType="com.ym.mec.biz.dal.vo.TenantCloudCourseRecordVo">
@@ -53,6 +51,9 @@
             <if test="param.type != null ">
                 AND b.type_ = #{param.type}
             </if>
+            <if test="param.orgId != null ">
+                AND o.id_= #{param.orgId}
+            </if>
             <if test="param.teacherName != null ">
                 AND s.real_name_ = #{param.teacherName}
             </if>
@@ -74,4 +75,14 @@
         </where>
     </select>
 
+    <select id="queryLastRecord" parameterType="integer" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from
+        tenant_cloud_course_record
+        where course_id_=#{courseId}
+        order by created_time_ desc
+        limit 1
+    </select>
+
 </mapper>

+ 0 - 16
mec-biz/src/main/resources/rebel.xml

@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-  This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
-  Refer to https://manuals.jrebel.com/jrebel/standalone/config.html for more information.
--->
-<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_3.xsd">
-
-	<id>mec-biz</id>
-
-	<classpath>
-		<dir name="E:/hgw/DYYM/项目/mec/mec-biz/target/classes">
-		</dir>
-	</classpath>
-
-</application>

+ 5 - 0
mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java

@@ -229,4 +229,9 @@ public interface TaskRemoteService {
      */
 	@GetMapping("task/checkTenantOrder")
     void checkTenantOrder();
+
+
+	/** 兑换码分配数量底告警 */
+	@GetMapping("task/redemptionCodeWarn")
+	void redemptionCodeWarn();
 }

+ 5 - 0
mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java

@@ -282,4 +282,9 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
     public void checkTenantOrder() {
         logger.error("校验机构付款记录支付状态失败");
     }
+
+	@Override
+	public void redemptionCodeWarn() {
+		logger.error("兑换码分配数量底告警");
+	}
 }

+ 23 - 0
mec-task/src/main/java/com/ym/mec/task/jobs/RedemptionCodeWarnTask.java

@@ -0,0 +1,23 @@
+package com.ym.mec.task.jobs;
+
+import com.ym.mec.task.TaskRemoteService;
+import com.ym.mec.task.core.BaseTask;
+import com.ym.mec.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/2/29
+ */
+@Service
+public class RedemptionCodeWarnTask extends BaseTask {
+
+    @Autowired
+    private TaskRemoteService taskRemoteService;
+
+    @Override
+    public void execute() throws TaskException {
+        taskRemoteService.redemptionCodeWarn();
+    }
+}

+ 45 - 0
mec-web/src/main/java/com/ym/mec/web/controller/AppRedemptionCodeController.java

@@ -0,0 +1,45 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.AppRedemptionCode;
+import com.ym.mec.biz.service.AppRedemptionCodeService;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+import com.ym.mec.common.controller.BaseController;
+
+import javax.annotation.Resource;
+
+/**
+ * 兑换码分配表(RedemptionCode)表控制层
+ *
+ * @author makejava
+ * @since 2021-12-27 14:27:56
+ */
+@RestController
+@RequestMapping("/appRedemptionCode")
+public class AppRedemptionCodeController extends BaseController {
+    /**
+     * 服务对象
+     */
+    @Resource
+    private AppRedemptionCodeService appRedemptionCodeService;
+
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @ApiOperation(value = "分配url")
+    @PostMapping(value = "allocation")
+    @PreAuthorize("@pcs.hasPermissions('appRedemptionCode/allocation')")
+    public HttpResponseResult<AppRedemptionCode> allocation(@RequestParam("userId")Integer userId) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        return succeed(appRedemptionCodeService.allocation(userId));
+    }
+}
+

+ 17 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ImportController.java

@@ -4,10 +4,12 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.entity.FinancialExpenditure;
 import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.AppRedemptionCode;
 import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
 import com.ym.mec.biz.dal.enums.TemplateTypeEnum;
 import com.ym.mec.biz.service.FinancialExpenditureService;
 import com.ym.mec.biz.service.GoodsService;
+import com.ym.mec.biz.service.AppRedemptionCodeService;
 import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -41,6 +43,9 @@ public class ImportController extends BaseController {
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
+    @Autowired
+    private AppRedemptionCodeService appRedemptionCodeService;
+
 
     @ApiOperation(value = "导入商品")
     @PostMapping(value = "goods")
@@ -60,6 +65,18 @@ public class ImportController extends BaseController {
         return succeed(financialExpenditureService.importFinancialExpenditure(file));
     }
 
+    @ApiOperation(value = "导入兑换码分配模板")
+    @PostMapping(value = "importRedemptionCode")
+    @PreAuthorize("@pcs.hasPermissions('import/importRedemptionCode')")
+    public HttpResponseResult<List<AppRedemptionCode>> importRedemptionCode(@RequestParam("file") MultipartFile file) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        List<AppRedemptionCode> ret = appRedemptionCodeService.importRedemptionCode(file);
+        return succeed(ret);
+    }
+
     @ApiOperation(value = "导入财务管理订单")
     @PostMapping(value = "routeOrder")
     @PreAuthorize("@pcs.hasPermissions('import/routeOrder')")

+ 15 - 10
mec-web/src/main/java/com/ym/mec/web/controller/SysManualController.java

@@ -3,6 +3,8 @@ package com.ym.mec.web.controller;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.entity.SysManual;
 import com.ym.mec.biz.dal.entity.TenantOrderRecord;
 import com.ym.mec.biz.dal.page.SysManualQueryInfo;
@@ -32,24 +34,24 @@ public class SysManualController extends BaseController {
      */
     @Autowired
     private SysManualService sysManualService;
-
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
 
     @ApiOperation(value = "查询操作手册")
     @RequestMapping("/list")
     public Object list(SysManualQueryInfo queryInfo) {
-
-        QueryWrapper<SysManual> queryWrapper = new WrapperUtil<SysManual>().hasEq("menu_id_", queryInfo.getMenuId()).queryWrapper();
-        Page<SysManual> pageInfo = PageUtil.getPage(queryInfo.getPage(), queryInfo.getRows());
-
-        return PageUtil.pageInfo(sysManualService.page(pageInfo, queryWrapper));
+        return sysManualService.query(queryInfo);
     }
 
     @ApiOperation(value = "新增帮助手册")
     @PostMapping("/add")
     public Object add(@RequestBody SysManual sysManual) throws Exception {
         this.check(sysManual);
-        sysManualService.save(sysManual);
-        return succeed();
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        return succeed(sysManualService.add(sysManual, sysUser.getId()));
     }
 
     @ApiOperation(value = "修改帮助手册")
@@ -59,8 +61,11 @@ public class SysManualController extends BaseController {
         if (sysManual.getId() == null) {
             throw new Exception("更新必须有id");
         }
-        sysManualService.updateById(sysManual);
-        return succeed();
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        return succeed(sysManualService.update(sysManual, sysUser.getId()));
     }
 
     private void check(SysManual sysManual) throws Exception {

+ 2 - 16
mec-web/src/main/java/com/ym/mec/web/controller/TenantAssetsInfoController.java

@@ -1,16 +1,11 @@
 package com.ym.mec.web.controller;
 
-
-import com.ym.mec.biz.dal.entity.CourseSchedule;
-import com.ym.mec.biz.dal.entity.TenantAssetsInfo;
 import com.ym.mec.biz.service.TenantAssetsInfoService;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import org.springframework.web.bind.annotation.*;
 import com.ym.mec.common.controller.BaseController;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
-import java.util.List;
 
 /**
  * 机构资产信息(TenantAssetsInfo)表控制层
@@ -27,14 +22,5 @@ public class TenantAssetsInfoController extends BaseController {
     @Resource
     private TenantAssetsInfoService tenantAssetsInfoService;
 
-    @ApiOperation("修改机构启用停用状态")
-    @GetMapping(value = "/ops/{id}")
-//    @PreAuthorize("@pcs.hasPermissions('tenantInfo/opsState')")
-    public Object opsState() {
-        tenantAssetsInfoService.courseDeductionRules(null);
-        return succeed();
-    }
-
-
 }
 

+ 4 - 0
mec-web/src/main/resources/columnMapper.ini

@@ -48,3 +48,7 @@
 商品数量 = goodsNums
 备注 = memo
 缴费单号 = calenderId
+
+[兑换码分配模板表]
+分配码 = code
+兑换链接 = url