|
@@ -1,7 +1,5 @@
|
|
|
package com.ssj.service.sys.fx.service.impl;
|
|
|
|
|
|
-import java.text.DateFormat;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -66,7 +64,19 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
|
|
|
|
|
|
//12点定时任务,处理套餐的数据
|
|
|
//1:处理加油包过期的数据
|
|
|
- //2:处理商户主套餐过期的数据,加油包全过期。
|
|
|
+
|
|
|
+ //2:处理激活日期的数据,生成一条0的激活数据,设置下一个结算日,CurIsSummary=0,免费结算
|
|
|
+ //注:如果在激活日期之前的时间,也会生成一条0的激活数据,设置下一个结算日,CurIsSummary=0,免费结算
|
|
|
+
|
|
|
+ //3:处理激活日期的下一结算日数据,再生成一条0的结算数据,CurIsSummary=0的,设置下一个结算时间。
|
|
|
+ //注:设置当前的时间
|
|
|
+
|
|
|
+ //4:处理开始计费日期,生成一条真实的数据30,设置当前的时间, 设置下一个结算日,CurIsSummary=+1,真实开始结算。
|
|
|
+
|
|
|
+
|
|
|
+ //5:处理开始计费日期的下一个结算日,生成一条30的数据,如果当前的CurIsSummary>=LibServiceMonth证明,结算完成,把结算日期都设置为空。
|
|
|
+ //注:处理商户主套餐过期的数据,加油包全过期。
|
|
|
+
|
|
|
@Override
|
|
|
public void runMerchantSignByEndTime() {
|
|
|
try {
|
|
@@ -74,11 +84,10 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
|
|
|
List<MerchantSign> merchantSigns=dao.findMerchantSignByEndTime();
|
|
|
for (MerchantSign merchantSign : merchantSigns) {
|
|
|
try {
|
|
|
- merchantSign.setRemarks("加油包过期");
|
|
|
+ merchantSign.setRemarks("加油包失效【加油包过期】");
|
|
|
merchantSign.setStatus(1);
|
|
|
merchantSign.setUpdateTime(new Date());
|
|
|
this.save(merchantSign);
|
|
|
-
|
|
|
Merchant merchant = merchantService.getById(merchantSign.getMerchantId());
|
|
|
merchant.setLibService(merchant.getLibService()-merchantSign.getLibService());
|
|
|
merchantService.save(merchant);
|
|
@@ -91,18 +100,18 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
|
|
|
List<LibVip> libVips=libVipService.findByLibId(merchant.getLibId());
|
|
|
if(libVips.size()>merchant.getLibService()) {
|
|
|
//这里需要调用灿哥的代码。
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
//记录加油包记录
|
|
|
TbLibJoinConsume consume=new TbLibJoinConsume();
|
|
|
consume.setFromLibId(merchant.getLibId());
|
|
|
consume.setFromMerchantId(merchant.getId());
|
|
|
consume.setLibService(merchantSign.getLibService());
|
|
|
consume.setPlatformService(0);
|
|
|
- consume.setType(2);
|
|
|
- consume.setRemarks("消费【加油包过期】");
|
|
|
+ consume.setType(10);
|
|
|
+ consume.setComputeNum(merchant.getCurIsSummary());
|
|
|
+ consume.setSignType(merchant.getSignType());
|
|
|
+ consume.setRemarks("加油包失效【加油包过期】");
|
|
|
consume.setCreateTime(new Date());
|
|
|
libJoinConsumeService.save(consume);
|
|
|
|
|
@@ -113,23 +122,150 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
|
|
|
merchant.getSignType(),
|
|
|
merchant.getLibService(),
|
|
|
null);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.error("1:处理加油包过期数据,异常:"+e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //2:处理激活日期的数据,生成一条0的激活数据,设置下一个结算日,CurIsSummary=0,免费结算
|
|
|
+ //注:如果在激活日期之前的时间,也会生成一条0的激活数据,设置下一个结算日,CurIsSummary=0,免费结算
|
|
|
+ List<Merchant> activeMerchants=merchantService.findMerchantSignByActiveTime();
|
|
|
+ for (Merchant merchant : activeMerchants) {
|
|
|
+ try {
|
|
|
+ merchant.setCurIsSummary(0);
|
|
|
+ merchant.setCurSummaryTime(new Date());
|
|
|
+ merchant.setNextSummaryTime(DateHelper.getMonthDate(merchant.getCurSummaryTime(),1));
|
|
|
+ merchantService.save(merchant);
|
|
|
+
|
|
|
+ //记录
|
|
|
+ TbLibJoinConsume consume=new TbLibJoinConsume();
|
|
|
+ consume.setFromLibId(merchant.getLibId());
|
|
|
+ consume.setFromMerchantId(merchant.getId());
|
|
|
+ consume.setLibService(0);
|
|
|
+ consume.setPlatformService(0);
|
|
|
+ consume.setType(7);
|
|
|
+ consume.setComputeNum(merchant.getCurIsSummary());
|
|
|
+ consume.setSignType(merchant.getSignType());
|
|
|
+ consume.setRemarks("激活期扣费【服务包扣费】");
|
|
|
+ consume.setCreateTime(new Date());
|
|
|
+ libJoinConsumeService.save(consume);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- logger.error("1:处理加油包过期的数据,异常:"+e.getMessage());
|
|
|
+ logger.error("2:处理商户系统激活日期数据,异常:"+e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- //2:处理商户结算的数据
|
|
|
+ //3:处理激活日期的下一结算日数据,再生成一条0的结算数据,CurIsSummary=0的,设置下一个结算时间。
|
|
|
+ //注:设置当前的时间
|
|
|
+ List<Merchant> activeEndMerchants=merchantService.findMerchantSignBySummaryTime();
|
|
|
+ for (Merchant merchant : activeEndMerchants) {
|
|
|
+
|
|
|
+ //只有在激活期的商户才处理数据。
|
|
|
+ if(merchant.getCurIsSummary()==null || merchant.getCurIsSummary()==0) {
|
|
|
+ try {
|
|
|
+ merchant.setCurIsSummary(0);
|
|
|
+ merchant.setCurSummaryTime(new Date());
|
|
|
+ merchant.setNextSummaryTime(DateHelper.getMonthDate(merchant.getCurSummaryTime(),1));
|
|
|
+ merchantService.save(merchant);
|
|
|
+
|
|
|
+ //记录
|
|
|
+ TbLibJoinConsume consume=new TbLibJoinConsume();
|
|
|
+ consume.setFromLibId(merchant.getLibId());
|
|
|
+ consume.setFromMerchantId(merchant.getId());
|
|
|
+ consume.setLibService(0);
|
|
|
+ consume.setPlatformService(0);
|
|
|
+ consume.setType(8);
|
|
|
+ consume.setComputeNum(merchant.getCurIsSummary());
|
|
|
+ consume.setSignType(merchant.getSignType());
|
|
|
+ consume.setRemarks("激活期失效【服务包失效】");
|
|
|
+ consume.setCreateTime(new Date());
|
|
|
+ libJoinConsumeService.save(consume);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.error("3:处理商户激活结算日期数据,异常:"+e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //4:处理开始计费日期,生成一条真实的数据30,设置当前的时间, 设置下一个结算日,CurIsSummary=+1,真实开始结算。
|
|
|
+ List<Merchant> computeMerchants=merchantService.findMerchantSignByComputeTime();
|
|
|
+ for (Merchant merchant : computeMerchants) {
|
|
|
+ try {
|
|
|
+
|
|
|
+ //记录激活期的结算
|
|
|
+ TbLibJoinConsume consume=new TbLibJoinConsume();
|
|
|
+ consume.setFromLibId(merchant.getLibId());
|
|
|
+ consume.setFromMerchantId(merchant.getId());
|
|
|
+ consume.setLibService(0);
|
|
|
+ consume.setPlatformService(0);
|
|
|
+ consume.setType(8);
|
|
|
+ consume.setComputeNum(merchant.getCurIsSummary());
|
|
|
+ consume.setSignType(merchant.getSignType());
|
|
|
+ consume.setRemarks("激活期失效【服务包失效】");
|
|
|
+ consume.setCreateTime(new Date());
|
|
|
+ libJoinConsumeService.save(consume);
|
|
|
+
|
|
|
+
|
|
|
+ merchant.setCurIsSummary(1);
|
|
|
+ merchant.setCurSummaryTime(new Date());
|
|
|
+ merchant.setNextSummaryTime(DateHelper.getMonthDate(merchant.getCurSummaryTime(),1));
|
|
|
+ merchantService.save(merchant);
|
|
|
+
|
|
|
+ //记录
|
|
|
+ consume=new TbLibJoinConsume();
|
|
|
+ consume.setFromLibId(merchant.getLibId());
|
|
|
+ consume.setFromMerchantId(merchant.getId());
|
|
|
+ consume.setLibService(merchant.getLibService());
|
|
|
+ consume.setPlatformService(0);
|
|
|
+ consume.setType(7);
|
|
|
+ consume.setComputeNum(merchant.getCurIsSummary());
|
|
|
+ consume.setSignType(merchant.getSignType());
|
|
|
+ consume.setRemarks("计费期扣费【服务包扣费:第"+merchant.getCurIsSummary()+"月】");
|
|
|
+ consume.setCreateTime(new Date());
|
|
|
+ libJoinConsumeService.save(consume);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.error("2:处理商户系统激活日期数据,异常:"+e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //5:处理商户结算的数据
|
|
|
List<Merchant> summaryMerchants=merchantService.findMerchantSignBySummaryTime();
|
|
|
for (Merchant merchant : summaryMerchants) {
|
|
|
try {
|
|
|
- //没有月份了,直接跳出
|
|
|
- if(merchant.getLibServiceMonth()<=0) {
|
|
|
+ //还在免费期的,直接跳出,由第3步处理了
|
|
|
+ if(merchant.getCurIsSummary()==null || merchant.getCurIsSummary()<=0) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ //没有月份数据的,直接跳出,不做处理
|
|
|
+ if(merchant.getLibServiceMonth()==null || merchant.getLibServiceMonth()<=0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //记录
|
|
|
+ TbLibJoinConsume consume=new TbLibJoinConsume();
|
|
|
+ consume.setFromLibId(merchant.getLibId());
|
|
|
+ consume.setFromMerchantId(merchant.getId());
|
|
|
+ consume.setLibService(0);
|
|
|
+ consume.setSignType(merchant.getSignType());
|
|
|
+ consume.setPlatformService(0);
|
|
|
+ consume.setType(8);
|
|
|
+ consume.setComputeNum(merchant.getCurIsSummary());
|
|
|
+ consume.setRemarks("计费期失效【服务包失效:第"+(merchant.getCurIsSummary())+"月】");
|
|
|
+ consume.setCreateTime(new Date());
|
|
|
+ libJoinConsumeService.save(consume);
|
|
|
+
|
|
|
//处理商户结算的数据
|
|
|
//已经够月份了,就终止商户
|
|
|
if(merchant.getCurIsSummary()>=merchant.getLibServiceMonth()) {
|
|
@@ -156,24 +292,28 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
|
|
|
logger.error("3:处理商户结算的数据,异常:"+e.getMessage());
|
|
|
}
|
|
|
continue;
|
|
|
+ }else {
|
|
|
+ merchant.setCurIsSummary(merchant.getCurIsSummary()==null ? 1 : merchant.getCurIsSummary()+1);
|
|
|
+ merchant.setCurSummaryTime(new Date());
|
|
|
+ merchant.setNextSummaryTime(DateHelper.getMonthDate(new Date(),1));
|
|
|
+ merchantService.save(merchant);
|
|
|
+
|
|
|
+
|
|
|
+ //记录
|
|
|
+ consume=new TbLibJoinConsume();
|
|
|
+ consume.setFromLibId(merchant.getLibId());
|
|
|
+ consume.setFromMerchantId(merchant.getId());
|
|
|
+ consume.setLibService(0);
|
|
|
+ consume.setPlatformService(0);
|
|
|
+ consume.setType(7);
|
|
|
+ consume.setComputeNum(merchant.getCurIsSummary());
|
|
|
+ consume.setSignType(merchant.getSignType());
|
|
|
+ consume.setRemarks("计费期扣费【服务包扣费:第"+merchant.getCurIsSummary()+"月】");
|
|
|
+ consume.setCreateTime(new Date());
|
|
|
+ libJoinConsumeService.save(consume);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- merchant.setCurIsSummary(merchant.getCurIsSummary()==null ? 1 : merchant.getCurIsSummary()+1);
|
|
|
- //merchant.setCurSummaryTime(new Date());
|
|
|
- merchant.setNextSummaryTime(DateHelper.getMonthDate(new Date(),1));
|
|
|
- merchantService.save(merchant);
|
|
|
-
|
|
|
- //记录
|
|
|
- TbLibJoinConsume consume=new TbLibJoinConsume();
|
|
|
- consume.setFromLibId(merchant.getLibId());
|
|
|
- consume.setFromMerchantId(merchant.getId());
|
|
|
- consume.setLibService(merchant.getLibService());
|
|
|
- consume.setPlatformService(0);
|
|
|
- consume.setType(2);
|
|
|
- consume.setRemarks("消费【套餐第"+(merchant.getCurIsSummary())+"个月结算】");
|
|
|
- consume.setCreateTime(new Date());
|
|
|
- libJoinConsumeService.save(consume);
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
logger.error("2:处理商户结算的数据,异常:"+e.getMessage());
|
|
@@ -200,21 +340,28 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
|
|
|
merchantSign.setStatus(0);
|
|
|
merchantSign.setCreateTime(new Date());
|
|
|
|
|
|
+ Date computeTime=merchant.getComputeTime();
|
|
|
+ if(computeTime.getTime()<new Date().getTime()) {
|
|
|
+ computeTime=new Date();
|
|
|
+ }
|
|
|
+ String remarks="加油包开通【新模式】";
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
- cal.setTime(merchant.getSignTime());
|
|
|
+ cal.setTime(computeTime);
|
|
|
switch (signType) {
|
|
|
case 4:
|
|
|
+ remarks="加油包开通【新模式月包】";
|
|
|
cal.add(Calendar.MONTH, num);
|
|
|
|
|
|
merchantSign.setLibService(10);
|
|
|
- merchantSign.setSignTime(merchant.getSignTime());
|
|
|
+ merchantSign.setSignTime(merchant.getComputeTime());
|
|
|
merchantSign.setEndSignTime(cal.getTime());
|
|
|
break;
|
|
|
case 5:
|
|
|
+ remarks="加油包开通【新模式量包】";
|
|
|
cal.add(Calendar.MONTH, 1);
|
|
|
|
|
|
merchantSign.setLibService(10*num);
|
|
|
- merchantSign.setSignTime(merchant.getSignTime());
|
|
|
+ merchantSign.setSignTime(merchant.getComputeTime());
|
|
|
merchantSign.setEndSignTime(cal.getTime());
|
|
|
break;
|
|
|
default:
|
|
@@ -231,15 +378,19 @@ public class MerchantSignServiceImpl extends BaseServiceImpl<MerchantSign, Strin
|
|
|
this.syncMerchantByLibJoin(merchant);
|
|
|
|
|
|
//记录加油包记录
|
|
|
- TbLibJoinConsume consume=new TbLibJoinConsume();
|
|
|
- consume.setToLibId(merchant.getLibId());
|
|
|
- consume.setToMerchantId(merchant.getId());
|
|
|
- consume.setLibService(merchantSign.getLibService());
|
|
|
- consume.setPlatformService(0);
|
|
|
- consume.setType(1);
|
|
|
- consume.setRemarks("加油包充值");
|
|
|
- consume.setCreateTime(new Date());
|
|
|
- libJoinConsumeService.save(consume);
|
|
|
+ for (int i = 1; i <=num; i++) {
|
|
|
+ TbLibJoinConsume consume=new TbLibJoinConsume();
|
|
|
+ consume.setToLibId(merchant.getLibId());
|
|
|
+ consume.setToMerchantId(merchant.getId());
|
|
|
+ consume.setLibService(10);
|
|
|
+ consume.setPlatformService(0);
|
|
|
+ consume.setType(9);
|
|
|
+ consume.setComputeNum(0);
|
|
|
+ consume.setSignType(merchant.getSignType());
|
|
|
+ consume.setRemarks(remarks);
|
|
|
+ consume.setCreateTime(new Date());
|
|
|
+ libJoinConsumeService.save(consume);
|
|
|
+ }
|
|
|
|
|
|
//调用openApi接口
|
|
|
libVipServiceService.openApiServiceCRM(
|