customized settle download view; shopify hmac log

master
Yixian 3 years ago
parent a3e5a4beb7
commit 6d9986d044

@ -56,6 +56,8 @@ public interface CleanService {
void settlementAba(Date date, HttpServletResponse response) throws IOException;
List<JSONObject> getCustomizedSettleDaily(Date date);
void getCustomizedSettleABA(int logId, HttpServletResponse response);
void getSettlementFilesForBatch(String batchId, HttpServletResponse resp) throws IOException;

@ -668,6 +668,15 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
}
}
@Override
public List<JSONObject> getCustomizedSettleDaily(Date date) {
DateTime dtFrom = new DateTime(date);
DateTime dtTo = dtFrom.plusDays(1);
List<JSONObject> logs = customizedSettleLogMapper.listByDate(dtFrom.toDate(), dtTo.toDate());
logs.forEach(log -> log.put("aba_file", String.format("/sys/settlement/customized_settle/%s/aba_file", log.getIntValue("log_id"))));
return logs;
}
@Override
public void getCustomizedSettleABA(int logId, HttpServletResponse response) {
JSONObject log = customizedSettleLogMapper.find(logId);
@ -686,7 +695,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
settle.put("client_moniker", log.getString("client_moniker"));
ABAFile file = generateSettleAbaFile(bank, group, new Date(), Collections.singletonList(settle));
response.setContentType("application/octet-stream;");
response.addHeader("Content-Disposition", "attachment; filename=" + file.filename());
String filename = String.format("[%s]Manual_Settle_%s_%s.aba", logId, log.getString("client_moniker"), DateTime.now().toString("yyyyMMdd"));
response.addHeader("Content-Disposition", "attachment; filename=" + filename);
try (OutputStream ous = response.getOutputStream()) {
ous.write(file.output(1));
ous.flush();

@ -9,6 +9,7 @@ import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.merchants.beans.BalanceGroup;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject;
import org.joda.time.DateTime;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@ -170,6 +171,12 @@ public class SettlementDevController {
}
}
@GetMapping("/customized_settle/dates/{date}")
public List<JSONObject> customizedSettleInDay(@PathVariable String date){
Date dt = DateTime.parse(date).withTimeAtStartOfDay().toDate();
return cleanService.getCustomizedSettleDaily(dt);
}
@GetMapping("/customized_settle/{logId}/aba_file")
public void getCustomizedSettleABAFile(@PathVariable int logId,HttpServletResponse response){
cleanService.getCustomizedSettleABA(logId, response);

@ -5,10 +5,17 @@ import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper;
import com.yixsoft.support.mybatis.autosql.annotations.AutoSql;
import com.yixsoft.support.mybatis.autosql.annotations.SqlType;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.util.Date;
import java.util.List;
@AutoMapper(tablename = "log_settle_customized", pkName = "log_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface CustomizedSettleLogMapper {
@AutoSql(SqlType.SELECT)
JSONObject find(@Param("log_id") int logId);
@Select("select * from log_settle_customized where create_time between #{date_from} and #{date_to}")
List<JSONObject> listByDate(@Param("date_from") Date dateFrom,@Param("date_to") Date dateTo);
}

@ -5,6 +5,8 @@ import org.apache.commons.codec.digest.HmacUtils;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.crypto.RuntimeCryptoException;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
@ -15,6 +17,10 @@ import java.security.Security;
import java.util.Locale;
public class HmacVerificationUtil {
private static final Logger logger = LoggerFactory.getLogger(HmacVerificationUtil.class);
private HmacVerificationUtil() {
}
public static boolean checkParameters(String message, String secret, String hmac) {
try {
@ -32,6 +38,7 @@ public class HmacVerificationUtil {
public static boolean hmacSHA256(String input, String key, String hmac) {
String encode = encode(input, key, HmacAlgorithms.HMAC_SHA_256);
logger.debug("input={}; key={}; encoded={}; request-hmac: {}", input, key, encode, hmac);
return StringUtils.equals(encode, hmac);
}

@ -269,6 +269,18 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
$state.reload();
};
$scope.showCustomizedSettle = function () {
$uibModal.open({
templateUrl: '/static/analysis/templates/dialog_customized_settle.html',
controller: 'customizedDialogCtrl',
resolve: {
customizedLogs: function () {
return $http.get('/sys/settlement/customized_settlements/dates/' + $scope.datePattern)
}
}
})
}
let nowStr = $filter('date')(new Date(), "yyyy-MM-dd");
$scope.datePattern = $stateParams.date;
if ($scope.datePattern == nowStr) {
@ -375,6 +387,10 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
})
}
}]);
app.controller('customizedDialogCtrl', ['$scope', 'customizedLogs', function ($scope, customizedLogs) {
$scope.customizedLogs = customizedLogs.data
}])
app.controller('settlementTransactionsCtrl', ['$scope', '$stateParams', 'detail', function ($scope, $stateParams, detail) {
$scope.ctrl = {channel: null};
$scope.report = detail.data;

@ -0,0 +1,27 @@
<div class="modal-header">Manual Settlements</div>
<div class="modal-body">
<table class="table table-striped table-bordered table-hover" ng-if="customizedLogs.length">
<thead>
<tr>
<th>Merchant</th>
<th>Amount</th>
<th>Operation</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="log in customizedLogs">
<td ng-bind="log.client_moniker"></td>
<td ng-bind="log.amount|currency:''"></td>
<td>
<a title="Download" ng-href="{{log.aba_file}}" target="_blank"><i class="fa fa-download"></i></a>
</td>
</tr>
</tbody>
</table>
<div ng-if="!customizedLogs.length">
No manual settlements today
</div>
</div>
<div class="modal-footer">
<button class="btn btn-danger" ng-click="$dismiss()">OK</button>
</div>

@ -43,6 +43,9 @@
<button class="btn btn-success pull-right" ng-click="reloadPage()">
<i class="fa fa-refresh"></i>Reload
</button>
<button class="btn btn-primary" ng-click="showCustomizedSettle()">
<i class="fa fa-money"></i> Manual Settlements
</button>
<a ui-sref="settle_tasks" class="btn btn-primary">Settle Tasks</a>
</div>
</div>

@ -1,10 +1,8 @@
package au.com.royalpay.payment.manage.valid;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.springframework.web.bind.annotation.RequestMethod;
@ -12,7 +10,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

Loading…
Cancel
Save