供应商操作日志

This commit is contained in:
liuyingfang 2024-01-26 09:33:52 +08:00
parent 8dfe061cc1
commit 5a41510fd5
16 changed files with 725 additions and 27 deletions

View File

@ -0,0 +1,99 @@
/*
* 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 me.zhengjie.modules.productInfo.productStockOperate.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.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author lyf
* @date 2024-01-25
**/
@Entity
@Data
@Table(name="tb_product_stock_operate")
public class TbProductStockOperate implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@ApiModelProperty(value = "自增id")
private Integer id;
@Column(name = "`shop_id`",nullable = false)
@NotBlank
@ApiModelProperty(value = "店铺Id")
private String shopId;
@Column(name = "`stock_snap`")
@ApiModelProperty(value = "操作镜像")
private String stockSnap;
@Column(name = "`type`")
@ApiModelProperty(value = "type")
private String type;
@Column(name = "`sub_type`")
@ApiModelProperty(value = "subType")
private Integer subType;
@Column(name = "`batch_number`")
@ApiModelProperty(value = "批次")
private String batchNumber;
@Column(name = "`remark`")
@ApiModelProperty(value = "remark")
private String remark;
@Column(name = "`stock_time`")
@ApiModelProperty(value = "操作时间")
private Long stockTime;
@Column(name = "`operator_snap`")
@ApiModelProperty(value = "操作人")
private String operatorSnap;
@Column(name = "`created_at`")
@ApiModelProperty(value = "createdAt")
private Long createdAt;
@Column(name = "`updated_at`")
@ApiModelProperty(value = "updatedAt")
private Long updatedAt;
@Column(name = "`purveyor_id`")
@ApiModelProperty(value = "供应商Id")
private String purveyorId;
@Column(name = "`purveyor_name`")
@ApiModelProperty(value = "供应商名称")
private String purveyorName;
@Column(name = "`status`")
@ApiModelProperty(value = "nullify作废normal正常")
private String status;
public void copy(TbProductStockOperate source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,28 @@
/*
* 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 me.zhengjie.modules.productInfo.productStockOperate.repository;
import me.zhengjie.modules.productInfo.productStockOperate.domain.TbProductStockOperate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author lyf
* @date 2024-01-25
**/
public interface TbProductStockOperateRepository extends JpaRepository<TbProductStockOperate, Integer>, JpaSpecificationExecutor<TbProductStockOperate> {
}

View File

@ -0,0 +1,84 @@
/*
* 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 me.zhengjie.modules.productInfo.productStockOperate.rest;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.productInfo.productStockOperate.domain.TbProductStockOperate;
import me.zhengjie.modules.productInfo.productStockOperate.service.TbProductStockOperateService;
import me.zhengjie.modules.productInfo.productStockOperate.service.dto.TbProductStockOperateQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
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;
/**
* @website https://eladmin.vip
* @author lyf
* @date 2024-01-25
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "/product/StockOperate管理")
@RequestMapping("/api/tbProductStockOperate")
public class TbProductStockOperateController {
private final TbProductStockOperateService tbProductStockOperateService;
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('tbProductStockOperate:list')")
public void exportTbProductStockOperate(HttpServletResponse response, TbProductStockOperateQueryCriteria criteria) throws IOException {
tbProductStockOperateService.download(tbProductStockOperateService.queryAll(criteria), response);
}
@PostMapping("/list")
public ResponseEntity<Object> queryTbProductStockOperate(@RequestBody TbProductStockOperateQueryCriteria criteria){
return new ResponseEntity<>(tbProductStockOperateService.queryAllPage(criteria),HttpStatus.OK);
}
@PostMapping
@Log("新增/product/StockOperate")
@ApiOperation("新增/product/StockOperate")
@PreAuthorize("@el.check('tbProductStockOperate:add')")
public ResponseEntity<Object> createTbProductStockOperate(@Validated @RequestBody TbProductStockOperate resources){
return new ResponseEntity<>(tbProductStockOperateService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改/product/StockOperate")
@ApiOperation("修改/product/StockOperate")
@PreAuthorize("@el.check('tbProductStockOperate:edit')")
public ResponseEntity<Object> updateTbProductStockOperate(@Validated @RequestBody TbProductStockOperate resources){
tbProductStockOperateService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@Log("删除/product/StockOperate")
@ApiOperation("删除/product/StockOperate")
@PreAuthorize("@el.check('tbProductStockOperate:del')")
public ResponseEntity<Object> deleteTbProductStockOperate(@RequestBody Integer[] ids) {
tbProductStockOperateService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -0,0 +1,83 @@
/*
* 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 me.zhengjie.modules.productInfo.productStockOperate.service;
import me.zhengjie.modules.productInfo.productStockOperate.domain.TbProductStockOperate;
import me.zhengjie.modules.productInfo.productStockOperate.service.dto.TbProductStockOperateDto;
import me.zhengjie.modules.productInfo.productStockOperate.service.dto.TbProductStockOperateQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务接口
* @author lyf
* @date 2024-01-25
**/
public interface TbProductStockOperateService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAllPage(TbProductStockOperateQueryCriteria criteria);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<TbProductStockOperateDto>
*/
List<TbProductStockOperateDto> queryAll(TbProductStockOperateQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return TbProductStockOperateDto
*/
TbProductStockOperateDto findById(Integer id);
/**
* 创建
* @param resources /
* @return TbProductStockOperateDto
*/
TbProductStockOperateDto create(TbProductStockOperate resources);
/**
* 编辑
* @param resources /
*/
void update(TbProductStockOperate resources);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Integer[] ids);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<TbProductStockOperateDto> all, HttpServletResponse response) throws IOException;
}

View File

@ -0,0 +1,48 @@
package me.zhengjie.modules.productInfo.productStockOperate.service.VO;
import com.alibaba.fastjson.JSONArray;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Map;
/**
* @author lyf
*/
@Data
public class ProductStockOperateVO {
private Integer id;
private String shopId;
private JSONArray stockSnap;
private String type;
private Integer subType;
private String batchNumber;
private String remark;
private Long stockTime;
private Map<String,Object> operatorSnap;
private Long createdAt;
private Long updatedAt;
private String purveyorId;
private String purveyorName;
private String status;
}

View File

@ -0,0 +1,66 @@
/*
* 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 me.zhengjie.modules.productInfo.productStockOperate.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author lyf
* @date 2024-01-25
**/
@Data
public class TbProductStockOperateDto implements Serializable {
/** 自增id */
private Integer id;
/** 店铺Id */
private String shopId;
/** 操作镜像 */
private String stockSnap;
private String type;
private Integer subType;
/** 批次 */
private String batchNumber;
private String remark;
/** 操作时间 */
private Long stockTime;
/** 操作人 */
private String operatorSnap;
private Long createdAt;
private Long updatedAt;
/** 供应商Id */
private String purveyorId;
/** 供应商名称 */
private String purveyorName;
/** nullify作废normal正常 */
private String status;
}

View File

@ -0,0 +1,42 @@
/*
* 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 me.zhengjie.modules.productInfo.productStockOperate.service.dto;
import lombok.Data;
import java.util.List;
import me.zhengjie.annotation.Query;
/**
* @website https://eladmin.vip
* @author lyf
* @date 2024-01-25
**/
@Data
public class TbProductStockOperateQueryCriteria{
/** 精确 */
@Query
private String shopId;
/** BETWEEN */
@Query(type = Query.Type.BETWEEN)
private List<Long> createdAt;
private Integer page;
private Integer size;
private String sort;
}

View File

@ -0,0 +1,133 @@
/*
* 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 me.zhengjie.modules.productInfo.productStockOperate.service.impl;
import cn.hutool.core.bean.BeanUtil;
import me.zhengjie.modules.productInfo.productStockOperate.domain.TbProductStockOperate;
import me.zhengjie.modules.productInfo.productStockOperate.service.VO.ProductStockOperateVO;
import me.zhengjie.utils.*;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.productInfo.productStockOperate.repository.TbProductStockOperateRepository;
import me.zhengjie.modules.productInfo.productStockOperate.service.TbProductStockOperateService;
import me.zhengjie.modules.productInfo.productStockOperate.service.dto.TbProductStockOperateDto;
import me.zhengjie.modules.productInfo.productStockOperate.service.dto.TbProductStockOperateQueryCriteria;
import me.zhengjie.modules.productInfo.productStockOperate.service.mapstruct.TbProductStockOperateMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
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.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author lyf
* @date 2024-01-25
**/
@Service
@RequiredArgsConstructor
public class TbProductStockOperateServiceImpl implements TbProductStockOperateService {
private final TbProductStockOperateRepository tbProductStockOperateRepository;
private final TbProductStockOperateMapper tbProductStockOperateMapper;
@Override
public Map<String, Object> queryAllPage(TbProductStockOperateQueryCriteria criteria) {
Sort sort = Sort.by(Sort.Direction.DESC, "id");
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
Page<TbProductStockOperate> page = tbProductStockOperateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
List<ProductStockOperateVO> stockOperateVOList = new ArrayList<>();
for (TbProductStockOperate stockOperate :page.getContent()) {
ProductStockOperateVO stockOperateVO = new ProductStockOperateVO();
BeanUtils.copyProperties(stockOperate,stockOperateVO);
stockOperateVO.setStockSnap(ListUtil.stringChangeList(stockOperate.getStockSnap()));
stockOperateVO.setOperatorSnap(StringUtils.stringChangeMap(stockOperate.getOperatorSnap()));
stockOperateVOList.add(stockOperateVO);
}
HashMap<String, Object> map = new HashMap<>();
map.put("content",stockOperateVOList);
map.put("totalElements",page.getTotalElements());
return map;
}
@Override
public List<TbProductStockOperateDto> queryAll(TbProductStockOperateQueryCriteria criteria){
return tbProductStockOperateMapper.toDto(tbProductStockOperateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
@Transactional
public TbProductStockOperateDto findById(Integer id) {
TbProductStockOperate tbProductStockOperate = tbProductStockOperateRepository.findById(id).orElseGet(TbProductStockOperate::new);
ValidationUtil.isNull(tbProductStockOperate.getId(),"TbProductStockOperate","id",id);
return tbProductStockOperateMapper.toDto(tbProductStockOperate);
}
@Override
@Transactional(rollbackFor = Exception.class)
public TbProductStockOperateDto create(TbProductStockOperate resources) {
return tbProductStockOperateMapper.toDto(tbProductStockOperateRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TbProductStockOperate resources) {
TbProductStockOperate tbProductStockOperate = tbProductStockOperateRepository.findById(resources.getId()).orElseGet(TbProductStockOperate::new);
ValidationUtil.isNull( tbProductStockOperate.getId(),"TbProductStockOperate","id",resources.getId());
tbProductStockOperate.copy(resources);
tbProductStockOperateRepository.save(tbProductStockOperate);
}
@Override
public void deleteAll(Integer[] ids) {
for (Integer id : ids) {
tbProductStockOperateRepository.deleteById(id);
}
}
@Override
public void download(List<TbProductStockOperateDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (TbProductStockOperateDto tbProductStockOperate : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("店铺Id", tbProductStockOperate.getShopId());
map.put("操作镜像", tbProductStockOperate.getStockSnap());
map.put(" type", tbProductStockOperate.getType());
map.put(" subType", tbProductStockOperate.getSubType());
map.put("批次", tbProductStockOperate.getBatchNumber());
map.put(" remark", tbProductStockOperate.getRemark());
map.put("操作时间", tbProductStockOperate.getStockTime());
map.put("操作人", tbProductStockOperate.getOperatorSnap());
map.put(" createdAt", tbProductStockOperate.getCreatedAt());
map.put(" updatedAt", tbProductStockOperate.getUpdatedAt());
map.put("供应商Id", tbProductStockOperate.getPurveyorId());
map.put("供应商名称", tbProductStockOperate.getPurveyorName());
map.put("nullify作废normal正常", tbProductStockOperate.getStatus());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@ -0,0 +1,32 @@
/*
* 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 me.zhengjie.modules.productInfo.productStockOperate.service.mapstruct;
import me.zhengjie.base.BaseMapper;
import me.zhengjie.modules.productInfo.productStockOperate.domain.TbProductStockOperate;
import me.zhengjie.modules.productInfo.productStockOperate.service.dto.TbProductStockOperateDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author lyf
* @date 2024-01-25
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TbProductStockOperateMapper extends BaseMapper<TbProductStockOperateDto, TbProductStockOperate> {
}

View File

@ -90,16 +90,6 @@ public class TbShopPurveyorTransact implements Serializable {
@ApiModelProperty(value = "type")
private String type;
/**
* 上笔进货日期
*/
private Long lastTransactAt;
/**
*待付款笔数
*/
private Integer waitCount;

View File

@ -34,10 +34,26 @@ import java.util.Map;
**/
public interface TbShopPurveyorTransactRepository extends JpaRepository<TbShopPurveyorTransact, Integer>, JpaSpecificationExecutor<TbShopPurveyorTransact> {
@Query("SELECT sum(transact.waitAmount) as waitAmount,count(transact.id) as waitCount, transact.purveyorId as purveyorId from TbShopPurveyorTransact transact " +
"where transact.purveyorId in :purveyorIds and transact.type =:type GROUP BY transact.purveyorId")
List<Map<String,Object>> findByPurveyorIds(@Param("purveyorIds") List<String> purveyorIds, @Param("type") String type);
@Query(value = "select transact.* from tb_shop_purveyor_transact transact where transact.shop_id =:shopId and transact.status =:status " +
"GROUP BY transact.purveyor_id LIMIT :page, :size ", nativeQuery = true)
List<TbShopPurveyorTransact> findByGroup(@Param("status")Integer status, @Param("shopId") String shopId,@Param("page") Integer page, @Param("size") Integer size);
// @Query("SELECT sum(transact.waitAmount) as waitAmount,count(transact.id) as waitCount, transact.purveyorId as purveyorId, from TbShopPurveyorTransact transact " +
// "where transact.purveyorId = :purveyorId and transact.type =:type GROUP BY transact.purveyorId")
// List<Map<String,Object>> findByPurveyorIds(@Param("purveyorId") String purveyorId, @Param("type") String type);
// @Query(value = "select transact.* from tb_shop_purveyor_transact transact where transact.shop_id =:shopId and transact.status =:status " +
// "GROUP BY transact.purveyor_id LIMIT :page, :size ", nativeQuery = true)
// List<TbShopPurveyorTransact> findByGroup(@Param("status")Integer status, @Param("shopId") String shopId,@Param("page") Integer page, @Param("size") Integer size);
//
@Query(value = "SELECT\n" +
"IFNULL(sum( b.wait_amount ), 0 ) AS waitAmount," +
"IFNULL(count( b.id ), 0 ) AS waitCount," +
"IFNULL(SUM(b.paid_amount),0) AS paidAmount," +
"IFNULL(SUM(b.total_amount),0) AS totalAmount" +
" FROM " +
" tb_shop_purveyor_transact b" +
" WHERE" +
" b.purveyor_id = :purveyorId" +
" AND b.type = :type",nativeQuery = true)
Map<String,Object> findBySum(@Param("purveyorId") String purveyorId,@Param("type")String type);
//
@Query(value = "SELECT IFNULL(count(b.id),0) AS waitNumber FROM tb_shop_purveyor_transact b WHERE" +
" b.purveyor_id = :purveyorId AND b.type = :type AND b.`status`= :status",nativeQuery = true)
Map<String,Object> findByStatusSum(@Param("purveyorId") String purveyorId,@Param("type")String type,@Param("status")Integer status);
}

View File

@ -51,13 +51,39 @@ public class TbShopPurveyorTransactController {
tbShopPurveyorTransactService.download(tbShopPurveyorTransactService.queryAll(criteria), response);
}
/**
* 进货账目
* @param criteria
* @param pageable
* @return
*/
@GetMapping
@Log("查询/shop/purveyorTransact")
@ApiOperation("查询/shop/purveyorTransact")
@PreAuthorize("@el.check('tbShopPurveyorTransact:list')")
public ResponseEntity<Object> queryTbShopPurveyorTransact(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable){
public ResponseEntity<Object> queryTbShopPurveyorTransactSum(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(tbShopPurveyorTransactService.queryTransactDate(criteria,pageable),HttpStatus.OK);
// return new ResponseEntity<>(tbShopPurveyorTransactService.queryAll(criteria,pageable),HttpStatus.OK);
}
/**
* 进货账目详情
* @param criteria
* @return
*/
@PostMapping("/info")
@Log("查询/shop/purveyorTransact")
public ResponseEntity<Object> queryPurveyorTransact(@RequestBody TbShopPurveyorTransactQueryCriteria criteria){
return new ResponseEntity<>(tbShopPurveyorTransactService.queryPurveyorTransact(criteria),HttpStatus.OK);
}
/**
* 汇总
* @param criteria
* @return
*/
@GetMapping("/sum")
public ResponseEntity<Object> queryTransactSum( TbShopPurveyorTransactQueryCriteria criteria){
return new ResponseEntity<>(tbShopPurveyorTransactService.queryTransactSum(criteria),HttpStatus.OK);
}
@PostMapping

View File

@ -16,6 +16,7 @@
package me.zhengjie.modules.shopInfo.shopPurveyorTransact.service;
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.domain.TbShopPurveyorTransact;
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.VO.PurveyorTransactSumVO;
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.VO.PurveyorTransactVO;
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.dto.TbShopPurveyorTransactDto;
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.dto.TbShopPurveyorTransactQueryCriteria;
@ -36,12 +37,13 @@ public interface TbShopPurveyorTransactService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable);
Map<String,Object> queryPurveyorTransact(TbShopPurveyorTransactQueryCriteria criteria);
Map<String, Object> queryTransactDate(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable);
Map<String, Object> queryTransactSum(TbShopPurveyorTransactQueryCriteria criteria);
/**
* 查询所有数据不分页
* @param criteria 条件参数

View File

@ -0,0 +1,29 @@
package me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.VO;
import java.math.BigDecimal;
/**
* @author 12847
*/
public class PurveyorTransactSumVO {
/**
* 交易笔数
*/
private Integer number;
/**
*已支付金额
*/
private BigDecimal paidAmount;
/**
*交易总金额
*/
private BigDecimal totalAmount;
/**
* 带支付金额
*/
private BigDecimal waitAmount;
/**
* 待支付笔数
*/
private Integer waitNumber;
}

View File

@ -46,4 +46,13 @@ public class TbShopPurveyorTransactQueryCriteria{
@Query
private Integer status;
@Query(type = Query.Type.BETWEEN)
private List<Long> createdAt;
private Integer page;
private Integer size;
private String sort;
}

View File

@ -18,6 +18,7 @@ package me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.impl;
import me.zhengjie.modules.shopInfo.shopPurveyor.domain.TbShopPurveyor;
import me.zhengjie.modules.shopInfo.shopPurveyor.repository.TbShopPurveyorRepository;
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.domain.TbShopPurveyorTransact;
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.VO.PurveyorTransactSumVO;
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.VO.PurveyorTransactVO;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
@ -27,6 +28,8 @@ import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.TbShopPurveyorT
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.dto.TbShopPurveyorTransactDto;
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.dto.TbShopPurveyorTransactQueryCriteria;
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.mapstruct.TbShopPurveyorTransactMapper;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
@ -88,14 +91,14 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
private EntityManager em;
@Override
public Map<String,Object> queryAll(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable){
Page<TbShopPurveyor> pageShopPurveyor = tbShopPurveyorRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
public Map<String, Object> queryPurveyorTransact(TbShopPurveyorTransactQueryCriteria criteria) {
Sort sort = Sort.by(Sort.Direction.DESC, "id");
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
Page<TbShopPurveyorTransact> pageShopPurveyor = tbShopPurveyorTransactRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
Map<String, Object> map = new HashMap<>();
// map.put("content",purveyorVoList);
map.put("totalElements",pageShopPurveyor.getTotalElements());
map.put("content",pageShopPurveyor.getContent());
map.put("totalElements",pageShopPurveyor.getTotalElements());
return map;
}
@ -129,7 +132,6 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
beginNo = (pageNum - 1) * pageSize;
}
sqlQuery.append(" LIMIT ").append(beginNo).append(",").append(pageSize);
System.out.println(sqlQuery);
Query query = em.createNativeQuery(String.valueOf(sqlQuery));
List<Object[]> resultList = query.getResultList();
@ -152,6 +154,15 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
return map;
}
@Override
public Map<String, Object> queryTransactSum(TbShopPurveyorTransactQueryCriteria criteria) {
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"));
return sumMap;
}
@Override
public List<TbShopPurveyorTransactDto> queryAll(TbShopPurveyorTransactQueryCriteria criteria){
return tbShopPurveyorTransactMapper.toDto(tbShopPurveyorTransactRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));