From 2a0ef3b23bd5abaa3d6710fa7e53e6908eb2980c Mon Sep 17 00:00:00 2001 From: "james.zhao" Date: Mon, 18 Feb 2019 19:27:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8A=A5=E5=85=B3=E6=8E=A5=E5=8F=A3API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/document/cn/apidoc.json | 2 +- src/document/cn/apis.js | 72 +++++++++++++++++++++++++++++++++++++ src/document/en/apidoc.json | 1 + src/document/en/apis.js | 72 +++++++++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 1 deletion(-) diff --git a/src/document/cn/apidoc.json b/src/document/cn/apidoc.json index b220a3a12..5e0a9dc9b 100644 --- a/src/document/cn/apidoc.json +++ b/src/document/cn/apidoc.json @@ -27,8 +27,8 @@ "JD_Online_Payment", "Alipay_Online_Payment", "HF_Online_Payment", - "CB_BankPay", "SDKPayment", + "CustomsDeclare", "CommonApi", "GetExchange", "OrderStatus", diff --git a/src/document/cn/apis.js b/src/document/cn/apis.js index 65e1ee0d8..2998de1da 100644 --- a/src/document/cn/apis.js +++ b/src/document/cn/apis.js @@ -17,6 +17,9 @@ /** * @apiDefine JSON JSON字段 */ +/** + * @apiDefine SUB_JSON JSON子字段 + */ /** * @apiDefine ERROR_CODE 错误码 */ @@ -874,6 +877,75 @@ * @apiError (ERROR_CODE) ORDER_PAID 订单已支付 * */ +/** + * @api {PUT} /api/v1.0/customs/partners/{partner_code}/declare/query/{client_report_id} 创建报关单 + * @apiName declare_report + * @apiDescription + * 用于商户提交海关需要的订单附件信息。仅支持微信和支付宝,微信只支持一个月内的支付订单进行报关申请。 + * + * @apiVersion 1.0.0 + * @apiGroup CustomsDeclare + * @apiHeader Accept application/json + * @apiHeader Content-Type application/json + * @apiParam (PathVariable) {String} partner_code 必填,商户编码,由4位大写字母或数字构成 + * @apiParam (PathVariable) {String} client_report_id 必填,商户申请报关单号,要求同一商户唯一 + * @apiUse Sign + * @apiParam (JSON) {String} order_id 必填,商户支付订单号,要求同一商户唯一 + * @apiParam (JSON) {String} custom 必填,海关编号 * 渠道海关编号 + * @apiParam (JSON) {String} mch_custom_id 必填,商户在海关备案的编号 + * @apiParam (JSON) {String} mch_custom_name 必填,商户海关备案名称 + * @apiParam (JSON) {JSONArray} sub_order 子订单(拆单) + * + * @apiParam (SUB_JSON) {String} sub_order_no 商户子订单号 + * @apiParam (SUB_JSON) {String=CNY} fee_type=CNY 币种代码 + * @apiParam (SUB_JSON) {Double} order_fee 子订单金额 + * @apiParam (SUB_JSON) {Double} transport_fee 子订单物流金额 + * + * @apiSuccess {String} report_id RoyalPay海关单号 + * @apiSuccess {String} client_report_id 商户申请报关单号 + * @apiSuccess {int} report_status 0:暂存,1:提交,2:提交失败,3:提交成功 + * @apiSuccess {String} channel 支付渠道 + * @apiSuccess {String} custom 海关编号 + * @apiSuccess {String} mch_custom_no 商户在海关备案的编号 + * @apiSuccess {String} mch_custom_name 商户海关备案名称 + * @apiSuccess {String} order_id Royalpay订单号 + * @apiSuccess {String} transaction_id 支付渠道订单号 + * @apiSuccess {String} order_currency 币种 + * @apiSuccess {Double} order_amount 订单金额 + * @apiSuccess {String} report_time 报关时间 + * @apiSuccess {String} creation_date 报关单创建时间 + * @apiSuccess {String} last_update_date 更新时间 + * @apiSuccess {String} error_code 错误代码 + * @apiSuccess {String} error_msg 错误返回的信息描述 + * + * @apiUse GlobalError + * @apiError (ERROR_CODE) ORDER_MISMATCH 订单号与商户不匹配 + * + */ +/** + * @api {PUT} /api/v1.0/customs/partners/{partner_code}/declare/query/{report_id} 查询报关单 + * @apiName declare_query + * @apiDescription + * 用于商户查询报关单号的状态。 + * + * @apiVersion 1.0.0 + * @apiGroup CustomsDeclare + * @apiHeader Accept application/json + * @apiHeader Content-Type application/json + * @apiParam (PathVariable) {String} partner_code 必填,商户编码,由4位大写字母或数字构成 + * @apiParam (PathVariable) {String} report_id 必填,RoyalPay海关单号 + * @apiUse Sign + * + * @apiSuccess {String} return_code 执行结果 + * @apiSuccess {String} report_status 报关单状态 + * @apiSuccess {String} report_id 商户申请报关单号 + * @apiSuccess {String} return_msg 错误描述,仅在执行结果不为SUCCESS情况下出现 + * @apiSuccess {String} order_id RoyalPay订单号 + * + * @apiUse GlobalError + * @apiError (ERROR_CODE) ORDER_MISMATCH 订单号与商户不匹配 + * + */ function apis() { } diff --git a/src/document/en/apidoc.json b/src/document/en/apidoc.json index ffa2a724f..87ce1f722 100644 --- a/src/document/en/apidoc.json +++ b/src/document/en/apidoc.json @@ -29,6 +29,7 @@ "HF_Online_Payment", "CB_BankPay", "SDKPayment", + "CustomsDeclare", "CommonApi", "GetExchange", "OrderStatus", diff --git a/src/document/en/apis.js b/src/document/en/apis.js index d3cbf6c56..c29a618b7 100644 --- a/src/document/en/apis.js +++ b/src/document/en/apis.js @@ -17,6 +17,9 @@ /** * @apiDefine JSON JSON keys */ +/** + * @apiDefine SUB_JSON JSON child keys + */ /** * @apiDefine ERROR_CODE Error Code */ @@ -891,6 +894,75 @@ * @apiError (ERROR_CODE) ORDER_PAID Order has already been paid * */ +/** + * @api {PUT} /api/v1.0/customs/partners/{partner_code}/declare/query/{client_report_id} Create Declare No. + * @apiName declare_report + * @apiDescription + * Used to submit the attachment information of the order required by the merchant. WeChat and Alipay are only supported. WeChat only supports payment orders within one month for customs declaration. + * + * @apiVersion 1.0.0 + * @apiGroup CustomsDeclare + * @apiHeader Accept application/json + * @apiHeader Content-Type application/json + * @apiParam (PathVariable) {String} partner_code Required, Partner code + * @apiParam (PathVariable) {String} client_report_id Required, Client declare ID + * @apiUse Sign + * @apiParam (JSON) {String} order_id Required, Partner order id + * @apiParam (JSON) {String} custom Required, Customs No. * Customs No. + * @apiParam (JSON) {String} mch_custom_id Required, Customs record id + * @apiParam (JSON) {String} mch_custom_name Required, Customs record name + * @apiParam (JSON) {JSONArray} sub_order Child orders + * + * @apiParam (SUB_JSON) {String} sub_order_no Child order ID + * @apiParam (SUB_JSON) {String=CNY} fee_type=CNY Currency + * @apiParam (SUB_JSON) {Double} order_fee Child Order Amount + * @apiParam (SUB_JSON) {Double} transport_fee Child Order Logistics Amount + * + * @apiSuccess {String} report_id RoyalPay declare ID + * @apiSuccess {String} client_report_id Client declare ID + * @apiSuccess {int} report_status 0:PROCCESSING,1:SUBMITED,2:FAIL,3:SUCCESS + * @apiSuccess {String} channel Channel + * @apiSuccess {String} custom Customs No. + * @apiSuccess {String} mch_custom_no Customs record ID + * @apiSuccess {String} mch_custom_name Customs record name + * @apiSuccess {String} order_id Royalpay Order ID + * @apiSuccess {String} transaction_id Channel Order ID + * @apiSuccess {String} order_currency Currency + * @apiSuccess {Double} order_amount Order Amount + * @apiSuccess {String} report_time Declare Time + * @apiSuccess {String} creation_date Create Time + * @apiSuccess {String} last_update_date Update Time + * @apiSuccess {String} error_code Error Code + * @apiSuccess {String} error_msg Error Description + * + * @apiUse GlobalError + * @apiError (ERROR_CODE) ORDER_MISMATCH Order is not belong to this partner + * + */ +/** + * @api {PUT} /api/v1.0/customs/partners/{partner_code}/declare/query/{report_id} Query Declare ID + * @apiName declare_query + * @apiDescription + * Used by the merchant to check the status of the customs declaration number. + * + * @apiVersion 1.0.0 + * @apiGroup CustomsDeclare + * @apiHeader Accept application/json + * @apiHeader Content-Type application/json + * @apiParam (PathVariable) {String} partner_code Required, Partner code + * @apiParam (PathVariable) {String} report_id Required,RoyalPay Declare ID + * @apiUse Sign + * + * @apiSuccess {String} return_code Execution result + * @apiSuccess {String} report_status Result status + * @apiSuccess {String} report_id Client declare ID + * @apiSuccess {String} return_msg Error Description + * @apiSuccess {String} order_id RoyalPay Order + * + * @apiUse GlobalError + * @apiError (ERROR_CODE) ORDER_MISMATCH Order is not belong to this partner + * + */ function apis() { } From 247a20d4fdbb8f4dc7f52252936578b0688abb18 Mon Sep 17 00:00:00 2001 From: "james.zhao" Date: Mon, 18 Feb 2019 20:16:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=95=86=E6=88=B7=E7=AB=AF=E6=8A=A5?= =?UTF-8?q?=E5=85=B3=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/custom/beans/QueryCustomVo.java | 38 ++++-- .../custom/core/impl/CustomServiceImpl.java | 10 +- .../custom/CustomReportDetailsMapper.java | 2 +- .../mappers/custom/CustomReportsMapper.java | 2 +- .../mappers/custom/CustomReportsMapper.xml | 9 +- src/main/ui/static/payment/custom/custom.js | 72 +++++++++-- .../payment/custom/templates/custom.html | 121 +++++++++++++----- .../payment/custom/templates/custom_add.html | 62 ++++----- .../custom/templates/custom_detail.html | 16 +-- .../process/custom/ManualReportCustom.java | 52 ++++---- 10 files changed, 262 insertions(+), 122 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 1297d19f7..0f285f0ec 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 @@ -1,9 +1,12 @@ package au.com.royalpay.payment.manage.custom.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.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -12,8 +15,9 @@ import java.text.SimpleDateFormat; * @date 2018/7/27 */ public class QueryCustomVo { - - private String date; + private final DateFormat format = new SimpleDateFormat("yyyyMMdd"); + private String datefrom; + private String dateto; private String channel; private String report_status; private int page = 1; @@ -21,12 +25,18 @@ public class QueryCustomVo { public JSONObject toParam() { JSONObject result = new JSONObject(); - if (StringUtils.isNotEmpty(date)) { - date = date.replace("Z", " UTC"); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z"); + if (datefrom != null) { + try { + result.put("from", format.parse(datefrom)); + } catch (ParseException e) { + throw new ParamInvalidException("datefrom", "error.payment.valid.invalid_date_format"); + } + } + if (dateto != null) { try { - result.put("date", format.parse(date)); + result.put("to", DateUtils.addDays(format.parse(dateto), 1)); } catch (ParseException e) { + throw new ParamInvalidException("dateto", "error.payment.valid.invalid_date_format"); } } if (StringUtils.isNotEmpty(channel)) { @@ -54,12 +64,20 @@ public class QueryCustomVo { this.limit = limit; } - public String getDate() { - return date; + public String getDatefrom() { + return datefrom; + } + + public void setDatefrom(String datefrom) { + this.datefrom = datefrom; + } + + public String getDateto() { + return dateto; } - public void setDate(String date) { - this.date = date; + public void setDateto(String dateto) { + this.dateto = dateto; } public String getChannel() { 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 8d473b7a5..47694c5e7 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 @@ -19,7 +19,9 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import java.util.ArrayList; import java.util.List; +import java.util.UUID; import javax.annotation.Resource; @@ -55,7 +57,7 @@ public class CustomServiceImpl implements CustomService { if (report != null) { throw new BadRequestException("report record exist"); } - CustomReport customReport = new CustomReport(addCustomVO.getOrder_id(), addCustomVO.getMch_custom_id(), addCustomVO.getMch_custom_name(), + CustomReport customReport = new CustomReport(UUID.randomUUID().toString(),addCustomVO.getOrder_id(), addCustomVO.getMch_custom_id(), addCustomVO.getMch_custom_name(), addCustomVO.getCustom()); customReport.addExtMchCustom(addCustomVO.getMch_ext_custom_id(), addCustomVO.getMch_ext_custom_name()); if (!CollectionUtils.isEmpty(addCustomVO.getSubOrders())) { @@ -83,7 +85,11 @@ public class CustomServiceImpl implements CustomService { @Override public JSONObject query(JSONObject param, int page, int limit) { param.put("orderStatus", OrderStatus.SUCCESS.getStatus()); - List channels = customSupport.customSupportedChannels(param.getIntValue("client_id")); +// List channels = customSupport.customSupportedChannels(param.getIntValue("client_id")); + List channels = new ArrayList<>(); + channels.add("Wechat"); + channels.add("Alipay"); + channels.add("AlipayOnline"); param.put("channels", channels); if (!StringUtils.isEmpty(param.getString("channel"))) { channels.clear(); 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 59316c558..1d148ba56 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 @@ -15,7 +15,7 @@ import cn.yixblog.support.mybatis.autosql.annotations.SqlType; /** * Created by yishuqian on 9/1/16. */ -@AutoMapper(tablename = "pmt_custom_report_details", pkName = "sub_order_no") +@AutoMapper(tablename = "pmt_custom_report_detail", pkName = "sub_order_no") public interface CustomReportDetailsMapper { @AutoSql(type = SqlType.SELECT) List findByReportId(@Param("report_id") String report_id); diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.java index 441f8756a..f06a9b6e6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/custom/CustomReportsMapper.java @@ -15,7 +15,7 @@ import cn.yixblog.support.mybatis.autosql.annotations.SqlType; /** * Created by yishuqian on 9/1/16. */ -@AutoMapper(tablename = "pmt_custom_reports", pkName = "report_id") +@AutoMapper(tablename = "pmt_custom_report", pkName = "report_id") public interface CustomReportsMapper { @AutoSql(type = SqlType.SELECT) JSONObject findOne(@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 ec3880a92..a8653e78c 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 @@ -12,7 +12,7 @@ pmt_transactions t on o.order_id = t.order_id left join - pmt_custom_reports r + pmt_custom_report r on r.order_id = o.order_id where o.channel in ( @@ -33,13 +33,12 @@ - - and DATE(t.transaction_time) = #{date} - + and t.transaction_time >= #{from} + and t.transaction_time < #{to} and r.report_status = #{report_status} order by transaction_time desc - \ 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 d81c288da..e62eb0dea 100644 --- a/src/main/ui/static/payment/custom/custom.js +++ b/src/main/ui/static/payment/custom/custom.js @@ -11,7 +11,41 @@ app.controller('customCtrl', ['$scope', '$http', 'commonDialog','$filter','$uibModal', function ($scope, $http, commonDialog,$filter,$uibModal) { $scope.pagination = {}; $scope.customOrders = {}; - $scope.params = {channel:'ALL',report_status:'ALL'}; + $scope.params = {channel :'ALL' ,report_status:'ALL',datefrom: new Date(), dateto: new Date()}; + $scope.chooseToday = function () { + $scope.params.datefrom = $scope.params.dateto = new Date(); + $scope.loadList(1); + }; + $scope.chooseYesterday = function () { + var yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + $scope.params.datefrom = $scope.params.dateto = yesterday; + $scope.loadList(1); + }; + $scope.chooseLast7Days = function () { + $scope.params.dateto = new Date(); + var day = new Date(); + day.setDate(day.getDate() - 7); + $scope.params.datefrom = day; + $scope.loadList(1); + }; + $scope.thisMonth = function () { + $scope.params.dateto = new Date(); + var monthBegin = new Date(); + monthBegin.setDate(1); + $scope.params.datefrom = monthBegin; + $scope.loadList(1); + }; + $scope.lastMonth = function () { + var monthFinish = new Date(); + monthFinish.setDate(0); + $scope.params.dateto = monthFinish; + var monthBegin = new Date(); + monthBegin.setDate(0); + monthBegin.setDate(1); + $scope.params.datefrom = monthBegin; + $scope.loadList(1); + }; $scope.loadList = function () { var params = angular.copy($scope.params); if (params.channel =='ALL'){ @@ -20,6 +54,16 @@ if (params.report_status =='ALL'){ delete params.report_status; } + if (params.datefrom) { + params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd'); + } else { + params.datefrom = $filter('date')(new Date(), 'yyyyMMdd'); + } + if (params.dateto) { + params.dateto = $filter('date')(params.dateto, 'yyyyMMdd'); + } else { + params.dateto = $filter('date')(new Date(), 'yyyyMMdd'); + } params.page = $scope.pagination.page || 1; $http.get('/custom/query',{params: params}).then(function (resp) { $scope.customOrders = resp.data.data; @@ -109,12 +153,24 @@ } $scope.custom.subOrders = $scope.subOrders; var param = angular.copy($scope.custom); - $http.post('/custom', param).then(function (resp) { + param.custom = $scope.custom.ext_custom_info[0]; + $http.post('/custom',param).then(function (resp) { $scope.$close(); }, function (resp) { commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); $scope.$close(); - }) + }); + if($scope.custom.ext_custom_info[1]){ + var infos = angular.copy($scope.custom); + infos.custom = $scope.custom.ext_custom_info[1]; + $http.post('/custom', infos).then(function (resp) { + $scope.$close(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + $scope.$close(); + }) + } + } $scope.removeSubOrders = function (order) { for(var i= 0 ;i<$scope.subOrders.length;i++){ @@ -195,13 +251,13 @@ return function (status) { switch (status + '') { case '0': - return 'Saved'; + return '暂存'; case '1': - return 'Submitted'; + return '已提交'; case '2': - return 'Failed'; + return '失败'; case '3': - return 'Success'; + return '成功'; } } }); @@ -209,4 +265,4 @@ return app; -}); \ No newline at end of file +}); diff --git a/src/main/ui/static/payment/custom/templates/custom.html b/src/main/ui/static/payment/custom/templates/custom.html index 15473745f..1d16e662d 100644 --- a/src/main/ui/static/payment/custom/templates/custom.html +++ b/src/main/ui/static/payment/custom/templates/custom.html @@ -5,12 +5,12 @@
-

Custom

+

海关

@@ -35,52 +35,114 @@
-->
- +

All | + ng-click="params.report_status='ALL';loadList()">全部 | Saved | + ng-click="params.report_status='0';loadList()">暂存 | Submitted | + ng-click="params.report_status='1';loadList()">已提交 | Failed | + ng-click="params.report_status='2';loadList()">失败 | Success | + ng-click="params.report_status='3';loadList()">成功 |

- +
- +

+ 全部 | + 微信 | + 支付宝| + 支付宝线上 +

+
+
+
+ +
+ +
+ ~ +
+ +
+
+ 今日 +
+
+ 昨日 +
+ +
+ 本月 +
+
+ 上月 +
+
+ +
+
+
-
+ + + + + + + + + + +
-

- Custom Order List +

+ 报关订单列表 + 商户报关API

- - - - - - + + + + + + @@ -116,20 +178,20 @@
Order IdTimeOrder AmountCNY AmountReport StatusOperation订单号时间金额金额(CNY)报关状态操作
- - Submit + 提交 - - @@ -153,8 +215,7 @@ first-text="«" last-text="»">
-
Total Records:{{pagination.totalCount}};Total - Pages:{{pagination.totalPages}} +
总单数:{{pagination.totalCount}};总页数:{{pagination.totalPages}}
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 decf68d7b..7fd6cfe75 100644 --- a/src/main/ui/static/payment/custom/templates/custom_add.html +++ b/src/main/ui/static/payment/custom/templates/custom_add.html @@ -1,6 +1,6 @@