From 59105ca592172cb2d91b0f12b8b3c9fa8c079334 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 22 十月 2024 09:34:28 +0800
Subject: [PATCH] 提交一把
---
server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java | 128 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 111 insertions(+), 17 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java
index b1aaf13..03f2ada 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/SolutionsServiceImpl.java
@@ -1,5 +1,6 @@
package com.doumee.service.business.impl;
+import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
@@ -27,10 +28,7 @@
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
-import java.util.UUID;
+import java.util.*;
/**
* 淇濋櫓鏂规淇℃伅琛⊿ervice瀹炵幇
@@ -40,6 +38,10 @@
@Service
public class SolutionsServiceImpl implements SolutionsService {
+ @Autowired
+ private SystemDictDataBiz systemDictDataBiz;
+ @Autowired
+ private MultifileMapper multifileMapper;
@Autowired
private SolutionsMapper solutionsMapper;
@Autowired
@@ -69,13 +71,21 @@
)>Constants.ZERO){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"淇濋櫓鏂规鍚嶇О宸插瓨鍦�");
}
-
+ solutions.setCanAdd(Constants.formatIntegerNum(solutions.getCanAdd()));
+ solutions.setCanReduce(Constants.formatIntegerNum(solutions.getCanReduce()));
+ solutions.setCanChangeUnit(Constants.formatIntegerNum(solutions.getCanChangeUnit()));
+ solutions.setAddValidDays(Constants.formatIntegerNum(solutions.getAddValidDays()));
+ solutions.setDelValidDays(Constants.formatIntegerNum(solutions.getDelValidDays()));
solutions.setIsdeleted(Constants.ZERO);
solutions.setCreator(user.getId());
solutions.setCreateDate(new Date());
solutions.setVersion(UUID.randomUUID().toString());//鐗堟湰鍙�
solutions.setDataType(Constants.ZERO);
solutions.setStatus(Constants.ZERO);
+ //2024骞�6鏈�17鏃�15:56:18 浠呮敮鎸佹浛鎹㈡ā寮忎笅锛屾壒澧炴棩鏈� 绛変簬 鎵瑰噺鏃ユ湡
+ if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){
+ solutions.setAddValidDays(solutions.getDelValidDays());
+ }
solutionsMapper.insert(solutions);//鍩虹鐗堟湰
//濡傛灉鏈夊伐绉嶏紝鍒欎骇鐢熶竴涓柊鐨勬湁鏁堝巻鍙茬増鏈� ~
@@ -87,6 +97,22 @@
solutionsMapper.insert(newModel);
dealWorkType(solutions,newModel,solutions.getWorktypeIdList(),true);
+ if(Constants.equalsObject(solutions.getType(),Constants.ONE) ){
+ if (solutions.getFanganFile()==null || StringUtils.isBlank(solutions.getFanganFile().getFileurl())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"璇蜂笂浼犳柟妗堢‘璁や功锛�");
+ }
+
+ Multifile file = solutions.getFanganFile();
+ file.setIsdeleted(Constants.ZERO);
+ file.setCreateDate(new Date());
+ file.setCreator(user.getId());
+ file.setObjId(solutions.getId());
+ file.setObjType(Constants.MultiFile.SOLUTIONS_CONFIRMATION_LATTER.getKey());
+ file.setType(Constants.formatIntegerNum(file.getType()));
+ multifileMapper.insert(file);
+ file.setObjId(newModel.getId());
+ multifileMapper.insert(file);
+ }
return solutions.getId();
}
@@ -138,12 +164,15 @@
// ||Constants.formatIntegerNum(solutions.getPriceCycleUnit()) < 0
||Constants.formatIntegerNum(solutions.getInsureCycle()) < 0
||Constants.formatIntegerNum(solutions.getInsureCycleUnit()) < 0
- || solutions.getMinAge() >solutions.getMaxAge()
+ ||Constants.formatIntegerNum( solutions.getMinAge()) >Constants.formatIntegerNum(solutions.getMaxAge())
|| Constants.formatBigdecimal(solutions.getPrice()).compareTo(new BigDecimal(0)) !=1
){
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
-
+ if(!(Constants.equalsInteger(solutions.getInsureCycleUnit(),Constants.ZERO)
+ ||Constants.equalsInteger(solutions.getInsureCycleUnit(),solutions.getInsureCycleUnit()))){
+ solutions.setDelOnlyReplace(Constants.ZERO);
+ }
}
@Override
@@ -176,6 +205,7 @@
}
//鏁版嵁鏈夋晥鎬ф牎楠�
initCreateParam(solutions);
+ solutions.setType(null);//涓嶆敮鎸佷慨鏀规姇淇濇柟妗�
if(solutionsMapper.selectCount(new QueryWrapper<Solutions>().lambda()
.eq(Solutions::getName,solutions.getName())
.eq(Solutions::getIsdeleted,Constants.ZERO)
@@ -187,6 +217,11 @@
solutions.setEditor(user.getId());
solutions.setVersion(UUID.randomUUID().toString());
solutions.setEditDate(new Date());
+
+ //2024骞�6鏈�17鏃�15:56:18 浠呮敮鎸佹浛鎹㈡ā寮忎笅锛屾壒澧炴棩鏈� 绛変簬 鎵瑰噺鏃ユ湡
+ if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){
+ solutions.setAddValidDays(solutions.getDelValidDays());
+ }
solutionsMapper.updateById(solutions);
Solutions oldVersion = solutionsMapper.selectOne(new QueryWrapper<Solutions>()
@@ -195,7 +230,6 @@
.eq(Solutions::getDataType,Constants.TWO)
.last("limit 1")
);
-
if(Objects.isNull(oldVersion)){
throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鍘嗗彶鐗堟湰鏁版嵁");
@@ -216,7 +250,29 @@
.lambda()
.eq(SolutionWorktype::getSolutionId,solutions.getId())
);
+ if(Constants.equalsObject(model.getType(),Constants.ONE) ){
+ if (solutions.getFanganFile()!=null && StringUtils.isNotBlank(solutions.getFanganFile().getFileurl())){
+ multifileMapper.update(null,new UpdateWrapper<Multifile>().lambda()
+ .set(Multifile::getIsdeleted,Constants.ONE)
+ .set(Multifile::getEditDate,solutions.getEditDate())
+ .set(Multifile::getEditor,solutions.getEditor())
+ .eq(Multifile::getObjId,solutions.getId())
+ .eq(Multifile::getIsdeleted,Constants.ZERO)
+ .eq(Multifile::getObjType,Constants.MultiFile.SOLUTIONS_CONFIRMATION_LATTER.getKey()));
+
+ Multifile file = solutions.getFanganFile();
+ file.setIsdeleted(Constants.ZERO);
+ file.setCreateDate(solutions.getEditDate());
+ file.setCreator(solutions.getEditor());
+ file.setObjId(solutions.getId());
+ file.setObjType(Constants.MultiFile.SOLUTIONS_CONFIRMATION_LATTER.getKey());
+ file.setType(Constants.formatIntegerNum(file.getType()));
+ multifileMapper.insert(file);
+ file.setObjId(newModel.getId());
+ multifileMapper.insert(file);
+ }
+ }
solutionsMapper.update(null,new UpdateWrapper<Solutions>()
.lambda()
@@ -286,7 +342,9 @@
MPJLambdaWrapper<Solutions> queryWrapper = new MPJLambdaWrapper<>();
queryWrapper.selectAll(Solutions.class);
queryWrapper.selectAs(Insurance::getName,Solutions::getInsuranceName);
+ queryWrapper.selectAs(Company::getName,Solutions::getShopName);
queryWrapper.leftJoin(Insurance.class,Insurance::getId,Solutions::getInsuranceId);
+ queryWrapper.leftJoin(Company.class,Company::getId,Solutions::getShopId);
queryWrapper.eq(Solutions::getId,id);
Solutions model = solutionsJoinMapper.selectJoinOne(Solutions.class,queryWrapper);
if(model == null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){
@@ -301,6 +359,16 @@
wrapper.orderByAsc(SolutionWorktype::getSortnum);
List<SolutionWorktype> worktypeList = solutionWorktypeJoinMapper.selectJoinList(SolutionWorktype.class,wrapper);
model.setWorktypeList(worktypeList);
+ Multifile f = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda()
+ .eq(Multifile::getObjId,model.getId())
+ .eq(Multifile::getObjType,Constants.MultiFile.SOLUTIONS_CONFIRMATION_LATTER.getKey())
+ .eq(Multifile::getIsdeleted,Constants.ZERO)
+ .last("limit 1"));
+ if(f!=null && StringUtils.isNotBlank(f.getFileurl())){
+ String url = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode()+f.getFileurl();
+ f.setFileurlFull(url);
+ model.setFanganFile(f);//鏂规纭涔�
+ }
return model;
}
@@ -312,12 +380,19 @@
@Override
public List<Solutions> findList(Solutions solutions) {
+ LoginUserInfo user = (LoginUserInfo)SecurityUtils.getSubject().getPrincipal();
solutions.setIsdeleted(Constants.ZERO);
solutions.setStatus(Constants.ZERO);
if(solutions.getDataType() == null){
solutions.setDataType(Constants.TWO);
}
QueryWrapper<Solutions> wrapper = new QueryWrapper<>(solutions);
+ if(Constants.equalsObject(user.getType(),Constants.TWO)){
+ //濡傛灉鏄垹闄�
+// wrapper.lambda().exists("select c.id from company_solution c left join solutions d on c.solution_id=d.id where c.isdeleted=0 and d.base_id=solutions.base_id and c.shop_id="+user.getCompanyId());//璁剧疆鏃犳晥璁块棶
+ wrapper.apply("((solutions.type=0 and exists(select cs.id from company_solution cs left join solutions s on cs.solution_id=s.id where cs.isdeleted=0 and s.base_id=solutions.base_id and cs.shop_id="+user.getCompanyId()+")) or (" +
+ "solutions.type=1 and solutions.shop_id="+user.getCompanyId()+"))") ;
+ }
return solutionsMapper.selectList(wrapper);
}
@@ -331,8 +406,13 @@
Utils.MP.blankToNull(pageWrap.getModel());
queryWrapper.selectAll(Solutions.class);
queryWrapper.selectAs(Insurance::getName,Solutions::getInsuranceName);
+ queryWrapper.selectAs(Company::getName,Solutions::getShopName);
queryWrapper.leftJoin(Insurance.class,Insurance::getId,Solutions::getInsuranceId);
-
+ queryWrapper.leftJoin(Company.class,Company::getId,Solutions::getShopId);
+ LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ if(user.getType().equals(Constants.ONE)){
+ queryWrapper.exists(("select 1 from company_solution b where b.isdeleted=0 and b.company_id="+user.getCompanyId()+" and b.SOLUTION_BASE_ID = t.id"));
+ }
if (pageWrap.getModel().getId() != null) {
queryWrapper.eq(Solutions::getId, pageWrap.getModel().getId());
}
@@ -420,13 +500,14 @@
if (pageWrap.getModel().getBaseId() != null) {
queryWrapper.eq(Solutions::getBaseId, pageWrap.getModel().getBaseId());
}
- for(PageWrap.SortData sortData: pageWrap.getSorts()) {
- if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
- queryWrapper.orderByDesc(sortData.getProperty());
- } else {
- queryWrapper.orderByAsc(sortData.getProperty());
- }
- }
+ queryWrapper.orderByDesc(Solutions::getCreateDate);
+// for(PageWrap.SortData sortData: pageWrap.getSorts()) {
+// if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
+// queryWrapper.orderByDesc(sortData.getProperty());
+// } else {
+// queryWrapper.orderByAsc(sortData.getProperty());
+// }
+// }
PageData<Solutions> pageData = PageData.from(solutionsJoinMapper.selectJoinPage(page,Solutions.class, queryWrapper));
return pageData;
@@ -478,7 +559,7 @@
.eq(Company::getStatus,Constants.ZERO)
.eq(Insurance::getIsdeleted,Constants.ZERO)
.eq(Insurance::getStatus,Constants.ZERO)
- .orderByAsc(Solutions::getSortnum)
+ .orderByDesc(Solutions::getCreateDate)
);
return solutionsList;
}
@@ -517,5 +598,18 @@
}
+ @Override
+ public BigDecimal testSolutionAddMoney(Integer id, BigDecimal fee, Date start,Date end,Date newDate,Date newEndTime){
+ return Constants.addFee(solutionsMapper.selectById(id),fee,start,end,newDate,newEndTime);
+ }
+ @Override
+ public BigDecimal testSolutionReduceMoney(Integer id, BigDecimal fee, Date start,Date end,Date reduceStartTime,Date reduceEndTime){
+ return Constants.reduceFee(solutionsMapper.selectById(id),fee,start,end,reduceStartTime,reduceEndTime);
+ }
+
+ @Override
+ public BigDecimal testSolutionProduceMoney(Integer id, BigDecimal fee, Date start,Date end,Date produceStart){
+ return Constants.produceFee(solutionsMapper.selectById(id),fee,start,end,produceStart);
+ }
}
--
Gitblit v1.9.3