|
|
@ -1,5 +1,42 @@
|
|
|
|
package au.com.royalpay.payment.manage.appclient.core.impls;
|
|
|
|
package au.com.royalpay.payment.manage.appclient.core.impls;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.TimeZone;
|
|
|
|
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
|
|
|
import org.jsoup.Jsoup;
|
|
|
|
|
|
|
|
import org.jsoup.nodes.Document;
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.core.PaymentApi;
|
|
|
|
import au.com.royalpay.payment.core.PaymentApi;
|
|
|
|
import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper;
|
|
|
|
import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper;
|
|
|
|
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
|
|
|
|
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
|
|
|
@ -14,17 +51,27 @@ import au.com.royalpay.payment.manage.mappers.log.ClearingDetailAnalysisMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.*;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientSettleDelayConfMapper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.CustomerMapper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper;
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
import au.com.royalpay.payment.manage.notice.beans.NoticeInfo;
|
|
|
|
import au.com.royalpay.payment.manage.notice.beans.NoticeInfo;
|
|
|
|
import au.com.royalpay.payment.manage.notice.core.NoticeManage;
|
|
|
|
import au.com.royalpay.payment.manage.notice.core.NoticeManage;
|
|
|
|
import au.com.royalpay.payment.manage.notice.core.NoticePartner;
|
|
|
|
import au.com.royalpay.payment.manage.notice.core.NoticePartner;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.pushMessage.JpushMessageHelper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.pushMessage.bean.JpushMessage;
|
|
|
|
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
|
|
|
|
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.impls.SignInAccountServiceImpl;
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.impls.SignInAccountServiceImpl;
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
|
|
|
|
import au.com.royalpay.payment.tools.cms.RoyalPayCMSSupport;
|
|
|
|
import au.com.royalpay.payment.tools.cms.RoyalPayCMSSupport;
|
|
|
|
import au.com.royalpay.payment.tools.device.DeviceSupport;
|
|
|
|
import au.com.royalpay.payment.tools.device.DeviceSupport;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.device.message.AppMessage;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.device.message.AppMsgSender;
|
|
|
|
import au.com.royalpay.payment.tools.device.support.DeviceRegister;
|
|
|
|
import au.com.royalpay.payment.tools.device.support.DeviceRegister;
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
@ -35,37 +82,6 @@ import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
|
|
|
|
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
|
|
|
|
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 com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
|
|
|
|
import com.notnoop.apns.APNS;
|
|
|
|
|
|
|
|
import com.notnoop.apns.ApnsService;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
|
|
|
import org.jsoup.Jsoup;
|
|
|
|
|
|
|
|
import org.jsoup.nodes.Document;
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Created by yishuqian on 28/03/2017.
|
|
|
|
* Created by yishuqian on 28/03/2017.
|
|
|
@ -77,72 +93,59 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
private TransactionAnalysisMapper transactionAnalysisMapper;
|
|
|
|
private TransactionAnalysisMapper transactionAnalysisMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private TransactionMapper transactionMapper;
|
|
|
|
private TransactionMapper transactionMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClientManager clientManager;
|
|
|
|
private ClientManager clientManager;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private NoticeManage noticeManage;
|
|
|
|
private NoticeManage noticeManage;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private NoticePartner noticePartner;
|
|
|
|
private NoticePartner noticePartner;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private CustomerAndOrdersStatisticsMapper customerAndOrdersStatisticsMapper;
|
|
|
|
private CustomerAndOrdersStatisticsMapper customerAndOrdersStatisticsMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClearingDetailMapper clearingDetailMapper;
|
|
|
|
private ClearingDetailMapper clearingDetailMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private OrderMapper orderMapper;
|
|
|
|
private OrderMapper orderMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClientAccountMapper clientAccountMapper;
|
|
|
|
private ClientAccountMapper clientAccountMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private AppMessageLogMapper appMessageLogMapper;
|
|
|
|
private AppMessageLogMapper appMessageLogMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private SignInAccountService signInAccountService;
|
|
|
|
private SignInAccountService signInAccountService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private CashbackService cashbackService;
|
|
|
|
private CashbackService cashbackService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClearingDetailAnalysisMapper clearingDetailAnalysisMapper;
|
|
|
|
private ClearingDetailAnalysisMapper clearingDetailAnalysisMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClientSettleDelayConfMapper clientSettleDelayConfMapper;
|
|
|
|
private ClientSettleDelayConfMapper clientSettleDelayConfMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private XPlanFundConfigServiceImpl xPlanFundConfigService;
|
|
|
|
private XPlanFundConfigServiceImpl xPlanFundConfigService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private MerchantInfoProvider merchantInfoProvider;
|
|
|
|
private MerchantInfoProvider merchantInfoProvider;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private RoyalPayCMSSupport royalPayCMSSupport;
|
|
|
|
private RoyalPayCMSSupport royalPayCMSSupport;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private PaymentApi paymentApi;
|
|
|
|
private PaymentApi paymentApi;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private DeviceSupport deviceSupport;
|
|
|
|
private DeviceSupport deviceSupport;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private CustomerRelationAlipayMapper customerRelationAlipayMapper;
|
|
|
|
private CustomerRelationAlipayMapper customerRelationAlipayMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private CustomerMapper customerMapper;
|
|
|
|
private CustomerMapper customerMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Value("classpath:apple_message_cert_dev.p12")
|
|
|
|
private APNSMessageHelper apnsMessageHelper;
|
|
|
|
private org.springframework.core.io.Resource appleMessageFileDev;
|
|
|
|
|
|
|
|
@Value("classpath:apple_message_cert_product.p12")
|
|
|
|
|
|
|
|
private org.springframework.core.io.Resource appleMessageFileProduct;
|
|
|
|
|
|
|
|
@Value("${apple.message.apns.password}")
|
|
|
|
|
|
|
|
private String appleMessagePassword;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClientDeviceTokenMapper clientDeviceTokenMapper;
|
|
|
|
private ClientDeviceTokenMapper clientDeviceTokenMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private JpushMessageHelper jpushMessageHelper;
|
|
|
|
|
|
|
|
|
|
|
|
private ThreadPoolExecutor sendingAppleMsgPool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
|
|
|
|
private Map<String, AppMsgSender> senderMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
public void setAppMsgSenders(AppMsgSender[] senders) {
|
|
|
|
|
|
|
|
Arrays.stream(senders).forEach(appMsgSender -> senderMap.put(appMsgSender.devType(), appMsgSender));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ThreadPoolExecutor sendingAppleMsgPool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private CouponValidateService couponVerificationService;
|
|
|
|
private CouponValidateService couponVerificationService;
|
|
|
@ -266,7 +269,6 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject getClientSettlementLog(JSONObject device, AppQueryBean appQueryBean) {
|
|
|
|
public JSONObject getClientSettlementLog(JSONObject device, AppQueryBean appQueryBean) {
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
@ -280,7 +282,8 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
JSONObject params = appQueryBean.toParams();
|
|
|
|
JSONObject params = appQueryBean.toParams();
|
|
|
|
setAllClientIds(params, client_id);
|
|
|
|
setAllClientIds(params, client_id);
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
PageList<JSONObject> logs = clearingDetailMapper.listClientSettlementLog(params, new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit(), Order.formString("report_date.desc")));
|
|
|
|
PageList<JSONObject> logs = clearingDetailMapper.listClientSettlementLog(params,
|
|
|
|
|
|
|
|
new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit(), Order.formString("report_date.desc")));
|
|
|
|
return PageListUtils.buildPageListResult(logs);
|
|
|
|
return PageListUtils.buildPageListResult(logs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -354,11 +357,13 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
params.put("dev_id", device.getString("dev_id"));
|
|
|
|
params.put("dev_id", device.getString("dev_id"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
PageList<JSONObject> orders = orderMapper.listOrdersByClients(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc")));
|
|
|
|
PageList<JSONObject> orders = orderMapper.listOrdersByClients(params,
|
|
|
|
|
|
|
|
new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc")));
|
|
|
|
TimeZoneUtils.switchTimeZone(orders, query.getTimezone(), "create_time", "transaction_time", "confirm_time");
|
|
|
|
TimeZoneUtils.switchTimeZone(orders, query.getTimezone(), "create_time", "transaction_time", "confirm_time");
|
|
|
|
ArrayList<String> date_contains = new ArrayList<>();
|
|
|
|
ArrayList<String> date_contains = new ArrayList<>();
|
|
|
|
for (JSONObject order : orders) {
|
|
|
|
for (JSONObject order : orders) {
|
|
|
|
// Date tradeDate = order.getDate("confirm_time") == null ? (order.getDate("transaction_time") == null ? order.getDate("create_time") : order.getDate("transaction_time")) : order.getDate("confirm_time");
|
|
|
|
// Date tradeDate = order.getDate("confirm_time") == null ? (order.getDate("transaction_time") == null ?
|
|
|
|
|
|
|
|
// order.getDate("create_time") : order.getDate("transaction_time")) : order.getDate("confirm_time");
|
|
|
|
Calendar calendar = (Calendar) order.get("create_time");
|
|
|
|
Calendar calendar = (Calendar) order.get("create_time");
|
|
|
|
String trade_date = DateFormatUtils.format(calendar, "yyyy-MM-dd");
|
|
|
|
String trade_date = DateFormatUtils.format(calendar, "yyyy-MM-dd");
|
|
|
|
String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss");
|
|
|
|
String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss");
|
|
|
@ -455,31 +460,6 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void sendAppMessage() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// String p12Path = "D:/MbaikeDevCertificates.p12";
|
|
|
|
|
|
|
|
// InputStream keyIns = appleMessageFile.getInputStream();
|
|
|
|
|
|
|
|
// String password = "F1b5*ChJPp73";
|
|
|
|
|
|
|
|
String pushToken = "719e4b7a7ed8b9000188440228437714d9dc67785f1791fae01234dae6a1570c";
|
|
|
|
|
|
|
|
JSONObject order = new JSONObject();
|
|
|
|
|
|
|
|
order.put("clearing_amount", 0.01);
|
|
|
|
|
|
|
|
order.put("client_id", 9);
|
|
|
|
|
|
|
|
order.put("client_moniker", "PINE");
|
|
|
|
|
|
|
|
order.put("order_id", "9201704110348156694986");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
/**设置参数,发送数据**/
|
|
|
|
|
|
|
|
InputStream keyIns = appleMessageFileProduct.getInputStream();
|
|
|
|
|
|
|
|
ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build();
|
|
|
|
|
|
|
|
String payload = APNS.newPayload().alertTitle("到账通知").alertBody("Hello,0.01AUD").badge(1).sound("default").customField("data", order).build();
|
|
|
|
|
|
|
|
service.push(pushToken, payload);
|
|
|
|
|
|
|
|
System.out.println("推送信息已发送!");
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
logger.error("出错了:" + e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void sendOrderAppMessage(final JSONObject order, int client_id) {
|
|
|
|
public void sendOrderAppMessage(final JSONObject order, int client_id) {
|
|
|
|
logger.debug("sendOrderAppMessage-" + client_id + "-" + order.getString("order_id"));
|
|
|
|
logger.debug("sendOrderAppMessage-" + client_id + "-" + order.getString("order_id"));
|
|
|
@ -491,21 +471,32 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.println("Device Token:" + token);
|
|
|
|
System.out.println("Device Token:" + token);
|
|
|
|
//todo 抽象发送信息接口,根据设备类型选择不同实现类
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "payment", token,
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "payment", token, order.getString("order_id"));
|
|
|
|
order.getString("order_id"));
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
order.put("send_type", "payment");
|
|
|
|
order.put("send_type", "payment");
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
type.put("send_type", "payment");
|
|
|
|
type.put("send_type", "payment");
|
|
|
|
type.put("id", order.getString("order_id"));
|
|
|
|
type.put("id", order.getString("order_id"));
|
|
|
|
sendAppleMessage(LocaleSupport.localeMessage("app.message.title.payment"),
|
|
|
|
AppMsgSender sender = senderMap.get(devToken.getString("client_type"));
|
|
|
|
LocaleSupport.localeMessage("app.message.body.payment") + order.getString("currency") + order.getDoubleValue("total_amount"), token, order, type);
|
|
|
|
if (token == null || sender == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject managerMsg = new JSONObject();
|
|
|
|
|
|
|
|
managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.payment"));
|
|
|
|
|
|
|
|
managerMsg.put("body",
|
|
|
|
|
|
|
|
LocaleSupport.localeMessage("app.message.body.payment") + order.getString("currency") + order.getDoubleValue("total_amount"));
|
|
|
|
|
|
|
|
managerMsg.put("type", type);
|
|
|
|
|
|
|
|
managerMsg.put("data", order);
|
|
|
|
|
|
|
|
managerMsg.put("msgType", "payment");
|
|
|
|
|
|
|
|
AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage();
|
|
|
|
|
|
|
|
sender.sendMessage(appMessage, devToken);
|
|
|
|
log.put("status", 2);
|
|
|
|
log.put("status", 2);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.error("出错了:" + e.getMessage());
|
|
|
|
logger.error("出错了:" + e.getMessage());
|
|
|
|
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
|
|
|
|
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
|
|
|
|
throw new ServerErrorException("Send App Message Failed", e);
|
|
|
|
throw new ServerErrorException("Send App "+devToken.getString("client_type")+" Failed", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
sendingAppleMsgPool.execute(task);
|
|
|
|
sendingAppleMsgPool.execute(task);
|
|
|
@ -536,14 +527,26 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.println("Device Token:" + token);
|
|
|
|
System.out.println("Device Token:" + token);
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "refund", token, order.getString("order_id"));
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "refund", token,
|
|
|
|
|
|
|
|
order.getString("order_id"));
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
order.put("send_type", "refund");
|
|
|
|
order.put("send_type", "refund");
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
type.put("send_type", "refund");
|
|
|
|
type.put("send_type", "refund");
|
|
|
|
type.put("id", order.getString("order_id"));
|
|
|
|
type.put("id", order.getString("order_id"));
|
|
|
|
sendAppleMessage("Refund Message",
|
|
|
|
|
|
|
|
LocaleSupport.localeMessage("app.message.body.refund") + refundAmount, token, order, type);
|
|
|
|
AppMsgSender sender = senderMap.get(devToken.getString("client_type"));
|
|
|
|
|
|
|
|
if (token == null || sender == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject managerMsg = new JSONObject();
|
|
|
|
|
|
|
|
managerMsg.put("title", "Refund "+devToken.getString("client_type")+"");
|
|
|
|
|
|
|
|
managerMsg.put("body", LocaleSupport.localeMessage("app.message.body.refund") + refundAmount);
|
|
|
|
|
|
|
|
managerMsg.put("type", type);
|
|
|
|
|
|
|
|
managerMsg.put("data", order);
|
|
|
|
|
|
|
|
managerMsg.put("msgType", "refund");
|
|
|
|
|
|
|
|
AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage();
|
|
|
|
|
|
|
|
sender.sendMessage(appMessage, devToken);
|
|
|
|
log.put("status", 2);
|
|
|
|
log.put("status", 2);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
@ -567,7 +570,8 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
if (token == null) {
|
|
|
|
if (token == null) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "notice", token, "notice_id:" + notice.getNotice_id());
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "notice", token,
|
|
|
|
|
|
|
|
"notice_id:" + notice.getNotice_id());
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
notice.setContent(null);
|
|
|
|
notice.setContent(null);
|
|
|
|
JSONObject noticeObj = notice.toJson();
|
|
|
|
JSONObject noticeObj = notice.toJson();
|
|
|
@ -575,7 +579,19 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
type.put("send_type", "notice");
|
|
|
|
type.put("send_type", "notice");
|
|
|
|
type.put("id", notice.getNotice_id());
|
|
|
|
type.put("id", notice.getNotice_id());
|
|
|
|
sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"), notice.getTitle(), token, noticeObj, type);
|
|
|
|
|
|
|
|
|
|
|
|
AppMsgSender sender = senderMap.get(devToken.getString("client_type"));
|
|
|
|
|
|
|
|
if (token == null || sender == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject managerMsg = new JSONObject();
|
|
|
|
|
|
|
|
managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.notice"));
|
|
|
|
|
|
|
|
managerMsg.put("body", notice.getTitle());
|
|
|
|
|
|
|
|
managerMsg.put("type", type);
|
|
|
|
|
|
|
|
managerMsg.put("data", noticeObj);
|
|
|
|
|
|
|
|
managerMsg.put("msgType", "notice");
|
|
|
|
|
|
|
|
AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage();
|
|
|
|
|
|
|
|
sender.sendMessage(appMessage, devToken);
|
|
|
|
log.put("status", 2);
|
|
|
|
log.put("status", 2);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
@ -600,19 +616,32 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
if (token == null) {
|
|
|
|
if (token == null) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "cashback", token, order.getString("order_id") + "返现" + cashbackAmount);
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "cashback", token,
|
|
|
|
|
|
|
|
order.getString("order_id") + "返现" + cashbackAmount);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
type.put("send_type", "cashback");
|
|
|
|
type.put("send_type", "cashback");
|
|
|
|
type.put("id", order.getString("order_id"));
|
|
|
|
type.put("id", order.getString("order_id"));
|
|
|
|
sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"),
|
|
|
|
|
|
|
|
LocaleSupport.localeMessage("app.message.body.cashback") + PlatformEnvironment.getEnv().getForeignCurrency() + " " + cashbackAmount, token, order, type);
|
|
|
|
AppMsgSender sender = senderMap.get(devToken.getString("client_type"));
|
|
|
|
|
|
|
|
if (token == null || sender == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject managerMsg = new JSONObject();
|
|
|
|
|
|
|
|
managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.notice"));
|
|
|
|
|
|
|
|
managerMsg.put("body", LocaleSupport.localeMessage("app.message.body.cashback") + PlatformEnvironment.getEnv().getForeignCurrency()
|
|
|
|
|
|
|
|
+ " " + cashbackAmount);
|
|
|
|
|
|
|
|
managerMsg.put("type", type);
|
|
|
|
|
|
|
|
managerMsg.put("data", order);
|
|
|
|
|
|
|
|
managerMsg.put("msgType", "cashback");
|
|
|
|
|
|
|
|
AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage();
|
|
|
|
|
|
|
|
sender.sendMessage(appMessage, devToken);
|
|
|
|
log.put("status", 2);
|
|
|
|
log.put("status", 2);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.error("出错了:" + e.getMessage());
|
|
|
|
logger.error("出错了:" + e.getMessage());
|
|
|
|
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
|
|
|
|
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
|
|
|
|
throw new ServerErrorException("Send App Message Failed", e);
|
|
|
|
throw new ServerErrorException("Send App "+devToken.getString("client_type")+" Failed", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -625,7 +654,8 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
String clearing_amount = log_clearing_detail.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_HALF_DOWN).toString();
|
|
|
|
String clearing_amount = log_clearing_detail.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_HALF_DOWN).toString();
|
|
|
|
String settle_date_from = DateFormatUtils.format(log_clearing_detail.getDate("settle_date_from"), "MM/dd/yyyy");
|
|
|
|
String settle_date_from = DateFormatUtils.format(log_clearing_detail.getDate("settle_date_from"), "MM/dd/yyyy");
|
|
|
|
String settle_date_to = DateFormatUtils.format(log_clearing_detail.getDate("settle_date_to"), "MM/dd/yyyy");
|
|
|
|
String settle_date_to = DateFormatUtils.format(log_clearing_detail.getDate("settle_date_to"), "MM/dd/yyyy");
|
|
|
|
logger.debug("sendCleanMessage-" + log_clearing_detail.getString("client_moniker") + "- " + PlatformEnvironment.getEnv().getForeignCurrency() + " " + clearing_amount + "(" + settle_date_from + "-" + settle_date_to + ")");
|
|
|
|
logger.debug("sendCleanMessage-" + log_clearing_detail.getString("client_moniker") + "- " + PlatformEnvironment.getEnv().getForeignCurrency() + " "
|
|
|
|
|
|
|
|
+ clearing_amount + "(" + settle_date_from + "-" + settle_date_to + ")");
|
|
|
|
List<JSONObject> tokens = clientDeviceTokenMapper.listTokensByClient_id(client_id);
|
|
|
|
List<JSONObject> tokens = clientDeviceTokenMapper.listTokensByClient_id(client_id);
|
|
|
|
for (JSONObject devToken : tokens) {
|
|
|
|
for (JSONObject devToken : tokens) {
|
|
|
|
String token = devToken.getString("token");
|
|
|
|
String token = devToken.getString("token");
|
|
|
@ -633,24 +663,36 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String log_clearing_detail_id = log_clearing_detail.getString("clear_detail_id");
|
|
|
|
String log_clearing_detail_id = log_clearing_detail.getString("clear_detail_id");
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "clean", token, "本次清算" + log_clearing_detail_id + ",$" + clearing_amount + "(" + settle_date_from + "-" + settle_date_to + ")");
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "clean", token,
|
|
|
|
|
|
|
|
"本次清算" + log_clearing_detail_id + ",$" + clearing_amount + "(" + settle_date_from + "-" + settle_date_to + ")");
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
type.put("send_type", "clean");
|
|
|
|
type.put("send_type", "clean");
|
|
|
|
type.put("id", log_clearing_detail_id);
|
|
|
|
type.put("id", log_clearing_detail_id);
|
|
|
|
sendAppleMessage(LocaleSupport.localeMessage("app.message.title.clean"),
|
|
|
|
|
|
|
|
LocaleSupport.localeMessage("app.message.body.clean") + PlatformEnvironment.getEnv().getForeignCurrency() + " " + clearing_amount + " (" + settle_date_from + "-" + settle_date_to + ")", token, log_clearing_detail, type);
|
|
|
|
AppMsgSender sender = senderMap.get(devToken.getString("client_type"));
|
|
|
|
|
|
|
|
if (token == null || sender == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject managerMsg = new JSONObject();
|
|
|
|
|
|
|
|
managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.clean"));
|
|
|
|
|
|
|
|
managerMsg.put("body", LocaleSupport.localeMessage("app.message.body.clean") + PlatformEnvironment.getEnv().getForeignCurrency() + " "
|
|
|
|
|
|
|
|
+ clearing_amount + " (" + settle_date_from + "-" + settle_date_to + ")");
|
|
|
|
|
|
|
|
managerMsg.put("type", type);
|
|
|
|
|
|
|
|
managerMsg.put("data", log_clearing_detail);
|
|
|
|
|
|
|
|
managerMsg.put("msgType", "clean");
|
|
|
|
|
|
|
|
AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage();
|
|
|
|
|
|
|
|
sender.sendMessage(appMessage, devToken);
|
|
|
|
log.put("status", 2);
|
|
|
|
log.put("status", 2);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.error("出错了:" + e.getMessage());
|
|
|
|
logger.error("出错了:" + e.getMessage());
|
|
|
|
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
|
|
|
|
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
|
|
|
|
throw new ServerErrorException("Send App Message Failed", e);
|
|
|
|
throw new ServerErrorException("Send App "+devToken.getString("client_type")+" Failed", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void sendTransactionDailyMessage(JSONObject tradeInfo, int client_id) {
|
|
|
|
public void sendTransactionDailyMessage(JSONObject tradeInfo, int client_id) {
|
|
|
|
String trade_date = tradeInfo.getString("trade_date");
|
|
|
|
String trade_date = tradeInfo.getString("trade_date");
|
|
|
@ -663,49 +705,41 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
if (token == null) {
|
|
|
|
if (token == null) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "daily_notice", token, "Trade Date:" + trade_date);
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "daily_notice", token,
|
|
|
|
|
|
|
|
"Trade Date:" + trade_date);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
type.put("send_type", "daily_notice");
|
|
|
|
type.put("send_type", "daily_notice");
|
|
|
|
type.put("id", trade_date);
|
|
|
|
type.put("id", trade_date);
|
|
|
|
sendAppleMessageDetail(LocaleSupport.localeMessage("app.message.title.daily_notice"),
|
|
|
|
apnsMessageHelper.sendAppleMessageDetail(
|
|
|
|
trade_date + ": 总交易额 " + PlatformEnvironment.getEnv().getForeignCurrency() + total_amount + ", 订单数:" + total_orders + ", 付款人数:" + customers, token, tradeInfo, type);
|
|
|
|
LocaleSupport.localeMessage("app.message.title.daily_notice"), trade_date + ": 总交易额 "
|
|
|
|
|
|
|
|
+ PlatformEnvironment.getEnv().getForeignCurrency() + total_amount + ", 订单数:" + total_orders + ", 付款人数:" + customers,
|
|
|
|
|
|
|
|
token, tradeInfo, type);
|
|
|
|
|
|
|
|
AppMsgSender sender = senderMap.get(devToken.getString("client_type"));
|
|
|
|
|
|
|
|
if (token == null || sender == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject managerMsg = new JSONObject();
|
|
|
|
|
|
|
|
managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.daily_notice"));
|
|
|
|
|
|
|
|
managerMsg.put("body", trade_date + ": 总交易额 "
|
|
|
|
|
|
|
|
+ PlatformEnvironment.getEnv().getForeignCurrency() + total_amount + ", 订单数:" + total_orders + ", 付款人数:" + customers);
|
|
|
|
|
|
|
|
managerMsg.put("type", type);
|
|
|
|
|
|
|
|
managerMsg.put("data", tradeInfo);
|
|
|
|
|
|
|
|
managerMsg.put("msgType", "daily_notice");
|
|
|
|
|
|
|
|
AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage();
|
|
|
|
|
|
|
|
sender.sendMessage(appMessage, devToken);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.put("status", 2);
|
|
|
|
log.put("status", 2);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.error("出错了:" + e.getMessage());
|
|
|
|
logger.error("出错了:" + e.getMessage());
|
|
|
|
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
|
|
|
|
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
|
|
|
|
throw new ServerErrorException("Send App Message Failed", e);
|
|
|
|
throw new ServerErrorException("Send App "+devToken.getString("client_type")+" Failed", e);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void sendAppleMessage(String title, String body, String token, JSONObject data, JSONObject type) throws IOException {
|
|
|
|
|
|
|
|
/**设置参数,发送数据**/
|
|
|
|
|
|
|
|
InputStream keyIns = appleMessageFileProduct.getInputStream();
|
|
|
|
|
|
|
|
ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build();
|
|
|
|
|
|
|
|
String payload = APNS.newPayload().alertTitle(title).alertBody(body).badge(1).sound("default").customField("data", data).customField("type", type).build();
|
|
|
|
|
|
|
|
service.push(token, payload);
|
|
|
|
|
|
|
|
System.out.println("推送信息已发送!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 可显示详情
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param title
|
|
|
|
|
|
|
|
* @param body
|
|
|
|
|
|
|
|
* @param token
|
|
|
|
|
|
|
|
* @param data
|
|
|
|
|
|
|
|
* @param type
|
|
|
|
|
|
|
|
* @throws IOException
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void sendAppleMessageDetail(String title, String body, String token, JSONObject data, JSONObject type) throws IOException {
|
|
|
|
|
|
|
|
/**设置参数,发送数据**/
|
|
|
|
|
|
|
|
InputStream keyIns = appleMessageFileProduct.getInputStream();
|
|
|
|
|
|
|
|
ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build();
|
|
|
|
|
|
|
|
String payload = APNS.newPayload().alertTitle(title).alertBody(body).category("myNotificationCategory").badge(1).sound("default").customField("data", data).customField("type", type).build();
|
|
|
|
|
|
|
|
service.push(token, payload);
|
|
|
|
|
|
|
|
System.out.println("推送信息已发送!");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -943,7 +977,6 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
return clientManager.listSubClients(device.getIntValue("client_id"));
|
|
|
|
return clientManager.listSubClients(device.getIntValue("client_id"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JSONObject saveAppMessageLog(String dev_id, int client_id, String messageType, String dev_token, String remark) {
|
|
|
|
private JSONObject saveAppMessageLog(String dev_id, int client_id, String messageType, String dev_token, String remark) {
|
|
|
|
JSONObject log = new JSONObject();
|
|
|
|
JSONObject log = new JSONObject();
|
|
|
|
log.put("dev_id", dev_id);
|
|
|
|
log.put("dev_id", dev_id);
|
|
|
@ -1086,7 +1119,6 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void sendMassageByCode(final JSONObject params) {
|
|
|
|
public void sendMassageByCode(final JSONObject params) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -1103,7 +1135,8 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
sendingAppleMsgPool.execute(new Runnable() {
|
|
|
|
sendingAppleMsgPool.execute(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "dev", token, "Param:partner_code,自定义推送消息");
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "dev", token,
|
|
|
|
|
|
|
|
"Param:partner_code,自定义推送消息");
|
|
|
|
sending(token, params, log);
|
|
|
|
sending(token, params, log);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -1135,19 +1168,30 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void sending(String devToken, JSONObject params, JSONObject log) {
|
|
|
|
public void sending(String devToken, JSONObject params, JSONObject log) {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
sendAppleMessage(params.getString("title"), params.getString("content"), devToken, new JSONObject(), new JSONObject());
|
|
|
|
JSONObject devTokenJson = new JSONObject();
|
|
|
|
|
|
|
|
devTokenJson.put("token", devToken);
|
|
|
|
|
|
|
|
AppMsgSender sender = senderMap.get(params.getString("client_type"));
|
|
|
|
|
|
|
|
if (devToken == null || sender == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject managerMsg = new JSONObject();
|
|
|
|
|
|
|
|
managerMsg.put("title", params.getString("title"));
|
|
|
|
|
|
|
|
managerMsg.put("body", params.getString("content"));
|
|
|
|
|
|
|
|
managerMsg.put("type", new JSONObject());
|
|
|
|
|
|
|
|
managerMsg.put("data", new JSONObject());
|
|
|
|
|
|
|
|
managerMsg.put("msgType", "payment");
|
|
|
|
|
|
|
|
AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage();
|
|
|
|
|
|
|
|
sender.sendMessage(appMessage, devTokenJson);
|
|
|
|
log.put("status", 2);
|
|
|
|
log.put("status", 2);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
appMessageLogMapper.update(log);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.error("出错了:" + e.getMessage());
|
|
|
|
logger.error("出错了:" + e.getMessage());
|
|
|
|
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
|
|
|
|
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
|
|
|
|
throw new ServerErrorException("Send App Message Failed", e);
|
|
|
|
throw new ServerErrorException("Send App "+params.getString("client_type")+" Failed", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject getCoupons(JSONObject device, int page, int limit) {
|
|
|
|
public JSONObject getCoupons(JSONObject device, int page, int limit) {
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
@ -1207,4 +1251,5 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
String regex = "[A-Za-z0-9]{8}";
|
|
|
|
String regex = "[A-Za-z0-9]{8}";
|
|
|
|
return str.matches(regex);
|
|
|
|
return str.matches(regex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|