|
@@ -9,10 +9,7 @@ import com.ym.mec.biz.dal.dao.CloudTeacherOrderDao;
|
|
|
import com.ym.mec.biz.dal.dao.TenantOrderRecordDao;
|
|
|
import com.ym.mec.biz.dal.dto.TenantOrderRecordDto;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
|
-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.enums.*;
|
|
|
import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
@@ -209,6 +206,7 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void activeCloudTeacher(TenantOrderRecord record) {
|
|
|
+ log.info("activeCloudTeacher>>> record : {}", JSON.toJSONString(record));
|
|
|
if (record.getId() == null) {
|
|
|
throw new BizException("订单未找到");
|
|
|
}
|
|
@@ -223,23 +221,26 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
|
|
|
}
|
|
|
//发信息
|
|
|
cloudTeacherOrderService.sendSms(record);
|
|
|
-
|
|
|
+ log.info("activeCloudTeacher>>> cloudTeacherOrders : {}", JSON.toJSONString(cloudTeacherOrders));
|
|
|
//消费大于0元则且有代理商的机构则写入分润表
|
|
|
if (record.getActualAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ log.info("activeCloudTeacher>>> proxy {}", record.getActualAmount());
|
|
|
//根据机构id查询对应的推荐人
|
|
|
TenantInfo tenantInfo = tenantInfoService.getById(record.getTenantId());
|
|
|
+ log.info("activeCloudTeacher>>> proxy tenantInfo {}", JSON.toJSONString(tenantInfo));
|
|
|
if (Objects.isNull(tenantInfo) || Objects.isNull(tenantInfo.getRecommender())) {
|
|
|
return;
|
|
|
}
|
|
|
//根据推荐人查询代理商
|
|
|
TenantProxyUserRelation proxyUserRelation = tenantProxyUserRelationService.getOne(Wrappers.<TenantProxyUserRelation>lambdaQuery()
|
|
|
.eq(TenantProxyUserRelation::getUserId, tenantInfo.getRecommender()));
|
|
|
+ log.info("activeCloudTeacher>>> proxy proxyUserRelation {}", JSON.toJSONString(proxyUserRelation));
|
|
|
if (Objects.isNull(proxyUserRelation)) {
|
|
|
return;
|
|
|
}
|
|
|
//获取总激活月份
|
|
|
Integer totalMonth = cloudTeacherOrders.stream()
|
|
|
- .map(CloudTeacherOrder::getTime)
|
|
|
+ .map(this::getTotalMonth)
|
|
|
.reduce(0, Integer::sum);
|
|
|
//写入分润表
|
|
|
TenantProxyDividend dividend = new TenantProxyDividend();
|
|
@@ -249,6 +250,22 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
|
|
|
dividend.setActiveTime(now);
|
|
|
dividend.setOrderId(record.getId());
|
|
|
tenantProxyDividendService.save(dividend);
|
|
|
+ log.info("activeCloudTeacher>>> proxy proxyUserRelation {}", JSON.toJSONString(dividend));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer getTotalMonth(CloudTeacherOrder order) {
|
|
|
+ PeriodEnum type = order.getType();
|
|
|
+ if (type.equals(PeriodEnum.MONTH)) {
|
|
|
+ return order.getTime();
|
|
|
+ } else if (type.equals(PeriodEnum.QUARTERLY)) {
|
|
|
+ return order.getTime() * 3;
|
|
|
+ } else if (type.equals(PeriodEnum.YEAR_HALF)) {
|
|
|
+ return order.getTime() * 6;
|
|
|
+ } else if (type.equals(PeriodEnum.YEAR)) {
|
|
|
+ return order.getTime() * 12;
|
|
|
+ } else {
|
|
|
+ return 1;
|
|
|
}
|
|
|
}
|
|
|
|