master
wangning 7 years ago
parent 3032d6315b
commit ce65ae462a

@ -1,5 +1,27 @@
package au.com.royalpay.payment.manage.citypartner.core.impls; 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.AgentCommissionAnalysis;
import au.com.royalpay.payment.manage.citypartner.beans.CityPartnerCommissionAnalysis; import au.com.royalpay.payment.manage.citypartner.beans.CityPartnerCommissionAnalysis;
import au.com.royalpay.payment.manage.citypartner.beans.ReferrerCommissionAnalysis; 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.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException; 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. * Created by yixian on 2017-03-08.
*/ */
@ -269,11 +271,15 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
channelMap.put("Bestpay", "Bestpay"); channelMap.put("Bestpay", "Bestpay");
channelMap.put("jd", "jd"); channelMap.put("jd", "jd");
channelMap.put("AlipayOnline", "AlipayOnline"); channelMap.put("AlipayOnline", "AlipayOnline");
Set<Integer> orgIds = new HashSet<>();
List<JSONObject> transactionAnalysis = transactionMapper.listTransactionsForCityPartnerCommission(year, month); List<JSONObject> transactionAnalysis = transactionMapper.listTransactionsForCityPartnerCommission(year, month);
Map<String, CityPartnerCommissionAnalysis> results = new HashMap<>(); Map<String, CityPartnerCommissionAnalysis> results = new HashMap<>();
for (JSONObject analysisDay : transactionAnalysis) { for (JSONObject analysisDay : transactionAnalysis) {
int orgId = analysisDay.getIntValue("org_id"); int orgId = analysisDay.getIntValue("org_id");
JSONObject org = orgMapper.findOne(orgId); JSONObject org = orgMapper.findOne(orgId);
if(org.getIntValue("parent_org_id")>0){
orgIds.add(orgId);
}
if (org == null) { if (org == null) {
// shall never happen // shall never happen
throw new ServerErrorException("Organization Id not exists:" + orgId); throw new ServerErrorException("Organization Id not exists:" + orgId);
@ -287,8 +293,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
if (!channelMap.containsKey(key)) { if (!channelMap.containsKey(key)) {
continue; continue;
} }
channel = channel.toLowerCase(); channel = channel.toLowerCase();
CityPartnerCommissionAnalysis orgAnalysis = results.get(orgId + channel); CityPartnerCommissionAnalysis orgAnalysis = results.get(orgId + channel);
if (orgAnalysis == null) { if (orgAnalysis == null) {
@ -308,7 +312,12 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
financialPartnerCommissionDetailMapper.save(detail); financialPartnerCommissionDetailMapper.save(detail);
} }
} }
Runnable task = ()->{
orgIds.forEach((p)->{
generateAgent(monthStr,p);
});
};
new Thread(task).start();
} }
@Override @Override

@ -177,12 +177,6 @@ public class CityPartnerPrizeController {
return result; 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}") @ManagerMapping("/agent/months/{monthStr}/orgs/{orgId}")
public JSONObject getAgentPrizeDetail(@PathVariable String monthStr, @PathVariable String orgId) { public JSONObject getAgentPrizeDetail(@PathVariable String monthStr, @PathVariable String orgId) {
return cityPartnerPrizeService.getAgentPrizeDetail(monthStr, orgId); return cityPartnerPrizeService.getAgentPrizeDetail(monthStr, orgId);

@ -1,27 +1,4 @@
<!--<section class="content-header">-->
<!--<h1>City Partner Commissions</h1>-->
<!--<ol class="breadcrumb">-->
<!--<li><i class="fa fa-users"></i> Analysis</li>-->
<!--<li class="active">City Partner Commissions</li>-->
<!--</ol>-->
<!--</section>-->
<section class="content"> <section class="content">
<div class="box box-default">
<div class="box-body">
<div class="form-inline">
<div class="form-group">
<input type="text" class="form-control" uib-datepicker-popup="yyyy-MM" ng-model="generate.month"
is-open="ctrl.genmonth" datepicker-options="{minMode: 'month'}"
ng-click="ctrl.genmonth=true" placeholder="Select Month"/>
</div>
<button class="btn btn-primary" ng-click="generateAgentCommission()" ng-disabled="!generate.month">
Generate
</button>
<loadingbar ng-if="generate.status"></loadingbar>
</div>
</div>
</div>
<div class="box box-warning"> <div class="box box-warning">
<div class="box-header"> <div class="box-header">
<input type="text" class="hidden" uib-datepicker-popup="yyyy" ng-model="params.year" is-open="ctrl.viewyear" <input type="text" class="hidden" uib-datepicker-popup="yyyy" ng-model="params.year" is-open="ctrl.viewyear"

Loading…
Cancel
Save