|
|
@@ -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());
|