From 2b63577b341349570df7c43d75bdafdae270f2a9 Mon Sep 17 00:00:00 2001 From: "james.zhao" Date: Wed, 28 Nov 2018 17:57:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=8E=E6=8E=A7=E8=B0=83=E6=95=B4log?= =?UTF-8?q?=E5=92=8Ce-charts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../appclient/core/RetailAppService.java | 2 + .../core/impls/RetailAppServiceImp.java | 25 ++ .../appclient/web/RetailAppController.java | 14 +- .../mappers/payment/TransactionMapper.java | 4 + .../mappers/riskbusiness/RiskEventMapper.java | 4 + .../riskbusiness/RiskOrdersMapper.java | 16 + .../riskbusiness/RiskProcessLogMapper.java | 24 ++ .../riskbusiness/bean/RiskEventQuery.java | 56 +++ .../core/RiskBusinessService.java | 22 +- .../core/RiskProcessLogService.java | 28 ++ .../core/impl/RiskBusinessServiceImpl.java | 171 ++++++++- .../core/impl/RiskProcessLogServiceImpl.java | 45 +++ .../core/impl/RiskUploadServiceIpml.java | 32 +- .../enums/RiskResultTypeEnum.java | 13 + .../web/RiskBusinessController.java | 45 ++- .../web/RiskFileUploadController.java | 15 +- .../web/RiskProcessLogController.java | 33 ++ .../mappers/riskbusiness/RiskEventMapper.xml | 251 ++++++++++++-- src/main/ui/static/analysis/risk_business.js | 326 ++++++++++-------- .../analysis/templates/audit_material.html | 112 +----- .../analysis/templates/new_riskEvent.html | 17 +- .../analysis/templates/riskEvent_detail.html | 11 + .../templates/riskEvent_detail_bd.html | 187 ++-------- .../analysis/templates/risk_business.html | 112 ++++-- 24 files changed, 1039 insertions(+), 526 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskOrdersMapper.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskProcessLogMapper.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskProcessLogService.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskProcessLogServiceImpl.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskProcessLogController.java 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 94850ee79..9b99846f7 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 @@ -167,4 +167,6 @@ public interface RetailAppService { JSONObject getStyle(); void cancelCouponAccuessLog(String accuess_id, String remark); + + void submitMaterial(JSONObject material, JSONObject device); } 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 f682cf30a..ebe0154a5 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 @@ -33,6 +33,9 @@ import au.com.royalpay.payment.manage.notice.core.NoticePartner; import au.com.royalpay.payment.manage.openim.core.CustomerServiceService; import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper; import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder; +import au.com.royalpay.payment.manage.riskbusiness.core.RiskProcessLogService; +import au.com.royalpay.payment.manage.riskbusiness.core.RiskUploadService; +import au.com.royalpay.payment.manage.riskbusiness.enums.RiskResultTypeEnum; 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; @@ -176,6 +179,10 @@ public class RetailAppServiceImp implements RetailAppService { private CouponAccuessLogMapper couponAccuessLogMapper; @Resource private CouponValidateService couponValidateService; + @Resource + private RiskProcessLogService riskProcessLogService; + @Resource + private RiskUploadService riskUploadService; private Map senderMap = new HashMap<>(); private final String fileName[] = { "client_bank_file", "client_id_file", "client_company_file" }; @@ -1378,6 +1385,10 @@ public class RetailAppServiceImp implements RetailAppService { if (Hf.containsKey("channel")) { channels.add(Hf); } + JSONObject Yeepay = getChannel(clientId, now, "Yeepay"); + if (Yeepay.containsKey("channel")) { + channels.add(Yeepay); + } res.put("channels", channels); return res; } @@ -1857,4 +1868,18 @@ public class RetailAppServiceImp implements RetailAppService { return sourceStr; } + @Override + public void submitMaterial(JSONObject material, JSONObject device) { + riskUploadService.submitMaterial(material); + JSONObject account = clientAccountMapper.findById(device.getString("account_id")); + if (account == null) + account = new JSONObject(); + riskProcessLogService.addRiskProcessLog(material.getString("risk_id"), + account.getString("account_id"), + account.getString("display_name"), + RiskResultTypeEnum.WAIT_FOR_AUDIT.getRemark(), + RiskResultTypeEnum.SEND_EMAIL_TO_BD.getResultType(), + RiskResultTypeEnum.WAIT_FOR_AUDIT.getResultType()); + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java index 7d449f341..740cd6c6b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java @@ -29,8 +29,11 @@ import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.http.HttpUtils; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; + import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; + +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,9 +43,6 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; import java.math.BigDecimal; import java.text.ParseException; import java.util.Arrays; @@ -50,6 +50,10 @@ import java.util.Date; import java.util.List; import java.util.Map; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + import static au.com.royalpay.payment.tools.CommonConsts.RETAIL_DEVICE; /** @@ -631,8 +635,8 @@ public class RetailAppController { * @param material */ @PostMapping(value = "/risk/business/events") - public void uploadMaterial(@RequestBody JSONObject material) { - riskUploadService.submitMaterial(material); + public void uploadMaterial(@RequestBody JSONObject material, @ModelAttribute(RETAIL_DEVICE) JSONObject device) { + retailAppService.submitMaterial(material, device); } @RequestMapping(value = "/risk/business/upload/files", method = RequestMethod.POST) diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java index 8f4ab97b4..9a47c34f4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java @@ -38,6 +38,10 @@ public interface TransactionMapper { @AdvanceSelect(addonWhereClause = "refund_id is null and system_generate=0 and transaction_type = 'Credit'") JSONObject findIncomeByOrderId(@Param("order_id") String orderId); + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "transaction_type = 'Credit'") + JSONObject findByOrderId(@Param("order_id") String orderId); + @AutoSql(type = SqlType.SELECT) @AdvanceSelect(addonWhereClause = "refund_id is null and system_generate=1") JSONObject findSystemIncomeByOrderId(@Param("order_id") String orderId); diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.java index 200a00356..3cfed3757 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.java @@ -28,6 +28,10 @@ public interface RiskEventMapper { PageList listRisksByPage(JSONObject params, PageBounds pageBounds); + List analysisByIndustry(JSONObject params); + + List analysisByAmount(JSONObject params); + @AutoSql(type = SqlType.SELECT) JSONObject findById(@Param("risk_id") String riskId); diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskOrdersMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskOrdersMapper.java new file mode 100644 index 000000000..ddf743854 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskOrdersMapper.java @@ -0,0 +1,16 @@ +package au.com.royalpay.payment.manage.mappers.riskbusiness; + +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; +import com.alibaba.fastjson.JSONObject; +import org.apache.ibatis.annotations.Param; + +@AutoMapper(tablename = "risk_orders", pkName = "risk_order_id") +public interface RiskOrdersMapper { + @AutoSql(type= SqlType.INSERT) + void save(JSONObject params); + + @AutoSql(type = SqlType.DELETE) + void clearOrders(@Param("risk_id") String riskId); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskProcessLogMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskProcessLogMapper.java new file mode 100644 index 000000000..aeaf6848d --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskProcessLogMapper.java @@ -0,0 +1,24 @@ +package au.com.royalpay.payment.manage.mappers.riskbusiness; + +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; +import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; +import org.apache.ibatis.annotations.Param; + +/** + * @Description: + * @Author: lujian + * @Date: 2018/11/22 15:32 + */ +@AutoMapper(tablename = "risk_process_log", pkName = "risk_process_id") +public interface RiskProcessLogMapper { + + @AutoSql(type = SqlType.SELECT) + PageList getRiskProcessLogs(@Param("risk_id") String riskId, PageBounds pagination); + + @AutoSql(type = SqlType.INSERT) + void addRiskProcessLog(JSONObject log); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/bean/RiskEventQuery.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/bean/RiskEventQuery.java index 29b3bb14f..53d5e7246 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/bean/RiskEventQuery.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/bean/RiskEventQuery.java @@ -38,9 +38,17 @@ public class RiskEventQuery { // 收到调单邮件日期 private String receiveEmailDate; + private String receiveEmailDateBegin; + + private String receiveEmailDateEnd; + // 邮件回复截止日期 private String replyEmailDate; + private String replyEmailDateBegin; + + private String replyEmailDateEnd; + private Integer page = 1; // 金额区间 @@ -135,6 +143,38 @@ public class RiskEventQuery { this.replyEmailDate = replyEmailDate; } + public String getReceiveEmailDateBegin() { + return receiveEmailDateBegin; + } + + public void setReceiveEmailDateBegin(String receiveEmailDateBegin) { + this.receiveEmailDateBegin = receiveEmailDateBegin; + } + + public String getReceiveEmailDateEnd() { + return receiveEmailDateEnd; + } + + public void setReceiveEmailDateEnd(String receiveEmailDateEnd) { + this.receiveEmailDateEnd = receiveEmailDateEnd; + } + + public String getReplyEmailDateBegin() { + return replyEmailDateBegin; + } + + public void setReplyEmailDateBegin(String replyEmailDateBegin) { + this.replyEmailDateBegin = replyEmailDateBegin; + } + + public String getReplyEmailDateEnd() { + return replyEmailDateEnd; + } + + public void setReplyEmailDateEnd(String replyEmailDateEnd) { + this.replyEmailDateEnd = replyEmailDateEnd; + } + public Integer getPage() { return page; } @@ -184,6 +224,22 @@ public class RiskEventQuery { params.put("reply_email_date", replyEmailDate); } + if (receiveEmailDateBegin != null) { + params.put("receive_email_date_begin", receiveEmailDateBegin); + } + + if (receiveEmailDateEnd != null) { + params.put("receive_email_date_end", receiveEmailDateEnd); + } + + if (replyEmailDateBegin != null) { + params.put("reply_email_date_begin", replyEmailDateBegin); + } + + if (replyEmailDateEnd != null) { + params.put("reply_email_date_end", replyEmailDateEnd); + } + if (page != null && page > 0) { params.put("page", page); } diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskBusinessService.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskBusinessService.java index 9a426ed12..74a62881f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskBusinessService.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskBusinessService.java @@ -27,6 +27,20 @@ public interface RiskBusinessService { */ JSONObject getRiskEventsByPage(JSONObject params, JSONObject manager); + /** + * 风险事件按行业分析 + * @param params + * @return + */ + List analysisByIndustry(JSONObject params, JSONObject manager); + + /** + * 风险事件列表按金额分析 + * @param params + * @return + */ + List analysisByAmount(JSONObject params, JSONObject manager); + /** * 风险事件详情 * @param riskId @@ -68,8 +82,10 @@ public interface RiskBusinessService { /** * 发送拒绝邮件 * @param riskId + * @param refuseDescription + * @throws IOException */ - void sendRefuseEmail(String riskId) throws IOException; + void sendRefuseEmail(String riskId, String refuseDescription) throws IOException; /** * 发送提醒邮件 @@ -110,5 +126,9 @@ public interface RiskBusinessService { */ JSONObject getRiskEventMaterialsRemark(String riskId); + JSONObject riskEventMaterialPass(JSONObject params, JSONObject manager); + JSONObject updateIsSendClient(String riskId); + + void completeOrderAmount(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskProcessLogService.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskProcessLogService.java new file mode 100644 index 000000000..2050feeb2 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/RiskProcessLogService.java @@ -0,0 +1,28 @@ +package au.com.royalpay.payment.manage.riskbusiness.core; + +import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; + +/** + * @Description: + * @Author: lujian + * @Date: 2018/11/22 15:40 + */ +public interface RiskProcessLogService { + + /** + * 获取事件处理流程 + * @param riskId + * @return + */ + PageList getRiskProcessLogs(String riskId); + + /** + * 新增处理流程 + * @param log + */ + void addRiskProcessLog(JSONObject log); + + void addRiskProcessLog(String riskId, String operatorId, String operator, String remark, int resultTypeFrom, int resultTypeTo); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java index 56792f71c..e7b9798fc 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java @@ -10,6 +10,7 @@ import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskEventMapper; import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskFileMapper; import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskMaterialMapper; +import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskOrdersMapper; import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper; import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper; @@ -17,6 +18,8 @@ import au.com.royalpay.payment.manage.notice.core.MailService; import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper; import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder; import au.com.royalpay.payment.manage.riskbusiness.core.RiskBusinessService; +import au.com.royalpay.payment.manage.riskbusiness.core.RiskMaterialService; +import au.com.royalpay.payment.manage.riskbusiness.core.RiskProcessLogService; import au.com.royalpay.payment.manage.riskbusiness.enums.RiskEmailStatusEnum; import au.com.royalpay.payment.manage.riskbusiness.enums.RiskResultTypeEnum; import au.com.royalpay.payment.manage.signin.beans.TodoNotice; @@ -95,11 +98,18 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo private RoyalThreadPoolExecutor royalThreadPoolExecutor; private final String UPLOAD_MAIL_PREFIX = "UPLOAD_MAIL"; + @Resource + private RiskProcessLogService riskProcessLogService; + @Resource private RiskMaterialMapper riskMaterialMapper; @Resource + private RiskMaterialService riskMaterialService; + @Resource private RiskFileMapper riskFileMapper; @Resource + private RiskOrdersMapper riskOrdersMapper; + @Resource private ClientDeviceTokenMapper clientDeviceTokenMapper; @Resource private AppMessageLogMapper appMessageLogMapper; @@ -172,6 +182,49 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo return PageListUtils.buildPageListResult(riskEvents); } + @Override + public List analysisByIndustry(JSONObject params, JSONObject manager) { + List industryAnalysis = riskEventMapper.analysisByIndustry(params); + for(JSONObject industry:industryAnalysis){ + if(StringUtils.isBlank(industry.getString("industry"))){ + industry.put("industry","未知行业"); + } + } + return industryAnalysis; + } + + private List industryArray(){ + List industryArray = new ArrayList<>(); + industryArray.add("鞋包服饰"); + industryArray.add("机票行业"); + industryArray.add("软件服务"); + industryArray.add("旅游票务"); + industryArray.add("国际租车"); + industryArray.add("医疗服务(出国)"); + industryArray.add("医疗服务(不出国)"); + industryArray.add("留学教育(网络教育)"); + industryArray.add("留学教育(一年及以下)"); + industryArray.add("其它货物贸易行业"); + industryArray.add("文具/办公用品"); + industryArray.add("综合商城"); + industryArray.add("酒店行业"); + industryArray.add("教育行业"); + industryArray.add("国际物流"); + industryArray.add("数码电器"); + industryArray.add("母婴"); + industryArray.add("化妆品"); + industryArray.add("食品"); + industryArray.add("留学教育(一年以上)"); + industryArray.add("其它服务行业"); + industryArray.add("未知行业"); + return industryArray; + } + + @Override + public List analysisByAmount(JSONObject params, JSONObject manager) { + return riskEventMapper.analysisByAmount(params); + } + @Override public JSONObject getRiskEventDetail(String riskId) { @@ -259,7 +312,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo // 将订单order_id存入数据库方便后面快速查询 JSONObject orderInfo = transactionList.get(0); realOrderIdList.add(orderInfo.getString("order_id")); - orderAmountList.add(orderInfo.getString("transaction_amount")); + orderAmountList.add(orderInfo.getString("clearing_amount")); } params.put("order_amounts", StringUtils.join(orderAmountList, ",")); params.put("real_order_ids", StringUtils.join(realOrderIdList, ",")); @@ -271,12 +324,37 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo public void addRiskEvent(JSONObject params, JSONObject manager) { params = getEvent(params); riskEventMapper.save(params); + setRiskOrders(params); + params = riskEventMapper.findAll(params).get(0); + riskProcessLogService.addRiskProcessLog(params.getString("risk_id"), + params.getString("fillin_id"), + params.getString("fillin_person"), + RiskResultTypeEnum.NOT_HANDLED.getRemark(), + RiskResultTypeEnum.NOT_HANDLED.getResultType(), + RiskResultTypeEnum.NOT_HANDLED.getResultType()); + } + + private void setRiskOrders(JSONObject params){ + if(StringUtils.isNotBlank(params.getString("order_ids"))){ + String riskId = params.getString("risk_id"); + String orderIds = params.getString("real_order_ids"); + for(String orderId : orderIds.split(",")){ + JSONObject order = transactionMapper.findByOrderId(orderId); + JSONObject riskOrder = new JSONObject(); + riskOrder.put("risk_id",riskId); + riskOrder.put("order_id",orderId); + riskOrder.put("clearing_amount",order.getString("clearing_amount")); + riskOrdersMapper.save(riskOrder); + } + } } @Override public void updateRiskEvent(JSONObject params) { params = getEvent(params); riskEventMapper.update(params); + riskOrdersMapper.clearOrders(params.getString("risk_id")); + setRiskOrders(params); } @Override @@ -321,13 +399,17 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo Context ctx = getMailContext(event); final List emailsTos = (List)ctx.getVariable("emailsTos"); final List emailsCcs = ctx.getVariable("emailsCcs")==null?new ArrayList<>():(List)ctx.getVariable("emailsCcs"); + final List emailsBccs = ctx.getVariable("emailsBccs") == null ? new ArrayList<>() : (List) ctx.getVariable("emailsBccs"); final String title = (String)ctx.getVariable("title"); final String content = thymeleaf.process("mail/risk_upload_mail.html", ctx); final String uploadUrl = (String)ctx.getVariable("uploadUrl"); royalThreadPoolExecutor.execute(() -> { try { - String emailId = mailService.sendRiskEmail(title, emailsTos.isEmpty() ? "" : StringUtils.join(emailsTos, ","), - emailsCcs.isEmpty() ? "" : StringUtils.join(emailsCcs, ","), "",content, null,event.getIntValue("order_type")); + String emailId = mailService.sendRiskEmail(title, + emailsTos.isEmpty() ? "" : StringUtils.join(emailsTos, ","), + emailsCcs.isEmpty() ? "" : StringUtils.join(emailsCcs, ","), + emailsBccs.isEmpty() ? "" : StringUtils.join(emailsBccs, ","), + content, null,event.getIntValue("order_type")); event.put("email_status", RiskEmailStatusEnum.ALREADY_SEND.getEmailStatus()); event.put("result_type", RiskResultTypeEnum.SEND_EMAIL_TO_BD.getResultType()); event.put("submit_url",uploadUrl); @@ -336,6 +418,12 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo event.put("result_type", RiskResultTypeEnum.ALREADY_HANDLED.getResultType()); } riskEventMapper.update(event); + riskProcessLogService.addRiskProcessLog(event.getString("risk_id"), + event.getString("fillin_id"), + event.getString("fillin_person"), + RiskResultTypeEnum.SEND_EMAIL_TO_BD.getRemark(), + RiskResultTypeEnum.NOT_HANDLED.getResultType(), + RiskResultTypeEnum.SEND_EMAIL_TO_BD.getResultType()); if(event.getIntValue("is_send_client") == 1){ sendAppRiskMessage(event); } @@ -403,8 +491,11 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo } @Override - public void sendRefuseEmail(String riskId) throws IOException { + public void sendRefuseEmail(String riskId, String refuseDescription) throws IOException { JSONObject event = getRiskEventDetail(riskId); + if (RiskResultTypeEnum.MATERIAL_NOT_PASS.getResultType().intValue() == event.getIntValue("result_type")) { + throw new BadRequestException("Refused Already!"); + } Context ctx = getMailContext(event); ctx.setVariable("refuse",true); ctx.setVariable("refuse_description", riskMaterialMapper.findAllMaterials(riskId).get(0).getString("refuse_description")); @@ -416,10 +507,18 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo try { String emailId = mailService.sendRiskEmail("You need to resubmit risk materials", emailsTos.isEmpty() ? "" : StringUtils.join(emailsTos, ","), emailsCcs.isEmpty() ? "" : StringUtils.join(emailsCcs, ","), "",content, null,event.getIntValue("order_type")); - event.put("email_status",2); + event.put("email_status",RiskEmailStatusEnum.BACK_AND_SEND.getEmailStatus()); event.put("result_type",RiskResultTypeEnum.MATERIAL_NOT_PASS.getResultType()); event.put("submit_url",uploadUrl); riskEventMapper.update(event); + riskMaterialService.updateRiskMaterial(riskId, refuseDescription); + // 日志记录 + riskProcessLogService.addRiskProcessLog(riskId, + event.getString("fillin_id"), + event.getString("fillin_person"), + RiskResultTypeEnum.MATERIAL_NOT_PASS.getRemark(), + RiskResultTypeEnum.WAIT_FOR_AUDIT.getResultType(), + RiskResultTypeEnum.MATERIAL_NOT_PASS.getResultType()); } catch (Exception e) { throw new EmailException("Email Sending Failed", e); } @@ -462,14 +561,13 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo expireDay = "3"; } )*/ - // 原来设定的过期时间是7天,现在改成半个月 - String expireDay = "180"; + // 原来设定的过期时间是7天 + String expireDay = "3650"; stringRedisTemplate.boundValueOps(getRiskUploadKey(codeKey)).set(codeKeyValue, Long.parseLong(expireDay), TimeUnit.DAYS); String uploadUrl = PlatformEnvironment.getEnv().concatUrl("/risk/upload/") + event.getString("risk_id") + "/" + codeKey; int orderType = event.getIntValue("order_type"); if (orderType == 1 || orderType == 2) uploadUrl = PlatformEnvironment.getEnv().concatUrl("/manage.html#/analysis/monitoring/") + event.getString("risk_id") + "/bd/detail?codeKey=" + codeKey; - //uploadUrl = "localhost:9009" + "/manage.html#/analysis/monitoring/" + event.getString("risk_id") + "/bd/detail"; List bds = clientBDMapper.listClientBDInfoAvailable(client.getIntValue("client_id"), new Date()); List bdNames = new ArrayList<>(); List bdEmails = new ArrayList<>(); @@ -509,6 +607,19 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo } List orders = new ArrayList(); int isSendClient = event.getIntValue("is_send_client"); + ctx.setVariable("emailsTos", bdEmails); + if (isSendClient == 1) { + ctx.setVariable("emailsTos", clientEmails); + ctx.setVariable("emailsCcs", bdEmails); + if (orderType == RiskOrderTypeEnum.ROYALPAY_ORDER.getOrderType().intValue()) { + ctx.setVariable("emailsBccs", Arrays.asList( +// "locky@royalpay.com.au ", "zoe.tao@royalpay.com.au", "leo.huang@royalpay.com.au", +// "mona.zhang@royalpay.com.au", "weixinfengkong@royalpay.com.au", "thomas.li@royalpay.com.au" + "18852852189@139.com", "1370256381@qq.com" + )); + } + } + switch (event.getIntValue("order_type")){ case 1: case 2: @@ -521,7 +632,6 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo } ctx.setVariable("orders", orders); ctx.setVariable("title","Your merchants needs to submit risk materials"); - ctx.setVariable("emailsTos", bdEmails); break; case 3: for(String orderId : realOrderIds){ @@ -548,12 +658,6 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo // ctx.setVariable("files",attachList); case 4: ctx.setVariable("title","RoyalPay风控调查 — " + client.getString("short_name")); - ctx.setVariable("emailsTos", bdEmails); - if (isSendClient == 1) { - ctx.setVariable("emailsTos", clientEmails); - ctx.setVariable("emailsCcs", bdEmails); - } - break; } return ctx; @@ -861,11 +965,27 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo } JSONObject result = new JSONObject(); result.put("material", materialItemList); - if (material != null && material.containsKey("description")) + if (material != null && material.containsKey("description")) { result.put("description", material.getString("description")); + } + if (material != null && material.containsKey("refuse_description")) { + result.put("refuse_description", material.getString("refuse_description")); + } return result; } + @Override + public JSONObject riskEventMaterialPass(JSONObject params, JSONObject manager) { + riskEventMapper.update(params); + riskProcessLogService.addRiskProcessLog(params.getString("risk_id"), + manager.getString("manager_id"), + manager.getString("display_name"), + RiskResultTypeEnum.MATERIAL_AUDIT_PASS.getRemark(), + params.getIntValue("result_type"), + RiskResultTypeEnum.MATERIAL_AUDIT_PASS.getResultType()); + return params; + } + @Override public JSONObject updateIsSendClient(String riskId) { JSONObject event = riskEventMapper.findById(riskId); @@ -874,4 +994,23 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo event = riskEventMapper.findById(riskId); return event; } + + @Override + public void completeOrderAmount() { + List riskEventList = getRiskEvents(null); + for(JSONObject riskEvent:riskEventList){ + if(riskEvent.getIntValue("order_type")==4 || StringUtils.isBlank(riskEvent.getString("real_order_ids"))){ + continue; + } + String[] order_ids=riskEvent.getString("real_order_ids").split(","); + for(String orderId : order_ids){ + JSONObject transaction = transactionMapper.findByOrderId(orderId); + JSONObject riskOrder = new JSONObject(); + riskOrder.put("risk_id",riskEvent.getString("risk_id")); + riskOrder.put("order_id",transaction.getString("order_id")); + riskOrder.put("clearing_amount",transaction.getString("clearing_amount")); + riskOrdersMapper.save(riskOrder); + } + } + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskProcessLogServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskProcessLogServiceImpl.java new file mode 100644 index 000000000..2743fd4bd --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskProcessLogServiceImpl.java @@ -0,0 +1,45 @@ +package au.com.royalpay.payment.manage.riskbusiness.core.impl; + +import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskProcessLogMapper; +import au.com.royalpay.payment.manage.riskbusiness.core.RiskProcessLogService; +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.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * @Description: + * @Author: lujian + * @Date: 2018/11/22 15:46 + */ +@Service +public class RiskProcessLogServiceImpl implements RiskProcessLogService { + + @Resource + private RiskProcessLogMapper riskProcessLogMapper; + + @Override + public PageList getRiskProcessLogs(String riskId) { + return riskProcessLogMapper.getRiskProcessLogs(riskId, new PageBounds(Order.formString("create_time"))); + } + + @Override + public void addRiskProcessLog(JSONObject log) { + riskProcessLogMapper.addRiskProcessLog(log); + } + + @Override + public void addRiskProcessLog(String riskId, String operatorId, String operator, String remark, int resultTypeFrom, int resultTypeTo) { + JSONObject log = new JSONObject(); + log.put("risk_id", riskId); + log.put("operator_id", operatorId); + log.put("operator", operator); + log.put("remark", remark); + log.put("result_type_from", resultTypeFrom); + log.put("result_type_to", resultTypeTo); + riskProcessLogMapper.addRiskProcessLog(log); + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskUploadServiceIpml.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskUploadServiceIpml.java index 65faa5f9e..e53ecf4d0 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskUploadServiceIpml.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskUploadServiceIpml.java @@ -7,6 +7,7 @@ import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskMaterialMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper; import au.com.royalpay.payment.manage.notice.core.MailService; import au.com.royalpay.payment.manage.riskbusiness.core.RiskBusinessService; +import au.com.royalpay.payment.manage.riskbusiness.core.RiskProcessLogService; import au.com.royalpay.payment.manage.riskbusiness.core.RiskUploadService; import au.com.royalpay.payment.manage.riskbusiness.enums.RiskResultTypeEnum; import au.com.royalpay.payment.tools.exceptions.BadRequestException; @@ -17,6 +18,7 @@ import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.thymeleaf.context.Context; import org.thymeleaf.spring4.SpringTemplateEngine; @@ -34,15 +36,22 @@ public class RiskUploadServiceIpml implements RiskUploadService { @Resource private RiskEventMapper riskEventMapper; @Resource + private RiskProcessLogService riskProcessLogService; + @Resource private StringRedisTemplate stringRedisTemplate; private final String UPLOAD_MAIL_PREFIX = "UPLOAD_MAIL"; @Override public void submitMaterial(JSONObject material) { - JSONObject event = riskEventMapper.findById(material.getString("risk_id")); + String riskId = material.getString("risk_id"); + JSONObject event = riskEventMapper.findById(riskId); + Integer resultType = event.getInteger("result_type"); + if (!resultType.equals(RiskResultTypeEnum.SEND_EMAIL_TO_BD.getResultType()) && !resultType.equals(RiskResultTypeEnum.MATERIAL_NOT_PASS.getResultType())) { + throw new BadRequestException("Committed Already"); + } material.put("update_time", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")); riskMaterialMapper.save(material); - material.put("material_id",riskMaterialMapper.findAllMaterials(material.getString("risk_id")).get(0).getString("material_id")); + material.put("material_id",riskMaterialMapper.findAllMaterials(riskId).get(0).getString("material_id")); for(int i=1;i<=10;i++){ if(material.containsKey("file"+i+"_url")){ List urls = (List)material.get("file"+i+"_url"); @@ -67,16 +76,17 @@ public class RiskUploadServiceIpml implements RiskUploadService { @Override public void checkUploadMailKey(String codeKey,String risk_id) { JSONObject event = riskEventMapper.findById(risk_id); + //到期日前一天的下午6点前url可用 - try { - String reply = DateFormatUtils.format(DateUtils.addDays(event.getDate("reply_email_date"),-1),"yyyy-MM-dd 18:00:00"); - if(new Date().after( DateUtils.parseDate(reply,new String[]{"yyyy-MM-dd HH:mm:ss"}))){ - deleteUploadMailKey(codeKey); - throw new BadRequestException("Url expired"); - } - } catch (ParseException e) { - e.printStackTrace(); - } +// try { +// String reply = DateFormatUtils.format(DateUtils.addDays(event.getDate("reply_email_date"),-1),"yyyy-MM-dd 18:00:00"); +// if(new Date().after( DateUtils.parseDate(reply,new String[]{"yyyy-MM-dd HH:mm:ss"}))){ +// deleteUploadMailKey(codeKey); +// throw new BadRequestException("Url expired"); +// } +// } catch (ParseException e) { +// e.printStackTrace(); +// } if (StringUtils.isNotEmpty(codeKey)) { String redisUpload = stringRedisTemplate.boundValueOps(getRiskUploadKey(codeKey)).get(); diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/enums/RiskResultTypeEnum.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/enums/RiskResultTypeEnum.java index 2938586d8..9aeb054c7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/enums/RiskResultTypeEnum.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/enums/RiskResultTypeEnum.java @@ -15,6 +15,15 @@ public enum RiskResultTypeEnum { private Integer resultType; + private static final String[] REMARK_ARR = { + "风控事件已创建", + "已发送邮件,资料完善中", + "资料已提交,等待审核", + "材料审核通过", + "材料打回", + "已处理" + }; + RiskResultTypeEnum(Integer resultType) { this.resultType = resultType; } @@ -26,4 +35,8 @@ public enum RiskResultTypeEnum { public void setResultType(Integer resultType) { this.resultType = resultType; } + + public String getRemark() { + return REMARK_ARR[resultType]; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskBusinessController.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskBusinessController.java index 2629b5a9a..b589de9fb 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskBusinessController.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskBusinessController.java @@ -6,23 +6,17 @@ import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.manage.riskbusiness.bean.RiskEventQuery; import au.com.royalpay.payment.manage.riskbusiness.core.RiskBusinessService; import au.com.royalpay.payment.manage.riskbusiness.core.RiskMaterialService; +import au.com.royalpay.payment.manage.riskbusiness.core.RiskProcessLogService; import au.com.royalpay.payment.manage.riskbusiness.enums.RiskResultTypeEnum; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; -import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import com.alibaba.fastjson.JSONObject; -import com.sun.org.apache.xerces.internal.impl.dv.xs.BooleanDV; -import com.sun.org.apache.xpath.internal.operations.Bool; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; + import java.util.List; /** @@ -43,18 +37,34 @@ public class RiskBusinessController { @Autowired private ClientManager clientManager; + @Autowired + private RiskProcessLogService riskProcessLogService; + @GetMapping(value = "events") public JSONObject getRiskEvents(RiskEventQuery riskEventQuery, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject params = riskEventQuery.toJSON(); return riskBusinessService.getRiskEventsByPage(params, manager); } + @GetMapping(value = "events/analysis/industry") + public List analysisByIndustry(RiskEventQuery riskEventQuery, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + JSONObject params = riskEventQuery.toJSON(); + return riskBusinessService.analysisByIndustry(params, manager); + } + + @GetMapping(value = "events/analysis/amount") + public List analysisByAmount(RiskEventQuery riskEventQuery, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + JSONObject params = riskEventQuery.toJSON(); + return riskBusinessService.analysisByAmount(params, manager); + } + @GetMapping(value = "events/{risk_id}") public JSONObject getRiskEventDetail(@PathVariable("risk_id") String riskId, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { JSONObject riskEvent = riskBusinessService.getRiskEventDetail(riskId); List tradeLogs = riskBusinessService.getRiskEventOrderList(riskEvent); riskEvent.put("tradeLogs", tradeLogs); + riskEvent.put("process_logs", riskProcessLogService.getRiskProcessLogs(riskId)); return riskEvent; } @@ -71,6 +81,12 @@ public class RiskBusinessController { riskBusinessService.updateRiskEvent(params); } + @PutMapping(value = "events/pass") + public void riskEventMaterialPass(@RequestBody JSONObject params, + @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + riskBusinessService.riskEventMaterialPass(params, manager); + } + @GetMapping(value = "/{risk_id}/download/materialsAsZIP") public void downloadComplianceZip(@PathVariable("risk_id") String riskId, HttpServletResponse response) throws Exception { riskBusinessService.downloadAuditMaterialZiP(riskId, response); @@ -83,9 +99,8 @@ public class RiskBusinessController { } @RequestMapping(value = "/{risk_id}/refuse",method = RequestMethod.PUT) - public void refuseEmail(@PathVariable String risk_id, @RequestBody JSONObject otherParams) throws IOException { - riskMaterialService.updateRiskMaterial(risk_id, otherParams.getString("refuse_description")); - riskBusinessService.sendRefuseEmail(risk_id); + public void refuseEmail(@PathVariable("risk_id") String riskId, @RequestBody JSONObject otherParams) throws IOException { + riskBusinessService.sendRefuseEmail(riskId, otherParams.getString("refuse_description")); } @GetMapping(value = "/{risk_id}/material") @@ -129,8 +144,8 @@ public class RiskBusinessController { params.put("result_type", RiskResultTypeEnum.ALREADY_HANDLED.getResultType()); } riskBusinessService.updateRiskEvent(params); - } + @RequestMapping(value = "/{risk_id}/urge",method = RequestMethod.PUT) public void urgeEmail(@PathVariable String risk_id) throws IOException { riskBusinessService.sendUrgeEmail(risk_id); @@ -157,5 +172,11 @@ public class RiskBusinessController { public JSONObject updateRiskEventIsSendClient(@RequestParam("risk_id") String riskId) { return riskBusinessService.updateIsSendClient(riskId); } + + @GetMapping(value = "/complete/event/order_amount") + public String completeOrderAmount() { + riskBusinessService.completeOrderAmount(); + return "SUCCESS"; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskFileUploadController.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskFileUploadController.java index 2145b046d..63da4f111 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskFileUploadController.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskFileUploadController.java @@ -1,7 +1,10 @@ package au.com.royalpay.payment.manage.riskbusiness.web; import au.com.royalpay.payment.manage.riskbusiness.core.RiskBusinessService; +import au.com.royalpay.payment.manage.riskbusiness.core.RiskProcessLogService; import au.com.royalpay.payment.manage.riskbusiness.core.RiskUploadService; +import au.com.royalpay.payment.manage.riskbusiness.enums.RiskResultTypeEnum; +import au.com.royalpay.payment.tools.CommonConsts; import com.alibaba.fastjson.JSONObject; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; @@ -15,6 +18,8 @@ public class RiskFileUploadController { private RiskUploadService riskUploadService; @Resource private RiskBusinessService riskBusinessService; + @Resource + private RiskProcessLogService riskProcessLogService; /** * 上传材料的链接 @@ -41,9 +46,17 @@ public class RiskFileUploadController { * @param material */ @RequestMapping(value = "/{codeKey}", method = RequestMethod.POST) - public void upload(@PathVariable String codeKey, @RequestBody JSONObject material) { + public void upload(@PathVariable String codeKey, + @RequestBody JSONObject material, + @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { // riskUploadService.checkUploadMailKey(codeKey, material.getString("risk_id")); riskUploadService.submitMaterial(material); + riskProcessLogService.addRiskProcessLog(material.getString("risk_id"), + manager.getString("manager_id"), + manager.getString("display_name"), + RiskResultTypeEnum.WAIT_FOR_AUDIT.getRemark(), + RiskResultTypeEnum.SEND_EMAIL_TO_BD.getResultType(), + RiskResultTypeEnum.WAIT_FOR_AUDIT.getResultType()); riskUploadService.deleteUploadMailKey(codeKey); } diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskProcessLogController.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskProcessLogController.java new file mode 100644 index 000000000..cdfc2ba39 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/web/RiskProcessLogController.java @@ -0,0 +1,33 @@ +package au.com.royalpay.payment.manage.riskbusiness.web; + +import au.com.royalpay.payment.manage.riskbusiness.core.RiskProcessLogService; +import com.alibaba.fastjson.JSONObject; +import com.google.gson.JsonObject; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.xml.bind.util.JAXBSource; +import java.util.List; + +/** + * @Description: + * @Author: lujian + * @Date: 2018/11/22 15:52 + */ +@RestController +@RequestMapping(value = "/risk/business/process/logs") +public class RiskProcessLogController { + + @Resource + private RiskProcessLogService riskProcessLogService; + + @GetMapping(value = "/{risk_id}") + public List getRiskProcessLogs(@PathVariable("risk_id") String riskId) { + return riskProcessLogService.getRiskProcessLogs(riskId); + } + + @PostMapping + public void addRiskProcessLog(@RequestBody JSONObject log) { + riskProcessLogService.addRiskProcessLog(log); + } +} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.xml index b666dc8d1..e188bec19 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/riskbusiness/RiskEventMapper.xml @@ -33,26 +33,11 @@ LEFT JOIN sys_clients sc ON re.client_moniker = sc.client_moniker - RIGHT JOIN( - SELECT distinct re.risk_id - FROM - risk_event re, - risk_event_help reh - - reh.risk_event_help_id < (LENGTH(re.order_amounts) - LENGTH(REPLACE(re.order_amounts, ',' , ''))) + 1 - - AND cast(SUBSTRING_INDEX(SUBSTRING_INDEX(order_amounts,',',reh.risk_event_help_id + 1),',',-1) as signed) >= #{start_amount} - - - - AND cast(SUBSTRING_INDEX(SUBSTRING_INDEX(order_amounts,',',reh.risk_event_help_id + 1),',',-1) as signed) <= #{end_amount} - - - - ) temp - on re.risk_id = temp.risk_id + RIGHT JOIN + (SELECT DISTINCT(risk_id) FROM risk_orders + WHERE #{start_amount} <= clearing_amount AND #{end_amount} > clearing_amount) ro + ON re.risk_id = ro.risk_id - INNER JOIN( SELECT DISTINCT client_id @@ -110,17 +95,235 @@ AND sc.industry = #{industry} - - AND re.receive_email_date = #{receive_email_date} + + AND re.receive_email_date >= #{receive_email_date_begin} + + + + AND re.receive_email_date <= #{receive_email_date_end} + + + + AND re.reply_email_date >= #{reply_email_date_begin} + + + + AND re.reply_email_date <= #{reply_email_date_begin} + + + + AND re.real_order_ids = #{real_order_ids} + + + + + - \ No newline at end of file + diff --git a/src/main/ui/static/analysis/risk_business.js b/src/main/ui/static/analysis/risk_business.js index e62781b43..bfeeba04d 100644 --- a/src/main/ui/static/analysis/risk_business.js +++ b/src/main/ui/static/analysis/risk_business.js @@ -128,8 +128,8 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], }]); - app.controller('riskBusinessCtrl', ['$scope', '$state', '$http', '$uibModal', '$filter', 'commonDialog', 'industryMap', - function ($scope, $state, $http, $uibModal, $filter, commonDialog, industryMap) { + app.controller('riskBusinessCtrl', ['$scope', '$state', '$http', '$uibModal', '$filter', 'commonDialog', 'industryMap','chartParser', + function ($scope, $state, $http, $uibModal, $filter, commonDialog, industryMap, chartParser) { $scope.orderTypes = orderTypesMap; $scope.orderTypesForBD = orderTypesMapForBD; $scope.resultTypes = resultTypesMap; @@ -139,13 +139,20 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], $scope.amountSection = amountSectionMap; $scope.pagination = {}; $scope.params = {}; - + var industries = new Array(); + angular.forEach($scope.industries, function (industry) { + industries.push(industry.label); + }); + industries.push('未知行业'); + console.log(industries); // 加载风险注册事件 $scope.loadRiskEvents = function (page) { var params = angular.copy($scope.params); params.page = page || $scope.pagination.page || 1; - params.replyEmailDate = $filter('date')(params.replyEmailDate, 'yyyy-MM-dd'); - params.receiveEmailDate = $filter('date')(params.receiveEmailDate, 'yyyy-MM-dd'); + params.replyEmailDateBegin = $filter('date')(params.replyEmailDateBegin, 'yyyy-MM-dd'); + params.replyEmailDateEnd = $filter('date')(params.replyEmailDateEnd, 'yyyy-MM-dd'); + params.receiveEmailDateBegin = $filter('date')(params.receiveEmailDateBegin, 'yyyy-MM-dd'); + params.receiveEmailDateEnd = $filter('date')(params.receiveEmailDateEnd, 'yyyy-MM-dd'); if (params.section != null) { var sectionArray = params.section.split('-'); params.startAmount = sectionArray[0]; @@ -155,6 +162,102 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], $scope.riskEvents = resp.data.data; $scope.pagination = resp.data.pagination; }); + $http.get('/risk/business/events/analysis/industry', {params: params}).then(function (resp) { + $scope.riskEventsByIndustry = resp.data; + $scope.risk_industry_chart = chartParser.parse(industryAmount(industries),$scope.riskEventsByIndustry); + }); + $http.get('/risk/business/events/analysis/amount', {params: params}).then(function (resp) { + $scope.riskEventsByAmount = resp.data; + $scope.risk_amount_chart = chartParser.parse(intervalsAmount(),$scope.riskEventsByAmount); + }); + + }; + + var industryAmount = function (industries) { + return { + chart: { + tooltip: { + trigger: 'item', + formatter: "{a}
{b} : {c}" + }, + // color: colors, + legend: { + orient: 'vertical', + left: 'right', + data: industries + } + }, + series: [{ + basic: { + name: '风控事件单量', type: 'pie', + radius: '80%', + center: ['50%', '58%'], + label:{ //饼图图形上的文本标签 + normal:{ + show:true, + position:'outer', //标签的位置 + textStyle : { + fontWeight : 300 , + fontSize : 16 //文字的字体大小 + }, + formatter:'{d}%' + } + }, + itemStyle: { + emphasis: { + shadowBlur: 10, + shadowOffsetX: 0, + shadowColor: 'rgba(0, 0, 0, 0.5)' + } + } + }, + column: {key: 'amount', name: 'industry'} + }] + } + }; + + var intervalsAmount = function () { + return { + chart: { + tooltip: { + trigger: 'item', + formatter: "{a}
{b} : {c}" + }, + // color: colors, + legend: { + orient: 'vertical', + left: 'right', + data: [ '0-500','500-1000','1000-1500','1500-2000','2000-2500','2500-3000','3000-3500','3500-4000','4000-4500','4500-5000','5000-5500','5500-6000', + '6000-6500','6500-7000','7000-7500','7500-8000','8000-8500','8500-9000','>9000'] + } + }, + series: [{ + basic: { + name: '风控事件单量', type: 'pie', + radius: '80%', + center: ['50%', '58%'], + label:{ //饼图图形上的文本标签 + normal:{ + show:true, + position:'outer', //标签的位置 + textStyle : { + fontWeight : 300 , + fontSize : 16 //文字的字体大小 + }, + formatter:'{d}%' + } + }, + itemStyle: { + emphasis: { + shadowBlur: 10, + shadowOffsetX: 0, + shadowColor: 'rgba(0, 0, 0, 0.5)' + } + } + }, + column: {key: 'amount', name: 'intervals'} + }] + } }; $scope.loadRiskEvents(1); @@ -170,6 +273,11 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], if (riskEvent.data.is_send_client == 1) riskEvent.data.is_send_client = true; $scope.riskEvent = riskEvent.data; + + $http.get('/risk/business/process/logs/' + $scope.riskEvent.risk_id).then(function (resp) { + $scope.riskEvent.process_logs = resp.data; + }); + // 编辑表格的数据保存对象,重新从源数据复制,从而取消保存操作时不会更新视图 $scope.riskEventEdit = angular.copy(riskEvent.data); //var index = $scope.riskEvent.order_ids.lastIndexOf(","); @@ -331,128 +439,11 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], // 以下为BD上传材料相关 $scope.material={}; - $scope.material.update_time=$filter('date')(new Date(), 'yyyy-MM-dd HH:mm:ss'); - $scope.material.risk_id = $scope.riskEvent.risk_id; - $scope.uploadFile1 = function (files) { - if (files && files.length) { - var urls = new Array(); - var value = 0; - $scope.file1Progress = {value: 0}; - for (var i = 0; i < files.length; i++) { - var file = files[i]; - Upload.upload({ - url: '/attachment/riskFiles', - data: {file: file} - }).then(function (resp) { - urls.push(resp.data.url); - }, function (resp) { - delete $scope.file1Progress; - alert('Upload Failed'); - }, function (evt) { - value += parseInt(100 * evt.loaded / evt.total ); - $scope.file1Progress.value = value/(files.length*2); - }) - } - $scope.material.file1_url = urls; - } - }; - $scope.uploadFile2 = function (files) { - if (files && files.length) { - var urls = new Array(); - var value = 0; - $scope.file2Progress = {value: 0}; - for (var i = 0; i < files.length; i++) { - var file = files[i]; - Upload.upload({ - url: '/attachment/riskFiles', - data: {file: file} - }).then(function (resp) { - urls.push(resp.data.url); - }, function (resp) { - delete $scope.file2Progress; - alert('Upload Failed'); - }, function (evt) { - value += parseInt(100 * evt.loaded / evt.total ); - $scope.file2Progress.value = value/(files.length*2); - }) - } - $scope.material.file2_url = urls; - } - }; - $scope.uploadFile3 = function (files) { - if (files && files.length) { - var urls = new Array(); - var value = 0; - $scope.file3Progress = {value: 0}; - for (var i = 0; i < files.length; i++) { - var file = files[i]; - Upload.upload({ - url: '/attachment/riskFiles', - data: {file: file} - }).then(function (resp) { - urls.push(resp.data.url); - }, function (resp) { - delete $scope.file3Progress; - alert('Upload Failed'); - }, function (evt) { - value += parseInt(100 * evt.loaded / evt.total ); - $scope.file3Progress.value = value/(files.length*2); - }) - } - $scope.material.file3_url = urls; - } - }; - $scope.uploadFile4 = function (files) { - if (files && files.length) { - var urls = new Array(); - var value = 0; - $scope.file4Progress = {value: 0}; - for (var i = 0; i < files.length; i++) { - var file = files[i]; - Upload.upload({ - url: '/attachment/riskFiles', - data: {file: file} - }).then(function (resp) { - urls.push(resp.data.url); - }, function (resp) { - delete $scope.file4Progress; - alert('Upload Failed'); - }, function (evt) { - value += parseInt(100 * evt.loaded / evt.total ); - $scope.file4Progress.value = value/(files.length*2); - }) - } - $scope.material.file4_url = urls; - } - }; - $scope.uploadFile5 = function (files) { - if (files && files.length) { - var urls = new Array(); - var value = 0; - $scope.file5Progress = {value: 0}; - for (var i = 0; i < files.length; i++) { - var file = files[i]; - Upload.upload({ - url: '/attachment/riskFiles', - data: {file: file} - }).then(function (resp) { - urls.push(resp.data.url); - }, function (resp) { - delete $scope.file5Progress; - alert('Upload Failed'); - }, function (evt) { - value += parseInt(100 * evt.loaded / evt.total ); - $scope.file5Progress.value = value/(files.length*2); - }) - } - $scope.material.file5_url = urls; - } - }; - $scope.uploadFile6 = function (files) { + $scope.uploadFile = function(files, index) { if (files && files.length) { var urls = new Array(); var value = 0; - $scope.file6Progress = {value: 0}; + $scope.allMaterialInfo.material[index].fileProgressValue = 0; for (var i = 0; i < files.length; i++) { var file = files[i]; Upload.upload({ @@ -461,18 +452,26 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], }).then(function (resp) { urls.push(resp.data.url); }, function (resp) { - delete $scope.file6Progress; + delete $scope.allMaterialInfo.material[index].fileProgressValue; alert('Upload Failed'); }, function (evt) { value += parseInt(100 * evt.loaded / evt.total ); - $scope.file6Progress.value = value/(files.length*2); + $scope.allMaterialInfo.material[index].fileProgressValue = value/(files.length*2); }) } - $scope.material.file6_url = urls; + $scope.allMaterialInfo.material[index].uploadFile = urls; } }; + $scope.submit = function (form) { var codeKey = $scope.riskEvent.submit_url.substring($scope.riskEvent.submit_url.lastIndexOf('=') + 1) || $scope.riskEvent.submit_url.substring($scope.riskEvent.submit_url.lastIndexOf('/') + 1); + $scope.material.update_time=$filter('date')(new Date(), 'yyyy-MM-dd HH:mm:ss'); + $scope.material.risk_id = $scope.riskEvent.risk_id; + for (var i = 0; i < $scope.allMaterialInfo.material.length; i++) { + var key = 'file' + (i + 1) + "_url"; + $scope.material[key] = $scope.allMaterialInfo.material[i].uploadFile; + } + $scope.material.description = $scope.allMaterialInfo.description; $http.post('/risk/upload/' + codeKey, $scope.material).then(function (resp) { commonDialog.alert({ title: 'Success', @@ -491,15 +490,22 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], // 加载提交材料 $scope.loadRiskMaterial = function() { - $http.get('/risk/business/' + $scope.riskEvent.risk_id + '/material').then(function(resp) { - $scope.material = resp.data; - }) + // $http.get('/risk/business/' + $scope.riskEvent.risk_id + '/material').then(function(resp) { + // $scope.material = resp.data; + // }); + + $http.get('/risk/business/' + $scope.riskEvent.risk_id + '/all_material_info').then(function(resp) { + $scope.allMaterialInfo = resp.data; + if ($scope.uploadShowFlag) { + $scope.allMaterialInfo.description = ''; + } + }); }; // BD是否可上传 $scope.uploadShowFlag = ($scope.riskEvent.result_type == 1 || $scope.riskEvent.result_type == 4) ? true : false; - if (!$scope.uploadShowFlag) - $scope.loadRiskMaterial(); + //if (!$scope.uploadShowFlag) + $scope.loadRiskMaterial(); } ]); @@ -514,29 +520,33 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], // 加载提交材料 // $scope.fileObject = {}; $scope.loadRiskMaterial = function() { - $http.get('/risk/business/' + $scope.riskEvent.risk_id + '/material').then(function(resp) { + // $http.get('/risk/business/' + $scope.riskEvent.risk_id + '/material').then(function(resp) { + // $scope.riskMaterial = resp.data; + // $scope.file1 = resp.data.file1; + // $scope.file2 = resp.data.file2; + // $scope.file3 = resp.data.file3; + // $scope.file4 = resp.data.file4; + // $scope.file5 = resp.data.file5; + // $scope.file6 = resp.data.file6; + // + // // for (var i = 1; i <= 10; i++) { + // // var key = "file" + i; + // // if (riskMaterial[key + '_url'] != null) + // // $scope.fileObject[key] = riskMaterial[key + '_url']; + // // } + // // $scope.fileLength = Object.keys($scope.fileObject).length; + // }) + + $http.get('/risk/business/' + $scope.riskEvent.risk_id + '/all_material_info').then(function(resp) { $scope.riskMaterial = resp.data; - $scope.file1 = resp.data.file1; - $scope.file2 = resp.data.file2; - $scope.file3 = resp.data.file3; - $scope.file4 = resp.data.file4; - $scope.file5 = resp.data.file5; - $scope.file6 = resp.data.file6; - - // for (var i = 1; i <= 10; i++) { - // var key = "file" + i; - // if (riskMaterial[key + '_url'] != null) - // $scope.fileObject[key] = riskMaterial[key + '_url']; - // } - // $scope.fileLength = Object.keys($scope.fileObject).length; - }) + }); }; $scope.loadRiskMaterial(); // 材料审核 $scope.auditMaterial = function(auditType) { - var url = '/risk/business/events'; + var url = '/risk/business/events/pass'; var warningMessageHTML = '是否确定通过该材料?'; if (auditType == 3) { commonDialog.confirm({ @@ -606,13 +616,19 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], } }; var array=new Array(); + var validIndex = 0; $scope.combineMaterials = function() { for (var i = 0; i < $scope.materials.length; i++) { + var value = $scope.materials[i].value; + if (value == '') + continue; var cr = {}; - cr['question'+(i+1)] = $scope.materials[i].value; - array[i] = cr; + cr['question' + (validIndex + 1)] = $scope.materials[i].value; + array[validIndex] = cr; + validIndex++; } - console.log(JSON.stringify(array)); + if (array.length == 0) + return null; return JSON.stringify(array); }; @@ -646,7 +662,13 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], $scope.riskEvent.is_send_client = $scope.is_send_client; + var saveRiskBtn = document.getElementById('save-risk-btn'); + var saveRiskBtnInnerHtmlBak = saveRiskBtn.innerHTML; + saveRiskBtn.disabled = true; + saveRiskBtn.innerHTML = " Processing"; $http.post('/risk/business/events', $scope.riskEvent).then(function (resp) { + saveRiskBtn.innerHTML = saveRiskBtnInnerHtmlBak; + saveRiskBtn.disabled = false; commonDialog.alert({ title: 'Success', content: 'Register new riskEvent successfully', @@ -654,6 +676,8 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'], }); $state.go('^',{}, {reload: true}); }, function (resp) { + saveRiskBtn.innerHTML = saveRiskBtnInnerHtmlBak; + saveRiskBtn.disabled = false; commonDialog.alert({ title: 'Error', content: resp.data.message, diff --git a/src/main/ui/static/analysis/templates/audit_material.html b/src/main/ui/static/analysis/templates/audit_material.html index d93b759fc..5f76d3952 100644 --- a/src/main/ui/static/analysis/templates/audit_material.html +++ b/src/main/ui/static/analysis/templates/audit_material.html @@ -42,126 +42,20 @@ -
-
-

1、物流公司发货单据照片 - 要求:每笔交易对应的物流单必须提供,且单据必须清晰可见
- Photos of logistics companies’ goods-delivery documents - Requirement: The logistics order record corresponding to each transaction must be provided, and details of records should be clearly visible. -

-

1.请解释相应的消费场景/业务模式,例如网站商城,扫码支付, 消费者到店支付等;
- Please explain the relative payment scenario/business activities, for example, online store, QR code payment, payment at the store, etc; -

-
-
-   
-
- - - -
-
-
-
-
-

2、用户购买虚拟物品需要提供聊天记录、订单信息、发货凭证截图、虚拟物品最终消费场景(例如何种游戏、软件)、提供消费场景网址/下载链接 - 要求:每笔交易对应的截图必须清晰可见
- Users need to provide chat records, order information, screenshots of delivery documents, final consumption scenarios of virtual goods (such as games, software); provide consumer scene URL / download link. - Requirement: The screenshot corresponding to each transaction must be clearly visible. -

-

2.提供相应购物清单,订单小票(请提供与被查交易订单号相匹配的交易时间及金额的发票);
- Provide related shopping lists, invoices. (Please provide the invoices, amount of which matches that of the abnormal transaction); -

-
-
-   
-
- - - -
-
-
-
+
-

3、购物小票/发票存根照片 - 照片应清晰,必须显示商户名称、商户地址、购物时间、物品名称 - 购物金额等
- Photos of shopping receipts/ invoice stubs - Requirement: The photos should be clear and must show Merchant name, Business address, Transaction time, Product information, Quantity purchased, etc. -

-

3.提供相应的发货证明,报关单(若有消费者在国内购买,请提供物流单据或报关单);
- Relative proof of delivery, customs declaration (If the consumer purchased from China, please provide shipping receipt or customs declaration); -

+

  
-
-
-

4、显示商户门牌号码和店头名称的照片 - 要求:清晰可见,至少一张
- Photos of Merchant Street number & Merchant name - Requirement: At least one visible photo -

-

4.提供您的门店照片(门店照及店铺内的照片各一张, 一张可以看到商户名的门头照,一张可以看到相关商品或服务的店内照片);
- Photos of the store ( one of each front-store and in-store); -

-
-
-   
-
- - - -
-
- -
-
-
-

5、显示商户营业场景所场内部情况(如店内商品陈列、收银台等)的照片 - 要求:照片清晰,且能清楚显示商户实际售卖物品或服务,至少三张
- Photos of internal environment of merchant business (such as in-store merchandise display, checkout counter, etc.) - Requirements: The photos (at least three) showing merchant activities including actual selling-goods or services obviously -

-

5.其他可以还原交易背景的资料,如和消费者的聊天记录等,来佐证被查单号交易的真实性;
- Other materials that can verify the payment scenario, for example, chatting history, to prove the truth of the transactions; -

-
-
-   
-
- - - -
-
- -
-
-
-

6、其他图片
- Other pictures -

-
-
-   
-
- - - -
-
- -
diff --git a/src/main/ui/static/analysis/templates/new_riskEvent.html b/src/main/ui/static/analysis/templates/new_riskEvent.html index be1d2ad01..b678c4570 100644 --- a/src/main/ui/static/analysis/templates/new_riskEvent.html +++ b/src/main/ui/static/analysis/templates/new_riskEvent.html @@ -210,9 +210,8 @@ -
+
@@ -249,11 +246,17 @@
-
+
+ cancel +
diff --git a/src/main/ui/static/analysis/templates/riskEvent_detail.html b/src/main/ui/static/analysis/templates/riskEvent_detail.html index a95d9b951..08917465a 100644 --- a/src/main/ui/static/analysis/templates/riskEvent_detail.html +++ b/src/main/ui/static/analysis/templates/riskEvent_detail.html @@ -1,4 +1,15 @@
+
+
+ +
+ + +
+ +
+
+