From 070c2f7586276ca6da3e8072b9856f1a1addfcc5 Mon Sep 17 00:00:00 2001 From: luoyang Date: Tue, 15 Jan 2019 10:54:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=EF=BC=8C=E6=AF=8F=E6=9C=88=E4=B8=80=E5=8F=B70?= =?UTF-8?q?=E7=82=B915=E5=88=86=E7=94=9F=E6=88=90=E5=90=88=E4=BC=99?= =?UTF-8?q?=E4=BA=BA=E6=8F=90=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impls/CityPartnerPrizeServiceImpl.java | 6 +-- .../manage/task/OrgCommissionTask.java | 37 +++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/task/OrgCommissionTask.java diff --git a/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java index 1cfed3e39..fb8a28025 100644 --- a/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java @@ -390,9 +390,9 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { int month = monthCal.get(Calendar.MONTH) + 1; List 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); diff --git a/src/main/java/au/com/royalpay/payment/manage/task/OrgCommissionTask.java b/src/main/java/au/com/royalpay/payment/manage/task/OrgCommissionTask.java new file mode 100644 index 000000000..614ef9212 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/task/OrgCommissionTask.java @@ -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); + } +} + +