|
|
|
@ -549,6 +549,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getAgentPrizeDetail(String monthStr, String orgId) {
|
|
|
|
|
|
|
|
|
|
Date monthDate = parseMonth(monthStr);
|
|
|
|
|
Calendar monthCal = Calendar.getInstance();
|
|
|
|
|
monthCal.setTime(monthDate);
|
|
|
|
@ -560,17 +561,11 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
if (CollectionUtils.isEmpty(total)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
List<String> recordIds = new ArrayList<>();
|
|
|
|
|
for (JSONObject jsonObject : total) {
|
|
|
|
|
result.put("name", jsonObject.getString("name"));
|
|
|
|
|
recordIds.add(jsonObject.getString("record_id"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal royalpay_charge = BigDecimal.ZERO;
|
|
|
|
|
List<JSONObject> partnerPrizeDetailList = financialPartnerCommissionDetailMapper.listDetailByMonth(year,month);
|
|
|
|
|
List<JSONObject> partnerPrizeList = getCityPartnerPrizeInfoList(monthStr);
|
|
|
|
|
Map<Integer, JSONObject> countPartnerPrizeMap = new HashMap<>();
|
|
|
|
|
for (JSONObject p : partnerPrizeDetailList) {
|
|
|
|
|
for (JSONObject p : partnerPrizeList) {
|
|
|
|
|
royalpay_charge = royalpay_charge.add(p.getBigDecimal("royalpay_charge"));
|
|
|
|
|
Integer key = p.getInteger("client_id");
|
|
|
|
|
JSONObject partnerTmp = countPartnerPrizeMap.get(key);
|
|
|
|
@ -583,9 +578,34 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String tableColumn[] = { "gross_amount", "total_charge", "org_charge", "org_net_charge" };
|
|
|
|
|
|
|
|
|
|
List<String> recordIds = new ArrayList<>();
|
|
|
|
|
Map<String, BigDecimal> chargeResultMap = new HashMap<>();
|
|
|
|
|
for (JSONObject jsonObject : total) {
|
|
|
|
|
result.put("name", jsonObject.getString("name"));
|
|
|
|
|
recordIds.add(jsonObject.getString("record_id"));
|
|
|
|
|
for (String s : tableColumn) {
|
|
|
|
|
String key = jsonObject.getString("channel") + "_" + s;
|
|
|
|
|
if (chargeResultMap.containsKey(key)) {
|
|
|
|
|
chargeResultMap.put(key, chargeResultMap.get(key).add(jsonObject.getBigDecimal(s)));
|
|
|
|
|
} else {
|
|
|
|
|
chargeResultMap.put(key, jsonObject.getBigDecimal(s));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<JSONObject> details = financialAgentCommissionDetailMapper.listDetailsByRecordIds(recordIds);
|
|
|
|
|
Map<String, List<JSONObject>> detailMap = new HashMap<>();
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
for (JSONObject detail : details) {
|
|
|
|
|
detail.put("date_from", format.format(detail.get("date_from")));
|
|
|
|
|
detail.put("date_to", format.format(detail.get("date_to")));
|
|
|
|
|
String key = detail.getString("client_id");
|
|
|
|
|
if (detailMap.containsKey(key)) {
|
|
|
|
|
detailMap.get(key).add(detail);
|
|
|
|
@ -598,36 +618,53 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
|
|
|
|
|
List<JSONObject> partnerClientInfos = new ArrayList<>();
|
|
|
|
|
BigDecimal resultGrossAmount = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal resultTotalCharge = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal resultRoyalpayCharge = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal resultOrgCharge = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal resultOrgNetCharge = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal resultNetCharge = BigDecimal.ZERO;
|
|
|
|
|
for (Map.Entry<String, List<JSONObject>> entry : detailMap.entrySet()) {
|
|
|
|
|
JSONObject sumResult = new JSONObject();
|
|
|
|
|
BigDecimal grossAmount = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal totalCharge = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal royalpayCharge = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal netCharge = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal orgCharge = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal orgNetCharge = BigDecimal.ZERO;
|
|
|
|
|
String clientMoniker = "";
|
|
|
|
|
int client_id = 0;
|
|
|
|
|
for (JSONObject jsonObject : entry.getValue()) {
|
|
|
|
|
grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount"));
|
|
|
|
|
totalCharge = totalCharge.add(jsonObject.getBigDecimal("total_charge"));
|
|
|
|
|
// royalpayCharge = royalpayCharge.add(jsonObject.getBigDecimal("royalpay_charge"));
|
|
|
|
|
orgCharge = orgCharge.add(jsonObject.getBigDecimal("org_charge"));
|
|
|
|
|
orgNetCharge = orgNetCharge.add(jsonObject.getBigDecimal("org_net_charge"));
|
|
|
|
|
if (jsonObject.getBigDecimal("net_charge") != null) {
|
|
|
|
|
netCharge = netCharge.add(jsonObject.getBigDecimal("org_net_charge"));
|
|
|
|
|
}
|
|
|
|
|
clientMoniker = jsonObject.getString("client_moniker");
|
|
|
|
|
}
|
|
|
|
|
resultGrossAmount = resultGrossAmount.add(grossAmount);
|
|
|
|
|
resultTotalCharge = resultTotalCharge.add(totalCharge);
|
|
|
|
|
resultRoyalpayCharge = resultRoyalpayCharge.add(royalpayCharge);
|
|
|
|
|
resultOrgCharge = resultOrgCharge.add(orgCharge);
|
|
|
|
|
resultOrgNetCharge = resultOrgNetCharge.add(orgNetCharge);
|
|
|
|
|
resultNetCharge = resultNetCharge.add(netCharge);
|
|
|
|
|
sumResult.put("gross_amount", grossAmount);
|
|
|
|
|
sumResult.put("total_charge", totalCharge);
|
|
|
|
|
sumResult.put("royalpay_charge", royalpayCharge);
|
|
|
|
|
sumResult.put("org_charge", orgCharge);
|
|
|
|
|
sumResult.put("org_net_charge", netCharge);
|
|
|
|
|
sumResult.put("client_moniker", clientMoniker);
|
|
|
|
|
sumResult.put("org_net_charge",orgNetCharge);
|
|
|
|
|
sumResult.put("royalpay_charge",countPartnerPrizeMap.get(client_id)==null?BigDecimal.ZERO:countPartnerPrizeMap.get(client_id).getBigDecimal("royalpay_charge"));
|
|
|
|
|
sumResult.put("channel_detail", entry.getValue());
|
|
|
|
|
partnerClientInfos.add(sumResult);
|
|
|
|
|
}
|
|
|
|
|
result.put("partner_client_infos", partnerClientInfos);
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, BigDecimal> entry : chargeResultMap.entrySet()) {
|
|
|
|
|
result.put(entry.getKey(), entry.getValue());
|
|
|
|
|
}
|
|
|
|
|
result.put("monthstr", monthStr);
|
|
|
|
|
result.put("gross_amount", resultGrossAmount);
|
|
|
|
|
result.put("org_charge", resultOrgCharge);
|
|
|
|
|
result.put("org_net_charge", resultOrgNetCharge);
|
|
|
|
|
result.put("total_transaction", resultGrossAmount);
|
|
|
|
|
result.put("total_charge", resultTotalCharge);
|
|
|
|
|
result.put("royalPay_charge", resultRoyalpayCharge);
|
|
|
|
|
result.put("org_net_charge", resultNetCharge);
|
|
|
|
|
result.put("city_partner_charge", resultOrgCharge);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|