parent
7bf66ab106
commit
7ea3ee3ec0
|
|
@ -1,26 +1,15 @@
|
|||
/*
|
||||
* 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.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactQueryCriteria;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopPurveyorTransactPay;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopPurveyorTransactPayService;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopPurveyorTransact;
|
||||
import cn.ysk.cashier.service.shop.TbShopPurveyorTransactService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -39,6 +28,8 @@ public class TbShopPurveyorTransactController {
|
|||
|
||||
private final TbShopPurveyorTransactService tbShopPurveyorTransactService;
|
||||
|
||||
private final TbShopPurveyorTransactPayService transactPayService;
|
||||
|
||||
/**
|
||||
* 供应商列表
|
||||
* @param criteria
|
||||
|
|
@ -77,6 +68,18 @@ public class TbShopPurveyorTransactController {
|
|||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/transactPayInfos")
|
||||
@ApiOperation("付款记录")
|
||||
public ResponseEntity<Object> transactPayInfos(@RequestParam Integer id,@RequestParam String type){
|
||||
QueryWrapper<TbShopPurveyorTransactPay> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("transact_id", id);
|
||||
if(StringUtils.isNotBlank(type)){
|
||||
queryWrapper.like("pay_type", type);
|
||||
}
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
return new ResponseEntity<>(transactPayService.list(queryWrapper),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("新增帐目往来")
|
||||
public ResponseEntity<Object> createTbShopPurveyorTransact(@Validated @RequestBody TbShopPurveyorTransact resources){
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public class TbCashierCartDto implements Serializable {
|
|||
private Integer userId;
|
||||
|
||||
/** 台桌id */
|
||||
private Integer tableId;
|
||||
private Long tableId;
|
||||
|
||||
/** 打包费 */
|
||||
private BigDecimal packFee;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
|
||||
/**
|
||||
* (TbShopPurveyorTransactPay)表实体类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-07-01 11:23:28
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class TbShopPurveyorTransactPay extends Model<TbShopPurveyorTransactPay> {
|
||||
//自增id
|
||||
private Integer id;
|
||||
//进出帐id
|
||||
private Integer transactId;
|
||||
//付款方式
|
||||
private String payType;
|
||||
//付款金额
|
||||
private BigDecimal paidAmount;
|
||||
//备注
|
||||
private String remark;
|
||||
//创建时间
|
||||
private Date createTime;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getTransactId() {
|
||||
return transactId;
|
||||
}
|
||||
|
||||
public void setTransactId(Integer transactId) {
|
||||
this.transactId = transactId;
|
||||
}
|
||||
|
||||
public String getPayType() {
|
||||
return payType;
|
||||
}
|
||||
|
||||
public void setPayType(String payType) {
|
||||
this.payType = payType;
|
||||
}
|
||||
|
||||
public BigDecimal getPaidAmount() {
|
||||
return paidAmount;
|
||||
}
|
||||
|
||||
public void setPaidAmount(BigDecimal paidAmount) {
|
||||
this.paidAmount = paidAmount;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public TbShopPurveyorTransactPay() {
|
||||
}
|
||||
|
||||
public TbShopPurveyorTransactPay(Integer transactId, String payType, BigDecimal paidAmount, String remark, Date createTime) {
|
||||
this.transactId = transactId;
|
||||
this.payType = payType;
|
||||
this.paidAmount = paidAmount;
|
||||
this.remark = remark;
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopPurveyorTransactPay;
|
||||
|
||||
/**
|
||||
* (TbShopPurveyorTransactPay)表数据库访问层
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-07-01 11:23:28
|
||||
*/
|
||||
public interface TbShopPurveyorTransactPayMapper extends BaseMapper<TbShopPurveyorTransactPay> {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopPurveyorTransactPay;
|
||||
|
||||
/**
|
||||
* (TbShopPurveyorTransactPay)表服务接口
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-07-01 11:23:28
|
||||
*/
|
||||
public interface TbShopPurveyorTransactPayService extends IService<TbShopPurveyorTransactPay> {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbShopPurveyorTransactPayMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopPurveyorTransactPay;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopPurveyorTransactPayService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* (TbShopPurveyorTransactPay)表服务实现类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-07-01 11:23:28
|
||||
*/
|
||||
@Service("tbShopPurveyorTransactPayService")
|
||||
public class TbShopPurveyorTransactPayServiceImpl extends ServiceImpl<TbShopPurveyorTransactPayMapper, TbShopPurveyorTransactPay> implements TbShopPurveyorTransactPayService {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ public class TbCashierCart implements Serializable {
|
|||
|
||||
@Column(name = "`table_id`")
|
||||
@ApiModelProperty(value = "台桌id")
|
||||
private Integer tableId;
|
||||
private Long tableId;
|
||||
|
||||
@Column(name = "`pack_fee`")
|
||||
@ApiModelProperty(value = "打包费")
|
||||
|
|
|
|||
|
|
@ -96,10 +96,20 @@ public class TestTask {
|
|||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void countStock(){
|
||||
log.info("记录当日库存损耗开始");
|
||||
List<StockCountDTO> stockCountDTOS = stockCountRepository.countStock(DateUtil.getStrTime(DateUtil.getBeginDayOfYesterday()), DateUtil.getStrTime(DateUtil.getEndDayOfYesterday()));
|
||||
System.out.println(stockCountDTOS);
|
||||
public void countStock(String str) {
|
||||
String startTime = "";
|
||||
String endTime = "";
|
||||
if (!"today".equals(str)) {
|
||||
startTime = str + " 00:00:00";
|
||||
endTime = str + " 23:59:59";
|
||||
} else {
|
||||
startTime = DateUtil.getStrTime(DateUtil.getBeginDayOfYesterday());
|
||||
endTime = DateUtil.getStrTime(DateUtil.getEndDayOfYesterday());
|
||||
str = DateUtil.getYMDTime(DateUtil.getBeginDayOfYesterday());
|
||||
}
|
||||
log.info("记录" + str + " 库存损耗开始");
|
||||
List<StockCountDTO> stockCountDTOS = stockCountRepository.countStock(startTime, endTime);
|
||||
String finalStr = str;
|
||||
stockCountDTOS.forEach(s->{
|
||||
TbProductStockDetail productStockDetail = new TbProductStockDetail();
|
||||
productStockDetail.setCreatedAt(System.currentTimeMillis());
|
||||
|
|
@ -115,9 +125,9 @@ public class TestTask {
|
|||
productStockDetail.setStockNumber(-Double.valueOf(s.getStockCount()));
|
||||
productStockDetail.setSourcePath("NORMAL");
|
||||
productStockDetail.setType("other-out");
|
||||
productStockDetail.setRemark(DateUtil.getYMDTime(DateUtil.getBeginDayOfYesterday())+"日统计库存");
|
||||
productStockDetail.setType(finalStr +"日售出记录");
|
||||
productStockDetail.setRemark(finalStr +"日统计库存");
|
||||
productStockDetail.setSubType(-1);
|
||||
productStockDetail.setType(DateUtil.getYMDTime(DateUtil.getBeginDayOfYesterday())+"日售出记录");
|
||||
entityManager.persist(productStockDetail);
|
||||
});
|
||||
log.info("记录当日库存损耗结束");
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ import java.util.List;
|
|||
**/
|
||||
public interface StockCountRepository extends JpaRepository<StockCountDTO, Integer> {
|
||||
|
||||
@Query(value = "SELECT pro.shop_id as shop_id, pro.id as pro_id, info.product_name as pro_name,pro.stock_number, pro.is_stock," +
|
||||
@Query(value = "SELECT pro.shop_id as shop_id, pro.id as pro_id, info.product_name as pro_name, pro.is_stock," +
|
||||
" info.product_sku_name as sku_name, unit.NAME as unit_name ," +
|
||||
"SUM( CASE WHEN orders.order_type != 'return' THEN info.num ELSE 0 END )- SUM( CASE WHEN orders.order_type = 'return' THEN info.num ELSE 0 END ) as stock_count," +
|
||||
"CASE WHEN pro.is_distribute = '1' THEN sum(sku.stock_number) ELSE pro.stock_number END as stock_number " +
|
||||
"CASE WHEN pro.is_distribute = '1' THEN sku.stock_number ELSE pro.stock_number END AS stock_number " +
|
||||
"FROM " +
|
||||
"tb_order_info orders " +
|
||||
"LEFT JOIN tb_order_detail info ON orders.id = info.order_id " +
|
||||
"LEFT JOIN tb_product pro ON info.product_id = pro.id " +
|
||||
"LEFT JOIN tb_product_sku sku ON info.product_id = sku.product_id " +
|
||||
"LEFT JOIN (SELECT product_id,sum(stock_number) as stock_number from tb_product_sku GROUP BY product_id) sku ON info.product_id = sku.product_id " +
|
||||
"LEFT JOIN tb_shop_unit unit ON unit.id = pro.unit_id " +
|
||||
"WHERE " +
|
||||
"info.create_time > :startTime " +
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ package cn.ysk.cashier.service.impl.shopimpl;
|
|||
|
||||
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopPurveyorTransactQueryCriteria;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mapper.shop.TbShopPurveyorTransactMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopPurveyorTransactPay;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopPurveyorTransactPayService;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopPurveyorTransact;
|
||||
import cn.ysk.cashier.repository.shop.TbShopPurveyorRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopPurveyorTransactRepository;
|
||||
|
|
@ -21,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
|
@ -36,6 +40,7 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
|
|||
private final TbShopPurveyorTransactRepository tbShopPurveyorTransactRepository;
|
||||
private final TbShopPurveyorTransactMapper tbShopPurveyorTransactMapper;
|
||||
private final TbShopPurveyorRepository tbShopPurveyorRepository;
|
||||
private final TbShopPurveyorTransactPayService transactPayService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryPurveyorTransact(TbShopPurveyorTransactQueryCriteria criteria) {
|
||||
|
|
@ -103,7 +108,17 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
|
|||
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()));
|
||||
if (resources.getPaidAmount().compareTo(BigDecimal.ZERO) == 0) {
|
||||
throw new BadRequestException("付款金额不能为 0");
|
||||
} else {
|
||||
if (tbShopPurveyorTransact.getWaitAmount().compareTo(BigDecimal.ZERO) > 0 && resources.getPaidAmount().compareTo(BigDecimal.ZERO) > 0) {//待付款金额大于0
|
||||
tbShopPurveyorTransact.setWaitAmount(tbShopPurveyorTransact.getWaitAmount().subtract(resources.getPaidAmount()));
|
||||
} else if (tbShopPurveyorTransact.getWaitAmount().compareTo(BigDecimal.ZERO) < 0 && resources.getPaidAmount().compareTo(BigDecimal.ZERO) < 0) {
|
||||
tbShopPurveyorTransact.setWaitAmount(tbShopPurveyorTransact.getWaitAmount().subtract(resources.getPaidAmount()));
|
||||
} else {
|
||||
tbShopPurveyorTransact.setWaitAmount(tbShopPurveyorTransact.getWaitAmount().add(resources.getPaidAmount()));
|
||||
}
|
||||
}
|
||||
tbShopPurveyorTransact.setPaidAt(System.currentTimeMillis());
|
||||
if (tbShopPurveyorTransact.getWaitAmount().compareTo(tbShopPurveyorTransact.getPaidAmount()) <= 0) {
|
||||
tbShopPurveyorTransact.setStatus(1);
|
||||
|
|
@ -112,6 +127,7 @@ public class TbShopPurveyorTransactServiceImpl implements TbShopPurveyorTransact
|
|||
}
|
||||
tbShopPurveyorTransact.setPayType(resources.getPayType());
|
||||
tbShopPurveyorTransactRepository.save(tbShopPurveyorTransact);
|
||||
transactPayService.save(new TbShopPurveyorTransactPay(resources.getId(),resources.getPayType(),resources.getPaidAmount(),resources.getRemark(),new Date()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue