diff --git a/src/document/cn/apis.js b/src/document/cn/apis.js index f0e0dbcc7..de43ef974 100644 --- a/src/document/cn/apis.js +++ b/src/document/cn/apis.js @@ -756,52 +756,15 @@ * */ /** - * @api {PUT} /api/v1.0/alipay/partners/{partner_code}/app_orders/{order_id} 创建支付宝SDK订单 - * @apiName AlipaySDK - * @apiDescription - * 用于移动端APP调用支付宝SDK支付,调用API创建订单,得到支付宝SDK调用参数,将参数传递给SDK拉起支付宝支付,并由支付宝客户端直接返回支付结果。 - * 强烈建议获得支付结果后再调用RoyalPay订单查询API确认完成支付后再进行后续流程,避免因超时自动撤单导致资金损失
- *
- * 关于客户端和支付宝整合的更多信息: 支付宝SDK文档
- * SDK for Android
- * SDK for iOS - * - * @apiVersion 1.0.0 - * @apiGroup SDKPayment - * @apiHeader Accept application/json - * @apiHeader Content-Type application/json - * @apiParam (PathVariable) {String} partner_code 必填,商户编码,由4位大写字母或数字构成 - * @apiParam (PathVariable) {String} order_id 必填,商户支付订单号,要求同一商户唯一 - * @apiUse Sign - * @apiParam (JSON) {String} description 必填,订单标题(最大长度128字符,超出自动截取) - * @apiParam (JSON) {int} price 必填,金额,单位为货币最小单位,例如使用100表示AUD1.00 - * @apiParam (JSON) {String=AUD,CNY} currency=AUD 币种代码 - * @apiParam (JSON) {String} notify_url 支付通知url,详见支付通知api,不填则不会推送支付通知 - * @apiParam (JSON) {String} operator 操作人员标识 - * @apiParam (JSON) {String=android,iphone,ipad} system 客户端操作系统类型,可选参数 - * @apiParam (JSON) {String} version 客户端版本号,可选参数 - * - * @apiSuccess {String} return_code 执行结果 - * @apiSuccess {String} result_code SUCCESS表示创建订单成功,EXISTS表示订单已存在 - * @apiSuccess {String} partner_code 商户编码 - * @apiSuccess {String} full_name 商户注册全名 - * @apiSuccess {String} partner_name 商户名称 - * @apiSuccess {String} order_id RoyalPay订单ID,同时也是微信订单ID,最终支付成功的订单ID可能不同 - * @apiSuccess {String} partner_order_id 商户订单ID - * @apiSuccess {String} sdk_params 调用SDK的参数字符串 - * - * @apiUse GlobalError - * @apiError (ERROR_CODE) ORDER_MISMATCH 订单号与商户不匹配 - * @apiError (ERROR_CODE) ORDER_PAID 订单已支付 - * - */ -/** - * @api {PUT} /api/v1.0/gateway/partners/{partner_code}/app_orders/{order_id} 创建微信SDK订单 - * @apiName WechatSDK + * @api {PUT} /api/v1.0/gateway/partners/{partner_code}/app_orders/{order_id} 创建SDK订单 + * @apiName SDK * @apiDescription * 用于移动端APP调用微信SDK支付,调用API创建订单,得到微信SDK调用参数,将参数传递给SDK拉起微信支付,并由微信客户端直接返回支付结果。 * 强烈建议获得支付结果后再调用RoyalPay订单查询API确认完成支付后再进行后续流程,避免因超时自动撤单导致资金损失
*
+ * 关于客户端和支付宝整合的更多信息: 支付宝SDK文档
+ * SDK for Android
+ * SDK for iOS * * @apiVersion 1.0.0 * @apiGroup SDKPayment @@ -813,11 +776,12 @@ * @apiParam (JSON) {String} description 必填,订单标题(最大长度128字符,超出自动截取) * @apiParam (JSON) {int} price 必填,金额,单位为货币最小单位,例如使用100表示AUD1.00 * @apiParam (JSON) {String=AUD,CNY} currency=AUD 币种代码 + * @apiParam (JSON) {String=Alipay,Wechat} 支付渠道,必填,大小写敏感 * @apiParam (JSON) {String} notify_url 支付通知url,详见支付通知api,不填则不会推送支付通知 * @apiParam (JSON) {String} operator 操作人员标识 - * @apiParam (JSON) {String=android,iphone,ipad} system 客户端操作系统类型,可选参数 - * @apiParam (JSON) {String} version 客户端版本号,可选参数 - * @apiParam (JSON) {String} appid 微信 appid + * @apiParam (JSON) {String=android,iphone,ipad} system 客户端操作系统类型,支付宝通道可选,微信不需要 + * @apiParam (JSON) {String} version 客户端版本号,支付宝通道可选,微信不需要 + * @apiParam (JSON) {String} appid 微信 appid,微信通道要求必填 * * @apiSuccess {String} return_code 执行结果 * @apiSuccess {String} result_code SUCCESS表示创建订单成功,EXISTS表示订单已存在 diff --git a/src/document/en/apis.js b/src/document/en/apis.js index 86f8737d8..716e20dfe 100644 --- a/src/document/en/apis.js +++ b/src/document/en/apis.js @@ -769,54 +769,17 @@ * @apiError (ERROR_CODE) ORDER_PAID Order has already been paid * */ -/** - * @api {PUT} /api/v1.0/alipay/partners/{partner_code}/app_orders/{order_id} 创建支付宝SDK订单 - * @apiName AlipaySDK - * @apiDescription - * Used for mobile Apps calling Alipay payment with Alipay SDK. Call this api to create order and get param string for SDK calling. Call SDK api with the param to start payment and get payment result from Alipay app - * It is strongly advised to request RoyalPay order query Api to confirm that the order has been paid in order to cancelling order by system at the same time.
- *
- * More information for integration with Alipay: Alipay SDK Document
- * SDK for Android
- * SDK for iOS - * @apiVersion 1.0.0 - * @apiGroup SDKPayment - * @apiHeader Accept application/json - * @apiHeader Content-Type application/json - * @apiParam (PathVariable) {String} partner_code Required, Partner code - * @apiParam (PathVariable) {String} order_id Required, Partner order id - * @apiUse Sign - * @apiParam (JSON) {String} description Required, Order description - * @apiParam (JSON) {int} price Required, Price of the order. Use the base unit of the currency. - * @apiParam (JSON) {String=AUD,CNY} currency=AUD Currency - * @apiParam (JSON) {String} notify_url System will call the notify url if provided when the payment succeeds - * @apiParam (JSON) {String} operator Note for the operator who created this order. - * @apiParam (JSON) {String=android,iphone,ipad} system os type of client app, optional - * @apiParam (JSON) {String} version client app version, optional - * - * @apiSuccess {String} return_code Execution result - * @apiSuccess {String} result_code SUCCESS means order created successfully, EXISTS means order has already existed. - * @apiSuccess {String} partner_code Partner code - * @apiSuccess {String} full_name Partner's full company name when registered - * @apiSuccess {String} partner_name Partner's name - * @apiSuccess {String} order_id Order id in RoyalPay, which is also WeChat order id. The final order id which is paid may be different from this one - * @apiSuccess {String} partner_order_id Partner order id - * @apiSuccess {String} sdk_params param string for calling SDK - * - * @apiUse GlobalError - * @apiError (ERROR_CODE) ORDER_MISMATCH Order is not belong to this partner - * @apiError (ERROR_CODE) ORDER_PAID Order has already been paid - * - */ - /** - * @api {PUT} /api/v1.0/gateway/partners/{partner_code}/app_orders/{order_id} Create Wechat SDK Order - * @apiName WechatSDK + * @api {PUT} /api/v1.0/gateway/partners/{partner_code}/app_orders/{order_id} Create SDK Order + * @apiName SDK * @apiDescription * Used for mobile Apps calling Wechat payment with Wechat SDK. Call this api to create order and get param string for SDK calling. Call SDK api with the param to start payment and get payment result from Wechat app * It is strongly advised to request RoyalPay order query Api to confirm that the order has been paid in order to cancelling order by system at the same time.
*
+ * More information for integration with Alipay: Alipay SDK Document
+ * SDK for Android
+ * SDK for iOS * @apiVersion 1.0.0 * @apiGroup SDKPayment * @apiHeader Accept application/json @@ -827,11 +790,12 @@ * @apiParam (JSON) {String} description Required, Order description * @apiParam (JSON) {int} price Required, Price of the order. Use the base unit of the currency. * @apiParam (JSON) {String=AUD,CNY} currency=AUD Currency + * @apiParam (JSON) {String=Alipay,Wechat} payment channel, required, case sensitive * @apiParam (JSON) {String} notify_url System will call the notify url if provided when the payment succeeds * @apiParam (JSON) {String} operator Note for the operator who created this order. - * @apiParam (JSON) {String=android,iphone,ipad} system os type of client app, optional - * @apiParam (JSON) {String} version client app version, optional - * @apiParam (JSON) {String} appid wechat appid + * @apiParam (JSON) {String=android,iphone,ipad} system os type of client app, optional for Alipay, not required for Wechat + * @apiParam (JSON) {String} version client app version, optional for Alipay, not required for Wechat + * @apiParam (JSON) {String} appid wechat appid, required for Wechat, not required for Alipay * * @apiSuccess {String} return_code Execution result * @apiSuccess {String} result_code SUCCESS means order created successfully, EXISTS means order has already existed. diff --git a/src/main/ui/static/phpdemo.zip b/src/main/ui/static/phpdemo.zip index bac6014f9..779335b19 100644 Binary files a/src/main/ui/static/phpdemo.zip and b/src/main/ui/static/phpdemo.zip differ diff --git a/src/test/java/au/com/royalpay/payment/manage/task/FillExcelTask.java b/src/test/java/au/com/royalpay/payment/manage/task/FillExcelTask.java new file mode 100644 index 000000000..600c8b225 --- /dev/null +++ b/src/test/java/au/com/royalpay/payment/manage/task/FillExcelTask.java @@ -0,0 +1,83 @@ +package au.com.royalpay.payment.manage.task; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.io.FileUtils; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.ss.usermodel.*; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.*; +import java.util.function.BinaryOperator; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Create by yixian at 2018-05-01 17:15 + */ +public class FillExcelTask { + + private File rpayCat = new File("C:\\Users\\yixian\\develop\\royalpayv2\\manage\\src\\main\\ui\\static\\data\\royalpayindustry.json"); + private File wxCat = new File("C:\\Users\\yixian\\develop\\royalpayv2\\manage\\src\\main\\resources\\wx_industry.json"); + + private Map royalCatMap; + private Map wxCatMap; + private File excel = new File("C:\\Users\\yixian\\Documents\\bd_merchants.xlsx"); + + @Before + public void initCategory() throws IOException { + String rpayCatStr = FileUtils.readFileToString(rpayCat, "utf-8"); + JSONArray rpayCatJson = JSON.parseArray(rpayCatStr); + List flatCollect = rpayCatJson.stream().map(item -> (JSONObject) item) + .flatMap(item -> loadChildren(item).stream()).collect(Collectors.toList()); + royalCatMap = rpayCatJson.stream().map(item -> (JSONObject) item) + .flatMap(item -> loadChildren(item).stream()) + .collect(Collectors.toMap(item -> item.getString("mccCode"), item -> item.getString("label"), (a, b) -> a)); + + String wxCatStr = FileUtils.readFileToString(wxCat, "utf-8"); + JSONObject wxCatJson = JSON.parseObject(wxCatStr); + wxCatMap = wxCatJson.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> (String) entry.getValue())); + + } + + private List loadChildren(JSONObject entity) { + if (entity.containsKey("children") && !entity.getJSONArray("children").isEmpty()) { + List arr = new ArrayList<>(Arrays.asList(entity)); + arr.addAll(entity.getJSONArray("children").stream().map(item -> (JSONObject) item).flatMap(item -> loadChildren(item).stream()).collect(Collectors.toList())); + return arr; + } + return Collections.singletonList(entity); + } + + @Test + public void replaceCat() throws IOException, InvalidFormatException { + Workbook wb = WorkbookFactory.create(excel); + Sheet sheet = wb.getSheetAt(0); + for (int rn = 1; rn <= sheet.getLastRowNum(); rn++) { + Row row = sheet.getRow(rn); + Cell wxCatCell = row.getCell(2); + Cell rpCatCell = row.getCell(3); + fillCateLabel(wxCatCell, wxCatMap); + fillCateLabel(rpCatCell, royalCatMap); + } + wb.write(new FileOutputStream("C:\\Users\\yixian\\Documents\\bd_merchants_final.xlsx")); + } + + private void fillCateLabel(Cell rpCatCell, Map royalCatMap) { + if (rpCatCell == null) { + return; + } + if (rpCatCell.getCellType() == Cell.CELL_TYPE_NUMERIC) { + String typeNum = (int) rpCatCell.getNumericCellValue() + ""; + if (royalCatMap.get(typeNum) != null) { + rpCatCell.setCellType(Cell.CELL_TYPE_STRING); + rpCatCell.setCellValue(royalCatMap.get(typeNum)); + } + } + } +}