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 cfad647ae..71f147ec8 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 @@ -1,5 +1,27 @@ package au.com.royalpay.payment.manage.citypartner.core.impls; +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.annotation.Resource; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.alibaba.fastjson.JSONObject; + import au.com.royalpay.payment.manage.citypartner.beans.AgentCommissionAnalysis; import au.com.royalpay.payment.manage.citypartner.beans.CityPartnerCommissionAnalysis; import au.com.royalpay.payment.manage.citypartner.beans.ReferrerCommissionAnalysis; @@ -16,26 +38,6 @@ import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; -import com.alibaba.fastjson.JSONObject; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.time.DateUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.math.BigDecimal; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.Resource; - /** * Created by yixian on 2017-03-08. */ @@ -269,11 +271,15 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { channelMap.put("Bestpay", "Bestpay"); channelMap.put("jd", "jd"); channelMap.put("AlipayOnline", "AlipayOnline"); + Set orgIds = new HashSet<>(); List transactionAnalysis = transactionMapper.listTransactionsForCityPartnerCommission(year, month); Map results = new HashMap<>(); for (JSONObject analysisDay : transactionAnalysis) { int orgId = analysisDay.getIntValue("org_id"); JSONObject org = orgMapper.findOne(orgId); + if(org.getIntValue("parent_org_id")>0){ + orgIds.add(orgId); + } if (org == null) { // shall never happen throw new ServerErrorException("Organization Id not exists:" + orgId); @@ -287,8 +293,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { if (!channelMap.containsKey(key)) { continue; } - - channel = channel.toLowerCase(); CityPartnerCommissionAnalysis orgAnalysis = results.get(orgId + channel); if (orgAnalysis == null) { @@ -308,7 +312,12 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { financialPartnerCommissionDetailMapper.save(detail); } } - + Runnable task = ()->{ + orgIds.forEach((p)->{ + generateAgent(monthStr,p); + }); + }; + new Thread(task).start(); } @Override diff --git a/src/main/java/au/com/royalpay/payment/manage/citypartner/web/CityPartnerPrizeController.java b/src/main/java/au/com/royalpay/payment/manage/citypartner/web/CityPartnerPrizeController.java index 83b177814..3e53c6041 100644 --- a/src/main/java/au/com/royalpay/payment/manage/citypartner/web/CityPartnerPrizeController.java +++ b/src/main/java/au/com/royalpay/payment/manage/citypartner/web/CityPartnerPrizeController.java @@ -177,12 +177,6 @@ public class CityPartnerPrizeController { return result; } - @RequestMapping(value = "/agent/generate", method = RequestMethod.POST) - public void generateAgent(@RequestBody JSONObject param, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject managerInfo) { - String month = param.getString("month"); - cityPartnerPrizeService.generateAgent(month, managerInfo.getIntValue("org_id")); - } - @ManagerMapping("/agent/months/{monthStr}/orgs/{orgId}") public JSONObject getAgentPrizeDetail(@PathVariable String monthStr, @PathVariable String orgId) { return cityPartnerPrizeService.getAgentPrizeDetail(monthStr, orgId); diff --git a/src/main/ui/static/agent/commission/templates/agent_commission_root.html b/src/main/ui/static/agent/commission/templates/agent_commission_root.html index 338ad3521..22fcff5cd 100644 --- a/src/main/ui/static/agent/commission/templates/agent_commission_root.html +++ b/src/main/ui/static/agent/commission/templates/agent_commission_root.html @@ -1,27 +1,4 @@ - - - - - - -
-
-
-
-
- - -
- - -
-
-