Merge branch 'mailGunTest' into test

# Conflicts:
#	src/main/resources/application-local.properties
#	src/main/resources/application.properties
#	src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java
master
wangning 7 years ago
commit 25d54b340b

@ -491,3 +491,15 @@ CREATE TABLE `pmt_directed_bill_code` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
CREATE TABLE `sys_mail_send` (
`id` int(11) NOT NULL,
`mail_address` varchar(100) NOT NULL COMMENT '邮箱地址',
`message_id` varchar(60) NOT NULL COMMENT 'Mailgun Message id',
`status` int(9) NOT NULL DEFAULT 0,
`create_time` datetime not null DEFAULT now(),
`title` varchar(50) NOT NULL comment '邮件标题',
PRIMARY KEY (`id`,`mail_address`),
KEY `mail_address` (`mail_address`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

@ -255,8 +255,8 @@ public class RetailAppServiceImp implements RetailAppService {
JSONObject res = new JSONObject();
res.put("url", url);
res.put("qrcode", QRCodeUtils.qrcodeImageCode(url, 250, false));
// res.put("qrcode_board", merchantInfoProvider.getQrCodeBoard(client, config,clientAccountMapper.findById(device.getString("account_id")),"APP"));
res.put("qrcode_board", merchantInfoProvider.getQrCodeBoard(client, config));
res.put("qrcode_board", merchantInfoProvider.getQrCodeBoard(client, config,clientAccountMapper.findById(device.getString("account_id")),"APP"));
// res.put("qrcode_board", merchantInfoProvider.getQrCodeBoard(client, config));
return res;
}

@ -22,22 +22,31 @@ import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import static au.com.royalpay.payment.tools.CommonConsts.RETAIL_DEVICE;
/**
@ -461,4 +470,16 @@ public class RetailAppController {
public void getInvoiceFile(@ModelAttribute(RETAIL_DEVICE) JSONObject device,AppQueryBean appQueryBean,HttpServletResponse httpResponse) throws Exception {
retailAppService.getInvoiceFile(device,appQueryBean,httpResponse);
}
@RequestMapping(value = "/surcharge", method = RequestMethod.GET)
public JSONObject changeQRCodePaySurCharge(@ModelAttribute(RETAIL_DEVICE) JSONObject device) {
JSONObject client = retailAppService.getClientInfo(device);
JSONObject result = new JSONObject();
result.put("qrcode_surcharge", client.getBooleanValue("qrcode_surcharge"));
result.put("retail_surcharge", client.getBooleanValue("retail_surcharge"));
result.put("api_surcharge", client.getBooleanValue("api_surcharge"));
result.put("require_custinfo", client.getBooleanValue("require_custinfo"));
result.put("require_remark", client.getBooleanValue("require_remark"));
return result;
}
}

@ -11,12 +11,16 @@ public class QueryBillBean {
private int limit = 10;
private int page = 1;
private String status;
private String client_order_id;
public JSONObject toJson(){
JSONObject jason = new JSONObject();
if(StringUtils.isNotEmpty(status)){
jason.put("status",status);
}
if(StringUtils.isNotEmpty(client_order_id)){
jason.put("client_order_id",client_order_id);
}
return jason;
}
@ -43,4 +47,12 @@ public class QueryBillBean {
public void setStatus(String status) {
this.status = status;
}
public String getClient_order_id() {
return client_order_id;
}
public void setClient_order_id(String client_order_id) {
this.client_order_id = client_order_id;
}
}

@ -95,7 +95,7 @@ public class PartnerBillServiceImpl implements PartnerBillService {
JSONObject params = queryBillBean.toJson();
params.put("client_id",client_id);
List<JSONObject> bills = directedBillCodeMapper.findByClientId(params,new PageBounds(queryBillBean.getPage(),queryBillBean.getLimit(), Order.formString("create_time.desc")));
bills.stream().filter(t->t.getString("code_url")!= null).forEach(t->t.put("code_url",QRCodeUtils.qrcodeImageCode(t.getString("code_url"), 250, false)));
bills.stream().filter(t->StringUtils.isNotEmpty(t.getString("code_url"))).forEach(t->t.put("code_url",QRCodeUtils.qrcodeImageCode(t.getString("code_url"), 250, false)));
return bills;
}

@ -27,4 +27,7 @@ public interface ClientConfigMapper {
@AutoSql(type = SqlType.SELECT)
JSONObject find(@Param("client_id") int client_id);
@AutoSql(type = SqlType.SELECT)
List<JSONObject> getAll();
}

@ -74,4 +74,7 @@ public interface ClientMapper {
List<JSONObject> listSubMerchantId();
List<JSONObject> listBySubMerchantId(@Param("sub_merchant_id") String sub_merchant_id);
@AutoSql(type = SqlType.SELECT)
List<JSONObject> AllClients();
}

@ -0,0 +1,24 @@
package au.com.royalpay.payment.manage.mappers.system;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/**
* Create by yixian at 2017-12-13 19:10
*/
@AutoMapper(tablename = "sys_mail_send", pkName = "id")
public interface MailSendMapper {
@AutoSql(type = SqlType.INSERT)
void save(JSONObject record);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject record);
@AutoSql(type = SqlType.SELECT)
JSONObject find(String emailId, String contact_email);
}

@ -71,6 +71,8 @@ public interface ClientManager {
void checkEmailStatus();
void newCheckEmailStatus();
@Transactional
void switchPermission(JSONObject manager, String clientMoniker, String permissionKey, boolean allow);

@ -29,6 +29,7 @@ import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
import au.com.royalpay.payment.manage.mappers.system.CommoditiesMapper;
import au.com.royalpay.payment.manage.mappers.system.MailSendMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper;
@ -69,6 +70,7 @@ import au.com.royalpay.payment.manage.signin.beans.TodoNotice;
import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.system.core.ClientContractService;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
@ -83,6 +85,7 @@ 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.locale.LocaleSupport;
import au.com.royalpay.payment.tools.mail.SendMail;
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;
@ -145,8 +148,10 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
@ -260,6 +265,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private ClientInfoCacheSupport clientInfoCacheSupport;
@Resource
private MongoTemplate mongoTemplate;
@Resource
private MailGunService mailGunService;
@Resource
private MailSendMapper mailSendMapper;
private static final String SOURCE_AGREE_FILE = "source_agree_file";
private static final String CLIENT_BANK_FILE = "client_bank_file";
@ -572,6 +581,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientApplyMapper.updatePartnerApplication(apply);
}
}
try {
mailGunService.addClientToMailList(partner);
}catch (Exception e){
logger.error("邮件列表添加成员失败",e);
}
return partner;
}
@ -607,6 +621,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
clientMapper.update(updateInfo);
if(client.getString("contact_email").equals(updateInfo.getString("contact_email"))){
mailGunService.updateClientOfMailList(updateInfo,client);
}
clientInfoCacheSupport.clearClientCache(clientId);
}
@ -790,7 +807,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (StringUtils.isEmpty(mailTo)) {
throw new EmailException("Client Contact Email is invalid");
}
final List<String> emails = new ArrayList<>();
final Set<String> emails = new HashSet<>();
for (JSONObject bd : bds) {
String email = bd.getString("email");
if (StringUtils.isNotEmpty(email)) {
@ -801,9 +818,16 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public void run() {
try {
String emailId = mailService.sendEmail("Your RoyalPay Cross-border Payment has been set up", mailTo,
emails.isEmpty() ? "" : StringUtils.join(emails, ","), content);
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 3, emailId));
SendMail sendMail = new SendMail();
Set<String> to = new HashSet<>();
to.add(mailTo);
sendMail.setFrom("postmaster@mail.royalpay.com.au");
sendMail.setMailTos(to);
sendMail.setMailCcs(emails);
sendMail.setTitle("Your RoyalPay Cross-border Payment has been set up");
sendMail.setContent(content);
JSONObject mailResult = mailGunService.sendMail(sendMail);
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 3, mailResult.getString("mail_id")));
} catch (Exception e) {
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 0, null));
throw new EmailException("Email Sending Failed", e);
@ -837,7 +861,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
List<JSONObject> bds = clientBDMapper.listClientBDInfoAvailable(client.getIntValue("client_id"), new Date());
final List<String> emails = new ArrayList<>();
final Set<String> emails = new HashSet<>();
for (JSONObject bd : bds) {
String email = bd.getString("email");
if (StringUtils.isNotEmpty(email)) {
@ -848,9 +872,16 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public void run() {
try {
String emailId = mailService.sendEmail("Your Partner Account Has Been Authenticated Successfully", mailTo,
emails.isEmpty() ? "" : StringUtils.join(emails, ","), content);
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 3, emailId));
SendMail sendMail = new SendMail();
Set<String> to = new HashSet<>();
to.add(mailTo);
sendMail.setMailTos(to);
sendMail.setFrom("postmaster@mail.royalpay.com.au");
sendMail.setMailCcs(emails);
sendMail.setTitle("Your Partner Account Has Been Authenticated Successfully");
sendMail.setContent(content);
JSONObject mailResult = mailGunService.sendMail(sendMail);
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 3, mailResult.getString("mail_id")));
} catch (Exception e) {
throw new EmailException("Email Sending Failed", e);
}
@ -907,6 +938,37 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
@Override
public void newCheckEmailStatus() {
List<JSONObject> clients = clientMapper.listClientsWithEmailNotVerify();
for (JSONObject client : clients) {
try {
String emailId = client.getString("approve_email_id");
JSONObject status = mailSendMapper.find(emailId,client.getString("contact_email"));
if (status!=null) {
int statusNo = status.getIntValue("status");
logger.debug("get mail status:" + emailId + "--" + statusNo);
int mailStatus = 3;
switch (statusNo) {
case 1:
mailStatus = 1;
break;
case 2:
mailStatus = 2;
break;
}
updateClientApproveEmailStatus(mailStatus, null, client.getString("client_moniker"));
} else {
logger.debug("get mail status:" + emailId + "-- none");
// updateClientApproveEmailStatus(client.getIntValue("client_id"), 0);
}
} catch (Exception e) {
logger.error("check email status failed", e);
}
}
}
@Override
public void switchPermission(JSONObject manager, String clientMoniker, String permissionKey, boolean allow) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
@ -1559,8 +1621,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public String getQrCodeBoard(JSONObject client, QRCodeConfig config,JSONObject account,String plantform) {
// JSONObject org = orgMapper.findOne(client.getIntValue("org_id"));
return merchantInfoProvider.getQrCodeBoard(client, config);
// return merchantInfoProvider.getQrCodeBoard(client, config,account,plantform);
// return merchantInfoProvider.getQrCodeBoard(client, config);
return merchantInfoProvider.getQrCodeBoard(client, config,account,plantform);
}
@Override
@ -1584,8 +1646,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
qrboardConfig.put("brandw", "600");
qrboardConfig.put("brandh", "200");
String type = qrboardConfig.getString("type");
// QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config,mongoTemplate,manager,plantform);
QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config);
QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config,mongoTemplate,manager,plantform);
// QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config);
board.drawBoardImage(ous);
} catch (Exception e) {
throw new ServerErrorException("QR board config not set for current organize", e);
@ -1605,8 +1667,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
JSONObject qrboardConfig = JSON.parseObject(qrBoardConfigString);
String type = qrboardConfig.getString("type");
// QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config,mongoTemplate,manager,plantform);
QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config);
QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config,mongoTemplate,manager,plantform);
// QRBoard board = QRBoardProvider.getQRBoard(type, qrboardConfig, client, config);
board.drawBoardImage(ous);
} catch (Exception e) {
throw new ServerErrorException("QR board config not set for current organize", e);

@ -3,15 +3,13 @@ package au.com.royalpay.payment.manage.notice.core.impls;
import au.com.royalpay.payment.manage.notice.beans.NoticeBean;
import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
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 org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@ -27,6 +25,9 @@ import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
/**
* Created by yishuqian on 18/01/2017.
*/
@ -97,6 +98,12 @@ public class MailServiceImp implements MailService {
noticeBean.setSenderAddress("info@royalpay.com.au");
noticeBean.setPassword("Vaba6439");
String postUrl = mailHost + "/mail?" + generateMailSignParam();
HttpRequestResult result = new HttpRequestGenerator(postUrl, RequestMethod.POST).setJSONEntity(noticeBean).execute();
if (result.isSuccess()) {
String mail_id = result.getResponseContentJSONObj().getString("mail_id");

@ -10,6 +10,7 @@ import au.com.royalpay.payment.manage.notice.beans.NoticeInfo;
import au.com.royalpay.payment.manage.notice.beans.NoticeQuery;
import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.manage.notice.core.NoticeManage;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.utils.PageListUtils;
@ -29,7 +30,9 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
@ -50,6 +53,8 @@ public class NoticeManageImpl implements NoticeManage {
@Resource
private MailService mailService;
@Resource
private MailGunService mailGunService;
@Resource
private RetailAppService retailAppService;
@Resource
private NotifyErrorLogMapper notifyErrorLogMapper;
@ -156,19 +161,13 @@ public class NoticeManageImpl implements NoticeManage {
if (info.getStatus() != null && info.getSend_clients() != null) {
if (info.getStatus().equals("1") && noticeInfo.getString("status").equals("0") && !info.getSend_clients().isEmpty()) {
String client_monikers []=info.getSend_clients().split(",");
List<JSONObject> mailto = new ArrayList<>();
Set<String> mailto = new HashSet<>();
ArrayList<String> mailboxs = new ArrayList<>();
for (String clientMoniker : client_monikers) {
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
JSONObject c = new JSONObject();
c.put("create_time", date);
c.put("notice_id", noticeId);
c.put("client_id", client.getIntValue("client_id"));
noticePartnerMapper.save(c);
String contact_email = client.getString("contact_email");
if (contact_email!=null && !mailboxs.contains(contact_email)){
c.put("mailto",contact_email);
mailto.add(c);
mailto.add(contact_email);
mailboxs.add(contact_email);
}
}
@ -177,17 +176,13 @@ public class NoticeManageImpl implements NoticeManage {
if (info.isIs_tomail_cc_stockholder()){
String stockholder_mails_mailto [] = stockholder_mails.trim().split(",");
for (String stockholder_mailto:stockholder_mails_mailto){
JSONObject stockholder = new JSONObject();
stockholder.put("mailto",stockholder_mailto);
stockholder.put("client_id",0);
mailto.add(stockholder);
mailto.add(stockholder_mailto);
}
}
try {
logger.info(noticeId+"|"+info.getTitle()+"|"+mailto);
String mail_id = mailService.sendEmail(noticeId,info.getTitle(),mailto,info.getContent());
notice.put("mail_id",mail_id);
JSONObject mailResult = mailGunService.sendEmail(noticeId,info.getTitle(),mailto,info.getContent());
notice.put("mail_id",mailResult.getString("mail_id"));
noticeManageMapper.updateNotice(notice);
} catch (URISyntaxException | IOException e) {
e.printStackTrace();

@ -12,18 +12,21 @@ import au.com.royalpay.payment.tools.locale.LocaleSupport;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
/**
* Create by yixian at 2018-03-20 17:44
*/
@ -73,7 +76,7 @@ public class ManualSettleSupportImpl implements ManualSettleSupport {
@Override
public JSONObject findCurrentSettle(int clientId, boolean includingUnsettleData) {
JSONObject client = merchantInfoProvider.getClientInfo(clientId);
JSONObject client = merchantInfoProvider.getClientInfoWithConfig(clientId);
if (!client.getBooleanValue("manual_settle")) {
throw new ForbiddenException("Manual Settlement Not Enabled");
}

@ -9,18 +9,19 @@ import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientConfigService;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.beans.LoginInfo;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.manage.signin.events.ClientLoginEvent;
import au.com.royalpay.payment.manage.signin.events.ManagerLoginEvent;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.env.RequestEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.locale.LocaleSupport;
import au.com.royalpay.payment.tools.mail.SendMail;
import au.com.royalpay.payment.tools.utils.PasswordUtils;
import com.alibaba.fastjson.JSONObject;
@ -39,8 +40,10 @@ import org.thymeleaf.spring4.SpringTemplateEngine;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
@ -60,7 +63,7 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
@Resource
private ClientMapper clientMapper;
@Resource
private MailService mailService;
private MailGunService mailService;
@Resource
private PermissionManager permissionManager;
@Resource
@ -306,12 +309,14 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
// final String content = VelocityEngineUtils.mergeTemplateIntoString(null, "mail/reset_password.vm",
// "utf-8", map);
new Thread(() -> {
try {
mailService.sendEmail("Reset Password", contact_email, "", content);
} catch (Exception ignored) {
}
}).start();
SendMail sendMail = new SendMail();
Set<String> to = new HashSet<>();
to.add(contact_email);
sendMail.setMailTos(to);
sendMail.setFrom("postmaster@mail.royalpay.com.au");
sendMail.setTitle("Reset Password");
sendMail.setContent(content);
mailService.sendMail(sendMail);
return contact_email;
@ -363,4 +368,5 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
account.put("is_password_expired", 0);
clientAccountMapper.update(account);
}
}

@ -0,0 +1,26 @@
package au.com.royalpay.payment.manage.system.core;
import au.com.royalpay.payment.tools.mail.SendMail;
import com.alibaba.fastjson.JSONObject;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Set;
public interface MailGunService {
void dealNotify(String nofityString) throws Exception;
void dealDroppedNotify(String content) throws Exception;
JSONObject sendMail(SendMail sendMail);
JSONObject addClientToMailList(JSONObject client);
JSONObject updateClientOfMailList(JSONObject newClient,JSONObject oldClient);
JSONObject sendEmail(String notice_id, String title, Set<String> mailTo, String content) throws URISyntaxException, IOException ;
}

@ -0,0 +1,167 @@
package au.com.royalpay.payment.manage.system.core.impl;
import au.com.royalpay.payment.manage.mappers.system.MailSendMapper;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient;
import au.com.royalpay.payment.tools.mail.MailGunClient;
import au.com.royalpay.payment.tools.mail.SendMail;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
@Service
public class MailGunServiceImpl implements MailGunService {
Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private MailSendMapper mailSendMapper;
@Resource
private MailGunClient mailGunClient;
@Value("${mail.mailgun.default.merchantlist}")
private String mailListDefault;
@Resource
private AttachmentClient attachmentClient;
@Override
public void dealNotify(String nofityString) throws Exception {
String dd = URLDecoder.decode(nofityString, "UTF-8");
Map<String, String> mailgunNotify = getQueryMap(dd);
String myData = mailgunNotify.get("my-custom-data");
String recipient = mailgunNotify.get("recipient");
if (StringUtils.isNotEmpty(myData) && StringUtils.isNotEmpty(recipient)) {
JSONObject tmpJSONObject = JSONObject.parseObject(myData);
String[] mailAddresses = recipient.split(",");
for (String mailAddress : mailAddresses) {
JSONObject record = new JSONObject();
record.put("id", tmpJSONObject.getString("id"));
record.put("mail_address", mailAddress);
record.put("status", 1);
mailSendMapper.update(record);
}
}
}
@Override
public void dealDroppedNotify(String content) throws Exception {
String dd = URLDecoder.decode(content, "UTF-8");
Map<String, String> mailgunNotify = getQueryMap(dd);
String myData = mailgunNotify.get("my-custom-data");
String recipient = mailgunNotify.get("recipient");
if (StringUtils.isNotEmpty(myData) && StringUtils.isNotEmpty(recipient)) {
JSONObject tmpJSONObject = JSONObject.parseObject(myData);
String[] mailAddresses = recipient.split(",");
for (String mailAddress : mailAddresses) {
JSONObject record = new JSONObject();
record.put("id", tmpJSONObject.getString("id"));
record.put("mail_address", mailAddress);
record.put("status", 2);
mailSendMapper.update(record);
}
}
}
@Override
public JSONObject sendMail(SendMail sendMail) {
return mailGunClient.sendMail(sendMail);
}
@Override
public JSONObject addClientToMailList(JSONObject client) {
JSONObject result = null;
try {
JSONObject var = new JSONObject();
var.put("client_moniker", client.getString("client_moniker"));
var.put("short_name", client.getString("short_name"));
result = mailGunClient.addListMember(client.getString("contact_email"), mailListDefault, client.getString("contact_person"), var);
} catch (Exception ignore) {
logger.info("add Mail List Failed email:" + client.getString("contact_email") + " client_moniker:" + client.getString("client_moniker"));
}
return result;
}
@Override
public JSONObject updateClientOfMailList(JSONObject newClient, JSONObject oldClient) {
JSONObject result = null;
try {
JSONObject var = new JSONObject();
var.put("client_moniker", newClient.getString("client_moniker"));
var.put("short_name", newClient.getString("short_name"));
result = mailGunClient.updateClientOfMailList(newClient.getString("contact_email"), mailListDefault, newClient.getString("contact_person"),
oldClient.getString("contact_email"), var);
} catch (Exception ignore) {
logger.info("Modify Mail List Failed oldEmail:" + oldClient.getString("contact_email") + " client_moniker:" + newClient.getString("client_moniker")
+ " newEmail:" + newClient.getString("contact_email"));
}
return result;
}
@Override
public JSONObject sendEmail(String notice_id, String title, Set<String> mailTo, String content) throws URISyntaxException, IOException {
Document doc = Jsoup.parse(content);
Elements links = doc.select("a[href]");
List<JSONObject> files = new ArrayList<>();
for (Element link : links) {
String linkHref = link.attr("href");
String linkText = link.text();
Element e = link.previousElementSibling();
if (e != null && "img".equalsIgnoreCase(e.tagName())) {
e.remove();
}
if (linkHref.contains("mailto")) {
continue;
}
JSONObject file = new JSONObject();
file.put("name", linkText);
file.put("byteArr", attachmentClient.getFileByUrl(linkHref));
files.add(file);
}
SendMail sendMail = new SendMail();
sendMail.setFrom("postmaster@mail.royalpay.com.au");
sendMail.setTitle(title);
sendMail.setContent(doc.outerHtml());
sendMail.setNotice_id(notice_id);
sendMail.setMailTos(mailTo);
sendMail.setAttachFiles(files);
return mailGunClient.sendMail(sendMail);
}
public Map<String, String> getQueryMap(String query) {
String[] params = query.split("&");
Map<String, String> map = new HashMap<>();
for (String param : params) {
String[] tmpArr = param.split("=");
if (tmpArr.length < 2) {
continue;
}
map.put(tmpArr[0], tmpArr[1]);
}
return map;
}
}

@ -0,0 +1,30 @@
package au.com.royalpay.payment.manage.system.web;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping(value = "/mailgun")
public class MailCallBackController {
@Resource
private MailGunService mailService;
@RequestMapping(value = "/callback", method = RequestMethod.POST)
public void dealSuccessNptify(@RequestBody String content) throws Exception {
mailService.dealNotify(content);
}
@RequestMapping(value = "/callback/dropped", method = RequestMethod.POST)
public void contractList(@RequestBody String content) throws Exception {
mailService.dealDroppedNotify(content);
}
}

@ -16,7 +16,7 @@ public class DirectedBillCodeStatusDailyCheck {
@Resource
private PartnerBillService partnerBillService;
@Scheduled(cron = "0 0 6 * * ?")
@Scheduled(cron = "0 30 5 * * ?")
public void statusDailyCheck(){
partnerBillService.dailyCheckDirectedBillCode();
}

@ -22,6 +22,7 @@ public class PartnerInitEmailChecker {
public void checkEmailStatus(){
if (PlatformEnvironment.getEnv().taskEnabled()) {
clientManager.checkEmailStatus();
clientManager.newCheckEmailStatus();
}
}
}

@ -28,9 +28,4 @@ public class WeekReportGenerationTask {
lastweek = DateUtils.addDays(lastweek, -7);
weekReporter.generateReport(DateFormatUtils.format(lastweek, "yyyy-MM-dd"), true);
}
public static void main(String[] args) {
String asd = "a sd ";
System.out.println(asd);
System.out.println(asd.trim());
}
}

@ -1,6 +1,6 @@
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.schema-name=royalpay_production
spring.datasource.host=192.168.0.49:3306
spring.datasource.host=192.168.99.100:3306
spring.datasource.url=jdbc:mysql://${spring.datasource.host}/${spring.datasource.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username=root
spring.datasource.password=root

@ -18,11 +18,11 @@ spring.datasource.max-idle=150
spring.datasource.max-wait=3000
spring.datasource.filters=stat,wall,log4j
spring.redis.host=192.168.99.100
spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.database=1
spring.data.mongodb.host=192.168.99.100
spring.data.mongodb.host=10.30.0.8
spring.data.mongodb.port=27017
spring.data.mongodb.database=admin
spring.data.mongodb.username=mongouser
@ -100,4 +100,9 @@ app.ofei.md5-key=Khjx6wejblaJzmG0JBWFlPFKAUxhFIXQ
app.ofei.pwd=aomi@8888
app.ofei.sp-code=A1407200
mail.mailgun.api_key=api:key-96fa3b5866ace125b8ec5a9d27e19353
mail.mailgun.api_key=api:key-2e67b891a1a7974bf3a40ea440d5a77f
mail.mailgun.public_key=api:pubkey-1aaaffc2662ba1b400c409d3e974ba7e
mail.mailgun.domain=mail.royalpay.com.au
mail.mailgun.default.merchantlist=merchants@mail.royalpay.com.au

@ -286,7 +286,7 @@
</select>
<select id="listClientByCleanDays" resultType="java.lang.String">
SELECT c.client_id FROM sys_clients c
inner join sys_client_config cc
inner join sys_client_config cc on c.client_id = cc.client_id
WHERE c.is_valid = 1 and cc.clean_days = #{clean_days}
</select>

@ -888,11 +888,6 @@ margin-bottom: 10%;"/>
<!--<i class="fa fa-users" aria-hidden="true"></i> -->Cashiers Management
</a>
</li>
<li ng-if="currentUser.client.client_moniker=='PINE'">
<a ui-sref="bill_qrcode">
Bill QR Code
</a>
</li>
</ul>
</li>
<li ng-if="([1,2]|withRole)">
@ -919,16 +914,21 @@ margin-bottom: 10%;"/>
</li>
<li class="has-submenu" ng-class="{'open' : products.active}" ui-sref-active="active">
<a ng-click="products.active = !products.active"><i class="fa fa-balance-scale"></i>Products & Sale</a>
<a ng-click="products.active = !products.active"><i class="fa fa-balance-scale"></i>Extended products</a>
<ul class="submenu" ng-class="{'open' : products.active}">
<li>
<a ui-sref="goods">
<!--<i class="fa fa-shopping-bag"></i> -->Products
<!--<i class="fa fa-shopping-bag"></i> -->Products & Sale
</a>
</li>
<li>
<!-- <li>
<a ui-sref="sale">
<!--<i class="fa fa-shopping-cart"></i>-->Sale
&lt;!&ndash;<i class="fa fa-shopping-cart"></i>&ndash;&gt;Sale
</a>
</li>-->
<li ng-if="currentUser.client.client_moniker=='PINE' || currentUser.client.client_moniker=='OCCO'">
<a ui-sref="bill_qrcode">
Bill QR Code
</a>
</li>
</ul>

@ -59,7 +59,6 @@ var modules = [
{path: 'static/boot/indexMainApp', module: 'indexMainApp', roles: [1, 2, 3]},
{path: 'static/commons/commons', module: 'commons', roles: [1, 2, 3]},
{path: 'static/payment/good/good-manage', module: 'goodManagement', roles: [1, 2, 3]},
{path: 'static/payment/good/good-sale', module: 'goodSale', roles: [1, 2, 3]},
{path: 'static/payment/partner/partner', module: 'partnerInfoApp', roles: [1, 2, 3]},
{path: 'static/payment/tradelog/tradelog', module: 'tradeLogApp', roles: [1, 2, 3]},
{path: 'static/payment/tradelog/transflow', module: 'balanceReport', roles: [1, 2, 3]},

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

@ -35,28 +35,28 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-4 col-sm-3">* Expire</label>
<label class="control-label col-xs-4 col-sm-3">* Expire Date</label>
<div class="col-xs-8 col-sm-6">
<input class="form-control" ng-model="new_bill.cancle_time"
uib-datepicker-popup size="10" is-open="ctrl.dateInput"
ng-click="ctrl.dateInput=true"
datepicker-options="{minDate:minDate,maxDate:maxDate}" name="cancle_time" required>
<p class="small text-info">Expire Date 不得超过十五天</p>
<p class="small text-info">The date of expiry should not exceed fifteen days</p>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-4 col-sm-3">Client Order Id</label>
<label class="control-label col-xs-4 col-sm-3">Reference NO</label>
<div class="col-xs-8 col-sm-6">
<input class="form-control" ng-model="new_bill.client_order_id">
<p class="small text-info">Client Order Id 为空时,系统自动生成</p>
<p class="small text-info"> System will automatically generate when the Reference NO is empty</p>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-4 col-sm-3">Remark</label>
<div class="col-xs-8 col-sm-6">
<textarea maxlength="100" class="form-control" ng-model="new_bill.remark"></textarea>
<p class="small text-info">Remark 不得超过100字符</p>
<p class="small text-info">within 100 characters</p>
</div>
</div>
<div class="form-group">
@ -79,16 +79,38 @@
</div>
</div>
</div>
<div class="box">
<div class="box box-warning">
<div class="box-header">
<h3 class="box-title">Bill List &nbsp;&nbsp;&nbsp;&nbsp;
<a role="button" ng-class="{'bg-primary':params.status==null}"
ng-click="params.status=null;loadBills(1)">All</a> |
<a role="button" ng-class="{'bg-primary':params.status==3}"
ng-click="params.status=3;loadBills(1)">Success</a> |
<a role="button" ng-class="{'bg-primary':params.status==2}"
ng-click="params.status=2;loadBills(1)">Disabled</a>
<div class="form-inline">
<div class="form-group">
<label class="control-label">Bill Status</label>
&nbsp;
<a role="button" ng-class="{'bg-primary':params.status==null}"
ng-click="params.status=null;loadBills(1)">All</a> |
<a role="button" ng-class="{'bg-primary':params.status==3}"
ng-click="params.status=3;loadBills(1)">Success</a> |
<a role="button" ng-class="{'bg-primary':params.status==2}"
ng-click="params.status=2;loadBills(1)">Disabled</a>
</div>
&nbsp; &nbsp; &nbsp; &nbsp;
<div class="form-group">
<label class="control-label" >Reference NO</label>
<input type="text" class="form-control"
ng-model="params.client_order_id"
ng-enter="loadBills(1)">
</div>
<div class="form-group">
<button class="btn btn-primary" type="button" ng-click="loadBills(1)"><i
class="fa fa-search"></i></button>
</div>
</div>
</div>
</div>
<div class="box">
<div class="box-header">
<h3 class="box-title">
Bill List
</h3>
</div>
<div class="box-body table-responsive">
@ -96,7 +118,7 @@
<thead>
<tr>
<th>Order Amount</th>
<th>Client Order Id</th>
<th>Reference NO</th>
<th>Payer</th>
<th>Order Status</th>
<th>Bill Status</th>
@ -118,7 +140,7 @@
<td ng-bind="bill.remark|remarkCut:true:10:'...'"></td>
<td ng-bind="bill.create_time"></td>
<td>
<a ng-if="bill.order_id" class="text-primary" role="button" title="Detail"
<a ng-if="bill.order_id&&bill.status!=2" class="text-primary" role="button" title="Detail"
ng-click="showTradeDetail(bill)">
<i class="fa fa-search"></i>
</a>

@ -10,6 +10,11 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
templateUrl: '/static/payment/good/templates/goods.html',
controller: 'goodListCtrl',
data: {label: '商品列表'}
}).state('goods.sale', {
url: '/sale',
templateUrl: '/static/payment/good/templates/good_sale.html',
controller: 'goodOrderListCtrl',
data: {label: '商品列表'}
}).state('goods.new', {
url: '/new',
templateUrl: '/static/payment/good/templates/add_good.html',
@ -196,7 +201,57 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
$scope.ctrl = {};
}]);
app.controller('goodOrderListCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.pagination = {};
$scope.params = {status:'1'};
$scope.today = new Date();
$scope.chooseToday = function () {
$scope.params.datefrom = $scope.params.dateto = new Date();
$scope.loadGoodOrders(1);
};
$scope.chooseYesterday = function () {
var yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
$scope.params.datefrom = $scope.params.dateto = yesterday;
$scope.loadGoodOrders(1);
};
$scope.chooseLast7Days = function () {
$scope.params.dateto = new Date();
var day = new Date();
day.setDate(day.getDate() - 7);
$scope.params.datefrom = day;
$scope.loadGoodOrders(1);
};
$scope.thisMonth = function () {
$scope.params.dateto = new Date();
var monthBegin = new Date();
monthBegin.setDate(1);
$scope.params.datefrom = monthBegin;
$scope.loadGoodOrders(1);
};
$scope.lastMonth = function () {
var monthFinish = new Date();
monthFinish.setDate(0);
$scope.params.dateto = monthFinish;
var monthBegin = new Date();
monthBegin.setDate(0);
monthBegin.setDate(1);
$scope.params.datefrom = monthBegin;
$scope.loadGoodOrders(1);
};
$scope.loadGoodOrders = function (page) {
var params = angular.copy($scope.params);
if (params.status=='ALL'){
delete params.status;
}
params.page = page || $scope.pagination.page || 1;
$http.get('/sys/client/goods/goodOrders', {params: params}).then(function (resp) {
$scope.sales = resp.data.data;
$scope.pagination = resp.data.pagination;
});
};
$scope.loadGoodOrders(1);
}]);
return app;
});

@ -1,6 +1,7 @@
/**
* Created by yishuqian on 8/29/16.
*/
/*
define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootSwitch'], function (angular) {
'use strict';
@ -67,4 +68,4 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
}]);
return app;
});
});*/

@ -1,158 +1,146 @@
<div ui-view>
<section class="content-header">
<h1>List of Products Sold</h1>
<ol class="breadcrumb">
<li>
<i class="fa fa-sitemap"></i> Products & Sale
</li>
<li class="active">Sale</li>
</ol>
</section>
<div class="content">
<div class="row">
<div class="col-sm-12">
<div class="box-solid">
<div class="box box-warning">
<div class="box-header">
<div class="form-inline">
<div class="form-group col-xs-12">
<label class="control-label col-xs-4 col-sm-2">Status</label>
<div class="col-sm-10 col-xs-8">
<p class="form-control-static">
<a role="button" ng-class="{'bg-primary':params.status=='ALL'}"
ng-click="params.status='ALL';loadGoodOrders(1)">All</a> |
<a role="button" ng-class="{'bg-primary':params.status=='PAID'}"
ng-click="params.status='1';loadGoodOrders(1)">Payment Success</a> |
<a role="button" ng-class="{'bg-primary':params.status=='UNPAID'}"
ng-click="params.status='0';loadGoodOrders(1)">Waiting for Payment</a>
</p>
<div class="row">
<div class="col-sm-12">
<div class="box-solid">
<div class="box box-warning">
<div class="box-header">
<div class="form-inline">
<div class="form-group col-xs-12">
<label class="control-label col-xs-4 col-sm-2">Status</label>
<div class="col-sm-10 col-xs-8">
<p class="form-control-static">
<a role="button" ng-class="{'bg-primary':params.status=='ALL'}"
ng-click="params.status='ALL';loadGoodOrders(1)">All</a> |
<a role="button" ng-class="{'bg-primary':params.status=='PAID'}"
ng-click="params.status='1';loadGoodOrders(1)">Payment Success</a> |
<a role="button" ng-class="{'bg-primary':params.status=='UNPAID'}"
ng-click="params.status='0';loadGoodOrders(1)">Waiting for Payment</a>
</p>
</div>
</div>
<div class="form-group col-xs-12">
<label class="control-label col-xs-4 col-sm-2">Date Range</label>
<div class="col-sm-10 col-xs-8">
<div class="form-control-static form-inline">
<div style="display: inline-block">
<input class="form-control" id="date-from-input" ng-model="params.datefrom"
uib-datepicker-popup size="10" placeholder="From"
is-open="dateBegin.open" ng-click="dateBegin.open=true"
datepicker-options="{maxDate:params.dateto||today}">
</div>
</div>
<div class="form-group col-xs-12">
<label class="control-label col-xs-4 col-sm-2">Date Range</label>
<div class="col-sm-10 col-xs-8">
<div class="form-control-static form-inline">
<div style="display: inline-block">
<input class="form-control" id="date-from-input" ng-model="params.datefrom"
uib-datepicker-popup size="10" placeholder="From"
is-open="dateBegin.open" ng-click="dateBegin.open=true"
datepicker-options="{maxDate:params.dateto||today}">
</div>
~
<div style="display: inline-block">
<input class="form-control" id="date-to-input" ng-model="params.dateto"
uib-datepicker-popup size="10" placeholder="To"
is-open="dateTo.open" ng-click="dateTo.open=true"
datepicker-options="{minDate:params.datefrom,maxDate:today}">
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm"
ng-click="chooseToday()">Today</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm"
ng-click="chooseYesterday()">Yesterday</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm"
ng-click="chooseLast7Days()">Last 7
Days</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm" ng-click="thisMonth()">This
Month</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm" ng-click="lastMonth()">Last
Month</a>
</div>
</div>
~
<div style="display: inline-block">
<input class="form-control" id="date-to-input" ng-model="params.dateto"
uib-datepicker-popup size="10" placeholder="To"
is-open="dateTo.open" ng-click="dateTo.open=true"
datepicker-options="{minDate:params.datefrom,maxDate:today}">
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm"
ng-click="chooseToday()">Today</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm"
ng-click="chooseYesterday()">Yesterday</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm"
ng-click="chooseLast7Days()">Last 7
Days</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm" ng-click="thisMonth()">This
Month</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm" ng-click="lastMonth()">Last
Month</a>
</div>
</div>
<!--<div class="form-group">-->
<!--<label class="control-label" for="short-name-search">Partner Name</label>-->
<!--<input type="text" class="form-control" id="short-name-search"-->
<!--ng-model="params.short_name">-->
<!--</div>-->
<button class="btn btn-success" type="button" ng-click="loadGoodOrders(1)">
<i class="fa fa-search"></i> Search
</button>
</div>
</div>
<!--<div class="form-group">-->
<!--<label class="control-label" for="short-name-search">Partner Name</label>-->
<!--<input type="text" class="form-control" id="short-name-search"-->
<!--ng-model="params.short_name">-->
<!--</div>-->
<button class="btn btn-success" type="button" ng-click="loadGoodOrders(1)">
<i class="fa fa-search"></i> Search
</button>
</div>
</div>
</div>
<div class="box">
<div class="box-header">
<h3 class="box-title">List of Products Sold</h3>
</div>
<div class="box-body no-padding table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Sale ID</th>
<th>Payment Order ID</th>
<th>Product Name</th>
<th>Unit Price</th>
<th>Quantity</th>
<th>Order Total</th>
<th>Order Status</th>
<th>Create Time</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="goodOrder in sales">
<!--<td><span ng-bind="good.goodId"></span><i class="fa fa-sitemap" ng-if="good.parent_client_id" title="Sub Partner"></i></td>-->
<td ng-bind="goodOrder.id"></td>
<td ng-bind="goodOrder.order_id"></td>
<td ng-bind="goodOrder.title"></td>
<td ng-bind="goodOrder.price"></td>
<td ng-bind="goodOrder.count"></td>
<td ng-bind="goodOrder.order_total"></td>
<!--<td ng-bind="good.is_using"></td>-->
<td>
<span ng-if="goodOrder.order_status==1">PAID</span>
<span ng-if="goodOrder.order_status==0">NOT PAID</span>
<span ng-if="goodOrder.order_status==2">CLOSED</span>
</td>
<td ng-bind="goodOrder.create_time"></td>
<div class="box">
<div class="box-header">
<h3 class="box-title">List of Products Sold</h3>
</div>
</tr>
</tbody>
</table>
<div class="box-body no-padding table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Sale ID</th>
<th>Payment Order ID</th>
<th>Product Name</th>
<th>Unit Price</th>
<th>Quantity</th>
<th>Order Total</th>
<th>Order Status</th>
<th>Create Time</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="goodOrder in sales">
<!--<td><span ng-bind="good.goodId"></span><i class="fa fa-sitemap" ng-if="good.parent_client_id" title="Sub Partner"></i></td>-->
<td ng-bind="goodOrder.id"></td>
<td ng-bind="goodOrder.order_id"></td>
<td ng-bind="goodOrder.title"></td>
<td ng-bind="goodOrder.price"></td>
<td ng-bind="goodOrder.count"></td>
<td ng-bind="goodOrder.order_total"></td>
<!--<td ng-bind="good.is_using"></td>-->
<td>
<span ng-if="goodOrder.order_status==1">PAID</span>
<span ng-if="goodOrder.order_status==0">NOT PAID</span>
<span ng-if="goodOrder.order_status==2">CLOSED</span>
</td>
<td ng-bind="goodOrder.create_time"></td>
</tr>
</tbody>
</table>
</div>
<div class="box-footer" ng-if="goods.length">
<uib-pagination class="pagination"
total-items="pagination.totalCount"
boundary-links="true"
ng-model="pagination.page"
items-per-page="pagination.limit"
max-size="10"
ng-change="loadGoodOrders()"
previous-text="&lsaquo;"
next-text="&rsaquo;"
first-text="&laquo;"
last-text="&raquo;"></uib-pagination>
<div class="row">
<div class="col-xs-12">Total Records:{{pagination.totalCount}};Total Pages:{{pagination.totalPages}}</div>
</div>
</div>
<div class="box-footer" ng-if="goods.length">
<uib-pagination class="pagination"
total-items="pagination.totalCount"
boundary-links="true"
ng-model="pagination.page"
items-per-page="pagination.limit"
max-size="10"
ng-change="loadGoodOrders()"
previous-text="&lsaquo;"
next-text="&rsaquo;"
first-text="&laquo;"
last-text="&raquo;"></uib-pagination>
<div class="row">
<div class="col-xs-12">Total Records:{{pagination.totalCount}};Total
Pages:{{pagination.totalPages}}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

@ -1,135 +1,150 @@
<div ui-view>
<section class="content-header">
<h1>Product Management</h1>
<ol class="breadcrumb">
<li>
<i class="fa fa-sitemap"></i> Products & Sale
</li>
<li class="active">Product Management</li>
</ol>
</section>
<div class="content">
<section class="content-header">
<h1>Product & Sale</h1>
<ol class="breadcrumb">
<li>
<i class="fa fa-sitemap"></i> Products & Sale
</li>
<li class="active">Product & Sale Management</li>
</ol>
</section>
<div class="content">
<div class="row">
<div class="col-sm-12">
<div class="box-solid">
<div class="box box-warning">
<div class="box-header">
<div class="form-inline">
<!--<div class="form-group">-->
<!--<label class="control-label" for="good-code-search">Good Code</label>-->
<!--<input class="form-control" id="good-code-search" ng-model="params.code">-->
<!--</div>-->
<div class="form-group">
<label class="control-label" for="good-title-search">Product Name</label>
<input type="number" class="form-control" id="good-title-search"
ng-model="params.title">
</div>
<div class="form-group">
<label class="control-label" for="good-type-search">Product Type</label>
<input type="number" class="form-control" id="good-type-search"
ng-model="params.type">
</div>
<!--<div class="form-group">-->
<!--<label class="control-label" for="short-name-search">Partner Name</label>-->
<!--<input type="text" class="form-control" id="short-name-search"-->
<!--ng-model="params.short_name">-->
<!--</div>-->
<div class="form-group">
<button class="btn btn-primary" type="button" ng-click="loadGood(1)"><i
class="fa fa-search"></i></button>
</div>
<div class="form-group">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li ui-sref-active-eq="active">
<a ui-sref="goods">Product</a>
</li>
<li ui-sref-active="active">
<a ui-sref="goods.sale">Sale</a>
</li>
</ul>
<div class="tab-content" ui-view>
<div class="row">
<div class="col-sm-12">
<div class="box-solid">
<div class="box box-warning">
<div class="box-header">
<div class="form-inline">
<!--<div class="form-group">-->
<!--<label class="control-label" for="good-code-search">Good Code</label>-->
<!--<input class="form-control" id="good-code-search" ng-model="params.code">-->
<!--</div>-->
<div class="form-group">
<label class="control-label" for="good-title-search">Product Name</label>
<input type="number" class="form-control" id="good-title-search"
ng-model="params.title">
</div>
<div class="form-group">
<label class="control-label" for="good-type-search">Product Type</label>
<input type="number" class="form-control" id="good-type-search"
ng-model="params.type">
</div>
<!--<div class="form-group">-->
<!--<label class="control-label" for="short-name-search">Partner Name</label>-->
<!--<input type="text" class="form-control" id="short-name-search"-->
<!--ng-model="params.short_name">-->
<!--</div>-->
<div class="form-group">
<button class="btn btn-primary" type="button" ng-click="loadGood(1)"><i
class="fa fa-search"></i></button>
</div>
<div class="form-group">
<a role="button" class="btn btn-info pull-right" ui-sref=".new" title="Add Product">
<i class="fa fa-plus"></i>
Add Product
</a>
</div>
<a role="button" class="btn btn-info pull-right" ui-sref=".new" title="Add Product">
<i class="fa fa-plus"></i>
Add Product
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="box">
<div class="box-header">
<h3 class="box-title">List of Products</h3>
</div>
<div class="box">
<div class="box-header">
<h3 class="box-title">List of Products</h3>
</div>
<div class="box-body no-padding table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Product Image</th>
<th>Product Name</th>
<th>Price (AUD)</th>
<th>Current Price (AUD)</th>
<th>Price (CNY)</th>
<th>Current Price(CNY)</th>
<th>Product Type</th>
<th>Stocks Available</th>
<th>Origin</th>
<th>Status</th>
<th>Operation</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="good in goods">
<div class="box-body no-padding table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Product Image</th>
<th>Product Name</th>
<th>Price (AUD)</th>
<th>Current Price (AUD)</th>
<th>Price (CNY)</th>
<th>Current Price(CNY)</th>
<th>Product Type</th>
<th>Stocks Available</th>
<th>Origin</th>
<th>Status</th>
<th>Operation</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="good in goods">
<!--<td><span ng-bind="good.goodId"></span><i class="fa fa-sitemap" ng-if="good.parent_client_id" title="Sub Partner"></i></td>-->
<td><img ng-if="good.thumbnailUrl" src="{{good.thumbnailUrl}}"></td>
<td ng-bind="good.title"></td>
<td ng-bind="good.price"></td>
<td ng-bind="good.actual_price"></td>
<td ng-bind="good.cny_price"></td>
<td ng-bind="good.actual_cny_price"></td>
<td ng-bind="good.type"></td>
<td ng-bind="good.inventory"></td>
<td ng-bind="good.origin"></td>
<!--<td ng-bind="good.is_using"></td>-->
<td>
<span ng-if="good.is_using==1">On Sale</span>
<span ng-if="good.is_using==0">Out Of Stock</span>
</td>
<td>
<a class="text-primary" role="button" title="Detail"
ui-sref=".detail({goodId:good.id})">
<i class="fa fa-search"></i> Detail
</a>|
<a class="text-primary" role="button" title="Delete"
ng-click="deleteGoods(good.id)">
<i class="fa fa-trash-o"></i> Delete
</a>
</td>
</tr>
</tbody>
</table>
<!--<td><span ng-bind="good.goodId"></span><i class="fa fa-sitemap" ng-if="good.parent_client_id" title="Sub Partner"></i></td>-->
<td><img ng-if="good.thumbnailUrl" src="{{good.thumbnailUrl}}"></td>
<td ng-bind="good.title"></td>
<td ng-bind="good.price"></td>
<td ng-bind="good.actual_price"></td>
<td ng-bind="good.cny_price"></td>
<td ng-bind="good.actual_cny_price"></td>
<td ng-bind="good.type"></td>
<td ng-bind="good.inventory"></td>
<td ng-bind="good.origin"></td>
<!--<td ng-bind="good.is_using"></td>-->
<td>
<span ng-if="good.is_using==1">On Sale</span>
<span ng-if="good.is_using==0">Out Of Stock</span>
</td>
<td>
<a class="text-primary" role="button" title="Detail"
ui-sref=".detail({goodId:good.id})">
<i class="fa fa-search"></i> Detail
</a>|
<a class="text-primary" role="button" title="Delete"
ng-click="deleteGoods(good.id)">
<i class="fa fa-trash-o"></i> Delete
</a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="box-footer" ng-if="goods.length">
<uib-pagination class="pagination"
total-items="pagination.totalCount"
boundary-links="true"
ng-model="pagination.page"
items-per-page="pagination.limit"
max-size="10"
ng-change="loadGoods()"
previous-text="&lsaquo;"
next-text="&rsaquo;"
first-text="&laquo;"
last-text="&raquo;"></uib-pagination>
<div class="row">
<div class="col-xs-12">Total Records:{{pagination.totalCount}};Total Pages:{{pagination.totalPages}}</div>
</div>
</div>
</div>
</div>
</div>
<div class="box-footer" ng-if="goods.length">
<uib-pagination class="pagination"
total-items="pagination.totalCount"
boundary-links="true"
ng-model="pagination.page"
items-per-page="pagination.limit"
max-size="10"
ng-change="loadGoods()"
previous-text="&lsaquo;"
next-text="&rsaquo;"
first-text="&laquo;"
last-text="&raquo;"></uib-pagination>
<div class="row">
<div class="col-xs-12">Total Records:{{pagination.totalCount}};Total Pages:{{pagination.totalPages}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

@ -0,0 +1,79 @@
/**
* Created by yixian on 2016-07-15.
*/
$(document).ready(function () {
'use strict';
decode();
function decode() {
var redirect = window.redirect;
while(redirect.indexOf('://')<0){
redirect = decodeURIComponent(redirect);
if(redirect==window.redirect){
break;
}
window.redirect = redirect;
}
}
var dataCache = {paying: false};
$('#key_P').bind('touchstart', startPay);
function startPay() {
$('#wdiv').show();
if (dataCache.paying) {
return;
}
dataCache.paying = true;
$.ajax({
url: '/api/v1.0/alipay/partners/' + window.client_moniker + '/orders/'+window.order_id+'/order_params',
method: 'GET',
dataType: 'json',
success: function (pay) {
if (pay.direct_paid) {
location.href = window.redirect;
return;
}
if (window.AlipayJSBridge) {
callPayment();
} else {
// 如果没有注入则监听注入的事件
document.addEventListener('AlipayJSBridgeReady', callPayment, false);
}
function callPayment() {
try {
AlipayJSBridge.call('tradePay', {
tradeNO: pay.trade_no
}, function (res) {
dataCache.paying = false;
if (res.resultCode == '9000') {
AlipayJSBridge.call('startApp', {
appId: '20000056',
param: {
actionType: 'showSuccPage',
payResult: res.result
},
closeCurrentApp: false
});
location.href = window.redirect;
} else {
alert(res.memo);
}
$('#wdiv').hide();
})
} catch (err) {
alert(err);
$('#wdiv').hide();
}
}
},
error: function (jqXhr) {
alert(jqXhr.responseJSON.message);
$('#wdiv').hide();
dataCache.paying = false;
}
})
}
});

@ -0,0 +1,120 @@
.weui_cell_ft {
max-width: 60%;
white-space: normal
}
.pay-container{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.pay-container>img{
display: block;
margin: auto;
width: 250px;
}
div,span,img,button,a,p{
box-sizing: border-box;
}
body{
background: #fff;
}
.royal-container{
margin-top: 20%;
display: block;
width: 100%;
padding: 10px 30px;
}
.royal-container .royal-row{
border-bottom: 1px solid #d1d2d4;
padding: 5px 0;
}
.royal-container .royal-row.brand{
text-align: center;
}
.royal-container .royal-row.brand img{
display: block;
max-width: 60%;
max-height: 100px;
margin: auto;
}
.royal-container .royal-row.brand .name{
display: block;
margin: auto;
font-size: 1.6em;
}
.text-title{
color: #888888;
font-size: 0.9em;
}
.text-main{
color: #333333;
font-size: 1.1em;
}
.royal-pay-btn{
background: #30af69;
color: #fff;
width: 96%;
display: block;
margin: 10px auto 30px;
height: 50px;
line-height: 50px;
font-size: 1.4em;
text-align: center;
}
.alipay .royal-pay-btn{
background: #108ee9;
}
.alipay .amount_title{
background: #108ee9;
}
.amount_title{
height: 14%;
z-index: 10;
background: #30af69;
max-height: 200px;
min-height: 120px;
width: 100%;
}
.amount_title_logo{
float: left;
max-width: 90px;
min-width: 80px;
margin-left: 10px;
}
.amount_title_content{
float: left;
}
.amount_title_content_amount{
font-family: Avenir-Roman;
font-size: 30px;
color: #FFFFFF;
}
.amount_title_content_text{
font-family: PingFangSC-Regular;
font-size: 17px;
color: #FFFFFF;
}
.merchant_info{
height: 100px;
z-index: 1;
position: absolute;
width: 94%;
margin: -5% 0% 0px 3%;
text-align: center;
background-color: #FFFFFF;
box-shadow: 0px 0px 8px 0px rgba(171,171,171,0.50);
}
.merchant_info img{
max-height: 60px;
min-height: 50px;
}

@ -0,0 +1,106 @@
$(document).ready(function () {
'use strict';
decode();
function decode() {
var redirect = window.redirect;
while (redirect.indexOf('://') < 0) {
redirect = decodeURIComponent(redirect);
if (redirect == window.redirect) {
break;
}
window.redirect = redirect;
}
}
var dataCache = {paying: false};
$('#key_P').bind('touchstart', startPay);
function startPay() {
$('#wdiv').show();
if (dataCache.paying) {
return;
}
dataCache.paying = true;
$.ajax({
url: '/api/payment/v1.0/wechat_jsapi_payment/partners/' + window.client_moniker + '/orders/' + window.order_id + '/preorder',
method: 'get',
dataType: 'json',
success: function (pay) {
try {
if (pay.direct_paid) {
dataCache.paying = false;
location.href = window.redirect;
}
var paydata = pay.jsapi;
invokePay(paydata);
}catch (e) {
alert("Unexpected Error:" + e);
$('#wdiv').hide();
dataCache.paying = false;
}
},
error: function (jqXhr) {
var respText = jqXhr.responseText;
try {
alert(JSON.parse(respText).message);
$('#wdiv').hide();
dataCache.paying = false;
} catch (e) {
alert("Unexpected Error:" + respText);
$('#wdiv').hide();
dataCache.paying = false;
}
}
});
}
function invokePay(paydata) {
WeixinJSBridge.invoke('getBrandWCPayRequest', {
'appId': paydata.appId,
'timeStamp': paydata.timeStamp,
'nonceStr': paydata.nonceStr,
'package': paydata.package,
'signType': paydata.signType,
'paySign': paydata.paySign
}, function (res) {
dataCache.paying = false;
if (res.err_msg == 'get_brand_wcpay_request:ok') {
startCheckOrder(window.order_id)
} else {
if (res.err_msg != 'get_brand_wcpay_request:cancel' && res.err_msg != 'get_brand_wcpay_request:fail') {
alert('WeChat Error:' + res.err_msg);
}
if (window.paydata) {
location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=false';
}
}
//todo get status from server
$('#wdiv').hide();
})
}
function startCheckOrder(orderId) {
function checkOrderStd() {
$.ajax({
url: '/api/v1.0/payment/orders/' + orderId + '/status',
method: 'GET',
dataType: 'json',
success: function (res) {
if (res.paid) {
location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true';
} else {
setTimeout(checkOrderStd, 500);
}
}
})
}
checkOrderStd();
}
});

@ -1,32 +1,41 @@
package au.com.royalpay.payment.manage.apps.core.impls;
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.tools.mail.MailGunClient;
import au.com.royalpay.payment.tools.mail.SendMail;
import com.alibaba.fastjson.JSONObject;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
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.util.Iterator;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
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.
*/
@ -43,6 +52,10 @@ public class CustomerImpressionImplTest {
private ClientMapper clientMapper;
@Resource
private OrgMapper orgMapper;
@Resource
private MailGunClient mailGunClient;
@Resource
private ClientConfigMapper clientConfigMapper;
// @Test
// public void redisQueue() {
@ -54,39 +67,155 @@ public class CustomerImpressionImplTest {
// }
// }
// @Test
// public void excel() {
// 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(3);
// cell.setCellType(HSSFCell.CELL_TYPE_STRING);
//
// JSONObject client = clientMapper.findClientByMoniker(cell.getStringCellValue().trim());
// if(client==null){
// System.out.println();
// continue;
// }
// JSONObject org = orgMapper.findOne(client.getIntValue("org_id"));
// if(org==null){
// continue;
// }
//
// row.createCell(5).setCellValue(org.getString("name"));
// }
//
// OutputStream out = new FileOutputStream("/Users/wangning/Desktop/春节活动报名结果通知(包含BD名称).xlsx");
// workbook.write(out);
// workbook.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
@Test
public void excel() {
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 {
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/11.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(0);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
JSONObject client = clientMapper.findClientByMoniker(cell.getStringCellValue().trim());
if(client==null){
System.out.println();
continue;
}
JSONObject org = orgMapper.test(client.getIntValue("client_id"));
if(org==null){
continue;
}
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();
}
}
row.createCell(10).setCellValue(org.getString("sum"));
row.createCell(11).setCellValue(org.getString("counts"));
}
@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());
OutputStream out = new FileOutputStream("/Users/wangning/Desktop/22.xlsx");
workbook.write(out);
workbook.close();
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 qwe() {
List<JSONObject> clients = clientMapper.AllClients();
List<JSONObject> clientConfigs = clientConfigMapper.getAll();
Map<String, JSONObject> clientConfigMap = new HashMap<>();
Map<String, JSONObject> clientMap = new HashMap<>();
clientConfigs.forEach(p -> {
clientConfigMap.put(p.getString("client_moniker"), p);
});
clients.forEach(p -> {
clientMap.put(p.getString("client_moniker"), p);
});
String split = "--";
String cc = "cc:";
String c = "c";
clientConfigMap.values().forEach(p -> {
String clientMoniker = p.getString("client_moniker");
JSONObject tmpClient = clientMap.get(clientMoniker);
tmpClient.keySet().forEach(o->{
if(StringUtils.isNotEmpty(p.getString(o))){
if(!tmpClient.getString(o).equals(p.getString(o))){
System.out.println(clientMoniker+split+o+split+cc+p.getString(o)+split+c+tmpClient.getString(o));
}
}
});
});
}
}

@ -0,0 +1,30 @@
package au.com.royalpay.payment.manage.system.core.impl;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
@SpringBootTest
@ActiveProfiles({ "local", "alipay", "wechat", "jd", "bestpay" })
@RunWith(SpringRunner.class)
public class MailGunServiceImplTest {
@Resource
MailGunService mailService;
@Test
public void dealNotify() {
String dd= "timestamp=1526298391&token=b7ad8dc0905c46b1c4853200941d30417b4d3f3695815dc729&signature=a3507be4d7ad2b48c4b57202eabd6f63b75abfacd974a9bc7773dc968a12c34e&X-Mailgun-Sid=WyJlMjYwYSIsICI0NjQ1NjMxMThAcXEuY29tIiwgIjQzODY0NiJd&domain=dev.showcodes.com&X-Mailgun-Tag=test1&event=delivered&event-timestamp=1526298391.16&message-headers=[[\"X-Mailgun-Sending-Ip\", \"184.173.153.207\"], [\"X-Mailgun-Sid\", \"WyJlMjYwYSIsICI0NjQ1NjMxMThAcXEuY29tIiwgIjQzODY0NiJd\"], [\"List-Unsubscribe\", \"<mailto:u+mq6timzygy2dmjtjhuzdamjyga2tcnbrge2dmmrzfyys4msdivdecmkegi3uenbwgu4ugnbfgqygizlwfzzwq33xmnxwizltfzrw63jgna6tgmbummzdqnjzga2tkylggfqwkzjqhbrwiyzumzqtkztgg44donrgnu6tknjugqytomjgoi6tinrugu3dgmjrhastimdroexgg33nezwxslldovzxi33nfvsgc5dbhustoqrfgizgwzlzeuzdejjtiestemtwmfwhkzjfgizckn2e@dev.showcodes.com>\"], [\"Received\", \"by luna.mailgun.net with SMTP X-Mailgun-List-Id=5544171, 8794346058393; Mon, 14 May 2018 11:46:29 +0000\"], [\"X-Mailgun-List-Id\", \"5544171\"], [\"X-Mailgun-List-Address\", \"info@dev.showcodes.com\"], [\"List-Id\", \"<info.dev.showcodes.com>\"], [\"Received\", \"by luna.mailgun.net with HTTP; Mon, 14 May 2018 11:46:27 +0000\"], [\"Date\", \"Mon, 14 May 2018 11:46:27 +0000\"], [\"Sender\", \"postmaster@mail.royalpay.com.au\"], [\"X-Mailgun-Variables\", \"{\\\"my-custom-data\\\": \\\"{\\\\\\\"key\\\\\\\":\\\\\\\"value\\\\\\\"}\\\"}\"], [\"X-Mailgun-Tag\", \"test1\"], [\"From\", \"postmaster@mail.royalpay.com.au\"], [\"Subject\", \"Testqweasdzxc1\"], [\"Mime-Version\", \"1.0\"], [\"Content-Type\", [\"multipart/alternative\", {\"boundary\": \"12109fc0295a479385fcbed01f501455\"}]], [\"Message-Id\", \"<20180514114629.1.2CEFA1D27B4659C4@dev.showcodes.com>\"], [\"To\", \"yz <464563118@qq.com>\"]]&Message-Id=<20180514114629.1.2CEFA1D27B4659C4@dev.showcodes.com>&recipient=464563118@qq.com&my-custom-data={\"id\":\"123\"}&body-plain=";
try {
mailService.dealNotify(dd);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Loading…
Cancel
Save