Bladeren bron

团练宝缴费自动生效

zouxuan 3 jaren geleden
bovenliggende
commit
9c28125799
21 gewijzigde bestanden met toevoegingen van 173 en 1004 verwijderingen
  1. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CloudCoachPaymentProgram.java
  2. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderMember.java
  3. 38 34
      mec-biz/src/main/java/com/ym/mec/biz/service/CloudTeacherOrderService.java
  4. 0 3
      mec-biz/src/main/java/com/ym/mec/biz/service/MemberRankSettingService.java
  5. 0 37
      mec-biz/src/main/java/com/ym/mec/biz/service/PracticeGroupService.java
  6. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/service/TenantConfigService.java
  7. 9 17
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudCoachPaymentProgramServiceImpl.java
  8. 44 138
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudTeacherOrderServiceImpl.java
  9. 1 73
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankSettingServiceImpl.java
  10. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  11. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  12. 1 630
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java
  13. 3 16
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  14. 15 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantConfigServiceImpl.java
  15. 2 8
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantOrderRecordServiceImpl.java
  16. 6 2
      mec-biz/src/main/resources/config/mybatis/CloudCoachPaymentProgramMapper.xml
  17. 6 2
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMemberMapper.xml
  18. 2 28
      mec-student/src/main/java/com/ym/mec/student/controller/ActivityController.java
  19. 2 10
      mec-student/src/main/java/com/ym/mec/student/controller/PracticeGroupController.java
  20. 2 1
      mec-web/src/main/java/com/ym/mec/web/controller/CloudTeacherOrderController.java
  21. 7 1
      mec-web/src/main/java/com/ym/mec/web/controller/TenantConfigController.java

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CloudCoachPaymentProgram.java

@@ -47,6 +47,9 @@ public class CloudCoachPaymentProgram extends BaseEntity {
 	
 	/** 原价 */
 	private java.math.BigDecimal originalAmount = BigDecimal.ZERO;
+
+	/** 是否自动激活团练宝缴费 */
+	private Boolean autoActivationFlag = false;
 	
 	/** 创建人 */
 	private Integer operator;
@@ -83,6 +86,14 @@ public class CloudCoachPaymentProgram extends BaseEntity {
 	@ApiModelProperty(value = "审核时间", required = false)
 	private Date auditTime;
 
+	public Boolean getAutoActivationFlag() {
+		return autoActivationFlag;
+	}
+
+	public void setAutoActivationFlag(Boolean autoActivationFlag) {
+		this.autoActivationFlag = autoActivationFlag;
+	}
+
 	public enum StatusEnum implements BaseEnum<String, CloudCoachPaymentProgram.StatusEnum> {
 		AUDITING("审核中"), REJECT("审核拒绝"), OPEN("审核通过");
 

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderMember.java

@@ -15,6 +15,17 @@ public class MusicGroupPaymentCalenderMember extends MusicGroupPaymentCalenderBa
 
     private Integer organId;
 
+    @ApiModelProperty(value = "自动激活团练宝标识", required = false)
+    private Boolean autoActivationFlag = false;
+
+    public Boolean getAutoActivationFlag() {
+        return autoActivationFlag;
+    }
+
+    public void setAutoActivationFlag(Boolean autoActivationFlag) {
+        this.autoActivationFlag = autoActivationFlag;
+    }
+
     public Integer getOrganId() {
         return organId;
     }

+ 38 - 34
mec-biz/src/main/java/com/ym/mec/biz/service/CloudTeacherOrderService.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.page.CloudTeacherAddQueryInfo;
 import com.ym.mec.biz.dal.page.CloudTeacherOrderQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -30,14 +31,15 @@ public interface CloudTeacherOrderService extends BaseService<Long, CloudTeacher
      */
     void addOrderDetail2CloudTeacher(StudentPaymentOrder order, BigDecimal cloudTeacherFee);
 
-
     /**
-     * 将生效的云教练订单加入
-     *
+    * @description: 激活团练宝
+     * @param now
      * @param cloudTeacherOrder
-     * @return
-     */
-    CloudTeacher addStudentCloudTeacher(CloudTeacherOrder cloudTeacherOrder);
+    * @return void
+    * @author zx
+    * @date 2022/3/21 11:10
+    */
+    void activationMember(Date now, CloudTeacherOrder cloudTeacherOrder);
 
     Date calcCloudTeacherOrderTime(CloudTeacherOrder cloudTeacherOrder, Date startTime, Date endTime);
 
@@ -59,32 +61,6 @@ public interface CloudTeacherOrderService extends BaseService<Long, CloudTeacher
     List<CloudTeacherOrder> getStudentCloudTeacherOrder(Integer studentId, String musicGroupId);
 
     /**
-     * 退云教练
-     *
-     * @param cloudTeacherOrders
-     * @param refundAmount
-     * @return
-     */
-    Boolean quitCloudTeacherOrders(List<CloudTeacherOrder> cloudTeacherOrders, BigDecimal refundAmount);
-
-    /**
-     * 退云教练
-     *
-     * @param order
-     * @param refundAmount
-     * @return
-     */
-    Boolean quitCloudTeacherOrder(CloudTeacherOrder order, BigDecimal refundAmount);
-
-    /**
-     * 根据studentPaymentOrder表id查询对象
-     *
-     * @param orderId
-     * @return
-     */
-    CloudTeacherOrder queryByOrderId(Long orderId);
-
-    /**
      * 根据订单编号查询订单详情
      *
      * @param orderId
@@ -116,7 +92,35 @@ public interface CloudTeacherOrderService extends BaseService<Long, CloudTeacher
 
     PageInfo<CloudTeacherStudent> queryRecord(CloudTeacherOrderQueryInfo cloudTeacherOrderQueryInfo);
 
-    boolean addStudents(CloudTeacherAddQueryInfo cloudTeacherAddQueryInfo);
-
     int sendSms(TenantOrderRecord record);
+
+    /**
+    * @description: 批量新增学员云教练
+     * @param cloudTeacherOrder
+     * @param userIds
+     * @param autoActivationFlag
+    * @return void
+    * @author zx
+    * @date 2022/3/21 11:21
+    */
+    void batchInsert(CloudTeacherOrder cloudTeacherOrder, List<Integer> userIds,Boolean autoActivationFlag);
+
+    /**
+    * @description: 通过团练宝缴费项目获取初始化的云教练订单
+     * @param cloudCoachPaymentProgram
+    * @return com.ym.mec.biz.dal.entity.CloudTeacherOrder
+    * @author zx
+    * @date 2022/3/21 11:40
+    */
+    CloudTeacherOrder getInitCloudTeacherOrder(CloudCoachPaymentProgram cloudCoachPaymentProgram);
+
+    /**
+    * @description: 保存云教练订单
+     * @param cloudTeacherOrder
+     * @param autoActivationFlag
+    * @return void
+    * @author zx
+    * @date 2022/3/21 11:59
+    */
+    void save(CloudTeacherOrder cloudTeacherOrder,Boolean autoActivationFlag);
 }

+ 0 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/MemberRankSettingService.java

@@ -3,11 +3,9 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.dto.MemberPayParamDto;
 import com.ym.mec.biz.dal.entity.MemberRankSetting;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.enums.PeriodEnum;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.service.BaseService;
 
-import java.math.BigDecimal;
 import java.util.List;
 
 public interface MemberRankSettingService extends BaseService<Integer, MemberRankSetting> {
@@ -41,5 +39,4 @@ public interface MemberRankSettingService extends BaseService<Integer, MemberRan
      */
     boolean orderCallback(StudentPaymentOrder studentPaymentOrder);
 
-    HttpResponseResult ActiveBuy(Integer id, Integer memberRankId, PeriodEnum month, BigDecimal amount, boolean isUseBalance, Integer buyNum, int giveNum, int activeRemark, String remark, boolean repay) throws Exception;
 }

+ 0 - 37
mec-biz/src/main/java/com/ym/mec/biz/service/PracticeGroupService.java

@@ -165,7 +165,6 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
      * @date 2020/2/10
      * @param userId: 用户编号
      * @param teacherId: 教师编号
-     * @param firstClassTime: 第一节课开始时间
      * @param buyMonths: 购买月数
      * @return java.util.Map
      */
@@ -207,24 +206,6 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
      */
 	void orderCallback(StudentPaymentOrder order);
 
-    /**
-    * @description: 活动购买支付订单回调
-     * @param order
-    * @return void
-    * @author zx
-    * @date 2021/10/13 19:52
-    */
-	void activityOrderCallback(StudentPaymentOrder order);
-
-    /**
-    * @description: 2021双十一活动订单回调
-     * @param order
-    * @return void
-    * @author zx
-    * @date 2021/10/13 19:52
-    */
-	void doubleEleven2021OrderCallback(StudentPaymentOrder order);
-
 	/**
 	 * @describe 获取用户历史购买的陪练课
 	 * @author Joburgess
@@ -367,15 +348,6 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
     */
 	HttpResponseResult buyTeacherPracticeGroup(PracticeGroupBuyParamsDto practiceGroupBuyParams) throws Exception;
 
-    /**
-    * @description: 营销活动网管课购买
-     * @param practiceGroupBuyParams
-    * @return com.ym.mec.common.entity.HttpResponseResult
-    * @author zx
-    * @date 2021/10/13 15:12
-    */
-	Object buyActivityPracticeGroup(PracticeGroupBuyParamsDto practiceGroupBuyParams) throws Exception;
-
 	/**
 	* @description: 获取学生端网管课购买详情
 	 * @param groupId
@@ -397,15 +369,6 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
 	Object getPracticeGroupPayInfo(Long practiceGroupId, Integer userId);
 
 	/**
-	* @description: 2021双十一活动购买
-	 * @param buyDoubleEleven2021Dto
-	* @return java.lang.Object
-	* @author zx
-	* @date 2021/10/20 10:39
-	*/
-	HttpResponseResult buyDoubleEleven2021(BuyDoubleEleven2021Dto buyDoubleEleven2021Dto) throws Exception;
-
-	/**
 	* @description: 获取学生指定网管课的剩余课时费用
 	 * @param practiceGroupId
 	* @return java.lang.Object

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/TenantConfigService.java

@@ -18,4 +18,13 @@ public interface TenantConfigService extends IService<TenantConfig> {
     Map<String, BigDecimal> getRule(Integer tenantId);
 
     Map<String, BigDecimal> getCloudRoomRule(String config);
+
+    /**
+    * @description: 是否可以自动激活团练宝
+     * @param tenantId
+    * @return java.lang.Boolean
+    * @author zx
+    * @date 2022/3/21 10:18
+    */
+    Boolean autoActivationFlag(Integer tenantId);
 }

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

@@ -6,12 +6,8 @@ import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.entity.CloudCoachPaymentProgram;
 import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
 import com.ym.mec.biz.dal.entity.MemberRankSetting;
-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.biz.service.*;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
@@ -25,7 +21,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.time.Instant;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -43,9 +38,9 @@ public class CloudCoachPaymentProgramServiceImpl extends BaseServiceImpl<Long, C
 	@Autowired
 	private MemberRankSettingDao memberRankSettingDao;
 	@Autowired
-	private CloudTeacherOrderDao cloudTeacherOrderDao;
+	private TenantConfigService tenantConfigService;
 	@Autowired
-	private TenantInfoDao tenantInfoDao;
+	private CloudTeacherOrderService cloudTeacherOrderService;
 	@Autowired
 	private SysConfigDao sysConfigDao;
 	@Autowired
@@ -82,6 +77,8 @@ public class CloudCoachPaymentProgramServiceImpl extends BaseServiceImpl<Long, C
 		cloudCoachPaymentProgram.setTenantId(tenantId);
 		//获取缴费状态
 		cloudCoachPaymentProgram.setStatus(getStatus(cloudCoachPaymentProgram));
+		//是否自动激活
+		cloudCoachPaymentProgram.setAutoActivationFlag(tenantConfigService.autoActivationFlag(tenantId));
 		cloudCoachPaymentProgramDao.insert(cloudCoachPaymentProgram);
 		studentCloudCoachPaymentDetailsDao.batchInsert(cloudCoachPaymentProgram.getId(),userIds,tenantId);
 		if(cloudCoachPaymentProgram.getStatus() == CloudCoachPaymentProgram.StatusEnum.OPEN){
@@ -115,15 +112,8 @@ public class CloudCoachPaymentProgramServiceImpl extends BaseServiceImpl<Long, C
 			cloudCoachPaymentProgram.setPaymentUserNum(userIds.size());
 			cloudCoachPaymentProgramDao.update(cloudCoachPaymentProgram);
 			studentCloudCoachPaymentDetailsDao.updatePaymentStatus(cloudCoachPaymentProgram.getId());
-			CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
-			cloudTeacherOrder.setTime(cloudCoachPaymentProgram.getMemberNum().intValue());
-			cloudTeacherOrder.setOrganId(cloudCoachPaymentProgram.getOrganId());
-			cloudTeacherOrder.setType(cloudCoachPaymentProgram.getPeriod());
-			cloudTeacherOrder.setLevel(cloudCoachPaymentProgram.getMemberRankSettingId());
-			cloudTeacherOrder.setAmount(BigDecimal.ZERO);
-			cloudTeacherOrder.setStatus(1);
-			cloudTeacherOrder.setRemark(cloudCoachPaymentProgram.getRemark());
-			cloudTeacherOrderDao.batchInsert(cloudTeacherOrder,cloudCoachPaymentProgram.getUserIds());
+			CloudTeacherOrder cloudTeacherOrder = cloudTeacherOrderService.getInitCloudTeacherOrder(cloudCoachPaymentProgram);
+			cloudTeacherOrderService.batchInsert(cloudTeacherOrder,cloudCoachPaymentProgram.getUserIds(),cloudCoachPaymentProgram.getAutoActivationFlag());
 		}else {
 			//推送缴费消息
 			//TenantInfo tenantInfo = tenantInfoDao.selectById(cloudCoachPaymentProgram.getTenantId());
@@ -149,6 +139,8 @@ public class CloudCoachPaymentProgramServiceImpl extends BaseServiceImpl<Long, C
 			throw new BizException("当前状态缴费项目不可编辑");
 		}
 		cloudCoachPaymentProgram.setStatus(getStatus(cloudCoachPaymentProgram));
+		//是否自动激活
+		cloudCoachPaymentProgram.setAutoActivationFlag(tenantConfigService.autoActivationFlag(cloudCoachPaymentProgram.getTenantId()));
 		cloudCoachPaymentProgramDao.update(cloudCoachPaymentProgram);
 		if(cloudCoachPaymentProgram.getStatus() == CloudCoachPaymentProgram.StatusEnum.OPEN){
 			List<Integer> userIds = studentCloudCoachPaymentDetailsDao.findUserByProgramId(cloudCoachPaymentProgram.getId());

+ 44 - 138
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudTeacherOrderServiceImpl.java

@@ -11,11 +11,9 @@ import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
 import com.ym.mec.biz.dal.enums.TenantOrderRecordEnum;
-import com.ym.mec.biz.dal.page.CloudTeacherAddQueryInfo;
 import com.ym.mec.biz.dal.page.CloudTeacherOrderQueryInfo;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.dal.BaseDAO;
-import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.common.service.IdGeneratorService;
@@ -67,21 +65,6 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
     @Autowired
     private TenantInfoService tenantInfoService;
 
-    @Override
-    public boolean addStudents(CloudTeacherAddQueryInfo cloudTeacherAddQueryInfo) {
-        for (Integer stId : cloudTeacherAddQueryInfo.getStudentIds()) {
-            CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
-            cloudTeacherOrder.setStudentId(stId);
-            cloudTeacherOrder.setTime(cloudTeacherAddQueryInfo.getTimes());
-            cloudTeacherOrder.setType(cloudTeacherAddQueryInfo.getAddType());
-            cloudTeacherOrder.setLevel(1);
-            cloudTeacherOrder.setMusicGroupId(cloudTeacherAddQueryInfo.getMusicGroupId());
-            cloudTeacherOrder.setTenantId(cloudTeacherAddQueryInfo.getTenantId());
-            cloudTeacherOrderDao.insert(cloudTeacherOrder);
-            this.addStudentCloudTeacher(cloudTeacherOrder);
-        }
-        return true;
-    }
 
     @Override
     public PageInfo<CloudTeacherStudent> queryRecord(CloudTeacherOrderQueryInfo queryInfo) {
@@ -242,6 +225,38 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
         return 0;
     }
 
+    @Override
+    public void batchInsert(CloudTeacherOrder cloudTeacherOrder, List<Integer> userIds,Boolean autoActivationFlag) {
+        Date date = new Date();
+        for (Integer userId : userIds) {
+            cloudTeacherOrder.setStudentId(userId);
+            this.activationMember(date,cloudTeacherOrder);
+        }
+    }
+
+    @Override
+    public CloudTeacherOrder getInitCloudTeacherOrder(CloudCoachPaymentProgram cloudCoachPaymentProgram) {
+        CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
+        cloudTeacherOrder.setTime(cloudCoachPaymentProgram.getMemberNum().intValue());
+        cloudTeacherOrder.setOrganId(cloudCoachPaymentProgram.getOrganId());
+        cloudTeacherOrder.setType(cloudCoachPaymentProgram.getPeriod());
+        cloudTeacherOrder.setLevel(cloudCoachPaymentProgram.getMemberRankSettingId());
+        cloudTeacherOrder.setAmount(BigDecimal.ZERO);
+        cloudTeacherOrder.setStatus(1);
+        cloudTeacherOrder.setRemark(cloudCoachPaymentProgram.getRemark());
+        return cloudTeacherOrder;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void save(CloudTeacherOrder cloudTeacherOrder,Boolean autoActivationFlag) {
+        if(autoActivationFlag){
+            this.activationMember(new Date(),cloudTeacherOrder);
+        }else {
+            cloudTeacherOrderDao.insert(cloudTeacherOrder);
+        }
+    }
+
     public Boolean payCheck(String orderNo) {
         TenantOrderRecord record = tenantOrderRecordService.getOne(new QueryWrapper<TenantOrderRecord>().eq("order_no_", orderNo));
         return record.getOrderState() == 1;
@@ -261,53 +276,24 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
         cloudTeacherOrder.setAmount(cloudTeacherFee);
         cloudTeacherOrder.setStudentId(order.getUserId());
         cloudTeacherOrder.setStatus(1);
-        cloudTeacherOrderDao.insert(cloudTeacherOrder);
+        //保存云教练订单
+        this.save(cloudTeacherOrder,calenderMember.getAutoActivationFlag());
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public CloudTeacher addStudentCloudTeacher(CloudTeacherOrder cloudTeacherOrder) {
-        Date nowDate = new Date();
-        CloudTeacher cloudTeacher = cloudTeacherDao.getByStudentId(cloudTeacherOrder.getStudentId());
-        Date startTime;
-        Date endTime = null;
-        Date endBaseTime;
-
-        //更新student表信息
-        studentService.updateMemberRank(cloudTeacherOrder);
-
-        if (cloudTeacher == null) {
-            cloudTeacher = new CloudTeacher();
-            startTime = DateUtil.trunc(nowDate);
-            endBaseTime = startTime;
-            endTime = calcCloudTeacherOrderTime(cloudTeacherOrder, startTime, endTime);
-            cloudTeacher.setStudentId(cloudTeacherOrder.getStudentId());
-            cloudTeacher.setLevel(cloudTeacherOrder.getLevel());
-            cloudTeacher.setStartTime(startTime);
-            cloudTeacher.setEndTime(endTime);
-            cloudTeacherDao.insert(cloudTeacher);
-        } else {
-            startTime = cloudTeacher.getStartTime();
-            endBaseTime = cloudTeacher.getEndTime();
-            if (cloudTeacher.getEndTime().compareTo(nowDate) < 0) {
-                startTime = DateUtil.trunc(nowDate);
-                endBaseTime = startTime;
-            }
-            endTime = calcCloudTeacherOrderTime(cloudTeacherOrder, endBaseTime, endTime);
-            cloudTeacher.setStartTime(startTime);
-            cloudTeacher.setEndTime(endTime);
-            cloudTeacher.setUpdateTime(nowDate);
-            if (cloudTeacherDao.update(cloudTeacher) <= 0) {
-                throw new BizException("团练宝有效期更新失败");
-            }
-        }
-        cloudTeacherOrder.setStartTime(endBaseTime);
+    public void activationMember(Date now,CloudTeacherOrder cloudTeacherOrder){
+        Date startTime = DateUtil.trunc(now);
+        Date endTime = this.calcCloudTeacherOrderTime(cloudTeacherOrder, startTime, now);
+        cloudTeacherOrder.setStartTime(startTime);
         cloudTeacherOrder.setEndTime(endTime);
-        cloudTeacherOrder.setStatus(1);
-        if (cloudTeacherOrderDao.update(cloudTeacherOrder) <= 0) {
-            throw new BizException("团练宝生效处理失败");
+        cloudTeacherOrder.setStatus(2);
+        if(Objects.isNull(cloudTeacherOrder.getId())){
+            cloudTeacherOrderDao.insert(cloudTeacherOrder);
+        }else {
+            cloudTeacherOrderDao.update(cloudTeacherOrder);
         }
-        return cloudTeacher;
+        studentService.updateMemberRank(cloudTeacherOrder.getStudentId(), cloudTeacherOrder.getType(), cloudTeacherOrder.getTime(), 1);
     }
 
     public Date calcCloudTeacherOrderTime(CloudTeacherOrder cloudTeacherOrder, Date startTime, Date endTime) {
@@ -336,86 +322,6 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public Boolean quitCloudTeacherOrders(List<CloudTeacherOrder> cloudTeacherOrders, BigDecimal refundAmount) {
-        Date nowDate = new Date();
-        for (int i = 0; i < cloudTeacherOrders.size(); i++) {
-            CloudTeacherOrder cloudTeacherOrder = cloudTeacherOrders.get(i);
-            if (cloudTeacherOrder.getStatus().equals(3)) {
-                throw new BizException("团练宝已退,请勿重复退");
-            }
-            if (cloudTeacherOrder.getStatus().equals(2) && DateUtil.stringToDate(DateUtil.format(cloudTeacherOrder.getEndTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT), DateUtil.ISO_EXPANDED_DATE_FORMAT).compareTo(
-                    DateUtil.stringToDate(DateUtil.format(nowDate, DateUtil.ISO_EXPANDED_DATE_FORMAT), DateUtil.ISO_EXPANDED_DATE_FORMAT)) < 0) {
-                throw new BizException("团练宝已过服务期,不可退费");
-            }
-            Integer oldStatus = cloudTeacherOrder.getStatus();
-            cloudTeacherOrder.setStatus(3);
-            if (i == 0) {
-                cloudTeacherOrder.setRefundAmount(refundAmount);
-            } else {
-                cloudTeacherOrder.setRefundAmount(BigDecimal.ZERO);
-            }
-            cloudTeacherOrder.setUpdateTime(nowDate);
-            if (cloudTeacherOrderDao.update(cloudTeacherOrder) <= 0) {
-                throw new BizException("团练宝退费处理失败,请重试");
-            }
-
-            if (oldStatus.equals(1)) {
-                continue;
-            }
-            int days = DateUtil.daysBetween(DateUtil.trunc(nowDate), cloudTeacherOrder.getEndTime());
-            CloudTeacher cloudTeacher = cloudTeacherDao.getByStudentId(cloudTeacherOrder.getStudentId());
-            if (cloudTeacher != null) {
-                Date endDate = DateUtil.addDays(cloudTeacherOrder.getEndTime(), -days);
-                cloudTeacher.setEndTime(endDate);
-                cloudTeacher.setUpdateTime(nowDate);
-                if (cloudTeacherDao.update(cloudTeacher) <= 0) {
-                    throw new BizException("团练宝服务有效期更新失败,请重试");
-                }
-            }
-        }
-        return true;
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public Boolean quitCloudTeacherOrder(CloudTeacherOrder cloudOrder, BigDecimal refundAmount) {
-        Date nowDate = new Date();
-        if (cloudOrder.getStatus().equals(3)) {
-            throw new BizException("团练宝已退,请勿重复退");
-        }
-        if (cloudOrder.getStatus().equals(2) && DateUtil.stringToDate(DateUtil.format(cloudOrder.getEndTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT), DateUtil.ISO_EXPANDED_DATE_FORMAT).compareTo(
-                DateUtil.stringToDate(DateUtil.format(nowDate, DateUtil.ISO_EXPANDED_DATE_FORMAT), DateUtil.ISO_EXPANDED_DATE_FORMAT)) < 0) {
-            throw new BizException("团练宝已过服务期,不可退费");
-        }
-        Integer oldStatus = cloudOrder.getStatus();
-        cloudOrder.setStatus(3);
-        cloudOrder.setRefundAmount(refundAmount);
-        cloudOrder.setUpdateTime(nowDate);
-        if (cloudTeacherOrderDao.update(cloudOrder) <= 0) {
-            throw new BizException("团练宝退费处理失败,请重试");
-        }
-
-        if (oldStatus.equals(1)) {
-            return true;
-        }
-        int days = DateUtil.daysBetween(DateUtil.trunc(nowDate), cloudOrder.getEndTime());
-        CloudTeacher cloudTeacher = cloudTeacherDao.getByStudentId(cloudOrder.getStudentId());
-        Date endDate = DateUtil.addDays(cloudOrder.getEndTime(), -days);
-        cloudTeacher.setEndTime(endDate);
-        cloudTeacher.setUpdateTime(nowDate);
-        if (cloudTeacherDao.update(cloudTeacher) <= 0) {
-            throw new BizException("团练宝服务有效期更新失败,请重试");
-        }
-        return true;
-    }
-
-    @Override
-    public CloudTeacherOrder queryByOrderId(Long orderId) {
-        return cloudTeacherOrderDao.queryByOrderId(orderId);
-    }
-
-    @Override
     public CloudTeacherOrderDto queryOrderInfoByOrderId(Long orderId) {
         return cloudTeacherOrderDao.queryOrderInfoByOrderId(orderId);
     }

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

@@ -457,7 +457,7 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
                 cloudTeacherOrder.setStudentId(coachPaymentDetails.getUserId());
                 cloudTeacherOrder.setOrganId(studentPaymentOrder.getOrganId());
                 cloudTeacherOrder.setAmount(studentPaymentOrder.getExpectAmount());
-                cloudTeacherOrderService.insert(cloudTeacherOrder);
+                cloudTeacherOrderService.save(cloudTeacherOrder,cloudCoachPaymentProgram.getAutoActivationFlag());
 
                 //修改缴费状态
                 coachPaymentDetails.setPaymentStatus(1);
@@ -515,76 +515,4 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
         userPhones.put(sysUser.getId(), sysUser.getPhone());
         sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.CLOUD_TEACHER_ORDER_SUCCESS, userPhones, null, 0, null, null);
     }
-
-    @Override
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-    public HttpResponseResult ActiveBuy(Integer userId, Integer memberRankId, PeriodEnum month, BigDecimal amount, boolean isUseBalance, Integer buyNum, int giveNum, int activeRemark, String remark, boolean repay) throws Exception {
-        HttpResponseResult result = new HttpResponseResult();
-        //判断用户是否已存在订单
-        StudentPaymentOrder applyOrder = studentPaymentOrderService.findByUserAndActive(userId, 202109, remark, "ING");
-        if (applyOrder != null) {
-            // 查询订单状态
-            PayStatus payStatus = studentPaymentOrderService.queryPayStatus(applyOrder.getPaymentChannel(), applyOrder.getOrderNo(), applyOrder.getTransNo());
-            if (payStatus == PayStatus.SUCCESSED) {
-                throw new BizException("订单已支付成功,请勿重复支付");
-            }/*else if(payStatus == PayStatus.PAYING){
-				throw new BizException("订单还在交易中,请稍后重试");
-			}*/
-            if (repay) {
-                //处理关闭订单
-                applyOrder.setStatus(DealStatusEnum.CLOSE);
-                applyOrder.setMemo("关闭团练宝活动订单");
-                if (applyOrder.getBalancePaymentAmount() != null && applyOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
-                    sysUserCashAccountService.updateBalance(applyOrder.getUserId(), applyOrder.getBalancePaymentAmount(),
-                            PlatformCashAccountDetailTypeEnum.REFUNDS, "购买团练宝活动支付失败");
-                }
-                studentPaymentOrderService.update(applyOrder);
-            } else {
-                result.setCode(HttpStatus.CONTINUE.value());
-                result.setMsg("您有待支付的订单");
-                return result;
-            }
-
-        }
-        result.setCode(HttpStatus.OK.value());
-        MemberPayParamDto memberPayParamDto = new MemberPayParamDto();
-//		memberPayParamDto.setMemberRankId(memberRankId);
-//		memberPayParamDto.setUserId(userId);
-//		memberPayParamDto.setPeriodEnum(month);
-//		memberPayParamDto.setUseBalance(isUseBalance);
-//		memberPayParamDto.setBuyNum(buyNum);
-//		memberPayParamDto.setGiveNum(giveNum);
-//		memberPayParamDto.setActiveRemark(activeRemark);
-//		memberPayParamDto.setRemark(remark);
-        memberPayParamDto.setAmount(amount);
-        return this.buy(memberPayParamDto);
-    }
-
-    //团练宝活动赠送优惠券
-    public void cloudTeacherActiveGiveCoupon(CloudTeacherOrder cloudTeacherOrder) {
-        Integer activeRemark = cloudTeacherOrder.getActiveRemark();
-        String remark = cloudTeacherOrder.getRemark();
-        if (activeRemark == null || StringUtils.isEmpty(remark)) {
-            return;
-        }
-        Integer studentId = cloudTeacherOrder.getStudentId();
-        SysUser sysUser = sysUserFeignService.queryUserById(studentId);
-        if (sysUser == null) {
-            throw new BizException("用户信息获取失败");
-        }
-        Integer couponId = 1;
-        if (sysUser.getOrganId() != null && sysUser.getOrganId() == 4) {
-            couponId = 2;
-        }
-        if (activeRemark.equals(202109)) {
-            switch (remark) {
-                case "2赠1":
-                    sysCouponCodeService.exchangeCoupon(cloudTeacherOrder.getStudentId(), couponId, cloudTeacherOrder.getOrderId(), 3, 2, null);
-                    break;
-                case "3赠2":
-                    sysCouponCodeService.exchangeCoupon(cloudTeacherOrder.getStudentId(), couponId, cloudTeacherOrder.getOrderId(), 6, 2, null);
-                    break;
-            }
-        }
-    }
 }

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

@@ -61,7 +61,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 	@Autowired
 	private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
 	@Autowired
-	private CloudTeacherOrderDao cloudTeacherOrderDao;
+	private CloudTeacherOrderService cloudTeacherOrderService;
 	@Autowired
 	private StudentPaymentOrderDao studentPaymentOrderDao;
 	@Autowired
@@ -269,7 +269,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 					cloudTeacherOrder.setStatus(1);
 					cloudTeacherOrder.setRemark("缴费项目0元新增学员");
 					cloudTeacherOrder.setMusicGroupId(musicGroupId);
-					cloudTeacherOrderDao.insert(cloudTeacherOrder);
+					cloudTeacherOrderService.save(cloudTeacherOrder,calenderMember.getAutoActivationFlag());
 				}
 				//添加小课包
 				if(calenderActivities != null && calenderActivities.size() > 0){

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

@@ -105,7 +105,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
     @Autowired
     private MemberRankPrivilegesService memberRankPrivilegesService;
     @Autowired
-    private CloudTeacherOrderDao cloudTeacherOrderDao;
+    private CloudTeacherOrderService cloudTeacherOrderService;
     @Autowired
     private MusicGroupPaymentCalenderActivityServiceImpl musicGroupPaymentCalenderActivityService;
     @Autowired
@@ -730,7 +730,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                         cloudTeacherOrder.setStatus(1);
                         cloudTeacherOrder.setRemark("进行中乐团0元加学生");
                         cloudTeacherOrder.setMusicGroupId(musicGroup.getId());
-                        cloudTeacherOrderDao.insert(cloudTeacherOrder);
+                        cloudTeacherOrderService.save(cloudTeacherOrder,calenderMember.getAutoActivationFlag());
                     }
                     //添加小课包
                     if (calenderActivities != null && calenderActivities.size() > 0) {

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

@@ -29,6 +29,7 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import com.ym.mec.biz.service.*;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -146,27 +147,6 @@ import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.PracticeGroupQueryInfo;
 import com.ym.mec.biz.dal.page.StudentBuyPracticeQueryInfo;
 import com.ym.mec.biz.dal.page.StudentQueryInfo;
-import com.ym.mec.biz.service.ActivityUserMapperService;
-import com.ym.mec.biz.service.ContractService;
-import com.ym.mec.biz.service.CourseScheduleService;
-import com.ym.mec.biz.service.CourseScheduleTeacherSalaryService;
-import com.ym.mec.biz.service.GroupClassService;
-import com.ym.mec.biz.service.ImUserFriendService;
-import com.ym.mec.biz.service.LuckDrawCountService;
-import com.ym.mec.biz.service.PayService;
-import com.ym.mec.biz.service.PracticeGroupService;
-import com.ym.mec.biz.service.StudentPaymentOrderService;
-import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
-import com.ym.mec.biz.service.StudentService;
-import com.ym.mec.biz.service.SysConfigService;
-import com.ym.mec.biz.service.SysCouponCodeService;
-import com.ym.mec.biz.service.SysMessageService;
-import com.ym.mec.biz.service.SysTenantConfigService;
-import com.ym.mec.biz.service.SysUserCashAccountDetailService;
-import com.ym.mec.biz.service.SysUserCashAccountLogService;
-import com.ym.mec.biz.service.SysUserCashAccountService;
-import com.ym.mec.biz.service.TeacherCourseRewardService;
-import com.ym.mec.biz.service.TeacherService;
 import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.dal.BaseDAO;
@@ -271,18 +251,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     @Autowired
     private ActivityUserMapperService activityUserMapperService;
     @Autowired
-    private MemberFeeSettingDao memberFeeSettingDao;
-    @Autowired
-    private CloudTeacherOrderDao cloudTeacherOrderDao;
-    @Autowired
-    private StudentService studentService;
-    @Autowired
     private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
     @Autowired
-    private RedisCache<String, Object> redisCache;
-    @Autowired
-    private LuckDrawCountService luckDrawCountService;
-    @Autowired
     private VipGroupDao vipGroupDao;
     @Autowired
     private VipGroupCategoryDao vipGroupCategoryDao;
@@ -306,8 +276,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 
     private static List<String> applyDayTimes = new ArrayList<>();
 
-    private static final Set<Integer> ENABLE_APPLY_ORGANIDS = new HashSet<>(Arrays.asList(new Integer[]{28, 34, 37}));
-
     static {
         applyStartDay = DateUtil.stringToDate("2020-03-25 00:00:00");
         activityStartDate = DateUtil.stringToDate("2020-03-25 00:00:00");
@@ -3540,305 +3508,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-    public void activityOrderCallback(StudentPaymentOrder studentPaymentOrder) {
-        Integer userId = studentPaymentOrder.getUserId();
-        StudentPaymentOrder order = studentPaymentOrderDao.lockOrder(studentPaymentOrder.getId());
-        if (!order.getStatus().equals(DealStatusEnum.ING)) {
-            return;
-        }
-        //更新订单状态
-        int updateCount = studentPaymentOrderService.update(studentPaymentOrder);
-        if (updateCount <= 0) {
-            throw new BizException("订单更新失败");
-        }
-        if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
-            Date now = new Date();
-            Student student = studentDao.get(order.getUserId());
-            Integer activityId = Integer.parseInt(order.getActivityId());
-            VipGroupActivity activity = vipGroupActivityDao.get(activityId);
-            ActivityUserMapper activityUserMapper = new ActivityUserMapper();
-            activityUserMapper.setActivityId(activityId);
-            activityUserMapper.setUserId(order.getUserId());
-            activityUserMapper.setPaymentOrderId(order.getId());
-            activityUserMapper.setTeacherId(student.getTeacherId());
-
-            if (activity.getActivityType() == 1) {
-                //会员立即生效
-                Integer cloudTeacherType;
-                PeriodEnum periodEnum = activity.getPeriodEnum();
-                Integer cloudTime = activity.getMemberTime();
-                CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
-//                Date addDate = now;
-//                if (student.getMemberRankSettingId() == null || now.after(student.getMembershipEndTime())) {
-//                    cloudTeacherOrder.setStartTime(now);
-//                } else {
-//                    addDate = student.getMembershipEndTime();
-//                    cloudTeacherOrder.setStartTime(DateUtil.addDays(addDate, 1));
-//                }
-//                cloudTeacherOrder.setEndTime(studentService.getMembershipEndTime(periodEnum, addDate, cloudTime));
-                cloudTeacherOrder.setRemark("营销活动购买会员");
-                cloudTeacherOrder.setStatus(1);
-                cloudTeacherOrder.setOrderId(order.getId());
-                cloudTeacherOrder.setType(periodEnum);
-                cloudTeacherOrder.setAmount(order.getActualAmount());
-                cloudTeacherOrder.setLevel(activity.getMemberRankId());
-                cloudTeacherOrder.setStudentId(userId);
-                cloudTeacherOrder.setOrganId(order.getOrganId());
-                cloudTeacherOrder.setTime(cloudTime);
-                cloudTeacherOrderDao.insert(cloudTeacherOrder);
-//                studentService.updateMemberRank(cloudTeacherOrder);
-                activityUserMapper.setMemberFlag(2);
-                activityUserMapper.setMemberOrderId(cloudTeacherOrder.getId());
-            } else {
-                if (activity.getCourseType().equals("VIP")) {
-                    activityUserMapper.setVipFlag(1);
-                } else {
-                    activityUserMapper.setPracticeFlag(1);
-                }
-                if (activity.isPayToBalance()) {
-                    boolean appendCourseBalance = sysUserCashAccountService.appendCourseBalance(userId, studentPaymentOrder.getExpectAmount(), PlatformCashAccountDetailTypeEnum.RECHARGE, "通用营销活动购买");
-                    if (!appendCourseBalance) {
-                        throw new BizException("增加用户课程余额失败");
-                    }
-                }
-            }
-            if (activity.getFullMinusCourseTimes() != -1 && order.getActivityBuyNum() >= activity.getFullMinusCourseTimes()) {
-                if (activity.getGiveMemberTime() > 0) {
-                    //会员立即生效
-                    Integer cloudTeacherType;
-                    PeriodEnum periodEnum = activity.getGivePeriodEnum();
-                    Integer cloudTime = activity.getGiveMemberTime();
-                    CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
-//                    Date addDate = now;
-//                    if (student.getMemberRankSettingId() == null || now.after(student.getMembershipEndTime())) {
-//                        cloudTeacherOrder.setStartTime(now);
-//                    } else {
-//                        addDate = student.getMembershipEndTime();
-//                        cloudTeacherOrder.setStartTime(DateUtil.addDays(addDate, 1));
-//                    }
-//                    cloudTeacherOrder.setEndTime(studentService.getMembershipEndTime(periodEnum, addDate, cloudTime));
-                    cloudTeacherOrder.setRemark("营销活动赠送会员");
-                    cloudTeacherOrder.setStatus(1);
-                    cloudTeacherOrder.setOrderId(order.getId());
-                    cloudTeacherOrder.setType(periodEnum);
-                    cloudTeacherOrder.setAmount(BigDecimal.ZERO);
-                    cloudTeacherOrder.setLevel(activity.getGiveMemberRankId());
-                    cloudTeacherOrder.setStudentId(userId);
-                    cloudTeacherOrder.setOrganId(order.getOrganId());
-                    cloudTeacherOrder.setTime(cloudTime);
-                    cloudTeacherOrderDao.insert(cloudTeacherOrder);
-//                    studentService.updateMemberRank(cloudTeacherOrder);
-                    activityUserMapper.setGiveMemberFlag(2);
-                    activityUserMapper.setGiveMemberOrderId(cloudTeacherOrder.getId());
-                } else if (activity.getGiveCourseNum() > 0) {
-                    if (activity.getGiveCourseType().equals("VIP")) {
-                        activityUserMapper.setGiveVipFlag(1);
-                    } else {
-                        activityUserMapper.setGivePracticeFlag(1);
-                    }
-                }
-            }
-            activityUserMapperService.insert(activityUserMapper);
-            SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(userId);
-            //插入缴费明细
-            //收入
-            SysUserCashAccountDetail sysUserIncomeCashAccountDetail = new SysUserCashAccountDetail();
-            sysUserIncomeCashAccountDetail.setUserId(order.getUserId());
-            sysUserIncomeCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
-            sysUserIncomeCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-            sysUserIncomeCashAccountDetail.setAmount(order.getActualAmount());
-            sysUserIncomeCashAccountDetail.setBalance(sysUserCashAccount.getBalance().add(order.getActualAmount()));
-            sysUserIncomeCashAccountDetail.setAttribute(order.getTransNo());
-            sysUserIncomeCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
-            sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount());
-            sysUserIncomeCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount());
-            //支出
-            SysUserCashAccountDetail sysUserExpendCashAccountDetail = new SysUserCashAccountDetail();
-            sysUserExpendCashAccountDetail.setUserId(order.getUserId());
-            sysUserExpendCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
-            sysUserExpendCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-            sysUserExpendCashAccountDetail.setAmount(order.getActualAmount().negate());
-            sysUserExpendCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
-            sysUserExpendCashAccountDetail.setAttribute(order.getTransNo());
-            sysUserExpendCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
-
-            if (studentPaymentOrder.getComAmount() != null) {
-                sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
-            }
-            if (studentPaymentOrder.getPerAmount() != null) {
-                sysUserExpendCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
-            }
-
-            sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
-            sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);
-
-//            try {
-//                contractService.transferPracticeCoursesContract(order.getUserId(), classGroup.getTotalClassTimes(), practiceGroup.getCoursesStartDate(), practiceGroup.getCoursesExpireDate(), order.getExpectAmount());
-//            } catch (Exception e) {
-//                LOGGER.error(MessageFormatter.arrayFormat("网管课[{}]购买协议错误:{}", order.getMusicGroupId(), e.getMessage()), e);
-//            }
-            studentDao.updateStudentServiceTag(userId, null, YesOrNoEnum.YES.getCode());
-        }
-        if (studentPaymentOrder.getStatus().equals(DealStatusEnum.FAILED)) {
-            if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
-                sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "报名缴费失败");
-            }
-            sysCouponCodeService.quit(studentPaymentOrder.getCouponCodeId());
-        }
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-    public void doubleEleven2021OrderCallback(StudentPaymentOrder studentPaymentOrder) {
-        Integer userId = studentPaymentOrder.getUserId();
-        StudentPaymentOrder order = studentPaymentOrderDao.lockOrder(studentPaymentOrder.getId());
-        if (!order.getStatus().equals(DealStatusEnum.ING)) {
-            return;
-        }
-        //更新订单状态
-        int updateCount = studentPaymentOrderService.update(studentPaymentOrder);
-        if (updateCount <= 0) {
-            throw new BizException("订单更新失败");
-        }
-        if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
-            Date now = new Date();
-            Student student = studentDao.get(order.getUserId());
-            List<VipGroupActivity> vipGroupActivities = vipGroupActivityDao.queryByIds(order.getActivityId());
-            List<ActivityUserMapper> activityUserMappers = new ArrayList<>();
-            Integer times = 0;
-
-            BigDecimal couponRemitFee = order.getCouponRemitFee();
-            BigDecimal subCouponRemitFee = couponRemitFee;
-            BigDecimal totalMarketPrice = vipGroupActivities.stream().map(e -> e.getMarketPrice()).reduce(ZERO, BigDecimal::add);
-
-            String startTimeStr = sysConfigDao.findConfigValue("2021_double_eleven_give_member_start_time");
-            Date startTime = DateUtil.stringToDate(startTimeStr);
-            String endTimeStr = sysConfigDao.findConfigValue("2021_double_eleven_give_member_end_time");
-            Date endTime = DateUtil.stringToDate(endTimeStr);
-            for (int i = 0; i < vipGroupActivities.size(); i++) {
-                VipGroupActivity activity = vipGroupActivities.get(i);
-                ActivityUserMapper activityUserMapper = new ActivityUserMapper();
-                activityUserMapper.setActivityId(activity.getId());
-                activityUserMapper.setUserId(order.getUserId());
-                activityUserMapper.setPaymentOrderId(order.getId());
-                activityUserMapper.setTeacherId(student.getTeacherId());
-                activityUserMapper.setVipFlag(1);
-                if (couponRemitFee.compareTo(ZERO) > 0) {
-                    if (i == vipGroupActivities.size() - 1) {
-                        activityUserMapper.setActualPrice(activity.getMarketPrice().subtract(subCouponRemitFee));
-                    } else {
-                        //获取比例
-                        BigDecimal ratioAmount = activity.getMarketPrice().divide(totalMarketPrice, 6, BigDecimal.ROUND_HALF_UP);
-                        //获取分配的减免金额
-                        BigDecimal multiply = ratioAmount.multiply(couponRemitFee).setScale(2, BigDecimal.ROUND_HALF_UP);
-                        subCouponRemitFee = subCouponRemitFee.subtract(multiply);
-                        activityUserMapper.setActualPrice(activity.getMarketPrice().subtract(multiply));
-                    }
-                } else {
-                    activityUserMapper.setActualPrice(activity.getMarketPrice());
-                }
-                activityUserMappers.add(activityUserMapper);
-                times = times + activity.getGivePrizeNum();
-                //是否进入课程余额
-                if (activity.isPayToBalance()) {
-                    boolean appendCourseBalance = sysUserCashAccountService.appendCourseBalance(userId, activityUserMapper.getActualPrice(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "2021双11活动");
-                    if (!appendCourseBalance) {
-                        throw new BizException("增加用户课程余额失败");
-                    }
-                }
-                if (!activity.getCode().equals(5)) {
-                    if (order.getCreateTime().compareTo(startTime) >= 0 && order.getCreateTime().compareTo(endTime) <= 0) {
-                        //赠送一次抽奖机会
-                        luckDrawCountService.freeGive(order.getUserId().longValue(), 1, 2);
-                    }
-                }
-            }
-            //赠送抽奖机会
-            if (times > 0) {
-                luckDrawCountService.freeGive(order.getUserId().longValue(), times, 2);
-            }
-            activityUserMapperService.batchInsert(activityUserMappers);
-
-            SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(userId);
-            //插入缴费明细
-            //收入
-            SysUserCashAccountDetail sysUserIncomeCashAccountDetail = new SysUserCashAccountDetail();
-            sysUserIncomeCashAccountDetail.setUserId(order.getUserId());
-            sysUserIncomeCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
-            sysUserIncomeCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-            sysUserIncomeCashAccountDetail.setAmount(order.getActualAmount());
-            sysUserIncomeCashAccountDetail.setBalance(sysUserCashAccount.getBalance().add(order.getActualAmount()));
-            sysUserIncomeCashAccountDetail.setAttribute(order.getTransNo());
-            sysUserIncomeCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
-            sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount());
-            sysUserIncomeCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount());
-            //支出
-            SysUserCashAccountDetail sysUserExpendCashAccountDetail = new SysUserCashAccountDetail();
-            sysUserExpendCashAccountDetail.setUserId(order.getUserId());
-            sysUserExpendCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
-            sysUserExpendCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-            sysUserExpendCashAccountDetail.setAmount(order.getActualAmount().negate());
-            sysUserExpendCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
-            sysUserExpendCashAccountDetail.setAttribute(order.getTransNo());
-            sysUserExpendCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
-
-            if (studentPaymentOrder.getComAmount() != null) {
-                sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
-            }
-            if (studentPaymentOrder.getPerAmount() != null) {
-                sysUserExpendCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
-            }
-
-            sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
-            sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);
-
-            try {
-                contractService.transferProduceContract(userId, null, null);
-            } catch (Exception e) {
-                LOGGER.error("产品协议生成失败", e);
-            }
-            studentDao.updateStudentServiceTag(userId, null, YesOrNoEnum.YES.getCode());
-            //是否指定满足赠送会员的条件
-            //是否赠送过会员
-            String memberKey = "2021_double_eleven" + order.getUserId();
-            Boolean aBoolean = redisCache.exists(memberKey);
-            if (!aBoolean) {
-                if (order.getCreateTime().compareTo(startTime) >= 0 && order.getCreateTime().compareTo(endTime) <= 0) {
-                    //赠送会员
-                    CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
-//                    Date addDate = now;
-//                    if (student.getMemberRankSettingId() == null || now.after(student.getMembershipEndTime())) {
-//                        cloudTeacherOrder.setStartTime(now);
-//                    } else {
-//                        addDate = student.getMembershipEndTime();
-//                        cloudTeacherOrder.setStartTime(DateUtil.addDays(addDate, 1));
-//                    }
-//                    cloudTeacherOrder.setEndTime(DateUtil.addDays(DateUtil.addMonths(addDate, 1), 1));
-                    cloudTeacherOrder.setRemark("双十一活动赠送会员");
-                    cloudTeacherOrder.setStatus(1);
-                    cloudTeacherOrder.setOrderId(order.getId());
-                    cloudTeacherOrder.setType(PeriodEnum.MONTH);
-                    cloudTeacherOrder.setAmount(BigDecimal.ZERO);
-                    cloudTeacherOrder.setLevel(1);
-                    cloudTeacherOrder.setStudentId(userId);
-                    cloudTeacherOrder.setOrganId(order.getOrganId());
-                    cloudTeacherOrder.setTime(1);
-                    cloudTeacherOrderDao.insert(cloudTeacherOrder);
-//                    studentService.updateMemberRank(cloudTeacherOrder);
-                    redisCache.put(memberKey, userId);
-                }
-            }
-        }
-        if (studentPaymentOrder.getStatus().equals(DealStatusEnum.FAILED)) {
-            if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
-                sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "报名缴费失败");
-            }
-            sysCouponCodeService.quit(studentPaymentOrder.getCouponCodeId());
-        }
-    }
-
-    @Override
     public List<PracticeCourseDto> findUserHistoryBuyPracticeGroups(Integer userId, Long groupId, PracticeGroupType type) {
         List<PracticeCourseDto> userPracticeGroups;
         if (Objects.nonNull(groupId)) {
@@ -5017,173 +4686,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     }
 
     @Override
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-    public Object buyActivityPracticeGroup(PracticeGroupBuyParamsDto practiceGroupBuyParams) throws Exception {
-        Integer activityId = practiceGroupBuyParams.getActivityId();
-        VipGroupActivity activity = vipGroupActivityDao.get(activityId);
-        Date now = new Date();
-        Date startTime = activity.getStartTime();
-        Date endTime = activity.getEndTime();
-        if (startTime != null && startTime.compareTo(now) > 0) {
-            throw new BizException("活动尚未开始,感谢您的关注");
-        }
-        if (endTime != null && endTime.compareTo(now) <= 0) {
-            throw new BizException("活动已结束,感谢您的参与");
-        }
-        Student student = studentDao.getLocked(practiceGroupBuyParams.getUserId());
-        Integer studentMaxUsedTimes = activity.getStudentMaxUsedTimes();
-        if (studentMaxUsedTimes != -1) {
-            //获取活动购买次数
-            int activityBuyNum = activityUserMapperService.countActivityBuyNum(activityId, practiceGroupBuyParams.getUserId());
-            if (activityBuyNum >= studentMaxUsedTimes) {
-                throw new BizException("当前活动最多课购买{}次,感谢您的参与", studentMaxUsedTimes);
-            }
-        }
-        GroupType groupType;
-        Integer buyNum = activity.getMinCourseNum();
-        if (activity.getActivityType() == 1) {
-            buyNum = practiceGroupBuyParams.getBuyMemberNum();
-            groupType = GroupType.MEMBER;
-        } else {
-            if (activity.getCourseType().equals("VIP")) {
-                groupType = GroupType.VIP;
-            } else {
-                groupType = GroupType.PRACTICE;
-            }
-        }
-
-        //判断用户是否已存在订单
-        // 判断是否存在支付中的记录
-        List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(groupType, null, student.getUserId(), DealStatusEnum.ING, OrderTypeEnum.ACTIVITY);
-        if (list.size() > 0) {
-            StudentPaymentOrder order = list.get(0);
-            // 查询订单状态
-            PayStatus payStatus = studentPaymentOrderService.queryPayStatus(order.getPaymentChannel(), order.getOrderNo(), order.getTransNo());
-            if (payStatus == PayStatus.SUCCESSED) {
-                throw new BizException("订单已支付成功,请勿重复支付");
-            }/*else if(payStatus == PayStatus.PAYING){
-                throw new BizException("订单还在交易中,请稍后重试");
-            }*/
-            if (practiceGroupBuyParams.isRepeatPay()) {
-                //处理关闭订单
-                order.setStatus(DealStatusEnum.CLOSE);
-                order.setMemo("关闭活动订单");
-                if (order.getBalancePaymentAmount() != null && order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
-                    sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(),
-                            PlatformCashAccountDetailTypeEnum.REFUNDS, "购买活动支付失败");
-                }
-                studentPaymentOrderService.update(order);
-                sysCouponCodeService.quit(order.getCouponCodeId());
-            } else {
-                return BaseController.failed(HttpStatus.CONTINUE, "您有待支付的订单");
-            }
-        }
-        BigDecimal activityFee = activity.getMarketPrice();
-        if (groupType == GroupType.MEMBER) {
-            MemberFeeSetting memberFeeSetting = memberFeeSettingDao.findByRankIdAndOrganId(practiceGroupBuyParams.getOrganId(), 1);
-            PeriodEnum periodEnum = activity.getPeriodEnum();
-            switch (periodEnum) {
-                case DAY:
-                    activityFee = memberFeeSetting.getCurrentDayFee().multiply(new BigDecimal(buyNum));
-                    break;
-                case MONTH:
-                    activityFee = memberFeeSetting.getCurrentMonthFee().multiply(new BigDecimal(buyNum));
-                    break;
-                case QUARTERLY:
-                    activityFee = memberFeeSetting.getCurrentQuarterlyFee().multiply(new BigDecimal(buyNum));
-                    break;
-                case YEAR_HALF:
-                    activityFee = memberFeeSetting.getCurrentHalfYearFee().multiply(new BigDecimal(buyNum));
-                    break;
-                case YEAR:
-                    activityFee = memberFeeSetting.getCurrentYearFee().multiply(new BigDecimal(buyNum));
-                    break;
-                default:
-                    throw new BizException("错误的会员周期");
-            }
-            activityFee = activityFee.multiply(activity.getDiscount()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, ROUND_DOWN);
-        }
-        //计算订单金额
-        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(practiceGroupBuyParams.getCouponIdList(), activityFee, true);
-        activityFee = studentPaymentOrder.getActualAmount();
-        if (practiceGroupBuyParams.getAmount().compareTo(activityFee) != 0) {
-            throw new BizException("非法访问");
-        }
-
-        String channelType = "";
-        Date nowDate = new Date();
-
-        BigDecimal balance = BigDecimal.ZERO;
-        if (practiceGroupBuyParams.isUseBalancePayment() && activityFee.compareTo(BigDecimal.ZERO) > 0) {
-            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(student.getUserId());
-            if (userCashAccount == null) {
-                throw new BizException("用户账户找不到");
-            }
-            if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
-                balance = activityFee.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : activityFee;
-                activityFee = activityFee.subtract(balance);
-                studentPaymentOrder.setActualAmount(activityFee);
-                studentPaymentOrder.setBalancePaymentAmount(balance);
-                sysUserCashAccountService.updateBalance(student.getUserId(), balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "营销活动购买");
-            }
-        }
-
-        String orderNo = idGeneratorService.generatorId("payment") + "";
-
-        studentPaymentOrder.setPaymentChannel("BALANCE");
-        studentPaymentOrder.setUserId(student.getUserId());
-        studentPaymentOrder.setGroupType(groupType);
-        studentPaymentOrder.setOrderNo(orderNo);
-        studentPaymentOrder.setType(OrderTypeEnum.ACTIVITY);
-        studentPaymentOrder.setStatus(DealStatusEnum.ING);
-        studentPaymentOrder.setRemitFee(BigDecimal.ZERO);
-        studentPaymentOrder.setCourseRemitFee(BigDecimal.ZERO);
-        studentPaymentOrder.setOrganId(practiceGroupBuyParams.getOrganId());
-        studentPaymentOrder.setRoutingOrganId(practiceGroupBuyParams.getOrganId());
-        studentPaymentOrder.setCreateTime(nowDate);
-        studentPaymentOrder.setUpdateTime(nowDate);
-        studentPaymentOrder.setActivityId(activityId.toString());
-        studentPaymentOrder.setActivityBuyNum(buyNum);
-        studentPaymentOrderService.insert(studentPaymentOrder);
-
-        studentPaymentOrder.setVersion(0);
-        if (activityFee.compareTo(BigDecimal.ZERO) == 0) {
-            studentPaymentRouteOrderService.addRouteOrder(orderNo, practiceGroupBuyParams.getOrganId(), balance);
-            Map<String, String> notifyMap = new HashMap<>();
-            notifyMap.put("tradeState", "1");
-            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
-            notifyMap.put("channelType", channelType);
-            notifyMap.put("orderNo", "");
-            studentPaymentOrderService.updateOrder(notifyMap);
-            return notifyMap;
-        }
-
-        String orderSubject = "营销活动";
-        String receiver = "activity";
-
-        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
-
-        Map payMap = payService.getPayMap(
-                activityFee,
-                balance,
-                orderNo,
-                baseApiUrl + "/api-student/studentOrder/notify",
-                baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
-                orderSubject,
-                orderSubject,
-                studentPaymentOrder.getOrganId(),
-                receiver
-        );
-
-        studentPaymentOrder.setOrganId(studentPaymentOrder.getOrganId());
-        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
-        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
-        studentPaymentOrder.setUpdateTime(nowDate);
-        studentPaymentOrderService.update(studentPaymentOrder);
-        return payMap;
-    }
-
-    @Override
     public StudentVipGroupDetailDto getPracticeGroupDetail(Long groupId) {
         return practiceGroupDao.getPracticeGroupDetail(groupId);
     }
@@ -5213,137 +4715,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     }
 
     @Override
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-    public HttpResponseResult buyDoubleEleven2021(BuyDoubleEleven2021Dto buyDoubleEleven2021Dto) throws Exception {
-        String activityIdList = buyDoubleEleven2021Dto.getActivityIdList();
-        List<VipGroupActivity> vipGroupActivities = vipGroupActivityDao.queryByIds(activityIdList);
-        Date now = new Date();
-        Student student = studentDao.getLocked(buyDoubleEleven2021Dto.getUserId());
-        BigDecimal activityFee = ZERO;
-        for (int i = 0; i < vipGroupActivities.size(); i++) {
-            VipGroupActivity activity = vipGroupActivities.get(i);
-            Date startTime = activity.getStartTime();
-            Date endTime = activity.getEndTime();
-            if (startTime != null && startTime.compareTo(now) > 0) {
-                throw new BizException("活动尚未开始,感谢您的关注");
-            }
-            if (endTime != null && endTime.compareTo(now) <= 0) {
-                throw new BizException("活动已结束,感谢您的参与");
-            }
-            Integer studentMaxUsedTimes = activity.getStudentMaxUsedTimes();
-            if (studentMaxUsedTimes != -1) {
-                //获取活动购买次数
-                int activityBuyNum = activityUserMapperService.countActivityBuyNum(activity.getId(), buyDoubleEleven2021Dto.getUserId());
-                if (activityBuyNum >= studentMaxUsedTimes) {
-                    throw new BizException("{}活动最多课购买{}次,感谢您的参与", activity.getName(), studentMaxUsedTimes);
-                }
-            }
-            activityFee = activityFee.add(activity.getMarketPrice());
-        }
-
-        //判断用户是否已存在订单
-        // 判断是否存在支付中的记录
-        List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.ACTIVITY, null, student.getUserId(), DealStatusEnum.ING, OrderTypeEnum.DOUBLE_ELEVEN2021);
-        if (list.size() > 0) {
-            StudentPaymentOrder order = list.get(0);
-            // 查询订单状态
-            PayStatus payStatus = studentPaymentOrderService.queryPayStatus(order.getPaymentChannel(), order.getOrderNo(), order.getTransNo());
-            if (payStatus == PayStatus.SUCCESSED) {
-                throw new BizException("订单已支付成功,请勿重复支付");
-            }/*else if(payStatus == PayStatus.PAYING){
-                throw new BizException("订单还在交易中,请稍后重试");
-            }*/
-            if (buyDoubleEleven2021Dto.isRepeatPay()) {
-                //处理关闭订单
-                order.setStatus(DealStatusEnum.CLOSE);
-                order.setMemo("关闭2021双十一活动订单");
-                if (order.getBalancePaymentAmount() != null && order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
-                    sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(),
-                            PlatformCashAccountDetailTypeEnum.REFUNDS, "2021双十一活动支付失败");
-                }
-                studentPaymentOrderService.update(order);
-                sysCouponCodeService.quit(order.getCouponCodeId());
-            } else {
-                return BaseController.failed(HttpStatus.CONTINUE, "您有待支付的订单,是否继续支付");
-            }
-        }
-        //计算订单金额
-        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(buyDoubleEleven2021Dto.getCouponIdList(), activityFee, true);
-        activityFee = studentPaymentOrder.getActualAmount();
-
-        String channelType = "";
-        Date nowDate = new Date();
-
-        BigDecimal balance = BigDecimal.ZERO;
-        if (buyDoubleEleven2021Dto.isUseBalancePayment() && activityFee.compareTo(BigDecimal.ZERO) > 0) {
-            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(student.getUserId());
-            if (userCashAccount == null) {
-                throw new BizException("用户账户找不到");
-            }
-            if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
-                balance = activityFee.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : activityFee;
-                activityFee = activityFee.subtract(balance);
-                studentPaymentOrder.setActualAmount(activityFee);
-                studentPaymentOrder.setBalancePaymentAmount(balance);
-                sysUserCashAccountService.updateBalance(student.getUserId(), balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "2021双十一活动购买");
-            }
-        }
-
-        String orderNo = idGeneratorService.generatorId("payment") + "";
-
-        studentPaymentOrder.setPaymentChannel("BALANCE");
-        studentPaymentOrder.setUserId(student.getUserId());
-        studentPaymentOrder.setGroupType(GroupType.ACTIVITY);
-        studentPaymentOrder.setOrderNo(orderNo);
-        studentPaymentOrder.setType(OrderTypeEnum.DOUBLE_ELEVEN2021);
-        studentPaymentOrder.setStatus(DealStatusEnum.ING);
-        studentPaymentOrder.setRemitFee(BigDecimal.ZERO);
-        studentPaymentOrder.setCourseRemitFee(BigDecimal.ZERO);
-        studentPaymentOrder.setOrganId(buyDoubleEleven2021Dto.getOrganId());
-        studentPaymentOrder.setRoutingOrganId(buyDoubleEleven2021Dto.getOrganId());
-        studentPaymentOrder.setActivityId(activityIdList);
-        studentPaymentOrder.setCreateTime(nowDate);
-        studentPaymentOrder.setUpdateTime(nowDate);
-        studentPaymentOrderService.insert(studentPaymentOrder);
-
-        studentPaymentOrder.setVersion(0);
-        if (activityFee.compareTo(BigDecimal.ZERO) == 0) {
-            studentPaymentRouteOrderService.addRouteOrder(orderNo, buyDoubleEleven2021Dto.getOrganId(), balance);
-            Map<String, String> notifyMap = new HashMap<>();
-            notifyMap.put("tradeState", "1");
-            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
-            notifyMap.put("channelType", channelType);
-            notifyMap.put("orderNo", "");
-            studentPaymentOrderService.updateOrder(notifyMap);
-            return BaseController.failed(HttpStatus.CREATED, notifyMap, "恭喜您,购买成功!");
-        }
-
-        String orderSubject = "2021双十一活动";
-        String receiver = "vip";
-
-        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
-
-        Map payMap = payService.getPayMap(
-                activityFee,
-                balance,
-                orderNo,
-                baseApiUrl + "/api-student/studentOrder/notify",
-                baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
-                orderSubject,
-                orderSubject,
-                studentPaymentOrder.getOrganId(),
-                receiver
-        );
-
-        studentPaymentOrder.setOrganId(studentPaymentOrder.getOrganId());
-        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
-        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
-        studentPaymentOrder.setUpdateTime(nowDate);
-        studentPaymentOrderService.update(studentPaymentOrder);
-        return BaseController.succeed(payMap);
-    }
-
-    @Override
     public Map<String, BigDecimal> getStudentSurplusCourseFee(Long practiceGroupId) {
         if (Objects.isNull(practiceGroupId)) {
             throw new BizException("请指定课程");

+ 3 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -107,6 +107,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
     @Autowired
     private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private TenantConfigService tenantConfigService;
 
     @Override
     public BaseDAO<Long, StudentPaymentOrder> getDAO() {
@@ -493,10 +495,6 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         } else if (order.getType().equals(OrderTypeEnum.MEMBER)) {
             //购买团练宝
             memberRankSettingService.orderCallback(order);
-        } else if (order.getType().equals(OrderTypeEnum.ACTIVITY)) {
-            practiceGroupService.activityOrderCallback(order);
-        } else if (order.getType().equals(OrderTypeEnum.DOUBLE_ELEVEN2021)) {
-            practiceGroupService.doubleEleven2021OrderCallback(order);
         }
     }
 
@@ -764,20 +762,9 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                 cloudTeacherOrder.setStudentId(studentPaymentOrder.getUserId());
                 cloudTeacherOrder.setType(activity.getGivePeriodEnum());
                 cloudTeacherOrder.setOrganId(studentPaymentOrder.getOrganId());
-
-//                Student student = studentService.get(studentPaymentOrder.getUserId());
-//                Date startDate = now;
-//                if (student.getMemberRankSettingId() == null || now.after(student.getMembershipEndTime())) {
-//                    cloudTeacherOrder.setStartTime(now);
-//                } else {
-//                    cloudTeacherOrder.setStartTime(DateUtil.addDays(student.getMembershipEndTime(), 1));
-//                    startDate = student.getMembershipEndTime();
-//                }
-//                cloudTeacherOrder.setEndTime(studentService.getMembershipEndTime(activity.getGivePeriodEnum(), startDate, activity.getGiveMemberTime()));
                 cloudTeacherOrder.setTime(activity.getGiveMemberTime());
-                cloudTeacherOrderService.insert(cloudTeacherOrder);
+                cloudTeacherOrderService.save(cloudTeacherOrder,tenantConfigService.autoActivationFlag(teacherId));
                 // 添加会员有效时长
-//                studentService.updateMemberRank(cloudTeacherOrder);
                 activityUserMapper.setGiveMemberFlag(2);
                 activityUserMapper.setGiveMemberOrderId(cloudTeacherOrder.getId());
             }

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantConfigServiceImpl.java

@@ -78,6 +78,21 @@ public class TenantConfigServiceImpl extends ServiceImpl<TenantConfigDao, Tenant
                 .orElse(null);
     }
 
+    @Override
+    public Boolean autoActivationFlag(Integer tenantId) {
+        TenantConfig tenantConfig = this.getOne(new WrapperUtil<TenantConfig>()
+                .hasEq("tenant_id_", tenantId).queryWrapper());
+        TenantConfigDetail configDetail = JSON.parseObject(tenantConfig.getConfig(), TenantConfigDetail.class);
+        TenantConfigDetail.MemberConfig memberConfig = configDetail.getMember_config();
+        if(memberConfig.getMonth_divide().compareTo(BigDecimal.ZERO) == 0 &&
+                memberConfig.getHalf_year_divide().compareTo(BigDecimal.ZERO) == 0 &&
+                memberConfig.getQuarter_divide().compareTo(BigDecimal.ZERO) == 0 &&
+                memberConfig.getYear_divide().compareTo(BigDecimal.ZERO) == 0){
+            return true;
+        }
+        return false;
+    }
+
     private void setUserId(Integer id, Consumer<Integer> setOption) {
         if (Objects.isNull(id)) {
             Integer userId = Optional.ofNullable(sysUserFeignService.queryUserInfo())

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

@@ -209,15 +209,9 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
         record.setPayTime(now);
         updateById(record);
         List<CloudTeacherOrder> cloudTeacherOrders = cloudTeacherOrderDao.findByPlatformOrderId(record.getId());
-        Date startTime = DateUtil.trunc(now);
-        Date endTime = now;
         for (CloudTeacherOrder cto : cloudTeacherOrders) {
-            endTime = cloudTeacherOrderService.calcCloudTeacherOrderTime(cto, startTime, endTime);
-            cto.setStartTime(startTime);
-            cto.setEndTime(endTime);
-            cto.setStatus(2);
-            cloudTeacherOrderDao.update(cto);
-            studentService.updateMemberRank(cto.getStudentId(), cto.getType(), cto.getTime(), 1);
+            //激活团练宝
+            cloudTeacherOrderService.activationMember(now,cto);
         }
         //发信息
         cloudTeacherOrderService.sendSms(record);

+ 6 - 2
mec-biz/src/main/resources/config/mybatis/CloudCoachPaymentProgramMapper.xml

@@ -27,6 +27,7 @@
 		<result column="audit_time_" property="auditTime" />
 		<result column="organ_id_" property="organId" />
 		<result column="organ_name_" property="organName" />
+		<result column="auto_activation_flag_" property="autoActivationFlag" />
 		<result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 	</resultMap>
 	
@@ -44,10 +45,10 @@
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CloudCoachPaymentProgram" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO cloud_coach_payment_program (name_,remark_,member_num_,user_num_,
 		payment_user_num_,period_,member_rank_setting_id_,actual_amount_,original_amount_,
-		operator_,create_time_,update_time_,tenant_id_,memo_,status_,organ_id_)
+		operator_,create_time_,update_time_,tenant_id_,memo_,status_,organ_id_,auto_activation_flag_)
 		VALUES(#{name},#{remark},#{memberNum},#{userNum},#{paymentUserNum},#{period,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 		#{memberRankSettingId},#{actualAmount},#{originalAmount},#{operator},
-		NOW(),NOW(),#{tenantId},#{memo},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{organId})
+		NOW(),NOW(),#{tenantId},#{memo},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{organId},#{autoActivationFlag})
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -56,6 +57,9 @@
 		<if test="status != null">
 			status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 		</if>
+		<if test="autoActivationFlag != null">
+			auto_activation_flag_ = #{autoActivationFlag},
+		</if>
 		<if test="memo != null">
 			memo_ = #{memo},
 		</if>

+ 6 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMemberMapper.xml

@@ -19,6 +19,7 @@
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
         <result column="tenant_id_" property="tenantId"/>
+        <result column="auto_activation_flag_" property="autoActivationFlag"/>
 	</resultMap>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -34,9 +35,9 @@
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderMember" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO music_group_payment_calender_member (calender_id_,name_,num_,period_,
-		member_rank_setting_id_,optional_flag_,actual_amount_,original_amount_,create_time_,update_time_,tenant_id_)
+		member_rank_setting_id_,optional_flag_,actual_amount_,original_amount_,create_time_,update_time_,tenant_id_,auto_activation_flag_)
 		VALUES(#{calenderId},#{name},#{num},#{period,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{memberRankSettingId},#{optionalFlag},#{actualAmount},
-		       #{originalAmount},NOW(),NOW(),#{tenantId})
+		       #{originalAmount},NOW(),NOW(),#{tenantId},#{autoActivationFlag})
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -51,6 +52,9 @@
 		<if test="num != null">
 		num_ = #{num},
 		</if>
+		<if test="autoActivationFlag != null">
+			auto_activation_flag_ = #{autoActivationFlag},
+		</if>
 		<if test="calenderId != null">
 		calender_id_ = #{calenderId},
 		</if>

+ 2 - 28
mec-student/src/main/java/com/ym/mec/student/controller/ActivityController.java

@@ -10,11 +10,8 @@ import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
 import com.ym.mec.biz.service.MarketActivityService;
 import com.ym.mec.biz.service.PracticeGroupService;
 import com.ym.mec.biz.service.SporadicChargeInfoService;
-import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
-import com.ym.mec.common.exception.BizException;
-import com.ym.mec.util.date.DateUtil;
 import com.yonge.log.model.AuditLogAnnotation;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -36,10 +33,6 @@ public class ActivityController extends BaseController {
     @Autowired
     private MarketActivityService marketActivityService;
     @Autowired
-    private PracticeGroupService practiceGroupService;
-    @Autowired
-    private SysConfigDao sysConfigDao;
-    @Autowired
     private StudentPaymentOrderDao studentPaymentOrderDao;
 
     @ApiOperation(value = "分部双11活动信息")
@@ -96,27 +89,8 @@ public class ActivityController extends BaseController {
     @PostMapping(value = "/buyDoubleEleven2021")
     @AuditLogAnnotation(operateName = "2021双十一活动购买")
     public HttpResponseResult buyDoubleEleven2021(@RequestBody BuyDoubleEleven2021Dto buyDoubleEleven2021Dto) throws Exception {
-        Date nowTime = new Date();
-        String startTimeStr = sysConfigDao.findConfigValue(SysConfigService.START_TIME_OF_1111);
-        Date startTime = DateUtil.stringToDate(startTimeStr);
-        if (startTime.compareTo(nowTime) > 0) {
-            throw new BizException("活动还未开始,谢谢关注");
-        }
-        String endTimeStr = sysConfigDao.findConfigValue(SysConfigService.END_TIME_OF_1111);
-        Date endTime = DateUtil.stringToDate(endTimeStr);
-        if (endTime.compareTo(nowTime) <= 0) {
-            throw new BizException("活动已结束,谢谢关注");
-        }
-        SysUser sysUser = sysUserFeignService.queryUserInfo();
-        if (sysUser == null) {
-            return failed(HttpStatus.FORBIDDEN, "请登录");
-        }
-        if(StringUtils.isEmpty(buyDoubleEleven2021Dto.getActivityIdList())){
-            throw new BizException("请选择活动");
-        }
-        buyDoubleEleven2021Dto.setOrganId(sysUser.getOrganId());
-        buyDoubleEleven2021Dto.setUserId(sysUser.getId());
-        return practiceGroupService.buyDoubleEleven2021(buyDoubleEleven2021Dto);
+//        return practiceGroupService.buyDoubleEleven2021(buyDoubleEleven2021Dto);
+        return failed("购买入口已关闭,请联系管理员");
     }
 
     @ApiOperation(value = "学员已购买的双十一活动信息")

+ 2 - 10
mec-student/src/main/java/com/ym/mec/student/controller/PracticeGroupController.java

@@ -276,16 +276,8 @@ public class PracticeGroupController extends BaseController {
     @PostMapping(value = "/buyActivity")
     @AuditLogAnnotation(operateName = "营销活动购买")
     public HttpResponseResult buyActivity(@RequestBody PracticeGroupBuyParamsDto practiceGroupBuyParams) throws Exception {
-        SysUser sysUser = sysUserFeignService.queryUserInfo();
-        if (sysUser == null) {
-            return failed(HttpStatus.FORBIDDEN, "请登录");
-        }
-        if(Objects.isNull(practiceGroupBuyParams.getActivityId())){
-            throw new BizException("请选择活动");
-        }
-        practiceGroupBuyParams.setOrganId(sysUser.getOrganId());
-        practiceGroupBuyParams.setUserId(sysUser.getId());
-        return succeed(practiceGroupService.buyActivityPracticeGroup(practiceGroupBuyParams));
+//        return succeed(practiceGroupService.buyActivityPracticeGroup(practiceGroupBuyParams));
+        return failed("购买入口已关闭,请联系管理员");
     }
 
     @ApiOperation(value = "购买指导老师创建的网管课")

+ 2 - 1
mec-web/src/main/java/com/ym/mec/web/controller/CloudTeacherOrderController.java

@@ -45,7 +45,8 @@ public class CloudTeacherOrderController extends BaseController {
     @PostMapping("/addStudents")
     @PreAuthorize("@pcs.hasPermissions('cloudTeacherOrder/addStudents')")
     public HttpResponseResult<Boolean> addStudents(@RequestBody CloudTeacherAddQueryInfo cloudTeacherAddQueryInfo) {
-        return succeed(cloudTeacherOrderService.addStudents(cloudTeacherAddQueryInfo));
+        return failed("该入口已关闭,请联系管理员");
+//        return succeed(cloudTeacherOrderService.addStudents(cloudTeacherAddQueryInfo));
     }
 
     @ApiOperation(value = "查询未激活团练宝用户")

+ 7 - 1
mec-web/src/main/java/com/ym/mec/web/controller/TenantConfigController.java

@@ -28,7 +28,13 @@ public class TenantConfigController extends BaseController {
 	public Object get() {
 		// 查询云教室扣费标准
 		TenantConfig tenantConfig = tenantConfigService.queryByTenantId(TenantContextHolder.getTenantId());
-
 		return succeed(tenantConfig);
 	}
+
+	@ApiOperation("当前机构是否可以自动激活团练宝")
+	@GetMapping(value = "/autoActivationFlag")
+	@PreAuthorize("@pcs.hasPermissions('tenantConfig/autoActivationFlag')")
+	public Object autoActivationFlag() {
+		return succeed(tenantConfigService.autoActivationFlag(TenantContextHolder.getTenantId()));
+	}
 }