diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/risk/RiskCustomerBlackListMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/risk/RiskCustomerBlackListMapper.java new file mode 100644 index 000000000..042aa2a3d --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/risk/RiskCustomerBlackListMapper.java @@ -0,0 +1,29 @@ +package au.com.royalpay.payment.manage.mappers.risk; + +import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect; +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; + +/** + * Create by yixian at 2017-12-21 11:45 + */ +@AutoMapper(tablename = "risk_customer_black_list", pkName = "openid") +public interface RiskCustomerBlackListMapper { + @AutoSql(type = SqlType.SELECT) + JSONObject findByOpenid(@Param("openid") String openid); + + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "is_valid=1") + PageList query(JSONObject params, PageBounds pagination); + + @AutoSql(type = SqlType.UPDATE) + void update(JSONObject customerBlackList); + + @AutoSql(type = SqlType.INSERT) + void save(JSONObject customerBlackList); +} \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/risk/bean/QueryBlackListCustomer.java b/src/main/java/au/com/royalpay/payment/manage/risk/bean/QueryBlackListCustomer.java new file mode 100644 index 000000000..fd3de0de7 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/risk/bean/QueryBlackListCustomer.java @@ -0,0 +1,46 @@ +package au.com.royalpay.payment.manage.risk.bean; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; + +public class QueryBlackListCustomer { + private String openid; + + private int page = 1; + private int limit = 10; + + + + public JSONObject toParams() { + JSONObject params = new JSONObject(); + if(StringUtils.isNotEmpty(openid)){ + params.put("openid", this.openid); + } + params.put("is_valid", 1); + return params; + } + + public String getOpenid() { + return openid; + } + + public void setOpenid(String openid) { + this.openid = openid; + } + + public int getPage() { + return page; + } + + public void setPage(int page) { + this.page = page; + } + + public int getLimit() { + return limit; + } + + public void setLimit(int limit) { + this.limit = limit; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/risk/core/RiskMerchantService.java b/src/main/java/au/com/royalpay/payment/manage/risk/core/RiskMerchantService.java index 3dc5eb074..d0eb061ad 100644 --- a/src/main/java/au/com/royalpay/payment/manage/risk/core/RiskMerchantService.java +++ b/src/main/java/au/com/royalpay/payment/manage/risk/core/RiskMerchantService.java @@ -33,4 +33,12 @@ public interface RiskMerchantService { void addAttentionMerchant(JSONObject manager, String clientMoniker, JSONObject params); void disableAttentionMerchant(JSONObject manager, String clientMoniker); + + JSONObject customerBlackList(JSONObject manager, QueryBlackListCustomer queryBlackListCustomer); + + void disableBlackListCustomer(JSONObject manager, String openid); + + void updateAttentionMerchant(JSONObject manager, String clientMoniker, JSONObject attention); + + void addBlackListCustomer(JSONObject manager, String openid, String remark); } diff --git a/src/main/java/au/com/royalpay/payment/manage/risk/core/impl/RiskMerchantServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/risk/core/impl/RiskMerchantServiceImpl.java index 4b6dd5e6d..f7655bfd9 100644 --- a/src/main/java/au/com/royalpay/payment/manage/risk/core/impl/RiskMerchantServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/risk/core/impl/RiskMerchantServiceImpl.java @@ -2,6 +2,8 @@ package au.com.royalpay.payment.manage.risk.core.impl; import au.com.royalpay.payment.manage.mappers.risk.*; import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper; +import au.com.royalpay.payment.manage.mappers.system.CustomerMapper; +import au.com.royalpay.payment.manage.mappers.system.ManagerCustomerRelationAlipayMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.risk.bean.*; import au.com.royalpay.payment.manage.risk.core.RiskMerchantService; @@ -13,6 +15,7 @@ import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -39,6 +42,12 @@ public class RiskMerchantServiceImpl implements RiskMerchantService { private RiskAttentionMerchantsMapper riskAttentionMerchantsAMapper; @Resource private ClientBankAccountMapper clientBankAccountMapper; + @Resource + private RiskCustomerBlackListMapper riskCustomerBlackListMapper; + @Resource + private CustomerMapper customerMapper; + @Resource + private ManagerCustomerRelationAlipayMapper managerCustomerRelationAlipayMapper; @Override @Transactional @@ -243,6 +252,11 @@ public class RiskMerchantServiceImpl implements RiskMerchantService { attention.put("contact_phone", client.getString("contact_phone")); attention.put("bank_account_no", bankAccount == null || bankAccount.size() <= 0 ? "" : bankAccount.get(0).getString("account_no")); attention.put("is_valid", 1); + attention.put("enjoin_wechat", params.getBoolean("enjoin_wechat")== null ? true : params.getBoolean("enjoin_wechat")); + attention.put("enjoin_alipay", params.getBoolean("enjoin_alipay")== null ? true : params.getBoolean("enjoin_alipay")); + attention.put("enjoin_bestpay", params.getBoolean("enjoin_bestpay")== null ? true : params.getBoolean("enjoin_bestpay")); + attention.put("enjoin_jd", params.getBoolean("enjoin_jd")== null ? true : params.getBoolean("enjoin_jd")); + attention.put("enjoin_hf", params.getBoolean("enjoin_hf")== null ? true : params.getBoolean("enjoin_hf")); attention.put("creation_date", params.getDate("creation_date")==null ? new Date() : params.getDate("creation_date")); attention.put("creation_by", manager.getString("manager_id")); attention.put("remark", params.getString("remark")); @@ -276,4 +290,82 @@ public class RiskMerchantServiceImpl implements RiskMerchantService { attentionMerchant.put("last_update_by", manager.getString("manager_id")); riskAttentionMerchantsAMapper.update(attentionMerchant); } + + @Override + public JSONObject customerBlackList(JSONObject manager, QueryBlackListCustomer queryBlackListCustomer) { + JSONObject params = queryBlackListCustomer.toParams(); + if (manager == null) { + throw new BadRequestException("登录状态已过期,请清新登录再试"); + } + PageList customerList = riskCustomerBlackListMapper.query(params, new PageBounds(queryBlackListCustomer.getPage(), queryBlackListCustomer.getLimit())); + JSONObject customer = new JSONObject(); + JSONObject customerAlipay = new JSONObject(); + for(JSONObject cus : customerList ){ + if (cus.getString("openid").startsWith("olH")) { + customer = customerMapper.findCustomerGlobalpayByOpenId(cus.getString("openid")); + } else { + customer = customerMapper.findCustomerByOpenId(cus.getString("openid")); + } + if (customer != null && !customer.isEmpty()) { + cus.put("headimg", customer.getString("headimg")); + cus.put("nickname", customer.getString("nickname")); + continue; + } + customerAlipay = managerCustomerRelationAlipayMapper.findCustomerByUserId(cus.getString("openid")); + if (customerAlipay != null) { + cus.put("headimg", customerAlipay.getString("headimg")); + cus.put("nickname", customerAlipay.getString("nickname")); + } + } + return PageListUtils.buildPageListResult(customerList); + } + + @Override + public void disableBlackListCustomer(JSONObject manager, String openid) { + if (manager == null) { + throw new BadRequestException("登录状态已过期,请清新登录再试"); + } + JSONObject customerBlackList = riskCustomerBlackListMapper.findByOpenid(openid); + if (customerBlackList == null) { + throw new BadRequestException("The customer does not exist"); + } + customerBlackList.put("is_valid", 0); + customerBlackList.put("last_update_date", new Date()); + customerBlackList.put("last_update_by", manager.getString("manager_id")); + riskCustomerBlackListMapper.update(customerBlackList); + } + + @Override + public void updateAttentionMerchant(JSONObject manager, String clientMoniker, JSONObject attention) { + if (manager == null) { + throw new BadRequestException("登录状态已过期,请清新登录再试"); + } + JSONObject attentionMerchant = riskAttentionMerchantsAMapper.findByClientMoniker(clientMoniker); + if (attentionMerchant == null) { + throw new BadRequestException("The client does not exist"); + } + attentionMerchant.put("enjoin_wechat", attention.getBoolean("enjoin_wechat")); + attentionMerchant.put("enjoin_alipay", attention.getBoolean("enjoin_alipay")); + attentionMerchant.put("enjoin_bestpay", attention.getBoolean("enjoin_bestpay")); + attentionMerchant.put("enjoin_jd", attention.getBoolean("enjoin_jd")); + attentionMerchant.put("enjoin_hf", attention.getBoolean("enjoin_hf")); + attentionMerchant.put("last_update_date", new Date()); + attentionMerchant.put("last_update_by", manager.getString("manager_id")); + riskAttentionMerchantsAMapper.update(attentionMerchant); + } + + @Override + public void addBlackListCustomer(JSONObject manager, String openid, String remark) { + if (manager == null) { + throw new BadRequestException("登录状态已过期,请清新登录再试"); + } + JSONObject customer = new JSONObject(); + customer.put("openid", openid); + customer.put("remark", remark); + customer.put("creation_date", new Date()); + customer.put("creation_by", manager.getString("manager_id")); + customer.put("last_update_date", new Date()); + customer.put("last_update_by", manager.getString("manager_id")); + riskCustomerBlackListMapper.save(customer); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/risk/web/RiskController.java b/src/main/java/au/com/royalpay/payment/manage/risk/web/RiskController.java index b1ffbff18..d306186cd 100644 --- a/src/main/java/au/com/royalpay/payment/manage/risk/web/RiskController.java +++ b/src/main/java/au/com/royalpay/payment/manage/risk/web/RiskController.java @@ -8,12 +8,7 @@ import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import com.alibaba.fastjson.JSONObject; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -104,4 +99,24 @@ public class RiskController { public void disableRiskMerchant(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker) { riskMerchantService.disableAttentionMerchant(manager, clientMoniker); } + + @ManagerMapping(value = "/customer/blacklist", role = ManagerRole.RISK_MANAGER, method = RequestMethod.GET) + public JSONObject blackListCustomer(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, QueryBlackListCustomer queryBlackListCustomer) { + return riskMerchantService.customerBlackList(manager, queryBlackListCustomer); + } + + @ManagerMapping(value = "/customer/blacklist/{openid}", role = ManagerRole.RISK_MANAGER, method = RequestMethod.PUT) + public void disableRiskCustomer(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String openid) { + riskMerchantService.disableBlackListCustomer(manager, openid); + } + + @ManagerMapping(value = "/attention/{clientMoniker}/detail", role = ManagerRole.RISK_MANAGER, method = RequestMethod.PUT) + public void updateRiskMerchant(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject attention) { + riskMerchantService.updateAttentionMerchant(manager, clientMoniker, attention); + } + + @ManagerMapping(value = "/customer/{openid}/blacklist", role = ManagerRole.RISK_MANAGER, method = RequestMethod.POST) + public void saveRiskCustomer(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String openid, @RequestBody JSONObject remark) { + riskMerchantService.addBlackListCustomer(manager, openid, remark.getString("remark")); + } } diff --git a/src/main/ui/manage.html b/src/main/ui/manage.html index d139c4903..bf9ba0fb7 100644 --- a/src/main/ui/manage.html +++ b/src/main/ui/manage.html @@ -414,6 +414,11 @@ margin-bottom: 10%;"/> 黑名单|Risky Merchants +
  • + + 消费者黑名单|Risky Customer + +
  • 消费排名|Risky Merchants diff --git a/src/main/ui/search_locations.html b/src/main/ui/search_locations.html new file mode 100644 index 000000000..f1263731a --- /dev/null +++ b/src/main/ui/search_locations.html @@ -0,0 +1,163 @@ + + + + Merchant Locations + + + + + + + +
    + + + + + + + \ No newline at end of file diff --git a/src/main/ui/static/menu/templates/main_menu.html b/src/main/ui/static/menu/templates/main_menu.html index bbe6ab835..0b4b99779 100644 --- a/src/main/ui/static/menu/templates/main_menu.html +++ b/src/main/ui/static/menu/templates/main_menu.html @@ -262,6 +262,16 @@
    +
    diff --git a/src/main/ui/static/payment/partner/templates/client_partner_detail.html b/src/main/ui/static/payment/partner/templates/client_partner_detail.html index 44ee74b66..1d90ce08b 100644 --- a/src/main/ui/static/payment/partner/templates/client_partner_detail.html +++ b/src/main/ui/static/payment/partner/templates/client_partner_detail.html @@ -312,7 +312,7 @@
    + src="search_locations.html">
    diff --git a/src/main/ui/static/risk/risk.js b/src/main/ui/static/risk/risk.js index 6dbf6370d..8bfe25bf8 100644 --- a/src/main/ui/static/risk/risk.js +++ b/src/main/ui/static/risk/risk.js @@ -49,6 +49,10 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS url: '/risk/attention', templateUrl: '/static/risk/templates/attention_merchants.html', controller: 'AttentionMerchantCtrl' + }).state('analysis_monitoring.customer', { + url: '/risk/customer', + templateUrl: '/static/risk/templates/customer_blacklist.html', + controller: 'RiskCustomerBlackListCtrl' }); }]); app.controller('RiskManageCtrl', ['$scope', '$http', function ($scope, $http){ @@ -264,8 +268,22 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS $scope.loadAttentionMerchants(1); }) }; + + $scope.editAttention = function (attention) { + $uibModal.open({ + templateUrl: '/static/risk/templates/risk_merchant_edit.html', + controller: 'editRiskCtrl', + resolve:{ + attention: attention + } + }).result.then(function () { + $scope.loadAttentionMerchants(1); + }) + }; }]); app.controller('newRiskCtrl', ['$scope', '$http','commonDialog', function ($scope, $http,commonDialog) { + $scope.attentions = {"enjoin_wechat": true,"enjoin_alipay": true,"enjoin_bestpay": true, + "enjoin_jd": true,"enjoin_hf": true} $scope.save = function (attentions) { var params = angular.copy(attentions); $http.post('/sys/risk/attention/'+ attentions.client_moniker, params).then(function () { @@ -276,6 +294,61 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS }); }; }]); + app.controller('editRiskCtrl', ['$scope', '$http','commonDialog', 'attention', function ($scope, $http,commonDialog, attention) { + $scope.attentions = angular.copy(attention); + $scope.update = function (attentions) { + var params = angular.copy(attentions); + $http.put('/sys/risk/attention/'+ attentions.client_moniker + '/detail', params).then(function () { + commonDialog.alert({title: 'Success', content: 'add successfully', type: 'success'}); + $scope.$close(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }); + }; + }]); + app.controller('RiskCustomerBlackListCtrl', ['$scope', '$http','commonDialog', '$uibModal', function ($scope, $http,commonDialog,$uibModal) { + $scope.params = {}; + $scope.pagination = {}; + $scope.loadCustomerBlackList = function (page) { + var params = angular.copy($scope.params); + params.page = page || $scope.pagination.page || 1; + $http.get('/sys/risk/customer/blacklist', {params : params}).then(function (resp) { + $scope.customerList = resp.data.data; + $scope.pagination = resp.data.pagination; + }); + }; + $scope.loadCustomerBlackList(); + $scope.disableCustomer = function (openid) { + commonDialog.confirm({title: 'Confirm', content: '确定将该用户移除黑名单?' + }).then(function () { + $http.put('/sys/risk/customer/blacklist/' + openid).then(function () { + commonDialog.alert({title: 'Success', content: 'disable successfully', type: 'success'}); + $scope.loadCustomerBlackList(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }); + }) + }; + $scope.save = function () { + $uibModal.open({ + templateUrl: '/static/risk/templates/new_customer_blacklist.html', + controller: 'newCustomerBlackListCtrl' + }).result.then(function () { + $scope.loadCustomerBlackList() + }) + }; + }]); + app.controller('newCustomerBlackListCtrl', ['$scope', '$http','commonDialog', function($scope, $http, commonDialog){ + $scope.params = {}; + $scope.addCustomer = function () { + $http.post('/sys/risk/customer/' + $scope.params.openid + '/blacklist', $scope.params).then(function () { + commonDialog.alert({title: 'Success', content: 'disable successfully', type: 'success'}); + $scope.$close(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }); + }; + }]); app.filter('risk_type', function () { return function (riskStr) { angular.forEach(riskType,function (type) { diff --git a/src/main/ui/static/risk/templates/attention_merchants.html b/src/main/ui/static/risk/templates/attention_merchants.html index 88aeee434..6d98cbd24 100644 --- a/src/main/ui/static/risk/templates/attention_merchants.html +++ b/src/main/ui/static/risk/templates/attention_merchants.html @@ -56,6 +56,7 @@ Contact Phone Operation Time Remark + Disable Channels Operation @@ -69,9 +70,18 @@ {{client.contact_phone}} {{client.creation_date}} {{client.remark}} + + Wechat + Alipay + Bestpay + JD + HF +
    Disable + Edit diff --git a/src/main/ui/static/risk/templates/customer_blacklist.html b/src/main/ui/static/risk/templates/customer_blacklist.html new file mode 100644 index 000000000..7b9958987 --- /dev/null +++ b/src/main/ui/static/risk/templates/customer_blacklist.html @@ -0,0 +1,76 @@ +
    +
    +

    Blacklist

    + +
    +
    +
    +
    +
    +
    + + +
    + +
    + +
    + +
    + +
    +
    +
    +
    +
    +
    Customer
    +
    + + + + + + + + + + + + + + + + + + + +
    OpenidCustomerOperation TimeRemarkOperation
    {{customer.openid}} + {{customer.nickname}} + {{customer.creation_date}}{{customer.remark}} + Disable +
    + +
    +
    +
    +
    \ No newline at end of file diff --git a/src/main/ui/static/risk/templates/new_customer_blacklist.html b/src/main/ui/static/risk/templates/new_customer_blacklist.html new file mode 100644 index 000000000..02e032830 --- /dev/null +++ b/src/main/ui/static/risk/templates/new_customer_blacklist.html @@ -0,0 +1,28 @@ +
    +

    New Customer Blacklist

    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + +
    +
    + + +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    diff --git a/src/main/ui/static/risk/templates/risk_add.html b/src/main/ui/static/risk/templates/risk_add.html index 31d9b768e..0911e621e 100644 --- a/src/main/ui/static/risk/templates/risk_add.html +++ b/src/main/ui/static/risk/templates/risk_add.html @@ -27,6 +27,26 @@ is-open="creationCtrl.open" ng-click="creationCtrl.open=true">
    +
    + +

    + + + + + +

    +
    diff --git a/src/main/ui/static/risk/templates/risk_merchant_edit.html b/src/main/ui/static/risk/templates/risk_merchant_edit.html new file mode 100644 index 000000000..49b7d7a06 --- /dev/null +++ b/src/main/ui/static/risk/templates/risk_merchant_edit.html @@ -0,0 +1,53 @@ + + + \ No newline at end of file