瀏覽代碼

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

zouxuan 3 年之前
父節點
當前提交
1d0b25cd15

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

@@ -15,6 +15,8 @@ public interface TenantInfoDao extends BaseMapper<TenantInfo> {
 
     <T> IPage<T> queryPage(Page<T> page, @Param("param") Map<String, Object> param);
 
+    <T> List<T> queryPage(@Param("param") Map<String, Object> param);
+
     TenantProductSumm queryTenantInfoProductSumm(Integer tenantId);
 
     TenantInfo getOpenTenant(Integer tenantId);
@@ -23,7 +25,5 @@ public interface TenantInfoDao extends BaseMapper<TenantInfo> {
 
     void updatePhone(@Param("newPhone")String newPhone, @Param("oldPhone")String oldPhone);
 
-    List<TenantInfo> queryExpiryTenant(@Param("expiryDate") Date expiryDate);
-
     Integer queryUserByTenantId(@Param("tenantId") Integer tenantId);
 }

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/vo/TenantInfoInfoPageVo.java

@@ -26,6 +26,9 @@ public class TenantInfoInfoPageVo implements Serializable {
     @ApiModelProperty(value = "机构联系人电话")
     private String phone;
 
+    @ApiModelProperty(value = "机构email")
+    private String email;
+
     @ApiModelProperty(value = "缴费状态 0未缴费  1已缴费")
     private Integer payState;
 
@@ -52,6 +55,9 @@ public class TenantInfoInfoPageVo implements Serializable {
     @ApiModelProperty(value = "到期时间")
     private Date expireDate;
 
+    @ApiModelProperty(value = "学员上限")
+    private Integer userId;
+
     public Integer getId() {
         return id;
     }
@@ -84,6 +90,14 @@ public class TenantInfoInfoPageVo implements Serializable {
         this.phone = phone;
     }
 
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
     public Integer getPayState() {
         return payState;
     }
@@ -147,4 +161,12 @@ public class TenantInfoInfoPageVo implements Serializable {
     public void setStudentCount(Integer studentCount) {
         this.studentCount = studentCount;
     }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
 }

+ 86 - 96
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OrderPayOpsServiceImpl.java

@@ -1,48 +1,10 @@
 package com.ym.mec.biz.service.impl;
 
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.function.BiPredicate;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-import org.apache.commons.lang3.StringUtils;
-import org.redisson.api.RBucket;
-import org.redisson.api.RedissonClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.DigestUtils;
-
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.entity.SysConfig;
-import com.ym.mec.biz.dal.entity.SysPaymentConfig;
-import com.ym.mec.biz.dal.entity.TenantConfig;
-import com.ym.mec.biz.dal.entity.TenantOrderRecord;
-import com.ym.mec.biz.dal.entity.TenantPaymentOrder;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
-import com.ym.mec.biz.service.CloudTeacherOrderService;
-import com.ym.mec.biz.service.OrderPayOpsService;
-import com.ym.mec.biz.service.StudentPaymentOrderService;
-import com.ym.mec.biz.service.SysConfigService;
-import com.ym.mec.biz.service.SysPaymentConfigService;
-import com.ym.mec.biz.service.TenantConfigService;
-import com.ym.mec.biz.service.TenantOrderRecordService;
-import com.ym.mec.biz.service.TenantPaymentOrderService;
+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.adapay.ConfigInit;
@@ -50,6 +12,24 @@ import com.ym.mec.thirdparty.adapay.Payment;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.http.HttpUtil;
 import com.ym.mec.util.json.JsonUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.redisson.api.RBucket;
+import org.redisson.api.RedissonClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.DigestUtils;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.function.BiPredicate;
+import java.util.function.Consumer;
+import java.util.function.Function;
 
 /**
  * @author hgw
@@ -71,10 +51,10 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
     private CloudTeacherOrderService cloudTeacherOrderService;
     @Autowired
     private TenantConfigService tenantConfigService;
-    
+
     @Autowired
     private SysConfigService sysConfigService;
-    
+
     @Autowired
     private SysPaymentConfigService sysPaymentConfigService;
 
@@ -102,25 +82,17 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
         }
         //签名验证
         checkSing(payParam);
-
-        Map<String, Object> payment = new HashMap<>();
+        //返回值
+        Map<String, Object> payment;
+        //如果platform is null 则应该是这一个,因为老代码就是这样写的。
         if (StringUtils.isBlank(platform)) {
+            payment = student(payParam);
+        } else {
             //根据传入platform 来判断执行哪个操作
             Function<PaymentParam, Map<String, Object>> function = checkOrderType.get(platform);
             //如果以上操作都没有 则应该是这一个,因为老代码就是这样写的。
             if (Objects.isNull(function)) {
-                StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findOrderByOrderNo(payParam.getOrderNo());
-                if (Objects.isNull(studentPaymentOrder)) {
-                    throw new BizException("订单不存在");
-                }
-                payParam.setTenantId(studentPaymentOrder.getTenantId());
-                payment = checkOrderAndGetParam(payParam,
-                        studentPaymentOrder,
-                        StudentPaymentOrder::getStatus,
-                        StudentPaymentOrder::getCreateTime,
-                        studentPaymentOrder::setTransNo,
-                        studentPaymentOrderService::update
-                );
+                payment = student(payParam);
             } else {
                 payment = function.apply(payParam);
             }
@@ -128,6 +100,24 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
         return payment;
     }
 
+    //platform is null 或者 student
+    private Map<String, Object> student(PaymentParam payParam) throws Exception {
+        Map<String, Object> payment;
+        StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findOrderByOrderNo(payParam.getOrderNo());
+        if (Objects.isNull(studentPaymentOrder)) {
+            throw new BizException("订单不存在");
+        }
+        payParam.setTenantId(studentPaymentOrder.getTenantId());
+        payment = checkOrderAndGetParam(payParam,
+                studentPaymentOrder,
+                StudentPaymentOrder::getStatus,
+                StudentPaymentOrder::getCreateTime,
+                studentPaymentOrder::setTransNo,
+                studentPaymentOrderService::update
+        );
+        return payment;
+    }
+
     //teacher
     private Map<String, Object> teacher(PaymentParam payParam) {
         Map<String, Object> payment;
@@ -329,55 +319,55 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
                 StudentPaymentOrder st = (StudentPaymentOrder) clazz;
                 merNos = st.getMerNos();
                 amount = amountTo.apply(st.getActualAmount());
-		        
-				List<Map<String, Object>> divMemberList = new ArrayList<>();
+
+                List<Map<String, Object>> divMemberList = new ArrayList<>();
                 // 实时分账
-    			if (amount.doubleValue() > 0) {
-    				
-    				SysConfig config = sysConfigService.findByParamName("platform_collection_organ");
-    		        if (Objects.isNull(config)) {
-    		            throw new BizException("平台收款账户没有设置[platform_collection_organ]");
-    		        }
-    	        	
-    	        	SysPaymentConfig sysPaymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(Integer.parseInt(config.getParanValue()));
-    	        	
-    	        	if(sysPaymentConfig == null || StringUtils.isBlank(sysPaymentConfig.getHfMerNo())){
-    	        		throw new BizException("分部[{}]没有设置收款账号", config.getParanValue());
-    	        	}
-    	        	
-    				Map<String, Object> divMember = new HashMap<>();
-    				divMember.put("member_id", sysPaymentConfig.getHfMerNo());
-    				divMember.put("amount", amount);
-    				divMember.put("fee_flag", "Y");
-    				divMemberList.add(divMember);
-    			}
-
-				Map<String, Object> divMember1 = new HashMap<>();
-				divMember1.put("member_id", merNos);
-				divMember1.put("amount", payParam.getAmount().subtract(amount));
-				divMember1.put("fee_flag", "N");
-				divMemberList.add(divMember1);
-				
-				paymentParams.put("div_members", JsonUtil.toJSONString(divMemberList));
-				
+                if (amount.doubleValue() > 0) {
+
+                    SysConfig config = sysConfigService.findByParamName("platform_collection_organ");
+                    if (Objects.isNull(config)) {
+                        throw new BizException("平台收款账户没有设置[platform_collection_organ]");
+                    }
+
+                    SysPaymentConfig sysPaymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(Integer.parseInt(config.getParanValue()));
+
+                    if (sysPaymentConfig == null || StringUtils.isBlank(sysPaymentConfig.getHfMerNo())) {
+                        throw new BizException("分部[{}]没有设置收款账号", config.getParanValue());
+                    }
+
+                    Map<String, Object> divMember = new HashMap<>();
+                    divMember.put("member_id", sysPaymentConfig.getHfMerNo());
+                    divMember.put("amount", amount);
+                    divMember.put("fee_flag", "Y");
+                    divMemberList.add(divMember);
+                }
+
+                Map<String, Object> divMember1 = new HashMap<>();
+                divMember1.put("member_id", merNos);
+                divMember1.put("amount", payParam.getAmount().subtract(amount));
+                divMember1.put("fee_flag", "N");
+                divMemberList.add(divMember1);
+
+                paymentParams.put("div_members", JsonUtil.toJSONString(divMemberList));
+
             } else if (clazz instanceof TenantOrderRecord) {//向平台支付,不分账
                 TenantOrderRecord tor = (TenantOrderRecord) clazz;
                 merNos = tor.getMerNos();
-                
+
                 List<Map<String, Object>> divMemberList = new ArrayList<>();
-				Map<String, Object> divMember = new HashMap<>();
-				divMember.put("member_id", merNos);
-				divMember.put("amount", tor.getActualAmount());
-				divMember.put("fee_flag", "Y");
-				divMemberList.add(divMember);
-
-				paymentParams.put("div_members", JsonUtil.toJSONString(divMemberList));
-				
+                Map<String, Object> divMember = new HashMap<>();
+                divMember.put("member_id", merNos);
+                divMember.put("amount", tor.getActualAmount());
+                divMember.put("fee_flag", "Y");
+                divMemberList.add(divMember);
+
+                paymentParams.put("div_members", JsonUtil.toJSONString(divMemberList));
+
             } /*else if (clazz instanceof TenantPaymentOrder) {
                 TenantPaymentOrder tpo = (TenantPaymentOrder) clazz;
                 merNos = tpo.getMerNos();
                 amount = amountTo.apply(tpo.getActualAmount());
-            } */else {
+            } */ else {
                 throw new BizException("订单[{}]找不到", payParam.getOrderNo());
             }
         }

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

@@ -22,7 +22,6 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.redis.service.RedisCache;
 import com.ym.mec.common.service.IdGeneratorService;
 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.date.DateUtil;
@@ -1824,7 +1823,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         } else {
             userDefaultSubjectIds = new ArrayList<>();
         }
-        Collections.swap(subjects, 6, 7);
         PracticeGroupSellPrice practiceGroupSellPrice = practiceGroupSellPriceDao.get(organId);
         result.put("subjects", subjects);
 //        result.put("practiceApplyStartTime", practiceApplyStartTimeConfig);
@@ -4051,7 +4049,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             if (report.getVersion().equals(2)) {
                 pushUrl.append("/#/reportDetailNew?id=").append(report.getId()).append("&classGroupId=").append(report.getClassGroupId());
                 smsUrl.append("/#/transfer?url=").append(baseApiUrl).append("&hash=reportDetailNew&id=").append(report.getId()).append("&classGroupId=").append(report.getClassGroupId());
-            }else {
+            } else {
                 pushUrl.append("/#/reportDetail?classGroupId=").append(report.getClassGroupId());
                 smsUrl.append("/#/transfer?url=").append(baseApiUrl).append("&hash=reportDetail&classGroupId=").append(report.getClassGroupId());
             }
@@ -4060,7 +4058,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
                 Map<Integer, String> userMap = new HashMap<>();
                 userMap.put(userFreePracticeGroup.getStudentId(), userFreePracticeGroup.getStudentId().toString());
                 sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_SMS_PUSH_PRACTICE_COMPLETED_STUDY_REPORT,
-                        userMap, null, 0, pushUrl.insert(0,"5?").toString(), "STUDENT", pushUrl.toString());
+                        userMap, null, 0, pushUrl.insert(0, "5?").toString(), "STUDENT", pushUrl.toString());
             }
 
             if (pushType.equals("ALL") || pushType.equals("SMS")) {

+ 15 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantInfoServiceImpl.java

@@ -835,24 +835,29 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
 
         //查询过期并且没有停用的机构,将其停用
         Date maturity = DateUtils.addDays(now, -1);
-        List<TenantInfo> maturityTenant = baseMapper.queryExpiryTenant(maturity);
+        Map<String, Object> par = new HashMap<>();
+        par.put("expiryDate", maturity);
+        List<TenantInfoInfoPageVo> maturityTenant = baseMapper.queryPage(par);
         maturityTenant.forEach(t -> {
-            t.setState(2);
-            t.setUpdatedBy(-1);
-            t.setUpdatedTime(now);
-            this.updateById(t);
+            TenantInfo tenantInfo = baseMapper.selectById(t.getId());
+            tenantInfo.setState(2);
+            tenantInfo.setUpdatedBy(-1);
+            tenantInfo.setUpdatedTime(now);
+            this.updateById(tenantInfo);
         });
     }
 
     private void checkAndSend(Date now, int i) {
-        Date one = DateUtils.addDays(now, i);
-        List<TenantInfo> oneTenant = baseMapper.queryExpiryTenant(one);
-        send(oneTenant, DateUtils.formatDate(one, "yyyy年MM月dd日"));
+        Date expiryDate = DateUtils.addDays(now, i);
+        Map<String, Object> par = new HashMap<>();
+        par.put("expiryDate", expiryDate);
+        List<TenantInfoInfoPageVo> oneTenant = baseMapper.queryPage(par);
+        send(oneTenant, DateUtils.formatDate(expiryDate, "yyyy年MM月dd日"));
     }
 
-    private void send(List<TenantInfo> infoList, String dateStr) {
+    private void send(List<TenantInfoInfoPageVo> infoList, String dateStr) {
         infoList.forEach(t -> {
-            Object[] objects = {t.getName(), dateStr};
+            Object[] objects = {t.getName(), t.getServeName(), dateStr, t.getStudentUpLimit()};
             tenantInfoSendMsgService.platformSendToAll(EXPIRATION, t.getUserId(), t.getEmail(), t.getPhone(), objects);
         });
     }

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

@@ -42,11 +42,13 @@
         <result column="name_" jdbcType="VARCHAR" property="name"/>
         <result column="contacts_" jdbcType="VARCHAR" property="contacts"/>
         <result column="phone_" jdbcType="VARCHAR" property="phone"/>
+        <result column="email_" jdbcType="VARCHAR" property="email"/>
         <result column="pay_state_" jdbcType="INTEGER" property="payState"/>
         <result column="state_" jdbcType="INTEGER" property="state"/>
         <result column="logo_" jdbcType="VARCHAR" property="logo"/>
         <result column="real_name_" jdbcType="VARCHAR" property="createdName"/>
         <result column="studentCount" jdbcType="INTEGER" property="studentCount"/>
+        <result column="userId" jdbcType="INTEGER" property="userId"/>
         <!-- 机构产品信息-->
         <result column="serve_name_" jdbcType="VARCHAR" property="serveName"/>
         <result column="student_up_limit_" jdbcType="INTEGER" property="studentUpLimit"/>
@@ -58,6 +60,7 @@
         a.`name_`,
         a.`contacts_`,
         a.`phone_`,
+        a.`email_`,
         a.`pay_state_`,
         a.`state_`,
         a.logo_,
@@ -65,7 +68,8 @@
         c.`name_` AS serve_name_,
         d.`student_up_limit_`,
         b.`expiry_date_`,
-        ifnull(st.studentCount, 0) as studentCount
+        ifnull(st.studentCount, 0) as studentCount,
+        a.user_id_ as userId
         FROM tenant_info AS a
         LEFT JOIN tenant_product_info AS b ON a.`id_` = b.`tenant_id_` and b.using_ = 0
         LEFT JOIN platform_serve AS c ON b.`serve_id_` = c.`id_`
@@ -96,6 +100,9 @@
             <if test="param.endDate != null ">
                 AND b.`expiry_date_` <![CDATA[ <= ]]>  #{param.endDate}
             </if>
+            <if test="param.expiryDate != null ">
+            AND b.`expiry_date_` = #{param.expiryDate}
+            </if>
         </where>
     </select>
 
@@ -125,37 +132,6 @@
         where id_ = (select tenant_id_ from organization where id_ = #{organId})
     </select>
 
-    <select id="queryExpiryTenant" resultMap="BaseResultMap">
-        SELECT a.id_,
-               a.name_,
-               a.contacts_,
-               a.phone_,
-               address_,
-               a.email_,
-               a.logo_,
-               a.customer_service_phone_,
-               a.remark_,
-               a.domain_name_,
-               a.data_source_,
-               a.pay_state_,
-               a.state_,
-               a.created_by_,
-               a.created_time_,
-               a.updated_by_,
-               a.updated_time_,
-               a.tsign_code_,
-               a.tsign_name_,
-               a.area_id_,
-               a.user_id_
-        FROM `tenant_info` AS a
-                 LEFT JOIN `tenant_product_info` AS b
-                           ON a.id_ = b.`tenant_id_`
-        WHERE a.`state_` = 1
-          AND a.`pay_state_` = 1
-          AND b.`using_` = 0
-          AND b.`expiry_date_` = #{expiryDate}
-    </select>
-
     <select id="queryUserByTenantId" resultType="integer">
         select id_ from sys_user where tenant_id_ = #{tenantId} limit 1
     </select>

+ 8 - 0
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -1,6 +1,7 @@
 package com.ym.mec.student.controller;
 
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
@@ -96,6 +97,8 @@ public class StudentOrderController extends BaseController {
     private OrderPayOpsService orderPayOpsService;
     @Autowired
     private MusicGroupPaymentCalenderActivityService musicGroupPaymentCalenderActivityService;
+    @Autowired
+    private TenantConfigService tenantConfigService;
 
     @Value("${spring.profiles.active:dev}")
     private String profiles;
@@ -161,6 +164,11 @@ public class StudentOrderController extends BaseController {
         HashMap<String, Object> orderDetail = new HashMap<>();
         orderDetail.put("order", orderByOrderNo);
         orderDetail.put("groupType", orderByOrderNo.getGroupType());
+        TenantConfig tenantConfig = tenantConfigService.getOne(new QueryWrapper<TenantConfig>()
+                .eq("tenant_id_", orderByOrderNo.getTenantId()));
+        if (Objects.nonNull(tenantConfig)) {
+            orderDetail.put("financeChops", tenantConfig.getCorporateFinanceChops());
+        }
         if (OrderTypeEnum.APPLY.equals(orderByOrderNo.getType())) {
             StudentRegistration studentRegistration = studentRegistrationDao.getStudentRegister(orderByOrderNo.getMusicGroupId(), orderByOrderNo.getUserId());
             if (studentRegistration.getPayingStatus().equals(2)) {