diff --git a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java index 90b824470..8c9500a41 100644 --- a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java @@ -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.core.AppActService; 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.system.ClientDeviceTokenMapper; 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.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; - import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import org.springframework.util.Assert; +import javax.annotation.Resource; import java.util.*; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import javax.annotation.Resource; - @Service public class AppActServiceImp implements AppActService { diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/beans/RetailAppMessage.java b/src/main/java/au/com/royalpay/payment/manage/appclient/beans/RetailAppMessage.java new file mode 100644 index 000000000..5b3651f6f --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/beans/RetailAppMessage.java @@ -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; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index 36bb7164d..7f3af63c4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -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.AppPaymentConfigBean; 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.ClientUpdateInfo; import au.com.royalpay.payment.manage.notice.beans.NoticeInfo; @@ -28,7 +29,7 @@ public interface RetailAppService { 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 getCustomersAndOrdersInDays(JSONObject device, AppQueryBean appQueryBean); @@ -42,31 +43,31 @@ public interface RetailAppService { 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 sendNoticeMessage(NoticeInfo notice, String[] client_monikers); + void sendNoticeMessage(NoticeInfo notice, String[] clientMonikers); 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); - JSONObject getDevTokenByDevId(String dev_id); + JSONObject getDevTokenByDevId(String devId); JSONObject listNotices(JSONObject device, JSONObject params); JSONObject getNoticeDetailById(JSONObject device, String noticeId); - List getLatestNotice(int client_id); + List getLatestNotice(int clientId); - void changeAccountPassword(JSONObject device, ChangePwdBean change, String account_id); + void changeAccountPassword(JSONObject device, ChangePwdBean change, String accountId); JSONObject bankAccountInfo(JSONObject device); @@ -76,11 +77,11 @@ public interface RetailAppService { 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); @@ -116,9 +117,9 @@ public interface RetailAppService { 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); @@ -126,21 +127,21 @@ public interface RetailAppService { 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 getAdDetail(String article_id); + JSONObject getAdDetail(String articleId); JSONObject getCheckClientInfo(JSONObject device); - void changeManualSettle(JSONObject device,boolean manual_settle); + void changeManualSettle(JSONObject device, boolean manualSettle); 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); @@ -150,13 +151,13 @@ public interface RetailAppService { void getInvoiceFile(JSONObject device, AppQueryBean appQueryBean, HttpServletResponse httpResponse) throws Exception; - Map channelAndDayOfAnalysis(int client_id, String clearingDetailId, String channel, JSONObject device); + Map channelAndDayOfAnalysis(int clientId, String clearingDetailId, String channel, JSONObject device); JSONObject getAuthFiles(JSONObject device); JSONObject getAuthFilesByMoniker(JSONObject device, String clientMoniker); - void uploadAuthFiles(JSONObject device,ClientAuthFilesInfo clientAuthFilesInfo); + void uploadAuthFiles(JSONObject device, ClientAuthFilesInfo clientAuthFilesInfo); void updateMerchantInfo(JSONObject device, ClientUpdateInfo clientUpdateInfo); @@ -166,31 +167,31 @@ public interface RetailAppService { JSONObject openimCheck(JSONObject device); - void addUnreadMsg(JSONObject device,JSONObject param); + void addUnreadMsg(JSONObject device, JSONObject param); JSONObject getRefunds(JSONObject device, AppQueryBean appQueryBean); 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(); - void cancelCouponAccuessLog(String accuess_id, String remark); + void cancelCouponAccuessLog(String accuessId, String remark); void submitMaterial(JSONObject material, JSONObject device); - void bindAccountEmail(JSONObject device,JSONObject email); + void bindAccountEmail(JSONObject device, JSONObject email); - void updateAccountEmail(JSONObject device,JSONObject codekey); + void updateAccountEmail(JSONObject device, JSONObject codekey); - void bindAccountPhone(JSONObject device,JSONObject phone); + void bindAccountPhone(JSONObject device, JSONObject phone); - void updateAccountPhone(JSONObject device,JSONObject codekey); + void updateAccountPhone(JSONObject device, JSONObject codekey); /** * 退款密码 @@ -218,11 +219,14 @@ public interface RetailAppService { void deleteGreenChannelAuthFiles(JSONObject device, String filesInfo); - void commitAuthFilesToCompliance(JSONObject device,JSONObject photoInfo); + void commitAuthFilesToCompliance(JSONObject device, JSONObject photoInfo); JSONObject getClientSubManage(JSONObject device); JSONObject getCustomerInfo(JSONObject device); boolean isSubPartner(JSONObject device, String clientMoniker); + + JSONObject postAppMessage(JSONObject device, RetailAppMessage message); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index 5da78d153..ec4f065be 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -8,11 +8,14 @@ import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper 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.AppQueryBean; +import au.com.royalpay.payment.manage.appclient.beans.RetailAppMessage; import au.com.royalpay.payment.manage.appclient.core.RetailAppService; +import au.com.royalpay.payment.manage.appclient.extend.GatewayOAuthRegister; import au.com.royalpay.payment.manage.cashback.core.CashbackService; import au.com.royalpay.payment.manage.customers.core.CouponValidateService; import au.com.royalpay.payment.manage.fund.core.impls.XPlanFundConfigServiceImpl; import au.com.royalpay.payment.manage.management.clearing.core.CleanService; +import au.com.royalpay.payment.manage.mappers.client.AuthAppMessageMapper; import au.com.royalpay.payment.manage.mappers.log.*; import au.com.royalpay.payment.manage.mappers.notice.NoticePartnerMapper; import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; @@ -31,6 +34,7 @@ import au.com.royalpay.payment.manage.notice.core.NoticePartner; import au.com.royalpay.payment.manage.openim.core.CustomerServiceService; import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper; import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder; +import au.com.royalpay.payment.manage.pushMessage.bean.AppMessageType; import au.com.royalpay.payment.manage.riskbusiness.core.RiskBusinessService; import au.com.royalpay.payment.manage.riskbusiness.core.RiskProcessLogService; import au.com.royalpay.payment.manage.riskbusiness.core.RiskUploadService; @@ -73,7 +77,6 @@ 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.joda.time.DateTime; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.slf4j.LoggerFactory; @@ -199,6 +202,8 @@ public class RetailAppServiceImp implements RetailAppService { @Resource private SysClientLegalPersonMapper sysClientLegalPersonMapper; @Resource + private AuthAppMessageMapper authAppMessageMapper; + @Resource private StringRedisTemplate stringRedisTemplate; private final String CBBANK_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/08/05/1564972204689_uwZvpTBjtLUMcN8c540xcZvux1Rd3O.pdf"; private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/10/22/1571723034726_5xK6A0FGv5aQPbMIDJzXJrUPKHFutv.pdf"; @@ -227,10 +232,10 @@ public class RetailAppServiceImp implements RetailAppService { if (params.containsKey("client_ids")) { return; } - JSONArray client_ids = clientManager.getAllClientIds(clientId); - if (client_ids.size() > 1) { - String[] arr = new String[client_ids.size()]; - params.put("client_ids", client_ids.toArray(arr)); + JSONArray clientIds = clientManager.getAllClientIds(clientId); + if (clientIds.size() > 1) { + String[] arr = new String[clientIds.size()]; + params.put("client_ids", clientIds.toArray(arr)); } } @@ -238,15 +243,15 @@ public class RetailAppServiceImp implements RetailAppService { public JSONObject getTransactionCommonData(JSONObject device, AppQueryBean appQueryBean) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id"); - JSONObject client = clientManager.getClientInfo(client_id); + int clientId = device.getIntValue("client_id"); + JSONObject client = clientManager.getClientInfo(clientId); String timezone = client.getString("timezone"); if (timezone != null && !timezone.isEmpty()) { appQueryBean.setTimezone(timezone); } JSONObject params = appQueryBean.toParams(); - setAllClientIds(params, client_id); - params.put("client_id", client_id); + setAllClientIds(params, clientId); + params.put("client_id", clientId); JSONObject res = transactionAnalysisMapper.getClientTransaction(params); // res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); // res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); @@ -255,8 +260,8 @@ public class RetailAppServiceImp implements RetailAppService { res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params)); // 微信小程序不查询汇率 if (!StringUtils.equals(device.getString("client_type"), "wxapp")) { - res.put("rate", paymentApi.channelApi("Wechat").queryExchangeRateDecimal(client_id)); - res.put("alipay_rate", paymentApi.channelApi("Alipay").queryExchangeRateDecimal(client_id)); + res.put("rate", paymentApi.channelApi("Wechat").queryExchangeRateDecimal(clientId)); + res.put("alipay_rate", paymentApi.channelApi("Alipay").queryExchangeRateDecimal(clientId)); } return res; } @@ -275,9 +280,7 @@ public class RetailAppServiceImp implements RetailAppService { setAllClientIds(params, client_id); params.put("client_id", client_id); List res = transactionAnalysisMapper.getWeekClientTransaction(params); - res.forEach(r -> { - r.put("date", r.getDate("date").toString()); - }); + res.forEach(r -> r.put("date", r.getDate("date").toString())); res.remove(res.size() - 1); return res; } @@ -286,15 +289,15 @@ public class RetailAppServiceImp implements RetailAppService { public JSONObject getTradeCommonDate(JSONObject device, AppQueryBean appQueryBean) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id"); - JSONObject client = clientManager.getClientInfo(client_id); + int clientId = device.getIntValue("client_id"); + JSONObject client = clientManager.getClientInfo(clientId); String timezone = client.getString("timezone"); if (timezone != null && !timezone.isEmpty()) { appQueryBean.setTimezone(timezone); } JSONObject params = appQueryBean.toParams(); - setAllClientIds(params, client_id); - params.put("client_id", client_id); + setAllClientIds(params, clientId); + params.put("client_id", clientId); JSONObject res = transactionAnalysisMapper.getClientTransaction(params); // res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); // res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); @@ -306,22 +309,21 @@ public class RetailAppServiceImp implements RetailAppService { public JSONObject getTradeCommonDateNew(JSONObject device, AppQueryBean appQueryBean) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id"); - JSONObject client = clientManager.getClientInfo(client_id); + int clientId = device.getIntValue("client_id"); + JSONObject client = clientManager.getClientInfo(clientId); String timezone = client.getString("timezone"); if (timezone != null && !timezone.isEmpty()) { appQueryBean.setTimezone(timezone); } JSONObject params = appQueryBean.toParams(); - setAllClientIds(params, client_id); - params.put("client_id", client_id); - JSONObject res = transactionMapper.analysisTransFlow(params); - return res; + setAllClientIds(params, clientId); + params.put("client_id", clientId); + return transactionMapper.analysisTransFlow(params); } @Override - public JSONObject getQrcode(JSONObject device, QRCodeConfig config, int client_id) { - JSONObject client = merchantInfoProvider.getClientInfo(client_id); + public JSONObject getQrcode(JSONObject device, QRCodeConfig config, int clientId) { + JSONObject client = merchantInfoProvider.getClientInfo(clientId); String url = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/payment/partners/" + client.getString("client_moniker")); if (config.isCNY()) { url += "_CNY"; @@ -412,17 +414,17 @@ public class RetailAppServiceImp implements RetailAppService { public JSONObject getInvoiceData(JSONObject device, AppQueryBean appQueryBean) throws Exception { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id"); - JSONObject client = clientManager.getClientInfo(client_id); + int clientId = device.getIntValue("client_id"); + JSONObject client = clientManager.getClientInfo(clientId); String timezone = client.getString("timezone"); appQueryBean.setTimezone(timezone); JSONObject params = appQueryBean.toParams(); - setAllClientIds(params, client_id); - clientManager.validateClients(client_id, params); - params.put("client_id", client_id); + setAllClientIds(params, clientId); + clientManager.validateClients(clientId, params); + params.put("client_id", clientId); JSONObject analysis = transactionMapper.analysisTransFlow(params); - BigDecimal total_surcharge = analysis.getBigDecimal("total_surcharge").add(analysis.getBigDecimal("tax_amount")); - analysis.put("total_surcharge", total_surcharge); + BigDecimal totalSurcharge = analysis.getBigDecimal("total_surcharge").add(analysis.getBigDecimal("tax_amount")); + analysis.put("total_surcharge", totalSurcharge); return analysis; } @@ -430,13 +432,13 @@ public class RetailAppServiceImp implements RetailAppService { public void getInvoiceFile(JSONObject device, AppQueryBean appQueryBean, HttpServletResponse httpResponse) throws Exception { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id"); + int clientId = device.getIntValue("client_id"); TradeLogQuery tradeLogQuery = new TradeLogQuery(); tradeLogQuery.setDatefrom(appQueryBean.getBegin()); tradeLogQuery.setDateto(appQueryBean.getEnd()); tradeLogQuery.setClearing_status(appQueryBean.getClearing_status()); if (appQueryBean.getApp_client_ids() == null) { - appQueryBean.setApp_client_ids(String.valueOf(client_id)); + appQueryBean.setApp_client_ids(String.valueOf(clientId)); } tradeLogQuery.setClient_ids(appQueryBean.getApp_client_ids().split(",")); JSONObject client = clientManager.getClientInfo(Integer.parseInt(tradeLogQuery.getClient_ids()[0])); @@ -449,10 +451,10 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public Map channelAndDayOfAnalysis(int client_id, String clearingDetailId, String channel, JSONObject device) { + public Map channelAndDayOfAnalysis(int clientId, String clearingDetailId, String channel, JSONObject device) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - return cleanService.channelAndDayOfAnalysis(client_id, clearingDetailId, channel, device.getJSONObject("client")); + return cleanService.channelAndDayOfAnalysis(clientId, clearingDetailId, channel, device.getJSONObject("client")); } @Override @@ -563,15 +565,15 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public JSONObject ctripCouponInfo(JSONObject device, String coupon_id) { - return couponVerificationService.ctripCouponInfo(coupon_id, device.getIntValue("client_id"), true); + public JSONObject ctripCouponInfo(JSONObject device, String couponId) { + return couponVerificationService.ctripCouponInfo(couponId, device.getIntValue("client_id"), true); } @Override - public JSONObject getCouponCusCouponLog(String client_moniker, AppQueryBean appQueryBean) { + public JSONObject getCouponCusCouponLog(String clientMoniker, AppQueryBean appQueryBean) { String keyword = "CTRIP_"; - JSONObject client = clientMapper.findClientByMoniker(client_moniker); + JSONObject client = clientMapper.findClientByMoniker(clientMoniker); if (client == null) { throw new BadRequestException("Partner not exists"); } @@ -579,7 +581,7 @@ public class RetailAppServiceImp implements RetailAppService { client.getIntValue("client_id"), keyword, new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit(), Order.formString("creation_date.desc"))); HashMap couponMap = new HashMap<>(); for (JSONObject cusCouponLog : cusCouponLogs) { - cusCouponLog.put("client_moniker", client_moniker); + cusCouponLog.put("client_moniker", clientMoniker); if (couponMap.containsKey(cusCouponLog.getString("coupon_id"))) { cusCouponLog.put("coupon", couponMap.get(cusCouponLog.getString("coupon_id"))); continue; @@ -592,16 +594,16 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public void saveCouponAccuessLog(int client_id, String coupon_id, String remark) { - JSONObject client = clientMapper.findClient(client_id); + public void saveCouponAccuessLog(int clientId, String couponId, String remark) { + JSONObject client = clientMapper.findClient(clientId); if (client == null) { throw new BadRequestException("Partner not exists"); } JSONObject couponAccuessLog = new JSONObject(); Date date = new Date(); - couponAccuessLog.put("client_id", client_id); + couponAccuessLog.put("client_id", clientId); couponAccuessLog.put("order_id", "NON_PLATFORM_ORDER"); - couponAccuessLog.put("coupon_id", "CTRIP_" + coupon_id); + couponAccuessLog.put("coupon_id", "CTRIP_" + couponId); couponAccuessLog.put("customer_openid", "NON_PLATFORM_ORDER"); couponAccuessLog.put("coupon_deal_amount", 0); couponAccuessLog.put("currency", "AUD"); @@ -618,9 +620,9 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public void cancelCouponAccuessLog(String accuess_id, String remark) { + public void cancelCouponAccuessLog(String accuessId, String remark) { JSONObject couponAccuessLog = new JSONObject(); - couponAccuessLog.put("accuess_id", accuess_id); + couponAccuessLog.put("accuess_id", accuessId); couponAccuessLog.put("is_valid", 0); couponAccuessLog.put("last_update_date", new Date()); if (StringUtils.isNotEmpty(remark)) { @@ -798,33 +800,31 @@ public class RetailAppServiceImp implements RetailAppService { new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit(), Order.formString("report_date.desc"))); logs.forEach(log -> log.put("total_charge", log.getBigDecimal("total_charge").add(log.getBigDecimal("tax_amount")))); JSONObject result = PageListUtils.buildPageListResult(logs); - if (appQueryBean.getPage() == 1) { - if (!logs.isEmpty() && logs.size() > 0) { - JSONObject clearingLog = clearingLogMapper.findById(logs.get(0).getIntValue("clearing_id")); - if (clearingLog.getBoolean("editable")) { - result.put("padding", true); - logs.get(0).put("padding", true); - } + if (appQueryBean.getPage() == 1 && !logs.isEmpty()) { + JSONObject clearingLog = clearingLogMapper.findById(logs.get(0).getIntValue("clearing_id")); + if (clearingLog.getBooleanValue("editable")) { + result.put("padding", true); + logs.get(0).put("padding", true); } } return result; } @Override - public JSONObject getTransactionLogsByClearingDetailId(JSONObject device, int clearing_detail_id, String timezone) { + public JSONObject getTransactionLogsByClearingDetailId(JSONObject device, int clearingDetailId, String timezone) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id"); - JSONObject client = clientManager.getClientInfo(client_id); - String timezone_client = client.getString("timezone"); - if (timezone_client != null && !timezone.isEmpty()) { - timezone = timezone_client; + int clientId = device.getIntValue("client_id"); + JSONObject client = clientManager.getClientInfo(clientId); + String timezoneClient = client.getString("timezone"); + if (timezoneClient != null && !timezone.isEmpty()) { + timezone = timezoneClient; } - List transactions = transactionMapper.listTransactionsOfClearingOrder(clearing_detail_id, new PageBounds(Order.formString("order_id.asc"))); + List transactions = transactionMapper.listTransactionsOfClearingOrder(clearingDetailId, new PageBounds(Order.formString("order_id.asc"))); if (timezone != null) { TimeZoneUtils.switchTimeZone(transactions, timezone, "transaction_time"); } - List channels = clearingDetailAnalysisMapper.listReportChannels(String.valueOf(clearing_detail_id)); + List channels = clearingDetailAnalysisMapper.listReportChannels(String.valueOf(clearingDetailId)); JSONObject channelsObj = new JSONObject(); for (JSONObject channel : channels) { channel.put("total_charge", channel.getBigDecimal("total_charge").add(channel.getBigDecimal("tax_amount"))); @@ -833,8 +833,8 @@ public class RetailAppServiceImp implements RetailAppService { List credit = new ArrayList<>(); List debit = new ArrayList<>(); for (JSONObject transaction : transactions) { - String clearing_amount = transaction.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString(); - transaction.put("clearing_amount", clearing_amount); + String clearingAmount = transaction.getBigDecimal("clearing_amount").setScale(2, RoundingMode.DOWN).toPlainString(); + transaction.put("clearing_amount", clearingAmount); if (transaction.getString("transaction_type").equals("Credit")) { credit.add(transaction); } else { @@ -869,45 +869,45 @@ public class RetailAppServiceImp implements RetailAppService { public JSONObject listOrders(JSONObject device, AppQueryBean query) { String clientType = device.getString("client_type"); DeviceRegister register = deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id"); - JSONObject client = clientManager.getClientInfo(client_id); + int clientId = device.getIntValue("client_id"); + JSONObject client = clientManager.getClientInfo(clientId); String timezone = client.getString("timezone"); if (timezone != null && !timezone.isEmpty()) { query.setTimezone(timezone); } JSONObject params = query.toParams(); - setAllClientIds(params, client_id); + setAllClientIds(params, clientId); if (register.includeDevId()) { params.put("dev_id", device.getString("dev_id")); } - params.put("client_id", client_id); + params.put("client_id", clientId); PageList 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"); - ArrayList date_contains = new ArrayList<>(); + ArrayList dateContains = new ArrayList<>(); 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"); Calendar calendar = (Calendar) order.get("create_time"); - String trade_date = DateFormatUtils.format(calendar, "yyyy-MM-dd"); - String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss"); - order.put("trade_date", trade_date); - order.put("trade_time", trade_time); - if (!date_contains.contains(trade_date)) { - String re_date = trade_date.replaceAll("-", ""); - TradeLogQuery date_query = new TradeLogQuery(); - date_query.setDatefrom(re_date); - date_query.setDateto(re_date); + String tradeDate = DateFormatUtils.format(calendar, "yyyy-MM-dd"); + String tradeTime = DateFormatUtils.format(calendar, "HH:mm:ss"); + order.put("trade_date", tradeDate); + order.put("trade_time", tradeTime); + if (!dateContains.contains(tradeDate)) { + String reDate = tradeDate.replace("-", ""); + TradeLogQuery dateQuery = new TradeLogQuery(); + dateQuery.setDatefrom(reDate); + dateQuery.setDateto(reDate); // date_query.setStatus(OrderStatus.ALL); if (params.containsKey("client_ids")) { - date_query.setClient_ids((String[]) params.get("client_ids")); + dateQuery.setClient_ids((String[]) params.get("client_ids")); } - JSONObject date_params = date_query.toParams(query.getTimezone()); - date_params.put("client_id", device.getIntValue("client_id")); - JSONObject analysis = orderMapper.analysisOrders(date_params); + JSONObject dateParams = dateQuery.toParams(query.getTimezone()); + dateParams.put("client_id", device.getIntValue("client_id")); + JSONObject analysis = orderMapper.analysisOrders(dateParams); order.put("date_total", analysis); - date_contains.add(trade_date); + dateContains.add(tradeDate); } } return PageListUtils.buildPageListResult(orders); @@ -917,32 +917,32 @@ public class RetailAppServiceImp implements RetailAppService { public JSONObject listOrdersNew(JSONObject device, AppQueryBean query) { String clientType = device.getString("client_type"); DeviceRegister register = deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id"); - JSONObject client = clientManager.getClientInfo(client_id); + int clientId = device.getIntValue("client_id"); + JSONObject client = clientManager.getClientInfo(clientId); String timezone = client.getString("timezone"); if (timezone != null && !timezone.isEmpty()) { query.setTimezone(timezone); } JSONObject params = query.toParams(); - setAllClientIds(params, client_id); + setAllClientIds(params, clientId); if (register.includeDevId()) { params.put("dev_id", device.getString("dev_id")); } - params.put("client_id", client_id); - params.put("after_limit", (query.getPage()-1)*query.getLimit()); + params.put("client_id", clientId); + params.put("after_limit", (query.getPage() - 1) * query.getLimit()); params.put("limit", query.getLimit()); List orders = orderMapper.listTransactionsForApp(params); TimeZoneUtils.switchTimeZone(orders, query.getTimezone(), "create_time", "transaction_time", "confirm_time"); - ArrayList date_contains = new ArrayList<>(); + ArrayList dateContains = new ArrayList<>(); for (JSONObject order : orders) { Calendar calendar = (Calendar) order.get("transaction_time"); if (timezone != null) { calendar.setTimeZone(TimeZone.getTimeZone(timezone)); } - String trade_date = DateFormatUtils.format(calendar, "yyyy-MM-dd", calendar.getTimeZone()); - String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss", calendar.getTimeZone()); - order.put("trade_date", trade_date); - order.put("trade_time", trade_time); + String tradeDate = DateFormatUtils.format(calendar, "yyyy-MM-dd", calendar.getTimeZone()); + String tradeTime = DateFormatUtils.format(calendar, "HH:mm:ss", calendar.getTimeZone()); + order.put("trade_date", tradeDate); + order.put("trade_time", tradeTime); // todo if ("Debit".equals(order.getString("transaction_type"))) { order.put("currency", "AUD"); @@ -950,44 +950,44 @@ public class RetailAppServiceImp implements RetailAppService { if ("CNY".equals(order.getString("currency"))) { order.put("clearing_amount", order.getBigDecimal("total_amount")); } - if (!date_contains.contains(trade_date)) { - String re_date = trade_date.replaceAll("-", ""); - AppQueryBean date_query = new AppQueryBean(); - date_query.setBegin(re_date); - date_query.setEnd(re_date); + if (!dateContains.contains(tradeDate)) { + String reDate = tradeDate.replace("-", ""); + AppQueryBean dateQuery = new AppQueryBean(); + dateQuery.setBegin(reDate); + dateQuery.setEnd(reDate); if (timezone != null && !timezone.isEmpty()) { query.setTimezone(timezone); } // date_query.setStatus(OrderStatus.ALL); if (params.containsKey("client_ids")) { - date_query.setClient_ids((String[]) params.get("client_ids")); + dateQuery.setClient_ids((String[]) params.get("client_ids")); } - JSONObject date_params = date_query.toParams(); - date_params.put("begin", date_params.getDate("from")); - date_params.put("end", date_params.getDate("to")); - date_params.put("client_id", device.getIntValue("client_id")); - JSONObject analysis = transactionAnalysisMapper.getClientTransaction(date_params); + JSONObject dateParams = dateQuery.toParams(); + dateParams.put("begin", dateParams.getDate("from")); + dateParams.put("end", dateParams.getDate("to")); + dateParams.put("client_id", device.getIntValue("client_id")); + JSONObject analysis = transactionAnalysisMapper.getClientTransaction(dateParams); order.put("date_total", analysis); - date_contains.add(trade_date); + dateContains.add(tradeDate); } - String customer_id = order.getString("customer_id"); - if (StringUtils.isEmpty(customer_id)) { + String customerId = order.getString("customer_id"); + if (StringUtils.isEmpty(customerId)) { continue; } switch (order.getString("channel")) { case "Alipay": - JSONObject alipayUser = managerCustomerRelationAlipayMapper.findCustomerByUserId(customer_id); + JSONObject alipayUser = managerCustomerRelationAlipayMapper.findCustomerByUserId(customerId); if (alipayUser != null) { order.put("nickname", alipayUser.getString("nickname")); order.put("headimg", alipayUser.getString("headimg")); } break; case "Wechat": - JSONObject weUser = new JSONObject(); - if (customer_id.startsWith("olH")) { - weUser = customerMapper.findCustomerGlobalpayByOpenId(customer_id); + JSONObject weUser; + if (customerId.startsWith("olH")) { + weUser = customerMapper.findCustomerGlobalpayByOpenId(customerId); } else { - weUser = customerMapper.findCustomerByOpenId(customer_id); + weUser = customerMapper.findCustomerByOpenId(customerId); } if (weUser != null && !weUser.isEmpty()) { order.put("nickname", weUser.getString("nickname")); @@ -1009,39 +1009,39 @@ public class RetailAppServiceImp implements RetailAppService { String clientType = device.getString("client_type"); DeviceRegister register = deviceSupport.findRegister(clientType); Assert.notNull(register, "Device is not registered"); - int client_id = device.getIntValue("client_id"); - JSONObject client = clientManager.getClientInfo(client_id); + int clientId = device.getIntValue("client_id"); + JSONObject client = clientManager.getClientInfo(clientId); String timezone = client.getString("timezone"); if (timezone != null && !timezone.isEmpty()) { query.setTimezone(timezone); } JSONObject params = query.toParams(); - setAllClientIds(params, client_id); + setAllClientIds(params, clientId); if (register.includeDevId()) { params.put("dev_id", device.getString("dev_id")); } - params.put("client_id", client_id); + params.put("client_id", clientId); PageList 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"); for (JSONObject order : orders) { Calendar calendar = (Calendar) order.get("create_time"); - String trade_date = DateFormatUtils.format(calendar, "yyyy-MM-dd"); - String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss"); - order.put("trade_date", trade_date); - order.put("trade_time", trade_time); - String customer_id = order.getString("customer_id"); - if (StringUtils.isEmpty(customer_id)) { + String tradeDate = DateFormatUtils.format(calendar, "yyyy-MM-dd"); + String tradeTime = DateFormatUtils.format(calendar, "HH:mm:ss"); + order.put("trade_date", tradeDate); + order.put("trade_time", tradeTime); + String customerId = order.getString("customer_id"); + if (StringUtils.isEmpty(customerId)) { continue; } switch (order.getString("channel")) { case "Alipay": - JSONObject alipayUser = managerCustomerRelationAlipayMapper.findCustomerByUserId(customer_id); + JSONObject alipayUser = managerCustomerRelationAlipayMapper.findCustomerByUserId(customerId); order.put("nickname", alipayUser.getString("nickname")); order.put("headimg", alipayUser.getString("headimg")); break; case "Wechat": - JSONObject weUser = customerMapper.findCustomerByOpenId(customer_id); + JSONObject weUser = customerMapper.findCustomerByOpenId(customerId); order.put("nickname", weUser.getString("nickname")); order.put("headimg", weUser.getString("headimg")); break; @@ -1068,7 +1068,7 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public void sign_out(JSONObject device) { + public void signOut(JSONObject device) { String clientType = device.getString("client_type"); DeviceRegister register = deviceSupport.findRegister(clientType); register.signout(device); @@ -1076,16 +1076,16 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public void sendOrderAppMessage(final JSONObject order, int client_id) { - logger.debug("sendOrderAppMessage-" + client_id + "-" + order.getString("order_id")); - List tokens = clientDeviceTokenMapper.listTokensByClient_id(client_id); + public void sendOrderAppMessage(final JSONObject order, int clientId) { + logger.debug("sendOrderAppMessage-{}-{}", clientId, order.getString("order_id")); + List tokens = clientDeviceTokenMapper.listTokensByClient_id(clientId); for (final JSONObject devToken : tokens) { Runnable task = () -> { String token = devToken.getString("token"); if (token == null) { return; } - System.out.println("Device Token:" + token); + logger.info("Device Token:{}", token); JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "payment", token, order.getString("order_id")); try { @@ -1094,7 +1094,7 @@ public class RetailAppServiceImp implements RetailAppService { type.put("send_type", "payment"); type.put("id", order.getString("order_id")); AppMsgSender sender = senderMap.get(devToken.getString("client_type")); - if (token == null || sender == null) { + if (sender == null) { return; } JSONObject managerMsg = new JSONObject(); @@ -1109,7 +1109,7 @@ public class RetailAppServiceImp implements RetailAppService { log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { - logger.error("出错了:" + e.getMessage()); + logger.error("出错了:{}", e.getMessage(), e); appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); throw new ServerErrorException("Send App " + devToken.getString("client_type") + " Failed", e); } @@ -1121,7 +1121,7 @@ public class RetailAppServiceImp implements RetailAppService { @Override public void sendRefundAppMessage(String refundAmount, JSONObject order) { - logger.debug("sendRefundAppMessage-" + order.getIntValue("client_id") + "-" + order.getString("order_id")); + logger.debug("sendRefundAppMessage-{}-{}", order.getIntValue("client_id"), order.getString("order_id")); int clientId = order.getIntValue("client_id"); refundMessage(refundAmount, order, clientId); JSONObject client = clientManager.getClientInfo(clientId); @@ -1134,14 +1134,14 @@ public class RetailAppServiceImp implements RetailAppService { private void refundMessage(final String refundAmount, final JSONObject order, int clientId) { List tokens = clientDeviceTokenMapper.listTokensByClient_id(clientId); - if (tokens != null && tokens.size() > 0) { + if (!tokens.isEmpty()) { for (final JSONObject devToken : tokens) { sendingAppleMsgPool.execute(() -> { String token = devToken.getString("token"); if (token == null) { return; } - System.out.println("Device Token:" + token); + logger.info("Device Token:{}", token); JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "refund", token, order.getString("order_id")); try { @@ -1151,7 +1151,7 @@ public class RetailAppServiceImp implements RetailAppService { type.put("id", order.getString("order_id")); AppMsgSender sender = senderMap.get(devToken.getString("client_type")); - if (token == null || sender == null) { + if (sender == null) { return; } JSONObject managerMsg = new JSONObject(); @@ -1165,7 +1165,7 @@ public class RetailAppServiceImp implements RetailAppService { log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { - logger.error("出错了:" + e.getMessage()); + logger.error("出错了:{}", e.getMessage(), e); appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); } }); @@ -1174,15 +1174,15 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public void sendNoticeMessage(final NoticeInfo notice, final String[] client_monikers) { - for (String clientMoniker : client_monikers) { + public void sendNoticeMessage(final NoticeInfo notice, final String[] clientMonikers) { + for (String clientMoniker : clientMonikers) { JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker); if (client == null) { continue; } sendingAppleMsgPool.execute(() -> { List tokens = clientDeviceTokenMapper.listAllTokensByClient_id(client.getIntValue("client_id")); - if (tokens != null && tokens.size() > 0) { + if (!tokens.isEmpty()) { for (JSONObject devToken : tokens) { String token = devToken.getString("token"); if (token == null) { @@ -1199,7 +1199,7 @@ public class RetailAppServiceImp implements RetailAppService { type.put("id", notice.getNotice_id()); AppMsgSender sender = senderMap.get(devToken.getString("client_type")); - if (token == null || sender == null) { + if (sender == null) { return; } JSONObject managerMsg = new JSONObject(); @@ -1213,7 +1213,7 @@ public class RetailAppServiceImp implements RetailAppService { log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { - System.out.println("出错了:" + e.getMessage()); + logger.error("出错了:", e); appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); } } @@ -1224,43 +1224,40 @@ public class RetailAppServiceImp implements RetailAppService { @Override public void sendCashbackMessage(final String cashbackAmount, final JSONObject order) { - logger.debug("sendCashbackMessage-" + cashbackAmount + "-" + order.getString("order_id")); + logger.debug("sendCashbackMessage-{}-{}", cashbackAmount, order.getString("order_id")); List tokens = clientDeviceTokenMapper.listTokensByClient_id(order.getIntValue("client_id")); for (final JSONObject devToken : tokens) { - sendingAppleMsgPool.execute(new Runnable() { - @Override - public void run() { - String token = devToken.getString("token"); - if (token == null) { - return; - } - JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "cashback", token, - order.getString("order_id") + "返现" + cashbackAmount); - try { - JSONObject type = new JSONObject(); - type.put("send_type", "cashback"); - type.put("id", order.getString("order_id")); + sendingAppleMsgPool.execute(() -> { + String token = devToken.getString("token"); + if (token == null) { + return; + } + JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "cashback", token, + order.getString("order_id") + "返现" + cashbackAmount); + try { + JSONObject type = new JSONObject(); + type.put("send_type", "cashback"); + type.put("id", order.getString("order_id")); - 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); - appMessageLogMapper.update(log); - } catch (Exception e) { - logger.error("出错了:" + e.getMessage()); - appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); - throw new ServerErrorException("Send App " + devToken.getString("client_type") + " Failed", e); + AppMsgSender sender = senderMap.get(devToken.getString("client_type")); + if (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); + appMessageLogMapper.update(log); + } catch (Exception e) { + logger.error("出错了:", e); + appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); + throw new ServerErrorException("Send App " + devToken.getString("client_type") + " Failed", e); } }); @@ -1268,43 +1265,47 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public void sendCleanMessage(JSONObject log_clearing_detail, int client_id) { - String clearing_amount = log_clearing_detail.getBigDecimal("clearing_amount").setScale(2, RoundingMode.HALF_DOWN).toString(); - 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"); - logger.debug("sendCleanMessage-" + log_clearing_detail.getString("client_moniker") + "- " + PlatformEnvironment.getEnv().getForeignCurrency() + " " - + clearing_amount + "(" + settle_date_from + "-" + settle_date_to + ")"); - List tokens = clientDeviceTokenMapper.listTokensByClient_id(client_id); + public void sendCleanMessage(JSONObject logClearingDetail, int clientId) { + String clearingAmount = logClearingDetail.getBigDecimal("clearing_amount").setScale(2, RoundingMode.HALF_DOWN).toString(); + String settleDateFrom = DateFormatUtils.format(logClearingDetail.getDate("settle_date_from"), "MM/dd/yyyy"); + String settleDateTo = DateFormatUtils.format(logClearingDetail.getDate("settle_date_to"), "MM/dd/yyyy"); + logger.debug("sendCleanMessage-{}-{} {}({}}-{}})", + logClearingDetail.getString("client_moniker"), + PlatformEnvironment.getEnv().getForeignCurrency(), + clearingAmount, + settleDateFrom, + settleDateTo); + List tokens = clientDeviceTokenMapper.listTokensByClient_id(clientId); for (JSONObject devToken : tokens) { String token = devToken.getString("token"); if (token == null) { continue; } - String log_clearing_detail_id = log_clearing_detail.getString("clear_detail_id"); + String logClearingDetailId = logClearingDetail.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 + ")"); + "本次清算" + logClearingDetailId + ",$" + clearingAmount + "(" + settleDateFrom + "-" + settleDateTo + ")"); try { JSONObject type = new JSONObject(); type.put("send_type", "clean"); - type.put("id", log_clearing_detail_id); + type.put("id", logClearingDetailId); AppMsgSender sender = senderMap.get(devToken.getString("client_type")); - if (token == null || sender == null) { + if (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 + ")"); + + clearingAmount + " (" + settleDateFrom + "-" + settleDateTo + ")"); managerMsg.put("type", type); - managerMsg.put("data", log_clearing_detail); + managerMsg.put("data", logClearingDetail); managerMsg.put("msgType", "clean"); AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage(); sender.sendMessage(appMessage, devToken); log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { - logger.error("出错了:" + e.getMessage()); + logger.error("出错了:", e); appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); throw new ServerErrorException("Send App " + devToken.getString("client_type") + " Failed", e); } @@ -1312,34 +1313,34 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public void sendTransactionDailyMessage(JSONObject tradeInfo, int client_id) { - String trade_date = tradeInfo.getString("trade_date"); - String total_amount = tradeInfo.getString("total"); - String total_orders = tradeInfo.getString("orders"); + public void sendTransactionDailyMessage(JSONObject tradeInfo, int clientId) { + String tradeDate = tradeInfo.getString("trade_date"); + String totalAmount = tradeInfo.getString("total"); + String totalOrders = tradeInfo.getString("orders"); String customers = tradeInfo.getString("customers"); - List tokens = clientDeviceTokenMapper.listTokensByClient_id(client_id); + List tokens = clientDeviceTokenMapper.listTokensByClient_id(clientId); for (JSONObject devToken : tokens) { String token = devToken.getString("token"); if (token == null) { continue; } JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "daily_notice", token, - "Trade Date:" + trade_date); + "Trade Date:" + tradeDate); try { JSONObject type = new JSONObject(); type.put("send_type", "daily_notice"); - type.put("id", trade_date); + type.put("id", tradeDate); apnsMessageHelper.sendAppleMessageDetail( - LocaleSupport.localeMessage("app.message.title.daily_notice"), trade_date + ": 总交易额 " - + PlatformEnvironment.getEnv().getForeignCurrency() + total_amount + ", 订单数:" + total_orders + ", 付款人数:" + customers, + LocaleSupport.localeMessage("app.message.title.daily_notice"), tradeDate + ": 总交易额 " + + PlatformEnvironment.getEnv().getForeignCurrency() + totalAmount + ", 订单数:" + totalOrders + ", 付款人数:" + customers, token, tradeInfo, type); AppMsgSender sender = senderMap.get(devToken.getString("client_type")); - if (token == null || sender == null) { + if (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 + managerMsg.put("body", tradeDate + ": 总交易额 " + PlatformEnvironment.getEnv().getForeignCurrency() + totalAmount + ", 订单数:" + totalOrders + ", 付款人数:" + customers); managerMsg.put("type", type); managerMsg.put("data", tradeInfo); @@ -1350,7 +1351,7 @@ public class RetailAppServiceImp implements RetailAppService { log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { - logger.error("出错了:" + e.getMessage()); + logger.error("出错了:", e); appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); throw new ServerErrorException("Send App " + devToken.getString("client_type") + " Failed", e); } @@ -1369,9 +1370,9 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - @Cacheable(value = ":dev_message_token:", key = "#dev_id") - public JSONObject getDevTokenByDevId(String dev_id) { - return clientDeviceTokenMapper.findByDevId(dev_id); + @Cacheable(value = ":dev_message_token:", key = "#devId") + public JSONObject getDevTokenByDevId(String devId) { + return clientDeviceTokenMapper.findByDevId(devId); } @Override @@ -1380,7 +1381,7 @@ public class RetailAppServiceImp implements RetailAppService { deviceSupport.findRegister(clientType); params.put("is_to_app", 1); JSONObject res = noticePartner.listNotices(device, params); - List data = (List) res.get("data"); + List data = res.getJSONArray("data").toJavaList(JSONObject.class); for (JSONObject notice : data) { notice.remove("content"); } @@ -1397,9 +1398,9 @@ public class RetailAppServiceImp implements RetailAppService { Document doc = Jsoup.parse(res.getString("content")); String father = "
"; String html = doc.body().children().wrap(father).html(); - // logger.debug("wrapped html---->"+html); + logger.debug("wrapped html---->{}", html); if (res.getIntValue("type") == 2) { - List buttons = JSONObject.parseArray(res.getString("buttons"), JSONObject.class); + List buttons = JSON.parseArray(res.getString("buttons"), JSONObject.class); res.put("buttons", buttons); } else { res.put("content", doc.html()); @@ -1408,17 +1409,17 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public List getLatestNotice(int client_id) { - JSONObject clientConfig = clientConfigService.find(client_id); + public List getLatestNotice(int clientId) { + JSONObject clientConfig = clientConfigService.find(clientId); JSONObject notice = new JSONObject(); - JSONObject latestNotice = noticeManage.getLatestWindowNotice(client_id); + JSONObject latestNotice = noticeManage.getLatestWindowNotice(clientId); if (latestNotice != null) { latestNotice.put("id", latestNotice.getString("notice_id")); latestNotice.remove("notice_id"); notice.put("data", latestNotice); } JSONObject unReadParams = new JSONObject(); - unReadParams.put("client_id", client_id); + unReadParams.put("client_id", clientId); unReadParams.put("status", 0); unReadParams.put("is_to_app", 1); unReadParams.put("type", 1); @@ -1429,30 +1430,30 @@ public class RetailAppServiceImp implements RetailAppService { result.add(notice); JSONObject confirmNotice = new JSONObject(); - JSONObject latestConfirmNotice = noticeManage.getLatestWindowConfirmNotice(client_id); + JSONObject latestConfirmNotice = noticeManage.getLatestWindowConfirmNotice(clientId); if (latestConfirmNotice != null) { latestConfirmNotice.put("id", latestConfirmNotice.getString("notice_id")); latestConfirmNotice.remove("notice_id"); - List buttons = JSONObject.parseArray(latestConfirmNotice.getString("buttons"), JSONObject.class); + List buttons = JSON.parseArray(latestConfirmNotice.getString("buttons"), JSONObject.class); latestConfirmNotice.put("buttons", buttons); String content = latestConfirmNotice.getString("content"); - if (content.indexOf("%excharge_rate%") > 0) { - JSONObject rate = merchantInfoProvider.clientCurrentRate(client_id, new Date(), "CB_BankPay"); + if (content.contains("%excharge_rate%")) { + JSONObject rate = merchantInfoProvider.clientCurrentRate(clientId, new Date(), "CB_BankPay"); if (rate != null) { - content = content.replace("%excharge_rate%", (rate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() + "%")); + content = content.replace("%excharge_rate%", (rate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN).toPlainString() + "%")); } else { content = content.replace("%excharge_rate%", "(暂未配置)"); } } if (StringUtils.isNotBlank(latestConfirmNotice.getString("aggregate_file"))) { - JSONObject rate = merchantInfoProvider.clientCurrentRate(client_id, new Date(), "CB_BankPay"); + JSONObject rate = merchantInfoProvider.clientCurrentRate(clientId, new Date(), "CB_BankPay"); JSONArray rateInfo = new JSONArray(); if (rate != null) { String cleanDays = "T+" + rate.getIntValue("clean_days"); String rateValue = rate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN).toPlainString() + "%"; - String EndDate = DateFormatUtils.format(rate.getDate("expiry_date"), "yyyy-MM-dd"); + String endDate = DateFormatUtils.format(rate.getDate("expiry_date"), "yyyy-MM-dd"); String[] rateName = {"清算时间", "签约费率", "结束时间"}; - String[] rateKey = {cleanDays, rateValue, EndDate}; + String[] rateKey = {cleanDays, rateValue, endDate}; for (int i = 0; i < rateName.length; i++) { JSONObject b = new JSONObject(); b.put("name", rateName[i]); @@ -1507,11 +1508,11 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public void changeAccountPassword(JSONObject device, ChangePwdBean change, String account_id) { + public void changeAccountPassword(JSONObject device, ChangePwdBean change, String accountId) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); // JSONObject client = signInAccountService.getClient(account_id); - if (!account_id.equals(device.getString("account_id"))) { + if (!accountId.equals(device.getString("account_id"))) { throw new ForbiddenException("You have no permission"); } signInAccountService.changeAccountPassword(device, change); @@ -1577,7 +1578,7 @@ public class RetailAppServiceImp implements RetailAppService { } private JSONObject getChannel(int clientId, Date date, String channel) { - JSONObject per_channel = new JSONObject(); + JSONObject perChannel = new JSONObject(); JSONObject res = null; try { res = merchantInfoProvider.clientCurrentRate(clientId, date, channel); @@ -1587,16 +1588,16 @@ public class RetailAppServiceImp implements RetailAppService { DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); if (null != res) { - per_channel.put("channel", res.getString("rate_name")); - per_channel.put("rate", res.getBigDecimal("rate_value")); - per_channel.put("from", format.format(res.getDate("active_date"))); - per_channel.put("to", format.format(res.getDate("expiry_date"))); + perChannel.put("channel", res.getString("rate_name")); + perChannel.put("rate", res.getBigDecimal("rate_value")); + perChannel.put("from", format.format(res.getDate("active_date"))); + perChannel.put("to", format.format(res.getDate("expiry_date"))); } - return per_channel; + return perChannel; } @Override - public JSONObject listDailyTransactions(String dateStr, String timezone, boolean thisDevOnly, JSONObject device, String app_client_ids) { + public JSONObject listDailyTransactions(String dateStr, String timezone, boolean thisDevOnly, JSONObject device, String appClientIds) { try { JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id")); if (client == null) { @@ -1613,41 +1614,41 @@ public class RetailAppServiceImp implements RetailAppService { devId = device.getString("dev_id"); } Date to = DateUtils.addDays(date, 1); - String[] param_client_ids = null; - if (StringUtils.isEmpty(app_client_ids)) { - JSONArray client_ids = clientManager.getAllClientIds(device.getIntValue("client_id")); - if (client_ids.size() > 1) { - param_client_ids = new String[client_ids.size()]; - client_ids.toArray(param_client_ids); + String[] paramClientIds = null; + if (StringUtils.isEmpty(appClientIds)) { + JSONArray clientIds = clientManager.getAllClientIds(device.getIntValue("client_id")); + if (clientIds.size() > 1) { + paramClientIds = new String[clientIds.size()]; + clientIds.toArray(paramClientIds); } } else { - param_client_ids = app_client_ids.split(","); + paramClientIds = appClientIds.split(","); } - List transactions = transactionMapper.listDailyTransactions(date, to, devId, device.getIntValue("client_id"), param_client_ids); + List transactions = transactionMapper.listDailyTransactions(date, to, devId, device.getIntValue("client_id"), paramClientIds); if (transactions.isEmpty()) { throw new BadRequestException("No Transactions in date " + dateStr + " at " + timezone); } TimeZoneUtils.switchTimeZoneToString(transactions, timezone, "HH:mm:ss", Collections.singletonList("transaction_time")); - BigDecimal display_amount = BigDecimal.ZERO; - BigDecimal cny_display_amount = BigDecimal.ZERO; + BigDecimal displayAmount = BigDecimal.ZERO; + BigDecimal cnyDisplayAmount = BigDecimal.ZERO; for (JSONObject transaction : transactions) { if (PlatformEnvironment.getEnv().getForeignCurrency().equals(transaction.getString("currency"))) { if ("Credit".equals(transaction.getString("transaction_type"))) { - display_amount = display_amount.add(transaction.getBigDecimal("display_amount")); + displayAmount = displayAmount.add(transaction.getBigDecimal("display_amount")); } } else { if ("Credit".equals(transaction.getString("transaction_type"))) { - cny_display_amount = cny_display_amount.add(transaction.getBigDecimal("display_amount")); + cnyDisplayAmount = cnyDisplayAmount.add(transaction.getBigDecimal("display_amount")); } } } JSONObject res = new JSONObject(); res.put("transactions", transactions); - JSONObject analysis = transactionMapper.analysisRetailDailyReport(date, to, devId, device.getIntValue("client_id"), param_client_ids); + JSONObject analysis = transactionMapper.analysisRetailDailyReport(date, to, devId, device.getIntValue("client_id"), paramClientIds); analysis.put("date", TimeZoneUtils.formatTime(date, "dd/MMM/yyyy", timezone)); - analysis.put("display_amount", display_amount); - analysis.put("cny_display_amount", cny_display_amount); + analysis.put("display_amount", displayAmount); + analysis.put("cny_display_amount", cnyDisplayAmount); res.put("analysis", analysis); return res; } catch (ParseException e) { @@ -1656,22 +1657,22 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public JSONObject getActivities(JSONObject device, String type, int page, int limit) { + public JSONObject getActivities(JSONObject device, String activityPage, int page, int limit) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); JSONObject res = royalPayCMSSupport.listArticles("app_activity", false, true, page, limit); - if (type.equalsIgnoreCase("home_page")) { + if (activityPage.equalsIgnoreCase("home_page")) { JSONArray acts = res.getJSONArray("data"); - List new_acts = new ArrayList<>(); + List newActs = new ArrayList<>(); for (JSONObject act : JSON.parseArray(acts.toJSONString(), JSONObject.class)) { if (act.getString("page_desc") != null && !act.getString("page_desc").equals("0")) { - new_acts.add(act); + newActs.add(act); } } - res.put("data", new_acts); + res.put("data", newActs); } // 手续费返还活动 - List acts = (List) res.get("data"); + List acts = res.getJSONArray("data").toJavaList(JSONObject.class); for (JSONObject act : acts) { if (StringUtils.isNotBlank(act.getString("page_keywords")) && act.getString("page_keywords").equalsIgnoreCase("native")) { JSONObject clientRate = merchantInfoProvider.clientCurrentRate(device.getIntValue("client_id"), new Date(), "Wechat"); @@ -1684,13 +1685,11 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public JSONObject getActivityDetail(JSONObject device, String article_id) { + public JSONObject getActivityDetail(JSONObject device, String articleId) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - JSONObject res = royalPayCMSSupport.getArticle("app_activity", article_id); + JSONObject res = royalPayCMSSupport.getArticle("app_activity", articleId); Document doc = Jsoup.parse(res.getString("content")); - String father = "
"; - String html = doc.body().children().wrap(father).html(); res.put("content", doc.html()); res.put("publish_time_format", TimeZoneUtils.formatTime(res.getDate("publish_time"), "yyyy-MM-dd HH:mm:ss", "Australia/Melbourne")); return res; @@ -1702,27 +1701,27 @@ public class RetailAppServiceImp implements RetailAppService { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); String newAppVersion = PlatformEnvironment.getEnv().getNewVersion(clientType); - Boolean isUpdate = PlatformEnvironment.getEnv().isAppUpdate(clientType); + boolean isUpdate = PlatformEnvironment.getEnv().isAppUpdate(clientType); String updateContent = PlatformEnvironment.getEnv().getAppUpdateContent(clientType); - int update_type = 0;// 0:不更新 1:更新 2:强制更新 + int updateType = 0;// 0:不更新 1:更新 2:强制更新 String[] oldVersion = version.split("\\."); String[] newVersion = newAppVersion.split("\\."); JSONObject res = new JSONObject(); res.put("update_content", updateContent); for (int i = 0; i < newVersion.length; i++) { - if (Integer.valueOf(newVersion[i]) > Integer.valueOf(oldVersion[i])) { - update_type = 1; + if (Integer.parseInt(newVersion[i]) > Integer.parseInt(oldVersion[i])) { + updateType = 1; if (isUpdate) { - update_type = 2; + updateType = 2; } - res.put("update_type", update_type); + res.put("update_type", updateType); return res; - } else if (Integer.valueOf(newVersion[i]) < Integer.valueOf(oldVersion[i])) { - res.put("update_type", update_type); + } else if (Integer.valueOf(newVersion[i]) < Integer.parseInt(oldVersion[i])) { + res.put("update_type", updateType); return res; } } - res.put("update_type", update_type); + res.put("update_type", updateType); return res; } @@ -1733,12 +1732,12 @@ public class RetailAppServiceImp implements RetailAppService { 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 devId, int clientId, String messageType, String devToken, String remark) { JSONObject log = new JSONObject(); - log.put("dev_id", dev_id); - log.put("client_id", client_id); + log.put("dev_id", devId); + log.put("client_id", clientId); log.put("msg_type", messageType); - log.put("dev_token", dev_token); + log.put("dev_token", devToken); log.put("remark", remark); log.put("send_time", new Date()); appMessageLogMapper.save(log); @@ -1748,14 +1747,13 @@ public class RetailAppServiceImp implements RetailAppService { @Override public JSONObject getCashbackCommData(JSONObject device, AppQueryBean appQueryBean) { - JSONObject res = new JSONObject(); String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id"); + int clientId = device.getIntValue("client_id"); JSONObject params = appQueryBean.toParams(); - setAllClientIds(params, client_id); - params.put("client_id", client_id); - res = cashbackService.getCashbackAmount(params); + setAllClientIds(params, clientId); + params.put("client_id", clientId); + JSONObject res = cashbackService.getCashbackAmount(params); JSONObject rate = merchantInfoProvider.clientCurrentRate(device.getIntValue("client_id"), new Date(), "Wechat"); if (rate.getInteger("clean_days") == null) { JSONObject clientConfig = clientConfigService.find(device.getIntValue("client_id")); @@ -1769,41 +1767,41 @@ public class RetailAppServiceImp implements RetailAppService { public JSONObject getCashbackRecords(JSONObject device, AppQueryBean appQueryBean) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id"); - JSONObject client = clientManager.getClientInfo(client_id); + int clientId = device.getIntValue("client_id"); + JSONObject client = clientManager.getClientInfo(clientId); String timezone = client.getString("timezone"); if (timezone != null && !timezone.isEmpty()) { appQueryBean.setTimezone(timezone); } JSONObject params = appQueryBean.toParams(); - setAllClientIds(params, client_id); - params.put("client_id", client_id); + setAllClientIds(params, clientId); + params.put("client_id", clientId); JSONObject res = cashbackService.getCashbackRecores(params, appQueryBean.getPage(), appQueryBean.getLimit()); - ArrayList list = (ArrayList) res.get("data"); + List list = res.getJSONArray("data").toJavaList(JSONObject.class); TimeZoneUtils.switchTimeZone(list, appQueryBean.getTimezone(), "create_time"); - ArrayList date_contains = new ArrayList<>(); + List dateContains = new ArrayList<>(); for (JSONObject cashRecord : list) { Date tradeDate = cashRecord.getDate("create_time"); - String trade_date = DateFormatUtils.format(tradeDate, "yyyy-MM-dd"); - String trade_time = DateFormatUtils.format(tradeDate, "HH:mm:ss"); - cashRecord.put("trade_date", trade_date); - cashRecord.put("trade_time", trade_time); - if (!date_contains.contains(trade_date)) { - String re_date = trade_date.replaceAll("-", ""); - AppQueryBean date_query = new AppQueryBean(); - date_query.setBegin(re_date); - date_query.setEnd(re_date); + String tradeDateStr = DateFormatUtils.format(tradeDate, "yyyy-MM-dd"); + String tradeTimeStr = DateFormatUtils.format(tradeDate, "HH:mm:ss"); + cashRecord.put("trade_date", tradeDateStr); + cashRecord.put("trade_time", tradeTimeStr); + if (!dateContains.contains(tradeDateStr)) { + String reDate = tradeDateStr.replace("-", ""); + AppQueryBean dateQuery = new AppQueryBean(); + dateQuery.setBegin(reDate); + dateQuery.setEnd(reDate); if (params.containsKey("client_ids")) { - date_query.setClient_ids((String[]) params.get("client_ids")); + dateQuery.setClient_ids((String[]) params.get("client_ids")); } if (timezone != null && !timezone.isEmpty()) { - date_query.setTimezone(timezone); + dateQuery.setTimezone(timezone); } - JSONObject date_params = date_query.toParams(); - date_params.put("client_id", device.getIntValue("client_id")); - JSONObject analysis = cashbackService.analysisCashback(date_params); + JSONObject dateParams = dateQuery.toParams(); + dateParams.put("client_id", device.getIntValue("client_id")); + JSONObject analysis = cashbackService.analysisCashback(dateParams); cashRecord.put("date_total", analysis); - date_contains.add(trade_date); + dateContains.add(tradeDateStr); } } return res; @@ -1813,21 +1811,21 @@ public class RetailAppServiceImp implements RetailAppService { public JSONObject getCashbackDrawLogs(JSONObject device, AppQueryBean appQueryBean) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id"); - JSONObject client = clientManager.getClientInfo(client_id); + int clientId = device.getIntValue("client_id"); + JSONObject client = clientManager.getClientInfo(clientId); String timezone = client.getString("timezone"); if (timezone != null && !timezone.isEmpty()) { appQueryBean.setTimezone(timezone); } JSONObject params = appQueryBean.toParams(); - setAllClientIds(params, client_id); - params.put("client_id", client_id); + setAllClientIds(params, clientId); + params.put("client_id", clientId); return cashbackService.getDrawDeposits(params, appQueryBean.getPage(), appQueryBean.getLimit()); } @Override - public void drawDeposits(JSONObject device, BigDecimal draw_amount, String client_id) { + public void drawDeposits(JSONObject device, BigDecimal drawAmount, String clientId) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); JSONObject account = clientAccountMapper.findById(device.getString("account_id")); @@ -1835,24 +1833,24 @@ public class RetailAppServiceImp implements RetailAppService { operator.put("account_id", device.getString("account_id")); operator.put("display_name", account.getString("display_name")); JSONArray clientIds = clientManager.getAllClientIds(device.getIntValue("client_id")); - if (!clientIds.contains(client_id)) { + if (!clientIds.contains(clientId)) { throw new ForbiddenException("partner has no permission"); } - cashbackService.drawDeposits(draw_amount, Integer.parseInt(client_id), operator); + cashbackService.drawDeposits(drawAmount, Integer.parseInt(clientId), operator); } @Override - public JSONObject getCashbackCleanInfo(JSONObject device, String client_id) { + public JSONObject getCashbackCleanInfo(JSONObject device, String clientId) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); JSONArray clientIds = clientManager.getAllClientIds(device.getIntValue("client_id")); - if (!clientIds.contains(client_id)) { + if (!clientIds.contains(clientId)) { throw new ForbiddenException("partner has no permission"); } - JSONObject res = clientManager.getBankAccountByClientId(Integer.parseInt(client_id)); - JSONObject rate = merchantInfoProvider.clientCurrentRate(Integer.parseInt(client_id), new Date(), "Wechat"); + JSONObject res = clientManager.getBankAccountByClientId(Integer.parseInt(clientId)); + JSONObject rate = merchantInfoProvider.clientCurrentRate(Integer.parseInt(clientId), new Date(), "Wechat"); if (rate.getInteger("clean_days") == null) { - JSONObject clientConfig = clientConfigService.find(Integer.parseInt(client_id)); + JSONObject clientConfig = clientConfigService.find(Integer.parseInt(clientId)); rate.put("clean_days", clientConfig.getIntValue("clean_days")); } res.put("clean_days", rate.getIntValue("clean_days")); @@ -1867,8 +1865,7 @@ public class RetailAppServiceImp implements RetailAppService { if (clientRate.getIntValue("clean_days") == 1) { JSONObject config = clientSettleDelayConfMapper.findClientConf(device.getIntValue("client_id")); if (config == null) { - // res.put("show", true); - res.put("interest_rate", xPlanFundConfigService.configuration().getInterestRate().setScale(2, BigDecimal.ROUND_DOWN)); + res.put("interest_rate", xPlanFundConfigService.configuration().getInterestRate().setScale(2, RoundingMode.DOWN)); } } @@ -1885,39 +1882,33 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject client = clientManager.getClientInfoByMoniker(partner_code); Assert.notNull(client, "Client is null"); List tokens = clientDeviceTokenMapper.listTokensByClient_id(client.getInteger("client_id")); - if (null != tokens && tokens.size() > 0) { + if (!tokens.isEmpty()) { for (final JSONObject devToken : tokens) { final String token = devToken.getString("token"); - sendingAppleMsgPool.execute(new Runnable() { - @Override - public void run() { - JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "dev", token, - "Param:partner_code,自定义推送消息"); - sending(token, params, log); - } + sendingAppleMsgPool.execute(() -> { + JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "dev", token, + "Param:partner_code,自定义推送消息"); + sending(token, params, log); }); } } else { - logger.error("出错了:" + client.getString("short_name") + "无token"); + logger.error("出错了:{}无token", client.getString("short_name")); throw new ServerErrorException(client.getString("short_name") + "无token"); } } } if (params.getString("type").equals("Personal")) { for (final String dev_token : codes) { - sendingAppleMsgPool.execute(new Runnable() { - @Override - public void run() { - JSONObject log = saveAppMessageLog("0", 0, "dev", dev_token, "Param:devToken,自定义推送消息"); - sending(dev_token, params, log); - } + sendingAppleMsgPool.execute(() -> { + JSONObject log = saveAppMessageLog("0", 0, "dev", dev_token, "Param:devToken,自定义推送消息"); + sending(dev_token, params, log); }); } } } catch (ServerErrorException s) { throw new ServerErrorException(s.getMessage()); } catch (Exception e) { - logger.error("出错了:" + e.getMessage()); + logger.error("出错了:{}", e.getMessage(), e); throw new ServerErrorException("Send App Message Failed", e); } @@ -1942,7 +1933,7 @@ public class RetailAppServiceImp implements RetailAppService { log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { - logger.error("出错了:" + e.getMessage()); + logger.error("出错了:{}", e.getMessage(), e); appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); throw new ServerErrorException("Send App " + params.getString("client_type") + " Failed", e); } @@ -1957,30 +1948,30 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public JSONObject getCouponById(JSONObject device, String coupon_log_id) { + public JSONObject getCouponById(JSONObject device, String couponLogId) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - if (!mathchLetterorNum(coupon_log_id)) { + if (!matchLetterorNum(couponLogId)) { throw new BadRequestException("非RP优惠券二维码"); } - return couponVerificationService.getCouponById(device.getJSONObject("client"), coupon_log_id); + return couponVerificationService.getCouponById(device.getJSONObject("client"), couponLogId); } @Override - public void useCoupon(JSONObject device, String coupon_log_id) { + public void useCoupon(JSONObject device, String couponLogId) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - if (!mathchLetterorNum(coupon_log_id)) { + if (!matchLetterorNum(couponLogId)) { throw new BadRequestException("非RP优惠券二维码"); } - couponVerificationService.useCoupon(coupon_log_id); + couponVerificationService.useCoupon(couponLogId); } @Override public JSONObject getAd() { JSONObject res = royalPayCMSSupport.listArticles("app_ad", false, true, 1, 10); JSONArray acts = res.getJSONArray("data"); - if (acts.size() > 0) { + if (!acts.isEmpty()) { int selectNo = RandomUtils.nextInt(0, acts.size()); JSONObject getActs = acts.getJSONObject(selectNo); getActs.put("ad_cover", getActs.getString("page_desc")); @@ -1988,7 +1979,7 @@ public class RetailAppServiceImp implements RetailAppService { getActs.put("ad_link", getActs.getString("summery")); getActs.put("publish_date", DateFormatUtils.format(getActs.getDate("publish_time"), "yyyy/MM/dd HH:mm:ss")); String reference = getActs.getString("reference"); - JSONObject referenceObj = JSONObject.parseObject(reference); + JSONObject referenceObj = JSON.parseObject(reference); if (reference != null) { if (referenceObj.getString("ad_type") != null) { getActs.put("ad_type", referenceObj.getString("ad_type")); @@ -2014,11 +2005,12 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public JSONObject getAdDetail(String article_id) { - JSONObject res = royalPayCMSSupport.getArticle("app_ad", article_id); + public JSONObject getAdDetail(String articleId) { + JSONObject res = royalPayCMSSupport.getArticle("app_ad", articleId); Document doc = Jsoup.parse(res.getString("content")); String father = "
"; String html = doc.body().children().wrap(father).html(); + logger.debug("html:{}", html); res.put("content", doc.html()); res.put("publish_time_format", TimeZoneUtils.formatTime(res.getDate("publish_time"), "yyyy-MM-dd HH:mm:ss", "Australia/Melbourne")); return res; @@ -2030,13 +2022,13 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public void changeManualSettle(JSONObject device, boolean manual_settle) { + public void changeManualSettle(JSONObject device, boolean manualSettle) { JSONObject account = clientAccountMapper.findById(device.getString("account_id")); - clientManager.changeManualSettle(account, device.getIntValue("client_id"), manual_settle, device.getString("account_id"), 1, - "商户" + (manual_settle ? "打开" : "关闭") + "手动清算"); + clientManager.changeManualSettle(account, device.getIntValue("client_id"), manualSettle, device.getString("account_id"), 1, + "商户" + (manualSettle ? "打开" : "关闭") + "手动清算"); } - private static boolean mathchLetterorNum(String str) { + private static boolean matchLetterorNum(String str) { String regex = "[A-Za-z0-9]{8}"; return str.matches(regex); } @@ -2130,7 +2122,7 @@ public class RetailAppServiceImp implements RetailAppService { try { smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, BIND_PHONE_TEMPLID, param, "RoyalPay", "", ""); } catch (Exception e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); throw new ServerErrorException("Phone number is wrong.Please try again."); } stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES); @@ -2143,15 +2135,15 @@ public class RetailAppServiceImp implements RetailAppService { throw new BadRequestException("Captcha has expired"); } String captcha = key.split("&")[0]; - String nation_code = key.split("&")[1]; - String contact_phone = key.split("&")[2]; + String nationCode = key.split("&")[1]; + String contactPhone = key.split("&")[2]; if (!StringUtils.equals(captcha, params.getString("captcha"))) { throw new BadRequestException("Verification code is wrong"); } JSONObject account = new JSONObject(); account.put("account_id", device.getString("account_id")); - account.put("contact_phone", contact_phone); - account.put("nation_code", "+" + nation_code); + account.put("contact_phone", contactPhone); + account.put("nation_code", "+" + nationCode); clientAccountMapper.update(account); deleteAccountPhoneKey(device.getString("account_id")); } @@ -2256,8 +2248,7 @@ public class RetailAppServiceImp implements RetailAppService { deviceSupport.findRegister(clientType); JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id")); client.put("now", DateFormatUtils.format(new Date(), "yyyy-MM-dd")); - String clientName = ""; - clientName = client.getString("business_name"); + String clientName = client.getString("business_name"); if (StringUtils.isNotBlank(client.getString("acn"))) { clientName += "(" + client.getString("acn") + ")"; client.put("client_acn", client.getString("acn")); @@ -2304,8 +2295,8 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id")); String address = client.getString("address").trim(); if (address.contains(",")) { - client.put("address", address.substring(0, address.lastIndexOf(",")).trim()); - client.put("address_sub", address.substring(address.lastIndexOf(",") + 1).trim()); + client.put("address", address.substring(0, address.lastIndexOf(',')).trim()); + client.put("address_sub", address.substring(address.lastIndexOf(',') + 1).trim()); } if (client.getString("acn") != null && !client.getString("acn").equals("")) { client.put("acn_type", "ACN: (" + client.getString("acn") + ")"); @@ -2319,26 +2310,26 @@ public class RetailAppServiceImp implements RetailAppService { if (weChatRate == null) { throw new BadRequestException("The Partner's Rate is not config!"); } - client.put("wechat_rate", weChatRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); + client.put("wechat_rate", weChatRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)); client.put("clean", "T+" + weChatRate.getString("clean_days")); client.put("clean_days", weChatRate.getString("clean_days")); String rateConfig = sysConfigManager.getSysConfig().getString("sys_rates"); - JSONObject sysConfigRate = JSONObject.parseObject(rateConfig); + JSONObject sysConfigRate = JSON.parseObject(rateConfig); try { JSONObject alipayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Alipay"); if (alipayRate != null) { - client.put("alipay_rate", alipayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); + client.put("alipay_rate", alipayRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)); } JSONObject alipayOnlineRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "AlipayOnline"); if (alipayOnlineRate != null) { - client.put("alipay_online_rate", alipayOnlineRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); + client.put("alipay_online_rate", alipayOnlineRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)); } JSONObject cbBankPayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "CB_BankPay"); if (cbBankPayRate != null) { - client.put("cbbank_rate", cbBankPayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); + client.put("cbbank_rate", cbBankPayRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)); } } catch (Exception ignored) { throw new BadRequestException("Merchant Rate Not Configure,Please Contact Customer Service"); @@ -2347,17 +2338,17 @@ public class RetailAppServiceImp implements RetailAppService { try { JSONObject bestPayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Bestpay"); if (bestPayRate != null) { - client.put("bestpay_rate", bestPayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); + client.put("bestpay_rate", bestPayRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)); } JSONObject jdRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "jd"); if (jdRate != null) { - client.put("jd_rate", jdRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); + client.put("jd_rate", jdRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)); } } catch (Exception ignored) { JSONObject rate = sysConfigRate.getJSONObject("t" + weChatRate.getString("clean_days")); - client.put("bestpay_rate", rate.getBigDecimal("Bestpay").setScale(2, BigDecimal.ROUND_DOWN)); - client.put("jd_rate", rate.getBigDecimal("JDpay").setScale(2, BigDecimal.ROUND_DOWN)); + client.put("bestpay_rate", rate.getBigDecimal("Bestpay").setScale(2, RoundingMode.DOWN)); + client.put("jd_rate", rate.getBigDecimal("JDpay").setScale(2, RoundingMode.DOWN)); } JSONObject bankAccount = getBankAccountByClientId(client.getIntValue("client_id")); @@ -2368,11 +2359,11 @@ public class RetailAppServiceImp implements RetailAppService { client.put("bsb_no", bankAccount.getString("bsb_no")); client.put("account_no", bankAccount.getString("account_no")); client.put("account_name", bankAccount.getString("account_name")); - String start_date = DateFormatUtils.format(new Date(), "dd/MM/yyyy"); - client.put("start_date", start_date); + String startDateStr = DateFormatUtils.format(new Date(), "dd/MM/yyyy"); + client.put("start_date", startDateStr); Date endDate = TimeZoneUtils.nextYearByCurrDay(); - String end_date = DateFormatUtils.format(endDate, "dd/MM/yyyy"); - client.put("end_date", end_date); + String endDateStr = DateFormatUtils.format(endDate, "dd/MM/yyyy"); + client.put("end_date", endDateStr); JSONObject clientLegal = sysClientLegalPersonMapper.findRepresentativeInfo(client.getIntValue("client_id")); if (clientLegal != null) { client.put("legal_person", clientLegal.getString("representative_person")); @@ -2449,7 +2440,7 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public boolean isSubPartner(JSONObject device,String clientMoniker) { + public boolean isSubPartner(JSONObject device, String clientMoniker) { JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker); if (client == null) { throw new NotFoundException("Client not found, please check"); @@ -2462,6 +2453,52 @@ public class RetailAppServiceImp implements RetailAppService { return (listSubClients.contains(client.getString("client_id")) && deviceClient.getBooleanValue("sub_manage")); } + @Override + public JSONObject postAppMessage(JSONObject device, RetailAppMessage message) { + String clientType = device.getString("client_type"); + if (!GatewayOAuthRegister.CLIENT_TYPE.equals(clientType)) { + throw new ForbiddenException("Invalid Client Type:" + clientType); + } + int clientId = device.getIntValue("client_id"); + String appid = device.getString("appid"); + JSONObject msg = message.forSave(appid, clientId); + authAppMessageMapper.save(msg); + String msgId = msg.getString("message_id"); + List tokens = clientDeviceTokenMapper.listTokensByClient_id(clientId); + final String[] supportedClientTypes = {"android", "iphone", "ipad"}; + long successCount = tokens.parallelStream().filter(devToken -> ArrayUtils.contains(supportedClientTypes, devToken.getString("client_type"))) + .filter(devToken -> StringUtils.isNoneEmpty(devToken.getString("account_id"), devToken.getString("token"))) + .filter(devToken -> { + JSONObject account = clientAccountMapper.findById(devToken.getString("account_id")); + return account != null && message.acceptRole(account.getIntValue("role")); + }) + .filter(devToken -> { + String token = devToken.getString("token"); + JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), AppMessageType.MESSAGE.name(), token, + "Message from app:" + appid); + try { + + AppMsgSender sender = senderMap.get(devToken.getString("client_type")); + if (sender == null) { + return false; + } + AppMessage appMessage = message.initAppMessage(msgId); + sender.sendMessage(appMessage, devToken); + log.put("status", 2); + appMessageLogMapper.update(log); + return true; + } catch (Exception e) { + logger.error("出错了:{}", e.getMessage(), e); + appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); + return false; + } + }).count(); + JSONObject resp = new JSONObject(); + resp.put("message_id", msgId); + resp.put("success_count", successCount); + return resp; + } + private void exportCBBankAggregateFile(JSONObject client, HttpServletResponse httpResponse) { httpResponse.setContentType("application/pdf"); httpResponse.setHeader("content-disposition", "attachment;filename=" + client.getString("client_moniker") + "_AGREEMENT_" + new Date() + ".pdf"); @@ -2475,7 +2512,7 @@ public class RetailAppServiceImp implements RetailAppService { ByteArrayOutputStream bos = pdu.templetPdfBos(file); sos.write(bos.toByteArray()); sos.close(); - } catch (Exception e) { + } catch (Exception ignore) { } } @@ -2514,8 +2551,8 @@ public class RetailAppServiceImp implements RetailAppService { return BIND_ACCOUNT_PHONE_PREFIX + codeKey; } - private JSONObject getBankAccountByClientId(int client_id) { - List list = clientBankAccountMapper.clientBankAccounts(client_id); + private JSONObject getBankAccountByClientId(int clientId) { + List list = clientBankAccountMapper.clientBankAccounts(clientId); return list.isEmpty() ? new JSONObject() : list.get(0); } @@ -2579,21 +2616,13 @@ public class RetailAppServiceImp implements RetailAppService { if (jd.containsKey("channel")) { channels.add(jd); } - JSONObject AlipayOnline = getChannel(clientId, now, "AlipayOnline"); - if (AlipayOnline.containsKey("channel")) { - channels.add(AlipayOnline); - } -// JSONObject Hf = getChannel(clientId, now, "hf"); -// if (Hf.containsKey("channel")) { -// channels.add(Hf); -// } -// JSONObject Yeepay = getChannel(clientId, now, "Yeepay"); -// if (Yeepay.containsKey("channel")) { -// channels.add(Yeepay); -// } - JSONObject CBBankPay = getChannel(clientId, now, "CB_BankPay"); - if (CBBankPay.containsKey("channel")) { - channels.add(CBBankPay); + JSONObject alipayOnline = getChannel(clientId, now, "AlipayOnline"); + if (alipayOnline.containsKey("channel")) { + channels.add(alipayOnline); + } + JSONObject cbBankPay = getChannel(clientId, now, "CB_BankPay"); + if (cbBankPay.containsKey("channel")) { + channels.add(cbBankPay); } res.put("channels", channels); return res; diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/extend/GatewayOAuthRegister.java b/src/main/java/au/com/royalpay/payment/manage/appclient/extend/GatewayOAuthRegister.java index dfe200f7a..9bae01d6c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/extend/GatewayOAuthRegister.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/extend/GatewayOAuthRegister.java @@ -12,6 +12,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; +import java.time.Duration; /** * 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("scope", authObj.getString("scope")); auth.put("grant_scene", authObj.getString("grant_scene")); - + redisTemplate.boundValueOps(authDetailCacheKey(authId)).set(auth.toJSONString(), Duration.ofMinutes(10)); return auth; } return JSON.parseObject(authStr); diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java index 56b24df82..017b54719 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java @@ -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.monsettledelay.core.ActMonDelaySettleService; 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.AppQueryBean; 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.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; @@ -219,6 +219,11 @@ public class RetailAppController { 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") public JSONObject getClientCurrentRateNew(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { return retailAppService.getClientCurrentRateNew(device); @@ -231,7 +236,7 @@ public class RetailAppController { @PutMapping("/sign_out") public void signOut(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - retailAppService.sign_out(device); + retailAppService.signOut(device); } /* 我的页面end */ @@ -543,7 +548,7 @@ public class RetailAppController { @PutMapping("/surcharge/{clientMoniker}") @ResponseBody public void changeQRCodePaySurChargeByMoniker(@ModelAttribute(RETAIL_DEVICE) JSONObject device, @PathVariable String clientMoniker, @RequestBody AppPaymentConfigBean appPaymentConfigBean) { - retailAppService.changePaymentConfigByMoniker(device, clientMoniker,appPaymentConfigBean); + retailAppService.changePaymentConfigByMoniker(device, clientMoniker, appPaymentConfigBean); } @GetMapping("/invoice") diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/client/AuthAppMessageMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/client/AuthAppMessageMapper.java new file mode 100644 index 000000000..63c492ed0 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/client/AuthAppMessageMapper.java @@ -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); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/pushMessage/bean/AppMessageType.java b/src/main/java/au/com/royalpay/payment/manage/pushMessage/bean/AppMessageType.java new file mode 100644 index 000000000..cb46702ba --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/pushMessage/bean/AppMessageType.java @@ -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 +} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientDeviceTokenMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientDeviceTokenMapper.xml index 912dade37..4ff113942 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientDeviceTokenMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientDeviceTokenMapper.xml @@ -3,37 +3,32 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > \ No newline at end of file