diff --git a/src/db/modify.sql b/src/db/modify.sql index 79f642563..33cff6cca 100644 --- a/src/db/modify.sql +++ b/src/db/modify.sql @@ -490,4 +490,6 @@ CREATE TABLE `pmt_directed_bill_code` ( KEY `order_id` (`order_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 +ALTER TABLE `act_red_packets_customer` ADD COLUMN `rule_max_num_limit` tinyint(1) DEFAULT 1 COMMENT '0:Whole Activity,1:day' + diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/redpack/ActRedPacketsCustomerOrdersMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/redpack/ActRedPacketsCustomerOrdersMapper.java index 67c544ec4..631a78ca6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/redpack/ActRedPacketsCustomerOrdersMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/redpack/ActRedPacketsCustomerOrdersMapper.java @@ -44,4 +44,8 @@ public interface ActRedPacketsCustomerOrdersMapper { PageList listOrders(JSONObject jsonObject, PageBounds pageBounds); List listUnsend(@Param("act_id") String actId, @Param("before") Date before); + + List getCustomerRedpackAnalysis(JSONObject params); + + JSONObject analysisCustomerLuckyMoney(JSONObject params); } diff --git a/src/main/java/au/com/royalpay/payment/manage/redpack/beans/CustomerRedpackActBean.java b/src/main/java/au/com/royalpay/payment/manage/redpack/beans/CustomerRedpackActBean.java index bbe9b58de..cf9b1a460 100644 --- a/src/main/java/au/com/royalpay/payment/manage/redpack/beans/CustomerRedpackActBean.java +++ b/src/main/java/au/com/royalpay/payment/manage/redpack/beans/CustomerRedpackActBean.java @@ -13,6 +13,7 @@ public class CustomerRedpackActBean { private String act_name; private BigDecimal rule_order_total; private int rule_max_num; + private int rule_max_num_limit; private int status=0; private List prize_type_list; @@ -59,4 +60,12 @@ public class CustomerRedpackActBean { public void setPrize_type_list(List prize_type_list) { this.prize_type_list = prize_type_list; } + + public int getRule_max_num_limit() { + return rule_max_num_limit; + } + + public void setRule_max_num_limit(int rule_max_num_limit) { + this.rule_max_num_limit = rule_max_num_limit; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/redpack/beans/RedpackQuery.java b/src/main/java/au/com/royalpay/payment/manage/redpack/beans/RedpackQuery.java index 2a54140c7..bbad4bfb5 100644 --- a/src/main/java/au/com/royalpay/payment/manage/redpack/beans/RedpackQuery.java +++ b/src/main/java/au/com/royalpay/payment/manage/redpack/beans/RedpackQuery.java @@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.redpack.beans; import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; import java.text.ParseException; @@ -50,16 +51,16 @@ public class RedpackQuery { throw new ParamInvalidException("event_date", "error.payment.valid.invalid_date_format"); } } - if (short_name != null){ + if (StringUtils.isNotEmpty(short_name)){ param.put("short_name",short_name); } - if (client_moniker != null){ + if (StringUtils.isNotEmpty(client_moniker)){ param.put("client_moniker",client_moniker); } - if (nickname != null){ + if (StringUtils.isNotEmpty(nickname)){ param.put("nickname",nickname); } - if (org_id != null){ + if (StringUtils.isNotEmpty(org_id)){ param.put("org_id",org_id); } if (bd != null){ diff --git a/src/main/java/au/com/royalpay/payment/manage/redpack/core/ActRedPackService.java b/src/main/java/au/com/royalpay/payment/manage/redpack/core/ActRedPackService.java index 7e7c886c7..5a4b44fef 100644 --- a/src/main/java/au/com/royalpay/payment/manage/redpack/core/ActRedPackService.java +++ b/src/main/java/au/com/royalpay/payment/manage/redpack/core/ActRedPackService.java @@ -1,8 +1,11 @@ package au.com.royalpay.payment.manage.redpack.core; import au.com.royalpay.payment.core.exceptions.RedPackException; +import au.com.royalpay.payment.manage.redpack.beans.RedpackQuery; import com.alibaba.fastjson.JSONObject; +import java.util.List; + /** * Created by wangning on 2017/8/10. */ @@ -23,4 +26,8 @@ public interface ActRedPackService { JSONObject listCustomerOrders(JSONObject params, int page, int limit); void resendFailed(); + + List getCustomerRedpackAnalysis(String act_id, RedpackQuery redpackQuery); + + JSONObject analysisCustomerLuckyMoney(JSONObject params); } diff --git a/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java index 963cdcd66..6dc0a9a25 100644 --- a/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java @@ -7,6 +7,7 @@ import au.com.royalpay.payment.manage.mappers.redpack.ActPrizeTypeCustomerMapper import au.com.royalpay.payment.manage.mappers.redpack.ActRedPacketsCustomerMapper; import au.com.royalpay.payment.manage.mappers.redpack.ActRedPacketsCustomerOrdersMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerMapper; +import au.com.royalpay.payment.manage.redpack.beans.RedpackQuery; import au.com.royalpay.payment.manage.redpack.core.ActRedPackService; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi; @@ -286,4 +287,15 @@ public class ActRedPackServiceImpl implements ActRedPackService { } } + @Override + public List getCustomerRedpackAnalysis(String act_id, RedpackQuery redpackQuery) { + JSONObject params = redpackQuery.params(); + params.put("act_id", act_id); + return actRedPacketsCustomerOrdersMapper.getCustomerRedpackAnalysis(params); + } + + @Override + public JSONObject analysisCustomerLuckyMoney(JSONObject params) { + return actRedPacketsCustomerOrdersMapper.analysisCustomerLuckyMoney(params); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/redpack/web/ActRedpackConfigController.java b/src/main/java/au/com/royalpay/payment/manage/redpack/web/ActRedpackConfigController.java index 0023166f3..2c25f1b04 100644 --- a/src/main/java/au/com/royalpay/payment/manage/redpack/web/ActRedpackConfigController.java +++ b/src/main/java/au/com/royalpay/payment/manage/redpack/web/ActRedpackConfigController.java @@ -1,12 +1,14 @@ package au.com.royalpay.payment.manage.redpack.web; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.manage.redpack.beans.RedpackQuery; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.manage.redpack.core.ActRedPackService; import com.alibaba.fastjson.JSONObject; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.List; /** * Created by wangning on 2017/8/10. @@ -30,10 +32,21 @@ public class ActRedpackConfigController { } @RequestMapping(value = "/act/{act_id}",method = RequestMethod.GET) - private JSONObject listCustomerOrders(@PathVariable String act_id, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit){ - JSONObject params = new JSONObject(); + private JSONObject listCustomerOrders(@PathVariable String act_id, RedpackQuery redpackQuery){ + JSONObject params = redpackQuery.params(); params.put("actId",act_id); - return actRedPackService.listCustomerOrders(params,page,limit); + return actRedPackService.listCustomerOrders(params,redpackQuery.getPage(),redpackQuery.getLimit()); } + @ManagerMapping(value = "/{act_id}/sendLogs/analysis",method = RequestMethod.GET) + public List getCustomerRedpackAnalysis(@PathVariable String act_id, RedpackQuery query){ + return actRedPackService.getCustomerRedpackAnalysis(act_id,query); + } + + @ManagerMapping(value = "/act/{act_id}/analysis",method = RequestMethod.GET) + public JSONObject customerLuckyMoneyAnalysis(@PathVariable String act_id, RedpackQuery query){ + JSONObject params= query.params(); + params.put("act_id",act_id); + return actRedPackService.analysisCustomerLuckyMoney(params); + } } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/redpack/ActRedPacketsCustomerOrdersMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/redpack/ActRedPacketsCustomerOrdersMapper.xml index d569bb1cc..bdf193373 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/redpack/ActRedPacketsCustomerOrdersMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/redpack/ActRedPacketsCustomerOrdersMapper.xml @@ -23,9 +23,25 @@ + + and event_time >= #{from} + and event_time <= #{to} + GROUP BY date + + + + + \ No newline at end of file diff --git a/src/main/ui/static/config/redpackets/act-redpackets-customer.js b/src/main/ui/static/config/redpackets/act-redpackets-customer.js index 7560792c8..c9e2a7ebf 100644 --- a/src/main/ui/static/config/redpackets/act-redpackets-customer.js +++ b/src/main/ui/static/config/redpackets/act-redpackets-customer.js @@ -37,11 +37,184 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS }]); - app.controller('actCustomerRedpackOrdersCtrl',['$scope','$http',function ($scope, $http) { + app.controller('actCustomerRedpackOrdersCtrl',['$scope','$http','$filter',function ($scope, $http,$filter) { + $scope.analysis = {}; + $scope.today = new Date(); + $scope.chooseToday = function () { + $scope.analysis.begin = $scope.analysis.end = new Date(); + $scope.doAnalysis(); + }; + $scope.chooseYesterday = function () { + var yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + $scope.analysis.begin = $scope.analysis.end = yesterday; + $scope.doAnalysis(); + }; + $scope.chooseLast7Days = function () { + $scope.analysis.end = new Date(); + var day = new Date(); + day.setDate(day.getDate() - 7); + $scope.analysis.begin = day; + $scope.doAnalysis(); + }; + $scope.thisMonth = function () { + $scope.analysis.end = new Date(); + var monthBegin = new Date(); + monthBegin.setDate(1); + $scope.analysis.begin = monthBegin; + $scope.doAnalysis(); + }; + $scope.doAnalysis = function () { + var params = angular.copy($scope.analysis); + if (params.begin) { + params.from = $filter('date')(params.begin, 'yyyyMMdd'); + } else { + params.from = $filter('date')(new Date(), 'yyyyMMdd'); + } + if (params.end) { + params.to = $filter('date')(params.end, 'yyyyMMdd'); + } else { + params.to = $filter('date')(new Date(), 'yyyyMMdd'); + } + $http.get('/sys/redpack/customer/'+$scope.act.act_id+'/sendLogs/analysis', {params: params}).then(function (resp) { + $scope.redPackCounts = angular.copy(resp.data); + var dates = []; + var send_counts = []; + var fail_counts = []; + var receive_counts = []; + var refund_counts = []; + var amounts = []; + var real_amounts = []; + resp.data.forEach(function (e) { + dates.push(e.date); + send_counts.push(e.send_counts); + fail_counts.push(e.fail_counts); + receive_counts.push(e.receive_counts); + refund_counts.push(e.refund_counts); + amounts.push(e.amount); + real_amounts.push(e.real_amount); + }); + var customerRedPackSendLogsHistory = function (dates, send_counts, fail_counts, receive_counts, refund_counts, amounts, real_amounts) { + return { + color: colors, + tooltip: { + trigger: 'axis', + axisPointer: { // 坐标轴指示器,坐标轴触发有效 + type: 'shadow' // 默认为直线,可选为:'line' | 'shadow' + } + }, + legend: { + data: ['已领取', '发送未领取', '发送失败', '退回', '发送红包金额', '实际红包金额'] + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true + }, + xAxis: [ + { + type: 'category', + data: dates + } + ], + yAxis: [ + { + type: 'value', + name: 'RedPackets' + }, { + type: 'value', + name: 'Amount(¥)' + } + ], + series: [{ + name: '已领取', + type: 'bar', + stack: 'repackets', + data: receive_counts + }, + { + name: '发送未领取', + type: 'bar', + stack: 'repackets', + data: send_counts + }, + { + name: '发送失败', + type: 'bar', + stack: 'repackets', + data: fail_counts + }, + + { + name: '退回', + type: 'bar', + stack: 'repackets', + data: refund_counts + }, + { + name: '发送红包金额', + type: 'line', + yAxisIndex: 1, + data: amounts + }, + { + name: '实际红包金额', + type: 'line', + yAxisIndex: 1, + data: real_amounts + } + ] + }; + }; + $scope.customerRedPackSendLogsHistory = customerRedPackSendLogsHistory(dates, send_counts, fail_counts, receive_counts, refund_counts, amounts, real_amounts); + + }) + }; + $scope.chooseLast7Days(); + + /* 《==========================================OrderList========================================================>*/ + $scope.params = {}; $scope.redpack_order_pagination = {}; + $scope.chooseTodayForLogs = function () { + $scope.params.begin = $scope.params.end = new Date(); + $scope.listOrders(1); + }; + $scope.chooseYesterdayForLogs = function () { + var yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + $scope.params.begin = $scope.params.end = yesterday; + $scope.listOrders(1); + }; + $scope.chooseLast7DaysForLogs = function () { + $scope.params.end = new Date(); + var day = new Date(); + day.setDate(day.getDate() - 7); + $scope.params.begin = day; + $scope.listOrders(1); + }; + $scope.thisMonthForLogs = function () { + $scope.params.end = new Date(); + var monthBegin = new Date(); + monthBegin.setDate(1); + $scope.params.begin = monthBegin; + $scope.listOrders(1); + }; + $scope.customerLuckyMoneyAnalysis = function (params) { + $http.get('/sys/redpack/customer/act/' + $scope.act.act_id + '/analysis', {params: params}).then(function (resp) { + $scope.luckyMoneyAnalysis = resp.data; + }); + }; + $scope.customerLuckyMoneyAnalysis({}); $scope.listOrders = function (page) { - var params = angular.copy($scope.redpack_order_pagination); - params.page = page || params.page || 1; + var params = angular.copy($scope.params); + if (params.begin) { + params.from = $filter('date')(params.begin, 'yyyyMMdd'); + } + if (params.end) { + params.to = $filter('date')(params.end, 'yyyyMMdd'); + } + params.page = page || $scope.redpack_order_pagination.page || 1; $http.get('/sys/redpack/customer/act/'+$scope.act.act_id, {params: params}).then(function (resp) { $scope.redpack_order_pagination = resp.data.pagination; $scope.orders = resp.data.data; @@ -94,6 +267,17 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS }; $scope.listClients(); + $scope.addAttendClient = function () { + $uibModal.open({ + templateUrl: '/static/config/redpackets/templates/add_act_client.html', + controller: 'addClientInfoCtrl', + resolve: { + act: $scope.act + } + }).result.then(function () { + $scope.listClients(); + }) + }; $scope.editClientInfo = function (client) { var client = angular.copy(client); $uibModal.open({ @@ -129,6 +313,18 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS $scope.$close(); } }]); + app.controller('addClientInfoCtrl',['$scope', '$http','act','commonDialog', function ($scope, $http,act,commonDialog) { + $scope.client = {act_name:act.act_name}; + $scope.doAddClientInfo = function(){ + var params= {'send_name':$scope.client.send_name,'act_name':$scope.client.act_name,'wishing':$scope.client.wishing}; + $http.post('/sys/lucky_money/customer/acts/'+act.act_id+'/partners/'+$scope.client.client_moniker,params).then(function () { + commonDialog.alert({title: 'Success', content: '新增成功!', type: 'success'}); + $scope.$close(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + }); + } + }]); app.filter('send_status', function () { return function (stateValue) { diff --git a/src/main/ui/static/config/redpackets/templates/act_customer_detail.html b/src/main/ui/static/config/redpackets/templates/act_customer_detail.html index cc58cb6ca..44ec94f1e 100644 --- a/src/main/ui/static/config/redpackets/templates/act_customer_detail.html +++ b/src/main/ui/static/config/redpackets/templates/act_customer_detail.html @@ -49,13 +49,20 @@

红包限制:订单满足的最小金额

-
+

红包限制:每个客户每天最多所能获取的红包数量

+
+ +
+

+

红包限制:每个客户活动期间最多所能获取的红包数量

+
+
diff --git a/src/main/ui/static/config/redpackets/templates/act_customer_edit.html b/src/main/ui/static/config/redpackets/templates/act_customer_edit.html index 94663d4a5..b492c3886 100644 --- a/src/main/ui/static/config/redpackets/templates/act_customer_edit.html +++ b/src/main/ui/static/config/redpackets/templates/act_customer_edit.html @@ -53,8 +53,20 @@
- -
+ +
+ + +
+
+
@@ -79,6 +91,31 @@
+
+ +
+ +

红包限制:每个客户活动内最多所能获取的红包数量

+
+
+ No more than 100 +
+
+ No less than 1 +
+
+ Required Field +
+
+
+
+
diff --git a/src/main/ui/static/config/redpackets/templates/act_customer_partners.html b/src/main/ui/static/config/redpackets/templates/act_customer_partners.html index a82ef1586..3518cdb57 100644 --- a/src/main/ui/static/config/redpackets/templates/act_customer_partners.html +++ b/src/main/ui/static/config/redpackets/templates/act_customer_partners.html @@ -1,23 +1,35 @@ -
- - - - - - - - - - - - - - - - - -
ClientSend NameAct NameOperation
{{client.short_name}}({{client.client_moniker}}) - - -
-
\ No newline at end of file +
+
+
+
+ +
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + +
ClientSend NameAct NameOperation
{{client.short_name}}({{client.client_moniker}}) + + +
+
+
diff --git a/src/main/ui/static/config/redpackets/templates/act_customer_send_orders.html b/src/main/ui/static/config/redpackets/templates/act_customer_send_orders.html index ca3e2c59c..42846e4b1 100644 --- a/src/main/ui/static/config/redpackets/templates/act_customer_send_orders.html +++ b/src/main/ui/static/config/redpackets/templates/act_customer_send_orders.html @@ -1,37 +1,206 @@ -
- - - - - - - - - - - - - - - - - -
Client MonikerstatusOrder AmountCreate Time
{{order.client_moniker}}{{order.status|send_status}}{{order.order_amount}}{{order.create_time}}
+
+
+
+
+
+
+ +
+
+
+ +
+ ~ +
+ +
- +
+
+
+
+
+
+
+
+
+
+
+
+
+
-
Total Records:{{redpack_order_pagination.totalCount}};Total Pages:{{redpack_order_pagination.totalPages}}
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ ~ +
+ +
+ +
+ Today +
+
+ Yesterday +
+ + +
+
+
+
+
-
\ No newline at end of file +
+
+
+ Orders(总共红包{{luckyMoneyAnalysis.total_counts}}|{{luckyMoneyAnalysis.total_amount}}¥; + 已发红包{{luckyMoneyAnalysis.send_counts}}|{{luckyMoneyAnalysis.send_amount}}¥;客户所得红包{{luckyMoneyAnalysis.receive_counts}}|{{luckyMoneyAnalysis.receive_amount}}¥ + 待发送红包{{luckyMoneyAnalysis.unsend_counts}}|{{luckyMoneyAnalysis.unsend_amount}}¥)
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Client MonikerLucky MoneyOrder AmountNick NamestatusEvent TimeCreate Time
{{order.client_moniker}}{{order.red_packet_amount}}{{order.order_amount}} {{order.nickname}}{{order.status|send_status}}{{order.event_time}}{{order.create_time}}
+ + +
+
+ +
diff --git a/src/main/ui/static/config/redpackets/templates/add_act_client.html b/src/main/ui/static/config/redpackets/templates/add_act_client.html new file mode 100644 index 000000000..455539848 --- /dev/null +++ b/src/main/ui/static/config/redpackets/templates/add_act_client.html @@ -0,0 +1,51 @@ + + + \ No newline at end of file