Przeglądaj źródła

feat(contract): 实现合同包功能并优化签署状态查询

- 新增 ContractBundle 实体类定义合同包表结构
- 添加 ContractBundleMapper 数据访问接口
- 修改 StoreContractServiceImpl 使用合同包表查询签署状态
- 更新 API 文档注释说明合同包查询方式
- 移除旧的合同状态转换逻辑直接返回合同包状态
fcw 1 miesiąc temu
rodzic
commit
f0881d72a6

+ 82 - 0
alien-entity/src/main/java/shop/alien/entity/store/ContractBundle.java

@@ -0,0 +1,82 @@
+package shop.alien.entity.store;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 合同包表 contract_bundle
+ */
+@Data
+@JsonInclude
+@EqualsAndHashCode(callSuper = false)
+@TableName("contract_bundle")
+@ApiModel(value = "ContractBundle对象", description = "合同包表")
+public class ContractBundle extends Model<ContractBundle> {
+
+    @ApiModelProperty(value = "合同包唯一标识")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    @ApiModelProperty(value = "签约主体类型(store/lawyer)")
+    @TableField("subject_type")
+    private String subjectType;
+
+    @ApiModelProperty(value = "签约主体ID,门店/律师业务主键")
+    @TableField("subject_id")
+    private Long subjectId;
+
+    @ApiModelProperty(value = "签约主体名称")
+    @TableField("subject_name")
+    private String subjectName;
+
+    @ApiModelProperty(value = "业务板块")
+    @TableField("business_segment")
+    private String businessSegment;
+
+    @ApiModelProperty(value = "联系人姓名")
+    @TableField("contact_name")
+    private String contactName;
+
+    @ApiModelProperty(value = "联系人手机号")
+    @TableField("contact_phone")
+    private String contactPhone;
+
+    @ApiModelProperty(value = "组织标识(统一社会信用代码)")
+    @TableField("ord_id")
+    private String ordId;
+
+    @ApiModelProperty(value = "合同包类型(STORE_STANDARD/LAWYER_STANDARD)")
+    @TableField("bundle_type")
+    private String bundleType;
+
+    @ApiModelProperty(value = "整体状态: 未签署/审核中/已签署")
+    @TableField("status")
+    private String status;
+
+    @ApiModelProperty(value = "主合同文档ID")
+    @TableField("primary_document_id")
+    private Long primaryDocumentId;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(value = "created_time", fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createdTime;
+
+    @ApiModelProperty(value = "更新时间")
+    @TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updatedTime;
+
+    @ApiModelProperty(value = "逻辑删除(0未删/1已删)")
+    @TableField("delete_flag")
+    @TableLogic
+    private Integer deleteFlag;
+}

+ 12 - 0
alien-entity/src/main/java/shop/alien/mapper/ContractBundleMapper.java

@@ -0,0 +1,12 @@
+package shop.alien.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import shop.alien.entity.store.ContractBundle;
+
+/**
+ * 合同包 Mapper
+ */
+@Mapper
+public interface ContractBundleMapper extends BaseMapper<ContractBundle> {
+}

+ 1 - 1
alien-store-platform/src/main/java/shop/alien/storeplatform/controller/StoreContractController.java

@@ -114,7 +114,7 @@ public class StoreContractController {
         return storeContractService.deleteContract(id);
     }
 
-    @ApiOperation("获取合同签署状态")
+    @ApiOperation("获取合同签署状态(contract_bundle:subject_id=店铺ID,subject_type=store,返回 status)")
     @ApiOperationSupport(order = 8)
     @ApiImplicitParams({
             @ApiImplicitParam(name = "store_id", value = "店铺ID", dataType = "int", paramType = "query", required = true)

+ 19 - 32
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/StoreContractServiceImpl.java

@@ -9,9 +9,11 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import shop.alien.entity.result.R;
+import shop.alien.entity.store.ContractBundle;
 import shop.alien.entity.store.StoreContract;
 import shop.alien.entity.store.dto.StoreContractQueryDto;
 import shop.alien.entity.store.vo.StoreContractVo;
+import shop.alien.mapper.ContractBundleMapper;
 import shop.alien.mapper.StoreContractMapper;
 import shop.alien.storeplatform.service.StoreContractService;
 
@@ -30,7 +32,11 @@ import java.util.List;
 @Transactional
 public class StoreContractServiceImpl implements StoreContractService {
 
+    /** contract_bundle.subject_type,门店场景固定为 store */
+    private static final String CONTRACT_BUNDLE_SUBJECT_TYPE_STORE = "store";
+
     private final StoreContractMapper storeContractMapper;
+    private final ContractBundleMapper contractBundleMapper;
 
     @Override
     public R<IPage<StoreContractVo>> getContractList(StoreContractQueryDto queryDto) {
@@ -200,41 +206,22 @@ public class StoreContractServiceImpl implements StoreContractService {
             if (storeId == null) {
                 return R.fail("店铺ID不能为空");
             }
-            String contracts = storeContractMapper.selectSigningStatus(storeId);
-
-            // 根据店铺ID查询最新的合同(按创建时间倒序)
-//            List<StoreContract> contracts = storeContractMapper.selectList(
-//                    new LambdaQueryWrapper<StoreContract>()
-//                            .eq(StoreContract::getStoreId, storeId.longValue())
-//                            .eq(StoreContract::getDeleteFlag, 0)
-//                            .orderByDesc(StoreContract::getCreatedTime)
-//                            .last("LIMIT 1")
-//            );
-
-            if (contracts == null || contracts.isEmpty()) {
+
+            // contract_bundle:subject_id=店铺ID,subject_type=store,取最新一条
+            List<ContractBundle> bundles = contractBundleMapper.selectList(
+                    new LambdaQueryWrapper<ContractBundle>()
+                            .eq(ContractBundle::getSubjectId, storeId.longValue())
+                            .eq(ContractBundle::getSubjectType, CONTRACT_BUNDLE_SUBJECT_TYPE_STORE)
+                            .eq(ContractBundle::getDeleteFlag, 0)
+                            .orderByDesc(ContractBundle::getCreatedTime)
+                            .last("LIMIT 1")
+            );
+
+            if (bundles == null || bundles.isEmpty()) {
                 return R.fail("该店铺暂无合同");
             }
 
-//            StoreContract contract = contracts.get(0);
-            String signingStatus = contracts;
-            // 将字符串状态转换为数字:已签署=1, 未签署=0, 已到期=2
-            Integer statusValue = null;
-            if (signingStatus != null) {
-                switch (signingStatus) {
-                    case "已签署":
-                        statusValue = 1;
-                        break;
-                    case "未签署":
-                        statusValue = 0;
-                        break;
-                    case "已到期":
-                        statusValue = 2;
-                        break;
-                    default:
-                        statusValue = 0;
-                }
-            }
-            return R.data(signingStatus);
+            return R.data(bundles.get(0).getStatus());
         } catch (Exception e) {
             log.error("StoreContractServiceImpl.getSigningStatus ERROR: {}", e.getMessage(), e);
             return R.fail("获取签署状态失败: " + e.getMessage());