From 8ac418984adddf28b343f0c167fd7c363ba1702e Mon Sep 17 00:00:00 2001 From: Owen <595466820@qq.com> Date: Thu, 26 Dec 2024 22:05:28 +0800 Subject: [PATCH] =?UTF-8?q?Feat:=20Api=20=E8=81=94=E9=80=9A=20+=20?= =?UTF-8?q?=E5=9C=B0=E5=8C=BA=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../haoka/api/HaokaAllSuperiorApiService.java | 134 +++++++++++++++++- .../haoka/api/liantong/LianTongApiUtil.java | 8 +- .../admin/api/HaokaApiController.java | 80 ++++++++--- 3 files changed, 194 insertions(+), 28 deletions(-) diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/HaokaAllSuperiorApiService.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/HaokaAllSuperiorApiService.java index 5f5215b68f..44790ada6a 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/HaokaAllSuperiorApiService.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/HaokaAllSuperiorApiService.java @@ -4,8 +4,8 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.haoka.api.liantong.LianTongApiUtil; import cn.iocoder.yudao.module.haoka.api.liantong.client.ZopClient; import cn.iocoder.yudao.module.haoka.api.liantong.model.ZopResponse; -import cn.iocoder.yudao.module.haoka.api.liantong.model.request.KingNumSelectRequest; -import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingNumSelectResponse; +import cn.iocoder.yudao.module.haoka.api.liantong.model.request.*; +import cn.iocoder.yudao.module.haoka.api.liantong.model.response.*; import cn.iocoder.yudao.module.haoka.dal.dataobject.superiorapi.SuperiorApiDevConfigDO; import cn.iocoder.yudao.module.haoka.service.superiorapi.SuperiorApiDevConfigService; import cn.iocoder.yudao.module.haoka.service.superiorapi.SuperiorApiService; @@ -35,16 +35,142 @@ public class HaokaAllSuperiorApiService { private ZopClient lianTongZopClient(ApiFrom apiFrom) { Map devConfig = this.getDevConfig(apiFrom); + return this.lianTongZopClient(devConfig); + } + private ZopClient lianTongZopClient(Map devConfig) { + String reqUrl = devConfig.get(LianTongApiUtil.KEY_reqUrl); String appCode = devConfig.get(LianTongApiUtil.KEY_appCode); String hmac = devConfig.get(LianTongApiUtil.KEY_hmac); String aes = devConfig.get(LianTongApiUtil.KEY_aes); - - return LianTongApiUtil.getClient(appCode, hmac, aes); + return LianTongApiUtil.getClient(reqUrl, appCode, hmac, aes); } public KingNumSelectResponse lianTongSelectNumber(KingNumSelectRequest kingNumSelectRequest) { ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); return zopClient.execute(kingNumSelectRequest); } + + /** + * 联通:占号接口,占号期间类需要把订单同步给联通:调用完成同步订单接口, + * + * @param request request + * @return KingNumStateChangeResponse + */ + public KingNumStateChangeResponse lianTongZhanHao(KingNumStateChangeRequest request) { + ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + return zopClient.execute(request); + } + + /** + * 联通---收货地址省市区和号码省市信息查询接口 + *

+ * 用于查询收货地址的省市区信息和号码归属省市信息。 + * + * @param request 请求参数 + * @return KingPostInfoResponse + */ + public KingPostInfoResponse lianTongPostInfoQuery(KingPostInfoRequest request) { + ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + return zopClient.execute(request); + } + + /** + * 资料提交 + * + * @param request request + * @return KingIdentityCustV2Response + */ + public KingIdentityCustV2Response lianTongSubmitUserInfo(KingIdentityCustV2Request request) { + ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + return zopClient.execute(request); + } + + + /** + * 联通---意向单同步接口 + *

+ * 用于用户填写完身份证信息、联系电话、收货地址信息后,将意向单数据(未选号)同步给联通商城。 + * + * @param request 请求参数 + * @return KingPreOrderSyncResponse + */ + public KingPreOrderSyncResponse lianTongPreOrderSync(KingPreOrderSyncRequest request) { + ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + return zopClient.execute(request); + } + + + /** + * 联通---同步订单 + *

+ * goodsId Y String V12 商品编码:咨询联通商城管理员;此处商品ID以省份编码开头,意为商城省份商品ID,比如北京的商品ID为11XXXXXXXXXX + * provinceCode Y String F2 号码省份 + * cityCode Y String F3 号码地市 + * phoneNum Y String V20 号码 + * token Y String V500 预约单同步服务返回参数 + * createTime Y String V30 订单创建时间,格式:yyyy-mm-dd hh24miss + * isOpenCF Y String V1 是否开通呼叫转移服务: 0不开通 1开通(2C业务必传) + * actId N String V8 合约id—如果是金融分期必选 + * totalPrice N String V15 总价 = 商品价格+号码预存款的价格 (单位 : 厘) + * captchaId N String V 19 短信验证码校验流水(短信验证码校验接口返回值 ) + * + * @param request request + * @return KingOrderSyncResponse + * rspCode Y String F4 0000-操作成功;0002-当前客户正在下单(仅在并发请求情况下出现,不是业务逻辑异常);P002-号码查询服务失败;9999-其他错误;8888-订单已存在注:针对9999报错,建议第三方增加订单同步重试机制,设置重试次数上限,如5。如都返回失败联系商城管理员走运维处理 + * rspDesc N String V256 如果同步失败,此处说明原因 + * uuid Y String V256 流水号 + * body N JSONString V500 {\"mallOrderId\":\"369705189376\",\"orderNo\":\"7019042323299970\",\"preNumber\":\"17600271211\",\"shortUrl\":\"https://url.cn/5t6aZM\"}(shortUrl:非必返回参数,证件信息大于十六岁会返回该参数。) + */ + public KingOrderSyncResponse lianTongOrderSyncV2(KingOrderSyncV2Request request) { + ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + // request.setGoodsId(GOODS_ID); + // request.setProvinceCode(PROVINCE_CODE); + // request.setCityCode(CITY_CODE); + // request.setPhoneNum(number); + // request.setToken(token); + // request.setCreateTime(CREATE_TIME); + return zopClient.execute(request); + } + + + /** + * @param type 消息类型:3-下单消息;4-订单状态变更消息 + */ + public KingMessageGetResponse lianTongMessageGet(String type) { + Map devConfig = this.getDevConfig(ApiFrom.LianTong); + String msgChannel = devConfig.get(LianTongApiUtil.KEY_msgChannel); + + KingMessageGetRequest request = new KingMessageGetRequest(); + request.setType(type); + request.setMsgChannel(msgChannel); + + ZopClient zopClient = this.lianTongZopClient(devConfig); + return zopClient.execute(request); + } + + /** + * @param megIds 消息id,支持传多个,逗号分隔,如:5418052422792399,3018052422792357,1518061322813443 + * @param type 消息类型:3-下单消息;4-订单状态变更消息 + */ + public KingMessageDelResponse lianTongMessageDel(String type, String megIds) { + KingMessageDelRequest request = new KingMessageDelRequest(); + request.setType(type); + request.setMsgId(megIds); + ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + return zopClient.execute(request); + } + + /** + * 联通---token选号接口 + *

+ * 用于通过 token 进行选号操作。 + * + * @param request 请求参数 + * @return KingNumSelectResponse + */ + public KingNumSelectResponse lianTongTokenSelectNumber(KingNumTokenSelectRequest request) { + ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + return zopClient.execute(request); + } } diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/liantong/LianTongApiUtil.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/liantong/LianTongApiUtil.java index df52ee12fc..b574e4d8e3 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/liantong/LianTongApiUtil.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/liantong/LianTongApiUtil.java @@ -11,12 +11,16 @@ public class LianTongApiUtil { public static final String KEY_hmac = "hmac"; public static final String KEY_aes = "aes"; - public static ZopClient getClient( String appCode ,String hmac,String aes){ + public static final String KEY_reqUrl = "reqUrl"; + + public static final String KEY_msgChannel = "msgChannel"; + + public static ZopClient getClient( String reqUrl,String appCode ,String hmac,String aes){ // String appCode = "1A2715D230724895AFB318FE8919244A"; // String hmac = "wi/iBAuOWhfn63nEw8/yi2g1kypvdc1X7qt901z1G+uZN2JzdW0SwsxBwYDGYBDW+etr2i4V/rLpXp5yQb9BBg=="; // String aes = "uH6eH0iGoFsgsfOHOF/kUw=="; - return new ZopHttpClient(appCode, hmac, aes); + return new ZopHttpClient(reqUrl,appCode, hmac, aes); } public static void main(String[] args) { diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/api/HaokaApiController.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/api/HaokaApiController.java index c0f4fd4eff..11c1a672de 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/api/HaokaApiController.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/api/HaokaApiController.java @@ -1,37 +1,18 @@ package cn.iocoder.yudao.module.haoka.controller.admin.api; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.haoka.api.HaokaAllSuperiorApiService; -import cn.iocoder.yudao.module.haoka.api.liantong.model.ZopResponse; -import cn.iocoder.yudao.module.haoka.api.liantong.model.request.KingNumSelectRequest; -import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingNumSelectResponse; -import cn.iocoder.yudao.module.haoka.controller.admin.demo.vo.HaokaDemoPageReqVO; -import cn.iocoder.yudao.module.haoka.controller.admin.demo.vo.HaokaDemoRespVO; -import cn.iocoder.yudao.module.haoka.controller.admin.demo.vo.HaokaDemoSaveReqVO; -import cn.iocoder.yudao.module.haoka.dal.dataobject.demo.HaokaDemoDO; -import cn.iocoder.yudao.module.haoka.service.demo.HaokaDemoService; +import cn.iocoder.yudao.module.haoka.api.liantong.model.request.*; +import cn.iocoder.yudao.module.haoka.api.liantong.model.response.*; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import java.io.IOException; -import java.util.List; - -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -@Tag(name = "上游接口") +@Tag(name = "API----上游接口") @RestController @RequestMapping("/haoka/api") @Validated @@ -47,4 +28,59 @@ public class HaokaApiController { return success(zopResponse); } + @PostMapping("/lian-tong/zhan-hao") + @Operation(summary = "联通占号接口") + public CommonResult lianTongZhanHao(@RequestBody KingNumStateChangeRequest request) { + KingNumStateChangeResponse response = haokaAllSuperiorApiService.lianTongZhanHao(request); + return success(response); + } + + @PostMapping("/lian-tong/submit-user-info") + @Operation(summary = "联通资料提交接口") + public CommonResult lianTongSubmitUserInfo(@RequestBody KingIdentityCustV2Request request) { + KingIdentityCustV2Response response = haokaAllSuperiorApiService.lianTongSubmitUserInfo(request); + return success(response); + } + + @PostMapping("/lian-tong/order-sync-v2") + @Operation(summary = "联通订单同步接口") + public CommonResult lianTongOrderSyncV2(@RequestBody KingOrderSyncV2Request request) { + KingOrderSyncResponse response = haokaAllSuperiorApiService.lianTongOrderSyncV2(request); + return success(response); + } + + @GetMapping("/lian-tong/message-get") + @Operation(summary = "联通消息获取接口") + public CommonResult lianTongMessageGet(@RequestParam String type) { + KingMessageGetResponse response = haokaAllSuperiorApiService.lianTongMessageGet(type); + return success(response); + } + + @PostMapping("/lian-tong/message-del") + @Operation(summary = "联通消息删除接口") + public CommonResult lianTongMessageDel(@RequestParam String type, @RequestParam String megIds) { + KingMessageDelResponse response = haokaAllSuperiorApiService.lianTongMessageDel(type, megIds); + return success(response); + } + + @PostMapping("/lian-tong/pre-order-sync") + @Operation(summary = "联通意向单同步接口") + public CommonResult lianTongPreOrderSync(@RequestBody KingPreOrderSyncRequest request) { + KingPreOrderSyncResponse response = haokaAllSuperiorApiService.lianTongPreOrderSync(request); + return success(response); + } + + @PostMapping("/lian-tong/post-info-query") + @Operation(summary = "联通收货地址和号码信息查询接口") + public CommonResult lianTongPostInfoQuery(@RequestBody KingPostInfoRequest request) { + KingPostInfoResponse response = haokaAllSuperiorApiService.lianTongPostInfoQuery(request); + return success(response); + } + + @PostMapping("/lian-tong/token-select-number") + @Operation(summary = "联通token选号接口") + public CommonResult lianTongTokenSelectNumber(@RequestBody KingNumTokenSelectRequest request) { + KingNumSelectResponse response = haokaAllSuperiorApiService.lianTongTokenSelectNumber(request); + return success(response); + } }