fix 跨境商城优化、gateway进件优化

master
luoyang 5 years ago
parent 8bec790b96
commit 381e26453c

@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>1.3.83</version>
<version>1.3.84</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.8.0</jib-maven-plugin.version>

@ -10,7 +10,7 @@ public interface RetailRSvcService {
* @param sourceCode
* @return
*/
JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode);
JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode, boolean debug);
JSONObject enterIntoServiceBySourceCode(String sourceCode, JSONObject params);

@ -11,7 +11,6 @@ import au.com.royalpay.payment.tools.codec.AESCrypt;
import au.com.royalpay.payment.tools.device.DeviceSupport;
import au.com.royalpay.payment.tools.encryptalgorithm.SignUtils;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.mappers.CommonIncrementalChannelMapper;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@ -44,9 +43,13 @@ public class RetailRSvcServiceImpl implements RetailRSvcService {
private ClientConfigMapper clientConfigMapper;
@Override
public JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode) {
public JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode, boolean debug) {
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
JSONObject clientConfig = clientConfigMapper.find(device.getIntValue("client_id"));
if (!debug && !clientConfig.getBooleanValue("geek_shop_status")) {
throw new BadRequestException("商户未开店");
}
JSONObject svcInfo = commonIncrementalChannelMapper.findIncreamentalChannelBySourceCode(sourceCode);
if (svcInfo == null || StringUtils.isEmpty(svcInfo.getString("channel_pub_key"))
|| StringUtils.isEmpty(svcInfo.getString("platform_pub_key")) || StringUtils.isEmpty("platform_pri_key")) {

@ -4,10 +4,7 @@ import au.com.royalpay.payment.manage.appclient.core.RetailRSvcService;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.device.advise.AppClientController;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -19,8 +16,10 @@ public class RetailRSvcController {
private RetailRSvcService retailRSvcService;
@GetMapping(value = "/{source_code}/userinfo")
public JSONObject findUserInfoBySourceCode(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String source_code) {
return retailRSvcService.findMchInfoBySourceCode(device, source_code);
public JSONObject findUserInfoBySourceCode(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,
@PathVariable String source_code,
@RequestParam(defaultValue = "false", required = false) boolean debug) {
return retailRSvcService.findMchInfoBySourceCode(device, source_code, debug);
}

@ -25,7 +25,7 @@ public class ClientComplianceFileConfig {
@JSONField(name = "utility_bill")
private String utilityBill;
private static String[] WHITE_LIST = {"utility_bill","id_title_description"};
private static String[] WHITE_LIST = {"utilityBill","idTitleDesc"};
public void checkParamsInvalid() throws IllegalAccessException {
for (Field field : getClass().getDeclaredFields()) {

@ -25,7 +25,7 @@ public class ClientPayConfig {
@JSONField(name = "company_website")
private String companyWebsite;
private static String[] WHITE_LIST = {"companyWebsite","store_photo", "company_photo"};
private static String[] WHITE_LIST = {"companyWebsite","storePhoto", "companyPhoto"};
public void checkParamsInvalid() throws IllegalAccessException {

@ -7,6 +7,8 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field;
@ -18,6 +20,8 @@ import java.util.Date;
*/
@Data
public class ClientRegisterInfo {
private static final String[] DATE_PATTERNS = {"yyyy-MM-dd HH:mm:ss"};
private org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
@JSONField(name = "apply_id")
private String applyId;
@ -118,7 +122,8 @@ public class ClientRegisterInfo {
public JSONObject insertClientRateInfo(JSONObject defaultRateConfig) {
JSONObject rate = new JSONObject();
rate.put("clean_days", settleConfig.getCleanDays());
rate.put("active_time", settleConfig.getActiveTime());
Date lessActiveTime = DateUtils.addDays(settleConfig.getActiveTimeDate(), -1);
rate.put("active_time", DateFormatUtils.format(lessActiveTime,"yyyy-MM-dd HH:mm:ss"));
rate.put("expiry_time", settleConfig.getExpireTime());
rate.put("wechat_rate_value", settleConfig.getWechatRate());
rate.put("alipay_rate_value", settleConfig.getAlipayRate());

@ -1,28 +1,34 @@
package au.com.royalpay.payment.manage.gateway.beans;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import au.com.royalpay.payment.manage.system.core.impl.ClientContractServiceImpl;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMethod;
import java.io.IOException;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Data
public class ClientSettleConfig {
private Logger logger = LoggerFactory.getLogger(ClientContractServiceImpl.class);
@JSONField(name = "swift_code")
private String swiftCode;
@JSONField(name = "bsb_no")
private String bsbNo;
private String bank;
private String city;
private String address;
private String system;
private String postcode;
private String state;
private String branch;
@JSONField(name = "account_no")
private String accountNo;
@JSONField(name = "account_name")
@ -41,21 +47,19 @@ public class ClientSettleConfig {
private String activeTime;
@JSONField(name = "expire_time")
private String expireTime;
private JSONObject bankQueryInfo;
private Date activeTimeDate;
private static String[] WHITE_LIST = {"bankQueryInfo","activeTimeDate"};
private static Pattern ACCOUNT_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9 &]+$");
public void checkParamsInvalid() throws IllegalAccessException {
for (Field field : getClass().getDeclaredFields()) {
field.setAccessible(true);
if (field.get(this) == null) {
if (field.get(this) == null && !Arrays.asList(WHITE_LIST).contains(field.getName())) {
throw new ParamInvalidException(field.getName(), "Required Param " + field.getName() +" not found");
}
}
}
public JSONObject insertBankInfo() {
JSONObject bankInfo = new JSONObject();
if (swiftCode.length() > 12) {
throw new BadRequestException("PARAM_ERROR:Switft code must be less than 12 characters");
}
@ -68,21 +72,46 @@ public class ClientSettleConfig {
if (accountName.length() > 50) {
throw new BadRequestException("PARAM_ERROR:Account Name must be less than 50 characters");
}
Matcher matcher = ACCOUNT_NAME_PATTERN.matcher(accountName);
if (!matcher.matches()) {
throw new BadRequestException("PARAM_ERROR:Invalid Account Name format");
}
bankQueryInfo = getBankInfo(bsbNo);
if (bankQueryInfo == null || bankQueryInfo.isEmpty() || !bankQueryInfo.getBooleanValue("valid")) {
throw new BadRequestException("PARAM_ERROR:BSB No is invalid");
}
try {
activeTimeDate = DateUtils.parseDate(activeTime, new String[]{"yyyy-MM-dd HH:mm:ss"});
} catch (ParseException e) {
throw new BadRequestException("PARAM_ERROR:Invalid ActiveTime format");
}
}
public JSONObject insertBankInfo() {
JSONObject bankInfo = new JSONObject();
bankInfo.put("swift_code", swiftCode);
bankInfo.put("bsb_no", bsbNo);
bankInfo.put("account_no", accountNo);
bankInfo.put("account_name", accountName);
bankInfo.put("bank", bank);
bankInfo.put("city", city);
bankInfo.put("address", address);
bankInfo.put("system", system);
bankInfo.put("postcode", postcode);
bankInfo.put("state", state);
bankInfo.put("branch", branch);
bankInfo.putAll(bankQueryInfo);
return bankInfo;
}
private JSONObject getBankInfo(String bsb_no) {
// bd451cc3e3ad66c75165dc852507e8f0
// 收费 ab9379cfdab559509bbdcdd11923489f
String url = "https://api.bank.codes/au-bsb/json/ab9379cfdab559509bbdcdd11923489f/" + bsb_no;
JSONObject res = new JSONObject();
try {
HttpRequestResult result = new HttpRequestGenerator(url, RequestMethod.GET).execute();
if (result.isSuccess()) {
res = result.getResponseContentJSONObj();
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return res;
}
}

@ -100,7 +100,7 @@ public class GatewayMerchantApplyImpl implements GatewayMerchantApply {
JSONObject client = registerBean.insertClientInfo(clientManager.initMerchantCode(), manager.getString("display_name"), hasParentBoolean, parentClientId);
client.put("org_id", org.getString("org_id"));
clientMapper.save(client);
clientConfigMapper.save(registerBean.insertClientConfigInfo(client.getIntValue("client_id"),client.getString("client_moniker")));
clientConfigMapper.save(registerBean.insertClientConfigInfo(client.getIntValue("client_id"), client.getString("client_moniker")));
sysClientLegalPersonMapper.save(registerBean.insertClientLegalInfo(client.getIntValue("client_id")));
permissionPartnerManagerImpl.permissionClientModuleSave(client.getIntValue("client_id"), client.getString("client_moniker"));
JSONObject clientBd = new JSONObject();
@ -113,7 +113,7 @@ public class GatewayMerchantApplyImpl implements GatewayMerchantApply {
clientBd.put("proportion", 1);
clientBDMapper.saveBD(clientBd);
clientBankAccountMapper.save(registerBean.insertBankInfo(client.getIntValue("client_id")));
//todo 合规文件待增加source_agree_file
ClientAuthFilesInfo clientAuthFilesInfo = registerBean.insertClientComplianceInfo();
clientManager.uploadAuthFiles(manager, client.getString("client_moniker"), clientAuthFilesInfo);
JSONObject rateConfig = registerBean.insertClientRateInfo(JSONObject.parseObject(sysConfigManager.getSysConfig().getString("sys_rates")));
@ -123,6 +123,9 @@ public class GatewayMerchantApplyImpl implements GatewayMerchantApply {
result.put("credential_code", client.getString("credential_code"));
result.put("company_name", client.getString("company_name"));
result.put("short_name", client.getString("short_name"));
} catch (BadRequestException e) {
logger.error("gateway api register fail :{}", e.getMessage());
throw new BadRequestException("PARAM_ERROR:" + e.getMessage());
} catch (Exception e) {
logger.error("gateway api register fail :{}", e.getMessage());
throw new BadRequestException("PARAM_ERROR:Params length too long");

@ -87,14 +87,7 @@ public class CityPartnerPrizeServiceImplTest {
}};
JSONObject settleConfig = new JSONObject() {{
put("swift_code", "2");
put("bsb_no", "201");
put("bank", "10001");
put("city", "339");
put("address", "4511");
put("system", "sytem");
put("postcode", "postcode");
put("state", "state");
put("branch", "branch");
put("bsb_no", "033385");
put("account_no", "21213131");
put("account_name", "dasdasdasd");
put("clean_days", "2");
@ -102,7 +95,7 @@ public class CityPartnerPrizeServiceImplTest {
put("alipay_rate", "1.2");
put("alipay_online_rate", "1.2");
put("transaction_fee", "0");
put("active_time", "2020-02-04 00:00:00");
put("active_time", "2020-02-06 00:00:00");
put("expire_time", "2021-02-06 00:00:00");
}};
@ -118,7 +111,7 @@ public class CityPartnerPrizeServiceImplTest {
JSONObject params = new JSONObject() {{
put("apply_id", "orgtestadmin4");
put("apply_id", "orgapply1");
put("notify_url", "http://127.0.0.1:9002/sys/partners/7CMV/qrcode");
put("company_info", companyInfo);
put("contact_info", contactInfo);
@ -127,10 +120,11 @@ public class CityPartnerPrizeServiceImplTest {
put("settle_info", settleConfig);
put("compliance_file_info", complianceInfo);
}};
String originUrl = "https://sandbox.royalpay.com.au/api/v1.0/org_gateway/partner/RE2ZLPEAZL/merchant/application";
String originUrl = "http://127.0.0.1:5000/api/v1.0/org_gateway/partner/AXLCEXDDMB/merchant/application";
String url = addSignUrl(originUrl, params, PRIKEY);
HttpRequestGenerator gen = new HttpRequestGenerator(url, RequestMethod.POST);
gen.setJSONEntity(params);
gen.setTimeout(10000);
HttpRequestResult result = gen.execute();
if (result.isSuccess()) {
System.out.println(result.getResponseContentJSONObj().toJSONString());
@ -144,7 +138,7 @@ public class CityPartnerPrizeServiceImplTest {
@Test
public void queryMerchantStatus() throws Exception{
String partnerCode = "PHQ3";
String originUrl = "https://sandbox.royalpay.com.au/api/v1.0/org_gateway/partner/RE2ZLPEAZL/merchant/" + partnerCode + "/status";
String originUrl = "http://127.0.0.1:5000/api/v1.0/org_gateway/partner/AXLCEXDDMB/merchant/" + partnerCode + "/status";
String url = addSignUrl(originUrl, null, PRIKEY);
HttpRequestGenerator gen = new HttpRequestGenerator(url, RequestMethod.GET);
HttpRequestResult result = gen.execute();
@ -157,7 +151,7 @@ public class CityPartnerPrizeServiceImplTest {
@Test
public void updateFile() throws Exception{
String originUrl = "https://sandbox.royalpay.com.au/api/v1.0/org_gateway/partner/RE2ZLPEAZL/attachment/files";
String originUrl = "http://127.0.0.1:5000/api/v1.0/org_gateway/partner/AXLCEXDDMB/attachment/files";
String url = addSignUrl(originUrl, null, PRIKEY);
File file = new File("/Users/luoyang/Downloads/banner_eshop.jpg");
InputStream stream = new FileInputStream(file);

Loading…
Cancel
Save