diff --git a/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/CustomerArchive.java b/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/CustomerArchive.java index 0fc97777..6890fa1b 100644 --- a/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/CustomerArchive.java +++ b/blade-service-api/blade-transport-api/src/main/java/org/springblade/transport/pojo/entity/CustomerArchive.java @@ -158,4 +158,13 @@ public class CustomerArchive extends TenantEntity { @Schema(description = "审核通过时间") private LocalDateTime approvedTime; + @Schema(description = "金蝶协同状态:none未推送/exist金蝶已有/synced已推送/failed推送失败") + private String kingdeeStatus; + + @Schema(description = "金蝶推送失败原因") + private String kingdeeFailReason; + + @Schema(description = "金蝶推送时间") + private LocalDateTime kingdeeSyncTime; + } diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/constant/CustomerBfiConstants.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/constant/CustomerBfiConstants.java new file mode 100644 index 00000000..6725a436 --- /dev/null +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/constant/CustomerBfiConstants.java @@ -0,0 +1,69 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is + * not liable for any claims arising from secondary or illegal development. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.constant; + +import java.util.Map; + +/** + * 客商档案金蝶(星瀚)协同常量 + * + * @author Chill + */ +public class CustomerBfiConstants { + + /** + * 推送金蝶固定值:业务职能全选(1销售,2结算,3付款,4收货) + */ + public static final String BIZ_FUNCTION_ALL = "1,2,3,4"; + + /** + * 推送金蝶固定值:伙伴类型兜底编码(民营企业),客商性质未命中映射时使用 + */ + public static final String DEFAULT_PARTNER_TYPE = "6"; + + /** + * 营业期限类型:长期(TMS 表单文本) + */ + public static final String BUSINESS_TERM_LONG = "长期"; + + /** + * 客商性质(nature_of_client 字典 dictKey)→ 金蝶伙伴类型编码 + * 键名以数据库字典 nature_of_client 实际 dictKey 为准核对;未命中走 DEFAULT_PARTNER_TYPE + */ + public static final Map NATURE_TYPE_MAPPING = Map.of( + "企业法人", "1", + "个人", "4", + "个体工商户", "5", + "民营企业", "6", + "国有企业", "8", + "政府事业单位", "9", + "其他", "12" + ); + + private CustomerBfiConstants() { + } + +} diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/BfiCustomerController.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/BfiCustomerController.java new file mode 100644 index 00000000..5faea7c8 --- /dev/null +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/BfiCustomerController.java @@ -0,0 +1,75 @@ +/** + * BladeX Commercial License Agreement + * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved. + *

+ * Use of this software is governed by the Commercial License Agreement + * obtained after purchasing a license from BladeX. + *

+ * 1. This software is for development use only under a valid license + * from BladeX. + *

+ * 2. Redistribution of this software's source code to any third party + * without a commercial license is strictly prohibited. + *

+ * 3. Licensees may copyright their own code but cannot use segments + * from this software for such purposes. Copyright of this software + * remains with BladeX. + *

+ * Using this software signifies agreement to this License, and the software + * must not be used for illegal purposes. + *

+ * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is + * not liable for any claims arising from secondary or illegal development. + *

+ * Author: Chill Zhuang (bladejava@qq.com) + */ +package org.springblade.transport.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.thirdparty.bfi.pojo.dto.BfiCustomerQueryDTO; +import org.springblade.thirdparty.bfi.pojo.vo.BfiCustomerVO; +import org.springblade.thirdparty.bfi.pojo.vo.BfiPageVO; +import org.springblade.thirdparty.bfi.service.IBfiService; +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 java.util.List; + +/** + * 业财融合(BFI)客商查询控制器 + * + * @author Chill + */ +@RestController +@AllArgsConstructor +@RequestMapping("/bfi") +@Tag(name = "BFI客商", description = "业财融合客商查询接口") +public class BfiCustomerController extends BladeController { + + private final IBfiService bfiService; + + @GetMapping("/customer/query-by-credit-code") + @Operation(summary = "按统一社会信用代码查询金蝶客商", description = "新增客商时查询金蝶是否已有该客商,已审核则回填工商信息") + public R queryByCreditCode( + @Parameter(description = "统一社会信用代码", required = true) @RequestParam String creditCode) { + if (StringUtil.isBlank(creditCode)) { + return R.fail("统一社会信用代码不能为空"); + } + BfiCustomerQueryDTO param = new BfiCustomerQueryDTO(); + param.setPageNo(1); + param.setPageSize(1); + param.setSocietycreditcode(List.of(creditCode.trim().toUpperCase())); + BfiPageVO page = bfiService.queryCustomer(param); + List rows = page == null ? null : page.getRows(); + return R.data(rows == null || rows.isEmpty() ? null : rows.get(0)); + } + +} diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CustomerArchiveController.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CustomerArchiveController.java index 6b1a1266..3c44fd00 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CustomerArchiveController.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/CustomerArchiveController.java @@ -31,6 +31,7 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.excel.util.ExcelUtil; import org.springblade.core.mp.support.Condition; @@ -60,6 +61,7 @@ import java.util.List; * * @author Chill */ +@Slf4j @RestController @AllArgsConstructor @PreAuth(menu = "customer_archive") @@ -133,13 +135,21 @@ public class CustomerArchiveController extends BladeController { } /** - * 审核通过 + * 审核通过(通过后自动推送金蝶,推送失败不影响审批结果) */ @PostMapping("/approve") @ApiOperationSupport(order = 6) @Operation(summary = "审核通过", description = "传入id") public R approve(@Parameter(description = "主键", required = true) @RequestParam Long id) { - return R.status(customerArchiveService.approve(id)); + boolean result = customerArchiveService.approve(id); + if (result) { + try { + customerArchiveService.syncKingdee(id); + } catch (Exception exception) { + log.error("客商审批通过后推送金蝶异常,id={}", id, exception); + } + } + return R.status(result); } /** @@ -173,6 +183,16 @@ public class CustomerArchiveController extends BladeController { return R.status(customerArchiveService.removeDraft(ids)); } + /** + * 推送金蝶(审批通过后失败重推入口) + */ + @PostMapping("/sync-kingdee") + @ApiOperationSupport(order = 12) + @Operation(summary = "推送金蝶", description = "传入id,仅审批通过的客商可推送,已推送/金蝶已有自动幂等跳过") + public R syncKingdee(@Parameter(description = "主键", required = true) @RequestParam Long id) { + return R.data(customerArchiveService.syncKingdee(id)); + } + /** * 评分明细模板 */ diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/excel/CustomerArchiveExcel.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/excel/CustomerArchiveExcel.java index cc15e8b6..6c71a297 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/excel/CustomerArchiveExcel.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/excel/CustomerArchiveExcel.java @@ -105,4 +105,7 @@ public class CustomerArchiveExcel implements Serializable { @ExcelProperty("审核通过时间") private LocalDateTime approvedTime; + @ExcelProperty("金蝶同步状态") + private String kingdeeStatusName; + } diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CustomerArchiveMapper.xml b/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CustomerArchiveMapper.xml index d9df1358..2494a669 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CustomerArchiveMapper.xml +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/mapper/CustomerArchiveMapper.xml @@ -46,6 +46,9 @@ + + +