Merge branch 'develop'

master
luoyang 6 years ago
commit 5f726c71ec

@ -31,6 +31,7 @@ import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.locale.LocaleSupport;
import au.com.royalpay.payment.tools.lock.Locker;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.tasksupport.TaskFinishNotifyEvent;
import au.com.royalpay.payment.tools.utils.PageListUtils;
@ -153,6 +154,12 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
private ClientConfigService clientConfigService;
@Resource
private SysConfigManager sysConfigManager;
@Resource
private ClientsSurchargeAccountsMapper clientsSurchargeAccountsMapper;
@Resource
private ClearingDistributedSurchargeMapper clearingDistributedSurchargeMapper;
@Resource
private Locker locker;
@Resource
private ClientDeviceMapper clientDeviceMapper;
@ -1241,6 +1248,13 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
if (!log.getBooleanValue("editable")) {
throw new ForbiddenException("Settlement log has been sent and unable to edit");
}
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(clearingId);
List<JSONObject> detailsWithDistributedSurcharge = details.stream().filter(detail -> detail.getBigDecimal("distributed_surcharge").compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
if (!detailsWithDistributedSurcharge.isEmpty()) {
for (JSONObject detail : detailsWithDistributedSurcharge) {
releaseDistributedSurcharge(detail);
}
}
transactionMapper.deleteSettlementTransaction(clearingId);
transactionMapper.removeSettleRemark(clearingId);
clearingDetailAnalysisMapper.clearAnalysis(clearingId);
@ -1249,6 +1263,47 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
clearingLogMapper.deleteSettleLogs(clearingId);
}
private void releaseDistributedSurcharge(JSONObject clearingDetail) {
int clientId = clearingDetail.getIntValue("client_id");
BigDecimal distributedSurcharge = clearingDetail.getBigDecimal("distributed_surcharge");
String lockKey = "client_surcharge_account_processing:" + clientId;
locker.lock(lockKey, 30_000, 1000);
try {
JSONObject account = getClientSurchargeAccount(clientId);
BigDecimal balance = account.getBigDecimal("balance");
BigDecimal newBalance = balance.add(distributedSurcharge);
JSONObject surchargeLog = new JSONObject();
String logId = DateFormatUtils.format(new Date(), "yyyyMMdd") + clientId + RandomStringUtils.random(5, true, true).toUpperCase();
surchargeLog.put("log_id", logId);
surchargeLog.put("client_id", clientId);
surchargeLog.put("clearing_detail_id", clearingDetail.getString("clear_detail_id"));
surchargeLog.put("settle_date", clearingDetail.getDate("report_date"));
surchargeLog.put("create_time", new Date());
surchargeLog.put("amount", distributedSurcharge);
surchargeLog.put("total_surcharge", clearingDetail.getBigDecimal("total_charge"));
surchargeLog.put("tax_amount", clearingDetail.getBigDecimal("tax_amount"));
surchargeLog.put("type", "Credit");
surchargeLog.put("post_balance", newBalance);
surchargeLog.put("remark", "settle revoke");
clearingDistributedSurchargeMapper.save(surchargeLog);
clientsSurchargeAccountsMapper.updateBalance(clientId, newBalance);
} finally {
locker.unlock(lockKey);
}
}
private JSONObject getClientSurchargeAccount(int clientId) {
JSONObject account = clientsSurchargeAccountsMapper.find(clientId);
if (account == null) {
account = new JSONObject();
account.put("client_id", clientId);
account.put("create_time", new Date());
account.put("balance", 0);
clientsSurchargeAccountsMapper.save(account);
}
return account;
}
private byte[] getZipByteArr(List<JSONObject> fileByteArrWithName) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(bos);

@ -7,7 +7,7 @@ import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.math.BigDecimal;
@AutoMapper(tablename = "sys_clients_surcharge_accounts", pkName = "client_id")
@ -22,4 +22,7 @@ public interface ClientsSurchargeAccountsMapper {
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject surchargeAccount);
@AutoSql(type = SqlType.UPDATE)
void updateBalance(@Param("client_id") int clientId, @Param("balance") BigDecimal balance);
}

@ -327,7 +327,13 @@ public interface ClientManager {
String subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager);
void registerAlipayGms(String clientMoniker,JSONObject manager);
void registerAlipayGms(String clientMoniker, String representative_id, JSONObject manager);
void registerAlipayOnlineGms(String clientMoniker, String representative_id, JSONObject manager);
String queryAlipayGmsStatus(String clientMoniker, JSONObject manager);
String queryAlipayOnlineGmsStatus(String clientMoniker, JSONObject manager);
List<JSONObject> listMerchantIds(String clientMoniker,JSONObject manager);

@ -3789,7 +3789,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
@Override
public void registerAlipayGms(String clientMoniker, JSONObject manager) {
public void registerAlipayGms(String clientMoniker, String representative_id, JSONObject manager) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
@ -3798,6 +3798,19 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (!client.containsKey("store_photo") || !client.containsKey("company_photo")) {
throw new InvalidParameterException("store photo cannot be empty ");
}
JSONObject client_bank = getBankAccountByClientId(client.getIntValue("client_id"));
if (client_bank == null || client_bank.size() <= 0) {
throw new BadRequestException("The Partner's Account is not config!");
}
client.put("bank_id", client_bank.getString("account_no"));
if (!"Company".equals(client.getString("business_structure"))) {
if (representative_id == null || representative_id.isEmpty()) {
throw new BadRequestException("ID or passport number can't be null");
}
client.put("representative_id", representative_id);
}
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant();
Element resultElement = alipayClient.registerGmsPortal(mch.getPid(), client);
if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) {
@ -3813,6 +3826,74 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
@Override
public String queryAlipayGmsStatus(String clientMoniker, JSONObject manager) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
checkOrgPermission(manager, client);
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant();
Element resultElement = alipayClient.queryGmsPortalStatus(mch.getPid(), client);
if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) {
return "查询成功:" + resultElement.elementText("error");
}
Element responseElement = resultElement.element("response").element("alipay");
return "查询成功:" + responseElement.elementText("secondary_merchant_id") + "报备状态 : " + responseElement.elementText("status");
}
@Override
public void registerAlipayOnlineGms(String clientMoniker, String representative_id, JSONObject manager) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
checkOrgPermission(manager, client);
if (!client.containsKey("company_website")) {
throw new InvalidParameterException("Website cannot be empty ");
}
JSONObject client_bank = getBankAccountByClientId(client.getIntValue("client_id"));
if (client_bank == null || client_bank.size() <= 0) {
throw new BadRequestException("The Partner's Account is not config!");
}
client.put("bank_id", client_bank.getString("account_no"));
if (representative_id == null || representative_id.isEmpty()) {
throw new BadRequestException("ID or passport number can't be null");
}
client.put("representative_id", representative_id);
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant();
Element resultElement = alipayClient.registerOnlineGmsPortal(mch.getPid(), client);
if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) {
throw new BadRequestException(resultElement.elementText("error"));
}
try {
Element responseElement = resultElement.element("response").element("alipay");
if (!StringUtils.equalsIgnoreCase("SUCCESS", responseElement.elementText("result_code"))) {
throw new BadRequestException(responseElement.elementText("result_code"));
}
} catch (Exception e) {
throw new ServerErrorException(e);
}
}
@Override
public String queryAlipayOnlineGmsStatus(String clientMoniker, JSONObject manager) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
checkOrgPermission(manager, client);
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant();
Element resultElement = alipayClient.queryOnlineGmsPortalStatus(mch.getPid(), client);
if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) {
return "查询成功:" + resultElement.elementText("error");
}
Element responseElement = resultElement.element("response").element("alipay");
return "查询成功:" + responseElement.elementText("secondary_merchant_id") + "报备状态 : " + responseElement.elementText("status");
}
@Override
public void subRpayMerchantApplication(String clientMoniker, JSONObject merchantInfo,JSONObject manager) {
JSONObject client = getClientInfoByMoniker(clientMoniker);

@ -601,8 +601,23 @@ public class PartnerManageController {
}
@ManagerMapping(value = "/{clientMoniker}/register/alipay_gms", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
public void registerAlipayGms(@PathVariable String clientMoniker,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.registerAlipayGms(clientMoniker,manager);
public void registerAlipayGms(@PathVariable String clientMoniker,@RequestBody String representative_id,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.registerAlipayGms(clientMoniker, representative_id, manager);
}
@ManagerMapping(value = "/{clientMoniker}/query/alipay_gms", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
public String queryAlipayGmsStatus(@PathVariable String clientMoniker,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.queryAlipayGmsStatus(clientMoniker, manager);
}
@ManagerMapping(value = "/{clientMoniker}/register/alipayOnline_gms", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
public void registerAlipayOnlineGms(@PathVariable String clientMoniker,@RequestBody String representative_id,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.registerAlipayOnlineGms(clientMoniker, representative_id, manager);
}
@ManagerMapping(value = "/{clientMoniker}/query/alipayOnline_gms", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
public String queryAlipayOnlineGmsStatus(@PathVariable String clientMoniker,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.queryAlipayOnlineGmsStatus(clientMoniker, manager);
}
@ManagerMapping(value = "/{clientMoniker}/get_merchant_ids",method = RequestMethod.GET,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN})

@ -1509,13 +1509,52 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
title: 'Warning',
content: '是否使用该商户的现有信息进件?'
}).then(function () {
$http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms').then(function () {
commonDialog.alert({title: 'Success', content: 'Alipay进件成功', type: 'success'});
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
})
if ($scope.partner.business_structure == "Company"){
$http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms',{representative_id:""}).then(function () {
commonDialog.alert({title: 'Success', content: 'Alipay进件成功', type: 'success'});
}, function (resp) {
commonDialog.alert({title: 'Error', content: "进件失败:" + resp.data.message, type: 'error'});
})
}else {
commonDialog.inputText({title: '请输入商户身份证或护照号码'}).then(function (text) {
$http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms',{representative_id:text}).then(function () {
commonDialog.alert({title: 'Success', content: '提示Alipay进件成功', type: 'success'});
}, function (resp) {
commonDialog.alert({title: 'Error', content: "进件失败:" + resp.data.message, type: 'error'});
})
});
}
})
};
$scope.queryAlipayGms = function () {
$http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms').then(function (resp) {
commonDialog.alert({title: 'Success', content: resp.data, type: 'success'});
}, function (resp) {
commonDialog.alert({title: 'Error', content: "查询失败:" + resp.data.message, type: 'error'});
})
}
$scope.submitAlipayOnlineSubId = function () {
commonDialog.confirm({
title: 'Warning',
content: '是否使用该商户的现有信息进件?'
}).then(function () {
commonDialog.inputText({title: '请输入商户身份证或护照号码'}).then(function (text) {
$http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipayOnline_gms',{representative_id:text}).then(function () {
commonDialog.alert({title: 'Success', content: '提示AlipayOnline进件成功', type: 'success'});
}, function (resp) {
commonDialog.alert({title: 'Error', content: "进件失败:" + resp.data.message, type: 'error'});
})
});
})
};
$scope.queryAlipayOnlineGms = function () {
$http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipayOnline_gms').then(function (resp) {
commonDialog.alert({title: 'Success', content: resp.data, type: 'success'});
}, function (resp) {
commonDialog.alert({title: 'Error', content: "查询失败:" + resp.data.message, type: 'error'});
})
}
$scope.refreshCredential = function () {
commonDialog.confirm({
title: 'Warning',

@ -72,6 +72,11 @@
{{paymentInfo.ali_sub_merchant_id||'Not Configure'}}
<a role="button" ng-click="ctrl.editAliSubMerchant=true" ng-if="'10'|withRole"><i class="fa fa-edit"></i></a>
<a role="button" ng-click="submitAlipaySubId()"><i class="fa fa-arrow-up" title="Alipay进件"></i></a>
<a role="button" ng-click="queryAlipayGms()"><i class="fa fa-refresh" title="Alipay进件"></i></a>
|
<a role="button" ng-click="submitAlipayOnlineSubId()"><i class="fa fa-arrow-up" title="AlipayOnline进件"></i></a>
<a role="button" ng-click="queryAlipayOnlineGms()"><i class="fa fa-refresh" title="AlipayOnline进件"></i></a>
(AlipayOnline)
</p>
<div class="input-group" ng-if="ctrl.editAliSubMerchant">
<input type="text" class="form-control" ng-model="paymentInfo.ali_sub_merchant_id"

Loading…
Cancel
Save