ソースを参照

分部关联分部经理、乐团主管、维修技师

zouxuan 3 年 前
コミット
56deabb982

+ 2 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/dal/dao/SysUserDeviceDao.java

@@ -12,4 +12,6 @@ public interface SysUserDeviceDao extends BaseDAO<Integer, SysUserDevice> {
 	List<SysUserDevice> queryByUserId(@Param("clientId") String clientId, @Param("userId") Integer userId);
 
 	List<SysUserDevice> queryByDeviceNum(@Param("clientId") String clientId, @Param("deviceNum") String deviceNum);
+
+	String getDeviceConfig(@Param("paramName") String paramName, @Param("tenantId") Integer tenantId);
 }

+ 22 - 44
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/impl/SysUserDeviceServiceImpl.java

@@ -5,7 +5,7 @@ import com.ym.mec.auth.dal.dao.SysUserDeviceDao;
 import com.ym.mec.auth.service.SysUserDeviceService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
-import com.ym.mec.web.WebFeignService;
+import com.ym.mec.common.tenant.TenantContextHolder;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.authentication.BadCredentialsException;
@@ -21,8 +21,6 @@ public class SysUserDeviceServiceImpl extends BaseServiceImpl<Integer, SysUserDe
 	
 	@Autowired
 	private SysUserDeviceDao sysUserDeviceDao;
-	@Autowired
-	private WebFeignService webFeignService;
 
 	@Override
 	public BaseDAO<Integer, SysUserDevice> getDAO() {
@@ -41,52 +39,32 @@ public class SysUserDeviceServiceImpl extends BaseServiceImpl<Integer, SysUserDe
 
 	@Override
 	public boolean bindDevice(String clientId, Integer userId, String deviceNum) {
+		Integer tenantId = TenantContextHolder.getTenantId();
+		String paramName = null;
 		if (StringUtils.equals(clientId, "STUDENT")) {
-			// 检查学生是否绑定了多个设备号
-			List<SysUserDevice> studentDeviceList = queryByUserId(clientId, userId);
-
-			if (studentDeviceList == null) {
-				studentDeviceList = new ArrayList<SysUserDevice>();
-			}
-
-			List<String> deviceList = studentDeviceList.stream().map(t -> t.getDeviceNum()).collect(Collectors.toList());
-
-			if (!deviceList.contains(deviceNum)) {
-				if (deviceList.size() >= 5) {
-					throw new BadCredentialsException("当前账号绑定设备过多,请联系主教老师");
-				}
-				SysUserDevice sysUserDevice = new SysUserDevice();
-				sysUserDevice.setUserId(userId);
-				sysUserDevice.setDeviceNum(deviceNum);
-				sysUserDevice.setBindTime(new Date());
-				sysUserDevice.setClientId(clientId);
-				sysUserDeviceDao.insert(sysUserDevice);
-			}
-		} else {
-			if(StringUtils.equals(clientId, "TEACHER")){
-
-			}
-			if(StringUtils.equals(clientId, "SYSTEM")){
-
-			}
-			// 查询设备号是否已存在
-			List<SysUserDevice> sysUserDeviceList = sysUserDeviceDao.queryByDeviceNum(null, deviceNum);
-
-			if (sysUserDeviceList == null) {
-				sysUserDeviceList = new ArrayList<SysUserDevice>();
-			}
-
-			sysUserDeviceList = sysUserDeviceList.stream().filter(sud -> !StringUtils.equals(sud.getClientId(), "STUDENT")).collect(Collectors.toList());
+			paramName = "student_device_login_num";
+		}else if(StringUtils.equals(clientId, "TEACHER")){
+			paramName = "teacher_device_login_num";
+		}else {
+			paramName = "edu_device_login_num";
+		}
+		String configValue = sysUserDeviceDao.getDeviceConfig(paramName,tenantId);
+		if(StringUtils.isEmpty(configValue)){
+			return true;
+		}
+		// 检查学生是否绑定了多个设备号
+		List<SysUserDevice> studentDeviceList = queryByUserId(clientId, userId);
 
-			if (sysUserDeviceList != null && sysUserDeviceList.size() > 0) {
-				if (sysUserDeviceList.stream().filter(sud -> sud.getUserId().equals(userId)).count() > 0) {
+		if (studentDeviceList == null) {
+			studentDeviceList = new ArrayList<SysUserDevice>();
+		}
 
-					return true;
-				}
+		List<String> deviceList = studentDeviceList.stream().map(t -> t.getDeviceNum()).collect(Collectors.toList());
 
-				throw new BadCredentialsException("当前设备已绑定账号,请更换设备");
+		if (!deviceList.contains(deviceNum)) {
+			if (deviceList.size() >= Integer.parseInt(configValue)) {
+				throw new BadCredentialsException("当前账号绑定设备过多,请联系主教老师");
 			}
-
 			SysUserDevice sysUserDevice = new SysUserDevice();
 			sysUserDevice.setUserId(userId);
 			sysUserDevice.setDeviceNum(deviceNum);

+ 6 - 1
mec-auth/mec-auth-server/src/main/resources/config/mybatis/SysUserDeviceMapper.xml

@@ -124,5 +124,10 @@
 			and client_id_ = #{clientId}
 		</if>
 	</select>
-	
+	<select id="getDeviceConfig" resultType="java.lang.String">
+		SELECT CASE WHEN stc.id_ IS NULL THEN sc.paran_value_ ELSE stc.param_value_ END paran_value_ FROM sys_config sc
+		LEFT JOIN sys_tenant_config stc ON sc.id_ = stc.sys_config_id_ AND sc.group_ = #{tenantId}
+		WHERE sc.group_ IS NOT NULL AND sc.group_ != '' AND sc.param_name_ = #{paramName}
+	</select>
+
 </mapper>

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OrganizationDao.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.dal.dao;
 import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
+import sun.jvm.hotspot.opto.HaltNode;
 
 import java.util.List;
 import java.util.Map;
@@ -59,4 +60,5 @@ public interface OrganizationDao extends BaseDAO<Integer, Organization> {
 	List<Organization> findAllOrgans();
 
 	List<Organization> getActivityOrgans();
+
 }

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

@@ -58,6 +58,72 @@ public class Organization {
 	@ApiModelProperty(value = "子节点列表",required = false)
 	private List<Organization> organizations;
 
+	@ApiModelProperty(value = "分部经理",required = false)
+	private String organManager;
+
+	@ApiModelProperty(value = "乐团主管",required = false)
+	private String educationId;
+
+	@ApiModelProperty(value = "维修技师",required = false)
+	private String repairId;
+
+	@ApiModelProperty(value = "分部经理",required = false)
+	private String organManagerName;
+
+	@ApiModelProperty(value = "乐团主管",required = false)
+	private String educationName;
+
+	@ApiModelProperty(value = "维修技师",required = false)
+	private String repairName;
+
+	public String getOrganManagerName() {
+		return organManagerName;
+	}
+
+	public void setOrganManagerName(String organManagerName) {
+		this.organManagerName = organManagerName;
+	}
+
+	public String getEducationName() {
+		return educationName;
+	}
+
+	public void setEducationName(String educationName) {
+		this.educationName = educationName;
+	}
+
+	public String getRepairName() {
+		return repairName;
+	}
+
+	public void setRepairName(String repairName) {
+		this.repairName = repairName;
+	}
+
+	public String getOrganManager() {
+		return organManager;
+	}
+
+	public void setOrganManager(String organManager) {
+		this.organManager = organManager;
+	}
+
+	public String getEducationId() {
+		return educationId;
+	}
+
+	public void setEducationId(String educationId) {
+		this.educationId = educationId;
+	}
+
+	public String getRepairId() {
+		return repairId;
+	}
+
+	public void setRepairId(String repairId) {
+		this.repairId = repairId;
+	}
+
 	public String getAreaName() {
 		return areaName;
 	}

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/OrganizationService.java

@@ -41,4 +41,8 @@ public interface OrganizationService extends BaseService<Integer, Organization>
      * @param id
      */
     Map<Integer, String> getGradeList(Integer id);
+
+    int updateOrgan(Organization organization);
+
+    Long add(Organization organization);
 }

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

@@ -164,6 +164,14 @@ public interface SysConfigService extends BaseService<Long, SysConfig> {
     //对外课程课后缓冲时间{}分钟
     String COURSE_AFTER_BUFFER_TIME = "course_after_buffer_time";
 
+    //乐保
+    //是否开启乐保
+    String MUSICAL_REPAIR_OPEN_FLAG = "musical_repair_open_flag";
+    //一年期乐保零售价
+    String ONE_YEAR_MUSICAL_REPAIR_AMOUNT = "one_year_musical_repair_amount";
+    //一年期乐保原价
+    String ONE_YEAR_MUSICAL_REPAIR_ORIGINAL_AMOUNT = "one_year_musical_repair_original_amount";
+
     public static final String BASE_API_URL = "base_api_url";
 
     /**

+ 13 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -33,6 +33,7 @@ import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.service.*;
+import com.ym.mec.common.tenant.TenantContextHolder;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -676,6 +677,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if(musicGroupRegCalender == null){
         	throw new BizException("缴费信息不存在");
         }
+        Integer tenantId = TenantContextHolder.getTenantId();
 
         Integer userId = studentRegistration.getUserId();
 
@@ -756,8 +758,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
         //乐器保养
         if (registerPayDto.getBuyMaintenance()) {
-            BigDecimal maintenancePrice = new BigDecimal(sysConfigDao.findConfigValue("maintenance_price"));
-            orderAmount = orderAmount.add(maintenancePrice);
+            String configValue = sysTenantConfigService.getTenantConfigValue(SysConfigService.ONE_YEAR_MUSICAL_REPAIR_AMOUNT, tenantId);
+            if(StringUtils.isEmpty(configValue)){
+                throw new BizException("乐保价格异常,请联系指导老师");
+            }
+            orderAmount = orderAmount.add(new BigDecimal(configValue));
         }
         
         studentRegistration.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
@@ -925,6 +930,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (studentRegistration == null) {
             throw new BizException("报名信息有误,请核查");
         }
+        Integer tenantId = TenantContextHolder.getTenantId();
 
         Integer userId = studentRegistration.getUserId();
 
@@ -1036,8 +1042,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
 
         if (registerPayDto.getBuyMaintenance()) {
-            BigDecimal maintenancePrice = new BigDecimal(sysConfigDao.findConfigValue("maintenance_price"));
-            orderAmount = orderAmount.add(maintenancePrice);
+            String configValue = sysTenantConfigService.getTenantConfigValue(SysConfigService.ONE_YEAR_MUSICAL_REPAIR_AMOUNT, tenantId);
+            if(StringUtils.isEmpty(configValue)){
+                throw new BizException("乐保价格异常,请联系指导老师");
+            }
+            orderAmount = orderAmount.add(new BigDecimal(configValue));
         }
 
         studentRegistration.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());

+ 34 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OrganizationServiceImpl.java

@@ -1,13 +1,16 @@
 package com.ym.mec.biz.service.impl;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.enums.FivePlusGradeEnum;
 import com.ym.mec.biz.dal.enums.GradeTypeEnum;
 import com.ym.mec.biz.dal.enums.SixPlusGradeEnum;
 import com.ym.mec.common.exception.BizException;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -25,6 +28,8 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati
 	@Autowired
 	private OrganizationDao organizationDao;
 	@Autowired
+	private TeacherDao teacherDao;
+	@Autowired
 	private SysUserFeignService sysUserFeignService;
 
 	@Override
@@ -105,4 +110,33 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati
 		}
 		return gradeMap;
 	}
+
+	@Override
+	public int updateOrgan(Organization organization) {
+		return organizationDao.update(initOrganization(organization));
+	}
+
+	@Override
+	public Long add(Organization organization) {
+		return organizationDao.insert(initOrganization(organization));
+	}
+
+	private Organization initOrganization(Organization organization){
+		if(StringUtils.isNotEmpty(organization.getOrganManager())){
+			organization.setOrganManagerName(teacherDao.queryTeacherNameByTeacherIds(organization.getOrganManager()));
+		}else {
+			organization.setOrganManagerName("");
+		}
+		if(StringUtils.isNotEmpty(organization.getEducationId())){
+			organization.setEducationName(teacherDao.queryTeacherNameByTeacherIds(organization.getEducationId()));
+		}else {
+			organization.setEducationName("");
+		}
+		if(StringUtils.isNotEmpty(organization.getRepairId())){
+			organization.setRepairName(teacherDao.queryTeacherNameByTeacherIds(organization.getRepairId()));
+		}else {
+			organization.setRepairName("");
+		}
+		return organization;
+	}
 }

+ 10 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java

@@ -9,6 +9,8 @@ import java.util.Map;
 import java.util.stream.Collectors;
 
 import com.ym.mec.biz.service.*;
+import com.ym.mec.common.tenant.TenantContextHolder;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -56,6 +58,8 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
     @Autowired
     private SysConfigDao sysConfigDao;
     @Autowired
+    private SysTenantConfigService sysTenantConfigService;
+    @Autowired
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
@@ -91,7 +95,12 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
             throw new BizException("所选乐器不存在,请核查");
         }
         Integer userId = studentInstrument.getStudentId();
-        BigDecimal orderAmount = new BigDecimal(sysConfigDao.findConfigValue("maintenance_price"));
+        Integer tenantId = TenantContextHolder.getTenantId();
+        String maintenancePrice = sysTenantConfigService.getTenantConfigValue(SysConfigService.ONE_YEAR_MUSICAL_REPAIR_AMOUNT, tenantId);
+        if(StringUtils.isEmpty(maintenancePrice)){
+            throw new BizException("乐保价格异常,请联系指导老师");
+        }
+        BigDecimal orderAmount = new BigDecimal(maintenancePrice);
         StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(maintenancePayDto.getCouponIdList(),orderAmount,true);
         BigDecimal amount = studentPaymentOrder.getActualAmount();
         if (amount.compareTo(maintenancePayDto.getAmount()) != 0) {

+ 7 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -25,6 +25,7 @@ import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.constant.CommonConstants;
+import com.ym.mec.common.tenant.TenantContextHolder;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -600,6 +601,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         studentPaymentOrderDetail.setUpdateTime(date);
         studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
         studentPaymentOrderDetailList.add(studentPaymentOrderDetail);*/
+        Integer tenantId = TenantContextHolder.getTenantId();
         //乐器及打包辅件
         String maintenanceGoodsId = "";
         if (goodsGroups != null && goodsGroups.size() > 0) {
@@ -667,7 +669,11 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             if ("".equals(maintenanceGoodsId)) {
                 throw new BizException("有乐器才能购买乐保,请核查");
             }
-            BigDecimal maintenancePrice = new BigDecimal(sysConfigDao.findConfigValue("maintenance_price"));
+            String configValue = sysTenantConfigService.getTenantConfigValue(SysConfigService.ONE_YEAR_MUSICAL_REPAIR_AMOUNT, tenantId);
+            if(StringUtils.isEmpty(configValue)){
+                throw new BizException("乐保价格异常,请联系指导老师");
+            }
+            BigDecimal maintenancePrice = new BigDecimal(configValue);
             StudentPaymentOrderDetail maintenanceOrderDetail = new StudentPaymentOrderDetail();
             maintenanceOrderDetail.setType(OrderDetailTypeEnum.MAINTENANCE);
             maintenanceOrderDetail.setPrice(maintenancePrice);

+ 19 - 3
mec-biz/src/main/resources/config/mybatis/OrganizationMapper.xml

@@ -18,6 +18,12 @@
         <result column="linkman_" property="linkman"/>
         <result column="mobile_" property="mobile"/>
         <result column="address_" property="address"/>
+        <result column="organ_manager_" property="organManager"/>
+        <result column="education_id_" property="educationId"/>
+        <result column="repair_id_" property="repairId"/>
+        <result column="organ_manager_name_" property="organManagerName"/>
+        <result column="education_name_" property="educationName"/>
+        <result column="repair_name_" property="repairName"/>
         <result column="grade_type_" property="gradeType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
     </resultMap>
 
@@ -34,8 +40,12 @@
     <!-- 向数据库增加一条记录 -->
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Organization" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
-        INSERT INTO organization (id_,name_,area_id_,create_time_,update_time_,register_date_,linkman_,mobile_,address_,grade_type_)
-        VALUES(#{id},#{name},#{areaId},now(),now(),#{registerDate},#{linkman},#{mobile},#{address},#{gradeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
+        INSERT INTO organization (id_,name_,area_id_,create_time_,update_time_,
+                                  register_date_,linkman_,mobile_,address_,grade_type_,organ_manager_,education_id_,repair_id_,
+                                  organ_manager_name_,education_name_,repair_name_)
+        VALUES(#{id},#{name},#{areaId},now(),now(),#{registerDate},#{linkman},#{mobile},#{address},
+               #{gradeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+               ,#{organManager},#{educationId},#{repairId},#{organManagerName},#{educationName},#{repairName})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -45,6 +55,12 @@
             <if test="delFlag != null">
                 del_flag_ = #{delFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
+                organ_manager_ = #{organManager},
+                education_id_ = #{educationId},
+                repair_id_ = #{repairId},
+                organ_manager_name_ = #{organManagerName},
+                education_name_ = #{educationName},
+                repair_name_ = #{repairName},
             <if test="areaId != null">
                 area_id_ = #{areaId},
             </if>
@@ -91,7 +107,7 @@
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="Organization" parameterType="map">
-        SELECT o.*,sa.name_ area_name_ FROM organization o
+        SELECT o.*,sa.name_ area_name_  FROM organization o
         LEFT JOIN sys_area sa ON o.area_id_ = sa.id_
         <include refid="queryPageSql"/>
          ORDER BY id_

+ 2 - 4
mec-web/src/main/java/com/ym/mec/web/controller/OrganizationController.java

@@ -8,11 +8,9 @@ import com.ym.mec.biz.service.OrganizationService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
-
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
-
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -64,7 +62,7 @@ public class OrganizationController extends BaseController {
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('organization/add')")
     public Object add(Organization organization){
-        return succeed(organizationService.insert(organization));
+        return succeed(organizationService.add(organization));
     }
 
     @ApiOperation(value = "根据分部编号删除分部")
@@ -79,7 +77,7 @@ public class OrganizationController extends BaseController {
     @PreAuthorize("@pcs.hasPermissions('organization/update')")
     public Object update(Organization organization){
         organization.setUpdateTime(new Date());
-        return succeed(organizationService.update(organization));
+        return succeed(organizationService.updateOrgan(organization));
     }
 
     @ApiOperation(value = "根据分部编号查询分部详情")