Merge remote-tracking branch 'origin/develop' into develop

master
yixian 6 years ago
commit a4e62a3bb5

@ -168,4 +168,10 @@ public interface TransactionMapper {
List<JSONObject> listCreditTransactionsForSecure(Date from, Date to);
List<JSONObject> listDebitTransactionsForSecure(Date from, Date to);
JSONObject getClearDetailTotal(JSONObject params);
List<JSONObject> getSettlementLogDetailList(@Param("clientOrders") List<Integer> clientOrders, @Param("client_id") int clientId);
List<JSONObject> getClientOrderByTransactionTime(JSONObject params);
}

@ -50,4 +50,6 @@ public interface TradeLogService {
void fullReleasePreAuthorization(JSONObject account, TradeLogQuery query)throws Exception;
PageList<JSONObject> listPreRefundClients(PreRefundQueryBean params);
void exportSettlementLog(TradeLogQuery query, JSONObject partner, HttpServletResponse response);
}

@ -28,6 +28,7 @@ import au.com.royalpay.payment.manage.organizations.core.OrgManager;
import au.com.royalpay.payment.manage.tradelog.beans.PreRefundQueryBean;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
import au.com.royalpay.payment.tools.defines.TradeType;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
@ -68,6 +69,8 @@ import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@ -1177,4 +1180,97 @@ public class TradeLogServiceImpl implements TradeLogService {
return transactionMapper.listPreRefundClients(new PageBounds(params.getPage(), params.getLimit()));
}
@Override
public void exportSettlementLog(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) {
int client_id = partner.getIntValue("client_id");
String begin = query.getDatefrom() == null ?"":query.getDatefrom();
String end = query.getDateto() == null ?"":query.getDateto();
String timezone = partner.getJSONObject("client").getString("timezone");
JSONObject params = query.toParams(timezone);
params.put("client_id", client_id);
List<JSONObject> clientOrderList = transactionMapper.getClientOrderByTransactionTime(params);
List<Integer> clientOrders = new ArrayList<>(clientOrderList.size());
clientOrderList.parallelStream().forEach(p->{
clientOrders.add(p.getInteger("clearing_order"));
});
List<JSONObject> settlementLogDetailList = transactionMapper.getSettlementLogDetailList(clientOrders, client_id);
OutputStream ous = null;
try {
JSONObject clearDetailTotal = transactionMapper.getClearDetailTotal(params);
resp.setContentType("application/octet-stream;");
resp.addHeader("Content-Disposition",
"attachment; filename=" + "Merchant_Settlement_Info_" + begin + "_" + end + ".xlsx");
ous = resp.getOutputStream();
Workbook wb = new XSSFWorkbook();
Cell cell = null;
Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 10);
CellStyle analysisStyle = wb.createCellStyle();
analysisStyle.setFont(font);
Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + begin + "_" + end);
int rowNum = 0;
Row row = sheet.createRow(rowNum);
String[] title = {"order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency",
"Input Amount", "Total Amount", "Clearing Amount", "Sruchange Rate", "Settle Amount", "Remark", "Dev No"};
String[] analysis = {"Total Credit", "Total Debit", "Gross Amount", "Total Charge", "Net Amount"};
for (int i = 0; i < title.length; i++) {
row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]);
}
JSONObject device;
String clientDevId = "";
for (JSONObject settle : settlementLogDetailList) {
if (settle.getBigDecimal("clearing_amount").compareTo(BigDecimal.ZERO) == 0) {
continue;
}
row = sheet.createRow(++rowNum);
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("order_id"));
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("client_order_id"));
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_time"));
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("channel"));
if (settle.getInteger("gateway") != null) {
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(TradeType.fromGatewayNumber(settle.getIntValue("gateway")).getTradeType());
} else {
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue("-");
}
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("exchange_rate").setScale(5, BigDecimal.ROUND_DOWN).toPlainString());
row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_type"));
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_currency"));
row.createCell(8, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("display_amount") == null ? ""
: settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
row.createCell(9, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("transaction_amount") == null ? ""
: settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
row.createCell(10, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("clearing_amount") == null ? ""
: settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("rate") == null? "": settle.getBigDecimal("rate").toPlainString() + "%");
row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("settle_amount") == null ? ""
: settle.getBigDecimal("settle_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("order_detail"));
device = clientDeviceMapper.find(settle.getString("dev_id"));
if (device != null)
clientDevId = device.getString("client_dev_id");
row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(clientDevId);
}
row = sheet.createRow(++rowNum);
for (int i = 0; i < analysis.length; i++) {
cell = row.createCell(i, Cell.CELL_TYPE_STRING);
cell.setCellStyle(analysisStyle);
cell.setCellValue(analysis[i]);
}
row = sheet.createRow(++rowNum);
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(clearDetailTotal.getString("total_payment"));
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(clearDetailTotal.getString("total_refund"));
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(clearDetailTotal.getString("gross_amount"));
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(clearDetailTotal.getString("total_charge"));
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(clearDetailTotal.getString("clearing_amount"));
wb.write(ous);
ous.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(ous);
}
}
}

@ -59,5 +59,10 @@ public class TradeFlowController {
return tradeLogService.getClientUnClearedAmount(partner).toString();
}
@PartnerMapping(value = "/settlement/log/excel",method = RequestMethod.GET)
@ResponseBody
public void exportSettlementLog(TradeLogQuery query, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse response) {
tradeLogService.exportSettlementLog(query, partner, response);
}
}

@ -10,10 +10,11 @@
c.city,
c.get_prize,
c.bd_group,
c.kpi_amount
c.kpi_amount,
m.is_valid
FROM sys_managers m
LEFT JOIN financial_bd_config c ON c.manager_id = m.manager_id
WHERE m.role & 4 > 0 AND m.is_valid = 1 AND (m.org_id = 1 OR m.org_id IS NULL)
WHERE m.role & 4 > 0 AND (m.org_id = 1 OR m.org_id IS NULL)
]]>
</select>

@ -1032,4 +1032,70 @@
and t.transaction_type = 'Debit'
</select>
<select id="getClearDetailTotal" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
client_id,
sum(total_payment) total_payment,
sum(total_refund) total_refund,
sum(gross_amount) gross_amount,
SUM(clearing_amount) clearing_amount,
sum(total_charge) total_charge
from (
SELECT
t.client_id,
total_payment,
total_refund,
gross_amount,
cd.clearing_amount,
total_charge
FROM
pmt_transactions t
LEFT JOIN log_clearing_detail cd ON cd.clear_detail_id = t.clearing_order
WHERE
t.channel = 'Settlement' and t.client_id=#{client_id}
]]>
<if test="from!=null">and t.transaction_time &gt;= #{from}</if>
<if test="to!=null">and t.transaction_time &lt; #{to}</if>
GROUP BY
t.order_id) temp
</select>
<select id="getSettlementLogDetailList" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
t.*, o.display_amount,
o.client_order_id,
o.gateway,
r.out_refund_id,
r.client_refund_id,
o.order_detail,
o.dev_id,
a.rate
FROM
pmt_transactions t
LEFT JOIN pmt_orders o ON o.order_id = t.order_id
LEFT JOIN pmt_refunds r ON r.refund_id = t.refund_id
LEFT JOIN log_clearing_detail_analysis a ON a.clearing_detail_id = t.clearing_order
AND t.channel = a.channel
WHERE t.channel != 'Settlement' AND t.client_id = #{client_id}
]]>
<if test="clientOrders!=null">
AND t.clearing_order IN
<foreach collection="clientOrders" open="(" close=")" separator="," item="clearing_order">
#{clearing_order}
</foreach>
</if>
ORDER BY transaction_time DESC
</select>
<select id="getClientOrderByTransactionTime" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT t.clearing_order
FROM pmt_transactions t
WHERE t.channel='Settlement' AND client_id = #{client_id}
]]>
<if test="from!=null">and t.transaction_time &gt;= #{from}</if>
<if test="to!=null">and t.transaction_time &lt; #{to}</if>
</select>
</mapper>

@ -349,7 +349,7 @@
<div class="form-group has-feedback"
ng-class="{'has-error':companyForm.short_name.$invalid && companyForm.short_name.$dirty}">
<input type="text" class="form-control" ng-model="partner.short_name" name="short_name"
placeholder="Merchant Name" required maxlength="50">
placeholder="Merchant Name" required maxlength="15">
</div>
<div class="form-group has-feedback"
ng-class="{'has-error':companyForm.company_phone.$invalid && companyForm.company_phone.$dirty}">

@ -332,7 +332,7 @@
<div class="form-group has-feedback"
ng-class="{'has-error':partnerForm.short_name.$invalid && partnerForm.short_name.$dirty}">
<input type="text" class="form-control" ng-model="partner.short_name" name="short_name"
placeholder="Store Name /Company Name" required maxlength="80">
placeholder="Store Name /Company Name" required maxlength="15">
<span ng-messages="partnerForm.short_name.$error" ng-if="partnerForm.short_name.$dirty" ng-message="required">
</span>
</div>

@ -46,13 +46,13 @@
<label class="control-label col-sm-2" for="short-name-input">* Short Name</label>
<div class="col-sm-8">
<input class="form-control" ng-model="partner.short_name" type="text"
name="short_name" id="short-name-input" required maxlength="50">
name="short_name" id="short-name-input" required maxlength="15">
<p class="small text-info">short name for WeChat payment display and partner
name</p>
<div ng-messages="partnerForm.short_name.$error"
ng-if="partnerForm.company_name.$dirty">
<p class="small text-danger" ng-message="required">Required Field</p>
<p class="small text-danger" ng-message="maxlength">Less Than 50
<p class="small text-danger" ng-message="maxlength">Less Than 15
Characters(including symbols and spaces)</p>
</div>
</div>

@ -124,7 +124,8 @@
</thead>
<tbody>
<tr ng-repeat="bd in bds|filter:{get_prize:true}">
<td ng-bind="bd.display_name"></td>
<td ng-if="bd.is_valid==1">{{bd.display_name}}</td>
<td ng-if="bd.is_valid==0"><s>{{bd.display_name}}</s><span style="color: red"> (Left Company)</span></td>
<td>
<input type="number" ng-model="bd.kpi_amount" min="0">
</td>

@ -77,7 +77,7 @@
<input class="form-control" ng-model="partner.short_name"
type="text"
name="short_name" id="short-name-input" required
maxlength="50">
maxlength="15">
<p class="small text-info">short name for WeChat payment display
and partner
name</p>
@ -86,7 +86,7 @@
<p class="small text-danger" ng-message="required">Required
Field</p>
<p class="small text-danger" ng-message="maxlength">Less
Than 50
Than 15
Characters(including symbols and spaces)</p>
</div>
</div>

@ -58,13 +58,13 @@
<label class="control-label col-sm-2" for="short-name-input">* Short Name</label>
<div class="col-sm-8">
<input class="form-control" ng-model="partner.short_name" type="text"
name="short_name" id="short-name-input" required maxlength="50">
name="short_name" id="short-name-input" required maxlength="15">
<p class="small text-info">short name for WeChat payment display and partner
name</p>
<div ng-messages="partnerForm.short_name.$error"
ng-if="partnerForm.company_name.$dirty">
<p class="small text-danger" ng-message="required">Required Field</p>
<p class="small text-danger" ng-message="maxlength">Less Than 50
<p class="small text-danger" ng-message="maxlength">Less Than 15
Characters(including symbols and spaces)</p>
</div>
</div>

@ -37,10 +37,10 @@
<label class="control-label col-sm-3" for="company_shortname_input">* Company Short Name</label>
<div class="col-sm-8">
<input class="form-control" ng-model="subMerchantInfo.short_name"
type="text" name="company_shortname" id="company_shortname_input" required maxlength="50">
type="text" name="company_shortname" id="company_shortname_input" required maxlength="15">
<div ng-messages="subForm.company_shortname.$error" ng-if="subForm.company_shortname.$dirty">
<p class="small text-danger" ng-message="required">Required Field</p>
<p class="small text-danger" ng-message="maxlength">Length is more than 50</p>
<p class="small text-danger" ng-message="maxlength">Length is more than 15</p>
</div>
</div>
</div>

@ -344,9 +344,9 @@
<label class="control-label col-sm-2" for="company-name-input">Short Name</label>
<div class="col-sm-8">
<input class="form-control" ng-model="partner.short_name" type="text" name="short_name"
id="short-name-input" maxlength="50" required>
id="short-name-input" maxlength="15" required>
<div ng-messages="partnerForm.short_name.$error" ng-if="partnerForm.short_name.$dirty">
<p class="small text-danger" ng-message="required">No more than 50 characters</p>
<p class="small text-danger" ng-message="required">No more than 15 characters</p>
</div>
</div>
</div>

@ -62,13 +62,13 @@
<div class="col-sm-8">
<input class="form-control" ng-model="partner.short_name" type="text"
name="short_name"
id="short-name-input" required maxlength="50">
id="short-name-input" required maxlength="15">
<p class="small text-info">short name for WeChat payment display and partner
name</p>
<div ng-messages="partnerForm.short_name.$error"
ng-if="partnerForm.company_name.$dirty">
<p class="small text-danger" ng-message="required">Required Field</p>
<p class="small text-danger" ng-message="maxlength">Less Than 50
<p class="small text-danger" ng-message="maxlength">Less Than 15
Characters(including symbols and spaces)</p>
</div>
</div>
@ -111,13 +111,13 @@
<div class="col-sm-8">
<input class="form-control" ng-model="partner.short_name" type="text"
name="short_name"
id="short-name-input" required maxlength="50">
id="short-name-input" required maxlength="15">
<p class="small text-info">short name for WeChat payment display and partner
name</p>
<div ng-messages="partnerForm.short_name.$error"
ng-if="partnerForm.company_name.$dirty">
<p class="small text-danger" ng-message="required">Required Field</p>
<p class="small text-danger" ng-message="maxlength">Less Than 50
<p class="small text-danger" ng-message="maxlength">Less Than 15
Characters(including symbols and spaces)</p>
</div>
</div>

@ -92,6 +92,22 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
};
$scope.loadSettlementLogs(1);
$scope.exportSettlementLogs = function() {
var params = angular.copy($scope.params);
var url = '/client/trans_flow/settlement/log/excel';
var connectSymbol = '?';
if (params.datefrom) {
params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd');
url += connectSymbol + 'datefrom=' + params.datefrom;
connectSymbol = '&';
}
if (params.dateto) {
params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
url += connectSymbol + 'dateto=' + params.dateto;
}
return url;
};
var getClientUnClearedAmount = function () {
$http.get('/client/trans_flow/settlement/unclear').then(function (resp) {
$scope.unclear = resp.data;

@ -88,6 +88,9 @@
<button class="btn btn-success" type="button" ng-click="loadSettlementLogs()">
<i class="fa fa-search"></i> Search
</button>
<a role="button" class="btn btn-primary" style="float: right;right: 20px;" type="button" ng-href="{{exportSettlementLogs()}}">
<i class="fa fa-download"></i> export
</a>
</div>
</div>
</div>

Loading…
Cancel
Save