[Y] 新增禁止查询level3商户开关

master
taylor.dang 5 years ago
parent d19bc70a16
commit 0582321556

@ -5,11 +5,11 @@
<parent>
<groupId>au.com.royalpay.payment</groupId>
<artifactId>payment-parent</artifactId>
<version>1.1.7</version>
<version>1.1.12</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>1.3.22</version>
<version>1.3.23</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.4.0</jib-maven-plugin.version>

@ -24,12 +24,12 @@ import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.locale.LocaleSupport;
import au.com.royalpay.payment.tools.utils.PasswordUtils;
import au.com.royalpay.payment.tools.utils.PdfUtils;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.RandomStringUtils;
@ -45,10 +45,14 @@ import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring5.SpringTemplateEngine;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import java.awt.image.BufferedImage;
import java.io.*;
import java.math.BigDecimal;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.util.*;
@ -57,15 +61,6 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import org.thymeleaf.spring5.SpringTemplateEngine;
@Service
public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
@ -828,7 +823,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
throw new NotFoundException("BSB Number Not Found");
}
}
} catch (URISyntaxException | IOException e) {
} catch (IOException e) {
throw new ServerErrorException();
}
return banInfo;

@ -3,10 +3,8 @@ package au.com.royalpay.payment.manage.apps.events.listeners;
import au.com.royalpay.payment.core.events.AfterPaymentFinishEvent;
import au.com.royalpay.payment.manage.customers.core.CustomerPaymentInfoService;
import au.com.royalpay.payment.manage.mappers.system.SysCustomerPaymentInfoMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;

@ -4,17 +4,14 @@ import au.com.royalpay.payment.manage.analysis.core.PartnersAnalysisService;
import au.com.royalpay.payment.manage.datav.core.DatavService;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientAndCustomerLocation;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.annotation.Resource;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -104,7 +101,7 @@ public class DatavServiceImpl implements DatavService {
obj.put("moniker_longitude", customer.getString("longitude"));
obj.put("moniker_latitude", customer.getString("latitude"));
}
} catch (IOException | URISyntaxException e) {
} catch (IOException e) {
e.printStackTrace();
}
}

@ -3,11 +3,9 @@ package au.com.royalpay.payment.manage.logview.core.impl;
import au.com.royalpay.payment.manage.logview.core.OperationLogService;
import au.com.royalpay.payment.manage.merchants.beans.mongo.ClientConfigLog;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.Paginator;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
@ -16,9 +14,8 @@ import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.List;
import javax.annotation.Resource;
import java.util.List;
/**
* @author kira
@ -35,16 +32,16 @@ public class OperationLogServiceImpl implements OperationLogService {
public JSONObject query(JSONObject params, PageBounds pageBounds) {
if (StringUtils.isNotEmpty(params.getString("client_moniker"))) {
JSONObject client = clientManager.getClientInfoByMoniker(params.getString("client_moniker"));
if(client!=null) {
if (client != null) {
params.put("client_id", client.getIntValue("client_id"));
}
}
Query query = new Query();
query.with(new Sort(new Sort.Order(Sort.Direction.DESC,"createTime")));
query.with(Sort.by(Sort.Direction.DESC, "createTime"));
if (params.getIntValue("client_id") != 0) {
query.addCriteria(Criteria.where("clientId").is(params.getIntValue("client_id")));
}
query.with(new PageRequest(pageBounds.getPage()-1, pageBounds.getLimit()));
query.with(PageRequest.of(pageBounds.getPage() - 1, pageBounds.getLimit()));
query.addCriteria(Criteria.where("createTime").gt((params.getDate("begin"))).lt(params.getDate("end")));
List<ClientConfigLog> clientConfigLogList = mongoTemplate.find(query, ClientConfigLog.class);
return buildPageListResult(clientConfigLogList,

@ -78,6 +78,10 @@ public interface ClientMapper {
@AdvanceSelect(addonWhereClause = "is_valid=1")
List<JSONObject> listChildClients(@Param("parent_client_id") int parentClientId);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1")
List<JSONObject> listChildClients(@Param("parent_client_id") int parentClientId, PageBounds pagination);
@AutoSql(type = SqlType.UPDATE)
void updateCleanDays(@Param("client_id") int clientId, @Param("clean_days") int cleanDays);

@ -25,13 +25,14 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.annotation.Resource;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -166,11 +167,7 @@ public class MerchantIdManageServiceImpl implements MerchantIdManageService {
param.put("sub_merchant_id",sub_merchant_id);
String createUrl= PlatformEnvironment.getEnv().concatUrl("api/v1.0/gateway/partners/" + partner_code + "/orders/" + orderId +"/manager/test"+"?" + queryParams(partner_code));
HttpRequestResult result = null;
try {
result = new HttpRequestGenerator(createUrl, RequestMethod.PUT).setJSONEntity(param).execute();
} catch (URISyntaxException e) {
e.printStackTrace();
}
if (result.isSuccess()) {
try {
return result.getResponseContentJSONObj();

@ -126,7 +126,6 @@ import java.awt.image.BufferedImage;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.security.InvalidParameterException;
@ -830,7 +829,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Transactional
public void updateClientRegisterInfo(JSONObject manager, String clientMoniker, ClientRegisterInfo info) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
Assert.notNull(client);
checkOrgPermission(manager, client);
JSONObject updateInfo = info.updateObject();
@ -892,7 +890,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Transactional
public void updateClientRegisterInfoV2(JSONObject manager, String clientMoniker, JSONObject info) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
Assert.notNull(client);
checkOrgPermission(manager, client);
int clientId = client.getIntValue("client_id");
@ -1656,7 +1653,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private JSONObject checkAndFindAccount(JSONObject manager, String clientMoniker, String accountId) {
JSONObject account = clientAccountMapper.findById(accountId);
Assert.notNull(account);
if (clientMoniker != null) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
Assert.notNull(client);
@ -2072,8 +2068,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException();
}
checkOrgPermission(manager, client);
JSONObject listSubClients = new JSONObject();
List<JSONObject> listChildClients = clientMapper.listChildClients(client.getIntValue("client_id"));
JSONObject mchConfig = merchantInfoProvider.getMchExtParams(client.getIntValue("client_id"));
if (!mchConfig.getBooleanValue("disable_level3_mch")) {
for (JSONObject partner : listChildClients) {
List<JSONObject> clients = clientMapper.listChildClients(partner.getIntValue("client_id"));
if (clients.size() > 0) {
@ -2083,6 +2080,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
});
}
}
}
return listChildClients;
}
@ -2546,7 +2544,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
ous.flush();
IOUtils.closeQuietly(ous);
}
} catch (URISyntaxException | IOException e) {
} catch (IOException e) {
throw new ServerErrorException("Error", e);
}
}
@ -2565,7 +2563,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
ous.flush();
IOUtils.closeQuietly(ous);
}
} catch (URISyntaxException | IOException e) {
} catch (IOException e) {
throw new ServerErrorException("Error", e);
}
}
@ -2602,7 +2600,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
ImageUtils.drawImage(g, logoImg, 588, 1916, 2363, 960);
}
} catch (URISyntaxException | IOException ignored) {
} catch (IOException ignored) {
}
}
}
@ -2795,7 +2793,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (result.isSuccess()) {
res = result.getResponseContentJSONObj();
}
} catch (URISyntaxException | IOException e) {
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return res;
@ -3400,14 +3398,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public void disableClient(String clientMoniker, JSONObject manager) {
JSONObject client = clientDetail(manager, clientMoniker);
Assert.notEmpty(client);
clientModifySupport.processClientModify(new DisableModify(manager, clientMoniker, false));
}
@Override
public void revertClient(String clientMoniker, JSONObject manager) {
JSONObject client = clientDetail(manager, clientMoniker);
Assert.notEmpty(client);
clientModifySupport.processClientModify(new DisableModify(manager, clientMoniker, true));
}
@ -4716,7 +4712,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public void updateAppClient(JSONObject account, int client_id, AppClientBean appClientBean) {
JSONObject client = getClientInfo(client_id);
Assert.notNull(client);
JSONObject updateObj = appClientBean.updateObject();
if (updateObj.size() > 0) {
updateObj.put("client_id", client_id);
@ -5838,7 +5833,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public void sendVerifyEmail(JSONObject client, String accountId) {
JSONObject clientAccount = clientAccountMapper.findById(accountId);
Assert.notNull(clientAccount);
simpleClientApplyService.sendVerifyEmail(client.getString("contact_email"), client.getIntValue("client_id"), clientAccount.getString("username"));
}

@ -11,13 +11,13 @@ import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import au.com.royalpay.payment.tools.utils.id.IdUtil;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.annotation.Resource;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
@ -40,11 +41,6 @@ import java.security.Key;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
/**
* Created by yishuqian on 18/01/2017.
*/
@ -183,7 +179,6 @@ public class MailServiceImp implements MailService {
noticeBean.setPassword(mailPwd);
String postUrl = mailHost + "/mail/single?" + generateMailSignParam();
HttpRequestResult result = null;
try {
logger.info("===sendEmail===noticeBean:" + JSON.toJSON(noticeBean));
result = new HttpRequestGenerator(postUrl, RequestMethod.POST).setJSONEntity(noticeBean).setTimeout(60_000).execute();
if (result.isSuccess()) {
@ -193,9 +188,6 @@ public class MailServiceImp implements MailService {
} else {
throw new ServerErrorException("Error Connection");
}
} catch (URISyntaxException e) {
throw new ServerErrorException("Error Connection");
}
}
@Override
@ -219,7 +211,6 @@ public class MailServiceImp implements MailService {
noticeBean.setPassword(mailPwd);
String postUrl = mailHost + "/mail/single?" + generateMailSignParam();
HttpRequestResult result = null;
try {
logger.info("===sendEmail===noticeBean:" + JSON.toJSON(noticeBean));
result = new HttpRequestGenerator(postUrl, RequestMethod.POST).setJSONEntity(noticeBean).setTimeout(60_000).execute();
if (result.isSuccess()) {
@ -229,9 +220,6 @@ public class MailServiceImp implements MailService {
} else {
throw new ServerErrorException("Error Connection");
}
} catch (URISyntaxException e) {
throw new ServerErrorException("Error Connection");
}
}
@Override
@ -249,7 +237,7 @@ public class MailServiceImp implements MailService {
} else {
throw new ServerErrorException("Mail Service failed; status code=" + result.getStatusCode());
}
} catch (URISyntaxException | IOException e) {
} catch (IOException e) {
throw new ServerErrorException("Mail Service failed", e);
}
@ -305,7 +293,6 @@ public class MailServiceImp implements MailService {
noticeBean.setAttachFiles(attachFiles);
String postUrl = mailHost + "/mail/single?" + generateMailSignParam();
HttpRequestResult result = null;
try {
logger.info("===sendEmail===noticeBean:" + JSON.toJSON(noticeBean));
result = new HttpRequestGenerator(postUrl, RequestMethod.POST).setJSONEntity(noticeBean).setTimeout(60_000).execute();
if (result.isSuccess()) {
@ -315,9 +302,6 @@ public class MailServiceImp implements MailService {
} else {
throw new ServerErrorException("Error Connection");
}
} catch (URISyntaxException e) {
throw new ServerErrorException("Error Connection");
}
}
@Override
@ -350,7 +334,6 @@ public class MailServiceImp implements MailService {
}
String postUrl = mailHost + "/mail/single?" + generateMailSignParam();
HttpRequestResult result = null;
try {
logger.info("===sendEmail===noticeBean:" + JSON.toJSON(noticeBean));
result = new HttpRequestGenerator(postUrl, RequestMethod.POST).setJSONEntity(noticeBean).setTimeout(60_000).execute();
if (result.isSuccess()) {
@ -360,9 +343,6 @@ public class MailServiceImp implements MailService {
} else {
throw new ServerErrorException("Error Connection");
}
} catch (URISyntaxException e) {
throw new ServerErrorException("Error Connection");
}
}
}

@ -9,9 +9,9 @@ import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.fixing.FixedDocumentHelper;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.http.NameValuePair;
@ -25,18 +25,9 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMethod;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import java.io.IOException;
import java.util.*;
/**
* Created by wangning on 2017/12/7.
@ -266,7 +257,7 @@ public class OfeiClientImpl implements OfeiClient {
} else {
throw new ChannelNetworkException(errMsg + "-->Network Error:" + res.getStatusCode());
}
} catch (URISyntaxException | DocumentException | IOException e) {
} catch (DocumentException | IOException e) {
throw new ChannelNetworkException(errMsg + "-->Network Error", e);
}
}
@ -282,7 +273,7 @@ public class OfeiClientImpl implements OfeiClient {
} else {
throw new ChannelNetworkException(errMsg + "-->Network Error:" + res.getStatusCode());
}
} catch (URISyntaxException | IOException e) {
} catch (IOException e) {
throw new ChannelNetworkException(errMsg + "-->Network Error", e);
}

@ -12,9 +12,7 @@ public class ReadWriteSplitRoutingDataSource extends AbstractRoutingDataSource {
@Override
public Object determineCurrentLookupKey() {
DbContextHolder.DbType dataSource = DbContextHolder.getDbType();
logger.info("------------------当前数据源:{}---------------------",dataSource);
return dataSource;
return DbContextHolder.getDbType();
}
}

@ -11,7 +11,6 @@ import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMethod;
import java.io.IOException;
import java.net.URISyntaxException;
/**
@ -29,7 +28,6 @@ public class PosterServiceImpl implements PosterService {
public void updatePoster(String imgUrl) {
String url = cmsHost + "/api/statistics/count";
HttpRequestGenerator htg = new HttpRequestGenerator(url, RequestMethod.PUT);
try {
HttpRequestResult result = htg.addQueryString("imgUrl", imgUrl).execute();
if (result.isSuccess()) {
int statusCode = result.getStatusCode();
@ -37,9 +35,6 @@ public class PosterServiceImpl implements PosterService {
logger.info("CMS request succeeded");
}
}
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
@Override
@ -57,8 +52,6 @@ public class PosterServiceImpl implements PosterService {
// final String s = result.getResponseContentString();
return obj;
}
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

@ -23,11 +23,9 @@ import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
@ -35,12 +33,11 @@ import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
/**
* Created by yixian on 2016-07-04.
*/
@ -222,7 +219,7 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish
int accountClientId = partnerAccount.getIntValue("client_id");
Assert.isTrue(accountClientId == client.getIntValue("client_id") || accountClientId == client.getIntValue("parent_client_id")
||clientManager.listLevel3Client(accountClientId).contains(client.getIntValue("parent_client_id")),
|| clientManager.listLevel3Client(accountClientId).contains(client.getIntValue("parent_client_id")),
"This order is not belong to current merchant");
operator.put("operator_id", partnerAccount.getString("account_id"));
operator.put("operator", partnerAccount.getString("display_name"));
@ -233,7 +230,7 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish
boolean requireAudit = type == OperatorType.PARTNER && PartnerRole.getRole(partnerAccount.getIntValue("role")) == PartnerRole.CASHIER
&& clientConfig.getBooleanValue("enable_refund_auth");
logger.debug("applyer type=" + type + "; require audit=" + requireAudit);
return paymentApi.refundOrder(orderId, null, amount, remark, operator, type, requireAudit);
return paymentApi.refundOrder(null, orderId, null, amount, remark, operator, type, requireAudit);
}
// 订单使用积分商城优惠券,仅支持全额退款

@ -1,628 +0,0 @@
package au.com.royalpay.payment.manage.apps.core.impls;
import au.com.royalpay.payment.manage.analysis.core.WeekReporter;
import au.com.royalpay.payment.manage.citypartner.core.CityPartnerPrizeService;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.tools.mail.MailGunClient;
import au.com.royalpay.payment.tools.mail.SendMail;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.BoundListOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.RequestMethod;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
/**
* Created by wangning on 05/01/2018.
*/
// @SpringBootTest
// @ActiveProfiles({ "local", "alipay", "wechat", "jd", "bestpay" })
// @RunWith(SpringRunner.class)
public class CustomerImpressionImplTest {
@Resource
private OrderMapper orderMapper;
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private ClientMapper clientMapper;
@Resource
private OrgMapper orgMapper;
@Resource
private MailGunClient mailGunClient;
@Resource
private ClientConfigMapper clientConfigMapper;
@Resource
private ClientManager clientManager;
@Resource
private MailService mailService;
@Resource
private WeekReporter weekReporter;
@Resource
private CityPartnerPrizeService cityPartnerPrizeService;
@Test
public void redisQueue() {
BoundListOperations<String, String> ops = stringRedisTemplate.boundListOps("customer_impression");
JSONObject order = orderMapper.find("00009201711300930013961422");
for (int i = 0; i < 10000; i++) {
ops.rightPush(order.toJSONString());
}
}
@Test
public void excel1() {
try {
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/asd.xlsx")));
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();
Row row = null;
Cell cell = null;
Map<String, Map<String, String>> result = new HashMap<>();
while (rowIterator.hasNext()) {
row = rowIterator.next();
cell = row.getCell(0);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String amount = cell.getStringCellValue().trim();
cell = row.getCell(1);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String dateStr = cell.getStringCellValue();
cell = row.getCell(2);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String clientId = cell.getStringCellValue();
if (result.containsKey(clientId)) {
result.get(clientId).put(dateStr, amount);
} else {
Map<String, String> ele = new HashMap<>();
ele.put(dateStr, amount);
result.put(clientId, ele);
}
}
Set<String> clients = new HashSet<>();
result.entrySet().parallelStream().forEach(p -> {
p.getValue().entrySet().parallelStream().forEach(o -> {
BigDecimal insAvg = BigDecimal.valueOf(Double.valueOf(o.getValue()));
BigDecimal pastTotal = BigDecimal.ZERO;
for (int i = 1; i < 4; i++) {
if (i == 1) {
pastTotal = BigDecimal.ZERO;
}
try {
Date tmp = DateUtils.addMonths(DateUtils.parseDate(o.getKey(), "YYYYMM"), (-i + 1));
String pastKey = String.valueOf(tmp.getYear() + 1900) + String.valueOf(tmp.getMonth());
if (p.getValue().containsKey(String.valueOf(pastKey))) {
BigDecimal pastAvgtmp = BigDecimal.valueOf(Double.parseDouble(p.getValue().get(String.valueOf(pastKey))));
pastTotal = pastTotal.add(pastAvgtmp);
} else {
i = 10;
}
if (i == 3) {
try {
BigDecimal pastAvg = pastTotal.divide(BigDecimal.valueOf(3L), 5, BigDecimal.ROUND_HALF_DOWN);
if (pastAvg.compareTo(BigDecimal.ZERO) > 0) {
if (insAvg.divide(pastAvg, 5, BigDecimal.ROUND_HALF_DOWN).intValue() > 3) {
clients.add(p.getKey());
}
}
} catch (Exception ignore) {
}
}
} catch (ParseException e) {
}
}
});
});
clients.forEach(p -> {
System.out.println(p);
});
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
OutputStream out = new FileOutputStream("/Users/wangning/Desktop/春节活动报名结果通知(包含BD名称).xlsx");
workbook.write(out);
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void excel2() {
try {
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/qwe.xlsx")));
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();
Row row = null;
Cell cell = null;
Map<String, LinkedHashMap<String, String>> result = new HashMap<>();
while (rowIterator.hasNext()) {
row = rowIterator.next();
cell = row.getCell(3);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String orders = cell.getStringCellValue().trim();
cell = row.getCell(1);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String dateStr = cell.getStringCellValue();
cell = row.getCell(2);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String clientId = cell.getStringCellValue();
if (result.containsKey(clientId)) {
result.get(clientId).put(dateStr, orders);
} else {
LinkedHashMap<String, String> ele = new LinkedHashMap<>();
ele.put(dateStr, orders);
result.put(clientId, ele);
}
}
Set<String> clients = new HashSet<>();
for (Map.Entry<String, LinkedHashMap<String, String>> p : result.entrySet()) {
int count = 1;
for (Map.Entry<String, String> o : p.getValue().entrySet()) {
count += 1;
for (int i = 1; i < 4; i++) {
if (p.getValue().size() < 4 && count == p.getValue().size()) {
try {
if (DateUtils.addMonths(DateUtils.parseDate(o.getKey(), "YYYYMM"), 3).compareTo(new Date()) < 0) {
clients.add(p.getKey());
}
} catch (ParseException e) {
}
}
Date tmp = null;
try {
tmp = DateUtils.addMonths(DateUtils.parseDate(o.getKey(), "YYYYMM"), i);
String pastKey = String.valueOf(tmp.getYear() + 1900) + String.valueOf(tmp.getMonth());
if (p.getValue().containsKey(String.valueOf(pastKey))) {
i = 10;
} else {
if (i == 3 && (Integer.valueOf(o.getValue()) > 99)) {
clients.add(p.getKey());
}
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}
}
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
System.out.println(clients.size());
// OutputStream out = new FileOutputStream("/Users/wangning/Desktop/春节活动报名结果通知(包含BD名称).xlsx");
// workbook.write(out);
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void excel3() {
List<JSONObject> clients = clientMapper.listValidClient();
Map<String,JSONObject> clientMap = new HashMap<>();
clients.parallelStream().forEach(p->{
clientMap.put(p.getString("client_id"),p);
});
try {
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/e4.xlsx")));
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();
Row row = null;
Cell cell = null;
Map<String, LinkedHashMap<String, String>> result = new HashMap<>();
while (rowIterator.hasNext()) {
row = rowIterator.next();
cell = row.getCell(0);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String orderCounts = cell.getStringCellValue().trim();
cell = row.getCell(1);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String clientId = cell.getStringCellValue().trim();
cell = row.getCell(2);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String dateStr = cell.getStringCellValue().trim();
if (result.containsKey(clientId)) {
result.get(clientId).put(dateStr, orderCounts);
} else {
LinkedHashMap<String, String> ele = new LinkedHashMap<>();
ele.put(dateStr, orderCounts);
result.put(clientId, ele);
}
}
Set<String> resultClients = new HashSet<>();
Date now = new Date();
for (Map.Entry<String, LinkedHashMap<String, String>> p : result.entrySet()) {
JSONObject tmpClient = clientMap.get(p.getKey());
if(tmpClient==null){
continue;
}
if(DateUtils.addMonths(tmpClient.getDate("create_time"), 7).compareTo(now)>-1){
continue;
}
for (Map.Entry<String, String> o : p.getValue().entrySet()) {
LinkedHashMap<String,String> resultEle = p.getValue();
int compareCount = 0;
for (int i = 1; i < 7; i++) {
compareCount+=1;
if(DateUtils.addMonths(DateUtils.parseDate(o.getKey(), "YYYY-MM"), 7).compareTo(now)>-1){
i=10;
continue;
}
Date compareDate = DateUtils.addMonths(DateUtils.parseDate(o.getKey(), "YYYY-MM"), i);
String compareKey = DateFormatUtils.format(compareDate,"YYYY-MM");
if(resultEle.containsKey(compareKey)){
i=10;
}
if(compareCount==6){
resultClients.add(p.getKey());
}
}
}
}
System.out.println("0---"+resultClients.size());
resultClients.forEach(p->{
System.out.println(p);
});
// OutputStream out = new FileOutputStream("/Users/wangning/Desktop/春节活动报名结果通知(包含BD名称).xlsx");
// workbook.write(out);
workbook.close();
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void sendSimpleMessage() throws Exception {
String url = "https://api.mailgun.net/v3/dev.showcodes.com/messages?from=postmaster@mail.royalpay.com.au&to=164851225@qq.com,1029811920@qq.com&subject=啊是记录&text=暗杀苏&v:my-custom-data={\"key\":\"value\"}";
String asd = "王宁测试标题";
HttpRequestGenerator generator = new HttpRequestGenerator(url, RequestMethod.POST).addHeader("Authorization", getHeader());
HttpRequestResult res = null;
try {
res = generator.execute();
} catch (URISyntaxException e) {
e.printStackTrace();
}
System.out.println(res.getException());
System.out.println();
System.out.println();
try {
System.out.println(res.getResponseContentJSONObj().toJSONString());
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void sendSimeMessage() throws Exception {
String url = "https://api.mailgun.net/v3/dev.showcodes.com/events";
HttpRequestGenerator generator = new HttpRequestGenerator(url, RequestMethod.POST).addHeader("Authorization", getHeader());
generator.addQueryString("ascending", "yes");
generator.addQueryString("v:my-custom-data", "123456789");
generator.addQueryString("limit", "12");
System.out.println(String.valueOf(DateUtils.addDays(new Date(), 1)));
HttpRequestResult res = null;
try {
res = generator.execute();
} catch (URISyntaxException e) {
e.printStackTrace();
}
System.out.println(res.getException());
System.out.println();
System.out.println();
try {
System.out.println(res.getResponseContentJSONObj().toJSONString());
} catch (IOException e) {
e.printStackTrace();
}
}
private String getHeader() {
String auth = "api:key-96fa3b5866ace125b8ec5a9d27e19353";
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("UTF-8")));
String authHeader = "Basic " + new String(encodedAuth);
return authHeader;
}
@Test
public void sendSimpleMessages() throws Exception {
SendMail sendMail = new SendMail();
sendMail.setFrom("info@mail.royalpay.com.au");
sendMail.setContent("<html><p>Hi</p ></html>");
List<String> list = new ArrayList<>();
list.add("testTag");
// sendMail.setTags(list);
Set<String> mailCCs = new HashSet<>();
mailCCs.add("asd1159111@163.com");
sendMail.setMailCcs(mailCCs);
Set<String> mailtos = new HashSet<>();
mailtos.add("eason.qian@royalpay.com.au");
sendMail.setMailTos(mailtos);
sendMail.setTitle("Final Test");
JSONObject result = mailGunClient.sendMail(sendMail);
System.out.println(result.toJSONString());
System.out.println(result.toJSONString());
System.out.println(result.toJSONString());
}
@Test
public void asd() {
JSONObject client = clientMapper.findClient(9);
JSONObject var = new JSONObject();
var.put("client_moniker", client.getString("client_moniker"));
var.put("short_name", client.getString("short_name"));
JSONObject result = mailGunClient.addListMember(client.getString("contact_email"), "merchants@mail.royalpay.com.au", client.getString("contact_person"),
"", var);
}
@Test
public void fd() {
List<String> asd12eq = new ArrayList<>();
asd12eq.add("9");
JSONObject asd = clientManager.getByEmail("164851225@qq.com", 1, 1, asd12eq);
JSONArray qwe = asd.getJSONArray("data");
System.out.println(asd.getJSONArray("data"));
System.out.println(qwe);
System.out.println(asd);
System.out.println(asd);
System.out.println(asd);
}
@Test
public void addMailUnsub() {
try {
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/asd.xlsx")));
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();
Row row = null;
Cell cell = null;
while (rowIterator.hasNext()) {
row = rowIterator.next();
cell = row.getCell(1);
if (cell == null) {
continue;
}
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
CellStyle cellStyle = cell.getCellStyle();
if (cellStyle.getFillForegroundColor() == 0) {
continue;
}
String clientMonikers = cell.getStringCellValue().trim();
if (clientMonikers.contains("/")) {
String[] clientMonikerArr = clientMonikers.split("/");
for (String s : clientMonikerArr) {
String tmp = s.trim().toUpperCase();
if (tmp.length() > 4 || tmp.length() == 0) {
continue;
}
mailService.addUnsub(s.trim().toUpperCase());
}
} else {
String tmp = clientMonikers.trim().toUpperCase();
if (tmp.length() > 4 || tmp.length() == 0) {
continue;
}
mailService.addUnsub(clientMonikers.trim().toUpperCase());
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void zxc() {
weekReporter.generateReport("2018-06-04", false);
}
@Test
public void royalpayIndustryTransform() {
String json = "[\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"机票\",\n"
+ " \"mccCode\": \"10001\"\n" + " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"旅游行业\",\n"
+ " \"mccCode\": \"10002\"\n" + " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"私人定制旅游\",\n"
+ " \"mccCode\": \"10003\"\n" + " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"租车\",\n"
+ " \"mccCode\": \"10004\"\n" + " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"巴士\",\n"
+ " \"mccCode\": \"10005\"\n" + " }\n" + " ],\n" + " \"label\": \"旅游出行\",\n" + " \"mccCode\": \"1\"\n" + " },\n" + " {\n"
+ " \"children\": [\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"饭店\",\n" + " \"mccCode\": \"20001\"\n"
+ " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"奶茶店\",\n" + " \"mccCode\": \"20002\"\n"
+ " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"烧烤\",\n" + " \"mccCode\": \"20003\"\n"
+ " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"火锅\",\n" + " \"mccCode\": \"20004\"\n"
+ " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"Coffee\",\n" + " \"mccCode\": \"20005\"\n"
+ " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"酒吧\",\n" + " \"mccCode\": \"20006\"\n" + " }\n"
+ " ],\n" + " \"label\": \"餐饮\",\n" + " \"mccCode\": \"2\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"培训类\",\n" + " \"mccCode\": \"30001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"移民留学\",\n" + " \"mccCode\": \"30002\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"私人幼儿园\",\n" + " \"mccCode\": \"30003\"\n" + " }\n" + " ],\n"
+ " \"label\": \"教育\",\n" + " \"mccCode\": \"3\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"换汇\",\n" + " \"mccCode\": \"40001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"房产\",\n" + " \"mccCode\": \"40002\"\n" + " }\n" + " ],\n"
+ " \"label\": \"商务咨询\",\n" + " \"mccCode\": \"4\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"公众号服务商\",\n" + " \"mccCode\": \"50001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"各种媒体类宣传\",\n" + " \"mccCode\": \"50002\"\n" + " }\n" + " ],\n"
+ " \"label\": \"传媒\",\n" + " \"mccCode\": \"5\",\n"
+ " \"value\": \"{\\\"category\\\":\\\"SERVICE\\\",\\\"code\\\":\\\"7542\\\",\\\"description\\\":\\\"Car Washes\\\",\\\"parentCode\\\":\\\"S10\\\"}\"\n"
+ " },\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"美容院\",\n"
+ " \"mccCode\": \"60001\"\n" + " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"医疗美容\",\n"
+ " \"mccCode\": \"60002\"\n" + " }\n" + " ],\n" + " \"label\": \"医美\",\n" + " \"mccCode\": \"6\"\n" + " },\n" + " {\n"
+ " \"children\": [\n" + " {\n" + " \"label\": \"超市\",\n" + " \"mccCode\": \"70001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"服装店\",\n" + " \"mccCode\": \"70002\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"鞋店\",\n" + " \"mccCode\": \"70003\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"珠宝店\",\n" + " \"mccCode\": \"70004\"\n" + " },{\n"
+ " \"children\": [],\n" + " \"label\": \"箱包\",\n" + " \"mccCode\": \"70005\"\n" + " }\n" + " ],\n"
+ " \"label\": \"零售\",\n" + " \"mccCode\": \"7\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"桌游吧\",\n" + " \"mccCode\": \"80001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"演唱会\",\n" + " \"mccCode\": \"80002\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"马术训练\",\n" + " \"mccCode\": \"80003\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"瑜伽\",\n" + " \"mccCode\": \"80004\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"健身\",\n" + " \"mccCode\": \"80005\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"社团\",\n" + " \"mccCode\": \"80006\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"网吧\",\n" + " \"mccCode\": \"80007\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"KTV\",\n" + " \"mccCode\": \"80008\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"电影\",\n" + " \"mccCode\": \"80009\"\n" + " }\n" + " ],\n"
+ " \"label\": \"休闲娱乐\",\n" + " \"mccCode\": \"8\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"摄影\",\n" + " \"mccCode\": \"90001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"massage\",\n" + " \"mccCode\": \"90002\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"通讯运营商\",\n" + " \"mccCode\": \"90003\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"车行\",\n" + " \"mccCode\": \"90004\"\n" + " },\n" + " {\n"
+ " \"children:\":[],\n" + " \"label\":\"软件服务\",\n" + " \"mccCode\":\"90005\"\n" + " }\n" + " ],\n"
+ " \"label\": \"其他服务类\",\n" + " \"mccCode\": \"9\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"Hotel\",\n" + " \"mccCode\": \"100001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"Motel\",\n" + " \"mccCode\": \"100002\"\n" + " }\n" + " ],\n"
+ " \"label\": \"酒店\",\n" + " \"mccCode\": \"10\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"代购\",\n" + " \"mccCode\": \"110001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"物流(大宗出口贸易)\",\n" + " \"mccCode\": \"110002\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"红酒出口\",\n" + " \"mccCode\": \"110003\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"综合电商\",\n" + " \"mccCode\": \"110004\"\n" + " }\n" + " ],\n"
+ " \"label\": \"出口贸易\",\n" + " \"mccCode\": \"11\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"建材\",\n" + " \"mccCode\": \"120001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"家居\",\n" + " \"mccCode\": \"120002\"\n" + " }\n" + " ],\n"
+ " \"label\": \"家居建材\",\n" + " \"mccCode\": \"12\"\n" + " }\n" + "]";
JSONArray jsonArray = JSONObject.parseArray(json);
try {
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/asd.xlsx")));
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();
Row row = null;
Cell cell = null;
while (rowIterator.hasNext()) {
row = rowIterator.next();
cell = row.getCell(2);
if (cell == null) {
continue;
}
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String industryChinese = recursionIndustry(jsonArray, cell.getStringCellValue());
cell.setCellValue(industryChinese);
}
OutputStream out = new FileOutputStream("/Users/wangning/Desktop/qwe.xlsx");
workbook.write(out);
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public String recursionIndustry(JSONArray jsonArray, String mccCode) {
String result = "";
for (Object o : jsonArray) {
if (StringUtils.isNotEmpty(result)) {
break;
}
JSONObject tmp = (JSONObject) o;
if (tmp.getString("mccCode").equals(mccCode)) {
result = tmp.getString("label");
} else {
if (tmp.getJSONArray("children") != null) {
result = recursionIndustry(tmp.getJSONArray("children"), mccCode);
} else {
result = "";
}
}
}
return result;
}
@Test
public void zxcs(){
cityPartnerPrizeService.generateSenior("2018-02");
}
}

@ -6,6 +6,7 @@ import au.com.royalpay.payment.tools.codec.AESCrypt;
import au.com.royalpay.payment.tools.encryptalgorithm.SignUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.stuxuhai.jpinyin.PinyinException;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.net.util.Base64;
import org.junit.Test;
@ -62,4 +63,14 @@ public class JPinYinTest {
System.err.println(SignUtils.decData(aesData, rsa1_pri));
}
@Test
public void testhash(){
String hash = DigestUtils.sha256Hex("customer&xxnpdBRwd4sIaCCI&1575949279241&/api/sso/manager_sign_in").toLowerCase();
String hash2 = DigestUtils.sha256Hex("customer&xxnpdBRwd4sIaCCI&1575950092568&/api/sso/manager_sign_in&119.28.3.196").toLowerCase();
System.err.println(hash);
System.err.println(hash2);
}
}

Loading…
Cancel
Save