From a9250ed81cf387724ac089f7111b8f894dfc669b Mon Sep 17 00:00:00 2001 From: Owen <595466820@qq.com> Date: Sun, 29 Dec 2024 22:47:40 +0800 Subject: [PATCH] =?UTF-8?q?Feat:=20=E6=B7=BB=E5=8A=A0AIp=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/haoka/api/ApiConfigService.java | 8 +- .../yudao/module/haoka/api/ApiFrom.java | 17 +- .../haoka/api/ApiGuangZhouDXService.java | 9 +- .../module/haoka/api/ApiHaiNanDXService.java | 7 +- .../module/haoka/api/ApiHuNanDXService.java | 7 +- .../module/haoka/api/ApiLianTongService.java | 27 +- .../haoka/api/liantong/LianTongApiUtil.java | 2 + .../admin/address/AddressAreaController.java | 22 +- .../product/vo/HaoKaProductPageReqVO.java | 4 +- .../admin/product/vo/HaoKaProductRespVO.java | 2 +- .../product/vo/HaoKaProductSaveReqVO.java | 2 +- .../dataobject/product/HaoKaProductDO.java | 2 +- .../module/haoka/service/api/ApiDealResp.java | 14 + .../haoka/service/api/ApiDealServiceImpl.java | 55 ++++ .../haoka/service/api/ApiDealStrategy.java | 7 + .../service/api/ApiDealStrategyService.java | 8 + .../service/api/OrderApiCreateParam.java | 61 ++++ .../haoka/service/api/OrderApiCreateResp.java | 277 ++++++++++++++++++ .../haoka/service/api/OrderApiQueryParam.java | 54 ++++ .../haoka/service/api/OrderApiQueryResp.java | 277 ++++++++++++++++++ .../strategy/GuangZhouDxApiDealStrategy.java | 94 ++++++ .../api/strategy/HaiNanDxApiDealStrategy.java | 106 +++++++ .../api/strategy/HuNanDxApiDealStrategy.java | 111 +++++++ .../api/strategy/LianTongApiDealStrategy.java | 146 +++++++++ .../V3.0.17__alter_product_belongType.sql | 2 + 25 files changed, 1291 insertions(+), 30 deletions(-) create mode 100644 yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealResp.java create mode 100644 yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealServiceImpl.java create mode 100644 yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealStrategy.java create mode 100644 yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealStrategyService.java create mode 100644 yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiCreateParam.java create mode 100644 yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiCreateResp.java create mode 100644 yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiQueryParam.java create mode 100644 yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiQueryResp.java create mode 100644 yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/GuangZhouDxApiDealStrategy.java create mode 100644 yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HaiNanDxApiDealStrategy.java create mode 100644 yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HuNanDxApiDealStrategy.java create mode 100644 yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/LianTongApiDealStrategy.java create mode 100644 yudao-server/src/main/resources/db/migration/V3.0.17__alter_product_belongType.sql diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiConfigService.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiConfigService.java index 9cfb70fc57..1f8b71cb18 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiConfigService.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiConfigService.java @@ -18,7 +18,10 @@ public abstract class ApiConfigService { @Resource protected SuperiorApiDevConfigService superiorApiDevConfigService; - protected Map getDevConfig(ApiFrom apiFrom) { + abstract public ApiFrom getApiFrom(); + + public Map getDevConfig() { + ApiFrom apiFrom = getApiFrom(); List list = superiorApiDevConfigService.list( new LambdaQueryWrapperX() .eqIfPresent(SuperiorApiDevConfigDO::getHaokaSuperiorApiId, apiFrom.getId()) @@ -27,6 +30,9 @@ public abstract class ApiConfigService { return list.stream().collect(Collectors.toMap(SuperiorApiDevConfigDO::getCode, SuperiorApiDevConfigDO::getValue)); } + public String getConfigValue(String key) { + return getDevConfig().get(key); + } } diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiFrom.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiFrom.java index e896670e64..a196fbb7d2 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiFrom.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiFrom.java @@ -6,13 +6,20 @@ import lombok.Getter; @AllArgsConstructor @Getter public enum ApiFrom { - Unknown(0L, "未知道接口"), - LianTong(1L, "联通Api"), - GuangZhouDX(2L, "广州电信Api"), - HaiNanDX(3L, "海南电信Api"), - HuNanDX(4L, "湖南电信Api"); + Unknown(0L, "未知道接口", "Unknown"), + LianTong(1L, "联通Api", ApiFrom.LianTongApiDealStrategy), + GuangZhouDX(2L, "广州电信Api", ApiFrom.GuangZhouDXApiDealStrategy), + HaiNanDX(3L, "海南电信Api", ApiFrom.HaiNanDXApiDealStrategy), + HuNanDX(4L, "湖南电信Api", ApiFrom.HuNanDXApiDealStrategy); private final Long id; private final String name; + private final String apiDealStrategy; + + + public static final String LianTongApiDealStrategy = "LianTongApiDealStrategy"; + public static final String GuangZhouDXApiDealStrategy = "GuangZhouDXApiDealStrategy"; + public static final String HaiNanDXApiDealStrategy = "HaiNanDXApiDealStrategy"; + public static final String HuNanDXApiDealStrategy = "HuNanDXApiDealStrategy"; public static ApiFrom fromId(Long id) { ApiFrom[] values = values(); diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiGuangZhouDXService.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiGuangZhouDXService.java index e3d4706aef..cecb62e670 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiGuangZhouDXService.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiGuangZhouDXService.java @@ -18,7 +18,7 @@ public class ApiGuangZhouDXService extends ApiConfigService { public String createOrder(GdOrderCreateRequestParam param) { - Map devConfig = getDevConfig(ApiFrom.GuangZhouDX); + Map devConfig = getDevConfig(); String urlPrefix = devConfig.get(Key_urlPrefix); String publicKey = devConfig.get(Key_publicKey); try { @@ -32,7 +32,7 @@ public class ApiGuangZhouDXService extends ApiConfigService { public String queryOrder(GdOrderQueryRequestParam param) { - Map devConfig = getDevConfig(ApiFrom.GuangZhouDX); + Map devConfig = getDevConfig(); String urlPrefix = devConfig.get(Key_urlPrefix); String publicKey = devConfig.get(Key_publicKey); try { @@ -43,4 +43,9 @@ public class ApiGuangZhouDXService extends ApiConfigService { } return ""; } + + @Override + public ApiFrom getApiFrom() { + return ApiFrom.GuangZhouDX; + } } diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHaiNanDXService.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHaiNanDXService.java index e6da6d4768..0557ce93ff 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHaiNanDXService.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHaiNanDXService.java @@ -17,7 +17,7 @@ public class ApiHaiNanDXService extends ApiConfigService { public static final String Key_privateKey = "privateKey"; private HaiNanDianXinApi.HaiNanDianXinApiConfig getConfig() { - Map devConfig = this.getDevConfig(ApiFrom.HaiNanDX); + Map devConfig = this.getDevConfig(); String url = devConfig.get(Key_url); String appCode = devConfig.get(Key_appCode); @@ -59,4 +59,9 @@ public class ApiHaiNanDXService extends ApiConfigService { synOrderInfo(HaiNanDianXinApi.SynOrderInfoRequest param) throws UnirestException { return HaiNanDianXinApi.synOrderInfo(this.getConfig(), param); } + + @Override + public ApiFrom getApiFrom() { + return ApiFrom.HaiNanDX; + } } diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHuNanDXService.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHuNanDXService.java index 37d9ede081..fc9c3aef71 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHuNanDXService.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHuNanDXService.java @@ -23,7 +23,7 @@ public class ApiHuNanDXService extends ApiConfigService { * @return 配置信息对象 {@link HaiNanDxInfo.ConfigInfo} */ private HaiNanDxInfo.ConfigInfo getConfig() { - Map devConfig = getDevConfig(ApiFrom.HuNanDX); + Map devConfig = getDevConfig(); return new HaiNanDxInfo.ConfigInfo( devConfig.get(Key_accessToken), devConfig.get(Key_secret), @@ -127,4 +127,9 @@ public class ApiHuNanDXService extends ApiConfigService { checkBlackList(HaiNanDxInfo.BlackListCheckParam param) throws Exception { return HuNanDXApi.checkBlackList(getConfig(), param); } + + @Override + public ApiFrom getApiFrom() { + return ApiFrom.HuNanDX; + } } diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiLianTongService.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiLianTongService.java index da2db698d9..72555c1638 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiLianTongService.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiLianTongService.java @@ -11,8 +11,8 @@ import java.util.Map; @Service public class ApiLianTongService extends ApiConfigService { - private ZopClient lianTongZopClient(ApiFrom apiFrom) { - Map devConfig = this.getDevConfig(apiFrom); + public ZopClient lianTongZopClient() { + Map devConfig = this.getDevConfig(); return this.lianTongZopClient(devConfig); } @@ -25,7 +25,7 @@ public class ApiLianTongService extends ApiConfigService { } public KingNumSelectResponse lianTongSelectNumber(KingNumSelectRequest kingNumSelectRequest) { - ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + ZopClient zopClient = this.lianTongZopClient(); return zopClient.execute(kingNumSelectRequest); } @@ -36,7 +36,7 @@ public class ApiLianTongService extends ApiConfigService { * @return KingNumStateChangeResponse */ public KingNumStateChangeResponse lianTongZhanHao(KingNumStateChangeRequest request) { - ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + ZopClient zopClient = this.lianTongZopClient(); return zopClient.execute(request); } @@ -49,7 +49,7 @@ public class ApiLianTongService extends ApiConfigService { * @return KingPostInfoResponse */ public KingPostInfoResponse lianTongPostInfoQuery(KingPostInfoRequest request) { - ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + ZopClient zopClient = this.lianTongZopClient(); return zopClient.execute(request); } @@ -60,7 +60,7 @@ public class ApiLianTongService extends ApiConfigService { * @return KingIdentityCustV2Response */ public KingIdentityCustV2Response lianTongSubmitUserInfo(KingIdentityCustV2Request request) { - ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + ZopClient zopClient = this.lianTongZopClient(); return zopClient.execute(request); } @@ -74,7 +74,7 @@ public class ApiLianTongService extends ApiConfigService { * @return KingPreOrderSyncResponse */ public KingPreOrderSyncResponse lianTongPreOrderSync(KingPreOrderSyncRequest request) { - ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + ZopClient zopClient = this.lianTongZopClient(); return zopClient.execute(request); } @@ -101,7 +101,7 @@ public class ApiLianTongService extends ApiConfigService { * 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); + ZopClient zopClient = this.lianTongZopClient(); // request.setGoodsId(GOODS_ID); // request.setProvinceCode(PROVINCE_CODE); // request.setCityCode(CITY_CODE); @@ -116,7 +116,7 @@ public class ApiLianTongService extends ApiConfigService { * @param type 消息类型:3-下单消息;4-订单状态变更消息 */ public KingMessageGetResponse lianTongMessageGet(String type) { - Map devConfig = this.getDevConfig(ApiFrom.LianTong); + Map devConfig = this.getDevConfig(); String msgChannel = devConfig.get(LianTongApiUtil.KEY_msgChannel); KingMessageGetRequest request = new KingMessageGetRequest(); @@ -135,7 +135,7 @@ public class ApiLianTongService extends ApiConfigService { KingMessageDelRequest request = new KingMessageDelRequest(); request.setType(type); request.setMsgId(megIds); - ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + ZopClient zopClient = this.lianTongZopClient(); return zopClient.execute(request); } @@ -148,7 +148,12 @@ public class ApiLianTongService extends ApiConfigService { * @return KingNumSelectResponse */ public KingNumSelectResponse lianTongTokenSelectNumber(KingNumTokenSelectRequest request) { - ZopClient zopClient = this.lianTongZopClient(ApiFrom.LianTong); + ZopClient zopClient = this.lianTongZopClient(); return zopClient.execute(request); } + + @Override + public ApiFrom getApiFrom() { + return ApiFrom.LianTong; + } } 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 b574e4d8e3..3bbec5ce3c 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 @@ -15,6 +15,8 @@ public class LianTongApiUtil { public static final String KEY_msgChannel = "msgChannel"; + public static final String KEY_channel = "channel"; + public static ZopClient getClient( String reqUrl,String appCode ,String hmac,String aes){ // String appCode = "1A2715D230724895AFB318FE8919244A"; // String hmac = "wi/iBAuOWhfn63nEw8/yi2g1kypvdc1X7qt901z1G+uZN2JzdW0SwsxBwYDGYBDW+etr2i4V/rLpXp5yQb9BBg=="; diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/address/AddressAreaController.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/address/AddressAreaController.java index 65d2a58161..b3a29108a5 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/address/AddressAreaController.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/address/AddressAreaController.java @@ -1,18 +1,22 @@ package cn.iocoder.yudao.module.haoka.controller.admin.address; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.haoka.api.ApiFrom; import cn.iocoder.yudao.module.haoka.controller.admin.address.vo.AddressVo; import cn.iocoder.yudao.module.haoka.service.address.HaoKaAddressService; +import cn.iocoder.yudao.module.haoka.service.api.ApiDealResp; +import cn.iocoder.yudao.module.haoka.service.api.OrderApiCreateParam; +import cn.iocoder.yudao.module.haoka.service.api.OrderApiCreateResp; +import cn.iocoder.yudao.module.haoka.service.api.strategy.LianTongApiDealStrategy; 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.annotation.security.PermitAll; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -46,4 +50,14 @@ public class AddressAreaController { return success(haoKaAddressService.getAllAddress()); } + @Autowired + @Qualifier(ApiFrom.LianTongApiDealStrategy) + private LianTongApiDealStrategy lianTongApiDealStrategy; + + @Operation(summary = "联通订单全部流程接口") + @PostMapping("/preOrder") + public CommonResult> proOrder(@RequestBody OrderApiCreateParam param) { + ApiDealResp order = lianTongApiDealStrategy.createOrder(param); + return success(order); + } } diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/product/vo/HaoKaProductPageReqVO.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/product/vo/HaoKaProductPageReqVO.java index 25d6c964d9..620a1428c4 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/product/vo/HaoKaProductPageReqVO.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/product/vo/HaoKaProductPageReqVO.java @@ -28,7 +28,7 @@ public class HaoKaProductPageReqVO extends PageParam { private Long haokaProductTypeId; @Schema(description = "归属地") - private Integer belongAreaCode; + private String belongAreaCode; @Schema(description = "产品渠道", example = "6850") private Long haokaProductChannelId; @@ -76,4 +76,4 @@ public class HaoKaProductPageReqVO extends PageParam { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] createTime; -} \ No newline at end of file +} diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/product/vo/HaoKaProductRespVO.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/product/vo/HaoKaProductRespVO.java index 00b0114449..5708575745 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/product/vo/HaoKaProductRespVO.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/product/vo/HaoKaProductRespVO.java @@ -37,7 +37,7 @@ public class HaoKaProductRespVO { @Schema(description = "归属地", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("归属地") - private Integer belongAreaCode; + private String belongAreaCode; @Schema(description = "产品渠道", example = "6850") @ExcelProperty("产品渠道") diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/product/vo/HaoKaProductSaveReqVO.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/product/vo/HaoKaProductSaveReqVO.java index 2b9ced97ec..cfc9d30db3 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/product/vo/HaoKaProductSaveReqVO.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/product/vo/HaoKaProductSaveReqVO.java @@ -34,7 +34,7 @@ public class HaoKaProductSaveReqVO { @Schema(description = "归属地", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "归属地不能为空") - private Integer belongAreaCode; + private String belongAreaCode; @Schema(description = "产品渠道", example = "6850") private Long haokaProductChannelId; diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/dal/dataobject/product/HaoKaProductDO.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/dal/dataobject/product/HaoKaProductDO.java index e2c8c09667..695875db4e 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/dal/dataobject/product/HaoKaProductDO.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/dal/dataobject/product/HaoKaProductDO.java @@ -48,7 +48,7 @@ public class HaoKaProductDO extends BaseDO { /** * 归属地 */ - private Integer belongAreaCode; + private String belongAreaCode; /** * 产品渠道 */ diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealResp.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealResp.java new file mode 100644 index 0000000000..adf8d3efba --- /dev/null +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealResp.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.haoka.service.api; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ApiDealResp { + private Boolean success; + private String msg; + private T data; +} diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealServiceImpl.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealServiceImpl.java new file mode 100644 index 0000000000..32c7d400d8 --- /dev/null +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealServiceImpl.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.haoka.service.api; + +import cn.iocoder.yudao.module.haoka.api.ApiFrom; +import cn.iocoder.yudao.module.haoka.controller.admin.onsaleproduct.vo.OnSaleProductPreOrderRespVO; +import cn.iocoder.yudao.module.haoka.service.onsaleproduct.OnSaleProductService; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Service +public class ApiDealServiceImpl implements ApiDealStrategyService { + + @Resource + private Map strategyMap; + + @Resource + private OnSaleProductService onSaleProductService; + + + private ApiDealStrategy getApiDealStrategy(Long productId) { + OnSaleProductPreOrderRespVO onSaleProductPreOrder = onSaleProductService.getOnSaleProductPreOrder(productId); + if (onSaleProductPreOrder == null) { + return null; + } + ApiFrom apiFrom = onSaleProductPreOrder.getApiFrom(); + if (apiFrom == null) { + return null; + } + return this.getApiDealStrategy(apiFrom); + } + + @Override + public ApiDealResp createOrder(OrderApiCreateParam param) { + ApiDealStrategy apiDealStrategy = this.getApiDealStrategy(param.getProductId()); + if (apiDealStrategy == null) { + return new ApiDealResp<>(false, "NoneService", null); + } + return apiDealStrategy.createOrder(param); + } + + @Override + public ApiDealResp queryOrder(OrderApiCreateParam param) { + ApiDealStrategy apiDealStrategy = this.getApiDealStrategy(param.getProductId()); + if (apiDealStrategy == null) { + return new ApiDealResp<>(false, "NoneService", null); + } + return apiDealStrategy.queryOrder(param); + } + + @Override + public ApiDealStrategy getApiDealStrategy(ApiFrom apiFrom) { + return strategyMap.get(apiFrom.getApiDealStrategy()); + } +} diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealStrategy.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealStrategy.java new file mode 100644 index 0000000000..d7540d5b04 --- /dev/null +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealStrategy.java @@ -0,0 +1,7 @@ +package cn.iocoder.yudao.module.haoka.service.api; + +public interface ApiDealStrategy { + ApiDealResp createOrder(OrderApiCreateParam param); + + ApiDealResp queryOrder(OrderApiCreateParam param); +} diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealStrategyService.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealStrategyService.java new file mode 100644 index 0000000000..a69fe4bf41 --- /dev/null +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealStrategyService.java @@ -0,0 +1,8 @@ +package cn.iocoder.yudao.module.haoka.service.api; + +import cn.iocoder.yudao.module.haoka.api.ApiFrom; + +public interface ApiDealStrategyService extends ApiDealStrategy{ + ApiDealStrategy getApiDealStrategy(ApiFrom apiFrom); + +} diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiCreateParam.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiCreateParam.java new file mode 100644 index 0000000000..b20e651993 --- /dev/null +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiCreateParam.java @@ -0,0 +1,61 @@ +package cn.iocoder.yudao.module.haoka.service.api; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +import java.time.LocalDateTime; + + +@Data +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OrderApiCreateParam { + + private String outerOrderId; + + /** + * 订单ID AAA + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** + * 产品ID AAA + */ + private Long productId; + + + /** + * 购买号码 AAA + */ + private String planMobile; + + private String addressMobile; + + /** + * 证件姓名 AAA + */ + private String idCardName; + + /** + * 身份证号 AAA + */ + private String idCardNum; + + /** + * 地址区 AAA + */ + private String addressDistrict; + + /** + * 详细地址 AAA + */ + private String address; + +} diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiCreateResp.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiCreateResp.java new file mode 100644 index 0000000000..67adbfa210 --- /dev/null +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiCreateResp.java @@ -0,0 +1,277 @@ +package cn.iocoder.yudao.module.haoka.service.api; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +import java.time.LocalDateTime; + +/** + * 订单 DO + * + * @author xiongxiong + */ +@TableName("haoka_orders") +@KeySequence("haoka_orders_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OrderApiCreateResp extends BaseDO { + + private Object data; + + /** + * 订单ID + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + /** + * 生产商ID + */ + private Long producerId; + /** + * 商品名称 + */ + private String supplierProductName; + /** + * 商品编码 + */ + private String supplierProductSku; + /** + * 外部订单编号 + */ + private String sourceId; + /** + * 外部SKU + */ + private String sourceSku; + /** + * 分享ID + */ + private Long shareId; + /** + * 订单来源 + *

+ * 枚举 {@link TODO haoka_order_channel 对应的类} + */ + private String source; + /** + * 用户ID + */ + private Long userId; + /** + * 产品ID + */ + private Long productId; + /** + * 产品编码 + */ + private String productSku; + /** + * 用户下单时间 + */ + private LocalDateTime orderedAt; + /** + * 购买号码 + */ + private String planMobile; + /** + * 生产时间 + */ + private LocalDateTime producedAt; + /** + * 生产号码 + */ + private String planMobileProduced; + /** + * 发货时间 + */ + private LocalDateTime deliveredAt; + /** + * 证件姓名 + */ + private String idCardName; + /** + * 激活时间 + */ + private LocalDateTime activatedAt; + /** + * 身份证号 + */ + private String idCardNum; + /** + * 充值时间 + */ + private LocalDateTime rechargedAt; + /** + * 地址省编码 + */ + private String addressProvinceCode; + /** + * 卖家备注 + */ + private String memo; + /** + * 地址市编码 + */ + private String addressCityCode; + /** + * 数量 + */ + private String amount; + /** + * 地址区编码 + */ + private String addressDistrictCode; + /** + * 状态变更时间 + */ + private LocalDateTime statusUpdatedAt; + /** + * 地址省 + */ + private String addressProvince; + /** + * 交易状态 + *

+ * 枚举 {@link TODO pay_refund_status 对应的类} + */ + private String refundStatus; + /** + * 地址市 + */ + private String addressCity; + /** + * 激活状态 + *

+ * 枚举 {@link TODO haoka_order_active_status 对应的类} + */ + private String activeStatus; + /** + * 地址区 + */ + private String addressDistrict; + /** + * ICCID + */ + private String iccid; + /** + * 详细地址 + */ + private String address; + /** + * 外部订单编号 + */ + private String realSourceId; + /** + * 收件人电话 + */ + private String addressMobile; + /** + * 图片大小 + */ + private Long picSize; + /** + * 收件人姓名 + */ + private String addressName; + /** + * 归属地省 + */ + private String regionP; + /** + * 物流公司ID + */ + private Long trackingCompanyId; + /** + * 归属地市 + */ + private String regionC; + /** + * 物流单号 + */ + private String trackingNumber; + /** + * 供应商 + */ + private String merchantName; + /** + * 买家备注 + */ + private String buyerMemo; + /** + * 上游状态 + */ + private String upStatus; + /** + * 卖家备注 + */ + private String sellerMemo; + /** + * 上游订单号 + */ + private String upstreamOrderId; + /** + * 生产备注 + */ + private String producerMemo; + /** + * 镇/乡 + */ + private String town; + /** + * 订单状态 + *

+ * 枚举 {@link TODO haoka_order_status 对应的类} + */ + private Long status; + /** + * 物流公司名称 + */ + private String trackingCompany; + /** + * 标旗 + *

+ * 枚举 {@link TODO haoka_order_flag 对应的类} + */ + private Long flag; + /** + * 订单状态名称 + */ + private String statusName; + /** + * 预警区域 + */ + private String warnArea; + /** + * 加密收货电话 + */ + private String encryptAddressMobile; + /** + * 原因 + */ + private String reason; + /** + * 加密收货人姓名 + */ + private String encryptAddressName; + /** + * 加密证件姓名 + */ + private String encryptIdCardName; + /** + * 加密证件号码 + */ + private String encryptIdCardNum; + /** + * 加密详细地址 + */ + private String encryptAddress; + +} diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiQueryParam.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiQueryParam.java new file mode 100644 index 0000000000..21bf8de698 --- /dev/null +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiQueryParam.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.haoka.service.api; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.*; + + +@Data +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OrderApiQueryParam { + + /** + * 订单ID AAA + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** + * 产品ID AAA + */ + private Long productId; + + + /** + * 购买号码 AAA + */ + private String planMobile; + + private String addressMobile; + + /** + * 证件姓名 AAA + */ + private String idCardName; + + /** + * 身份证号 AAA + */ + private String idCardNum; + + /** + * 地址区 AAA + */ + private String addressDistrict; + + /** + * 详细地址 AAA + */ + private String address; + +} diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiQueryResp.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiQueryResp.java new file mode 100644 index 0000000000..c409eca52c --- /dev/null +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/OrderApiQueryResp.java @@ -0,0 +1,277 @@ +package cn.iocoder.yudao.module.haoka.service.api; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +import java.time.LocalDateTime; + +/** + * 订单 DO + * + * @author xiongxiong + */ +@TableName("haoka_orders") +@KeySequence("haoka_orders_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OrderApiQueryResp extends BaseDO { + + private Object data; + + /** + * 订单ID + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + /** + * 生产商ID + */ + private Long producerId; + /** + * 商品名称 + */ + private String supplierProductName; + /** + * 商品编码 + */ + private String supplierProductSku; + /** + * 外部订单编号 + */ + private String sourceId; + /** + * 外部SKU + */ + private String sourceSku; + /** + * 分享ID + */ + private Long shareId; + /** + * 订单来源 + *

+ * 枚举 {@link TODO haoka_order_channel 对应的类} + */ + private String source; + /** + * 用户ID + */ + private Long userId; + /** + * 产品ID + */ + private Long productId; + /** + * 产品编码 + */ + private String productSku; + /** + * 用户下单时间 + */ + private LocalDateTime orderedAt; + /** + * 购买号码 + */ + private String planMobile; + /** + * 生产时间 + */ + private LocalDateTime producedAt; + /** + * 生产号码 + */ + private String planMobileProduced; + /** + * 发货时间 + */ + private LocalDateTime deliveredAt; + /** + * 证件姓名 + */ + private String idCardName; + /** + * 激活时间 + */ + private LocalDateTime activatedAt; + /** + * 身份证号 + */ + private String idCardNum; + /** + * 充值时间 + */ + private LocalDateTime rechargedAt; + /** + * 地址省编码 + */ + private String addressProvinceCode; + /** + * 卖家备注 + */ + private String memo; + /** + * 地址市编码 + */ + private String addressCityCode; + /** + * 数量 + */ + private String amount; + /** + * 地址区编码 + */ + private String addressDistrictCode; + /** + * 状态变更时间 + */ + private LocalDateTime statusUpdatedAt; + /** + * 地址省 + */ + private String addressProvince; + /** + * 交易状态 + *

+ * 枚举 {@link TODO pay_refund_status 对应的类} + */ + private String refundStatus; + /** + * 地址市 + */ + private String addressCity; + /** + * 激活状态 + *

+ * 枚举 {@link TODO haoka_order_active_status 对应的类} + */ + private String activeStatus; + /** + * 地址区 + */ + private String addressDistrict; + /** + * ICCID + */ + private String iccid; + /** + * 详细地址 + */ + private String address; + /** + * 外部订单编号 + */ + private String realSourceId; + /** + * 收件人电话 + */ + private String addressMobile; + /** + * 图片大小 + */ + private Long picSize; + /** + * 收件人姓名 + */ + private String addressName; + /** + * 归属地省 + */ + private String regionP; + /** + * 物流公司ID + */ + private Long trackingCompanyId; + /** + * 归属地市 + */ + private String regionC; + /** + * 物流单号 + */ + private String trackingNumber; + /** + * 供应商 + */ + private String merchantName; + /** + * 买家备注 + */ + private String buyerMemo; + /** + * 上游状态 + */ + private String upStatus; + /** + * 卖家备注 + */ + private String sellerMemo; + /** + * 上游订单号 + */ + private String upstreamOrderId; + /** + * 生产备注 + */ + private String producerMemo; + /** + * 镇/乡 + */ + private String town; + /** + * 订单状态 + *

+ * 枚举 {@link TODO haoka_order_status 对应的类} + */ + private Long status; + /** + * 物流公司名称 + */ + private String trackingCompany; + /** + * 标旗 + *

+ * 枚举 {@link TODO haoka_order_flag 对应的类} + */ + private Long flag; + /** + * 订单状态名称 + */ + private String statusName; + /** + * 预警区域 + */ + private String warnArea; + /** + * 加密收货电话 + */ + private String encryptAddressMobile; + /** + * 原因 + */ + private String reason; + /** + * 加密收货人姓名 + */ + private String encryptAddressName; + /** + * 加密证件姓名 + */ + private String encryptIdCardName; + /** + * 加密证件号码 + */ + private String encryptIdCardNum; + /** + * 加密详细地址 + */ + private String encryptAddress; + +} diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/GuangZhouDxApiDealStrategy.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/GuangZhouDxApiDealStrategy.java new file mode 100644 index 0000000000..dd6e735132 --- /dev/null +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/GuangZhouDxApiDealStrategy.java @@ -0,0 +1,94 @@ +package cn.iocoder.yudao.module.haoka.service.api.strategy; + +import cn.iocoder.yudao.module.haoka.api.ApiFrom; +import cn.iocoder.yudao.module.haoka.api.ApiGuangZhouDXService; +import cn.iocoder.yudao.module.haoka.api.ApiLianTongService; +import cn.iocoder.yudao.module.haoka.api.guangdong.GdOrderCreateRequestParam; +import cn.iocoder.yudao.module.haoka.api.guangdong.inner.GdOrderQueryRequestParam; +import cn.iocoder.yudao.module.haoka.api.hainandianxin.HaiNanDianXinApi; +import cn.iocoder.yudao.module.haoka.api.liantong.LianTongApiUtil; +import cn.iocoder.yudao.module.haoka.api.liantong.area.LianTongArea; +import cn.iocoder.yudao.module.haoka.api.liantong.area.LianTongAreaUtils; +import cn.iocoder.yudao.module.haoka.api.liantong.model.request.KingIdentityCustV2Request; +import cn.iocoder.yudao.module.haoka.api.liantong.model.request.KingNumStateChangeRequest; +import cn.iocoder.yudao.module.haoka.api.liantong.model.request.KingOrderSyncV2Request; +import cn.iocoder.yudao.module.haoka.api.liantong.model.request.KingPreOrderSyncRequest; +import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingIdentityCustV2Response; +import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingNumStateChangeResponse; +import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingOrderSyncResponse; +import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingPreOrderSyncResponse; +import cn.iocoder.yudao.module.haoka.controller.admin.onsaleproduct.vo.OnSaleProductPreOrderRespVO; +import cn.iocoder.yudao.module.haoka.service.api.*; +import cn.iocoder.yudao.module.haoka.service.onsaleproduct.OnSaleProductService; +import com.mashape.unirest.http.exceptions.UnirestException; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@Component(ApiFrom.GuangZhouDXApiDealStrategy) +public class GuangZhouDxApiDealStrategy implements ApiDealStrategy { + + @Resource + private ApiGuangZhouDXService apiGuangZhouDXService; + + @Resource + private OnSaleProductService onSaleProductService; + + private LianTongArea getAddress(String code) { + return LianTongAreaUtils.getArea(code); + } + + @Override + public ApiDealResp createOrder(OrderApiCreateParam param) { + OnSaleProductPreOrderRespVO preProduct = onSaleProductService.getOnSaleProductPreOrder(param.getProductId()); + + String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + + + LianTongArea receiveAddress = getAddress(param.getAddressDistrict()); + + LianTongArea numAddress = getAddress(preProduct.getParentProduct().getBelongAreaCode()); + + + ApiDealResp result = new ApiDealResp<>(); + + GdOrderCreateRequestParam createParam = new GdOrderCreateRequestParam(); + + String order = apiGuangZhouDXService.createOrder(createParam); + + + OrderApiCreateResp orderApiCreateResp = new OrderApiCreateResp(); + orderApiCreateResp.setData(order); + + result.setData(orderApiCreateResp); + result.setSuccess(true); + // result.setMsg(response.getRspDesc()); + return result; + } + + @Override + public ApiDealResp queryOrder(OrderApiCreateParam param) { + ApiDealResp result = new ApiDealResp<>(); + + + GdOrderQueryRequestParam queryParam = new GdOrderQueryRequestParam(); + String responseInfo = apiGuangZhouDXService.queryOrder(queryParam); + + if (responseInfo == null) { + result.setSuccess(false); +// result.setMsg(responseInfo.getErrMsg()); + return result; + } + + OrderApiQueryResp orderApiQueryResp = new OrderApiQueryResp(); + orderApiQueryResp.setData(responseInfo); + + result.setData(orderApiQueryResp); + result.setSuccess(true); + // result.setMsg(responseInfo.g()); + return result; + + } +} diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HaiNanDxApiDealStrategy.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HaiNanDxApiDealStrategy.java new file mode 100644 index 0000000000..cf389388a0 --- /dev/null +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HaiNanDxApiDealStrategy.java @@ -0,0 +1,106 @@ +package cn.iocoder.yudao.module.haoka.service.api.strategy; + +import cn.iocoder.yudao.module.haoka.api.ApiFrom; +import cn.iocoder.yudao.module.haoka.api.ApiGuangZhouDXService; +import cn.iocoder.yudao.module.haoka.api.ApiHaiNanDXService; +import cn.iocoder.yudao.module.haoka.api.hainandianxin.HaiNanDianXinApi; +import cn.iocoder.yudao.module.haoka.api.hunandianxin.HaiNanDxInfo; +import cn.iocoder.yudao.module.haoka.api.liantong.area.LianTongArea; +import cn.iocoder.yudao.module.haoka.api.liantong.area.LianTongAreaUtils; +import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingOrderSyncResponse; +import cn.iocoder.yudao.module.haoka.controller.admin.onsaleproduct.vo.OnSaleProductPreOrderRespVO; +import cn.iocoder.yudao.module.haoka.service.api.*; +import cn.iocoder.yudao.module.haoka.service.onsaleproduct.OnSaleProductService; +import com.mashape.unirest.http.exceptions.UnirestException; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@Component(ApiFrom.HaiNanDXApiDealStrategy) +public class HaiNanDxApiDealStrategy implements ApiDealStrategy { + + @Resource + private ApiHaiNanDXService apiHaiNanDXService; + + @Resource + private OnSaleProductService onSaleProductService; + + private LianTongArea getAddress(String code) { + return LianTongAreaUtils.getArea(code); + } + + @Override + public ApiDealResp createOrder(OrderApiCreateParam param) { + OnSaleProductPreOrderRespVO preProduct = onSaleProductService.getOnSaleProductPreOrder(param.getProductId()); + + String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + + + LianTongArea receiveAddress = getAddress(param.getAddressDistrict()); + + LianTongArea numAddress = getAddress(preProduct.getParentProduct().getBelongAreaCode()); + + + ApiDealResp result = new ApiDealResp<>(); + // 0、占用号码 lianTongZhanHao + // 1、提交资料 lianTongSubmitUserInfo + // 2、提交预订单 得到token lianTongPreOrderSync + // 3、用 token提交正式订单 lianTongOrderSyncV2 + + HaiNanDianXinApi.SynOrderInfoRequest createParam = new HaiNanDianXinApi.SynOrderInfoRequest(); + try { + HaiNanDianXinApi.HaiNanResponseInfo responseInfo = apiHaiNanDXService.synOrderInfo(createParam); + HaiNanDianXinApi.SynOrderInfoResponse data = responseInfo.getData(); + if (data==null){ + result.setSuccess(false); + result.setMsg(responseInfo.getErrMsg()); + return result; + } + + OrderApiCreateResp orderApiCreateResp = new OrderApiCreateResp(); + orderApiCreateResp.setData(responseInfo); + + result.setData(orderApiCreateResp); + result.setSuccess(true); + result.setMsg(responseInfo.getErrMsg()); + return result; + + } catch (UnirestException e) { + result.setSuccess(false); + result.setMsg(e.getMessage()); + return result; + } + + } + + @Override + public ApiDealResp queryOrder(OrderApiCreateParam param) { + ApiDealResp result = new ApiDealResp<>(); + try { + + HaiNanDianXinApi.QueryOrderInfoRequest queryParam = new HaiNanDianXinApi.QueryOrderInfoRequest(); + HaiNanDianXinApi.HaiNanResponseInfo responseInfo = apiHaiNanDXService.queryOrderInfo(queryParam); + + if (responseInfo.getData() == null) { + result.setSuccess(false); + result.setMsg(responseInfo.getErrMsg()); + return result; + } + + OrderApiQueryResp orderApiQueryResp = new OrderApiQueryResp(); + orderApiQueryResp.setData(responseInfo); + + result.setData(orderApiQueryResp); + result.setSuccess(true); + result.setMsg(responseInfo.getErrMsg()); + return result; + + } catch (UnirestException e) { + result.setSuccess(false); + result.setMsg(e.getMessage()); + return result; + } + } +} diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HuNanDxApiDealStrategy.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HuNanDxApiDealStrategy.java new file mode 100644 index 0000000000..7d6676430f --- /dev/null +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HuNanDxApiDealStrategy.java @@ -0,0 +1,111 @@ +package cn.iocoder.yudao.module.haoka.service.api.strategy; + +import cn.iocoder.yudao.module.haoka.api.ApiFrom; +import cn.iocoder.yudao.module.haoka.api.ApiGuangZhouDXService; +import cn.iocoder.yudao.module.haoka.api.ApiHuNanDXService; +import cn.iocoder.yudao.module.haoka.api.hainandianxin.HaiNanDianXinApi; +import cn.iocoder.yudao.module.haoka.api.hunandianxin.HaiNanDxInfo; +import cn.iocoder.yudao.module.haoka.api.liantong.area.LianTongArea; +import cn.iocoder.yudao.module.haoka.api.liantong.area.LianTongAreaUtils; +import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingOrderSyncResponse; +import cn.iocoder.yudao.module.haoka.controller.admin.onsaleproduct.vo.OnSaleProductPreOrderRespVO; +import cn.iocoder.yudao.module.haoka.service.api.*; +import cn.iocoder.yudao.module.haoka.service.onsaleproduct.OnSaleProductService; +import com.mashape.unirest.http.exceptions.UnirestException; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@Component(ApiFrom.HuNanDXApiDealStrategy) +public class HuNanDxApiDealStrategy implements ApiDealStrategy { + + @Resource + private ApiHuNanDXService apiHuNanDXService; + + @Resource + private OnSaleProductService onSaleProductService; + + private LianTongArea getAddress(String code) { + return LianTongAreaUtils.getArea(code); + } + + @Override + public ApiDealResp createOrder(OrderApiCreateParam param) { + OnSaleProductPreOrderRespVO preProduct = onSaleProductService.getOnSaleProductPreOrder(param.getProductId()); + + String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + + + LianTongArea receiveAddress = getAddress(param.getAddressDistrict()); + + LianTongArea numAddress = getAddress(preProduct.getParentProduct().getBelongAreaCode()); + + + ApiDealResp result = new ApiDealResp<>(); + // 0、占用号码 lianTongZhanHao + // 1、提交资料 lianTongSubmitUserInfo + // 2、提交预订单 得到token lianTongPreOrderSync + // 3、用 token提交正式订单 lianTongOrderSyncV2 + + HaiNanDxInfo.SyncOrderParam orderParam = new HaiNanDxInfo.SyncOrderParam(); + + HaiNanDianXinApi.SynOrderInfoRequest createParam = new HaiNanDianXinApi.SynOrderInfoRequest(); + try { + + HaiNanDxInfo.ResponseInfo responseInfo = apiHuNanDXService.syncOrder(orderParam); + + if (responseInfo.getData() == null) { + result.setSuccess(false); + result.setMsg(responseInfo.getRes_message()); + return result; + } + + OrderApiCreateResp orderApiCreateResp = new OrderApiCreateResp(); + orderApiCreateResp.setData(responseInfo); + + result.setData(orderApiCreateResp); + result.setSuccess(true); + result.setMsg(responseInfo.getRes_message()); + return result; + + } catch (Exception e) { + result.setSuccess(false); + result.setMsg(e.getMessage()); + return result; + } + } + + @Override + public ApiDealResp queryOrder(OrderApiCreateParam param) { + + + ApiDealResp result = new ApiDealResp<>(); + try { + + HaiNanDxInfo.QueryOrderParam queryParam = new HaiNanDxInfo.QueryOrderParam(); + queryParam.setOutId(param.getOuterOrderId()); + HaiNanDxInfo.ResponseInfo responseInfo = apiHuNanDXService.queryOrder(queryParam); + + if (responseInfo.getData() == null) { + result.setSuccess(false); + result.setMsg(responseInfo.getRes_message()); + return result; + } + + OrderApiQueryResp orderApiQueryResp = new OrderApiQueryResp(); + orderApiQueryResp.setData(responseInfo); + + result.setData(orderApiQueryResp); + result.setSuccess(true); + result.setMsg(responseInfo.getRes_message()); + return result; + + } catch (Exception e) { + result.setSuccess(false); + result.setMsg(e.getMessage()); + return result; + } + } +} diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/LianTongApiDealStrategy.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/LianTongApiDealStrategy.java new file mode 100644 index 0000000000..c11919e725 --- /dev/null +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/LianTongApiDealStrategy.java @@ -0,0 +1,146 @@ +package cn.iocoder.yudao.module.haoka.service.api.strategy; + +import cn.iocoder.yudao.module.haoka.api.ApiFrom; +import cn.iocoder.yudao.module.haoka.api.ApiLianTongService; +import cn.iocoder.yudao.module.haoka.api.liantong.LianTongApiUtil; +import cn.iocoder.yudao.module.haoka.api.liantong.area.LianTongArea; +import cn.iocoder.yudao.module.haoka.api.liantong.area.LianTongAreaUtils; +import cn.iocoder.yudao.module.haoka.api.liantong.model.request.KingIdentityCustV2Request; +import cn.iocoder.yudao.module.haoka.api.liantong.model.request.KingNumStateChangeRequest; +import cn.iocoder.yudao.module.haoka.api.liantong.model.request.KingOrderSyncV2Request; +import cn.iocoder.yudao.module.haoka.api.liantong.model.request.KingPreOrderSyncRequest; +import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingIdentityCustV2Response; +import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingNumStateChangeResponse; +import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingOrderSyncResponse; +import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingPreOrderSyncResponse; +import cn.iocoder.yudao.module.haoka.controller.admin.onsaleproduct.vo.OnSaleProductPreOrderRespVO; +import cn.iocoder.yudao.module.haoka.service.api.*; +import cn.iocoder.yudao.module.haoka.service.onsaleproduct.OnSaleProductService; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@Component(ApiFrom.LianTongApiDealStrategy) +public class LianTongApiDealStrategy implements ApiDealStrategy { + + @Resource + private ApiLianTongService apiLianTongService; + + @Resource + private OnSaleProductService onSaleProductService; + + private LianTongArea getAddress(String code) { + return LianTongAreaUtils.getArea(code); + } + + @Override + public ApiDealResp createOrder(OrderApiCreateParam param) { + OnSaleProductPreOrderRespVO preProduct = onSaleProductService.getOnSaleProductPreOrder(param.getProductId()); + + String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + + + LianTongArea receiveAddress = getAddress(param.getAddressDistrict()); + + LianTongArea numAddress = getAddress(preProduct.getParentProduct().getBelongAreaCode()); + + + ApiDealResp result = new ApiDealResp<>(); + // 0、占用号码 lianTongZhanHao + // 1、提交资料 lianTongSubmitUserInfo + // 2、提交预订单 得到token lianTongPreOrderSync + // 3、用 token提交正式订单 lianTongOrderSyncV2 + + // 0、占用号码 lianTongZhanHao + KingNumStateChangeRequest stateChangeRequest = new KingNumStateChangeRequest(); + stateChangeRequest.setCityCode(numAddress.getPhoneCityCode()); + stateChangeRequest.setProvinceCode(numAddress.getPhoneProvinceCode()); + stateChangeRequest.setSerialNumber(param.getPlanMobile()); + stateChangeRequest.setOccupiedFlag("S"); + stateChangeRequest.setCertCode(param.getIdCardNum()); + stateChangeRequest.setOccupiedTimeTag("S1"); + KingNumStateChangeResponse stateChangeResponse = apiLianTongService.lianTongZhanHao(stateChangeRequest); + + if (!"0".equals(stateChangeResponse.getRspCode())) { + result.setSuccess(false); + result.setMsg(stateChangeResponse.getRspDesc()); + return result; + } + + // 1、提交资料 lianTongSubmitUserInfo + KingIdentityCustV2Request ziLiao = new KingIdentityCustV2Request(); + ziLiao.setProvince(numAddress.getPhoneProvinceCode()); + ziLiao.setCity(numAddress.getPhoneCityCode()); + ziLiao.setCertName(param.getIdCardName()); + ziLiao.setCertNum(param.getIdCardNum()); + KingIdentityCustV2Response ziLiaoResponse + = apiLianTongService.lianTongSubmitUserInfo(ziLiao); + String rspCode = ziLiaoResponse.getaDesc(); + + if (!"成功".equals(rspCode)) { + result.setSuccess(false); + result.setMsg(ziLiaoResponse.getaDesc()); + return result; + } + + // 2、提交预订单 得到token lianTongPreOrderSync + KingPreOrderSyncRequest preOrder = new KingPreOrderSyncRequest(); + preOrder.setGoodsId(preProduct.getSuperiorProductConfigRespVO().getSuperiorCode()); + preOrder.setOrderId(param.getId().toString()); + preOrder.setCertName(param.getIdCardName()); + preOrder.setCertNo(param.getIdCardNum()); + preOrder.setPostProvinceCode(receiveAddress.getProvinceCode()); + preOrder.setPostCityCode(receiveAddress.getCityCode()); + preOrder.setPostDistrictCode(receiveAddress.getDistrictCode()); + preOrder.setPostAddr(param.getAddress()); + String channel = apiLianTongService.getConfigValue(LianTongApiUtil.KEY_channel); + preOrder.setChannel(channel); + preOrder.setCreateTime(format); + preOrder.setUpdateTime(format); + preOrder.setContactNum(param.getAddressMobile()); + KingPreOrderSyncResponse preOrderResponse = apiLianTongService.lianTongPreOrderSync(preOrder); + if (!"0000".equals(preOrderResponse.getRspCode())) { + result.setSuccess(false); + result.setMsg(preOrderResponse.getRspDesc()); + return result; + } +// String preOrderResponseBody = preOrderResponse.getBody(); +// JSONObject preOrderJSONObject = JSON.parseObject(preOrderResponseBody); +// String orderNo = preOrderJSONObject.getString("orderNo"); +// String token = preOrderJSONObject.getString("token"); + + + // 3、用 token提交正式订单 lianTongOrderSyncV2 + KingOrderSyncV2Request syncV2 = new KingOrderSyncV2Request(); + syncV2.setProvinceCode(numAddress.getPhoneProvinceCode()); + syncV2.setCityCode(numAddress.getPhoneCityCode()); + syncV2.setCreateTime(format); + syncV2.setPhoneNum(param.getPlanMobile()); + syncV2.setGoodsId(preProduct.getSuperiorProductConfigRespVO().getSuperiorCode()); + syncV2.setToken("tokentokentokentoken"); + KingOrderSyncResponse syncV2Response = apiLianTongService.lianTongOrderSyncV2(syncV2); + if (!"0000".equals(syncV2Response.getRspCode())) { + result.setSuccess(false); + result.setMsg(syncV2Response.getRspDesc()); + return result; + } + + KingOrderSyncResponse response = apiLianTongService.lianTongOrderSyncV2(syncV2); + OrderApiCreateResp orderApiCreateResp = new OrderApiCreateResp(); + orderApiCreateResp.setData(response); + + result.setData(orderApiCreateResp); + result.setSuccess(true); + result.setMsg(response.getRspDesc()); + return result; + } + + @Override + public ApiDealResp queryOrder(OrderApiCreateParam param) { + return null; + } +} diff --git a/yudao-server/src/main/resources/db/migration/V3.0.17__alter_product_belongType.sql b/yudao-server/src/main/resources/db/migration/V3.0.17__alter_product_belongType.sql new file mode 100644 index 0000000000..b3a5ebf1f6 --- /dev/null +++ b/yudao-server/src/main/resources/db/migration/V3.0.17__alter_product_belongType.sql @@ -0,0 +1,2 @@ +ALTER TABLE `haoka_dev`.`haoka_product` + MODIFY COLUMN `belong_area_code` varchar(64) NOT NULL COMMENT '归属地' AFTER `haoka_product_type_id`;