|
|
|
@ -67,9 +67,11 @@ import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.event.WechatExceptionEvent;
|
|
|
|
|
import au.com.royalpay.payment.tools.inspiry.core.InspiryPOSFinder;
|
|
|
|
|
import au.com.royalpay.payment.tools.locale.LocaleSupport;
|
|
|
|
|
import au.com.royalpay.payment.tools.lock.Locker;
|
|
|
|
|
import au.com.royalpay.payment.tools.mail.SendMail;
|
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
|
import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
|
|
|
|
|
import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
|
|
|
|
|
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
|
|
@ -101,6 +103,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
import org.apache.el.parser.AstNot;
|
|
|
|
|
import org.apache.http.client.utils.URLEncodedUtils;
|
|
|
|
|
import org.dom4j.Element;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@ -122,17 +125,16 @@ import org.thymeleaf.spring4.SpringTemplateEngine;
|
|
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.security.InvalidKeyException;
|
|
|
|
|
import java.security.InvalidParameterException;
|
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
|
import java.security.SecureRandom;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
@ -144,12 +146,17 @@ import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.crypto.*;
|
|
|
|
|
import javax.crypto.spec.DESKeySpec;
|
|
|
|
|
import javax.crypto.spec.IvParameterSpec;
|
|
|
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import cn.yixblog.platform.http.HttpRequestGenerator;
|
|
|
|
|
import cn.yixblog.platform.http.HttpRequestResult;
|
|
|
|
|
import sun.misc.BASE64Encoder;
|
|
|
|
|
|
|
|
|
|
import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission;
|
|
|
|
|
|
|
|
|
@ -4699,15 +4706,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
|
|
|
|
|
throw new BadRequestException("邮件发送失败", e);
|
|
|
|
|
}
|
|
|
|
|
}).start();
|
|
|
|
|
StringBuffer accountsStr = new StringBuffer("?");
|
|
|
|
|
accounts.forEach(account -> {
|
|
|
|
|
accountsStr.append("accounts=").append(account.getString("username")).append(",").append(account.getString("password")).append(",").append(account.getIntValue("role")).append(",").append(account.getString("client_moniker")).append("&");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
List<String> needNotifyUsers = royalPayUsers.stream().filter(user -> StringUtils.isNotEmpty(user.getString("wx_openid"))).map(user -> user.getString("wx_openid")).collect(Collectors.toList());
|
|
|
|
|
needNotifyUsers.forEach(userOpenId -> {
|
|
|
|
|
try {
|
|
|
|
|
String signStr = "?sign=" + AESencrypt(accounts.toString(),userOpenId);
|
|
|
|
|
MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi();
|
|
|
|
|
TemplateMessage msg = initSendTestPasswordTemplate(userOpenId, paymentApi.getTemplateId("test-merchant-password"), StringUtils.substring(accountsStr.toString(), 0, accountsStr.length() - 1));
|
|
|
|
|
TemplateMessage msg = initSendTestPasswordTemplate(userOpenId, paymentApi.getTemplateId("test-merchant-password"), signStr.replace("+", "%2B"));
|
|
|
|
|
paymentApi.sendTemplateMessage(msg);
|
|
|
|
|
} catch (WechatException e) {
|
|
|
|
|
logger.error("给{}发送微信消息失败,原因:{}", userOpenId, e.getMessage());
|
|
|
|
@ -4732,4 +4737,36 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
|
|
|
|
|
MpWechatApi api = mpWechatApiProvider.getNewPaymentApi();
|
|
|
|
|
return api.registerShortUrl(longUrl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String AESencrypt(String content, String password) {
|
|
|
|
|
try {
|
|
|
|
|
KeyGenerator kgen = KeyGenerator.getInstance("AES");
|
|
|
|
|
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
|
|
|
|
random.setSeed(password.getBytes());
|
|
|
|
|
kgen.init(128, random);
|
|
|
|
|
SecretKey secretKey = kgen.generateKey();
|
|
|
|
|
byte[] enCodeFormat = secretKey.getEncoded();
|
|
|
|
|
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");
|
|
|
|
|
Cipher cipher = Cipher.getInstance("AES");
|
|
|
|
|
byte[] byteContent = content.getBytes("utf-8");
|
|
|
|
|
cipher.init(Cipher.ENCRYPT_MODE, key);
|
|
|
|
|
byte[] result = cipher.doFinal(byteContent);
|
|
|
|
|
return Base64.encodeBase64String(result);
|
|
|
|
|
} catch (NoSuchPaddingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (NoSuchAlgorithmException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (InvalidKeyException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (IllegalBlockSizeException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (BadPaddingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|