待支付金额 大于等于 已支付金额时 状态为已付款

否则为 待付款
This commit is contained in:
wangw 2024-06-26 16:22:54 +08:00
parent fedf2dce17
commit 7bc6ae7b8a
1 changed files with 23 additions and 21 deletions

View File

@ -24,11 +24,11 @@ import java.io.IOException;
import java.util.*;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author lyf
* @date 2024-01-23
**/
* @author lyf
* @website https://eladmin.vip
* @description 服务实现
* @date 2024-01-23
**/
@Service
@RequiredArgsConstructor
public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransactService {
@ -44,17 +44,17 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
Page<TbShopPurveyorTransact> pageShopPurveyor = tbShopPurveyorTransactRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
Map<String, Object> map = new HashMap<>();
map.put("content",pageShopPurveyor.getContent());
map.put("totalElements",pageShopPurveyor.getTotalElements());
map.put("content", pageShopPurveyor.getContent());
map.put("totalElements", pageShopPurveyor.getTotalElements());
return map;
}
@Override
public Page<PurveyorTransactVO> queryTransactDate(TbShopPurveyorTransactQueryCriteria criteria){
public Page<PurveyorTransactVO> queryTransactDate(TbShopPurveyorTransactQueryCriteria criteria) {
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize());
Page<PurveyorTransactVO> purveyorTransactVOS = tbShopPurveyorTransactRepository.queryTransactDate(criteria.getType(), criteria.getShopId(), criteria.getPurveyorName(), pageable);
for (PurveyorTransactVO purveyorTransactVO : purveyorTransactVOS.getContent()) {
purveyorTransactVO.setType(purveyorTransactVO.getWaitCount().intValue()<1?1:0);
purveyorTransactVO.setType(purveyorTransactVO.getWaitCount().intValue() < 1 ? 1 : 0);
}
return purveyorTransactVOS;
@ -65,20 +65,20 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
Map<String, Object> bySum = tbShopPurveyorTransactRepository.findBySum(criteria.getPurveyorId(), criteria.getType());
Map<String, Object> byStatusSum = tbShopPurveyorTransactRepository.findByStatusSum(criteria.getPurveyorId(), criteria.getType(), 0);
Map<String, Object> sumMap = new HashMap<>(bySum);
sumMap.put("waitNumber",byStatusSum.get("waitNumber"));
sumMap.put("waitNumber", byStatusSum.get("waitNumber"));
return sumMap;
}
@Override
public List<TbShopPurveyorTransactDto> queryAll(TbShopPurveyorTransactQueryCriteria criteria){
return tbShopPurveyorTransactMapper.toDto(tbShopPurveyorTransactRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
public List<TbShopPurveyorTransactDto> queryAll(TbShopPurveyorTransactQueryCriteria criteria) {
return tbShopPurveyorTransactMapper.toDto(tbShopPurveyorTransactRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
}
@Override
@Transactional
public TbShopPurveyorTransactDto findById(Integer id) {
TbShopPurveyorTransact tbShopPurveyorTransact = tbShopPurveyorTransactRepository.findById(id).orElseGet(TbShopPurveyorTransact::new);
ValidationUtil.isNull(tbShopPurveyorTransact.getId(),"TbShopPurveyorTransact","id",id);
ValidationUtil.isNull(tbShopPurveyorTransact.getId(), "TbShopPurveyorTransact", "id", id);
return tbShopPurveyorTransactMapper.toDto(tbShopPurveyorTransact);
}
@ -92,7 +92,7 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
@Transactional(rollbackFor = Exception.class)
public void update(TbShopPurveyorTransact resources) {
TbShopPurveyorTransact tbShopPurveyorTransact = tbShopPurveyorTransactRepository.findById(resources.getId()).orElseGet(TbShopPurveyorTransact::new);
ValidationUtil.isNull( tbShopPurveyorTransact.getId(),"TbShopPurveyorTransact","id",resources.getId());
ValidationUtil.isNull(tbShopPurveyorTransact.getId(), "TbShopPurveyorTransact", "id", resources.getId());
tbShopPurveyorTransact.copy(resources);
tbShopPurveyorTransactRepository.save(tbShopPurveyorTransact);
}
@ -101,12 +101,14 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
@Transactional(rollbackFor = Exception.class)
public void payTransact(TbShopPurveyorTransact resources) {
TbShopPurveyorTransact tbShopPurveyorTransact = tbShopPurveyorTransactRepository.findById(resources.getId()).orElseGet(TbShopPurveyorTransact::new);
ValidationUtil.isNull( tbShopPurveyorTransact.getId(),"TbShopPurveyorTransact","id",resources.getId());
ValidationUtil.isNull(tbShopPurveyorTransact.getId(), "TbShopPurveyorTransact", "id", resources.getId());
tbShopPurveyorTransact.setPaidAmount(tbShopPurveyorTransact.getPaidAmount().add(resources.getPaidAmount()));
tbShopPurveyorTransact.setWaitAmount(tbShopPurveyorTransact.getWaitAmount().subtract(resources.getPaidAmount()));
tbShopPurveyorTransact.setPaidAt(System.currentTimeMillis());
if(tbShopPurveyorTransact.getWaitAmount().subtract(resources.getPaidAmount()).equals(0)){
if (tbShopPurveyorTransact.getWaitAmount().compareTo(tbShopPurveyorTransact.getPaidAmount()) <= 0) {
tbShopPurveyorTransact.setStatus(1);
}else {
tbShopPurveyorTransact.setStatus(0);
}
tbShopPurveyorTransactRepository.save(tbShopPurveyorTransact);
}
@ -123,19 +125,19 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
public void download(List<TbShopPurveyorTransactDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (TbShopPurveyorTransactDto tbShopPurveyorTransact : all) {
Map<String,Object> map = new LinkedHashMap<>();
Map<String, Object> map = new LinkedHashMap<>();
map.put("店铺Id", tbShopPurveyorTransact.getShopId());
map.put("供应商名字", tbShopPurveyorTransact.getPurveyorName());
map.put("供应商Id", tbShopPurveyorTransact.getPurveyorId());
map.put("0待付款1已付款 -1是否作废", tbShopPurveyorTransact.getStatus());
map.put("备注", tbShopPurveyorTransact.getRemark());
map.put(" createdAt", tbShopPurveyorTransact.getCreatedAt());
map.put(" updatedAt", tbShopPurveyorTransact.getUpdatedAt());
map.put(" createdAt", tbShopPurveyorTransact.getCreatedAt());
map.put(" updatedAt", tbShopPurveyorTransact.getUpdatedAt());
map.put("应付金额", tbShopPurveyorTransact.getTotalAmount());
map.put("待付款金额", tbShopPurveyorTransact.getWaitAmount());
map.put("已支付金额", tbShopPurveyorTransact.getPaidAmount());
map.put(" paidAt", tbShopPurveyorTransact.getPaidAt());
map.put(" type", tbShopPurveyorTransact.getType());
map.put(" paidAt", tbShopPurveyorTransact.getPaidAt());
map.put(" type", tbShopPurveyorTransact.getType());
list.add(map);
}
FileUtil.downloadExcel(list, response);