master:销售返单记录功能;

pull/1121/head
liujiang 2025-04-03 00:35:26 +08:00
parent f9783719d7
commit 2081504fa7
12 changed files with 152 additions and 200 deletions

View File

@ -44,23 +44,17 @@ public class StoreProductStorageController extends XktBaseController {
final IStoreProductStorageService storeProdStorageService;
// TODO 新增入款单库存会变化
// TODO 新增入款单库存会变化
// TODO 新增入款单库存会变化
// TODO 撤销入款单库存会变化
// TODO 撤销入款单库存会变化
// TODO 撤销入款单库存会变化
// TODO 需求抵扣明细没做
// TODO 需求抵扣明细没做
// TODO 需求抵扣明细没做
// TODO 需求抵扣明细没做
// TODO 需求抵扣明细没做
// TODO 需求抵扣明细没做
// TODO 需求抵扣明细没做
// TODO 需求抵扣明细没做
// TODO 需求抵扣明细没做
// TODO 需求抵扣明细没做
// TODO 需求抵扣明细没做
/**
*

View File

@ -80,21 +80,6 @@ public class StoreSaleController extends XktBaseController {
@ApiOperation(value = "返单后,更新档口销售出库", httpMethod = "PUT", response = R.class)
@PutMapping
public R edit(@Validated @RequestBody StoreSaleVO storeSaleVO) {
// TODO 扣件库存
// TODO 扣件库存
// TODO 扣件库存
// TODO 扣件库存
// TODO 扣件库存
// TODO 扣件库存
// TODO 增加库存
// TODO 增加库存
// TODO 增加库存
// TODO 增加库存
// TODO 增加库存
// TODO 增加库存
return R.ok(storeSaleService.updateStoreSale(BeanUtil.toBean(storeSaleVO, StoreSaleDTO.class)));
}

View File

@ -1,18 +1,29 @@
package com.ruoyi.web.controller.xkt;
import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.XktBaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.Page;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.xkt.vo.storeProdStock.StoreProdStockPageVO;
import com.ruoyi.web.controller.xkt.vo.storeSaleRefundRecord.StoreSaleRefundRecordVO;
import com.ruoyi.xkt.domain.StoreSaleRefundRecord;
import com.ruoyi.xkt.dto.storeProductStock.StoreProdStockPageDTO;
import com.ruoyi.xkt.dto.storeSaleRefundRecord.StoreSaleRefundRecordDTO;
import com.ruoyi.xkt.service.IStoreSaleRefundRecordService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
@ -22,70 +33,21 @@ import java.util.List;
* @date 2025-03-26
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/rest/v1/sale-refund-records")
public class StoreSaleRefundRecordController extends XktBaseController {
@Autowired
private IStoreSaleRefundRecordService storeSaleRefundRecordService;
final IStoreSaleRefundRecordService storeSaleRefundRecordService;
/**
*
*
*/
@PreAuthorize("@ss.hasPermi('system:record:list')")
@GetMapping("/list")
public TableDataInfo list(StoreSaleRefundRecord storeSaleRefundRecord) {
startPage();
List<StoreSaleRefundRecord> list = storeSaleRefundRecordService.selectStoreSaleRefundRecordList(storeSaleRefundRecord);
return getDataTable(list);
@PreAuthorize("@ss.hasPermi('system:refund:list')")
@ApiOperation(value = "查询档口销售出库返单记录", httpMethod = "POST", response = R.class)
@GetMapping("/list/{storeId}/{storeSaleId}")
public R<List<StoreSaleRefundRecordVO>> selectPage(@PathVariable("storeId") Long storeId, @PathVariable("storeSaleId") Long storeSaleId) {
List<StoreSaleRefundRecordDTO> refundDTOList = this.storeSaleRefundRecordService.selectList(storeId, storeSaleId);
return R.ok(BeanUtil.copyToList(refundDTOList, StoreSaleRefundRecordVO.class));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:record:export')")
@Log(title = "档口销售返单", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, StoreSaleRefundRecord storeSaleRefundRecord) {
List<StoreSaleRefundRecord> list = storeSaleRefundRecordService.selectStoreSaleRefundRecordList(storeSaleRefundRecord);
ExcelUtil<StoreSaleRefundRecord> util = new ExcelUtil<StoreSaleRefundRecord>(StoreSaleRefundRecord.class);
util.exportExcel(response, list, "档口销售返单数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:record:query')")
@GetMapping(value = "/{storeSaleRefundRecordId}")
public R getInfo(@PathVariable("storeSaleRefundRecordId") Long storeSaleRefundRecordId) {
return success(storeSaleRefundRecordService.selectStoreSaleRefundRecordByStoreSaleRefundRecordId(storeSaleRefundRecordId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:record:add')")
@Log(title = "档口销售返单", businessType = BusinessType.INSERT)
@PostMapping
public R add(@RequestBody StoreSaleRefundRecord storeSaleRefundRecord) {
return success(storeSaleRefundRecordService.insertStoreSaleRefundRecord(storeSaleRefundRecord));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:record:edit')")
@Log(title = "档口销售返单", businessType = BusinessType.UPDATE)
@PutMapping
public R edit(@RequestBody StoreSaleRefundRecord storeSaleRefundRecord) {
return success(storeSaleRefundRecordService.updateStoreSaleRefundRecord(storeSaleRefundRecord));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:record:remove')")
@Log(title = "档口销售返单", businessType = BusinessType.DELETE)
@DeleteMapping("/{storeSaleRefundRecordIds}")
public R remove(@PathVariable Long[] storeSaleRefundRecordIds) {
return success(storeSaleRefundRecordService.deleteStoreSaleRefundRecordByStoreSaleRefundRecordIds(storeSaleRefundRecordIds));
}
}

View File

@ -0,0 +1,39 @@
package com.ruoyi.web.controller.xkt.vo.storeSaleRefundRecord;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel("档口商品销售返单数据")
@Data
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StoreSaleRefundRecordVO {
@ApiModelProperty("返单ID")
private Long storeSaleRefundRecordId;
@ApiModelProperty(name = "单据编号")
private String code;
@ApiModelProperty(name = "档口销售客户名称")
private String storeCusName;
@JsonFormat(pattern = "HH:mm", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty(name = "支付方式支付宝、微信、现金、欠款ALIPAY WECHAT_PAY CASH DEBT")
private String payWay;
@ApiModelProperty(name = "数量")
private Integer quantity;
@ApiModelProperty(name = "总金额")
private BigDecimal amount;
}

View File

@ -24,6 +24,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
public static String YYYY_MM_DD = "yyyy-MM-dd";
public static String YYYYMMDD = "yyyyMMdd";
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";

View File

@ -0,0 +1,39 @@
package com.ruoyi.xkt.dto.storeSaleRefundRecord;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel("档口商品销售返单数据")
@Data
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StoreSaleRefundRecordDTO {
@ApiModelProperty("返单ID")
private Long storeSaleRefundRecordId;
@ApiModelProperty(name = "单据编号")
private String code;
@ApiModelProperty(name = "档口销售客户名称")
private String storeCusName;
@JsonFormat(pattern = "HH:mm", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty(name = "支付方式支付宝、微信、现金、欠款ALIPAY WECHAT_PAY CASH DEBT")
private String payWay;
@ApiModelProperty(name = "数量")
private Integer quantity;
@ApiModelProperty(name = "总金额")
private BigDecimal amount;
}

View File

@ -1,6 +1,6 @@
package com.ruoyi.xkt.service;
import com.ruoyi.xkt.domain.StoreSaleRefundRecord;
import com.ruoyi.xkt.dto.storeSaleRefundRecord.StoreSaleRefundRecordDTO;
import java.util.List;
@ -11,51 +11,13 @@ import java.util.List;
* @date 2025-03-26
*/
public interface IStoreSaleRefundRecordService {
/**
*
*
* @param storeSaleRefundRecordId
* @return
*/
public StoreSaleRefundRecord selectStoreSaleRefundRecordByStoreSaleRefundRecordId(Long storeSaleRefundRecordId);
/**
*
*
* @param storeSaleRefundRecord
* @param storeId ID
* @param storeSaleId ID
* @return
*/
public List<StoreSaleRefundRecord> selectStoreSaleRefundRecordList(StoreSaleRefundRecord storeSaleRefundRecord);
/**
*
*
* @param storeSaleRefundRecord
* @return
*/
public int insertStoreSaleRefundRecord(StoreSaleRefundRecord storeSaleRefundRecord);
/**
*
*
* @param storeSaleRefundRecord
* @return
*/
public int updateStoreSaleRefundRecord(StoreSaleRefundRecord storeSaleRefundRecord);
/**
*
*
* @param storeSaleRefundRecordIds
* @return
*/
public int deleteStoreSaleRefundRecordByStoreSaleRefundRecordIds(Long[] storeSaleRefundRecordIds);
/**
*
*
* @param storeSaleRefundRecordId
* @return
*/
public int deleteStoreSaleRefundRecordByStoreSaleRefundRecordId(Long storeSaleRefundRecordId);
public List<StoreSaleRefundRecordDTO> selectList(Long storeId, Long storeSaleId);
}

View File

@ -134,7 +134,7 @@ public class StoreProductStockServiceImpl implements IStoreProductStockService {
/**
*
*
* @param storeId
* @param storeId ID
* @param storeProdStockId
* @return int
*/

View File

@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@ -72,7 +73,7 @@ public class StoreProductStorageServiceImpl implements IStoreProductStorageServi
@Transactional
public int create(StoreProdStorageDTO storeProdStorageDTO) {
// 生成code
String code = this.sequenceService.generateCode(storeProdStorageDTO.getStoreId(), "STORAGE", DateUtils.getDate());
String code = this.sequenceService.generateCode(storeProdStorageDTO.getStoreId(), "STORAGE", DateUtils.parseDateToStr(DateUtils.YYYYMMDD, new Date()));
// 总的数量
Integer totalNum = storeProdStorageDTO.getDetailList().stream().map(x -> ObjectUtils.defaultIfNull(x.getQuantity(), 0)).reduce(0, Integer::sum);
// 总的金额

View File

@ -1,14 +1,25 @@
package com.ruoyi.xkt.service.impl;
import com.ruoyi.common.utils.DateUtils;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.xkt.domain.StoreSale;
import com.ruoyi.xkt.domain.StoreSaleRefundRecord;
import com.ruoyi.xkt.dto.storeSaleRefundRecord.StoreSaleRefundRecordDTO;
import com.ruoyi.xkt.mapper.StoreSaleMapper;
import com.ruoyi.xkt.mapper.StoreSaleRefundRecordMapper;
import com.ruoyi.xkt.service.IStoreSaleRefundRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* Service
@ -17,79 +28,36 @@ import java.util.List;
* @date 2025-03-26
*/
@Service
@RequiredArgsConstructor
public class StoreSaleRefundRecordServiceImpl implements IStoreSaleRefundRecordService {
@Autowired
private StoreSaleRefundRecordMapper storeSaleRefundRecordMapper;
/**
*
*
* @param storeSaleRefundRecordId
* @return
*/
@Override
public StoreSaleRefundRecord selectStoreSaleRefundRecordByStoreSaleRefundRecordId(Long storeSaleRefundRecordId) {
return storeSaleRefundRecordMapper.selectStoreSaleRefundRecordByStoreSaleRefundRecordId(storeSaleRefundRecordId);
}
final StoreSaleRefundRecordMapper refundRecordMapper;
final StoreSaleMapper storeSaleMapper;
/**
*
*
* @param storeSaleRefundRecord
* @return
* @param storeId ID
* @param storeSaleId ID
* @return
*/
@Override
public List<StoreSaleRefundRecord> selectStoreSaleRefundRecordList(StoreSaleRefundRecord storeSaleRefundRecord) {
return storeSaleRefundRecordMapper.selectStoreSaleRefundRecordList(storeSaleRefundRecord);
@Transactional(readOnly = true)
public List<StoreSaleRefundRecordDTO> selectList(Long storeId, Long storeSaleId) {
List<StoreSaleRefundRecord> refundRecordList = this.refundRecordMapper.selectList(new LambdaQueryWrapper<StoreSaleRefundRecord>()
.eq(StoreSaleRefundRecord::getStoreId, storeId).eq(StoreSaleRefundRecord::getStoreSaleId, storeSaleId).eq(StoreSaleRefundRecord::getDelFlag, "0"));
if (CollectionUtils.isEmpty(refundRecordList)) {
return new ArrayList<>();
}
List<StoreSaleRefundRecordDTO> refundRecordDTOList = refundRecordList.stream().map(x -> BeanUtil.toBean(x, StoreSaleRefundRecordDTO.class)
.setStoreSaleRefundRecordId(x.getId())).collect(Collectors.toList());
// 获取当前最新数据
StoreSale storeSale = Optional.ofNullable(storeSaleMapper.selectById(storeSaleId))
.orElseThrow(() -> new ServiceException("档口销售出库订单不存在!", HttpStatus.ERROR));
refundRecordDTOList.add(BeanUtil.toBean(storeSale, StoreSaleRefundRecordDTO.class).setStoreSaleRefundRecordId(-1L));
// 将最新数据放在第一位
Collections.reverse(refundRecordDTOList);
return refundRecordDTOList;
}
/**
*
*
* @param storeSaleRefundRecord
* @return
*/
@Override
@Transactional
public int insertStoreSaleRefundRecord(StoreSaleRefundRecord storeSaleRefundRecord) {
storeSaleRefundRecord.setCreateTime(DateUtils.getNowDate());
return storeSaleRefundRecordMapper.insertStoreSaleRefundRecord(storeSaleRefundRecord);
}
/**
*
*
* @param storeSaleRefundRecord
* @return
*/
@Override
@Transactional
public int updateStoreSaleRefundRecord(StoreSaleRefundRecord storeSaleRefundRecord) {
storeSaleRefundRecord.setUpdateTime(DateUtils.getNowDate());
return storeSaleRefundRecordMapper.updateStoreSaleRefundRecord(storeSaleRefundRecord);
}
/**
*
*
* @param storeSaleRefundRecordIds
* @return
*/
@Override
@Transactional
public int deleteStoreSaleRefundRecordByStoreSaleRefundRecordIds(Long[] storeSaleRefundRecordIds) {
return storeSaleRefundRecordMapper.deleteStoreSaleRefundRecordByStoreSaleRefundRecordIds(storeSaleRefundRecordIds);
}
/**
*
*
* @param storeSaleRefundRecordId
* @return
*/
@Override
@Transactional
public int deleteStoreSaleRefundRecordByStoreSaleRefundRecordId(Long storeSaleRefundRecordId) {
return storeSaleRefundRecordMapper.deleteStoreSaleRefundRecordByStoreSaleRefundRecordId(storeSaleRefundRecordId);
}
}

View File

@ -138,7 +138,7 @@ public class StoreSaleServiceImpl implements IStoreSaleService {
public int insertStoreSale(StoreSaleDTO storeSaleDTO) {
StoreSale storeSale = BeanUtil.toBean(storeSaleDTO, StoreSale.class);
// 生成code
String code = this.sequenceService.generateCode(storeSaleDTO.getStoreId(), "STORE_SALE", DateUtils.getDate());
String code = this.sequenceService.generateCode(storeSaleDTO.getStoreId(), "STORE_SALE", DateUtils.parseDateToStr(DateUtils.YYYYMMDD, new Date()));
// 总的数量
Integer quantity = storeSaleDTO.getDetailList().stream().map(x -> ObjectUtils.defaultIfNull(x.getQuantity(), 0)).reduce(0, Integer::sum);
// 总的金额

View File

@ -23,7 +23,7 @@ public class VoucherSequenceServiceImpl implements IVoucherSequenceService {
@Transactional(propagation = Propagation.REQUIRES_NEW)
public synchronized String generateCode(Long storeId, String type, String voucherDate) {
VoucherSequence voucherSequence = this.sequenceMapper.queryByStoreIdAndType(storeId, type);
String code = voucherSequence.getPrefix() + "-" + voucherDate + "-"
String code = voucherSequence.getPrefix() + "-" + voucherDate + storeId + "-"
+ String.format(voucherSequence.getSequenceFormat(), voucherSequence.getNextSequence());
sequenceMapper.updateById(voucherSequence.setNextSequence(voucherSequence.getNextSequence() + 1));
return code;