add locker for

master
Yixian 3 years ago
parent d928de507e
commit 239db01769

@ -37,6 +37,7 @@ import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import au.com.royalpay.payment.tools.utils.PdfUtils;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import com.alibaba.fastjson.JSON;
@ -77,6 +78,8 @@ import java.util.Optional;
public class TestController {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Resource
private OrderMapper orderMapper;
@Resource
private RefundMapper refundMapper;
@ -179,6 +182,7 @@ public class TestController {
/**
*
*
* @param clientMoniker
* @param manager
* @param httpResponse
@ -186,7 +190,7 @@ public class TestController {
*/
@ManagerMapping(value = "/{clientMoniker}/export/aggregate/agreepdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR})
public void exportAggregateAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, HttpServletResponse httpResponse) {
logger.info("===>exportAggregateAgreeFile:path:"+aggragatePdfPath);
logger.info("===>exportAggregateAgreeFile:path:" + aggragatePdfPath);
httpResponse.setContentType("application/pdf");
httpResponse.setHeader("content-disposition", "attachment;filename=" + clientMoniker + "_AGREEMENT_" + new Date() + ".pdf");
@ -215,21 +219,21 @@ public class TestController {
throw new BadRequestException("The Partner's Rate is not config!");
}
client.put("wechat_rate", weChatRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN));
client.put("clean", "T+"+weChatRate.getString("clean_days"));
client.put("clean", "T+" + weChatRate.getString("clean_days"));
client.put("clean_days", weChatRate.getString("clean_days"));
client.put("located_country", "Australia");
if("1".equalsIgnoreCase(weChatRate.getString("clean_days"))){
if ("1".equalsIgnoreCase(weChatRate.getString("clean_days"))) {
// clean_1 clean_1_friday clean_1_saturday
// second, third or fourth
client.put("clean_1", weChatRate.getString("clean_days"));
client.put("clean_1_friday", "first");
client.put("clean_1_saturday", "second");
}else if("2".equalsIgnoreCase(weChatRate.getString("clean_days"))){
} else if ("2".equalsIgnoreCase(weChatRate.getString("clean_days"))) {
client.put("clean_1", weChatRate.getString("clean_days"));
client.put("clean_1_friday", "second");
client.put("clean_1_saturday", "third");
}else if("3".equalsIgnoreCase(weChatRate.getString("clean_days"))){
} else if ("3".equalsIgnoreCase(weChatRate.getString("clean_days"))) {
client.put("clean_1", weChatRate.getString("clean_days"));
client.put("clean_1_friday", "third");
client.put("clean_1_saturday", "fourth");
@ -285,6 +289,7 @@ public class TestController {
e.printStackTrace();
}
}
/**
*
*
@ -464,8 +469,15 @@ public class TestController {
}
@GetMapping(value = "/task/analysisDashboard")
public void analysisDashboard(@RequestParam("date") String date) throws ParseException {
public void analysisDashboard(@RequestParam("date") String date) {
synchronizedScheduler.executeProcess("manage_task:dashboardTask", 120_000,
() -> {
try {
dashboardService.generateCustomersAndOrdersStatistics(DateUtils.parseDate(date, "yyyyMMdd"));
} catch (ParseException e) {
logger.error("invalid input date:{}", date);
}
});
}
@ -569,68 +581,67 @@ public class TestController {
*/
@ManagerMapping(value = "/batch_update_wxsubmerchantId", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR, ManagerRole.DEVELOPER})
public void batchUpdateWxSubmerchantId() {
List<JSONObject> findSubMerchantIdHistorys=sysWxMerchantApplyMapper.findSubMerchantIdHistorys();
if(findSubMerchantIdHistorys==null)return;
logger.info("=========>batchUpdateWxSubmerchantId:"+findSubMerchantIdHistorys.size());
List<JSONObject> findSubMerchantIdHistorys = sysWxMerchantApplyMapper.findSubMerchantIdHistorys();
if (findSubMerchantIdHistorys == null) return;
logger.info("=========>batchUpdateWxSubmerchantId:" + findSubMerchantIdHistorys.size());
findSubMerchantIdHistorys.parallelStream().forEach(jsonObject -> {
JSONObject clientJson = clientMapper.findClient(jsonObject.getInteger("client_id"));
JSONObject wechatMcc = paymentChannelMccGoodMapper.findWechatPayMccByClientId(jsonObject.getIntValue("client_id"));
JSONObject clientConfig = clientConfigMapper.find(jsonObject.getIntValue("client_id"));
if(clientJson==null){
logger.info("=========>没有查询到client:"+jsonObject.getInteger("client_id"));
if (clientJson == null) {
logger.info("=========>没有查询到client:" + jsonObject.getInteger("client_id"));
return;
}
if(wechatMcc==null){
logger.info("=========>没有查询到mcc:"+jsonObject.getInteger("client_id"));
if (wechatMcc == null) {
logger.info("=========>没有查询到mcc:" + jsonObject.getInteger("client_id"));
return;
}
// company_name short_name industry company_phone contact_person contact_phone contact_email 这些字段不能为空
if(TextUtils.isEmpty(clientJson.getString("short_name"))||
TextUtils.isEmpty(clientJson.getString("industry"))||
TextUtils.isEmpty(clientJson.getString("company_phone"))||
TextUtils.isEmpty(clientJson.getString("contact_phone"))||
TextUtils.isEmpty(clientJson.getString("contact_person"))||
TextUtils.isEmpty(clientJson.getString("contact_email"))||
TextUtils.isEmpty(wechatMcc.getString("mc_code"))){
logger.error("=======>数据不完整clientid"+jsonObject.getInteger("client_id")+"");
if (TextUtils.isEmpty(clientJson.getString("short_name")) ||
TextUtils.isEmpty(clientJson.getString("industry")) ||
TextUtils.isEmpty(clientJson.getString("company_phone")) ||
TextUtils.isEmpty(clientJson.getString("contact_phone")) ||
TextUtils.isEmpty(clientJson.getString("contact_person")) ||
TextUtils.isEmpty(clientJson.getString("contact_email")) ||
TextUtils.isEmpty(wechatMcc.getString("mc_code"))) {
logger.error("=======>数据不完整clientid" + jsonObject.getInteger("client_id") + "");
return;
}
NewSubMerchantIdApply newSubMerchantIdApply=new NewSubMerchantIdApply();
NewSubMerchantIdApply newSubMerchantIdApply = new NewSubMerchantIdApply();
newSubMerchantIdApply.setMerchant_id(jsonObject.getString("merchant_id"));
newSubMerchantIdApply.setSub_mch_id(jsonObject.getString("sub_merchant_id"));
newSubMerchantIdApply.setMerchantRemark(jsonObject.getString("merchant_remark"));
newSubMerchantIdApply.setMerchant_name(cutLength(jsonObject.getString("merchant_name"),50));
newSubMerchantIdApply.setAddress(cutLength(clientJson.getString("address"),128));
newSubMerchantIdApply.setMerchant_shortname(cutLength(clientJson.getString("short_name"),64));
newSubMerchantIdApply.setMerchant_name(cutLength(jsonObject.getString("merchant_name"), 50));
newSubMerchantIdApply.setAddress(cutLength(clientJson.getString("address"), 128));
newSubMerchantIdApply.setMerchant_shortname(cutLength(clientJson.getString("short_name"), 64));
newSubMerchantIdApply.setBusiness_category(clientJson.getString("industry"));
newSubMerchantIdApply.setWebsite(cutLength(clientJson.getString("company_website"),100));
newSubMerchantIdApply.setOffice_phone(cutLength(clientJson.getString("company_phone"),20));
newSubMerchantIdApply.setContact_phone(cutLength(clientJson.getString("contact_phone"),16));
newSubMerchantIdApply.setContact_name(cutLength(clientJson.getString("contact_person"),32));
newSubMerchantIdApply.setContact_email(cutLength(clientJson.getString("contact_email"),50));
newSubMerchantIdApply.setMcc_code(cutLength(wechatMcc.getString("mc_code"),10));
if(!TextUtils.isEmpty(clientConfig.getString("client_pay_type"))){
if(clientConfig.getString("client_pay_type").indexOf("1")>=0
&&clientConfig.getString("client_pay_type").indexOf("2")>=0){
newSubMerchantIdApply.setWebsite(cutLength(clientJson.getString("company_website"), 100));
newSubMerchantIdApply.setOffice_phone(cutLength(clientJson.getString("company_phone"), 20));
newSubMerchantIdApply.setContact_phone(cutLength(clientJson.getString("contact_phone"), 16));
newSubMerchantIdApply.setContact_name(cutLength(clientJson.getString("contact_person"), 32));
newSubMerchantIdApply.setContact_email(cutLength(clientJson.getString("contact_email"), 50));
newSubMerchantIdApply.setMcc_code(cutLength(wechatMcc.getString("mc_code"), 10));
if (!TextUtils.isEmpty(clientConfig.getString("client_pay_type"))) {
if (clientConfig.getString("client_pay_type").indexOf("1") >= 0
&& clientConfig.getString("client_pay_type").indexOf("2") >= 0) {
newSubMerchantIdApply.setBusiness_type("BOTH");
}else if(clientConfig.getString("client_pay_type").indexOf("1")>=0){
} else if (clientConfig.getString("client_pay_type").indexOf("1") >= 0) {
newSubMerchantIdApply.setBusiness_type("ONLINE");
}
else if(clientConfig.getString("client_pay_type").indexOf("2")>=0){
} else if (clientConfig.getString("client_pay_type").indexOf("2") >= 0) {
newSubMerchantIdApply.setBusiness_type("OFFLINE");
}
}else{
} else {
newSubMerchantIdApply.setBusiness_type("BOTH");
}
if (!TextUtils.isEmpty(clientJson.getString("business_structure"))) {
newSubMerchantIdApply.setMerchant_type(clientJson.getString("business_structure").equals("Registered body(Sole Trader)")?"INDIVIDUAL":"ENTERPRISE") ;
}else{
newSubMerchantIdApply.setMerchant_type("INDIVIDUAL") ;
newSubMerchantIdApply.setMerchant_type(clientJson.getString("business_structure").equals("Registered body(Sole Trader)") ? "INDIVIDUAL" : "ENTERPRISE");
} else {
newSubMerchantIdApply.setMerchant_type("INDIVIDUAL");
}
newSubMerchantIdApply.setCompany_register_no(cutLength(TextUtils.isEmpty(clientJson.getString("acn"))?clientJson.getString("abn"):clientJson.getString("acn"),50));
newSubMerchantIdApply.setCompany_register_no(cutLength(TextUtils.isEmpty(clientJson.getString("acn")) ? clientJson.getString("abn") : clientJson.getString("acn"), 50));
if (!TextUtils.isEmpty(clientJson.getString("certificat_expire_date"))) {
newSubMerchantIdApply.setCertificat_expire_date(clientJson.getString("certificat_expire_date"));
} else {
@ -638,34 +649,32 @@ public class TestController {
}
if("ENTERPRISE".equalsIgnoreCase(newSubMerchantIdApply.getMerchant_type())&&TextUtils.isEmpty(newSubMerchantIdApply.getCompany_register_no())){
logger.error("=======>公司注册号为空clientid"+clientJson.getInteger("client_id")+":"+clientJson.getString("client_moniker"));
if ("ENTERPRISE".equalsIgnoreCase(newSubMerchantIdApply.getMerchant_type()) && TextUtils.isEmpty(newSubMerchantIdApply.getCompany_register_no())) {
logger.error("=======>公司注册号为空clientid" + clientJson.getInteger("client_id") + ":" + clientJson.getString("client_moniker"));
return;
}
if("BOTH".equalsIgnoreCase(newSubMerchantIdApply.getBusiness_type())&&(TextUtils.isEmpty(newSubMerchantIdApply.getAddress())||
TextUtils.isEmpty(newSubMerchantIdApply.getWebsite()))){
logger.error("=======>公司类型为BOTH网址或地址为空clientid:"+clientJson.getInteger("client_id")+":"+clientJson.getString("client_moniker"));
if ("BOTH".equalsIgnoreCase(newSubMerchantIdApply.getBusiness_type()) && (TextUtils.isEmpty(newSubMerchantIdApply.getAddress()) ||
TextUtils.isEmpty(newSubMerchantIdApply.getWebsite()))) {
logger.error("=======>公司类型为BOTH网址或地址为空clientid:" + clientJson.getInteger("client_id") + ":" + clientJson.getString("client_moniker"));
return;
}
else if("OFFLINE".equalsIgnoreCase(newSubMerchantIdApply.getBusiness_type())&&(TextUtils.isEmpty(newSubMerchantIdApply.getAddress()))){
logger.error("=======>公司类型为OFFLINE地址为空clientid:"+clientJson.getInteger("client_id")+":"+clientJson.getString("client_moniker"));
} else if ("OFFLINE".equalsIgnoreCase(newSubMerchantIdApply.getBusiness_type()) && (TextUtils.isEmpty(newSubMerchantIdApply.getAddress()))) {
logger.error("=======>公司类型为OFFLINE地址为空clientid:" + clientJson.getInteger("client_id") + ":" + clientJson.getString("client_moniker"));
return;
}
else if("ONLINE".equalsIgnoreCase(newSubMerchantIdApply.getBusiness_type())&&
TextUtils.isEmpty(newSubMerchantIdApply.getWebsite())){
logger.error("=======>公司类型为ONLINE网址为空clientid:"+clientJson.getInteger("client_id")+":"+clientJson.getString("client_moniker"));
} else if ("ONLINE".equalsIgnoreCase(newSubMerchantIdApply.getBusiness_type()) &&
TextUtils.isEmpty(newSubMerchantIdApply.getWebsite())) {
logger.error("=======>公司类型为ONLINE网址为空clientid:" + clientJson.getInteger("client_id") + ":" + clientJson.getString("client_moniker"));
return;
}
JSONObject params = newSubMerchantIdApply.insertObject(clientJson);
params.put("merchant_app_id", jsonObject.getString("merchant_app_id"));
SubMerchantInfoInheritance subMerchantInfo = JSON.toJavaObject(params, SubMerchantInfoInheritance.class);
params.put("operator","System");
params.put("operator", "System");
WxPayMerchantRegister register = Optional.ofNullable(merchantChannelApplicationManager.getRegister(WxPayMerchantRegister.class))
.orElseThrow(() -> new ServerErrorException("No Register found for wechat"));
JSONObject manager=new JSONObject();
manager.put("display_name","System");
JSONObject manager = new JSONObject();
manager.put("display_name", "System");
register.modifyForBatch(jsonObject.getString("merchant_app_id"), clientJson, subMerchantInfo, manager);
try {
Thread.sleep(500);
@ -677,6 +686,7 @@ public class TestController {
}
/**
*
*/
@ -784,11 +794,11 @@ public class TestController {
//
//
// }
public String cutLength(String str,int maxlen){
if(TextUtils.isEmpty(str))return "";
if(str.length()>maxlen){
return str.substring(0,maxlen);
}else{
public String cutLength(String str, int maxlen) {
if (TextUtils.isEmpty(str)) return "";
if (str.length() > maxlen) {
return str.substring(0, maxlen);
} else {
return str;
}

Loading…
Cancel
Save