Skip to content

Commit

Permalink
Merge pull request #233 from Jzow/master
Browse files Browse the repository at this point in the history
Add other storage apis and views and fix (retail sale purchase service stock bug)
  • Loading branch information
wansenai-bot authored Nov 24, 2023
2 parents f97fc1f + 3ebd45a commit c34b264
Show file tree
Hide file tree
Showing 31 changed files with 1,986 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public Response<String> updatePassword(@RequestBody UpdatePasswordDto updatePass
return userService.updatePassword(updatePasswordDto);
}

@GetMapping(value = "operator")
public Response<List<UserInfoVO>> operator() {
return userService.operator();
}

@GetMapping(value = "info")
public Response<UserInfoVO> info() {
return userService.userInfo();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://opensource.wansenai.com/apache2.0/
*
* or in the "license" file accompanying this file. This file 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 com.wansenai.api.warehouse;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wansenai.dto.warehouse.OtherStorageDTO;
import com.wansenai.dto.warehouse.QueryOtherStorageDTO;
import com.wansenai.service.warehouse.OtherStorageService;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.warehouse.OtherStorageDetailVO;
import com.wansenai.vo.warehouse.OtherStorageVO;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

@RestController
@RequestMapping("warehouse/otherStorage")
public class OtherStorageController {

private final OtherStorageService otherStorageService;

public OtherStorageController(OtherStorageService otherStorageService) {
this.otherStorageService = otherStorageService;
}

@PostMapping("addOrUpdate")
public Response<String> addOrUpdateOtherStorage(@RequestBody OtherStorageDTO otherStorageDTO) {
return otherStorageService.addOrUpdateOtherStorage(otherStorageDTO);
}

@PostMapping("pageList")
public Response<Page<OtherStorageVO>> getOtherStoragePageList(@RequestBody QueryOtherStorageDTO queryOtherStorageDTO) {
return otherStorageService.getOtherStoragePageList(queryOtherStorageDTO);
}

@GetMapping("getDetailById/{id}")
public Response<OtherStorageDetailVO> getOtherStorageDetailById(@PathVariable("id") Long id) {
return otherStorageService.getOtherStorageDetail(id);
}

@PutMapping("deleteByIds")
public Response<String> deleteOtherStorageByIds(@RequestParam("ids") List<Long> ids) {
return otherStorageService.deleteBatchOtherStorage(ids);
}

@PutMapping("updateStatusByIds")
public Response<String> updateOtherStorageStatusByIds(@RequestParam("ids") List<Long> ids, @RequestParam("status") Integer status) {
return otherStorageService.updateOtherStorageStatus(ids, status);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Response<String> addOrUpdateWarehouse(@RequestBody AddOrUpdateWarehouseDT
public Response<String> deleteWarehouse(@RequestParam("ids") List<Long> ids) {
return warehouseService.deleteBatch(ids);
}
//

@PostMapping("updateStatus")
public Response<String> updateStatus(@RequestParam("ids") List<Long> ids, @RequestParam("status") Integer status) {
return warehouseService.updateBatchStatus(ids, status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ public class StorageShipmentStockBO {

private String productName;

private String productModel;

private String productUnit;

private String productStandard;

private String productModel;

private String productExtendInfo;

private Integer stock;

private Integer productNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

Expand All @@ -24,6 +27,9 @@
import java.time.LocalDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("warehouse_receipt_main")
Expand All @@ -48,6 +54,11 @@ public class WarehouseReceiptMain {
*/
private Long relatedPersonId;

/**
* 商品id
*/
private Long productId;

/**
* 类型(入库/出库/调拨/组装/拆卸)
*/
Expand Down Expand Up @@ -78,10 +89,6 @@ public class WarehouseReceiptMain {
*/
private Integer totalProductNumber;

/**
* 商品数量
*/
private String productInfo;

/**
* 备注
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
package com.wansenai.entities.warehouse;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.OrderBy;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

Expand All @@ -25,6 +27,9 @@
import java.time.LocalDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("warehouse_receipt_sub")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@
import lombok.Builder;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Data
@Builder
public class OtherStorageDetailVO {

@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long id;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long supplierId;

private String supplierName;

private String receiptNumber;

private String receiptDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime receiptDate;

private String remark;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,11 +702,16 @@ public Response<String> generateSnowflakeId(String type) {
case "报损单" -> "BSD";
case "报溢单" -> "BZD";
case "调价单" -> "DJD";
case "组装单" -> "ADD";
case "拆卸单" -> "CXD";
case "零售出库" -> "LSCK";
case "零售退货" -> "LSTH";
case "销售出库" -> "XSCK";
case "销售退货" -> "XSTH";
case "采购入库" -> "CGRK";
case "其他入库" -> "QTRK";
case "其他出库" -> "QTCK";
case "调拨出库" -> "DBCK";
case "采购退货" -> "CGTH";
case "收预付款" -> "ACD";
default -> "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,7 @@ public Response<String> addOrUpdatePurchaseStorage(PurchaseStorageDTO purchaseSt
.collect(Collectors.toList());

var updateSubResult = receiptPurchaseSubService.saveBatch(receiptPurchaseStorageList);
purchaseStorageDTO.getTableData().forEach(item -> {
updateProductStock(receiptPurchaseStorageList, 1);
});
updateProductStock(receiptPurchaseStorageList, 1);

var account = accountService.getById(purchaseStorageDTO.getAccountId());
if (account != null) {
Expand Down Expand Up @@ -1025,9 +1023,8 @@ public Response<String> addOrUpdatePurchaseRefund(PurchaseRefundDTO purchaseRefu
.collect(Collectors.toList());

var updateSubResult = receiptPurchaseSubService.saveBatch(receiptPurchaseRefundList);
purchaseRefundDTO.getTableData().forEach(item -> {
updateProductStock(receiptPurchaseRefundList, 2);
});
updateProductStock(receiptPurchaseRefundList, 2);

var account = accountService.getById(purchaseRefundDTO.getAccountId());
if (account != null) {
var accountBalance = account.getCurrentAmount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,7 @@ public Response<String> addOrUpdateRetailShipments(RetailShipmentsDTO shipmentsD
.build())
.collect(Collectors.toList());
var updateSubResult = receiptRetailSubService.saveBatch(receiptList);
shipmentsDTO.getTableData().forEach(item -> {
updateProductStock(receiptList, 2);
});
updateProductStock(receiptList, 2);

var updateMainResult = lambdaUpdate()
.eq(ReceiptRetailMain::getId, shipmentsDTO.getId())
Expand Down Expand Up @@ -655,21 +653,17 @@ public Response<String> addOrUpdateRetailRefund(RetailRefundDTO refundDTO) {
.collect(Collectors.toList());

var updateSubResult = receiptRetailSubService.saveBatch(receiptList);
refundDTO.getTableData().forEach(item -> {
updateProductStock(receiptList, 1);
});
updateProductStock(receiptList, 1);

// 更新余额 如果之前已经修改过那么就需要加上之前的金额 然后再减去现在的金额 如果之前没有修改过那么就直接加上现在的金额 因为这个是退货 所以是负数
var account = accountService.getById(refundDTO.getAccountId());
if (account != null) {
var accountBalance = account.getCurrentAmount();
var changeAmount = refundDTO.getReceiptAmount();
var beforeChangeAmount = beforeReceipt.stream()
.map(item -> item.getTotalAmount())
.map(ReceiptRetailSub::getTotalAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
if (beforeChangeAmount != null) {
accountBalance = accountBalance.add(beforeChangeAmount);
}
accountBalance = accountBalance.add(beforeChangeAmount);
if (changeAmount != null) {
accountBalance = accountBalance.subtract(changeAmount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,7 @@ public Response<String> addOrUpdateSaleShipments(SaleShipmentsDTO shipmentsDTO)
.collect(Collectors.toList());

var updateSubResult = receiptSaleSubService.saveBatch(receiptSaleList);
shipmentsDTO.getTableData().forEach(item -> {
updateProductStock(receiptSaleList, 2);
});
updateProductStock(receiptSaleList, 2);

var account = accountService.getById(shipmentsDTO.getAccountId());
if (account != null) {
Expand Down Expand Up @@ -1027,20 +1025,16 @@ public Response<String> addOrUpdateSaleRefund(SaleRefundDTO refundDTO) {
.collect(Collectors.toList());

var updateSubResult = receiptSaleSubService.saveBatch(receiptSaleList);
refundDTO.getTableData().forEach(item -> {
updateProductStock(receiptSaleList, 1);
});
updateProductStock(receiptSaleList, 1);

var account = accountService.getById(refundDTO.getAccountId());
if (account != null) {
var accountBalance = account.getCurrentAmount();
var thisRefundAmount = refundDTO.getThisRefundAmount();
var beforeChangeAmount = beforeReceipt.stream()
.map(item -> item.getTotalAmount())
.map(ReceiptSaleSub::getTotalAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
if (beforeChangeAmount != null) {
accountBalance = accountBalance.add(beforeChangeAmount);
}
accountBalance = accountBalance.add(beforeChangeAmount);
if (thisRefundAmount != null) {
accountBalance = accountBalance.subtract(thisRefundAmount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ public interface ISysUserService extends IService<SysUser> {
Response<String> deleteUser(List<Long> ids);

Response<String> resetPassword(Long id);

Response<List<UserInfoVO>> operator();
}
Original file line number Diff line number Diff line change
Expand Up @@ -728,4 +728,24 @@ public Response<String> resetPassword(Long id) {

return Response.responseMsg(UserCodeEnum.USER_RESET_PASSWORD_SUCCESS);
}

@Override
public Response<List<UserInfoVO>> operator() {
var user = lambdaQuery()
.eq(SysUser::getTenantId, getCurrentTenantId())
.eq(SysUser::getStatus, UserConstants.USER_STATUS_ENABLE)
.eq(SysUser::getDeleteFlag, CommonConstants.NOT_DELETED)
.list();
var result = new ArrayList<UserInfoVO>(user.size() + 1);
for (SysUser sysUser : user) {
var userVO = UserInfoVO.builder()
.id(sysUser.getId())
.name(sysUser.getName())
.userName(sysUser.getUserName())
.avatar(sysUser.getAvatar())
.build();
result.add(userVO);
}
return Response.responseData(result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
package com.wansenai.service.warehouse;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wansenai.dto.warehouse.AllotReceiptDTO;
import com.wansenai.dto.warehouse.QueryAllotReceiptDTO;
import com.wansenai.entities.warehouse.WarehouseReceiptMain;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.warehouse.AllotReceiptDetailVO;
import com.wansenai.vo.warehouse.AllotReceiptVO;

import java.util.List;

public interface AllotShipmentsService {
public interface AllotShipmentsService extends IService<WarehouseReceiptMain> {

Response<Page<AllotReceiptVO>> getAllotReceiptPageList(QueryAllotReceiptDTO queryAllotReceiptDTO);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
package com.wansenai.service.warehouse;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wansenai.dto.warehouse.AssembleReceiptDTO;
import com.wansenai.dto.warehouse.QueryAssembleReceiptDTO;
import com.wansenai.entities.warehouse.WarehouseReceiptMain;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.warehouse.AssembleReceiptDetailVO;
import com.wansenai.vo.warehouse.AssembleReceiptVO;

import java.util.List;

public interface AssembleReceiptService {
public interface AssembleReceiptService extends IService<WarehouseReceiptMain> {

Response<Page<AssembleReceiptVO>> getAssembleReceiptPageList(QueryAssembleReceiptDTO queryAssembleReceiptDTO);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
package com.wansenai.service.warehouse;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wansenai.dto.warehouse.DisassembleReceiptDTO;
import com.wansenai.dto.warehouse.QueryDisassembleReceiptDTO;
import com.wansenai.entities.warehouse.WarehouseReceiptMain;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.warehouse.DisassembleReceiptDetailVO;
import com.wansenai.vo.warehouse.DisassembleReceiptVO;

import java.util.List;

public interface DisassembleReceiptService {
public interface DisassembleReceiptService extends IService<WarehouseReceiptMain> {

Response<Page<DisassembleReceiptVO>> getDisassembleReceiptPageList(QueryDisassembleReceiptDTO queryDisassembleReceiptDTO);

Expand Down
Loading

0 comments on commit c34b264

Please sign in to comment.