diff --git a/pom.xml b/pom.xml index 0973a0f03..689bc1b0e 100644 --- a/pom.xml +++ b/pom.xml @@ -132,6 +132,21 @@ com.alibaba druid + + + + cn.jpush.api + jpush-client + 3.3.3 + + + com.google.code.gson + gson + 2.2.4 + + + + diff --git a/src/db/modify.sql b/src/db/modify.sql index 246464dcc..1eb8d6787 100644 --- a/src/db/modify.sql +++ b/src/db/modify.sql @@ -106,7 +106,7 @@ ALTER TABLE `sys_accounts` MODIFY COLUMN `creator` varchar(50) NOT NULL COMMENT '开户者'; ALTER TABLE `sys_clients_audit_process` - MODIFY COLUMN `operator_id` varchar(50) NOT NULL ; + MODIFY COLUMN `operator_id` tinyint(1) NOT NULL ; ALTER TABLE `pmt_refunds` MODIFY COLUMN `operator_id` varchar(50) DEFAULT NULL COMMENT '退款操作者账号'; @@ -117,5 +117,26 @@ ALTER TABLE `sys_clients_apply` ALTER TABLE `cashback_draw_deposits` MODIFY COLUMN `operator_id` varchar(50) NOT NULL ; + ALTER TABLE `sys_clients` + ADD COLUMN `local_merchant` tinyint(1) DEFAULT 0; + +--用户画像 + +ALTER TABLE sys_clients_customers ADD COLUMN headimg VARCHAR(200) DEFAULT NULL COMMENT '头像地址'; + +ALTER TABLE sys_clients_customers ADD COLUMN nick_name VARCHAR(80) DEFAULT NULL COMMENT '昵称'; + +ALTER TABLE sys_clients_customers ADD COLUMN tag VARCHAR(100) DEFAULT NULL COMMENT '标签'; + +ALTER TABLE sys_clients_customers ADD COLUMN payment_times INT DEFAULT 1 COMMENT '消费次数'; + +ALTER TABLE sys_clients_customers ADD COLUMN total_amount decimal(10 , 2) DEFAULT NULL COMMENT '消费总金额'; + +ALTER TABLE sys_clients_customers ADD COLUMN update_time datetime default NULL COMMENT '创建时间'; + +ALTER TABLE sys_clients_customers ADD COLUMN channel varchar(15) not NULL ; + +ALTER TABLE sys_clients_customers ADD COLUMN last_payment_time datetime DEFAULT NULL COMMENT '最后一次付款时间'; +ALTER TABLE sys_org ADD COLUMN parent_org_id int(11) DEFAULT NULL; diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/web/DashboardController.java b/src/main/java/au/com/royalpay/payment/manage/analysis/web/DashboardController.java index 856030e6c..ec3eaccfa 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/web/DashboardController.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/web/DashboardController.java @@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.analysis.web; import au.com.royalpay.payment.manage.analysis.beans.AnalysisBean; import au.com.royalpay.payment.manage.analysis.core.DashboardService; +import au.com.royalpay.payment.manage.organizations.core.OrgManager; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.manage.permission.manager.RequirePartner; @@ -20,32 +21,28 @@ import java.util.List; public class DashboardController { @Resource private DashboardService dashboardService; + @Resource + private OrgManager orgManager; @ManagerMapping("/common_analysis_1") public JSONObject commonAnalysis1(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getCommonAnalysis1(params); } @ManagerMapping("/common_analysis_2") public JSONObject commonAnalysis2(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getCommonAnalysis2(params); } @ManagerMapping("/trade_in_types") public List tradeInTypes(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getTradeInTypes(params); } @@ -53,18 +50,14 @@ public class DashboardController { public List topTradePartners(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestParam(defaultValue = "10") int limit) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getTopTradePartners(params, limit); } @ManagerMapping("/rank_trade_partners") public List rankTradePartners(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); if (analysis.isOnlyGroup() && ManagerRole.BD_LEADER.hasRole(manager.getIntValue("role"))) { params.put("bd_group", manager.getString("manager_id")); if (analysis.getGroup_bd()>0){ @@ -77,9 +70,7 @@ public class DashboardController { @ManagerMapping("/trade_in_hours") public List tradeInHours(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); if (analysis.isOnlyGroup() && ManagerRole.BD_LEADER.hasRole(manager.getIntValue("role"))) { params.put("bd_group", manager.getString("manager_id")); if (analysis.getGroup_bd()>0){ @@ -92,18 +83,14 @@ public class DashboardController { @ManagerMapping("/fee_analysis") public List tradeInDays(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getTradeAnalysisInDays(params); } @ManagerMapping("/partners_in_types") public List partnersInTypes(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); if (analysis.isOnlyGroup() && ManagerRole.BD_LEADER.hasRole(manager.getIntValue("role"))) { params.put("bd_group", manager.getString("manager_id")); if (analysis.getGroup_bd()>0){ @@ -118,9 +105,7 @@ public class DashboardController { @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); params.put("trade_type", trade_type); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); if (analysis.isOnlyGroup() && ManagerRole.BD_LEADER.hasRole(manager.getIntValue("role"))) { params.put("bd_group", manager.getString("manager_id")); if (analysis.getGroup_bd()>0){ @@ -134,9 +119,7 @@ public class DashboardController { @ManagerMapping("/trade_in_time") public List tradeInTime(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getTradeAnalysisInTime(params); } @@ -154,9 +137,7 @@ public class DashboardController { @ManagerMapping("/Total_platform_amount") public JSONObject getPlatformAmount(AnalysisBean analysis, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager){ JSONObject params = analysis.toParams(null); - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); return dashboardService.getPlatformAmount(params); } } 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 108d09593..2029c8870 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 @@ -32,8 +32,6 @@ public interface RetailAppService { void sign_out(JSONObject device); - void sendAppMessage(); - void sendOrderAppMessage(JSONObject order, int client_id); void sendRefundAppMessage(String refundAmount, JSONObject order); 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 bb6d1edd3..810aaa685 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 @@ -1,5 +1,42 @@ package au.com.royalpay.payment.manage.appclient.core.impls; +import java.math.BigDecimal; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TimeZone; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import javax.annotation.Resource; + +import org.apache.commons.lang3.RandomUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.commons.lang3.time.DateUtils; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.slf4j.LoggerFactory; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.Order; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; + import au.com.royalpay.payment.core.PaymentApi; import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; @@ -14,17 +51,27 @@ import au.com.royalpay.payment.manage.mappers.log.ClearingDetailAnalysisMapper; import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper; import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; -import au.com.royalpay.payment.manage.mappers.system.*; +import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientSettleDelayConfMapper; +import au.com.royalpay.payment.manage.mappers.system.CustomerMapper; +import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.notice.beans.NoticeInfo; import au.com.royalpay.payment.manage.notice.core.NoticeManage; import au.com.royalpay.payment.manage.notice.core.NoticePartner; +import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper; +import au.com.royalpay.payment.manage.pushMessage.JpushMessageHelper; +import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder; +import au.com.royalpay.payment.manage.pushMessage.bean.JpushMessage; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.manage.signin.core.impls.SignInAccountServiceImpl; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.tools.cms.RoyalPayCMSSupport; import au.com.royalpay.payment.tools.device.DeviceSupport; +import au.com.royalpay.payment.tools.device.message.AppMessage; +import au.com.royalpay.payment.tools.device.message.AppMsgSender; import au.com.royalpay.payment.tools.device.support.DeviceRegister; import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.exceptions.BadRequestException; @@ -35,37 +82,6 @@ import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.tools.utils.PageListUtils; import au.com.royalpay.payment.tools.utils.TimeZoneUtils; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.github.miemiedev.mybatis.paginator.domain.Order; -import com.github.miemiedev.mybatis.paginator.domain.PageBounds; -import com.github.miemiedev.mybatis.paginator.domain.PageList; -import com.notnoop.apns.APNS; -import com.notnoop.apns.ApnsService; -import org.apache.commons.lang3.RandomUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.time.DateFormatUtils; -import org.apache.commons.lang3.time.DateUtils; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; -import org.springframework.util.Assert; - -import javax.annotation.Resource; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; /** * Created by yishuqian on 28/03/2017. @@ -77,77 +93,64 @@ public class RetailAppServiceImp implements RetailAppService { private TransactionAnalysisMapper transactionAnalysisMapper; @Resource private TransactionMapper transactionMapper; - @Resource private ClientManager clientManager; - @Resource private NoticeManage noticeManage; - @Resource private NoticePartner noticePartner; - @Resource private CustomerAndOrdersStatisticsMapper customerAndOrdersStatisticsMapper; - @Resource private ClearingDetailMapper clearingDetailMapper; - @Resource private OrderMapper orderMapper; - @Resource private ClientAccountMapper clientAccountMapper; - @Resource private AppMessageLogMapper appMessageLogMapper; @Resource private SignInAccountService signInAccountService; - @Resource private CashbackService cashbackService; - @Resource private ClearingDetailAnalysisMapper clearingDetailAnalysisMapper; - @Resource private ClientSettleDelayConfMapper clientSettleDelayConfMapper; - @Resource private XPlanFundConfigServiceImpl xPlanFundConfigService; - @Resource private MerchantInfoProvider merchantInfoProvider; @Resource private RoyalPayCMSSupport royalPayCMSSupport; - @Resource private PaymentApi paymentApi; - @Resource private DeviceSupport deviceSupport; - @Resource private CustomerRelationAlipayMapper customerRelationAlipayMapper; @Resource private CustomerMapper customerMapper; - - @Value("classpath:apple_message_cert_dev.p12") - private org.springframework.core.io.Resource appleMessageFileDev; - @Value("classpath:apple_message_cert_product.p12") - private org.springframework.core.io.Resource appleMessageFileProduct; - @Value("${apple.message.apns.password}") - private String appleMessagePassword; + @Resource + private APNSMessageHelper apnsMessageHelper; @Resource private ClientDeviceTokenMapper clientDeviceTokenMapper; + @Resource + private JpushMessageHelper jpushMessageHelper; - private ThreadPoolExecutor sendingAppleMsgPool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue()); + private Map senderMap = new HashMap<>(); + + @Resource + public void setAppMsgSenders(AppMsgSender[] senders) { + Arrays.stream(senders).forEach(appMsgSender -> senderMap.put(appMsgSender.devType(), appMsgSender)); + } + private ThreadPoolExecutor sendingAppleMsgPool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue()); @Resource private CouponValidateService couponVerificationService; - //若app未传client_ids,检测是否包含子商户,若包含查询全部 + // 若app未传client_ids,检测是否包含子商户,若包含查询全部 private void setAllClientIds(JSONObject params, int clientId) { if (params.containsKey("client_ids")) { return; @@ -175,10 +178,10 @@ public class RetailAppServiceImp implements RetailAppService { params.put("client_id", client_id); res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); -// res.put("refund_amount", transactionAnalysisMapper.analysisRefundAmount(params)); + // res.put("refund_amount", transactionAnalysisMapper.analysisRefundAmount(params)); res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params)); res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params)); - //微信小程序不查询汇率 + // 微信小程序不查询汇率 if (!StringUtils.equals(device.getString("client_type"), "wxapp")) { res.put("rate", paymentApi.channelApi("Wechat").queryExchangeRateDecimal(client_id)); } @@ -266,7 +269,6 @@ public class RetailAppServiceImp implements RetailAppService { } } - @Override public JSONObject getClientSettlementLog(JSONObject device, AppQueryBean appQueryBean) { String clientType = device.getString("client_type"); @@ -280,7 +282,8 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject params = appQueryBean.toParams(); setAllClientIds(params, client_id); params.put("client_id", client_id); - PageList logs = clearingDetailMapper.listClientSettlementLog(params, new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit(), Order.formString("report_date.desc"))); + PageList logs = clearingDetailMapper.listClientSettlementLog(params, + new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit(), Order.formString("report_date.desc"))); return PageListUtils.buildPageListResult(logs); } @@ -354,11 +357,13 @@ public class RetailAppServiceImp implements RetailAppService { params.put("dev_id", device.getString("dev_id")); } params.put("client_id", client_id); - PageList orders = orderMapper.listOrdersByClients(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc"))); + 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<>(); for (JSONObject order : orders) { -// Date tradeDate = order.getDate("confirm_time") == null ? (order.getDate("transaction_time") == null ? order.getDate("create_time") : order.getDate("transaction_time")) : order.getDate("confirm_time"); + // Date tradeDate = order.getDate("confirm_time") == null ? (order.getDate("transaction_time") == null ? + // order.getDate("create_time") : order.getDate("transaction_time")) : order.getDate("confirm_time"); Calendar calendar = (Calendar) order.get("create_time"); String trade_date = DateFormatUtils.format(calendar, "yyyy-MM-dd"); String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss"); @@ -369,7 +374,7 @@ public class RetailAppServiceImp implements RetailAppService { TradeLogQuery date_query = new TradeLogQuery(); date_query.setDatefrom(re_date); date_query.setDateto(re_date); -// date_query.setStatus(OrderStatus.ALL); + // date_query.setStatus(OrderStatus.ALL); if (params.containsKey("client_ids")) { date_query.setClient_ids((String[]) params.get("client_ids")); } @@ -388,7 +393,7 @@ public class RetailAppServiceImp implements RetailAppService { query.setGateway_app("11"); String clientType = device.getString("client_type"); DeviceRegister register = deviceSupport.findRegister(clientType); - Assert.notNull(register,"Device is not registered"); + Assert.notNull(register, "Device is not registered"); int client_id = device.getIntValue("client_id"); JSONObject client = clientManager.getClientInfo(client_id); String timezone = client.getString("timezone"); @@ -455,31 +460,6 @@ public class RetailAppServiceImp implements RetailAppService { } - @Override - public void sendAppMessage() { - -// String p12Path = "D:/MbaikeDevCertificates.p12"; -// InputStream keyIns = appleMessageFile.getInputStream(); -// String password = "F1b5*ChJPp73"; - String pushToken = "719e4b7a7ed8b9000188440228437714d9dc67785f1791fae01234dae6a1570c"; - JSONObject order = new JSONObject(); - order.put("clearing_amount", 0.01); - order.put("client_id", 9); - order.put("client_moniker", "PINE"); - order.put("order_id", "9201704110348156694986"); - - try { - /**设置参数,发送数据**/ - InputStream keyIns = appleMessageFileProduct.getInputStream(); - ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build(); - String payload = APNS.newPayload().alertTitle("到账通知").alertBody("Hello,0.01AUD").badge(1).sound("default").customField("data", order).build(); - service.push(pushToken, payload); - System.out.println("推送信息已发送!"); - } catch (Exception e) { - logger.error("出错了:" + e.getMessage()); - } - } - @Override public void sendOrderAppMessage(final JSONObject order, int client_id) { logger.debug("sendOrderAppMessage-" + client_id + "-" + order.getString("order_id")); @@ -491,21 +471,32 @@ public class RetailAppServiceImp implements RetailAppService { return; } System.out.println("Device Token:" + token); - //todo 抽象发送信息接口,根据设备类型选择不同实现类 - JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "payment", token, order.getString("order_id")); + JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "payment", token, + order.getString("order_id")); try { order.put("send_type", "payment"); JSONObject type = new JSONObject(); type.put("send_type", "payment"); type.put("id", order.getString("order_id")); - sendAppleMessage(LocaleSupport.localeMessage("app.message.title.payment"), - LocaleSupport.localeMessage("app.message.body.payment") + order.getString("currency") + order.getDoubleValue("total_amount"), token, order, type); + AppMsgSender sender = senderMap.get(devToken.getString("client_type")); + if (token == null || sender == null) { + return; + } + JSONObject managerMsg = new JSONObject(); + managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.payment")); + managerMsg.put("body", + LocaleSupport.localeMessage("app.message.body.payment") + order.getString("currency") + order.getDoubleValue("total_amount")); + managerMsg.put("type", type); + managerMsg.put("data", order); + managerMsg.put("msgType", "payment"); + AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage(); + sender.sendMessage(appMessage, devToken); log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { logger.error("出错了:" + e.getMessage()); appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); - throw new ServerErrorException("Send App Message Failed", e); + throw new ServerErrorException("Send App "+devToken.getString("client_type")+" Failed", e); } }; sendingAppleMsgPool.execute(task); @@ -536,14 +527,26 @@ public class RetailAppServiceImp implements RetailAppService { return; } System.out.println("Device Token:" + token); - JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "refund", token, order.getString("order_id")); + JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "refund", token, + order.getString("order_id")); try { order.put("send_type", "refund"); JSONObject type = new JSONObject(); type.put("send_type", "refund"); type.put("id", order.getString("order_id")); - sendAppleMessage("Refund Message", - LocaleSupport.localeMessage("app.message.body.refund") + refundAmount, token, order, type); + + AppMsgSender sender = senderMap.get(devToken.getString("client_type")); + if (token == null || sender == null) { + return; + } + JSONObject managerMsg = new JSONObject(); + managerMsg.put("title", "Refund "+devToken.getString("client_type")+""); + managerMsg.put("body", LocaleSupport.localeMessage("app.message.body.refund") + refundAmount); + managerMsg.put("type", type); + managerMsg.put("data", order); + managerMsg.put("msgType", "refund"); + AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage(); + sender.sendMessage(appMessage, devToken); log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { @@ -567,7 +570,8 @@ public class RetailAppServiceImp implements RetailAppService { if (token == null) { continue; } - JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "notice", token, "notice_id:" + notice.getNotice_id()); + JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "notice", token, + "notice_id:" + notice.getNotice_id()); try { notice.setContent(null); JSONObject noticeObj = notice.toJson(); @@ -575,7 +579,19 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject type = new JSONObject(); type.put("send_type", "notice"); type.put("id", notice.getNotice_id()); - sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"), notice.getTitle(), token, noticeObj, type); + + AppMsgSender sender = senderMap.get(devToken.getString("client_type")); + if (token == null || sender == null) { + return; + } + JSONObject managerMsg = new JSONObject(); + managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.notice")); + managerMsg.put("body", notice.getTitle()); + managerMsg.put("type", type); + managerMsg.put("data", noticeObj); + managerMsg.put("msgType", "notice"); + AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage(); + sender.sendMessage(appMessage, devToken); log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { @@ -600,19 +616,32 @@ public class RetailAppServiceImp implements RetailAppService { if (token == null) { return; } - JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "cashback", token, order.getString("order_id") + "返现" + cashbackAmount); + JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "cashback", token, + order.getString("order_id") + "返现" + cashbackAmount); try { JSONObject type = new JSONObject(); type.put("send_type", "cashback"); type.put("id", order.getString("order_id")); - sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"), - LocaleSupport.localeMessage("app.message.body.cashback") + PlatformEnvironment.getEnv().getForeignCurrency() + " " + cashbackAmount, token, order, type); + + AppMsgSender sender = senderMap.get(devToken.getString("client_type")); + if (token == null || sender == null) { + return; + } + JSONObject managerMsg = new JSONObject(); + managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.notice")); + managerMsg.put("body", LocaleSupport.localeMessage("app.message.body.cashback") + PlatformEnvironment.getEnv().getForeignCurrency() + + " " + cashbackAmount); + managerMsg.put("type", type); + managerMsg.put("data", order); + managerMsg.put("msgType", "cashback"); + AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage(); + sender.sendMessage(appMessage, devToken); log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { logger.error("出错了:" + e.getMessage()); appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); - throw new ServerErrorException("Send App Message Failed", e); + throw new ServerErrorException("Send App "+devToken.getString("client_type")+" Failed", e); } } }); @@ -625,7 +654,8 @@ public class RetailAppServiceImp implements RetailAppService { String clearing_amount = log_clearing_detail.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_HALF_DOWN).toString(); String 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 + ")"); + 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); for (JSONObject devToken : tokens) { String token = devToken.getString("token"); @@ -633,24 +663,36 @@ public class RetailAppServiceImp implements RetailAppService { continue; } String log_clearing_detail_id = log_clearing_detail.getString("clear_detail_id"); - JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "clean", token, "本次清算" + log_clearing_detail_id + ",$" + clearing_amount + "(" + settle_date_from + "-" + settle_date_to + ")"); + JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "clean", token, + "本次清算" + log_clearing_detail_id + ",$" + clearing_amount + "(" + settle_date_from + "-" + settle_date_to + ")"); try { JSONObject type = new JSONObject(); type.put("send_type", "clean"); type.put("id", log_clearing_detail_id); - sendAppleMessage(LocaleSupport.localeMessage("app.message.title.clean"), - LocaleSupport.localeMessage("app.message.body.clean") + PlatformEnvironment.getEnv().getForeignCurrency() + " " + clearing_amount + " (" + settle_date_from + "-" + settle_date_to + ")", token, log_clearing_detail, type); + + AppMsgSender sender = senderMap.get(devToken.getString("client_type")); + if (token == null || sender == null) { + return; + } + JSONObject managerMsg = new JSONObject(); + managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.clean")); + managerMsg.put("body", LocaleSupport.localeMessage("app.message.body.clean") + PlatformEnvironment.getEnv().getForeignCurrency() + " " + + clearing_amount + " (" + settle_date_from + "-" + settle_date_to + ")"); + managerMsg.put("type", type); + managerMsg.put("data", log_clearing_detail); + managerMsg.put("msgType", "clean"); + AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage(); + sender.sendMessage(appMessage, devToken); log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { logger.error("出错了:" + e.getMessage()); appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); - throw new ServerErrorException("Send App Message Failed", e); + throw new ServerErrorException("Send App "+devToken.getString("client_type")+" Failed", e); } } } - @Override public void sendTransactionDailyMessage(JSONObject tradeInfo, int client_id) { String trade_date = tradeInfo.getString("trade_date"); @@ -663,51 +705,43 @@ public class RetailAppServiceImp implements RetailAppService { if (token == null) { continue; } - JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "daily_notice", token, "Trade Date:" + trade_date); + JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "daily_notice", token, + "Trade Date:" + trade_date); try { JSONObject type = new JSONObject(); type.put("send_type", "daily_notice"); type.put("id", trade_date); - sendAppleMessageDetail(LocaleSupport.localeMessage("app.message.title.daily_notice"), - trade_date + ": 总交易额 " + PlatformEnvironment.getEnv().getForeignCurrency() + total_amount + ", 订单数:" + total_orders + ", 付款人数:" + customers, token, tradeInfo, type); + apnsMessageHelper.sendAppleMessageDetail( + LocaleSupport.localeMessage("app.message.title.daily_notice"), trade_date + ": 总交易额 " + + PlatformEnvironment.getEnv().getForeignCurrency() + total_amount + ", 订单数:" + total_orders + ", 付款人数:" + customers, + token, tradeInfo, type); + AppMsgSender sender = senderMap.get(devToken.getString("client_type")); + if (token == null || sender == null) { + return; + } + JSONObject managerMsg = new JSONObject(); + managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.daily_notice")); + managerMsg.put("body", trade_date + ": 总交易额 " + + PlatformEnvironment.getEnv().getForeignCurrency() + total_amount + ", 订单数:" + total_orders + ", 付款人数:" + customers); + managerMsg.put("type", type); + managerMsg.put("data", tradeInfo); + managerMsg.put("msgType", "daily_notice"); + AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage(); + sender.sendMessage(appMessage, devToken); + + + + log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { logger.error("出错了:" + e.getMessage()); appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); - throw new ServerErrorException("Send App Message Failed", e); + throw new ServerErrorException("Send App "+devToken.getString("client_type")+" Failed", e); } } } - private void sendAppleMessage(String title, String body, String token, JSONObject data, JSONObject type) throws IOException { - /**设置参数,发送数据**/ - InputStream keyIns = appleMessageFileProduct.getInputStream(); - ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build(); - String payload = APNS.newPayload().alertTitle(title).alertBody(body).badge(1).sound("default").customField("data", data).customField("type", type).build(); - service.push(token, payload); - System.out.println("推送信息已发送!"); - } - - /** - * 可显示详情 - * - * @param title - * @param body - * @param token - * @param data - * @param type - * @throws IOException - */ - private void sendAppleMessageDetail(String title, String body, String token, JSONObject data, JSONObject type) throws IOException { - /**设置参数,发送数据**/ - InputStream keyIns = appleMessageFileProduct.getInputStream(); - ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build(); - String payload = APNS.newPayload().alertTitle(title).alertBody(body).category("myNotificationCategory").badge(1).sound("default").customField("data", data).customField("type", type).build(); - service.push(token, payload); - System.out.println("推送信息已发送!"); - } - @Override public void updateReadStatus(JSONObject device, String noticeId) { String clientType = device.getString("client_type"); @@ -747,7 +781,7 @@ 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); res.put("content", doc.html()); return res; } @@ -756,7 +790,7 @@ public class RetailAppServiceImp implements RetailAppService { public void changeAccountPassword(JSONObject device, ChangePwdBean change, String account_id) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - //JSONObject client = signInAccountService.getClient(account_id); + // JSONObject client = signInAccountService.getClient(account_id); if (!account_id.equals(device.getString("account_id"))) { throw new ForbiddenException("You have no permission"); } @@ -779,7 +813,7 @@ public class RetailAppServiceImp implements RetailAppService { Date now = new Date(); JSONObject res = merchantInfoProvider.clientCurrentRate(clientId, now, "Wechat"); JSONObject client = clientManager.getClientInfo(clientId); - Assert.notNull(client,"Client is null"); + Assert.notNull(client, "Client is null"); JSONObject[] channels = new JSONObject[3]; @@ -804,7 +838,7 @@ public class RetailAppServiceImp implements RetailAppService { Date now = new Date(); JSONObject res = merchantInfoProvider.clientCurrentRate(clientId, now, "Wechat"); JSONObject client = clientManager.getClientInfo(clientId); - Assert.notNull(client,"Client is null"); + Assert.notNull(client, "Client is null"); ArrayList channels = new ArrayList<>(); if (client.getBigDecimal("customer_surcharge_rate") != null) { @@ -889,7 +923,7 @@ public class RetailAppServiceImp implements RetailAppService { } res.put("data", new_acts); } - //手续费返还活动 + // 手续费返还活动 List acts = (List) res.get("data"); for (JSONObject act : acts) { if (StringUtils.isNotBlank(act.getString("page_keywords")) && act.getString("page_keywords").equalsIgnoreCase("native")) { @@ -923,7 +957,7 @@ public class RetailAppServiceImp implements RetailAppService { String newAppVersion = PlatformEnvironment.getEnv().getNewVersion(); Boolean isUpdate = PlatformEnvironment.getEnv().isAppUpdate(); String updateContent = PlatformEnvironment.getEnv().getAppUpdateContent(); - int update_type = 0;//0:不更新 1:更新 2:强制更新 + int update_type = 0;// 0:不更新 1:更新 2:强制更新 if (newAppVersion.compareToIgnoreCase(version) > 0) { update_type = 1; if (isUpdate) { @@ -943,7 +977,6 @@ 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) { JSONObject log = new JSONObject(); log.put("dev_id", dev_id); @@ -1078,7 +1111,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("show", true); res.put("interest_rate", xPlanFundConfigService.configuration().getInterestRate().setScale(2, BigDecimal.ROUND_DOWN)); } @@ -1086,7 +1119,6 @@ public class RetailAppServiceImp implements RetailAppService { return res; } - @Override public void sendMassageByCode(final JSONObject params) { try { @@ -1095,7 +1127,7 @@ public class RetailAppServiceImp implements RetailAppService { if (params.getString("type").equals("Merchant")) { for (String partner_code : codes) { JSONObject client = clientManager.getClientInfoByMoniker(partner_code); - Assert.notNull(client,"Client is null"); + Assert.notNull(client, "Client is null"); List tokens = clientDeviceTokenMapper.listTokensByClient_id(client.getInteger("client_id")); if (null != tokens && tokens.size() > 0) { for (final JSONObject devToken : tokens) { @@ -1103,7 +1135,8 @@ public class RetailAppServiceImp implements RetailAppService { sendingAppleMsgPool.execute(new Runnable() { @Override public void run() { - JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "dev", token, "Param:partner_code,自定义推送消息"); + JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "dev", token, + "Param:partner_code,自定义推送消息"); sending(token, params, log); } }); @@ -1135,19 +1168,30 @@ public class RetailAppServiceImp implements RetailAppService { } public void sending(String devToken, JSONObject params, JSONObject log) { - try { - sendAppleMessage(params.getString("title"), params.getString("content"), devToken, new JSONObject(), new JSONObject()); + JSONObject devTokenJson = new JSONObject(); + devTokenJson.put("token", devToken); + AppMsgSender sender = senderMap.get(params.getString("client_type")); + if (devToken == null || sender == null) { + return; + } + JSONObject managerMsg = new JSONObject(); + managerMsg.put("title", params.getString("title")); + managerMsg.put("body", params.getString("content")); + managerMsg.put("type", new JSONObject()); + managerMsg.put("data", new JSONObject()); + managerMsg.put("msgType", "payment"); + AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage(); + sender.sendMessage(appMessage, devTokenJson); log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { logger.error("出错了:" + e.getMessage()); appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); - throw new ServerErrorException("Send App Message Failed", e); + throw new ServerErrorException("Send App "+params.getString("client_type")+" Failed", e); } } - @Override public JSONObject getCoupons(JSONObject device, int page, int limit) { String clientType = device.getString("client_type"); @@ -1207,4 +1251,5 @@ public class RetailAppServiceImp implements RetailAppService { String regex = "[A-Za-z0-9]{8}"; return str.matches(regex); } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/bean/Message.java b/src/main/java/au/com/royalpay/payment/manage/dev/bean/Message.java index 2ded3cb61..b4d3ce22c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/bean/Message.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/bean/Message.java @@ -16,7 +16,7 @@ public class Message { public String title; @NotEmpty(message = "content can not be null") public String content; - + public String client_type; public JSONObject insertObject() { JSONObject res = (JSONObject) JSON.toJSON(this); return res; @@ -53,4 +53,12 @@ public class Message { public void setContent(String content) { this.content = content; } + + public String getClient_type() { + return client_type; + } + + public void setClient_type(String client_type) { + this.client_type = client_type; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/bean/SendWechatMessage.java b/src/main/java/au/com/royalpay/payment/manage/dev/bean/SendWechatMessage.java index 61975d7b6..3e2529319 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/bean/SendWechatMessage.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/bean/SendWechatMessage.java @@ -24,6 +24,7 @@ public class SendWechatMessage { private boolean bdleader; private boolean riskmanager; private boolean guest; + private boolean orgmanager; public JSONObject insertObject() { JSONObject res = (JSONObject) JSON.toJSON(this); @@ -157,4 +158,12 @@ public class SendWechatMessage { public void setGuest(boolean guest) { this.guest = guest; } + + public boolean isOrgmanager() { + return orgmanager; + } + + public void setOrgmanager(boolean orgmanager) { + this.orgmanager = orgmanager; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/WechatMessageServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/WechatMessageServiceImpl.java index e49e5769f..b31e7f614 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/WechatMessageServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/core/impl/WechatMessageServiceImpl.java @@ -117,6 +117,9 @@ public class WechatMessageServiceImpl implements WechatMessageService { if(sendWechatMessage.isDirector()){ set = getOpenIdSet(set, ManagerRole.DIRECTOR.getMask()); } + if(sendWechatMessage.isOrgmanager()){ + set = getOpenIdSet(set, ManagerRole.ORG_MANAGER.getMask()); + } for(String open_id : set){ object.put("open_id",open_id); sendWecharMessageByOpenId(object); diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/OrgMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/OrgMapper.java index 59cacde68..04ae18528 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/OrgMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/OrgMapper.java @@ -25,6 +25,10 @@ public interface OrgMapper { List listOrgs(@Param("type") int type, PageBounds order); + List listOrgsWithParent(JSONObject params); + + List listOrgsWithChid(JSONObject params); + @AutoSql(type = SqlType.INSERT) void saveOrg(JSONObject org); @@ -41,4 +45,6 @@ public interface OrgMapper { JSONObject findOrgByBDId(@Param("bd_id") int bd_id); PageList listOrgWithPages(JSONObject paraams, PageBounds order); + + List listOrgAndChild(@Param("org_id") int org_id); } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/PartnerQuery.java b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/PartnerQuery.java index d89677a80..44643a4bc 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/PartnerQuery.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/PartnerQuery.java @@ -22,6 +22,7 @@ public class PartnerQuery { private String short_name; private String sub_merchant_id; private String org_id; + private String org_ids; private Integer bd; private String business_structure; private String industry; @@ -117,6 +118,9 @@ public class PartnerQuery { if (org_id != null) { param.put("org_id", org_id); } + if (org_ids != null) { + param.put("org_ids", org_ids); + } if (bd != null) { param.put("bd_user", bd); } @@ -440,4 +444,12 @@ public class PartnerQuery { public boolean isIs_valid() { return is_valid; } + + public String getOrg_ids() { + return org_ids; + } + + public void setOrg_ids(String org_ids) { + this.org_ids = org_ids; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 62364635e..a0051133a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -10,25 +10,8 @@ import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientApplyMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientAuditProcessMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientDeviceMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; -import au.com.royalpay.payment.manage.mappers.system.CommoditiesMapper; -import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; -import au.com.royalpay.payment.manage.mappers.system.OrgMapper; -import au.com.royalpay.payment.manage.merchants.beans.ActivityPosterBuilder; -import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo; -import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo; -import au.com.royalpay.payment.manage.merchants.beans.ClientRateConfig; -import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo; -import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; -import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery; +import au.com.royalpay.payment.manage.mappers.system.*; +import au.com.royalpay.payment.manage.merchants.beans.*; import au.com.royalpay.payment.manage.merchants.core.ClientComplyValidator; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.notice.core.MailService; @@ -56,22 +39,16 @@ import au.com.royalpay.payment.tools.merchants.qrboard.QRBoard; import au.com.royalpay.payment.tools.merchants.qrboard.QRBoardProvider; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.PartnerRole; -import au.com.royalpay.payment.tools.utils.ImageUtils; -import au.com.royalpay.payment.tools.utils.PageListUtils; -import au.com.royalpay.payment.tools.utils.PasswordUtils; -import au.com.royalpay.payment.tools.utils.PdfUtils; -import au.com.royalpay.payment.tools.utils.QRCodeUtils; -import au.com.royalpay.payment.tools.utils.TimeZoneUtils; +import au.com.royalpay.payment.tools.utils.*; import au.com.royalpay.payment.tools.websocket.notify.PartnerPageEvent; - +import cn.yixblog.platform.http.HttpRequestGenerator; +import cn.yixblog.platform.http.HttpRequestResult; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; -import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; - import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; @@ -93,34 +70,22 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.thymeleaf.context.Context; import org.thymeleaf.spring4.SpringTemplateEngine; +import javax.annotation.Resource; +import javax.imageio.ImageIO; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; import java.awt.*; import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; +import java.io.*; import java.math.BigDecimal; import java.net.URISyntaxException; import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; +import java.util.*; import java.util.List; -import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import javax.annotation.Resource; -import javax.imageio.ImageIO; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletResponse; - -import cn.yixblog.platform.http.HttpRequestGenerator; -import cn.yixblog.platform.http.HttpRequestResult; - import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission; /** @@ -249,7 +214,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new InvalidShortIdException(); } - checkOrgPermission(manager, client); + checkClientOrg(manager, client); client.put("show_all_permission", true); int role = manager != null ? manager.getIntValue("role") : 0; if (manager != null) { @@ -309,6 +274,19 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid return client; } + private void checkClientOrg(JSONObject manager, JSONObject client) { + if (manager.getInteger("org_id")!=null){ + JSONObject org = orgMapper.findOne(client.getIntValue("org_id")); + if (org.getInteger("parent_org_id")!=null){ + if (org.getIntValue("parent_org_id")!=manager.getIntValue("org_id")){ + throw new ForbiddenException("The org of client is not belong to you"); + } + }else { + checkOrgPermission(manager, client); + } + } + } + @Override public JSONObject getClientDetailById(int clientId) { JSONObject client = getClientInfo(clientId); @@ -327,8 +305,18 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid params.put("bd_user", manager.getString("manager_id")); } } + + if(params.getString("org_id") != null){ + if(params.getString("org_ids") == null){ + orgIds(params,Integer.parseInt(params.getString("org_id"))); + }else { + params.put("org_id",params.getString("org_ids")); + params.remove("org_ids"); + } + } + JSONObject org = null; if (params.getString("org_id") != null) { - JSONObject org = orgMapper.findOne(params.getIntValue("org_id")); + org = orgMapper.findOne(params.getIntValue("org_id")); if (org.getIntValue("type") == 1) { params.put("referrer_id", org.getString("org_id")); params.remove("org_id"); @@ -336,7 +324,18 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } int orgId = manager.getIntValue("org_id"); if (orgId > 0) { - params.put("org_id", orgId); + if(params.getString("org_ids") == null){ + JSONObject org2 = orgMapper.findOne(orgId); + if(org2.getString("parent_org_id") != null){ + params.put("org_id",orgId); + }else { + params.put("org_id",orgId); + orgIds(params,orgId); + } + }else { + params.put("org_id", params.getIntValue("org_ids")); + params.remove("org_ids"); + } } String tempSubMchId = sysConfigManager.getSysConfig().getString("temp_sub_mch_id"); String tempSubMchSource = sysConfigManager.getSysConfig().getString("temp_sub_mch_id_source"); @@ -361,6 +360,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } return PageListUtils.buildPageListResult(partners); } + private void orgIds(JSONObject params,int orgId){ + JSONObject param = new JSONObject(); + param.put("parent_org_id",params.getString("org_id")); + param.put("type",0); + List orgIds = new ArrayList<>(); + List childOrgs = orgMapper.listOrgsWithChid(param); + if(childOrgs.size() > 0){ + for(JSONObject object : childOrgs ){ + orgIds.add(object.getIntValue("org_id")); + } + orgIds.add(orgId); + params.put("org_ids",orgIds); + params.remove("org_id"); + } + } @Override public List listPartners(JSONObject manager, PartnerQuery query) { @@ -1387,7 +1401,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new InvalidShortIdException(); } - checkOrgPermission(manager, client); + checkClientOrg(manager,client); JSONObject params = new JSONObject(); params.put("client_id", client.getIntValue("client_id")); params.put("is_valid", "1"); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index 35d9091c2..f9d090a2c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -477,4 +477,9 @@ public class PartnerManageController { public void wechatCcompliancePermission(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { clientManager.switchPermission(manager, clientMoniker, "wechat_compliance", pass.getBooleanValue("allow")); } + + @ManagerMapping(value = "/{clientMoniker}/local_merchant_permission",method = RequestMethod.PUT,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN}) + public void localMerchantPermission(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.switchPermission(manager, clientMoniker, "local_merchant", pass.getBooleanValue("allow")); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java index 86be29bc4..3eda2a10d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/organizations/beans/OrgInfo.java @@ -10,7 +10,7 @@ import org.hibernate.validator.constraints.NotEmpty; public class OrgInfo { @NotEmpty private String name; - private int type = 0; + private String type; private String logo; @NotEmpty private String location; @@ -32,6 +32,8 @@ public class OrgInfo { private String search_text; private int page = 1; private int limit = 10; + private String parent_org_id; + private String org_id; public JSONObject toJsonParam() { JSONObject param = new JSONObject(); @@ -44,9 +46,15 @@ public class OrgInfo { if (StringUtils.isNotBlank(search_text)) { param.put("search_text", search_text); } - if (StringUtils.isNotBlank(String.valueOf(type))){ + if (type != null){ param.put("type", type); } + if (StringUtils.isNotBlank(parent_org_id)){ + param.put("parent_org_id", parent_org_id); + } + if (StringUtils.isNotBlank(org_id)){ + param.put("org_id", org_id); + } return param; } @@ -126,11 +134,11 @@ public class OrgInfo { this.rate_value = rate_value; } - public int getType() { + public String getType() { return type; } - public void setType(int type) { + public void setType(String type) { this.type = type; } @@ -205,4 +213,20 @@ public class OrgInfo { public void setLimit(int limit) { this.limit = limit; } + + public String getParent_org_id() { + return parent_org_id; + } + + public void setParent_org_id(String parent_org_id) { + this.parent_org_id = parent_org_id; + } + + public String getOrg_id() { + return org_id; + } + + public void setOrg_id(String org_id) { + this.org_id = org_id; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgManager.java b/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgManager.java index 006eb8acc..d3f35d221 100644 --- a/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/organizations/core/OrgManager.java @@ -11,9 +11,11 @@ import java.util.List; public interface OrgManager { List listOrgs(boolean detail); - JSONObject listAllOrgs(OrgInfo orgInfo); + List listOrgsWithChid(JSONObject manager,OrgInfo orgInfo); - JSONObject getOrgDetail(int orgId); + JSONObject listAllOrgs(OrgInfo orgInfo,JSONObject manager); + + JSONObject getOrgDetail(int orgId,JSONObject manager); JSONObject saveNewOrg(OrgInfo org); @@ -25,4 +27,5 @@ public interface OrgManager { List listAllOrg(); + JSONObject checkOrg(JSONObject manager, JSONObject params); } diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/core/impls/OrgManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/organizations/core/impls/OrgManagerImpl.java index 11cda86db..658f5f7fa 100644 --- a/src/main/java/au/com/royalpay/payment/manage/organizations/core/impls/OrgManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/organizations/core/impls/OrgManagerImpl.java @@ -3,16 +3,23 @@ package au.com.royalpay.payment.manage.organizations.core.impls; import au.com.royalpay.payment.manage.mappers.system.OrgMapper; import au.com.royalpay.payment.manage.organizations.beans.OrgInfo; import au.com.royalpay.payment.manage.organizations.core.OrgManager; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import au.com.royalpay.payment.tools.exceptions.ForbiddenException; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.utils.PageListUtils; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; /** * Created by yixian on 2016-10-18. @@ -29,7 +36,36 @@ public class OrgManagerImpl implements OrgManager { } @Override - public JSONObject listAllOrgs(OrgInfo orgInfo) { + public List listOrgsWithChid(JSONObject manager,OrgInfo orgInfo) { + JSONObject params = new JSONObject(); + params.put("type",0); + List listOrgsByChild = orgMapper.listOrgsWithChid(params); + if(orgInfo.getOrg_id() != null){ + params.put("org_id", orgInfo.getOrg_id()); + }else { + if (manager.getInteger("org_id") != null) { + params.put("org_id", manager.getIntValue("org_id")); + } + } + List listOrgs = orgMapper.listOrgsWithParent(params); + List orgs = new ArrayList<>(); + for(JSONObject org : listOrgs){ + org.put("type",org.getString("name")); + orgs.add(org); + for(JSONObject orgChild : listOrgsByChild){ + if(org.getIntValue("org_id") == orgChild.getIntValue("parent_org_id")){ + orgChild.put("type",org.getString("name")); + orgs.add(orgChild); + } + } + } + return orgs; + } + + + + @Override + public JSONObject listAllOrgs(OrgInfo orgInfo,JSONObject manager) { /* PageBounds sort = new PageBounds(Order.formString("sort_no.asc")); return orgMapper.listsOrgWithDetail(sort);*/ JSONObject params = orgInfo.toJsonParam(); @@ -38,7 +74,7 @@ public class OrgManagerImpl implements OrgManager { } @Override - public JSONObject getOrgDetail(int orgId) { + public JSONObject getOrgDetail(int orgId,JSONObject manager) { return orgMapper.findOne(orgId); } @@ -86,4 +122,30 @@ public class OrgManagerImpl implements OrgManager { return listAllOrgs; } + @Override + public JSONObject checkOrg(JSONObject manager, JSONObject params){ + if (params.getString("org_id")==null){ + if (manager.getInteger("org_id")!=null){ + List orgs = orgMapper.listOrgAndChild(manager.getIntValue("org_id")); + if (orgs.size()>1){ + List orgIds = orgs.stream().map(org->org.getIntValue("org_id")).collect(Collectors.toList()); + params.put("org_ids",orgIds); + }else { + params.put("org_id",manager.getIntValue("org_id")); + } + } + }else { + if (manager.getInteger("org_id")!=null){ + List orgs = orgMapper.listOrgAndChild(manager.getIntValue("org_id")); + List orgIds = orgs.stream().map(org->org.getIntValue("org_id")).collect(Collectors.toList()); + if (!orgIds.contains(params.getString("org_id"))){ + throw new ForbiddenException("You have no permission to query the org"); + } + + } + + } + return params; + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/organizations/web/OrgManageController.java b/src/main/java/au/com/royalpay/payment/manage/organizations/web/OrgManageController.java index 3f0b7faa3..f86ff0da7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/organizations/web/OrgManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/organizations/web/OrgManageController.java @@ -3,9 +3,11 @@ package au.com.royalpay.payment.manage.organizations.web; import au.com.royalpay.payment.manage.organizations.beans.OrgInfo; import au.com.royalpay.payment.manage.organizations.core.OrgManager; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.manage.permission.manager.RequireManager; import au.com.royalpay.payment.tools.http.HttpUtils; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; @@ -29,10 +31,16 @@ public class OrgManageController { return orgManager.listOrgs(detail); } + @RequestMapping(value = "/orgChild",method = RequestMethod.GET) + @RequireManager + public List listOrgsWithChid(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,OrgInfo orgInfo) { + return orgManager.listOrgsWithChid(manager,orgInfo); + } + @RequestMapping(value = "/listsOrg", method = RequestMethod.GET) @RequireManager - public JSONObject listsOrg(OrgInfo orgInfo) { - return orgManager.listAllOrgs(orgInfo); + public JSONObject listsOrg(OrgInfo orgInfo,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + return orgManager.listAllOrgs(orgInfo,manager); } @RequestMapping(value = "/list_all_Org", method = RequestMethod.GET) @@ -41,15 +49,15 @@ public class OrgManageController { return orgManager.listAllOrg(); } - @ManagerMapping(method = RequestMethod.POST, role = ManagerRole.ADMIN) + @ManagerMapping(method = RequestMethod.POST, role = {ManagerRole.ADMIN}) public JSONObject saveOrg(@RequestBody @Valid OrgInfo org, Errors errors) { HttpUtils.handleValidErrors(errors); return orgManager.saveNewOrg(org); } - @ManagerMapping(value = "/{orgId}", method = RequestMethod.GET, role = ManagerRole.ADMIN) - public JSONObject getOrgDetail(@PathVariable int orgId) { - return orgManager.getOrgDetail(orgId); + @ManagerMapping(value = "/{orgId}", method = RequestMethod.GET, role = {ManagerRole.ADMIN}) + public JSONObject getOrgDetail(@PathVariable int orgId,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + return orgManager.getOrgDetail(orgId,manager); } @ManagerMapping(value = "/{orgId}", method = RequestMethod.PUT) diff --git a/src/main/java/au/com/royalpay/payment/manage/pushMessage/APNSMessageHelper.java b/src/main/java/au/com/royalpay/payment/manage/pushMessage/APNSMessageHelper.java new file mode 100644 index 000000000..3dffffcd3 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/pushMessage/APNSMessageHelper.java @@ -0,0 +1,46 @@ +package au.com.royalpay.payment.manage.pushMessage; + +import com.alibaba.fastjson.JSONObject; +import com.notnoop.apns.APNS; +import com.notnoop.apns.ApnsService; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Created by wangning on 2018/1/3. + */ +@Service +public class APNSMessageHelper { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Value("classpath:apple_message_cert_dev.p12") + private org.springframework.core.io.Resource appleMessageFileDev; + @Value("classpath:apple_message_cert_product.p12") + private org.springframework.core.io.Resource appleMessageFileProduct; + @Value("${apple.message.apns.password}") + private String appleMessagePassword; + + public void sendAppleMessage(String title, String body, String token, JSONObject data, JSONObject type) throws IOException { + /**设置参数,发送数据**/ + InputStream keyIns = appleMessageFileProduct.getInputStream(); + ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build(); + String payload = APNS.newPayload().alertTitle(title).alertBody(body).badge(1).sound("default").customField("data", data).customField("type", type).build(); + service.push(token, payload); + logger.debug("推送信息已发送!"); + } + + public void sendAppleMessageDetail(String title, String body, String token, JSONObject data, JSONObject type) throws IOException { + /**设置参数,发送数据**/ + InputStream keyIns = appleMessageFileProduct.getInputStream(); + ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build(); + String payload = APNS.newPayload().alertTitle(title).alertBody(body).category("myNotificationCategory").badge(1).sound("default").customField("data", data).customField("type", type).build(); + service.push(token, payload); + logger.debug("推送信息已发送!"); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/pushMessage/JpushMessageHelper.java b/src/main/java/au/com/royalpay/payment/manage/pushMessage/JpushMessageHelper.java new file mode 100644 index 000000000..337233c8e --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/pushMessage/JpushMessageHelper.java @@ -0,0 +1,97 @@ +package au.com.royalpay.payment.manage.pushMessage; + +import au.com.royalpay.payment.manage.pushMessage.bean.JpushMessage; + +import com.alibaba.fastjson.JSONObject; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.util.Map; + +import cn.jiguang.common.resp.APIConnectionException; +import cn.jiguang.common.resp.APIRequestException; +import cn.jpush.api.JPushClient; +import cn.jpush.api.push.model.Options; +import cn.jpush.api.push.model.Platform; +import cn.jpush.api.push.model.PushPayload; +import cn.jpush.api.push.model.audience.Audience; +import cn.jpush.api.push.model.notification.AndroidNotification; +import cn.jpush.api.push.model.notification.Notification; + +/** + * Created by wangning on 2018/1/3. + */ +@Service +public class JpushMessageHelper { + Logger logger = LoggerFactory.getLogger(getClass()); + + // 推送文本最大长度 + private final Integer NOTIFICATION_MAX_LENGTH = 54; + private static JPushClient client = null; + + private JPushClient getPush() { + if (client == null) { + client = new JPushClient("c235e93f6b91abd72ca5d74e", "c235e93f6b91abd72ca5d74e"); + } + return client; + } + + public void sendAppleMessage(String title, String body, String token, JSONObject data, JSONObject type) throws IOException, APIConnectionException, APIRequestException { + JPushClient jPushClient= getPush(); + JpushMessage jpushMessage = new JpushMessage(); + jpushMessage.setTitle(title); + jpushMessage.setText(body); + JSONObject param = new JSONObject(); + param.put("data",data); + param.put("type",type); + jpushMessage.setParams(param); + PushPayload pushPayload = generateSinglePayload(token,jpushMessage); + jPushClient.sendPush(pushPayload); + } + + private PushPayload generateSinglePayload(String alias, JpushMessage pushMessage) { + Notification notify = getNotify(pushMessage); + return PushPayload.newBuilder().setPlatform(Platform.android()).setAudience(Audience.alias(alias)).setNotification(notify) + // 设置离线时长 + .setOptions(Options.newBuilder().setTimeToLive(60 * 60 * 4).build()).build(); + } + + private Notification getNotify(JpushMessage pushMessage) { + String alert = getText(pushMessage); + return Notification.newBuilder().addPlatformNotification( + AndroidNotification.newBuilder().setTitle(pushMessage.getTitle()).setAlert(alert).addExtras(getExtra(pushMessage)).build()).build(); + } + + private String getText(JpushMessage pushMessage) { + String text = pushMessage.getText(); + int length = text.length(); + int trueLength = 0; + String cutString = ""; + for (int i = 0; i < length; i++) { + char c = text.charAt(i); + + if (c < 0 || c > 128) { + // 汉字 3个字符 + trueLength += 3; + } else { + // 英文等 1个字符 + trueLength++; + } + + cutString += c; + if (trueLength >= NOTIFICATION_MAX_LENGTH) { + cutString += "..."; + break; + } + } + return cutString; + } + + private Map getExtra(JpushMessage message) { + Map map = message.getParams(); + return map; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/pushMessage/bean/AppManagerMessageBuilder.java b/src/main/java/au/com/royalpay/payment/manage/pushMessage/bean/AppManagerMessageBuilder.java new file mode 100644 index 000000000..f008f7d6d --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/pushMessage/bean/AppManagerMessageBuilder.java @@ -0,0 +1,22 @@ +package au.com.royalpay.payment.manage.pushMessage.bean; + +import au.com.royalpay.payment.tools.device.message.AppMessage; +import au.com.royalpay.payment.tools.device.message.AppMessageBuilder; + +import com.alibaba.fastjson.JSONObject; + +/** + * Created by wangning on 08/01/2018. + */ +public class AppManagerMessageBuilder implements AppMessageBuilder { + private JSONObject managerMsg; + + public AppManagerMessageBuilder(JSONObject managerMsg) { + this.managerMsg = managerMsg; + } + + @Override + public AppMessage buildMessage() { + return new AppMessage(managerMsg.getString("msgType"), managerMsg.getString("title"), managerMsg.getString("body")).setTypeData(managerMsg.getJSONObject("type")).setData(managerMsg.getJSONObject("data")); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/pushMessage/bean/JpushMessage.java b/src/main/java/au/com/royalpay/payment/manage/pushMessage/bean/JpushMessage.java new file mode 100644 index 000000000..b74e8a993 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/pushMessage/bean/JpushMessage.java @@ -0,0 +1,44 @@ +package au.com.royalpay.payment.manage.pushMessage.bean; + +import com.alibaba.fastjson.JSONObject; + +public class JpushMessage implements java.io.Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 消息标题 + */ + private String title; + + /** + * 消息内容 + */ + private String text; + + private JSONObject params; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public JSONObject getParams() { + return params; + } + + public void setParams(JSONObject params) { + this.params = params; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/beans/ManagerInfo.java b/src/main/java/au/com/royalpay/payment/manage/signin/beans/ManagerInfo.java index 3d62ee532..41eb051e3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/beans/ManagerInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/beans/ManagerInfo.java @@ -37,6 +37,7 @@ public class ManagerInfo { private boolean bdleader; private boolean riskmanager; private boolean guest; + private boolean orgmanager; @JSONField(name = "org_id") private Integer orgId; @@ -101,6 +102,9 @@ public class ManagerInfo { if (guest){ role |= ManagerRole.GUEST.getMask(); } + if (orgmanager){ + role |= ManagerRole.ORG_MANAGER.getMask(); + } account.put("role", role); if (insert) { account.put("username", getUsername()); @@ -260,4 +264,12 @@ public class ManagerInfo { public void setGuest(boolean guest) { this.guest = guest; } + + public boolean isOrgmanager() { + return orgmanager; + } + + public void setOrgmanager(boolean orgmanager) { + this.orgmanager = orgmanager; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java index 4598f9434..9708e6b27 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/ManagerAccountServiceImpl.java @@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.signin.core.impls; import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper; import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; +import au.com.royalpay.payment.manage.mappers.system.OrgMapper; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.manage.signin.beans.ManagerInfo; import au.com.royalpay.payment.manage.signin.core.ManagerAccountsService; @@ -22,6 +23,9 @@ import java.util.List; public class ManagerAccountServiceImpl implements ManagerAccountsService { @Resource private ManagerMapper managerMapper; + + @Resource + private OrgMapper orgMapper; @Resource private FinancialBDConfigMapper financialBDConfigMapper; @@ -46,6 +50,7 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { manager.put("bdleader", ManagerRole.BD_LEADER.hasRole(role)); manager.put("riskmanager", ManagerRole.RISK_MANAGER.hasRole(role)); manager.put("guest", ManagerRole.GUEST.hasRole(role)); + manager.put("orgmanager", ManagerRole.ORG_MANAGER.hasRole(role)); } return managers; } @@ -88,7 +93,7 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { @Override public void disable(String userId, JSONObject loginManager) { JSONObject manager = managerMapper.findById(userId); - if (!ManagerRole.ADMIN.hasRole(loginManager.getIntValue("role"))) { + if (!ManagerRole.ADMIN.hasRole(loginManager.getIntValue("role"))){ if (manager.getIntValue("org_id") != loginManager.getIntValue("org_id")) { throw new BadRequestException("You cannot disable accounts belong to other organizations"); } @@ -117,4 +122,5 @@ public class ManagerAccountServiceImpl implements ManagerAccountsService { public JSONObject getBDConfig(String bd_id){ return financialBDConfigMapper.getBdConfig(bd_id); } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java b/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java index 2d0aad18b..06c607702 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/web/ManagerAccountsController.java @@ -1,5 +1,6 @@ package au.com.royalpay.payment.manage.signin.web; +import au.com.royalpay.payment.manage.organizations.core.OrgManager; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.manage.permission.manager.RequireManager; @@ -25,6 +26,8 @@ import java.util.Map; public class ManagerAccountsController { @Resource private ManagerAccountsService managerAccountsService; + @Resource + private OrgManager orgManager; // @RequestMapping(method = RequestMethod.GET) // @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER}) @@ -48,11 +51,14 @@ public class ManagerAccountsController { @ManagerMapping(value = "/roles/bd_user", method = RequestMethod.GET) public List listBDUsers(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager) { - return managerAccountsService.listBDUsers(loginManager); + JSONObject params = new JSONObject(); + orgManager.checkOrg(loginManager,params); + return managerAccountsService.listBDUsers(params); } @ManagerMapping(value = "/roles/org_bd_user", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.ACCOUNT_MANAGER}) - public List listOrgBDUsers(@RequestParam Map map) { - return managerAccountsService.listBDUsers((JSONObject) JSON.toJSON(map)); + public List listOrgBDUsers(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject loginManager,@RequestParam Map map) { + JSONObject params = (JSONObject) JSON.toJSON(map); + return managerAccountsService.listBDUsers(params); } @ManagerMapping(value = "/{userId}", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.ACCOUNT_MANAGER}) diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/beans/TradeLogQuery.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/beans/TradeLogQuery.java index 6773cbb08..d21fded04 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/beans/TradeLogQuery.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/beans/TradeLogQuery.java @@ -36,6 +36,7 @@ public class TradeLogQuery { private int trans_type; private boolean onlyGroup = false; private int group_bd; + private String org_id; public JSONObject toParams(String timezone) { JSONObject params = new JSONObject(); @@ -91,6 +92,9 @@ public class TradeLogQuery { if (getDev_id() != null) { params.put("dev_id", getDev_id()); } + if (org_id != null && org_id != "ALL") { + params.put("org_id", org_id); + } return params; } @@ -214,4 +218,12 @@ public class TradeLogQuery { public void setChannel(PayChannel channel) { this.channel = channel; } + + public String getOrg_id() { + return org_id; + } + + public void setOrg_id(String org_id) { + this.org_id = org_id; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java index 6848bd064..4f2ab89ab 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java @@ -18,7 +18,9 @@ import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper; +import au.com.royalpay.payment.manage.mappers.system.OrgMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; +import au.com.royalpay.payment.manage.organizations.core.OrgManager; import au.com.royalpay.payment.manage.tradelog.beans.PreRefundQueryBean; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; @@ -119,6 +121,9 @@ public class TradeLogServiceImpl implements TradeLogService { @Resource private ClientCustomersMapper clientCustomersMapper; + @Resource + private OrgManager orgManager; + // @Value("classpath:/jasper/trans_flow.jasper") // @Value("classpath:/jasper/trans_flow_new.jasper") @Value("classpath:/jasper/partner_invoice.jasper") @@ -175,9 +180,7 @@ public class TradeLogServiceImpl implements TradeLogService { params.put("bd_group_bd", query.getGroup_bd()); } } - if (manager.getInteger("org_id") != null) { - params.put("org_id", manager.getIntValue("org_id")); - } + orgManager.checkOrg(manager,params); PageList logs = orderMapper.listOrders(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc"))); JSONObject result = PageListUtils.buildPageListResult(logs); JSONObject analysis = orderMapper.analysisOrders(params); @@ -185,6 +188,8 @@ public class TradeLogServiceImpl implements TradeLogService { return result; } + + @Override public List listOrderRefunds(String orderId, String timezone) { List refunds = refundMapper.listOrderRefunds(orderId, new PageBounds(Order.formString("create_time.desc"))); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 1626209c0..40af310fa 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -77,7 +77,7 @@ app.settlement.email-cc=leo.huang@royalpay.com.au app.mpsupport.appid=royalpay app.mpsupport.auth_code=W3xucYnbmbE6rZDmA2V9BsKmagTrVIny -app.run-tasks=true +app.run-tasks=false app.allow-clearing-generation=false app.mail.appid=1 @@ -95,4 +95,7 @@ app.foreign-currency=AUD app.ofei.md5-key=Khjx6wejblaJzmG0JBWFlPFKAUxhFIXQ app.ofei.pwd=aomi@8888 -app.ofei.sp-code=A1407200 \ No newline at end of file +app.ofei.sp-code=A1407200 + +android.message.secret=2b96d9bc6169c9554218aab1 +android.message.appkey=3f33a10d0a7d4ac94d8f2431 \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/ClientAnalysisMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/ClientAnalysisMapper.xml index be9fe3d69..4f33ecef3 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/ClientAnalysisMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/ClientAnalysisMapper.xml @@ -8,7 +8,9 @@ WHERE create_time >= #{begin} AND create_time <= #{end} and is_valid=1 and (approve_result is null or approve_result !=0) ]]> - and org_id=#{org_id} + and org_id=#{org_id} + and org_id in + #{org_id} @@ -25,7 +27,9 @@ = #{begin} AND a.datelist< #{end} AND c.is_valid=1 ]]> - and c.org_id=#{org_id} + and c.org_id=#{org_id} + and c.org_id in + #{org_id} and c.client_id in (SELECT b.client_id FROM sys_client_bd b INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id @@ -43,7 +47,9 @@ WHERE create_time <= #{end} AND is_valid=1 and (approve_result is null or approve_result !=0) ]]> - and org_id=#{org_id} + and org_id=#{org_id} + and org_id in + #{org_id} 4 AND o.confirm_time IS NOT NULL WHERE o.create_time >= #{begin} AND o.create_time <= #{end} ]]> - and p.org_id=#{org_id} + and p.org_id=#{org_id} + and p.org_id in + #{org_id} @@ -62,7 +70,9 @@ INNER JOIN pmt_orders o ON o.client_id = p.client_id AND o.status >4 AND o.confirm_time IS NOT NULL WHERE o.create_time >= #{begin} AND o.create_time <= #{end} ]]> - and p.org_id=#{org_id} + and p.org_id=#{org_id} + and p.org_id in + #{org_id} and p.client_id in (SELECT b.client_id FROM sys_client_bd b INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id @@ -85,7 +95,9 @@ INNER JOIN pmt_orders o ON t.order_id = o.order_id WHERE o.create_time >= #{begin} AND o.create_time <= #{end} ]]> - and p.org_id=#{org_id} + and p.org_id=#{org_id} + and p.org_id in + #{org_id} and p.client_id in (SELECT b.client_id FROM sys_client_bd b INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id @@ -107,7 +119,9 @@ is_valid = 1 and industry <'400' AND approve_result=1 - and org_id=#{org_id} + and org_id=#{org_id} + and org_id in + #{org_id} and c.client_id in (SELECT b.client_id FROM sys_client_bd b INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/customers/CustomerMembershipMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/customers/CustomerMembershipMapper.xml index 28127795d..387f73791 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/customers/CustomerMembershipMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/customers/CustomerMembershipMapper.xml @@ -52,8 +52,8 @@ 0 + SELECT DISTINCT c.kanga_openid + from cus_membership c, sys_managers s where c.payment_openid = s.wx_openid AND (s.role & 1 >0 or s.role & 10000000 >0) ]]> \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml index d9476cdbf..1fa582785 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml @@ -172,10 +172,12 @@ and o.order_id=#{order_id} + and p.org_id in + #{org_id} and o.gateway in #{gateway} - and p.org_id=#{org_id} + and p.org_id=#{org_id} and o.create_time >= #{from} and o.create_time < #{to} and date(o.create_time)=date(#{date}) @@ -357,11 +359,13 @@ and t.system_transaction_id =#{search_text} + and p.org_id in + #{org_id} and o.order_id=#{order_id} and o.gateway in #{gateway} - and p.org_id=#{org_id} + and p.org_id=#{org_id} and o.create_time >= #{from} and o.create_time < #{to} and date(o.create_time)=date(#{date}) 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 3551b3c64..66996e519 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 @@ -1,10 +1,31 @@ - + - SELECT * FROM sys_clients_devices_token where client_id=#{client_id} and is_valid=1 group by token + SELECT + t.*, d.client_type + FROM + sys_clients_devices_token t + LEFT JOIN sys_clients_devices d ON t.dev_id = d.dev_id + WHERE + t.client_id = #{client_id} + AND t.is_valid = 1 + GROUP BY + token + + SELECT + t.*, d.client_type + FROM + sys_clients_devices_token t + LEFT JOIN sys_clients_devices d ON t.dev_id = d.dev_id + WHERE + t.client_id = #{client_id} + GROUP BY + token + SELECT * FROM sys_clients_devices_token where dev_id=#{dev_id} limit 1 diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml index 77c69f77f..59fce38fe 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml @@ -150,6 +150,8 @@ and c.org_id=#{org_id} + and c.org_id in + #{org_id} and c.referrer_id=#{referrer_id} and c.is_valid=1 diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.xml index 434d24c25..2ebe604e3 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ManagerMapper.xml @@ -3,7 +3,7 @@ 0 and m.is_valid=1 AND o.type = 0 diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/OrgMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/OrgMapper.xml index 7c5036341..c1a62ca1c 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/OrgMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/OrgMapper.xml @@ -8,6 +8,33 @@ + + SELECT * FROM sys_org WHERE is_valid=1 AND parent_org_id is NULL + + and type=#{type} + + + and org_id=#{org_id} + + + + + SELECT * FROM sys_org WHERE is_valid=1 AND parent_org_id is NOT NULL + + and type=#{type} + + + and org_id=#{org_id} + + + and parent_org_id=#{parent_org_id} + + + + + select * FROM sys_org where is_valid=1 and type=0 and (org_id=#{org_id} or parent_org_id=#{org_id}) + + @@ -37,6 +64,13 @@ and org.name=#{name} + + and org.parent_org_id=#{parent_org_id} + + + and (org.org_id=#{org_id} or org.parent_org_id=#{org_id}) + + \ No newline at end of file diff --git a/src/main/ui/static/analysis/monitoring/templates/analysis_monitoring.html b/src/main/ui/static/analysis/monitoring/templates/analysis_monitoring.html index 508155397..84efe7cf9 100644 --- a/src/main/ui/static/analysis/monitoring/templates/analysis_monitoring.html +++ b/src/main/ui/static/analysis/monitoring/templates/analysis_monitoring.html @@ -8,7 +8,7 @@ 交易监控|Trade Monitor - + 警告监控|Risk Monitor @@ -16,7 +16,7 @@ 风控配置|Cheat Monitor - + 欠款|Pre Refund diff --git a/src/main/ui/static/config/devtools/templates/send_message.html b/src/main/ui/static/config/devtools/templates/send_message.html index 378f1bbcb..84aa5393b 100644 --- a/src/main/ui/static/config/devtools/templates/send_message.html +++ b/src/main/ui/static/config/devtools/templates/send_message.html @@ -31,6 +31,13 @@ DevToken + + Client Type + + iphone + android + + Title diff --git a/src/main/ui/static/config/devtools/templates/wechat_message.html b/src/main/ui/static/config/devtools/templates/wechat_message.html index da0811abb..77d45aed6 100644 --- a/src/main/ui/static/config/devtools/templates/wechat_message.html +++ b/src/main/ui/static/config/devtools/templates/wechat_message.html @@ -83,6 +83,9 @@ GUEST:观察员 + + ORG_MANAGER:代理商管理 + Title diff --git a/src/main/ui/static/config/managers/manager.js b/src/main/ui/static/config/managers/manager.js index b749ab7a8..adf9fee30 100644 --- a/src/main/ui/static/config/managers/manager.js +++ b/src/main/ui/static/config/managers/manager.js @@ -20,9 +20,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }; if($filter('withRole')('1')){ $scope.listOrgs = function () { - $http.get('/sys/orgs',{params:{detail:true}}).then(function (resp) { + $http.get('/sys/orgs/list_all_Org', {params: {}}).then(function (resp) { $scope.orgs = resp.data; - }) + }); }; $scope.listOrgs(); } diff --git a/src/main/ui/static/config/managers/templates/managers.html b/src/main/ui/static/config/managers/templates/managers.html index 688282066..0f6de078a 100644 --- a/src/main/ui/static/config/managers/templates/managers.html +++ b/src/main/ui/static/config/managers/templates/managers.html @@ -33,14 +33,21 @@ BD Leader Risk Manager Guest + Org Manager + + All Organizations + + + @@ -89,6 +96,7 @@ + Modify diff --git a/src/main/ui/static/config/managers/templates/modify.html b/src/main/ui/static/config/managers/templates/modify.html index cf678293b..5faa653ac 100644 --- a/src/main/ui/static/config/managers/templates/modify.html +++ b/src/main/ui/static/config/managers/templates/modify.html @@ -81,6 +81,9 @@ Risk Manager + + Org Manager + diff --git a/src/main/ui/static/config/managers/templates/new_manager.html b/src/main/ui/static/config/managers/templates/new_manager.html index 3c17c0c5a..da4e5fd2d 100644 --- a/src/main/ui/static/config/managers/templates/new_manager.html +++ b/src/main/ui/static/config/managers/templates/new_manager.html @@ -36,22 +36,22 @@ - + Email - + Phone - + WeChat Account - + Roles @@ -90,6 +90,9 @@ Guest + + Org Manager + diff --git a/src/main/ui/static/config/organizations/organizations.js b/src/main/ui/static/config/organizations/organizations.js index c1ee8557a..175906192 100644 --- a/src/main/ui/static/config/organizations/organizations.js +++ b/src/main/ui/static/config/organizations/organizations.js @@ -26,6 +26,15 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { return $http.get('/sys/orgs/' + $stateParams.orgId); }] } + }).state('organizations.detail_parent', { + url: '/{orgId}/detail_parent', + templateUrl: '/static/config/organizations/templates/org_detail_parent.html', + controller: 'orgDetailParentCtrl', + resolve: { + org: ['$http', '$stateParams', function ($http, $stateParams) { + return $http.get('/sys/orgs/' + $stateParams.orgId); + }] + } }).state('organizations.new', { url: '/new_org', templateUrl: '/static/config/organizations/templates/new_org.html', @@ -33,17 +42,26 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }) }]); app.controller('orgsCtrl', ['$scope', '$http','commonDialog', function ($scope, $http,commonDialog ) { - $scope.params = {type:0}; + $scope.params = {}; + if($scope.currentUser.org_id !=null && !angular.equals({}, $scope.currentUser.org_id)) { + $scope.params.org_id = $scope.currentUser.org_id; + } $scope.pagination = {}; $scope.types = angular.copy(types); $scope.listOrgs = function (page) { var params = angular.copy( $scope.params); params.page = page || $scope.pagination.page || 1; $http.get('/sys/orgs/listsOrg',{params:params}).then(function (resp) { - $scope.orgs = resp.data.data; + $scope.orgs_detail = resp.data.data; $scope.pagination = resp.data.pagination; }) }; + if (($scope.currentUser.role & parseInt('1000011', 2)) > 0 && !$scope.currentUser.org_id) { + $scope.showOrg = 'Organization'; + $http.get('/sys/orgs/list_all_Org', {params: {}}).then(function (resp) { + $scope.orgs = resp.data; + }); + } $scope.disableOrg = function (org) { $scope.org =angular.copy(org); $scope.org.is_valid = 0; @@ -63,6 +81,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { app.controller('orgDetailCtrl', ['$scope', '$http', '$state', 'Upload', '$uibModal','commonDialog', 'org', function ($scope, $http, $state, Upload,$uibModal,commonDialog, org) { $scope.types = angular.copy(types); $scope.org = angular.copy(org.data); + if ($scope.currentUser.org_id != null) { + $scope.org.type = 0; + } $scope.uploadLogo = function (file) { if (file == null) { return; @@ -154,6 +175,103 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }) } }]); + app.controller('orgDetailParentCtrl', ['$scope', '$http', '$state', 'Upload', '$uibModal','commonDialog', 'org', function ($scope, $http, $state, Upload,$uibModal,commonDialog, org) { + $scope.types = angular.copy(types); + $scope.org = angular.copy(org.data); + if ($scope.currentUser.org_id != null) { + $scope.org.type = 0; + } + $scope.uploadLogo = function (file) { + if (file == null) { + return; + } + $scope.logoProgress = {value: 0}; + Upload.upload({ + url: '/attachment/files', + data: {file: file} + }).then(function (resp) { + delete $scope.logoProgress; + $scope.org.logo = resp.data.url; + }, function (resp) { + delete $scope.logoProgress; + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, function (evt) { + $scope.logoProgress.value = parseInt(100 * evt.loaded / evt.total); + }) + }; + $scope.update = function (form) { + if (form.$invalid) { + angular.forEach(form, function (item, key) { + if (key.indexOf('$') < 0) { + item.$dirty = true; + } + }); + return; + } + $http.put('/sys/orgs/' + $scope.org.org_id, $scope.org).then(function () { + commonDialog.alert({title: 'Succeed', content: 'Organization update succeeded', type: 'success'}); + $state.reload(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + }) + }; +/* + $scope.toggleRateEditable = function () { + if($scope.org.rate_editable==org.data.rate_editable){ + return; + } + $http.put('/sys/orgs/'+$scope.org.org_id+'/enable_change_rate',{enabled:$scope.org.rate_editable}).then(function () { + + },function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }) + }; + + $scope.search = {role:'1111111'}; + $scope.listManagers = function () { + $http.get('/sys/manager_accounts',{params:{org_id:$scope.org.org_id}}).then(function (resp) { + $scope.managers = resp.data; + }) + }; + + $scope.listManagers(); + $scope.modifyManager = function (manager) { + $uibModal.open({ + templateUrl: '/static/config/managers/templates/modify.html', + controller: 'modifyManagerCtrl', + resolve: { + manager: function () { + return angular.copy(manager); + } + } + }).result.then(function () { + $scope.listManagers(); + }) + }; + $scope.disableManager = function (manager) { + commonDialog.confirm({ + title: 'Confirm!', + content: 'You are setting manager ' + manager.display_name + ' disabled.Are you sure?' + }).then(function () { + $http.delete('/sys/manager_accounts/' + manager.manager_id).then(function () { + $scope.listManagers(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + }) + }) + }; + $scope.newManager = function () { + $uibModal.open({ + templateUrl: '/static/config/managers/templates/new_manager.html', + controller: 'newManagerCtrl', + resolve: { + org: angular.copy($scope.org) + } + }).result.then(function () { + $scope.listManagers(); + }) + }*/ + }]); app.controller('newOrgCtrl', ['$scope', '$http', '$state', 'Upload', 'commonDialog', function ($scope, $http, $state, Upload, commonDialog) { $scope.types = angular.copy(types); $scope.uploadLogo = function (file) { @@ -183,6 +301,10 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }); return; } + if($scope.currentUser.org_id !=null && !angular.equals({}, $scope.currentUser.org_id)) { + $scope.org.parent_org_id = angular.copy($scope.currentUser.org.org_id); + $scope.org.type = '0'; + } $http.post('/sys/orgs', $scope.org).then(function (resp) { commonDialog.alert({ title: 'Succeed', @@ -226,6 +348,10 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { }); return; } + if(currentUser.org_id != null && !currentUser.parent_org_id){ + $scope.manager.bd=true; + } + $http.post('/sys/manager_accounts', $scope.manager).then(function () { $scope.$close(); }, function (resp) { diff --git a/src/main/ui/static/config/organizations/templates/new_org.html b/src/main/ui/static/config/organizations/templates/new_org.html index 8b9348340..0682ae4c9 100644 --- a/src/main/ui/static/config/organizations/templates/new_org.html +++ b/src/main/ui/static/config/organizations/templates/new_org.html @@ -64,7 +64,8 @@ required> - + Type * @@ -88,7 +89,7 @@ - + Alipay rate * diff --git a/src/main/ui/static/config/organizations/templates/org_detail.html b/src/main/ui/static/config/organizations/templates/org_detail.html index dbba42c13..c23704ac5 100644 --- a/src/main/ui/static/config/organizations/templates/org_detail.html +++ b/src/main/ui/static/config/organizations/templates/org_detail.html @@ -50,7 +50,8 @@ - + Type * @@ -191,6 +192,7 @@ Director Site Manager Developer + Org Manager @@ -236,6 +238,7 @@ + Modify diff --git a/src/main/ui/static/config/organizations/templates/org_detail_parent.html b/src/main/ui/static/config/organizations/templates/org_detail_parent.html new file mode 100644 index 000000000..e2053af76 --- /dev/null +++ b/src/main/ui/static/config/organizations/templates/org_detail_parent.html @@ -0,0 +1,255 @@ + + + + + Basic Config + + Organizations + + + + + + + + + + + + + Name * + + + + + + Logo + + + + Upload + + + + + + + + Location * + + + + + + Type * + + + + + + + + + + + + + Rate * + + + % + + + + + + Alipay Rate * + + + % + + + + + Wechat Rate * + + + % + + + + + Bestpay Rate * + + + % + + + + + JD Pay Rate * + + + % + + + + + AlipayOnline Rate * + + + % + + + + + + Contact Person * + + + + + + Phone * + + + + + + Mail * + + + + + + Enable Commission + + + + + + Remark + + + + + + + Save + + Back + + + + + + + + + + \ No newline at end of file diff --git a/src/main/ui/static/config/organizations/templates/orgs.html b/src/main/ui/static/config/organizations/templates/orgs.html index 3a1d1a023..ba15ad749 100644 --- a/src/main/ui/static/config/organizations/templates/orgs.html +++ b/src/main/ui/static/config/organizations/templates/orgs.html @@ -86,15 +86,22 @@ - + + <!–Please Choose–> + --> + + + All Organizations + - @@ -144,7 +151,8 @@ - {{org.name}} + {{org.name}} {{org.location}} {{org.contact_person}} {{org.contact_phone}} @@ -153,11 +161,15 @@ Edit - | + ui-sref=".detail({orgId:org.org_id})" ng-if="(currentUser.org_id == null) || (org.parent_org_id == currentUser.org_id)"> Edit | + Disable + ng-click="disableOrg(org)" ng-if="(currentUser.org_id == null)||(org.parent_org_id == currentUser.org_id)">Disable + + Edit diff --git a/src/main/ui/static/config/sysconfigs/templates/permission_config.html b/src/main/ui/static/config/sysconfigs/templates/permission_config.html index 8bff132a6..e4dfa6819 100644 --- a/src/main/ui/static/config/sysconfigs/templates/permission_config.html +++ b/src/main/ui/static/config/sysconfigs/templates/permission_config.html @@ -67,6 +67,10 @@ GUEST + + + Org Manager + diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 9324a9fd7..512a6e310 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -122,7 +122,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter if ($scope.currentUser.org_id == 1 || $scope.currentUser.org_id == null) { $scope.analysisClients(); } - $scope.pagination = {}; $scope.industries = industryMap.configs(); $scope.states = stateMap.configs(); @@ -131,7 +130,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.business_structures = businessStructuresMap.configs(); $scope.clean_days = angular.copy(clean_days_map); $scope.bd_citys = angular.copy(bd_city_map); - $scope.params = {textType: 'all'}; + $scope.params = {textType: 'all',org_name:'ALL'}; $scope.loadPartners = function (page) { var params = angular.copy($scope.params); @@ -165,6 +164,21 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }); } + $scope.loadOrgs = function () { + var params = angular.copy($scope.params); + $http.get('/sys/orgs/orgChild',{params: params}).then(function (resp) { + $scope.orgs_child = resp.data; + }) + }; + $scope.loadOrgs(); + + + /* $scope.onOrgsSelect = function (selectedItem) { + $scope.params.org_id = selectedItem.org_id; + $scope.params.org_name = selectedItem.label; + $scope.loadPartners(); + }; +*/ /* $scope.chooseOrg = function (org) { if (org == 'all') { delete $scope.params.org_id; @@ -378,7 +392,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter } }]); app.controller('partnerDetailCtrl', ['$scope', '$http', '$state', '$uibModal', '$rootScope', 'Upload', 'commonDialog', 'partner', function ($scope, $http, $state, $uibModal, $rootScope, Upload, commonDialog, partner) { - $scope.init = {wechatcompliance: false}; + $scope.init = {wechat_compliance: false,local_merchant:false}; $scope.partner = partner.data; $scope.showDBUsers = function () { $http.get('/sys/partners/' + $scope.partner.client_moniker + '/bd_user').then(function (resp) { @@ -730,6 +744,24 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }) }) }; + $scope.changeLocalMerchant = function () { + if (!$scope.partner) { + return; + } + if (!$scope.init.local_merchant) { + $scope.init.local_merchant = true; + return; + } + $http.put('/sys/partners/' + $scope.partner.client_moniker + '/local_merchant_permission', {allow: $scope.partner.local_merchant}).then(function () { + + }, function (resp) { + commonDialog.alert({ + title: 'failed to change local_merchant permission status', + content: resp.data.message, + type: 'error' + }) + }) + }; }]); app.controller('partnerEditCtrl', ['$scope', '$http', '$state', 'Upload', 'commonDialog', 'timezone', 'partner', function ($scope, $http, $state, Upload, commonDialog, timezone, partner) { @@ -2487,5 +2519,32 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter return bdUsers; } }); + + app.filter('bdOrgSelect', function () { + return function (bdUsers, params) { + var org_id; + org_id = params.org_ids ||params.org_id || currentUser.org_id; + if (org_id) { + var bdUserByOrg = {}; + var count = 0; + angular.forEach(bdUsers, function (bdUser) { + if(params.org_ids){ + if (bdUser.org_id == org_id) { + bdUserByOrg[count] = bdUser; + count++; + } + }else { + if (bdUser.org_id == org_id || bdUser.parent_org_id == org_id) { + bdUserByOrg[count] = bdUser; + count++; + } + + } + }); + return bdUserByOrg; + } + return bdUsers; + } + }); return app; }); \ No newline at end of file diff --git a/src/main/ui/static/payment/partner/templates/partner_detail.html b/src/main/ui/static/payment/partner/templates/partner_detail.html index 05bd827ee..bf258e9aa 100644 --- a/src/main/ui/static/payment/partner/templates/partner_detail.html +++ b/src/main/ui/static/payment/partner/templates/partner_detail.html @@ -357,6 +357,13 @@ + + Local Merchant + + + + Description diff --git a/src/main/ui/static/payment/partner/templates/partners.html b/src/main/ui/static/payment/partner/templates/partners.html index 1a326ce7a..6be647567 100644 --- a/src/main/ui/static/payment/partner/templates/partners.html +++ b/src/main/ui/static/payment/partner/templates/partners.html @@ -142,11 +142,34 @@ + ng-change="params.bd = '';params.org_ids = null;loadPartners();loadOrgs();"> All + + + Sub Organization + Organization + + + All + + + + - + Status diff --git a/src/main/ui/static/payment/tradelog/templates/trade_logs.html b/src/main/ui/static/payment/tradelog/templates/trade_logs.html index a631b9a9e..b5b7cc556 100644 --- a/src/main/ui/static/payment/tradelog/templates/trade_logs.html +++ b/src/main/ui/static/payment/tradelog/templates/trade_logs.html @@ -56,6 +56,16 @@ + + Organization + + + All + + + Status diff --git a/src/main/ui/static/payment/tradelog/tradelog-manage.js b/src/main/ui/static/payment/tradelog/tradelog-manage.js index fb124fd19..7bac63aa5 100644 --- a/src/main/ui/static/payment/tradelog/tradelog-manage.js +++ b/src/main/ui/static/payment/tradelog/tradelog-manage.js @@ -17,7 +17,7 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) { }]); app.controller('globalTradeLogCtrl', ['$scope', '$http', '$filter', 'commonDialog', 'refunder', 'orderService', function ($scope, $http, $filter, commonDialog, refunder, orderService) { - $scope.params = {status: 'PAID',channel:'ALL', textType: 'all', datefrom: new Date(), dateto: new Date()}; + $scope.params = {status: 'PAID',channel:'ALL', textType: 'all', datefrom: new Date(), dateto: new Date(),org_name:'ALL'}; $scope.pagination = {}; $scope.today = new Date(); @@ -76,6 +76,14 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) { $scope.params.datefrom = monthBegin; $scope.loadTradeLogs(1); }; + + $scope.loadOrgs = function () { + $http.get('/sys/orgs/orgChild').then(function (resp) { + $scope.orgs = resp.data; + }) + }; + $scope.loadOrgs(); + $scope.loadTradeLogs = function (page) { var params = angular.copy($scope.params); if (params.datefrom) { diff --git a/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java b/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java new file mode 100644 index 000000000..f0631ed79 --- /dev/null +++ b/src/test/java/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionImplTest.java @@ -0,0 +1,27 @@ +package au.com.royalpay.payment.manage.apps.core.impls; + +import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.annotation.Resource; + +/** + * Created by wangning on 05/01/2018. + */ +@SpringBootTest +@ActiveProfiles({"proxy","alipay","wechat","jd","bestpay"}) +@RunWith(SpringRunner.class) +public class CustomerImpressionImplTest { + @Resource + private CustomerImpressionService customerImpression; + @Test + public void generate() throws Exception { + customerImpression.generate(9); + } + +} \ No newline at end of file diff --git a/src/test/java/au/com/royalpay/payment/manage/package-info.java b/src/test/java/au/com/royalpay/payment/manage/package-info.java new file mode 100644 index 000000000..8035e9d82 --- /dev/null +++ b/src/test/java/au/com/royalpay/payment/manage/package-info.java @@ -0,0 +1,4 @@ +/** + * Created by yishuqian on 05/01/2018. + */ +package au.com.royalpay.payment.manage; \ No newline at end of file
@@ -90,6 +90,9 @@ Guest + + Org Manager +
+ + Upload + + + +