api for sending message to royalpay apps

master
yixian 6 years ago
parent f9feb9dbca
commit 56f15a2244

@ -5,7 +5,6 @@ import au.com.royalpay.payment.manage.activities.app_index.beans.AppActBean;
import au.com.royalpay.payment.manage.activities.app_index.beans.AppActQueryBean; import au.com.royalpay.payment.manage.activities.app_index.beans.AppActQueryBean;
import au.com.royalpay.payment.manage.activities.app_index.core.AppActService; import au.com.royalpay.payment.manage.activities.app_index.core.AppActService;
import au.com.royalpay.payment.manage.mappers.act.ActAppMapper; import au.com.royalpay.payment.manage.mappers.act.ActAppMapper;
import au.com.royalpay.payment.manage.mappers.log.AppMessageLogMapper; import au.com.royalpay.payment.manage.mappers.log.AppMessageLogMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper; import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper;
import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper; import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper;
@ -20,20 +19,18 @@ import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
@Service @Service
public class AppActServiceImp implements AppActService { public class AppActServiceImp implements AppActService {

@ -0,0 +1,75 @@
package au.com.royalpay.payment.manage.appclient.beans;
import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder;
import au.com.royalpay.payment.manage.pushMessage.bean.AppMessageType;
import au.com.royalpay.payment.tools.device.message.AppMessage;
import au.com.royalpay.payment.tools.env.RequestEnvironment;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import com.alibaba.fastjson.JSONObject;
import java.util.Date;
/**
* Create by davep at 2019-10-23 17:17
*/
public class RetailAppMessage {
private String title;
private String body;
private PartnerRole role = PartnerRole.ADMIN;
public JSONObject forSave(String appid, int clientId) {
JSONObject msg = new JSONObject();
msg.put("appid", appid);
msg.put("client_id", clientId);
msg.put("role", role.getCode());
msg.put("title", title);
msg.put("body", body);
msg.put("send_time", new Date());
msg.put("from_ip", RequestEnvironment.getClientIp());
return msg;
}
public AppMessage initAppMessage(String msgId) {
JSONObject sendType = new JSONObject();
sendType.put("send_type", AppMessageType.MESSAGE.name());
sendType.put("id", msgId);
JSONObject managerMsg = new JSONObject();
managerMsg.put("title", title);
managerMsg.put("body", body);
managerMsg.put("type", sendType);
managerMsg.put("data", new JSONObject());
managerMsg.put("msgType", AppMessageType.MESSAGE.name());
return new AppManagerMessageBuilder(managerMsg).buildMessage();
}
public String getTitle() {
return title;
}
public RetailAppMessage setTitle(String title) {
this.title = title;
return this;
}
public String getBody() {
return body;
}
public RetailAppMessage setBody(String body) {
this.body = body;
return this;
}
public PartnerRole getRole() {
return role;
}
public RetailAppMessage setRole(PartnerRole role) {
this.role = role;
return this;
}
public boolean acceptRole(int roleNumber) {
return role.getCode() <= roleNumber;
}
}

@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.appclient.core;
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
import au.com.royalpay.payment.manage.appclient.beans.AppPaymentConfigBean; import au.com.royalpay.payment.manage.appclient.beans.AppPaymentConfigBean;
import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean; import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean;
import au.com.royalpay.payment.manage.appclient.beans.RetailAppMessage;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo; import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientUpdateInfo; import au.com.royalpay.payment.manage.merchants.beans.ClientUpdateInfo;
import au.com.royalpay.payment.manage.notice.beans.NoticeInfo; import au.com.royalpay.payment.manage.notice.beans.NoticeInfo;
@ -28,7 +29,7 @@ public interface RetailAppService {
JSONObject getClientSettlementLog(JSONObject device, AppQueryBean appQueryBean); JSONObject getClientSettlementLog(JSONObject device, AppQueryBean appQueryBean);
JSONObject getTransactionLogsByClearingDetailId(JSONObject device, int clearing_detail_id, String timezone); JSONObject getTransactionLogsByClearingDetailId(JSONObject device, int clearingDetailId, String timezone);
List<JSONObject> getCustomersAndOrdersInDays(JSONObject device, AppQueryBean appQueryBean); List<JSONObject> getCustomersAndOrdersInDays(JSONObject device, AppQueryBean appQueryBean);
@ -42,31 +43,31 @@ public interface RetailAppService {
void updateDevTokenStatus(String devId, int status); void updateDevTokenStatus(String devId, int status);
void sign_out(JSONObject device); void signOut(JSONObject device);
void sendOrderAppMessage(JSONObject order, int client_id); void sendOrderAppMessage(JSONObject order, int clientId);
void sendRefundAppMessage(String refundAmount, JSONObject order); void sendRefundAppMessage(String refundAmount, JSONObject order);
void sendNoticeMessage(NoticeInfo notice, String[] client_monikers); void sendNoticeMessage(NoticeInfo notice, String[] clientMonikers);
void sendCashbackMessage(String cashback, JSONObject order); void sendCashbackMessage(String cashback, JSONObject order);
void sendCleanMessage(JSONObject log_clearing_detail, int client_id); void sendCleanMessage(JSONObject logClearingDetail, int clientId);
void sendTransactionDailyMessage(JSONObject tradeInfo, int client_id); void sendTransactionDailyMessage(JSONObject tradeInfo, int clientId);
void updateReadStatus(JSONObject device, String noticeId); void updateReadStatus(JSONObject device, String noticeId);
JSONObject getDevTokenByDevId(String dev_id); JSONObject getDevTokenByDevId(String devId);
JSONObject listNotices(JSONObject device, JSONObject params); JSONObject listNotices(JSONObject device, JSONObject params);
JSONObject getNoticeDetailById(JSONObject device, String noticeId); JSONObject getNoticeDetailById(JSONObject device, String noticeId);
List<JSONObject> getLatestNotice(int client_id); List<JSONObject> getLatestNotice(int clientId);
void changeAccountPassword(JSONObject device, ChangePwdBean change, String account_id); void changeAccountPassword(JSONObject device, ChangePwdBean change, String accountId);
JSONObject bankAccountInfo(JSONObject device); JSONObject bankAccountInfo(JSONObject device);
@ -76,11 +77,11 @@ public interface RetailAppService {
JSONObject getClientCurrentRateNewByMoniker(JSONObject device, String clientMoniker); JSONObject getClientCurrentRateNewByMoniker(JSONObject device, String clientMoniker);
JSONObject listDailyTransactions(String dateStr, String timezone, boolean thisDevOnly, JSONObject device,String app_client_ids); JSONObject listDailyTransactions(String dateStr, String timezone, boolean thisDevOnly, JSONObject device, String appClientIds);
JSONObject getActivities(JSONObject device, String activity_page, int page, int limit); JSONObject getActivities(JSONObject device, String activityPage, int page, int limit);
JSONObject getActivityDetail(JSONObject device, String article_id); JSONObject getActivityDetail(JSONObject device, String articleId);
JSONObject getNewVersion(JSONObject device); JSONObject getNewVersion(JSONObject device);
@ -116,9 +117,9 @@ public interface RetailAppService {
JSONObject getCashbackDrawLogs(JSONObject device, AppQueryBean appQueryBean); JSONObject getCashbackDrawLogs(JSONObject device, AppQueryBean appQueryBean);
void drawDeposits(JSONObject device, BigDecimal draw_amount, String client_id); void drawDeposits(JSONObject device, BigDecimal drawAmount, String clientId);
JSONObject getCashbackCleanInfo(JSONObject device,String client_id); JSONObject getCashbackCleanInfo(JSONObject device, String clientId);
void sendMassageByCode(JSONObject params); void sendMassageByCode(JSONObject params);
@ -126,21 +127,21 @@ public interface RetailAppService {
JSONObject getCoupons(JSONObject device, int page, int limit); JSONObject getCoupons(JSONObject device, int page, int limit);
JSONObject getCouponById(JSONObject device, String coupon_log_id); JSONObject getCouponById(JSONObject device, String couponLogId);
void useCoupon(JSONObject device, String coupon_log_id); void useCoupon(JSONObject device, String couponLogId);
JSONObject getAd(); JSONObject getAd();
JSONObject getAdDetail(String article_id); JSONObject getAdDetail(String articleId);
JSONObject getCheckClientInfo(JSONObject device); JSONObject getCheckClientInfo(JSONObject device);
void changeManualSettle(JSONObject device,boolean manual_settle); void changeManualSettle(JSONObject device, boolean manualSettle);
JSONObject getTradeCommonDateNew(JSONObject device, AppQueryBean appQueryBean); JSONObject getTradeCommonDateNew(JSONObject device, AppQueryBean appQueryBean);
JSONObject getQrcode(JSONObject device, QRCodeConfig config,int client_id); JSONObject getQrcode(JSONObject device, QRCodeConfig config, int clientId);
void changeSurchargeEnable(JSONObject device, AppPaymentConfigBean appPaymentConfigBean); void changeSurchargeEnable(JSONObject device, AppPaymentConfigBean appPaymentConfigBean);
@ -150,7 +151,7 @@ public interface RetailAppService {
void getInvoiceFile(JSONObject device, AppQueryBean appQueryBean, HttpServletResponse httpResponse) throws Exception; void getInvoiceFile(JSONObject device, AppQueryBean appQueryBean, HttpServletResponse httpResponse) throws Exception;
Map<String,JSONObject> channelAndDayOfAnalysis(int client_id, String clearingDetailId, String channel, JSONObject device); Map<String, JSONObject> channelAndDayOfAnalysis(int clientId, String clearingDetailId, String channel, JSONObject device);
JSONObject getAuthFiles(JSONObject device); JSONObject getAuthFiles(JSONObject device);
@ -172,15 +173,15 @@ public interface RetailAppService {
JSONObject ctripCheck(JSONObject device); JSONObject ctripCheck(JSONObject device);
JSONObject ctripCouponInfo(JSONObject device,String coupon_id); JSONObject ctripCouponInfo(JSONObject device, String couponId);
JSONObject getCouponCusCouponLog(String client_moniker, AppQueryBean appQueryBean); JSONObject getCouponCusCouponLog(String clientMoniker, AppQueryBean appQueryBean);
void saveCouponAccuessLog(int client_id, String coupon_id, String remark); void saveCouponAccuessLog(int clientId, String couponId, String remark);
JSONObject getStyle(); JSONObject getStyle();
void cancelCouponAccuessLog(String accuess_id, String remark); void cancelCouponAccuessLog(String accuessId, String remark);
void submitMaterial(JSONObject material, JSONObject device); void submitMaterial(JSONObject material, JSONObject device);
@ -225,4 +226,7 @@ public interface RetailAppService {
JSONObject getCustomerInfo(JSONObject device); JSONObject getCustomerInfo(JSONObject device);
boolean isSubPartner(JSONObject device, String clientMoniker); boolean isSubPartner(JSONObject device, String clientMoniker);
JSONObject postAppMessage(JSONObject device, RetailAppMessage message);
} }

@ -12,6 +12,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.time.Duration;
/** /**
* Create by davep at 2019-09-19 12:07 * Create by davep at 2019-09-19 12:07
@ -81,7 +82,7 @@ public class GatewayOAuthRegister implements DeviceRegister {
auth.put("authorize_ip", authObj.getString("authorize_ip")); auth.put("authorize_ip", authObj.getString("authorize_ip"));
auth.put("scope", authObj.getString("scope")); auth.put("scope", authObj.getString("scope"));
auth.put("grant_scene", authObj.getString("grant_scene")); auth.put("grant_scene", authObj.getString("grant_scene"));
redisTemplate.boundValueOps(authDetailCacheKey(authId)).set(auth.toJSONString(), Duration.ofMinutes(10));
return auth; return auth;
} }
return JSON.parseObject(authStr); return JSON.parseObject(authStr);

@ -4,6 +4,7 @@ import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import au.com.royalpay.payment.manage.activities.app_index.core.AppActService; import au.com.royalpay.payment.manage.activities.app_index.core.AppActService;
import au.com.royalpay.payment.manage.activities.monsettledelay.core.ActMonDelaySettleService; import au.com.royalpay.payment.manage.activities.monsettledelay.core.ActMonDelaySettleService;
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
import au.com.royalpay.payment.manage.appclient.beans.RetailAppMessage;
import au.com.royalpay.payment.manage.appclient.beans.AppPaymentConfigBean; import au.com.royalpay.payment.manage.appclient.beans.AppPaymentConfigBean;
import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean; import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean;
import au.com.royalpay.payment.manage.appclient.core.RetailAppService; import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
@ -29,7 +30,6 @@ import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.http.HttpUtils; 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.QRCodeConfig;
import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
@ -219,6 +219,11 @@ public class RetailAppController {
return retailAppService.getClientCurrentRate(device); return retailAppService.getClientCurrentRate(device);
} }
@PostMapping("/app_messages")
public JSONObject postAppMessages(@ModelAttribute(RETAIL_DEVICE) JSONObject device, @RequestBody RetailAppMessage message) {
return retailAppService.postAppMessage(device, message);
}
@GetMapping("/current_rate_new") @GetMapping("/current_rate_new")
public JSONObject getClientCurrentRateNew(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { public JSONObject getClientCurrentRateNew(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return retailAppService.getClientCurrentRateNew(device); return retailAppService.getClientCurrentRateNew(device);
@ -231,7 +236,7 @@ public class RetailAppController {
@PutMapping("/sign_out") @PutMapping("/sign_out")
public void signOut(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { public void signOut(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
retailAppService.sign_out(device); retailAppService.signOut(device);
} }
/* 我的页面end */ /* 我的页面end */

@ -0,0 +1,15 @@
package au.com.royalpay.payment.manage.mappers.client;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
/**
* Create by davep at 2019-10-23 17:28
*/
@AutoMapper(tablename = "log_client_app_messages",pkName = "message_id")
public interface AuthAppMessageMapper {
@AutoSql(type = SqlType.INSERT)
void save(JSONObject msg);
}

@ -0,0 +1,16 @@
package au.com.royalpay.payment.manage.pushMessage.bean;
/**
* Create by davep at 2019-10-23 17:11
*/
public enum AppMessageType {
PAYMENT,
REFUND,
NOTICE,
RISK,
CLEAN,
CASHBACK,
DAILY_NOTICE,
ANNUAL_BILL,
MESSAGE
}

@ -3,29 +3,24 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" > "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper"> <mapper namespace="au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper">
<select id="listTokensByClient_id" resultType="com.alibaba.fastjson.JSONObject"> <select id="listTokensByClient_id" resultType="com.alibaba.fastjson.JSONObject">
SELECT SELECT t.*,
t.*, d.client_type d.client_type,
FROM d.account_id
sys_clients_devices_token t FROM sys_clients_devices_token t
LEFT JOIN sys_clients_devices d ON t.dev_id = d.dev_id LEFT JOIN sys_clients_devices d ON t.dev_id = d.dev_id
WHERE WHERE t.client_id = #{client_id}
t.client_id = #{client_id}
AND t.is_valid = 1 AND t.is_valid = 1
GROUP BY GROUP BY token
token
</select> </select>
<select id="listAllTokensByClient_id" resultType="com.alibaba.fastjson.JSONObject"> <select id="listAllTokensByClient_id" resultType="com.alibaba.fastjson.JSONObject">
SELECT SELECT t.*,
t.*, d.client_type d.client_type
FROM FROM sys_clients_devices_token t
sys_clients_devices_token t
LEFT JOIN sys_clients_devices d ON t.dev_id = d.dev_id LEFT JOIN sys_clients_devices d ON t.dev_id = d.dev_id
WHERE WHERE t.client_id = #{client_id}
t.client_id = #{client_id}
and client_type is not null and client_type is not null
GROUP BY GROUP BY token
token
</select> </select>
<select id="listAllTokens" resultType="com.alibaba.fastjson.JSONObject"> <select id="listAllTokens" resultType="com.alibaba.fastjson.JSONObject">
@ -46,6 +41,9 @@
</select> </select>
<select id="findByDevId" resultType="com.alibaba.fastjson.JSONObject"> <select id="findByDevId" resultType="com.alibaba.fastjson.JSONObject">
SELECT * FROM sys_clients_devices_token where dev_id=#{dev_id} limit 1 SELECT *
FROM sys_clients_devices_token
where dev_id = #{dev_id}
limit 1
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save