供应商相关,供应商进货/退货账目
This commit is contained in:
@@ -20,8 +20,10 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.w3c.dom.stylesheets.LinkStyle;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -31,5 +33,6 @@ import java.util.List;
|
||||
**/
|
||||
public interface TbProductStockDetailRepository extends JpaRepository<TbProductStockDetail, Long>, JpaSpecificationExecutor<TbProductStockDetail> {
|
||||
|
||||
|
||||
@Query("select sum(detail.stockNumber) from TbProductStockDetail detail where detail.productId =:product")
|
||||
BigDecimal sumStockNumber(@Param("product") String product);
|
||||
}
|
||||
@@ -66,8 +66,18 @@ public class TbProductStockDetailController {
|
||||
public ResponseEntity<Object> queryPage(@RequestBody TbProductStockDetailQueryCriteria criteria){
|
||||
return new ResponseEntity<>(tbProductStockDetailService.queryPage(criteria),HttpStatus.OK);
|
||||
}
|
||||
@GetMapping("/sum")
|
||||
@Log("查询/product/Stock")
|
||||
public ResponseEntity<Object> sumType(TbProductStockDetailQueryCriteria criteria){
|
||||
return new ResponseEntity<>(tbProductStockDetailService.sumStockNumber(criteria.getProductId()),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 出库/入库
|
||||
* @param resources
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Log("新增/product/Stock")
|
||||
@ApiOperation("新增/product/Stock")
|
||||
|
||||
@@ -19,6 +19,9 @@ import me.zhengjie.modules.productInfo.productStock.domain.TbProductStockDetail;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.dto.TbProductStockDetailDto;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.dto.TbProductStockDetailQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
@@ -56,6 +59,7 @@ public interface TbProductStockDetailService {
|
||||
*/
|
||||
TbProductStockDetailDto findById(Long id);
|
||||
|
||||
HashMap<String, BigDecimal> sumStockNumber(String productId);
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
|
||||
@@ -33,13 +33,12 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import javax.persistence.criteria.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
@@ -86,9 +85,19 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
|
||||
return tbProductStockDetailMapper.toDto(tbProductStockDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, BigDecimal> sumStockNumber(String productId) {
|
||||
BigDecimal bigDecimal = tbProductStockDetailRepository.sumStockNumber(productId);
|
||||
HashMap<String, BigDecimal> map = new HashMap<>();
|
||||
map.put("exchange",bigDecimal);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbProductStockDetailDto create(TbProductStockDetail resources) {
|
||||
|
||||
|
||||
return tbProductStockDetailMapper.toDto(tbProductStockDetailRepository.save(resources));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,12 @@
|
||||
package me.zhengjie.modules.shopInfo.shopPurveyor.repository;
|
||||
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.domain.TbShopPurveyor;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
@@ -25,4 +29,10 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
* @date 2024-01-22
|
||||
**/
|
||||
public interface TbShopPurveyorRepository extends JpaRepository<TbShopPurveyor, Integer>, JpaSpecificationExecutor<TbShopPurveyor> {
|
||||
|
||||
@Query(value = "select purveyor.* from tb_shop_purveyor purveyor where id in :ids LIMIT :page, :size ",nativeQuery = true)
|
||||
List<TbShopPurveyor> findByIds(@Param("ids") List<Integer> ids, @Param("page")Integer page, @Param("size")Integer size);
|
||||
|
||||
@Query("select count(1) from TbShopPurveyor purveyor where purveyor.shopId = :shopId")
|
||||
Integer findByCount(@Param("shop") String shopId);
|
||||
}
|
||||
@@ -32,8 +32,8 @@ public class TbShopPurveyorQueryCriteria{
|
||||
private String shopId;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String name;
|
||||
@Query(type = Query.Type.LEFT_LIKE)
|
||||
private String purveyorName;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
|
||||
@@ -30,6 +30,8 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
@@ -72,6 +74,8 @@ public class TbShopPurveyorServiceImpl implements TbShopPurveyorService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbShopPurveyorDto create(TbShopPurveyor resources) {
|
||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
return tbShopPurveyorMapper.toDto(tbShopPurveyorRepository.save(resources));
|
||||
}
|
||||
|
||||
@@ -79,6 +83,8 @@ public class TbShopPurveyorServiceImpl implements TbShopPurveyorService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbShopPurveyor resources) {
|
||||
TbShopPurveyor tbShopPurveyor = tbShopPurveyorRepository.findById(resources.getId()).orElseGet(TbShopPurveyor::new);
|
||||
tbShopPurveyor.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
tbShopPurveyor.setSort(0);
|
||||
ValidationUtil.isNull( tbShopPurveyor.getId(),"TbShopPurveyor","id",resources.getId());
|
||||
tbShopPurveyor.copy(resources);
|
||||
tbShopPurveyorRepository.save(tbShopPurveyor);
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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.shopInfo.shopPurveyorTransact.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;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-23
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="tb_shop_purveyor_transact")
|
||||
public class TbShopPurveyorTransact 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 = "`purveyor_name`")
|
||||
@ApiModelProperty(value = "供应商名字")
|
||||
private String purveyorName;
|
||||
|
||||
@Column(name = "`purveyor_id`")
|
||||
@ApiModelProperty(value = "供应商Id")
|
||||
private String purveyorId;
|
||||
|
||||
@Column(name = "`status`")
|
||||
@ApiModelProperty(value = "0待付款1已付款 -1是否作废")
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "`remark`")
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@Column(name = "`created_at`")
|
||||
@ApiModelProperty(value = "createdAt")
|
||||
private Long createdAt;
|
||||
|
||||
@Column(name = "`updated_at`")
|
||||
@ApiModelProperty(value = "updatedAt")
|
||||
private Long updatedAt;
|
||||
|
||||
@Column(name = "`total_amount`")
|
||||
@ApiModelProperty(value = "应付金额")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@Column(name = "`wait_amount`")
|
||||
@ApiModelProperty(value = "待付款金额")
|
||||
private BigDecimal waitAmount;
|
||||
|
||||
@Column(name = "`paid_amount`")
|
||||
@ApiModelProperty(value = "已支付金额")
|
||||
private BigDecimal paidAmount;
|
||||
|
||||
@Column(name = "`paid_at`")
|
||||
@ApiModelProperty(value = "paidAt")
|
||||
private Long paidAt;
|
||||
|
||||
@Column(name = "`type`")
|
||||
@ApiModelProperty(value = "type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 上笔进货日期
|
||||
*/
|
||||
private Long lastTransactAt;
|
||||
|
||||
/**
|
||||
*待付款笔数
|
||||
*/
|
||||
private Integer waitCount;
|
||||
|
||||
|
||||
|
||||
|
||||
public void copy(TbShopPurveyorTransact source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.shopInfo.shopPurveyorTransact.repository;
|
||||
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.domain.TbShopPurveyorTransact;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.VO.PurveyorTransactVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-23
|
||||
**/
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.shopInfo.shopPurveyorTransact.rest;
|
||||
|
||||
import me.zhengjie.annotation.Log;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.domain.TbShopPurveyorTransact;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.TbShopPurveyorTransactService;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.dto.TbShopPurveyorTransactQueryCriteria;
|
||||
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-23
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "/shop/purveyorTransact管理")
|
||||
@RequestMapping("/api/tbShopPurveyorTransact")
|
||||
public class TbShopPurveyorTransactController {
|
||||
|
||||
private final TbShopPurveyorTransactService tbShopPurveyorTransactService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbShopPurveyorTransact:list')")
|
||||
public void exportTbShopPurveyorTransact(HttpServletResponse response, TbShopPurveyorTransactQueryCriteria criteria) throws IOException {
|
||||
tbShopPurveyorTransactService.download(tbShopPurveyorTransactService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询/shop/purveyorTransact")
|
||||
@ApiOperation("查询/shop/purveyorTransact")
|
||||
@PreAuthorize("@el.check('tbShopPurveyorTransact:list')")
|
||||
public ResponseEntity<Object> queryTbShopPurveyorTransact(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbShopPurveyorTransactService.queryTransactDate(criteria,pageable),HttpStatus.OK);
|
||||
// return new ResponseEntity<>(tbShopPurveyorTransactService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增/shop/purveyorTransact")
|
||||
@ApiOperation("新增/shop/purveyorTransact")
|
||||
@PreAuthorize("@el.check('tbShopPurveyorTransact:add')")
|
||||
public ResponseEntity<Object> createTbShopPurveyorTransact(@Validated @RequestBody TbShopPurveyorTransact resources){
|
||||
return new ResponseEntity<>(tbShopPurveyorTransactService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改/shop/purveyorTransact")
|
||||
@ApiOperation("修改/shop/purveyorTransact")
|
||||
@PreAuthorize("@el.check('tbShopPurveyorTransact:edit')")
|
||||
public ResponseEntity<Object> updateTbShopPurveyorTransact(@Validated @RequestBody TbShopPurveyorTransact resources){
|
||||
tbShopPurveyorTransactService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除/shop/purveyorTransact")
|
||||
@ApiOperation("删除/shop/purveyorTransact")
|
||||
@PreAuthorize("@el.check('tbShopPurveyorTransact:del')")
|
||||
public ResponseEntity<Object> deleteTbShopPurveyorTransact(@RequestBody Integer[] ids) {
|
||||
tbShopPurveyorTransactService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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.shopInfo.shopPurveyorTransact.service;
|
||||
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.domain.TbShopPurveyorTransact;
|
||||
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;
|
||||
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-23
|
||||
**/
|
||||
public interface TbShopPurveyorTransactService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable);
|
||||
Map<String, Object> queryTransactDate(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbShopPurveyorTransactDto>
|
||||
*/
|
||||
List<TbShopPurveyorTransactDto> queryAll(TbShopPurveyorTransactQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return TbShopPurveyorTransactDto
|
||||
*/
|
||||
TbShopPurveyorTransactDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbShopPurveyorTransactDto
|
||||
*/
|
||||
TbShopPurveyorTransactDto create(TbShopPurveyorTransact resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbShopPurveyorTransact resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbShopPurveyorTransactDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.VO;
|
||||
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Data
|
||||
public class PurveyorTransactVO {
|
||||
/**
|
||||
* 上笔进货日期
|
||||
*/
|
||||
private BigInteger lastTransactAt;
|
||||
/**
|
||||
* 供货商id
|
||||
*/
|
||||
private Integer purveyorId;
|
||||
/**
|
||||
* 供货商名称
|
||||
*/
|
||||
private String purveyorName;
|
||||
/**
|
||||
* 剩余付款金额
|
||||
*/
|
||||
private BigDecimal waitAmount;
|
||||
/**
|
||||
*待付款笔数
|
||||
*/
|
||||
private BigInteger waitCount;
|
||||
/**
|
||||
* 0.待支付 1.已完结
|
||||
*/
|
||||
private Integer type;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.shopInfo.shopPurveyorTransact.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-23
|
||||
**/
|
||||
@Data
|
||||
public class TbShopPurveyorTransactDto implements Serializable {
|
||||
|
||||
/** 自增id */
|
||||
private Integer id;
|
||||
|
||||
/** 店铺Id */
|
||||
private String shopId;
|
||||
|
||||
/** 供应商名字 */
|
||||
private String purveyorName;
|
||||
|
||||
/** 供应商Id */
|
||||
private String purveyorId;
|
||||
|
||||
/** 0待付款1已付款 -1是否作废 */
|
||||
private Integer status;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
|
||||
/** 应付金额 */
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/** 待付款金额 */
|
||||
private BigDecimal waitAmount;
|
||||
|
||||
/** 已支付金额 */
|
||||
private BigDecimal paidAmount;
|
||||
|
||||
private Long paidAt;
|
||||
|
||||
private String type;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.shopInfo.shopPurveyorTransact.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-23
|
||||
**/
|
||||
@Data
|
||||
public class TbShopPurveyorTransactQueryCriteria{
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String shopId;
|
||||
|
||||
/** 精确 */
|
||||
@Query(type = Query.Type.LEFT_LIKE)
|
||||
private String purveyorName;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String purveyorId;
|
||||
/**
|
||||
* purveyor进货 reject退货
|
||||
*/
|
||||
@Query
|
||||
private String type;
|
||||
|
||||
@Query
|
||||
private Integer status;
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* 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.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.PurveyorTransactVO;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.repository.TbShopPurveyorTransactRepository;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.TbShopPurveyorTransactService;
|
||||
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.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author lyf
|
||||
* @date 2024-01-23
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransactService {
|
||||
|
||||
private final TbShopPurveyorTransactRepository tbShopPurveyorTransactRepository;
|
||||
private final TbShopPurveyorTransactMapper tbShopPurveyorTransactMapper;
|
||||
private final TbShopPurveyorRepository tbShopPurveyorRepository;
|
||||
|
||||
private final String LEFTQUERYSQL="SELECT\n" +
|
||||
"\ta.purveyor_name AS purveyorName,\n" +
|
||||
"\tb.last_transact_at AS lastTransactAt,\n" +
|
||||
"\tIFNULL( b.waitAmount, 0 ) AS waitAmount,\n" +
|
||||
"\tIFNULL( b.waitCount, 0 ) AS waitCount,\n" +
|
||||
"\ta.id AS purveyorId \n" +
|
||||
"FROM\n" +
|
||||
"\ttb_shop_purveyor a\n" +
|
||||
"\tLEFT JOIN (\n" +
|
||||
"\tSELECT\n" +
|
||||
"\t\tsum( a.wait_amount ) AS waitAmount,\n" +
|
||||
"\t\tcount( a.id ) AS waitCount,\n" +
|
||||
"\t\ta.purveyor_id AS id,\n" +
|
||||
"\t\tb.purveyor_name,\n" +
|
||||
"\t\tb.last_transact_at \n" +
|
||||
"\tFROM\n" +
|
||||
"\t\ttb_shop_purveyor_transact a\n" +
|
||||
"\t\tLEFT JOIN tb_shop_purveyor b ON a.purveyor_id = b.id \n" +
|
||||
"\tWHERE " +
|
||||
"a.`status` = 0 ";
|
||||
private final String RIGHTQUERYSQL = " GROUP BY\n" +
|
||||
"\t\tb.id \n" +
|
||||
"\t) b ON a.id = b.id\n" +
|
||||
"WHERE 1=1";
|
||||
@PersistenceContext
|
||||
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);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// map.put("content",purveyorVoList);
|
||||
map.put("totalElements",pageShopPurveyor.getTotalElements());
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryTransactDate(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable){
|
||||
// 构建动态SQL语句
|
||||
StringBuilder sqlQuery = new StringBuilder(LEFTQUERYSQL);
|
||||
sqlQuery.append(" and b.shop_id=").append(criteria.getShopId()).append(" AND a.type=").append("'purveyor'").append(RIGHTQUERYSQL);
|
||||
//没有条件时
|
||||
if (criteria.getStatus() == null && "".equals(criteria.getPurveyorName())){
|
||||
sqlQuery.append(" AND a.shop_id = ").append(criteria.getShopId());
|
||||
}
|
||||
//付款状态
|
||||
if (criteria.getStatus() != null) {
|
||||
sqlQuery.append(" AND a.id IN (SELECT purveyor_id FROM tb_shop_purveyor_transact WHERE shop_id AND `status` = ").append(criteria.getStatus())
|
||||
.append(" GROUP BY purveyor_id)");
|
||||
}
|
||||
//供应商名字
|
||||
if (criteria.getPurveyorName() != null && !"".equals(criteria.getPurveyorName())) {
|
||||
sqlQuery.append(" AND a.purveyor_name LIKE '").append(criteria.getPurveyorName()).append("%'");
|
||||
}
|
||||
|
||||
//获取页码号
|
||||
int pageNum = pageable.getPageNumber();
|
||||
//获取每页大小
|
||||
int pageSize = pageable.getPageSize();
|
||||
int beginNo;
|
||||
if(pageNum <=0){
|
||||
beginNo = 0;
|
||||
}else{
|
||||
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();
|
||||
List<PurveyorTransactVO> userVOs = new ArrayList<>();
|
||||
for (Object[] result : resultList) {
|
||||
PurveyorTransactVO purveyorTransactVO = new PurveyorTransactVO();
|
||||
purveyorTransactVO.setLastTransactAt((BigInteger) result[1]);
|
||||
purveyorTransactVO.setPurveyorId((Integer) result[4]);
|
||||
purveyorTransactVO.setPurveyorName((String) result[0]);
|
||||
purveyorTransactVO.setWaitAmount((BigDecimal) result[2]);
|
||||
purveyorTransactVO.setWaitCount((BigInteger) result[3]);
|
||||
purveyorTransactVO.setType(purveyorTransactVO.getWaitCount().intValue()<1?1:0);
|
||||
userVOs.add(purveyorTransactVO);
|
||||
}
|
||||
Integer byCount = tbShopPurveyorRepository.findByCount(criteria.getShopId());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("content",userVOs);
|
||||
map.put("totalElements",byCount);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
return tbShopPurveyorTransactMapper.toDto(tbShopPurveyorTransact);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbShopPurveyorTransactDto create(TbShopPurveyorTransact resources) {
|
||||
return tbShopPurveyorTransactMapper.toDto(tbShopPurveyorTransactRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@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());
|
||||
tbShopPurveyorTransact.copy(resources);
|
||||
tbShopPurveyorTransactRepository.save(tbShopPurveyorTransact);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
tbShopPurveyorTransactRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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.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("应付金额", tbShopPurveyorTransact.getTotalAmount());
|
||||
map.put("待付款金额", tbShopPurveyorTransact.getWaitAmount());
|
||||
map.put("已支付金额", tbShopPurveyorTransact.getPaidAmount());
|
||||
map.put(" paidAt", tbShopPurveyorTransact.getPaidAt());
|
||||
map.put(" type", tbShopPurveyorTransact.getType());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
@@ -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.shopInfo.shopPurveyorTransact.service.mapstruct;
|
||||
|
||||
import me.zhengjie.base.BaseMapper;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.domain.TbShopPurveyorTransact;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyorTransact.service.dto.TbShopPurveyorTransactDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-23
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TbShopPurveyorTransactMapper extends BaseMapper<TbShopPurveyorTransactDto, TbShopPurveyorTransact> {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user