Browse Source

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

yanite 3 năm trước cách đây
mục cha
commit
56ad05d662

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

@@ -50,7 +50,7 @@ public class TenantInterceptor extends HandlerInterceptorAdapter {
 				if(tenantInfo != null){
 					request.setAttribute(DATA_SOURCE_ID, tenantInfo.getDataSource());
 				}else {
-					throw new BizException("机构信息异常,请联系管理员");
+					throw new BizException("机构服务已停用,请联系机构管理员");
 				}
 			}
 		}

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

@@ -27,7 +27,7 @@ public interface TenantInfoService extends IService<TenantInfo> {
 
     TenantInfoDto queryTenantInfoCheck(Integer tenantId);
 
-    void opsTenantState(Integer id, Integer state);
+    Map<String,Object> opsTenantState(Integer id, Integer state);
 
     PageInfo<TenantInfoInfoPageVo> queryPage(Map<String, Object> param);
 

+ 9 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudCoachPaymentProgramServiceImpl.java

@@ -8,6 +8,7 @@ import com.ym.mec.biz.dal.entity.TenantInfo;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.service.CloudCoachPaymentProgramService;
 import com.ym.mec.biz.service.MemberFeeSettingService;
+import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.SysMessageService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
@@ -15,6 +16,7 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
+import com.ym.mec.util.http.HttpUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -93,15 +95,17 @@ public class CloudCoachPaymentProgramServiceImpl extends BaseServiceImpl<Long, C
 		}else {
 			//推送缴费消息
 			TenantInfo tenantInfo = tenantInfoDao.selectById(cloudCoachPaymentProgram.getTenantId());
-			Map<Integer, String> phoneMaps = MapUtil.convertMybatisMap(teacherDao.queryPhoneByIds(StringUtils.join(userIds)));
-			String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
-			String pushUrl = baseApiUrl + "/#/auditionActive/1?groupId=";
+			Map<Integer, String> phoneMaps = MapUtil.convertMybatisMap(teacherDao.queryPhoneByIds(StringUtils.join(userIds,",")));
+			String baseApiUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
+			StringBuffer pushUrl = new StringBuffer(baseApiUrl).append("/#/studentMember?id=").append(cloudCoachPaymentProgram.getId());
 			sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.STUDENT_SMS_CLOUD_PAYMENT,phoneMaps,
-					null,0,"",null,tenantInfo.getName());
+					null,0,"",null,tenantInfo.getName(), HttpUtil.getSortUrl(pushUrl.toString()));
+
+			StringBuffer notifyUrl = new StringBuffer("8?").append(baseApiUrl).append("/#/studentMember?id=").append(cloudCoachPaymentProgram.getId());
 			Map<Integer, String> userIdMaps = new HashMap<>(userIds.size());
 			userIds.forEach(e->userIdMaps.put(e,e.toString()));
 			sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_CLOUD_PAYMENT,userIdMaps,
-					null,0,"","STUDENT",tenantInfo.getName());
+					null,0,notifyUrl.toString(),"STUDENT",tenantInfo.getName());
 		}
 	}
 }

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

@@ -113,12 +113,12 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
 		Long paymentId = memberPayParamDto.getPaymentId();
 		CloudCoachPaymentProgram cloudCoachPaymentProgram = cloudCoachPaymentProgramService.get(paymentId);
 		if(cloudCoachPaymentProgram == null){
-			throw new BizException("云教练订单不存在,请联系指导老师");
+			throw new BizException("云教练缴费订单不存在,请联系指导老师");
 		}
 		SysUser sysUser = sysUserFeignService.queryUserInfo();
 		StudentCloudCoachPaymentDetails cloudCoachPaymentDetails = studentCloudCoachPaymentDetailsService.findByUserId(paymentId,sysUser.getId());
 		if(cloudCoachPaymentDetails == null){
-			throw new BizException("云教练订单不存在该学员,请联系指导老师");
+			throw new BizException("您不在当前云教练缴费项目中,请联系指导老师");
 		}
 		if(cloudCoachPaymentDetails.getPaymentStatus() == 1){
 			throw new BizException("当前云教练订单已支付,感谢您的支持");
@@ -242,8 +242,8 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
 
 		// 支付成功
 		if (studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS) {
-			StudentCloudCoachPaymentDetails coachPaymentDetails = studentCloudCoachPaymentDetailsService.get(Long.parseLong(studentPaymentOrder.getMusicGroupId()));
-			CloudCoachPaymentProgram cloudCoachPaymentProgram = cloudCoachPaymentProgramService.get(coachPaymentDetails.getCloudCoachPaymentProgramId());
+			CloudCoachPaymentProgram cloudCoachPaymentProgram = cloudCoachPaymentProgramService.get(Long.parseLong(studentPaymentOrder.getMusicGroupId()));
+			StudentCloudCoachPaymentDetails coachPaymentDetails = studentCloudCoachPaymentDetailsService.findByUserId(cloudCoachPaymentProgram.getId(),studentPaymentOrder.getUserId());
 			//保存云教练数据
 			CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
 			cloudTeacherOrder.setOrderId(studentPaymentOrder.getId());

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

@@ -650,7 +650,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 maintenanceOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
                 maintenanceOrderDetail.setIsRenew(0);
                 //保存的是活动编号
-                maintenanceOrderDetail.setStudentInstrumentId(calenderActivity.getId());
+                maintenanceOrderDetail.setStudentInstrumentId(calenderActivity.getActivityId().longValue());
                 studentPaymentOrderDetailList.add(maintenanceOrderDetail);
             }
         }

+ 8 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMessageServiceImpl.java

@@ -12,6 +12,9 @@ import java.util.Map.Entry;
 import java.util.Objects;
 import java.util.Random;
 import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -389,10 +392,13 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 	}
 
 	@Override
-	@Async
 	public void batchSendMessage(MessageSender messageSender, MessageTypeEnum type, Map<Integer, String> receivers, Date triggerTime, Integer readStatus,
 			String url,String jpushType, Object... args) {
-		batchSendMessage(TenantContextHolder.getTenantId(), messageSender, type, receivers, triggerTime, readStatus, url, jpushType, args);
+		ExecutorService executor = Executors.newFixedThreadPool(5);
+		CompletableFuture.runAsync(()->{
+			batchSendMessage(TenantContextHolder.getTenantId(), messageSender, type, receivers, triggerTime, readStatus, url, jpushType, args);
+		},executor);
+		executor.shutdown();
 	}
 
 

+ 35 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantAssetsInfoServiceImpl.java

@@ -11,8 +11,10 @@ import com.ym.mec.biz.dal.vo.TenantCloudCourseRecordVo;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.WrapperUtil;
+import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.thirdparty.yqpay.DateUtils;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,7 +28,8 @@ import java.util.*;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
-import static com.ym.mec.biz.service.impl.TenantInfoSendMsgServiceImpl.INSUFFICIENT;
+import static com.ym.mec.biz.dal.enums.MessageTypeEnum.EMAIL_TENANT_INSUFFICIENT_BALANCE;
+import static com.ym.mec.biz.dal.enums.MessageTypeEnum.SMS_TENANT_INSUFFICIENT_BALANCE;
 
 /**
  * 机构资产信息(TenantAssetsInfo)表服务实现类
@@ -47,6 +50,8 @@ public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao
     private TenantInfoSendMsgService tenantInfoSendMsgService;
     @Autowired
     private TenantInfoService tenantInfoService;
+    @Autowired
+    private SysMessageService sysMessageService;
 
     private final Predicate<String> VipPredicate = (o) -> Objects.equals(o, CourseSchedule.CourseScheduleType.VIP.getCode());
 
@@ -152,10 +157,37 @@ public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao
                 BigDecimal balance = assetsInfo.getBalance();
                 //当前余额 减 本次扣费 的剩余额度
                 BigDecimal after = balance.subtract(coursePrice);
+                //300
+                BigDecimal threeHundred = new BigDecimal(300);
                 //当前余额大于300 并且 本次扣除后剩余额度小于300 就发信息提醒
-                if (balance.compareTo(new BigDecimal(300)) > -1 && balance.compareTo(after) < 0) {
+                if (balance.compareTo(threeHundred) >= 0 && after.compareTo(threeHundred) <0) {
                     TenantInfo t = tenantInfoService.getById(course.getTenantId());
-                    tenantInfoSendMsgService.platformSendToAll(INSUFFICIENT,t.getUserId(), t.getEmail(), t.getPhone(), new Object[]{t.getName()});
+                    //邮件
+                    if (StringUtils.isNotBlank(t.getEmail())) {
+                        //机构名称 300 余额
+                        Object[] emailMsg = {t.getName(), 300, after.toString()};
+                        Map<Integer, String> sendPar = new HashMap<>();
+                        sendPar.put(t.getUserId(), t.getEmail());
+                        log.info("platformSendToAll>>> 余额不足 receiveUserId {} email {} objs {} sendPar {}", t.getUserId(), t.getEmail(), emailMsg, sendPar);
+                        sysMessageService.batchSendMessage(-1, MessageSenderPluginContext.MessageSender.EMAIL,
+                                EMAIL_TENANT_INSUFFICIENT_BALANCE,
+                                sendPar, null, 0, null,
+                                "SYSTEM", emailMsg);
+                    }
+
+                    //短信
+                    if (StringUtils.isNotBlank(t.getPhone())) {
+                        //机构名称
+                        Object[] phoneMsg = {t.getName()};
+                        Map<Integer, String> sendPar2 = new HashMap<>();
+                        sendPar2.put(t.getUserId(), t.getPhone());
+                        log.info("platformSendToAll>>> 余额不足 receiveUserId {} phone {} objs {} sendPar {}", t.getUserId(), t.getPhone(), phoneMsg, sendPar2);
+                        sysMessageService.batchSendMessage(-1, MessageSenderPluginContext.MessageSender.AWSMS,
+                                SMS_TENANT_INSUFFICIENT_BALANCE,
+                                sendPar2, null, 0, null,
+                                "SYSTEM", phoneMsg);
+                    }
+
                 }
             }
         });

+ 69 - 24
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantInfoServiceImpl.java

@@ -49,7 +49,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
 
-import static com.ym.mec.biz.service.impl.TenantInfoSendMsgServiceImpl.*;
+import static com.ym.mec.biz.dal.enums.MessageTypeEnum.*;
 
 @Service
 public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo> implements TenantInfoService {
@@ -92,15 +92,10 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
     @Autowired
     private SysMessageService sysMessageService;
     @Autowired
-    private TenantInfoSendMsgService tenantInfoSendMsgService;
-    @Autowired
     private SysConfigService sysConfigService;
     @Autowired
     private ContractService contractService;
 
-    @Value("${spring.profiles.active:dev}")
-    private String profiles;
-
     /**
      * 新增机构
      */
@@ -271,7 +266,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
      */
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public void opsTenantState(Integer id, Integer state) {
+    public Map<String, Object> opsTenantState(Integer id, Integer state) {
         if (Objects.nonNull(state) && state == 1 || state == 2) {
             TenantInfo tenantInfo = baseMapper.selectById(id);
             if (Objects.isNull(tenantInfo)) {
@@ -294,12 +289,10 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
                 }
             }
             baseMapper.updateById(tenantInfo);
-            //在执行了修改机构信息之后,并且有返回密码(第一次开通机构会生成登录密码并返回)就发送邮件及短信提醒
-            if (StringUtils.isNotBlank(pw)) {
-                Object[] msg = {tenantInfo.getName(), tenantInfo.getPhone(), pw, "https://online.dayaedu.com"};
-                tenantInfoSendMsgService.platformSendToAll(OPEN, tenantInfo.getUserId(), tenantInfo.getEmail(), tenantInfo.getPhone(), msg);
-            }
-            return;
+            Map<String, Object> result = new HashMap<>();
+            result.put("pw", pw);
+            result.put("tenantInfo", tenantInfo);
+            return result;
         }
         throw new BizException("传入机构状态参数异常!");
     }
@@ -583,10 +576,37 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
         productInfo.setExpiryCount(productInfo.getExpiryCount() + val);
         tenantProductInfoService.updateById(productInfo);
 
-        TenantInfo tenantInfo = this.getById(tenantId);
-        //发送邮件及短信提醒
-        Object[] msg = {tenantInfo.getName()};
-        tenantInfoSendMsgService.platformSendToAll(RENEW, tenantInfo.getUserId(), tenantInfo.getEmail(), tenantInfo.getPhone(), msg);
+        Map<String, Object> par = new HashMap<>();
+        par.put("tenantId", tenantId);
+        List<TenantInfoInfoPageVo> tenantInfos = baseMapper.queryPage(par);
+        if(CollectionUtils.isNotEmpty(tenantInfos)){
+            TenantInfoInfoPageVo tenantInfo = tenantInfos.get(0);
+            //邮件
+            if (StringUtils.isNotBlank(tenantInfo.getEmail())) {
+                //机构名称 服务名称 学员上限 有效期
+                Object[] emailMsg = {tenantInfo.getName(), tenantInfo.getServeName(), tenantInfo.getStudentUpLimit(), DateUtils.formatDate(expiryDate, "yyyy年MM月dd日")};
+                Map<Integer, String> sendPar = new HashMap<>();
+                sendPar.put(tenantInfo.getUserId(), tenantInfo.getEmail());
+                log.info("platformSendToAll>>> 续费 receiveUserId {} email {} objs {} sendPar {}", tenantInfo.getUserId(), tenantInfo.getEmail(), emailMsg, sendPar);
+                sysMessageService.batchSendMessage(-1, MessageSenderPluginContext.MessageSender.EMAIL,
+                        EMAIL_TENANT_RENEWAL_SUCCESSFUL,
+                        sendPar, null, 0, null,
+                        "SYSTEM", emailMsg);
+            }
+            //短信
+            if (StringUtils.isNotBlank(tenantInfo.getPhone())) {
+                //机构名称
+                Object[] phoneMsg = {tenantInfo.getName()};
+                Map<Integer, String> sendPar2 = new HashMap<>();
+                sendPar2.put(tenantInfo.getUserId(), tenantInfo.getPhone());
+                log.info("platformSendToAll>>> 续费 receiveUserId {} phone {} objs {} sendPar {}", tenantInfo.getUserId(), tenantInfo.getPhone(), phoneMsg, sendPar2);
+                sysMessageService.batchSendMessage(-1, MessageSenderPluginContext.MessageSender.AWSMS,
+                        SMS_TENANT_RENEWAL_SUCCESSFUL,
+                        sendPar2, null, 0, null,
+                        "SYSTEM", phoneMsg);
+            }
+        }
+
         //释放锁
         bucket.delete();
     }
@@ -810,7 +830,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
                 if (tenantInfo != null) {
                     request.setAttribute("datasourceId", tenantInfo.getDataSource());
                 } else {
-                    throw new BizException("机构信息异常,请联系管理员");
+                    throw new BizException("机构服务已停用,请联系机构管理员");
                 }
             }
         }
@@ -827,16 +847,16 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
      */
     @Override
     public void checkTenantState() {
-        Date now = LocalDate.now().toDate();
-
         //查询还差30天和1天过期的机构,并发送邮件和短信
         Integer[] days = {30, 1};
-        Arrays.stream(days).forEach(d -> checkAndSend(now, d));
+        Arrays.stream(days).forEach(this::checkAndSend);
 
+        Date now = LocalDate.now().toDate();
         //查询过期并且没有停用的机构,将其停用
         Date maturity = DateUtils.addDays(now, -1);
         Map<String, Object> par = new HashMap<>();
         par.put("expiryDate", maturity);
+        par.put("state", 1);
         List<TenantInfoInfoPageVo> maturityTenant = baseMapper.queryPage(par);
         maturityTenant.forEach(t -> {
             TenantInfo tenantInfo = baseMapper.selectById(t.getId());
@@ -847,9 +867,11 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
         });
     }
 
-    private void checkAndSend(Date now, int i) {
+    private void checkAndSend(int i) {
+        Date now = LocalDate.now().toDate();
         Date expiryDate = DateUtils.addDays(now, i);
         Map<String, Object> par = new HashMap<>();
+        par.put("state", 1);
         par.put("expiryDate", expiryDate);
         List<TenantInfoInfoPageVo> oneTenant = baseMapper.queryPage(par);
         send(oneTenant, DateUtils.formatDate(expiryDate, "yyyy年MM月dd日"));
@@ -857,8 +879,31 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
 
     private void send(List<TenantInfoInfoPageVo> infoList, String dateStr) {
         infoList.forEach(t -> {
-            Object[] objects = {t.getName(), t.getServeName(), dateStr, t.getStudentUpLimit()};
-            tenantInfoSendMsgService.platformSendToAll(EXPIRATION, t.getUserId(), t.getEmail(), t.getPhone(), objects);
+            //邮件
+            if (StringUtils.isNotBlank(t.getEmail())) {
+                //机构名称 服务名称 到期时间 学员数量
+                Object[] emailMsg = {t.getName(), t.getServeName(), dateStr, t.getStudentUpLimit()};
+                Map<Integer, String> sendPar = new HashMap<>();
+                sendPar.put(t.getUserId(), t.getEmail());
+                log.info("platformSendToAll>>> 即将到期 receiveUserId {} email {} objs {} sendPar {}", t.getUserId(), t.getEmail(), emailMsg, sendPar);
+                sysMessageService.batchSendMessage(-1, MessageSenderPluginContext.MessageSender.EMAIL,
+                        EMAIL_TENANT_EXPIRATION_REMINDERS,
+                        sendPar, null, 0, null,
+                        "SYSTEM", emailMsg);
+            }
+            //短信
+            if (StringUtils.isNotBlank(t.getPhone())) {
+                //机构名称 到期时间
+                Object[] phoneMsg = {t.getName(), dateStr};
+                Map<Integer, String> sendPar2 = new HashMap<>();
+                sendPar2.put(t.getUserId(), t.getPhone());
+                log.info("platformSendToAll>>> 即将到期 receiveUserId {} phone {} objs {} sendPar {}", t.getUserId(), t.getPhone(), phoneMsg, sendPar2);
+                sysMessageService.batchSendMessage(-1, MessageSenderPluginContext.MessageSender.AWSMS,
+                        SMS_TENANT_EXPIRATION_REMINDERS,
+                        sendPar2, null, 0, null,
+                        "SYSTEM", phoneMsg);
+            }
+
         });
     }
 

+ 10 - 0
mec-biz/src/main/resources/config/mybatis/CloudTeacherOrderMapper.xml

@@ -485,6 +485,16 @@
             </if>
         </where>
     </sql>
+
+    <insert id="batchInsert">
+        INSERT INTO cloud_teacher_order (organ_id_,student_id_, type_, level_, time_, amount_,status_,
+        remark_,create_time_, update_time_,tenant_id_)
+        VALUES
+        <foreach collection="userIds" item="userId" separator=",">
+            (#{bean.organId},#{userId},#{bean.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{bean.level},
+            #{bean.time}, #{bean.amount},#{bean.status},#{bean.remark},NOW(),NOW(),#{bean.tenantId})
+        </foreach>
+    </insert>
     
     <select id="queryByUserIdAndStatus" resultMap="CloudTeacherOrder">
         select cto.* from cloud_teacher_order cto where cto.student_id_ = #{userId} and cto.status_ = #{status}

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

@@ -85,6 +85,9 @@
                 OR a.`phone_` LIKE CONCAT('%', #{param.search},'%')
                 )
             </if>
+            <if test="param.tenantId != null ">
+                AND a.`id_` = #{param.tenantId}
+            </if>
             <if test="param.createdName != null ">
                 AND u.`real_name_` LIKE CONCAT('%', #{param.createdName},'%')
             </if>

+ 18 - 1
mec-student/src/main/java/com/ym/mec/student/controller/CloudCoachPaymentProgramController.java

@@ -1,10 +1,15 @@
 package com.ym.mec.student.controller;
 
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.entity.CloudCoachPaymentProgram;
 import com.ym.mec.biz.dal.entity.MemberRankSetting;
+import com.ym.mec.biz.dal.entity.StudentCloudCoachPaymentDetails;
 import com.ym.mec.biz.service.CloudCoachPaymentProgramService;
 import com.ym.mec.biz.service.MemberRankSettingService;
+import com.ym.mec.biz.service.StudentCloudCoachPaymentDetailsService;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,11 +26,23 @@ public class CloudCoachPaymentProgramController extends BaseController {
     private CloudCoachPaymentProgramService cloudCoachPaymentProgramService;
     @Autowired
     private MemberRankSettingService memberRankSettingService;
+    @Autowired
+    private StudentCloudCoachPaymentDetailsService studentCloudCoachPaymentDetailsService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
 
-    @ApiOperation(value = "新增")
+    @ApiOperation(value = "获取明细")
     @PostMapping("/get")
     public Object get(Long id){
         CloudCoachPaymentProgram cloudCoachPaymentProgram = cloudCoachPaymentProgramService.get(id);
+        if(cloudCoachPaymentProgram == null){
+            throw new BizException("云教练缴费项目不存在,请联系指导老师");
+        }
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        StudentCloudCoachPaymentDetails studentCloudCoachPaymentDetails = studentCloudCoachPaymentDetailsService.findByUserId(id, sysUser.getId());
+        if(studentCloudCoachPaymentDetails == null){
+            throw new BizException("您不在当前云教练缴费项目中,请联系指导老师");
+        }
         MemberRankSetting memberRankSetting = memberRankSettingService.get(cloudCoachPaymentProgram.getMemberRankSettingId());
         cloudCoachPaymentProgram.setMemberIntro(memberRankSetting.getIntro());
         return succeed(cloudCoachPaymentProgram);

+ 0 - 2
mec-web/src/main/java/com/ym/mec/web/controller/EmployeeController.java

@@ -47,8 +47,6 @@ public class EmployeeController extends BaseController {
     @Autowired
     private SysUserFeignService sysUserFeignService;
     @Autowired
-    private TeacherDao teacherDao;
-    @Autowired
     private StudentManageService studentManageService;
     @Autowired
     private OrganizationService organizationService;

+ 18 - 1
mec-web/src/main/java/com/ym/mec/web/controller/TenantInfoController.java

@@ -3,14 +3,18 @@ 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.dto.TenantInfoDto;
+import com.ym.mec.biz.dal.entity.TenantInfo;
 import com.ym.mec.biz.dal.entity.TenantProductSumm;
+import com.ym.mec.biz.service.TenantInfoSendMsgService;
 import com.ym.mec.biz.service.TenantInfoService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.yqpay.Msg;
 import com.ym.mec.util.validator.ValidationKit;
 import io.swagger.annotations.*;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -20,6 +24,9 @@ import org.springframework.web.bind.annotation.*;
 import javax.validation.Valid;
 import java.math.BigDecimal;
 import java.util.Map;
+import java.util.Objects;
+
+import static com.ym.mec.biz.service.impl.TenantInfoSendMsgServiceImpl.OPEN;
 
 /**
  * @author hgw
@@ -36,6 +43,9 @@ public class TenantInfoController extends BaseController {
     @Autowired
     private SysUserFeignService sysUserFeignService;
 
+    @Autowired
+    private TenantInfoSendMsgService tenantInfoSendMsgService;
+
     @ApiOperation("添加机构信息")
     @PostMapping(value = "/add")
     @PreAuthorize("@pcs.hasPermissions('tenantInfo/add')")
@@ -57,7 +67,14 @@ public class TenantInfoController extends BaseController {
     @GetMapping(value = "/opsState/{id}")
     @PreAuthorize("@pcs.hasPermissions('tenantInfo/opsState')")
     public Object opsState(@ApiParam(value = "机构ID", required = true) @PathVariable("id") Integer id, Integer state) {
-        tenantInfoService.opsTenantState(id, state);
+        Map<String, Object> openPar = tenantInfoService.opsTenantState(id, state);
+        //有返回密码(第一次开通机构会生成登录密码并返回)就发送邮件及短信提醒
+        String pw = WrapperUtil.toStr(openPar, "pw");
+        TenantInfo tenantInfo =(TenantInfo) openPar.get("tenantInfo");
+        if (StringUtils.isNotBlank(pw) && Objects.nonNull(tenantInfo)) {
+            Object[] msg = {tenantInfo.getName(), tenantInfo.getPhone(), pw, "https://online.dayaedu.com"};
+            tenantInfoSendMsgService.platformSendToAll(OPEN, tenantInfo.getUserId(), tenantInfo.getEmail(), tenantInfo.getPhone(), msg);
+        }
         return succeed();
     }