Browse Source

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

zouxuan 3 years ago
parent
commit
658c12d262

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

@@ -36,4 +36,6 @@ public interface OrganizationCourseUnitPriceSettingsDao extends BaseDAO<Integer,
 	 * @return
 	 */
     List<Map<String, Integer>> queryMapByOrganIdAndChargeTypeId(@Param("chargeTypeId") Integer chargeTypeId, @Param("organId") Integer organId);
+
+    List<OrganizationCourseUnitPriceSettings> querySingle(@Param("organId")Integer organId, @Param("courseType") String courseType, @Param("tenantId") Integer tenantId);
 }

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

@@ -23,4 +23,8 @@ public interface OrganizationCourseUnitPriceSettingsService extends BaseService<
 	 * @return
 	 */
 	OrganizationCourseUnitPriceSettings queryByOrganIdAndCourseTypeAndChargeType(Integer organId, CourseScheduleType courseType, Integer chargeTypeId);
+
+	List<OrganizationCourseUnitPriceSettings> querySingle(Integer organId, String courseType, Integer tenantId);
+
+    int save(List<OrganizationCourseUnitPriceSettings> organizationCourseUnitPriceSettingsList);
 }

+ 20 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OrganizationCourseUnitPriceSettingsServiceImpl.java

@@ -11,6 +11,7 @@ import com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings;
 import com.ym.mec.biz.service.OrganizationCourseUnitPriceSettingsService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.transaction.annotation.Transactional;
 
 @Service
 public class OrganizationCourseUnitPriceSettingsServiceImpl extends BaseServiceImpl<Integer, OrganizationCourseUnitPriceSettings>  implements OrganizationCourseUnitPriceSettingsService {
@@ -33,5 +34,23 @@ public class OrganizationCourseUnitPriceSettingsServiceImpl extends BaseServiceI
 	public OrganizationCourseUnitPriceSettings queryByOrganIdAndCourseTypeAndChargeType(Integer organId, CourseScheduleType courseType, Integer chargeTypeId) {
 		return organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(organId, courseType, chargeTypeId);
 	}
-	
+
+	@Override
+	public List<OrganizationCourseUnitPriceSettings> querySingle(Integer organId, String courseType, Integer tenantId) {
+		return organizationCourseUnitPriceSettingsDao.querySingle(organId, courseType, tenantId);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public int save(List<OrganizationCourseUnitPriceSettings> organizationCourseUnitPriceSettingsList) {
+		int successCount = 0;
+		for (OrganizationCourseUnitPriceSettings ocup : organizationCourseUnitPriceSettingsList) {
+			if (ocup.getId() != null) {
+				successCount += organizationCourseUnitPriceSettingsDao.update(ocup);
+			} else {
+				successCount += organizationCourseUnitPriceSettingsDao.insert(ocup);
+			}
+		}
+		return successCount;
+	}
 }

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PlatformServeServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
+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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -10,10 +11,12 @@ import com.ym.mec.biz.dal.dao.PlatformServeDetailDao;
 import com.ym.mec.biz.dal.dto.PlatformServeDto;
 import com.ym.mec.biz.dal.entity.PlatformServe;
 import com.ym.mec.biz.dal.entity.PlatformServeDetail;
+import com.ym.mec.biz.dal.entity.TenantProductInfo;
 import com.ym.mec.biz.dal.vo.PlatformServeInfoVo;
 import com.ym.mec.biz.dal.vo.PlatformServeModeVo;
 import com.ym.mec.biz.dal.vo.PlatformServePageVo;
 import com.ym.mec.biz.service.PlatformServeService;
+import com.ym.mec.biz.service.TenantProductInfoService;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.PageUtil;
@@ -25,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 import java.util.Optional;
 
 /**
@@ -38,6 +42,8 @@ public class PlatformServeServiceImpl extends ServiceImpl<PlatformServeDao, Plat
     private PlatformServeDetailDao platformServeDetailDao;
     @Autowired
     private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private TenantProductInfoService tenantProductInfoService;
 
     /**
      * 增加
@@ -84,6 +90,13 @@ public class PlatformServeServiceImpl extends ServiceImpl<PlatformServeDao, Plat
         Integer userId = Optional.ofNullable(sysUserFeignService.queryUserInfo())
                 .map(SysUser::getId)
                 .orElseThrow(() -> new BizException("用户信息获取失败"));
+
+        TenantProductInfo productInfo = tenantProductInfoService.getOne(new QueryWrapper<TenantProductInfo>()
+                .eq("serve_id_", id));
+        if(Objects.isNull(productInfo)){
+            throw new BizException("该服务已关联机构无法删除!");
+        }
+
         PlatformServe platformServe = new PlatformServe();
         platformServe.setId(id);
         platformServe.setDeleted(1);

+ 11 - 12
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantConfigServiceImpl.java

@@ -1,5 +1,15 @@
 package com.ym.mec.biz.service.impl;
 
+import java.util.Date;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.Consumer;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
@@ -9,17 +19,6 @@ import com.ym.mec.biz.dal.entity.TenantConfig;
 import com.ym.mec.biz.service.TenantConfigService;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.WrapperUtil;
-import com.ym.mec.common.tenant.TenantContextHolder;
-
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.Date;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.function.Consumer;
 
 /**
  * @author hgw
@@ -52,7 +51,7 @@ public class TenantConfigServiceImpl extends ServiceImpl<TenantConfigDao, Tenant
 
     @Override
 	public TenantConfig queryByTenantId(Integer tenantId) {
-		return getOne(new WrapperUtil<TenantConfig>().hasEq("tenant_id_", TenantContextHolder.getTenantId())
+		return getOne(new WrapperUtil<TenantConfig>().hasEq("tenant_id_", tenantId)
 				.queryWrapper());
 	}
 

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

@@ -124,4 +124,11 @@
 		WHERE organ_id_ = #{organId} AND charge_type_id_ = #{chargeTypeId}
 		GROUP BY course_type_
 	</select>
+	<select id="querySingle" resultType="com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings">
+		select * from organization_course_unit_price_settings
+		where organ_id_ = #{organId} and course_type_ = #{courseType}
+		<if test="tenantId != -1">
+			and tenant_id_ = #{tenantId}
+		</if>
+	</select>
 </mapper>

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

@@ -97,7 +97,7 @@
 
     <select id="queryTenantInfoProductSumm" resultType="com.ym.mec.biz.dal.entity.TenantProductSumm">
             SELECT t.*, ps.name_ as serverName,
-                   tp.pay_date_ as expiryDate,
+                   t.created_time_ as expiryDate, <!-- 不使用这个字段,需求没有开始时间, 使用创建时间临时代替 -->
                    tp.expiry_date_ as expiryDateEnd,
                    tp.expiry_count_  as expiryCount,
                    tp.expiry_unit_ as expiryUnit,

+ 26 - 0
mec-web/src/main/java/com/ym/mec/web/controller/OrganizationCourseUnitPriceSettingsController.java

@@ -1,5 +1,6 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.common.tenant.TenantContextHolder;
 import com.yonge.log.model.AuditLogAnnotation;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -38,10 +39,22 @@ public class OrganizationCourseUnitPriceSettingsController extends BaseControlle
 		return succeed(organizationCourseUnitPriceSettingsService.queryPage(queryInfo));
 	}
 
+	@ApiOperation(value = "查询单个")
+	@GetMapping(value = "/querySingle/{organId}/{courseType}")
+	// @PreAuthorize("@pcs.hasPermissions('organizationCourseUnitPriceSettings/querySingle')")
+	public Object querySingle(@PathVariable("organId")Integer organId,
+							  @PathVariable("courseType")String courseType) {
+		Integer tenantId = TenantContextHolder.getTenantId();
+		return succeed(organizationCourseUnitPriceSettingsService.querySingle(organId, courseType, tenantId));
+	}
+
 	@ApiOperation(value = "新增对象")
 	@PostMapping(value = "/insert", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
 	@PreAuthorize("@pcs.hasPermissions('organizationCourseUnitPriceSettings/insert')")
 	public Object insert(@RequestBody List<OrganizationCourseUnitPriceSettings> organizationCourseUnitPriceSettingsList) {
+		if (organizationCourseUnitPriceSettingsList.size() == 0) {
+			return failed("OrganizationCourseUnitPriceSettings 参数不能为空");
+		}
 		for (OrganizationCourseUnitPriceSettings organizationCourseUnitPriceSettings : organizationCourseUnitPriceSettingsList) {
 			OrganizationCourseUnitPriceSettings originalObj = organizationCourseUnitPriceSettingsService.queryByOrganIdAndCourseTypeAndChargeType(
 					organizationCourseUnitPriceSettings.getOrganId(), organizationCourseUnitPriceSettings.getCourseType(),
@@ -64,6 +77,19 @@ public class OrganizationCourseUnitPriceSettingsController extends BaseControlle
 		return succeed();
 	}
 
+	@ApiOperation(value = "根据是否已有插入或更新")
+	@PostMapping(value = "/save", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+	@PreAuthorize("@pcs.hasPermissions('organizationCourseUnitPriceSettings/save')")
+	@AuditLogAnnotation(operateName = "修改分部课程单价")
+	public Object save(@RequestBody List<OrganizationCourseUnitPriceSettings> organizationCourseUnitPriceSettingsList) {
+		for (OrganizationCourseUnitPriceSettings ocup : organizationCourseUnitPriceSettingsList) {
+			if (ocup.getId() == null) {
+				ocup.setUpdateTime(new Date());
+			}
+		}
+		return succeed(organizationCourseUnitPriceSettingsService.save(organizationCourseUnitPriceSettingsList));
+	}
+
 	@ApiOperation(value = "删除收费类型")
 	@PostMapping("/del/{id}")
 	@PreAuthorize("@pcs.hasPermissions('organizationCourseUnitPriceSettings/del')")