增加定时任务,每月一号0点15分生成合伙人提成

master
luoyang 6 years ago
parent 8b306885bc
commit 070c2f7586

@ -390,9 +390,9 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
int month = monthCal.get(Calendar.MONTH) + 1;
List<JSONObject> list = financialPartnerCommissionMapper.list(year, month);
// if (list!=null &&list.size() > 0) {
// throw new ServerErrorException("请不要重复生成合伙人记录");
// }
if (list!=null &&list.size() > 0) {
throw new ServerErrorException("请不要重复生成合伙人记录");
}
financialPartnerCommissionDetailMapper.clearData(year, month, 1);
financialPartnerCommissionMapper.clearData(year, month, 1);

@ -0,0 +1,37 @@
package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.citypartner.core.CityPartnerPrizeService;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
@Component
@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true")
public class OrgCommissionTask {
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Resource
private CityPartnerPrizeService cityPartnerPrizeService;
@Scheduled(cron = "0 15 0 1 * ?")
public void generateOrgCommission() {
Calendar monthCal = Calendar.getInstance();
monthCal.setTime(new Date());
int year = monthCal.get(Calendar.YEAR);
int month = monthCal.get(Calendar.MONTH);
if (month == 0) {
year = year - 1;
month = 12;
}
String monthStr = year + "-" + month;
cityPartnerPrizeService.generate(monthStr);
}
}
Loading…
Cancel
Save