|
|
|
@ -31,6 +31,11 @@ import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFFont;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
|
import org.apache.poi.hssf.util.HSSFColor;
|
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
@ -182,7 +187,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
|
|
|
|
|
private Date parseMonth(String monthStr) {
|
|
|
|
|
try {
|
|
|
|
|
return DateUtils.parseDate(monthStr, new String[] { "yyyy-MM" });
|
|
|
|
|
return DateUtils.parseDate(monthStr, new String[]{"yyyy-MM"});
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
throw new BadRequestException("Invalid month format");
|
|
|
|
|
}
|
|
|
|
@ -203,7 +208,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String tableColumn[] = { "gross_amount", "total_charge", "royalpay_charge", "org_charge", "net_charge" };
|
|
|
|
|
String tableColumn[] = {"gross_amount", "total_charge", "royalpay_charge", "org_charge", "net_charge"};
|
|
|
|
|
|
|
|
|
|
List<String> recordIds = new ArrayList<>();
|
|
|
|
|
Map<String, BigDecimal> chargeResultMap = new HashMap<>();
|
|
|
|
@ -274,7 +279,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
sumResult.put("net_charge", netCharge);
|
|
|
|
|
sumResult.put("client_moniker", clientMoniker);
|
|
|
|
|
sumResult.put("channel_detail", entry.getValue());
|
|
|
|
|
sumResult.put("type",type);
|
|
|
|
|
sumResult.put("type", type);
|
|
|
|
|
partnerClientInfos.add(sumResult);
|
|
|
|
|
}
|
|
|
|
|
result.put("partner_client_infos", partnerClientInfos);
|
|
|
|
@ -390,7 +395,7 @@ 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) {
|
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
|
|
throw new ServerErrorException("请不要重复生成合伙人记录");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -430,7 +435,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
// shall never happen
|
|
|
|
|
throw new ServerErrorException("Organization Id not exists:" + orgId);
|
|
|
|
|
}
|
|
|
|
|
if (org.getInteger("commission_type")!=1) {
|
|
|
|
|
if (org.getInteger("commission_type") != 1) {
|
|
|
|
|
generateold(monthStr);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -438,7 +443,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
|
|
|
|
|
List<JSONObject> items = oneOrg.getValue();
|
|
|
|
|
Map<String, List<JSONObject>> groupByChannelMap = items.stream().collect(Collectors.groupingBy(e -> e.getString("channel")));
|
|
|
|
|
List<JSONObject> channelAmount = orgChannelAmount(org,groupByChannelMap, channelCharge);
|
|
|
|
|
List<JSONObject> channelAmount = orgChannelAmount(org, groupByChannelMap, channelCharge);
|
|
|
|
|
for (JSONObject channel : channelAmount) {
|
|
|
|
|
channel.put("share_charge", 0);
|
|
|
|
|
channel.put("month", month);
|
|
|
|
@ -454,7 +459,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
JSONObject org = orgMapper.findOne(oneClient.getValue().get(0).getInteger("org_id"));
|
|
|
|
|
Map<String, List<JSONObject>> groupByChannel = oneClient.getValue().stream().collect(Collectors.groupingBy(e -> e.getString("channel")));
|
|
|
|
|
|
|
|
|
|
List<JSONObject> clientChannelAmount = clientChannelAmount(oneClient.getKey(),org, groupByChannel, channelCharge,year,month,1);
|
|
|
|
|
List<JSONObject> clientChannelAmount = clientChannelAmount(oneClient.getKey(), org, groupByChannel, channelCharge, year, month, 1);
|
|
|
|
|
for (JSONObject channel : clientChannelAmount) {
|
|
|
|
|
financialPartnerCommissionDetailMapper.save(channel);
|
|
|
|
|
}
|
|
|
|
@ -471,7 +476,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<JSONObject> orgChannelAmount(JSONObject orgInfo,Map<String, List<JSONObject>> channelMap,JSONObject channelCharge) {
|
|
|
|
|
public List<JSONObject> orgChannelAmount(JSONObject orgInfo, Map<String, List<JSONObject>> channelMap, JSONObject channelCharge) {
|
|
|
|
|
List<JSONObject> amountByChannel = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, List<JSONObject>> oneChannel : channelMap.entrySet()) {
|
|
|
|
@ -487,7 +492,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
if (orgInfo.get("cb_bankpay_rate_value") == null) {
|
|
|
|
|
throw new ServerErrorException(orgInfo.getString("name") + "组织下" + "cbbankpay" + "成本手续费未设置");
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
if (orgInfo.get(channel.toLowerCase() + "_rate_value") == null) {
|
|
|
|
|
throw new ServerErrorException(orgInfo.getString("name") + "组织下" + oneChannel.getKey() + "成本手续费未设置");
|
|
|
|
|
}
|
|
|
|
@ -502,14 +507,14 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
total = total.add(tmpClearingAmount);
|
|
|
|
|
total_surage = total_surage.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
// net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
|
|
|
|
|
// net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
|
|
|
|
|
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
}
|
|
|
|
|
BigDecimal org_charge = total_surage.subtract(royalpay_surage);
|
|
|
|
|
json.put("channel",oneChannel.getKey());
|
|
|
|
|
json.put("gross_amount",total);
|
|
|
|
|
json.put("total_charge",total_surage);
|
|
|
|
|
json.put("net_charge",net_surage);
|
|
|
|
|
json.put("channel", oneChannel.getKey());
|
|
|
|
|
json.put("gross_amount", total);
|
|
|
|
|
json.put("total_charge", total_surage);
|
|
|
|
|
json.put("net_charge", net_surage);
|
|
|
|
|
json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
json.put("royalpay_charge", royalpay_surage);
|
|
|
|
|
json.put("org_charge", org_charge);
|
|
|
|
@ -518,10 +523,10 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
amountByChannel.add(json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return amountByChannel;
|
|
|
|
|
return amountByChannel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<JSONObject> parentOrgChannelAmount(JSONObject orgInfo,JSONObject parentOrgInfo,Map<String, List<JSONObject>> channelMap,JSONObject channelCharge) {
|
|
|
|
|
public List<JSONObject> parentOrgChannelAmount(JSONObject orgInfo, JSONObject parentOrgInfo, Map<String, List<JSONObject>> channelMap, JSONObject channelCharge) {
|
|
|
|
|
List<JSONObject> amountByChannel = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, List<JSONObject>> oneChannel : channelMap.entrySet()) {
|
|
|
|
@ -549,14 +554,14 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
royalpay_surage = royalpay_surage.add(roy_surage);
|
|
|
|
|
//net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
|
|
|
|
|
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
share_surage = share_surage.add(roy_surage.subtract(parent_surage)).setScale(i,RoundingMode.HALF_UP);
|
|
|
|
|
share_surage = share_surage.add(roy_surage.subtract(parent_surage)).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
BigDecimal org_charge = total_surage.subtract(royalpay_surage);
|
|
|
|
|
json.put("channel",oneChannel.getKey());
|
|
|
|
|
json.put("gross_amount",total);
|
|
|
|
|
json.put("total_charge",total_surage);
|
|
|
|
|
json.put("net_charge",net_surage);
|
|
|
|
|
json.put("channel", oneChannel.getKey());
|
|
|
|
|
json.put("gross_amount", total);
|
|
|
|
|
json.put("total_charge", total_surage);
|
|
|
|
|
json.put("net_charge", net_surage);
|
|
|
|
|
json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
json.put("partner_charge", royalpay_surage);
|
|
|
|
|
json.put("share_charge", share_surage);
|
|
|
|
@ -570,7 +575,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//type 1:一级代理 2:二级代理
|
|
|
|
|
public List<JSONObject> clientChannelAmount(int clientId,JSONObject orgInfo,Map<String, List<JSONObject>> channelMap,JSONObject channelCharge,int year,int month,int type) {
|
|
|
|
|
public List<JSONObject> clientChannelAmount(int clientId, JSONObject orgInfo, Map<String, List<JSONObject>> channelMap, JSONObject channelCharge, int year, int month, int type) {
|
|
|
|
|
List<JSONObject> amountByChannel = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, List<JSONObject>> oneChannel : channelMap.entrySet()) {
|
|
|
|
@ -599,10 +604,10 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
BigDecimal tmpTotalSurcharge = tmpClearingAmount.multiply(params.getBigDecimal("surcharge_rate")).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
//增加货币判断
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
if (total.compareTo(BigDecimal.ZERO)==0 ) {
|
|
|
|
|
if (total.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
dateto = params.getDate("transaction_time");
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
if (params.getDate("transaction_time").before(datefrom)) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
}
|
|
|
|
@ -618,29 +623,29 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
}
|
|
|
|
|
BigDecimal org_charge = total_surage.subtract(royalpay_surage);
|
|
|
|
|
if(channel.toLowerCase().equals("alipay_direct")){
|
|
|
|
|
if (channel.toLowerCase().equals("alipay_direct")) {
|
|
|
|
|
channel = channel.replace("_", "");
|
|
|
|
|
}
|
|
|
|
|
json.put("channel",oneChannel.getKey());
|
|
|
|
|
json.put("channel", oneChannel.getKey());
|
|
|
|
|
|
|
|
|
|
json.put("record_id",recordId);
|
|
|
|
|
json.put("client_id",clientId);
|
|
|
|
|
json.put("client_rate",oneChannel.getValue().get(0).getBigDecimal("surcharge_rate").multiply(CommonConsts.HUNDRED));
|
|
|
|
|
json.put("gross_amount",total);
|
|
|
|
|
json.put("total_charge",total_surage);
|
|
|
|
|
json.put("record_id", recordId);
|
|
|
|
|
json.put("client_id", clientId);
|
|
|
|
|
json.put("client_rate", oneChannel.getValue().get(0).getBigDecimal("surcharge_rate").multiply(CommonConsts.HUNDRED));
|
|
|
|
|
json.put("gross_amount", total);
|
|
|
|
|
json.put("total_charge", total_surage);
|
|
|
|
|
json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
json.put("royalpay_charge", royalpay_surage);
|
|
|
|
|
if (type == 1) {
|
|
|
|
|
json.put("net_charge",net_surage);
|
|
|
|
|
json.put("net_charge", net_surage);
|
|
|
|
|
}
|
|
|
|
|
if (type == 2) {
|
|
|
|
|
json.put("org_net_charge",net_surage);
|
|
|
|
|
json.put("org_net_charge", net_surage);
|
|
|
|
|
}
|
|
|
|
|
json.put("org_charge", org_charge);
|
|
|
|
|
json.put("commission_type", "1");
|
|
|
|
|
json.put("create_time", new Date());
|
|
|
|
|
json.put("date_from", DateFormatUtils.format(datefrom,"yyyy-MM-dd"));
|
|
|
|
|
json.put("date_to", DateFormatUtils.format(dateto,"yyyy-MM-dd"));
|
|
|
|
|
json.put("date_from", DateFormatUtils.format(datefrom, "yyyy-MM-dd"));
|
|
|
|
|
json.put("date_to", DateFormatUtils.format(dateto, "yyyy-MM-dd"));
|
|
|
|
|
json.put("year", year);
|
|
|
|
|
json.put("month", month);
|
|
|
|
|
amountByChannel.add(json);
|
|
|
|
@ -662,20 +667,20 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private BigDecimal getThirdPartyCharge(String channel, BigDecimal total,JSONObject chargeRate) {
|
|
|
|
|
private BigDecimal getThirdPartyCharge(String channel, BigDecimal total, JSONObject chargeRate) {
|
|
|
|
|
BigDecimal thirdPartyPaymentCharge = BigDecimal.ZERO;
|
|
|
|
|
switch (channel) {
|
|
|
|
|
case "Alipay":
|
|
|
|
|
thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("alipayChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2,RoundingMode.HALF_UP);
|
|
|
|
|
thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("alipayChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
break;
|
|
|
|
|
case "Wechat":
|
|
|
|
|
thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("wechatChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2,RoundingMode.HALF_UP);
|
|
|
|
|
thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("wechatChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
break;
|
|
|
|
|
case "jd":
|
|
|
|
|
thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("jdChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2,RoundingMode.HALF_UP);
|
|
|
|
|
thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("jdChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
break;
|
|
|
|
|
case "AlipayOnline":
|
|
|
|
|
thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("alipayonlineChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2,RoundingMode.HALF_UP);
|
|
|
|
|
thirdPartyPaymentCharge = total.multiply(chargeRate.getBigDecimal("alipayonlineChargeRate").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_DOWN)).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
@ -684,7 +689,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void generateReferrer(String monthStr) {
|
|
|
|
@ -775,7 +779,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public void generateAgent(String monthStr,JSONObject channelCharge) {
|
|
|
|
|
public void generateAgent(String monthStr, JSONObject channelCharge) {
|
|
|
|
|
|
|
|
|
|
Date mon = checkMonth(monthStr);
|
|
|
|
|
Calendar monthCal = Calendar.getInstance();
|
|
|
|
@ -800,13 +804,13 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
// shall never happen
|
|
|
|
|
throw new ServerErrorException("Parent Organization Id not exists:" + orgId);
|
|
|
|
|
}
|
|
|
|
|
if (org.getInteger("commission_type")!=1) {
|
|
|
|
|
if (org.getInteger("commission_type") != 1) {
|
|
|
|
|
generateold(monthStr);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
List<JSONObject> items = oneOrg.getValue();
|
|
|
|
|
Map<String, List<JSONObject>> groupByChannelMap = items.stream().collect(Collectors.groupingBy(e -> e.getString("channel")));
|
|
|
|
|
List<JSONObject> channelAmount = parentOrgChannelAmount(org,parentOrg,groupByChannelMap, channelCharge);
|
|
|
|
|
List<JSONObject> channelAmount = parentOrgChannelAmount(org, parentOrg, groupByChannelMap, channelCharge);
|
|
|
|
|
for (JSONObject channel : channelAmount) {
|
|
|
|
|
if (channel.getBigDecimal("share_charge").compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
|
JSONObject parentCommission = financialPartnerCommissionMapper.findByChanel(year, month, parentOrg.getInteger("org_id"), channel.getString("channel"));
|
|
|
|
@ -857,8 +861,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -970,7 +972,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
|
|
|
|
|
private Date checkMonth(String month) {
|
|
|
|
|
try {
|
|
|
|
|
return DateUtils.parseDate(month, new String[] { "yyyy-MM" });
|
|
|
|
|
return DateUtils.parseDate(month, new String[]{"yyyy-MM"});
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
throw new BadRequestException("Invalid Month Format");
|
|
|
|
|
}
|
|
|
|
@ -1047,7 +1049,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String tableColumn[] = { "gross_amount", "total_charge", "org_charge", "org_net_charge" };
|
|
|
|
|
String tableColumn[] = {"gross_amount", "total_charge", "org_charge", "org_net_charge"};
|
|
|
|
|
|
|
|
|
|
List<String> recordIds = new ArrayList<>();
|
|
|
|
|
Map<String, BigDecimal> chargeResultMap = new HashMap<>();
|
|
|
|
@ -1224,4 +1226,73 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
return financialSeniorPartnerCommissionMapper.find(year, month, orgId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void exportMonthFiles(String monthStr, HttpServletResponse resp) throws Exception {
|
|
|
|
|
OutputStream ous = null;
|
|
|
|
|
Date monthDate = parseMonth(monthStr);
|
|
|
|
|
Calendar monthCal = Calendar.getInstance();
|
|
|
|
|
monthCal.setTime(monthDate);
|
|
|
|
|
int year = monthCal.get(Calendar.YEAR);
|
|
|
|
|
int month = monthCal.get(Calendar.MONTH) + 1;
|
|
|
|
|
List<JSONObject> report = financialPartnerCommissionMapper.listWithOrgInfo(year, month);
|
|
|
|
|
if (report != null) {
|
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
|
resp.addHeader("Content-Disposition", "attachment; filename=" + "CityPartner_Commission_Info_" + monthStr + ".xls");
|
|
|
|
|
ous = resp.getOutputStream();
|
|
|
|
|
HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
|
|
Cell cell = null;
|
|
|
|
|
HSSFFont font = wb.createFont();
|
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
|
|
font.setFontHeightInPoints((short) 10);
|
|
|
|
|
CellStyle titleStyle = wb.createCellStyle();
|
|
|
|
|
titleStyle.setFont(font);
|
|
|
|
|
HSSFCellStyle style = wb.createCellStyle();
|
|
|
|
|
style.setFillForegroundColor(HSSFColor.RED.index);
|
|
|
|
|
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
|
|
|
|
|
Sheet sheet = wb.createSheet("CityPartner_Commission_Info_" + month);
|
|
|
|
|
sheet.setDefaultColumnWidth(20);
|
|
|
|
|
int rowNum = 0;
|
|
|
|
|
Row row = sheet.createRow(rowNum);
|
|
|
|
|
String[] CommissionTitle = {"City Partner Name", "Transaction Amount", "Total Charge", "RoyalPay Charge", "Net Charge", "City Partner Charge", "Share Charge", "Type"};
|
|
|
|
|
for (int i = 0; i < CommissionTitle.length; i++) {
|
|
|
|
|
cell = row.createCell(i, Cell.CELL_TYPE_STRING);
|
|
|
|
|
cell.setCellStyle(titleStyle);
|
|
|
|
|
cell.setCellValue(CommissionTitle[i]);
|
|
|
|
|
}
|
|
|
|
|
for (JSONObject log : report) {
|
|
|
|
|
row = sheet.createRow(++rowNum);
|
|
|
|
|
StringBuffer name = new StringBuffer(log.getString("name"));
|
|
|
|
|
if (log.get("parent_org_id") == null) {
|
|
|
|
|
name.append("(一级代理)");
|
|
|
|
|
} else {
|
|
|
|
|
name.append("(二级代理)");
|
|
|
|
|
}
|
|
|
|
|
String type = "";
|
|
|
|
|
switch (log.getIntValue("commission_type")) {
|
|
|
|
|
case 1:
|
|
|
|
|
type = "渠道计算法";
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
type = "总交易额比例";
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
type = "收益比例";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(name.toString());
|
|
|
|
|
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("gross_amount") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("gross_amount").toPlainString());
|
|
|
|
|
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("total_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("total_charge").toPlainString());
|
|
|
|
|
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("royalpay_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("royalpay_charge").toPlainString());
|
|
|
|
|
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("net_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("net_charge").toPlainString());
|
|
|
|
|
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("org_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("org_charge").toPlainString());
|
|
|
|
|
row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("share_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("share_charge").toPlainString());
|
|
|
|
|
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(type);
|
|
|
|
|
}
|
|
|
|
|
wb.write(ous);
|
|
|
|
|
ous.flush();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|