Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -87,6 +87,17 @@ public class TbConsInfoFlow implements Serializable {
|
||||
@ApiModelProperty(value = "店铺id")
|
||||
private Integer shopId;
|
||||
|
||||
|
||||
|
||||
@Column(name = "`order_id`")
|
||||
@ApiModelProperty(value = "订单id")
|
||||
private Integer orderId;
|
||||
|
||||
|
||||
@Column(name = "`order_no`")
|
||||
@ApiModelProperty(value = "订单编号")
|
||||
private String orderNo;
|
||||
|
||||
@Transient
|
||||
@TableField(exist = false)
|
||||
private String productName;
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.cons.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-17
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="view_con_info_flow")
|
||||
public class ViewConInfoFlow implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`cons_id`")
|
||||
@ApiModelProperty(value = "耗材id")
|
||||
private Integer consId;
|
||||
|
||||
@Column(name = "`con_name`")
|
||||
@ApiModelProperty(value = "耗材名称")
|
||||
private String conName;
|
||||
|
||||
@Column(name = "`con_return`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "con_return")
|
||||
private BigDecimal conReturn;
|
||||
|
||||
@Column(name = "`con_in`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "con_in")
|
||||
private BigDecimal conIn;
|
||||
|
||||
@Column(name = "`con_consume`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "con_consume")
|
||||
private BigDecimal conConsume;
|
||||
|
||||
@Column(name = "`con_out`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "con_out")
|
||||
private BigDecimal conOut;
|
||||
|
||||
@Column(name = "`balance`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "balance")
|
||||
private BigDecimal balance;
|
||||
|
||||
public void copy(ViewConInfoFlow source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package cn.ysk.cashier.cons.repository;
|
||||
|
||||
import cn.ysk.cashier.cons.domain.TbConsInfoFlow;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
@@ -22,4 +21,5 @@ public interface TbConsInfoFlowRepository extends JpaRepository<TbConsInfoFlow,
|
||||
"\tLEFT JOIN tb_product p ON s.product_id = p.id\n" +
|
||||
"\twhere i.pro_sku_id=?1 limit 1",nativeQuery = true)
|
||||
String selectByPskId(Integer skuId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.ysk.cashier.cons.repository;
|
||||
|
||||
import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author admin
|
||||
* @date 2024-07-17
|
||||
**/
|
||||
public interface ViewConInfoFlowRepository extends JpaRepository<ViewConInfoFlow, Integer>, JpaSpecificationExecutor<ViewConInfoFlow> {
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import io.swagger.annotations.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
@@ -47,14 +48,14 @@ public class TbConsInfoController {
|
||||
@PostMapping
|
||||
@Log("新增耗材信息")
|
||||
@ApiOperation("新增耗材信息")
|
||||
public ResponseEntity<Object> createTbConsInfo(@Validated @RequestBody TbConsInfo resources) throws Exception {
|
||||
public ResponseEntity<Object> createTbConsInfo(@Validated @RequestBody List<TbConsInfo> resources) throws Exception {
|
||||
return new ResponseEntity<>(tbConsInfoService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改耗材信息")
|
||||
@ApiOperation("修改耗材信息")
|
||||
public ResponseEntity<Object> updateTbConsInfo(@Validated @RequestBody TbConsInfo resources) throws Exception {
|
||||
public ResponseEntity<Object> updateTbConsInfo(@Validated @RequestBody List<TbConsInfo> resources) throws Exception {
|
||||
tbConsInfoService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package cn.ysk.cashier.cons.rest;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
|
||||
import cn.ysk.cashier.cons.service.ViewConInfoFlowService;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-17
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "获取耗材流水信息管理")
|
||||
@RequestMapping("/api/viewConInfoFlow")
|
||||
public class ViewConInfoFlowController {
|
||||
|
||||
private final ViewConInfoFlowService viewConInfoFlowService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
public void exportViewConInfoFlow(HttpServletResponse response, ViewConInfoFlowQueryCriteria criteria) throws IOException {
|
||||
viewConInfoFlowService.download(viewConInfoFlowService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询获取耗材流水信息")
|
||||
@ApiOperation("查询获取耗材流水信息")
|
||||
public ResponseEntity<Object> queryViewConInfoFlow(ViewConInfoFlowQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(viewConInfoFlowService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增获取耗材流水信息")
|
||||
@ApiOperation("新增获取耗材流水信息")
|
||||
public ResponseEntity<Object> createViewConInfoFlow(@Validated @RequestBody ViewConInfoFlow resources){
|
||||
return new ResponseEntity<>(viewConInfoFlowService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改获取耗材流水信息")
|
||||
@ApiOperation("修改获取耗材流水信息")
|
||||
public ResponseEntity<Object> updateViewConInfoFlow(@Validated @RequestBody ViewConInfoFlow resources){
|
||||
viewConInfoFlowService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除获取耗材流水信息")
|
||||
@ApiOperation("删除获取耗材流水信息")
|
||||
public ResponseEntity<Object> deleteViewConInfoFlow(@RequestBody Integer[] ids) {
|
||||
viewConInfoFlowService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -47,13 +47,13 @@ public interface TbConsInfoService {
|
||||
* @param resources /
|
||||
* @return TbConsInfoDto
|
||||
*/
|
||||
TbConsInfoDto create(TbConsInfo resources) throws Exception;
|
||||
TbConsInfoDto create(List<TbConsInfo> resources) throws Exception;
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbConsInfo resources) throws Exception;
|
||||
void update(List<TbConsInfo> resources) throws Exception;
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.ysk.cashier.cons.service;
|
||||
|
||||
import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowDto;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-17
|
||||
**/
|
||||
public interface ViewConInfoFlowService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(ViewConInfoFlowQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<ViewConInfoFlowDto>
|
||||
*/
|
||||
List<ViewConInfoFlowDto> queryAll(ViewConInfoFlowQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param consId ID
|
||||
* @return ViewConInfoFlowDto
|
||||
*/
|
||||
ViewConInfoFlowDto findById(Integer consId);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return ViewConInfoFlowDto
|
||||
*/
|
||||
ViewConInfoFlowDto create(ViewConInfoFlow resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(ViewConInfoFlow resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<ViewConInfoFlowDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
@@ -15,7 +15,10 @@
|
||||
*/
|
||||
package cn.ysk.cashier.cons.service.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.sql.Timestamp;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
@@ -60,4 +63,9 @@ public class TbConsInfoFlowDto implements Serializable {
|
||||
private Integer shopId;
|
||||
|
||||
private String productName;
|
||||
|
||||
|
||||
private Integer orderId;
|
||||
|
||||
private String orderNo;
|
||||
}
|
||||
@@ -22,4 +22,8 @@ public class TbConsInfoFlowQueryCriteria{
|
||||
/** 精确 */
|
||||
@Query
|
||||
private Integer shopId;
|
||||
|
||||
|
||||
@Query
|
||||
private String orderNo;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.cons.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-17
|
||||
**/
|
||||
@Data
|
||||
public class ViewConInfoFlowDto implements Serializable {
|
||||
|
||||
/** 耗材id */
|
||||
private Integer consId;
|
||||
|
||||
/** 耗材名称 */
|
||||
private String conName;
|
||||
|
||||
private BigDecimal conReturn;
|
||||
|
||||
private BigDecimal conIn;
|
||||
|
||||
private BigDecimal conConsume;
|
||||
|
||||
private BigDecimal conOut;
|
||||
|
||||
private BigDecimal balance;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.ysk.cashier.cons.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import cn.ysk.cashier.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-17
|
||||
**/
|
||||
@Data
|
||||
public class ViewConInfoFlowQueryCriteria{
|
||||
|
||||
/** 模糊 */
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String conName;
|
||||
}
|
||||
@@ -99,14 +99,14 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbConsInfoDto create(TbConsInfo resources) throws Exception {
|
||||
public TbConsInfoDto create(List<TbConsInfo> resources) throws Exception {
|
||||
|
||||
|
||||
TbConsType tbConsType = tbConsTypeRepository.getById(resources.getConTypeId());
|
||||
if (Objects.isNull(tbConsType)) {
|
||||
throw new Exception("不存在的耗材类型");
|
||||
}
|
||||
|
||||
for (TbConsInfo resource : resources) {
|
||||
TbConsType tbConsType = tbConsTypeRepository.getById(resource.getConTypeId());
|
||||
if (Objects.isNull(tbConsType)) {
|
||||
throw new Exception("不存在的耗材类型");
|
||||
}
|
||||
|
||||
// int count = tbConsInfoRepository.countByConCode(resources.getConCode());
|
||||
// if (count > 0) {
|
||||
@@ -114,33 +114,37 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
||||
// }
|
||||
|
||||
|
||||
resources.setConCode(StringCodeUtil.getRandom(8,LETTER_CAPITAL_NUMBER));
|
||||
resources.setConTypeName(tbConsType.getConTypeName());
|
||||
resources.setLasterInStock(BigDecimal.ZERO);
|
||||
resources.setStockNumber(BigDecimal.ZERO);
|
||||
resources.setStatus("1");
|
||||
resources.setStockConsume(BigDecimal.ZERO);
|
||||
resources.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||
return tbConsInfoMapper.toDto(tbConsInfoRepository.save(resources));
|
||||
resource.setConCode(StringCodeUtil.getRandom(8,LETTER_CAPITAL_NUMBER));
|
||||
resource.setConTypeName(tbConsType.getConTypeName());
|
||||
resource.setLasterInStock(BigDecimal.ZERO);
|
||||
resource.setStockNumber(BigDecimal.ZERO);
|
||||
resource.setStatus("1");
|
||||
resource.setStockConsume(BigDecimal.ZERO);
|
||||
resource.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||
tbConsInfoRepository.save(resource);
|
||||
}
|
||||
return tbConsInfoMapper.toDto(new TbConsInfo());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbConsInfo resources) throws Exception {
|
||||
TbConsInfo tbConsInfo = tbConsInfoRepository.findById(resources.getId()).orElseGet(TbConsInfo::new);
|
||||
public void update(List<TbConsInfo> resources) throws Exception {
|
||||
for (TbConsInfo resource : resources) {
|
||||
TbConsInfo tbConsInfo = tbConsInfoRepository.findById(resource.getId()).orElseGet(TbConsInfo::new);
|
||||
|
||||
if (Objects.isNull(tbConsInfo)) {
|
||||
throw new Exception("耗材信息不存在");
|
||||
if (Objects.isNull(tbConsInfo)) {
|
||||
throw new Exception("耗材信息不存在");
|
||||
}
|
||||
|
||||
tbConsInfo.setConName(resource.getConName());
|
||||
tbConsInfo.setPrice(resource.getPrice());
|
||||
tbConsInfo.setConUnit(resource.getConUnit());
|
||||
tbConsInfo.setConWarning(resource.getConWarning());
|
||||
tbConsInfo.setStatus(resource.getStatus());
|
||||
tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||
tbConsInfoRepository.save(tbConsInfo);
|
||||
}
|
||||
|
||||
|
||||
tbConsInfo.setConName(resources.getConName());
|
||||
tbConsInfo.setPrice(resources.getPrice());
|
||||
tbConsInfo.setConUnit(resources.getConUnit());
|
||||
tbConsInfo.setConWarning(resources.getConWarning());
|
||||
tbConsInfo.setStatus(resources.getStatus());
|
||||
tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||
tbConsInfoRepository.save(tbConsInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package cn.ysk.cashier.cons.service.impl;
|
||||
|
||||
import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import cn.ysk.cashier.utils.QueryHelp;
|
||||
import cn.ysk.cashier.utils.ValidationUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import cn.ysk.cashier.cons.repository.ViewConInfoFlowRepository;
|
||||
import cn.ysk.cashier.cons.service.ViewConInfoFlowService;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowDto;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria;
|
||||
import cn.ysk.cashier.cons.service.mapstruct.ViewConInfoFlowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author admin
|
||||
* @date 2024-07-17
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ViewConInfoFlowServiceImpl implements ViewConInfoFlowService {
|
||||
|
||||
private final ViewConInfoFlowRepository viewConInfoFlowRepository;
|
||||
private final ViewConInfoFlowMapper viewConInfoFlowMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(ViewConInfoFlowQueryCriteria criteria, Pageable pageable){
|
||||
Page<ViewConInfoFlow> page = viewConInfoFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(viewConInfoFlowMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ViewConInfoFlowDto> queryAll(ViewConInfoFlowQueryCriteria criteria){
|
||||
return viewConInfoFlowMapper.toDto(viewConInfoFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ViewConInfoFlowDto findById(Integer consId) {
|
||||
ViewConInfoFlow viewConInfoFlow = viewConInfoFlowRepository.findById(consId).orElseGet(ViewConInfoFlow::new);
|
||||
ValidationUtil.isNull(viewConInfoFlow.getConsId(),"ViewConInfoFlow","consId",consId);
|
||||
return viewConInfoFlowMapper.toDto(viewConInfoFlow);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ViewConInfoFlowDto create(ViewConInfoFlow resources) {
|
||||
return viewConInfoFlowMapper.toDto(viewConInfoFlowRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(ViewConInfoFlow resources) {
|
||||
ViewConInfoFlow viewConInfoFlow = viewConInfoFlowRepository.findById(resources.getConsId()).orElseGet(ViewConInfoFlow::new);
|
||||
ValidationUtil.isNull( viewConInfoFlow.getConsId(),"ViewConInfoFlow","id",resources.getConsId());
|
||||
viewConInfoFlow.copy(resources);
|
||||
viewConInfoFlowRepository.save(viewConInfoFlow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer consId : ids) {
|
||||
viewConInfoFlowRepository.deleteById(consId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<ViewConInfoFlowDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (ViewConInfoFlowDto viewConInfoFlow : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("耗材名称", viewConInfoFlow.getConName());
|
||||
map.put(" conreturn", viewConInfoFlow.getConReturn());
|
||||
map.put(" conin", viewConInfoFlow.getConIn());
|
||||
map.put(" conconsume", viewConInfoFlow.getConConsume());
|
||||
map.put(" conout", viewConInfoFlow.getConOut());
|
||||
map.put(" balance", viewConInfoFlow.getBalance());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.ysk.cashier.cons.service.mapstruct;
|
||||
|
||||
import cn.ysk.cashier.base.BaseMapper;
|
||||
import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-17
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface ViewConInfoFlowMapper extends BaseMapper<ViewConInfoFlowDto, ViewConInfoFlow> {
|
||||
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
package cn.ysk.cashier.controller.order;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoDto;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria;
|
||||
import cn.ysk.cashier.dto.order.TbPayCountQueryCriteria;
|
||||
@@ -55,6 +56,7 @@ public class TbOrderInfoController {
|
||||
|
||||
@PostMapping("/date")
|
||||
@ApiOperation("查询订单")
|
||||
@AnonymousPostMapping
|
||||
public ResponseEntity<Object> queryTbOrderInfo(@RequestBody TbOrderInfoQueryCriteria criteria){
|
||||
return new ResponseEntity<>(tbOrderInfoService.queryAllPage(criteria),HttpStatus.OK);
|
||||
}
|
||||
@@ -90,4 +92,4 @@ public class TbOrderInfoController {
|
||||
// tbOrderInfoService.deleteAll(ids);
|
||||
// return new ResponseEntity<>(HttpStatus.OK);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,4 +72,6 @@ public class TbOrderInfoQueryCriteria{
|
||||
|
||||
@Query
|
||||
private String tableName;
|
||||
}
|
||||
|
||||
private String productName;
|
||||
}
|
||||
|
||||
@@ -136,4 +136,13 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
|
||||
"\t) AS total ", nativeQuery = true)
|
||||
Tuple searchCount(@Param("shopId") Integer shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
}
|
||||
@Query(value = "SELECT d.order_id \n" +
|
||||
" FROM tb_order_detail d \n" +
|
||||
" WHERE d.product_name LIKE %:productName% \n" +
|
||||
" AND d.shop_id = :shopId \n" +
|
||||
" AND d.create_time BETWEEN :startTime AND :endTime \n" +
|
||||
" GROUP BY d.order_id", nativeQuery = true)
|
||||
List<Integer> findOrderIdsByProductNameLike(@Param("productName") String productName, @Param("shop_id") String shopId,
|
||||
@Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package cn.ysk.cashier.service.impl.order;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.ysk.cashier.cons.rabbit.RabbitConstants;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoDto;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria;
|
||||
import cn.ysk.cashier.dto.order.TbPayCountQueryCriteria;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mapper.order.TbOrderInfoMapper;
|
||||
import cn.ysk.cashier.mapper.product.TbProductMapper;
|
||||
import cn.ysk.cashier.mapper.product.TbProductSkuMapper;
|
||||
@@ -96,6 +98,36 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
if (StringUtils.isBlank(criteria.getStatus()) && StringUtils.isBlank(criteria.getSource())) {
|
||||
predicate = criteriaBuilder.and(predicate, criteriaBuilder.notEqual(root.get("orderType"), "return"));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(criteria.getProductName())) {
|
||||
Date startTime, endTime;
|
||||
DateTime offsetMonth = cn.hutool.core.date.DateUtil.offsetMonth(new Date(), 3);
|
||||
if (criteria.getCreatedAt() != null && criteria.getCreatedAt().size() == 2) {
|
||||
Long startLong = criteria.getCreatedAt().get(0);
|
||||
Long endLong = criteria.getCreatedAt().get(1);
|
||||
|
||||
startTime = new Date(startLong);
|
||||
endTime = new Date(endLong);
|
||||
|
||||
// 如果开始时间小于三个月前,不查询
|
||||
if (startTime.before(offsetMonth)) {
|
||||
throw new BadRequestException("查询时间范围不能超过三个月");
|
||||
}
|
||||
} else {
|
||||
startTime = offsetMonth;
|
||||
endTime = new Date();
|
||||
}
|
||||
|
||||
List<Integer> productIds = tbOrderDetailRepository.findOrderIdsByProductNameLike(criteria.getProductName(),
|
||||
criteria.getShopId(), startTime, endTime);
|
||||
|
||||
if (productIds.isEmpty()) {
|
||||
predicate = criteriaBuilder.and(predicate, criteriaBuilder.equal(root.get("id"), 0));
|
||||
} else {
|
||||
predicate = criteriaBuilder.and(predicate, root.get("id").in(productIds));
|
||||
}
|
||||
}
|
||||
|
||||
return predicate;
|
||||
}, pageable);
|
||||
|
||||
@@ -121,7 +153,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
detail.setRefundNumber(refundNumber);
|
||||
}
|
||||
});
|
||||
}else {
|
||||
} else {
|
||||
details.parallelStream().forEach(detail -> {
|
||||
detail.setRefundNumber(detail.getNum());
|
||||
});
|
||||
@@ -151,10 +183,10 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
end = createdAt.get(1);
|
||||
}
|
||||
}
|
||||
if(ObjectUtil.isEmpty(criteria.getTableName())){
|
||||
if (ObjectUtil.isEmpty(criteria.getTableName())) {
|
||||
criteria.setTableName(null);
|
||||
}
|
||||
List<TbOrderPayCountVo> payCountVoList = tbOrderInfoRepository.queryTbOrderPayCount(criteria.getShopId(),criteria.getTableName(), start, end);
|
||||
List<TbOrderPayCountVo> payCountVoList = tbOrderInfoRepository.queryTbOrderPayCount(criteria.getShopId(), criteria.getTableName(), start, end);
|
||||
BigDecimal totalPayAmount = BigDecimal.ZERO;
|
||||
for (TbOrderPayCountVo payCount : payCountVoList) {
|
||||
totalPayAmount = totalPayAmount.add(new BigDecimal(payCount.getPayAmount().toString()));
|
||||
@@ -171,7 +203,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
result.add(payCount);
|
||||
}
|
||||
}
|
||||
TbOrderPayCountVo payRufund = tbOrderInfoRepository.queryTbOrderRefund(criteria.getShopId(),criteria.getTableName(), start, end);
|
||||
TbOrderPayCountVo payRufund = tbOrderInfoRepository.queryTbOrderRefund(criteria.getShopId(), criteria.getTableName(), start, end);
|
||||
if (payRufund != null) {
|
||||
totalPayAmount = totalPayAmount.subtract(new BigDecimal(payRufund.getPayAmount().toString()));
|
||||
payRufund.setPayType("退单");
|
||||
@@ -231,7 +263,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
dto.setIsRefund(0);
|
||||
dto.setRefundAmount(BigDecimal.ZERO);
|
||||
List<TbOrderInfo> tbOrderInfos = tbOrderInfoRepository.selTbOrdersBysource(tbOrderInfo.getId(), tbOrderInfo.getShopId());
|
||||
if(!CollectionUtils.isEmpty(tbOrderInfos)){
|
||||
if (!CollectionUtils.isEmpty(tbOrderInfos)) {
|
||||
dto.setIsRefund(1);
|
||||
dto.setRefundAmount(tbOrderInfos.stream().map(TbOrderInfo::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
}
|
||||
@@ -250,15 +282,15 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void expired(String orderId) {
|
||||
//修改耗材数据
|
||||
JSONObject jsonObject1=new JSONObject();
|
||||
jsonObject1.put("type","delete");
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("type", "delete");
|
||||
|
||||
Optional<TbOrderInfo> byId = tbOrderInfoRepository.findById(Integer.valueOf(orderId));
|
||||
if (byId != null && byId.isPresent()) {
|
||||
TbOrderInfo tbOrderInfo = byId.get();
|
||||
if (tbOrderInfo.getStatus().equals("unpaid")) {
|
||||
upOrderStatus(tbOrderInfo);
|
||||
jsonObject1.put("orderId",tbOrderInfo.getId());
|
||||
jsonObject1.put("orderId", tbOrderInfo.getId());
|
||||
// 发送取消订单mq消息
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT,
|
||||
jsonObject1.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
||||
@@ -274,7 +306,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
redisUtils.set(CacheKey.ORDER_EXPIRED + tbOrderInfo.getId(), tbOrderInfo.getId(), 60 * 2);
|
||||
} else {
|
||||
upOrderStatus(tbOrderInfo);
|
||||
jsonObject1.put("orderId",tbOrderInfo.getId());
|
||||
jsonObject1.put("orderId", tbOrderInfo.getId());
|
||||
|
||||
// 发送取消订单mq消息
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT,
|
||||
@@ -360,7 +392,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
public void download(List<TbOrderInfoDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
|
||||
all=all.stream().sorted(Comparator.comparing(TbOrderInfoDto::getId).reversed()).collect(Collectors.toList());
|
||||
all = all.stream().sorted(Comparator.comparing(TbOrderInfoDto::getId).reversed()).collect(Collectors.toList());
|
||||
for (TbOrderInfoDto tbOrderInfo : all) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("订单编号", tbOrderInfo.getOrderNo());
|
||||
@@ -408,8 +440,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
map.put("商品信息", productNames);
|
||||
//
|
||||
|
||||
if(ObjectUtil.isNotEmpty(tbOrderInfo.getPayType())&&ObjectUtil.isNotNull(tbOrderInfo.getPayType())){
|
||||
switch (tbOrderInfo.getPayType()){
|
||||
if (ObjectUtil.isNotEmpty(tbOrderInfo.getPayType()) && ObjectUtil.isNotNull(tbOrderInfo.getPayType())) {
|
||||
switch (tbOrderInfo.getPayType()) {
|
||||
case "scanCode":
|
||||
tbOrderInfo.setPayType("收款码支付");
|
||||
break;
|
||||
@@ -424,7 +456,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
break;
|
||||
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
tbOrderInfo.setPayType("");
|
||||
}
|
||||
|
||||
@@ -471,7 +503,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
map.put("状态", tbOrderInfo.getStatus());
|
||||
map.put("创建日期", DateUtil.timeStampFormatyMdHms(tbOrderInfo.getCreatedAt()));
|
||||
map.put("备注", tbOrderInfo.getRemark());
|
||||
map.put("台桌",tbOrderInfo.getTableName());
|
||||
map.put("台桌", tbOrderInfo.getTableName());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
|
||||
Reference in New Issue
Block a user