From 5fc12754932f560379b0f309789ebad192b410db Mon Sep 17 00:00:00 2001 From: kira <164851225@qq.com> Date: Mon, 30 Jul 2018 18:12:18 +0800 Subject: [PATCH] add custom --- .../manage/custom/beans/QueryCustomVo.java | 11 ++ .../manage/custom/core/CustomService.java | 2 + .../custom/core/impl/CustomServiceImpl.java | 10 +- .../manage/custom/web/CustomController.java | 8 ++ .../custom/CustomReportDetailsMapper.java | 2 +- .../mappers/custom/CustomReportsMapper.xml | 8 +- src/main/ui/static/payment/custom/custom.js | 114 ++++++++++++++++-- .../payment/custom/templates/custom.html | 29 ++++- .../payment/custom/templates/custom_add.html | 29 +++-- .../custom/templates/custom_detail.html | 50 ++------ 10 files changed, 200 insertions(+), 63 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/custom/beans/QueryCustomVo.java b/src/main/java/au/com/royalpay/payment/manage/custom/beans/QueryCustomVo.java index 5f929c292..1297d19f7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/custom/beans/QueryCustomVo.java +++ b/src/main/java/au/com/royalpay/payment/manage/custom/beans/QueryCustomVo.java @@ -15,6 +15,7 @@ public class QueryCustomVo { private String date; private String channel; + private String report_status; private int page = 1; private int limit = 10; @@ -31,6 +32,9 @@ public class QueryCustomVo { if (StringUtils.isNotEmpty(channel)) { result.put("channel", channel); } + if(StringUtils.isNotEmpty(report_status)){ + result.put("report_status", report_status); + } return result; } @@ -66,4 +70,11 @@ public class QueryCustomVo { this.channel = channel; } + public String getReport_status() { + return report_status; + } + + public void setReport_status(String report_status) { + this.report_status = report_status; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/custom/core/CustomService.java b/src/main/java/au/com/royalpay/payment/manage/custom/core/CustomService.java index 9ec90c39c..811e6061b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/custom/core/CustomService.java +++ b/src/main/java/au/com/royalpay/payment/manage/custom/core/CustomService.java @@ -18,4 +18,6 @@ public interface CustomService { JSONObject query(JSONObject param, int page, int limit); + List channelCustomConfigs(String channel); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/custom/core/impl/CustomServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/custom/core/impl/CustomServiceImpl.java index c363146b5..fd5914473 100644 --- a/src/main/java/au/com/royalpay/payment/manage/custom/core/impl/CustomServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/custom/core/impl/CustomServiceImpl.java @@ -6,6 +6,7 @@ import au.com.royalpay.payment.core.beans.OrderStatus; import au.com.royalpay.payment.manage.custom.core.CustomService; import au.com.royalpay.payment.manage.mappers.custom.CustomReportDetailsMapper; import au.com.royalpay.payment.manage.mappers.custom.CustomReportsMapper; +import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.tools.utils.PageListUtils; import com.alibaba.fastjson.JSONObject; @@ -30,6 +31,8 @@ public class CustomServiceImpl implements CustomService { private CustomReportsMapper customReportsMapper; @Resource private CustomReportDetailsMapper customReportDetailsMapper; + @Resource + private OrderMapper orderMapper; @Override public JSONObject findOneWithDetail(String report_id) { @@ -43,7 +46,7 @@ public class CustomServiceImpl implements CustomService { CustomReport customReport = new CustomReport(orderId, mchCustomId, custom); if (!CollectionUtils.isEmpty(subOrders)) { subOrders.forEach(p -> { - customReport.addSubOrder(p.getBigDecimal("sub_order_fee"), p.getBigDecimal("sub_order_fee").subtract(p.getBigDecimal("transport_fee"))); + customReport.addSubOrder(p.getBigDecimal("order_fee"), p.getBigDecimal("order_fee").subtract(p.getBigDecimal("transport_fee"))); }); } JSONObject result = customSupport.saveCustom(customReport); @@ -69,4 +72,9 @@ public class CustomServiceImpl implements CustomService { return PageListUtils.buildPageListResult(customReportsMapper.queryWithTrans(param, new PageBounds(page, limit))); } + @Override + public List channelCustomConfigs(String channel) { + return customSupport.channelCustomConfigs(channel); + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/custom/web/CustomController.java b/src/main/java/au/com/royalpay/payment/manage/custom/web/CustomController.java index c0e11c353..7e4457193 100644 --- a/src/main/java/au/com/royalpay/payment/manage/custom/web/CustomController.java +++ b/src/main/java/au/com/royalpay/payment/manage/custom/web/CustomController.java @@ -13,9 +13,12 @@ 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.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + import javax.annotation.Resource; @RestController @@ -42,4 +45,9 @@ public class CustomController { public void add(@RequestBody AddCustomVO addCustomVO) { customService.add(addCustomVO.getOrder_id(),addCustomVO.getMch_custom_no(),addCustomVO.getCustom(),addCustomVO.getSubOrders()); } + + @RequestMapping(value = "/channelCustom",method = RequestMethod.GET) + public List channelCustomConfigs(@RequestParam String channel) { + return customService.channelCustomConfigs(channel); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportDetailsMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportDetailsMapper.java index 1e1f73f3f..59316c558 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportDetailsMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportDetailsMapper.java @@ -18,6 +18,6 @@ import cn.yixblog.support.mybatis.autosql.annotations.SqlType; @AutoMapper(tablename = "pmt_custom_report_details", pkName = "sub_order_no") public interface CustomReportDetailsMapper { @AutoSql(type = SqlType.SELECT) - JSONObject findByReportId(@Param("report_id") String report_id); + List findByReportId(@Param("report_id") String report_id); } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.xml index d17fd9fa3..092c62776 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.xml @@ -3,7 +3,9 @@ \ No newline at end of file diff --git a/src/main/ui/static/payment/custom/custom.js b/src/main/ui/static/payment/custom/custom.js index 3bbaaa8fa..3d92af86d 100644 --- a/src/main/ui/static/payment/custom/custom.js +++ b/src/main/ui/static/payment/custom/custom.js @@ -11,14 +11,16 @@ app.controller('customCtrl', ['$scope', '$http', 'commonDialog','$filter','$uibModal', function ($scope, $http, commonDialog,$filter,$uibModal) { $scope.pagination = {}; $scope.customOrders = {}; - $scope.params = {channel:'ALL'}; + $scope.params = {channel:'ALL',report_status:'ALL'}; $scope.loadList = function () { var params = angular.copy($scope.params); if (params.channel =='ALL'){ delete params.channel; } + if (params.report_status =='ALL'){ + delete params.report_status; + } params.page = $scope.pagination.page || 1; - console.log(params); $http.get('/custom/query',{params: params}).then(function (resp) { $scope.customOrders = resp.data.data; $scope.pagination = resp.data.pagination; @@ -26,24 +28,62 @@ }; $scope.loadList(1); - $scope.add = function (order_id) { + $scope.add = function (order) { $uibModal.open({ templateUrl: '/static/payment/custom/templates/custom_add.html', controller: 'customAddCtrl', size: 'lg', resolve: { order_id: function () { - return order_id; - } + return order.order_id; + }, + channelCustom:['$http', '$stateParams', function ($http, $stateParams) { + return $http.get('/custom/channelCustom?channel='+order.channel); + }] } }) + }; + + $scope.edit = function (order) { + $uibModal.open({ + templateUrl: '/static/payment/custom/templates/custom_add.html', + controller: 'customEditCtrl', + size: 'lg', + resolve: { + customOrder: ['$http', '$stateParams', function ($http, $stateParams) { + return $http.get('/custom/'+order.report_id); + }], + order_id: function () { + return order.order_id; + }, + channelCustom:['$http', '$stateParams', function ($http, $stateParams) { + return $http.get('/custom/channelCustom?channel='+order.channel); + }] + } + }) + } + + $scope.detail = function (order) { + $uibModal.open({ + templateUrl: '/static/payment/custom/templates/custom_detail.html', + controller: 'customDetailCtrl', + size: 'lg', + resolve: { + customOrder: ['$http', '$stateParams', function ($http, $stateParams) { + return $http.get('/custom/'+order.report_id); + }] + + } + }) } + }]); - app.controller('customAddCtrl', ['$scope', '$http','commonDialog','order_id', function ($scope, $http,commonDialog,order_id) { - $scope.custom = {has_sub:false,order_id:order_id}; + app.controller('customAddCtrl', ['$scope', '$http','commonDialog','order_id','channelCustom', function ($scope, $http,commonDialog,order_id,channelCustom) { + $scope.custom = {has_sub:false,order_id:order_id,isSubmit:true}; $scope.subOrders = new Array(); $scope.subOrder = {}; + $scope.channelCustom = channelCustom.data; $scope.addSubOrders = function () { var subOrder = angular.copy($scope.subOrder); subOrder.idNum = $scope.subOrders.length+1; @@ -73,15 +113,69 @@ } } + }]); + app.controller('customEditCtrl', ['$scope', '$http','commonDialog','order_id','customOrder','channelCustom', function ($scope, $http,commonDialog,order_id,customOrder,channelCustom) { + $scope.custom =customOrder.data; + $scope.custom.has_sub = false; + $scope.custom.order_id = order_id; + $scope.custom.isSubmit = false; + $scope.subOrders = customOrder.data.sub_orders; + $scope.subOrder = {}; + $scope.channelCustom = channelCustom.data; + if($scope.subOrders.length>0) { + for (var i = 0; i < $scope.subOrders.length; i++) { + var idNum = i; + $scope.subOrders[i].idNum = idNum; + } + $scope.custom.has_sub = true; + }else{ + $scope.custom.has_sub = false; + } + $scope.addSubOrders = function () { + var subOrder = angular.copy($scope.subOrder); + subOrder.idNum = $scope.subOrders.length+1; + $scope.subOrders.push(subOrder); + }; - }]); + $scope.submit=function () { + if($scope.custom.custom==''){ + alert('请输入海关名称'); + } + if($scope.custom.mchCustomId==''){ + alert('请输入备案号'); + } + $scope.custom.subOrders = $scope.subOrders; + var param = angular.copy($scope.custom); + $http.post('/custom', param).then(function (resp) { + $scope.$close(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }) + } + $scope.removeSubOrders = function (order) { + for(var i= 0 ;i<$scope.subOrders.length;i++){ + if($scope.subOrders[i].idNum == order.idNum){ + $scope.subOrders.splice(i,1); + return; + } + } + + } - app.controller('customDetailCtrl', ['$scope', '$http','commonDialog', function ($scope, $http,commonDialog) { - $scope.subOrders = {}; + }]); + + app.controller('customDetailCtrl', ['$scope', '$http','commonDialog','customOrder', function ($scope, $http,commonDialog,customOrder) { + $scope.custom = customOrder.data; + if(customOrder.data.sub_orders.length>0){ + $scope.custom.has_sub = true; + $scope.subOrders = $scope.custom.sub_orders; + }else { + $scope.custom.has_sub = false; + } }]); diff --git a/src/main/ui/static/payment/custom/templates/custom.html b/src/main/ui/static/payment/custom/templates/custom.html index 40b07cf2e..19c082b96 100644 --- a/src/main/ui/static/payment/custom/templates/custom.html +++ b/src/main/ui/static/payment/custom/templates/custom.html @@ -34,6 +34,23 @@

+
+ +
+

+ All | + 暂存 | + 提交 | + 提交失败 | + 提交成功 | +

+
+
@@ -74,8 +91,16 @@ - + + Submit + + + + + + diff --git a/src/main/ui/static/payment/custom/templates/custom_add.html b/src/main/ui/static/payment/custom/templates/custom_add.html index 59a6e2b2c..0f53b86bc 100644 --- a/src/main/ui/static/payment/custom/templates/custom_add.html +++ b/src/main/ui/static/payment/custom/templates/custom_add.html @@ -1,5 +1,6 @@ - \ No newline at end of file