供应商
This commit is contained in:
parent
29299d3689
commit
6f9afcb246
|
|
@ -44,23 +44,15 @@ public class TbShopPurveyorTransactController {
|
||||||
|
|
||||||
private final TbShopPurveyorTransactService tbShopPurveyorTransactService;
|
private final TbShopPurveyorTransactService tbShopPurveyorTransactService;
|
||||||
|
|
||||||
@ApiOperation("导出数据")
|
|
||||||
@GetMapping(value = "/download")
|
|
||||||
@PreAuthorize("@el.check('tbShopPurveyorTransact:list')")
|
|
||||||
public void exportTbShopPurveyorTransact(HttpServletResponse response, TbShopPurveyorTransactQueryCriteria criteria) throws IOException {
|
|
||||||
tbShopPurveyorTransactService.download(tbShopPurveyorTransactService.queryAll(criteria), response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进货账目
|
* 供应商列表
|
||||||
* @param criteria
|
* @param criteria
|
||||||
* @param pageable
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("查询帐目往来")
|
@ApiOperation("供应商列表")
|
||||||
public ResponseEntity<Object> queryTbShopPurveyorTransactSum(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> queryTransactDate(TbShopPurveyorTransactQueryCriteria criteria){
|
||||||
return new ResponseEntity<>(tbShopPurveyorTransactService.queryTransactDate(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity<>(tbShopPurveyorTransactService.queryTransactDate(criteria),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -79,10 +71,17 @@ public class TbShopPurveyorTransactController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/sum")
|
@GetMapping("/sum")
|
||||||
public ResponseEntity<Object> queryTransactSum( TbShopPurveyorTransactQueryCriteria criteria){
|
public ResponseEntity<Object> queryTransactSum(TbShopPurveyorTransactQueryCriteria criteria){
|
||||||
return new ResponseEntity<>(tbShopPurveyorTransactService.queryTransactSum(criteria),HttpStatus.OK);
|
return new ResponseEntity<>(tbShopPurveyorTransactService.queryTransactSum(criteria),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/payTransact")
|
||||||
|
@ApiOperation("账单付款")
|
||||||
|
public ResponseEntity<Object> payTransact(@RequestBody TbShopPurveyorTransact resources){
|
||||||
|
tbShopPurveyorTransactService.payTransact(resources);
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增帐目往来")
|
@ApiOperation("新增帐目往来")
|
||||||
public ResponseEntity<Object> createTbShopPurveyorTransact(@Validated @RequestBody TbShopPurveyorTransact resources){
|
public ResponseEntity<Object> createTbShopPurveyorTransact(@Validated @RequestBody TbShopPurveyorTransact resources){
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,35 @@
|
||||||
/*
|
|
||||||
* 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.dto.shop;
|
package cn.ysk.cashier.dto.shop;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cn.ysk.cashier.annotation.Query;
|
import cn.ysk.cashier.annotation.Query;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @author lyf
|
||||||
* @author lyf
|
* @website https://eladmin.vip
|
||||||
* @date 2024-01-23
|
* @date 2024-01-23
|
||||||
**/
|
**/
|
||||||
@Data
|
@Data
|
||||||
public class TbShopPurveyorTransactQueryCriteria{
|
public class TbShopPurveyorTransactQueryCriteria {
|
||||||
|
|
||||||
/** 精确 */
|
/**
|
||||||
|
* 精确
|
||||||
|
*/
|
||||||
@Query
|
@Query
|
||||||
private String shopId;
|
private String shopId;
|
||||||
|
|
||||||
/** 精确 */
|
/**
|
||||||
|
* 精确
|
||||||
|
*/
|
||||||
@Query(type = Query.Type.LEFT_LIKE)
|
@Query(type = Query.Type.LEFT_LIKE)
|
||||||
private String purveyorName;
|
private String purveyorName;
|
||||||
|
|
||||||
/** 精确 */
|
/**
|
||||||
|
* 精确
|
||||||
|
*/
|
||||||
@Query
|
@Query
|
||||||
private String purveyorId;
|
private String purveyorId;
|
||||||
/**
|
/**
|
||||||
|
|
@ -54,11 +48,21 @@ public class TbShopPurveyorTransactQueryCriteria{
|
||||||
|
|
||||||
private Integer size;
|
private Integer size;
|
||||||
|
|
||||||
private String sort;
|
public void setShopId(String shopId) {
|
||||||
|
if (StringUtils.isNotBlank(shopId) && !shopId.equals("1")) {
|
||||||
|
this.shopId = shopId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setStatus(Integer status) {
|
public void setStatus(Integer status) {
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
if (StringUtils.isNotBlank(type)) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,10 @@
|
||||||
/*
|
|
||||||
* 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.repository.shop;
|
package cn.ysk.cashier.repository.shop;
|
||||||
|
|
||||||
import cn.ysk.cashier.pojo.shop.TbShopPurveyorTransact;
|
import cn.ysk.cashier.pojo.shop.TbShopPurveyorTransact;
|
||||||
|
import cn.ysk.cashier.vo.PurveyorTransactVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
@ -30,14 +18,7 @@ import java.util.Map;
|
||||||
**/
|
**/
|
||||||
public interface TbShopPurveyorTransactRepository extends JpaRepository<TbShopPurveyorTransact, Integer>, JpaSpecificationExecutor<TbShopPurveyorTransact> {
|
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 " +
|
@Query(value = "SELECT " +
|
||||||
// "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(sum( b.wait_amount ), 0 ) AS waitAmount," +
|
||||||
"IFNULL(count( b.id ), 0 ) AS waitCount," +
|
"IFNULL(count( b.id ), 0 ) AS waitCount," +
|
||||||
"IFNULL(SUM(b.paid_amount),0) AS paidAmount," +
|
"IFNULL(SUM(b.paid_amount),0) AS paidAmount," +
|
||||||
|
|
@ -46,10 +27,31 @@ public interface TbShopPurveyorTransactRepository extends JpaRepository<TbShopPu
|
||||||
" tb_shop_purveyor_transact b" +
|
" tb_shop_purveyor_transact b" +
|
||||||
" WHERE" +
|
" WHERE" +
|
||||||
" b.purveyor_id = :purveyorId" +
|
" b.purveyor_id = :purveyorId" +
|
||||||
" AND b.type = :type",nativeQuery = true)
|
" AND (:type IS NULL OR b.type = :type)",nativeQuery = true)
|
||||||
Map<String,Object> findBySum(@Param("purveyorId") String purveyorId,@Param("type")String type);
|
Map<String,Object> findBySum(@Param("purveyorId") String purveyorId,@Param("type")String type);
|
||||||
//
|
|
||||||
|
@Query("SELECT new cn.ysk.cashier.vo.PurveyorTransactVO(" +
|
||||||
|
"b.id," +
|
||||||
|
"b.purveyorName," +
|
||||||
|
"b.purveyorTelephone," +
|
||||||
|
"b.address," +
|
||||||
|
"b.remark," +
|
||||||
|
"b.lastTransactAt," +
|
||||||
|
"sum(a.waitAmount) ," +
|
||||||
|
"count(a.id)) " +
|
||||||
|
"from " +
|
||||||
|
"TbShopPurveyor b " +
|
||||||
|
"LEFT JOIN TbShopPurveyorTransact a ON a.purveyorId = b.id " +
|
||||||
|
"WHERE " +
|
||||||
|
"1=1 " +
|
||||||
|
"AND (:type IS NULL OR a.type = :type )" +
|
||||||
|
"AND (:shopId IS NULL OR b.shopId = :shopId) " +
|
||||||
|
"AND (:name IS NULL OR b.purveyorName LIKE %:name%) " +
|
||||||
|
"GROUP BY b.id " +
|
||||||
|
"order by b.lastTransactAt desc,a.purveyorId")
|
||||||
|
Page<PurveyorTransactVO> queryTransactDate(String type, String shopId, String name, Pageable page);
|
||||||
|
|
||||||
@Query(value = "SELECT IFNULL(count(b.id),0) AS waitNumber FROM tb_shop_purveyor_transact b WHERE" +
|
@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)
|
" b.purveyor_id = :purveyorId AND (:type IS NULL OR 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);
|
Map<String,Object> findByStatusSum(@Param("purveyorId") String purveyorId,@Param("type")String type,@Param("status")Integer status);
|
||||||
}
|
}
|
||||||
|
|
@ -188,7 +188,7 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe
|
||||||
purveyorTransact.setTotalAmount(resources.getTotalAmount());
|
purveyorTransact.setTotalAmount(resources.getTotalAmount());
|
||||||
purveyorTransact.setPaidAmount(resources.getPaidAmount());
|
purveyorTransact.setPaidAmount(resources.getPaidAmount());
|
||||||
purveyorTransact.setWaitAmount(resources.getTotalAmount().subtract(resources.getPaidAmount()));
|
purveyorTransact.setWaitAmount(resources.getTotalAmount().subtract(resources.getPaidAmount()));
|
||||||
if (resources.getTotalAmount().compareTo(resources.getPaidAmount()) < 0) {
|
if (resources.getTotalAmount().compareTo(resources.getPaidAmount()) <= 0) {
|
||||||
purveyorTransact.setStatus(1);
|
purveyorTransact.setStatus(1);
|
||||||
} else {
|
} else {
|
||||||
purveyorTransact.setStatus(0);
|
purveyorTransact.setStatus(0);
|
||||||
|
|
|
||||||
|
|
@ -1,47 +1,27 @@
|
||||||
/*
|
|
||||||
* 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.service.impl.shopimpl;
|
package cn.ysk.cashier.service.impl.shopimpl;
|
||||||
|
|
||||||
import cn.ysk.cashier.repository.shop.TbShopPurveyorRepository;
|
|
||||||
import cn.ysk.cashier.pojo.shop.TbShopPurveyorTransact;
|
|
||||||
import cn.ysk.cashier.vo.PurveyorTransactVO;
|
|
||||||
import cn.ysk.cashier.utils.ValidationUtil;
|
|
||||||
import cn.ysk.cashier.utils.FileUtil;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import cn.ysk.cashier.repository.shop.TbShopPurveyorTransactRepository;
|
|
||||||
import cn.ysk.cashier.service.shop.TbShopPurveyorTransactService;
|
|
||||||
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactDto;
|
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactDto;
|
||||||
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactQueryCriteria;
|
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactQueryCriteria;
|
||||||
import cn.ysk.cashier.mapper.shop.TbShopPurveyorTransactMapper;
|
import cn.ysk.cashier.mapper.shop.TbShopPurveyorTransactMapper;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopPurveyorTransact;
|
||||||
|
import cn.ysk.cashier.repository.shop.TbShopPurveyorRepository;
|
||||||
|
import cn.ysk.cashier.repository.shop.TbShopPurveyorTransactRepository;
|
||||||
|
import cn.ysk.cashier.service.shop.TbShopPurveyorTransactService;
|
||||||
|
import cn.ysk.cashier.utils.FileUtil;
|
||||||
|
import cn.ysk.cashier.utils.QueryHelp;
|
||||||
|
import cn.ysk.cashier.utils.ValidationUtil;
|
||||||
|
import cn.ysk.cashier.vo.PurveyorTransactVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import cn.ysk.cashier.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 javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @website https://eladmin.vip
|
||||||
|
|
@ -57,33 +37,6 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
|
||||||
private final TbShopPurveyorTransactMapper tbShopPurveyorTransactMapper;
|
private final TbShopPurveyorTransactMapper tbShopPurveyorTransactMapper;
|
||||||
private final TbShopPurveyorRepository tbShopPurveyorRepository;
|
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
|
@Override
|
||||||
public Map<String, Object> queryPurveyorTransact(TbShopPurveyorTransactQueryCriteria criteria) {
|
public Map<String, Object> queryPurveyorTransact(TbShopPurveyorTransactQueryCriteria criteria) {
|
||||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||||
|
|
@ -97,55 +50,14 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryTransactDate(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable){
|
public Page<PurveyorTransactVO> queryTransactDate(TbShopPurveyorTransactQueryCriteria criteria){
|
||||||
// 构建动态SQL语句
|
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize());
|
||||||
StringBuilder sqlQuery = new StringBuilder(LEFTQUERYSQL);
|
Page<PurveyorTransactVO> purveyorTransactVOS = tbShopPurveyorTransactRepository.queryTransactDate(criteria.getType(), criteria.getShopId(), criteria.getPurveyorName(), pageable);
|
||||||
sqlQuery.append(" and b.shop_id=").append(criteria.getShopId()).append(" AND a.type=").append("'purveyor'").append(RIGHTQUERYSQL);
|
for (PurveyorTransactVO purveyorTransactVO : purveyorTransactVOS.getContent()) {
|
||||||
//没有条件时
|
|
||||||
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);
|
|
||||||
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);
|
purveyorTransactVO.setType(purveyorTransactVO.getWaitCount().intValue()<1?1:0);
|
||||||
userVOs.add(purveyorTransactVO);
|
|
||||||
}
|
}
|
||||||
Integer byCount = tbShopPurveyorRepository.findByCount(criteria.getShopId());
|
return purveyorTransactVOS;
|
||||||
Map<String, Object> map = new HashMap<>();
|
|
||||||
map.put("content",userVOs);
|
|
||||||
map.put("totalElements",byCount);
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -185,6 +97,21 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
|
||||||
tbShopPurveyorTransactRepository.save(tbShopPurveyorTransact);
|
tbShopPurveyorTransactRepository.save(tbShopPurveyorTransact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void payTransact(TbShopPurveyorTransact resources) {
|
||||||
|
TbShopPurveyorTransact tbShopPurveyorTransact = tbShopPurveyorTransactRepository.findById(resources.getId()).orElseGet(TbShopPurveyorTransact::new);
|
||||||
|
ValidationUtil.isNull( tbShopPurveyorTransact.getId(),"TbShopPurveyorTransact","id",resources.getId());
|
||||||
|
tbShopPurveyorTransact.setPaidAmount(tbShopPurveyorTransact.getPaidAmount().add(resources.getPaidAmount()));
|
||||||
|
tbShopPurveyorTransact.setWaitAmount(tbShopPurveyorTransact.getWaitAmount().subtract(resources.getPaidAmount()));
|
||||||
|
tbShopPurveyorTransact.setPaidAt(System.currentTimeMillis());
|
||||||
|
if(tbShopPurveyorTransact.getWaitAmount().subtract(resources.getPaidAmount()).equals(0)){
|
||||||
|
tbShopPurveyorTransact.setStatus(1);
|
||||||
|
}
|
||||||
|
tbShopPurveyorTransactRepository.save(tbShopPurveyorTransact);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteAll(Integer[] ids) {
|
public void deleteAll(Integer[] ids) {
|
||||||
for (Integer id : ids) {
|
for (Integer id : ids) {
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,10 @@
|
||||||
/*
|
|
||||||
* 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.service.shop;
|
package cn.ysk.cashier.service.shop;
|
||||||
|
|
||||||
import cn.ysk.cashier.pojo.shop.TbShopPurveyorTransact;
|
import cn.ysk.cashier.pojo.shop.TbShopPurveyorTransact;
|
||||||
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactDto;
|
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactDto;
|
||||||
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactQueryCriteria;
|
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactQueryCriteria;
|
||||||
import org.springframework.data.domain.Pageable;
|
import cn.ysk.cashier.vo.PurveyorTransactVO;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -38,7 +24,7 @@ public interface TbShopPurveyorTransactService {
|
||||||
* @return Map<String,Object>
|
* @return Map<String,Object>
|
||||||
*/
|
*/
|
||||||
Map<String,Object> queryPurveyorTransact(TbShopPurveyorTransactQueryCriteria criteria);
|
Map<String,Object> queryPurveyorTransact(TbShopPurveyorTransactQueryCriteria criteria);
|
||||||
Map<String, Object> queryTransactDate(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable);
|
Page<PurveyorTransactVO> queryTransactDate(TbShopPurveyorTransactQueryCriteria criteria);
|
||||||
|
|
||||||
Map<String, Object> queryTransactSum(TbShopPurveyorTransactQueryCriteria criteria);
|
Map<String, Object> queryTransactSum(TbShopPurveyorTransactQueryCriteria criteria);
|
||||||
|
|
||||||
|
|
@ -69,6 +55,8 @@ public interface TbShopPurveyorTransactService {
|
||||||
*/
|
*/
|
||||||
void update(TbShopPurveyorTransact resources);
|
void update(TbShopPurveyorTransact resources);
|
||||||
|
|
||||||
|
void payTransact(TbShopPurveyorTransact resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多选删除
|
* 多选删除
|
||||||
* @param ids /
|
* @param ids /
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue