Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add selected data for querying products #146

Merged
merged 8 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@
*/
package com.wansenai.api.product;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wansenai.dto.product.QueryProductExtendPriceDTO;
import com.wansenai.service.product.ProductExtendPriceService;
import com.wansenai.utils.enums.BaseCodeEnum;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.product.ProductExtendPriceVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* <p>
* 产品价格扩展 前端控制器
Expand All @@ -25,7 +36,21 @@
* @since 2023-09-05
*/
@RestController
@RequestMapping("/product-extend-price")
@RequestMapping("/product/extend-price")
public class ProductExtendPriceController {

private final ProductExtendPriceService productExtendPriceService;

public ProductExtendPriceController(ProductExtendPriceService productExtendPriceService) {
this.productExtendPriceService = productExtendPriceService;
}

@PostMapping("pageList")
public Response<IPage<ProductExtendPriceVO>> getProductExtendPrice(@RequestBody QueryProductExtendPriceDTO priceDTO) {
var result = productExtendPriceService.getProductExtendPriceInfo(priceDTO);
if(result != null) {
return Response.responseData(result);
}
return Response.responseMsg(BaseCodeEnum.QUERY_DATA_EMPTY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
*/
package com.wansenai.mappers.product;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wansenai.dto.product.QueryProductExtendPriceDTO;
import com.wansenai.entities.product.ProductExtendPrice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wansenai.vo.product.ProductExtendPriceVO;

import java.util.List;

/**
* <p>
Expand All @@ -22,4 +27,7 @@
*/
public interface ProductExtendPriceMapper extends BaseMapper<ProductExtendPrice> {

IPage<ProductExtendPriceVO> getProductExtendPriceList(IPage<QueryProductExtendPriceDTO> pageObject, QueryProductExtendPriceDTO queryProductExtendPriceDTO);


}
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wansenai.mappers.product.ProductExtendPriceMapper">
<resultMap id="productResultMap" type="com.wansenai.vo.product.ProductExtendPriceVO">
<id property="id" column="id" />
<result property="productId" column="productId" />
<result property="productCategoryId" column="product_category_id" />
<result property="barCode" column="product_bar_code" />
<result property="productName" column="product_name" />
<result property="productCategoryName" column="category_name" />
<result property="productStandard" column="product_standard" />
<result property="productModel" column="product_model" />
<result property="productColor" column="product_color" />
<result property="productUnit" column="product_unit" />
<result property="multiAttribute" column="multi_attribute" />
<result property="stock" column="current_stock_quantity" />
<result property="extendInfo" column="product_manufacturer" />
<result property="retailPrice" column="retail_price" />
</resultMap>

<select id="getProductExtendPriceList" resultMap="productResultMap" parameterType="com.baomidou.mybatisplus.core.metadata.IPage">
SELECT pep.id, p.id AS productId, p.product_category_id, p.product_name, p.product_model, p.product_standard, p.product_color,
pep.product_bar_code, pep.multi_attribute, pep.product_unit, pep.retail_price, p.product_manufacturer,
pc.category_name
FROM product_extend_price AS pep
LEFT JOIN product AS p ON pep.product_id = p.id
LEFT JOIN product_category AS pc ON p.product_category_id = pc.id
<where>
<if test="queryProductExtendPriceDTO.productCategoryId != null">
AND p.product_category_id = #{queryProductExtendPriceDTO.productCategoryId}
</if>
<if test="queryProductExtendPriceDTO.warehouseId != null">
AND p.warehouse_id = #{queryProductExtendPriceDTO.warehouseId}
</if>
<if test="queryProductExtendPriceDTO.productName != null">
AND p.product_name = #{queryProductExtendPriceDTO.productName}
</if>
<if test="queryProductExtendPriceDTO.enableSerialNumber != null">
AND p.enable_serial_number = #{queryProductExtendPriceDTO.enableSerialNumber}
</if>
<if test="queryProductExtendPriceDTO.enableBatchNumber != null">
AND p.enable_batch_number = #{queryProductExtendPriceDTO.enableBatchNumber}
</if>
</where>
</select>

</mapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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.dto.product;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

@Data
public class QueryProductExtendPriceDTO {

private Long productCategoryId;

private Long warehouseId;

private String productName;

private Integer enableSerialNumber;

private Integer enableBatchNumber;

private Long page;

private Long pageSize;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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.vo.product;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.wansenai.bo.BigDecimalSerializerBO;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class ProductExtendPriceVO {

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

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

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

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

private String barCode;

private String productName;

private String productCategoryName;

private String warehouseName;

private String productStandard;

private String productModel;

private String productColor;

private String productUnit;

private String multiAttribute;

private Integer stock;

private String extendInfo;

@JsonSerialize(using = BigDecimalSerializerBO.class)
private BigDecimal retailPrice;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
*/
package com.wansenai.service.product;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wansenai.dto.product.QueryProductExtendPriceDTO;
import com.wansenai.utils.response.Response;
import com.wansenai.entities.product.ProductExtendPrice;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wansenai.vo.product.ProductExtendPriceVO;

import java.util.List;

Expand All @@ -28,4 +32,6 @@ public interface ProductExtendPriceService extends IService<ProductExtendPrice>
Response<Integer> getBarCode();

Boolean checkProductCode(List<String> barCodes);

IPage<ProductExtendPriceVO> getProductExtendPriceInfo(QueryProductExtendPriceDTO priceDTO);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
*/
package com.wansenai.service.product.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wansenai.dto.product.QueryProductExtendPriceDTO;
import com.wansenai.service.product.ProductExtendPriceService;
import com.wansenai.utils.response.Response;
import com.wansenai.entities.product.ProductExtendPrice;
import com.wansenai.mappers.product.ProductExtendPriceMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wansenai.vo.product.ProductExtendPriceVO;
import org.springframework.stereotype.Service;

import java.util.List;
Expand All @@ -29,7 +33,14 @@
@Service
public class ProductExtendPriceServiceImpl extends ServiceImpl<ProductExtendPriceMapper, ProductExtendPrice> implements ProductExtendPriceService {

private final ProductExtendPriceMapper productExtendPriceMapper;

private static int currentBarcode = 1000;

public ProductExtendPriceServiceImpl(ProductExtendPriceMapper productExtendPriceMapper) {
this.productExtendPriceMapper = productExtendPriceMapper;
}

public static int generateBarcode() {
if (currentBarcode > 9999) {
throw new IllegalStateException("No more barcodes available.");
Expand All @@ -55,4 +66,10 @@ public Response<Integer> getBarCode() {
public Boolean checkProductCode(List<String> barCodes) {
return lambdaQuery().in(ProductExtendPrice::getProductBarCode, barCodes).exists();
}

@Override
public IPage<ProductExtendPriceVO> getProductExtendPriceInfo(QueryProductExtendPriceDTO priceDTO) {
var page = new Page<QueryProductExtendPriceDTO>(priceDTO.getPage(), priceDTO.getPageSize());
return productExtendPriceMapper.getProductExtendPriceList(page, priceDTO);
}
}
24 changes: 24 additions & 0 deletions web/src/api/product/model/productModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,28 @@ export interface UpdateBatchProductInfoReq {
enableSerialNumber: string;
enableBatchNumber: string;
remark: string;
}

export interface QueryProductExtendPriceReq {
productCategoryId: number | string;
warehouseId: number | string;
productName: string;
enableSerialNumber: number;
enableBatchNumber: number;
}

export interface ProductExtendPriceResp {
id: number | string;
productId: number | string;
productCategoryId: number | string;
barCode: string;
productName: string;
productStandard: string;
productModel: string;
productColor: string;
productUnit: string;
multiAttribute: string;
stock: number;
extendInfo: string;
retailPrice: number;
}
14 changes: 13 additions & 1 deletion web/src/api/product/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
AddProductReq,
ProductInfoDetailResp,
QueryProductReq,
UpdateBatchProductInfoReq
UpdateBatchProductInfoReq,
ProductExtendPriceResp,
QueryProductExtendPriceReq,
} from "@/api/product/model/productModel";
import {ErrorMessageMode} from "#/axios";

Expand All @@ -16,6 +18,7 @@ enum Api {
deleteProduct = '/product/deleteProduct',
updateProductStatus = '/product/updateProductStatus',
updateBatchProductInfo = '/product/updateBatchProductInfo',
getProductExtendPrice = '/product/extend-price/pageList'
}

export function getBarCode() {
Expand Down Expand Up @@ -87,4 +90,13 @@ export function updateBatchProductInfo(params: UpdateBatchProductInfoReq, mode:
errorMessageMode: mode,
}
);
}

export function getProductExtendPricePage(params: QueryProductExtendPriceReq) {
return defHttp.post<BaseResp>(
{
url: Api.getProductExtendPrice,
params
}
);
}
57 changes: 57 additions & 0 deletions web/src/api/retail/model/shipmentsModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
interface FileData {
id: number | string;
fileName: string;
fileUrl: string;
fileType: string;
fileSize: number;
}

interface ShipmentsData {
warehouseId: number | string;
barcode: string;
productId: number | string;
productNumber: number;
unitPrice: number;
amount: number;
remark: string;
}

interface AddOrUpdateShipmentsReq {
id: number | string | undefined;
memberId: number | string;
accountId: number | string;
receiptDate: string;
receiptNumber: string;
receiptType: string;
collectionAmount: number;
receiptAmount: number;
backAmount: number;
remark: string;
tableData: ShipmentsData[];
fileDataList: FileData[];
}

interface QueryShipmentsReq {
receiptNumber: string;
productInfo: string;
memberId: number | string;
warehouseId: number | string;
accountId: number | string;
operatorId: number | string;
status: number;
remark: string;
}

interface ShipmentsResp {
id: number | string;
memberName: string;
receiptNumber: string;
receiptDate: string;
productInfo: string;
operator: string;
productNumber: number;
totalPrice: number;
collectionAmount: number;
backAmount: string;
status: number;
}
Loading