Skip to content

Commit

Permalink
Merge pull request #152 from Jzow/master
Browse files Browse the repository at this point in the history
Improve the functional code for retail shipements
  • Loading branch information
Jzow authored Nov 4, 2023
2 parents e3e67dd + f621b41 commit 4694d96
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ public interface ProductStockKeepUnitMapper extends BaseMapper<ProductStockKeepU

ProductStockKeepUnitVO getProductSkuByBarCode(Long barCode, Long warehouseId);

ProductStockKeepUnitVO getProductSkuByProductId(Long productId, Long warehouseId);
ProductStockKeepUnitVO getProductSkuDetail(Long productId, Long warehouseId, Long barCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<select id="getProductSkuList" resultMap="productResultMap" parameterType="com.baomidou.mybatisplus.core.metadata.IPage">
SELECT ps.id, p.id AS productId, p.product_category_id, p.product_name, p.product_model, p.product_standard, p.product_color,
sku.product_bar_code, sku.multi_attribute, sku.product_unit, sku.retail_price, p.product_manufacturer,pc.category_name,
ps.current_stock_quantity, w.warehouse_name
ps.current_stock_quantity, w.warehouse_name, ps.warehouse_id
FROM product_stock AS ps
LEFT JOIN warehouse as w ON ps.warehouse_id = w.id
LEFT JOIN product_sku AS sku ON sku.id = ps.product_sku_id
Expand Down Expand Up @@ -49,23 +49,23 @@
<select id="getProductSkuByBarCode" resultMap="productResultMap">
SELECT sku.id, p.id AS productId, p.product_category_id, p.product_name, p.product_model, p.product_standard, p.product_color,
sku.product_bar_code, sku.multi_attribute, sku.product_unit, sku.retail_price, p.product_manufacturer,
pc.category_name, ps.current_stock_quantity
pc.category_name, ps.current_stock_quantity, ps.warehouse_id
FROM product_stock AS ps
LEFT JOIN product_sku AS sku ON sku.id = ps.product_sku_id
LEFT JOIN product AS p ON sku.product_id = p.id
LEFT JOIN product_category AS pc ON p.product_category_id = pc.id
WHERE sku.product_bar_code = #{barCode} AND ps.warehouse_id = #{warehouseId}
</select>

<select id="getProductSkuByProductId" resultMap="productResultMap">
<select id="getProductSkuDetail" resultMap="productResultMap">
SELECT sku.id, p.id AS productId, p.product_category_id, p.product_name, p.product_model, p.product_standard, p.product_color,
sku.product_bar_code, sku.multi_attribute, sku.product_unit, sku.retail_price, p.product_manufacturer,
pc.category_name, ps.current_stock_quantity
pc.category_name, ps.current_stock_quantity, ps.warehouse_id
FROM product_stock AS ps
LEFT JOIN product_sku AS sku ON sku.id = ps.product_sku_id
LEFT JOIN product AS p ON sku.product_id = p.id
LEFT JOIN product_category AS pc ON p.product_category_id = pc.id
WHERE p.id= #{productId} AND ps.warehouse_id = #{warehouseId}
WHERE p.id= #{productId} AND ps.warehouse_id = #{warehouseId} AND sku.product_bar_code = #{barCode}
</select>

</mapper>
13 changes: 10 additions & 3 deletions core/domain/src/main/java/com/wansenai/bo/ShipmentsDataBO.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,24 @@ public class ShipmentsDataBO {

private String productCode;

private String barcode;
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long barCode;

private Long productId;

private String productName;

private String productUnit;

private String productStandard;

private Integer stock;

private Integer productNumber;

@JsonSerialize(using = BigDecimalSerializerBO.class)
private BigDecimal unitPrice;

@JsonSerialize(using = BigDecimalSerializerBO.class)
private BigDecimal amount;

private String remark;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public class ReceiptMain implements Serializable {

private String receiptNumber;

private String receiptType;

private BigDecimal changeAmount;

private BigDecimal backAmount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public class ReceiptSub implements Serializable {

private Long productId;

private Long warehouseId;

private Long productBarcode;

private Integer productNumber;

private BigDecimal productPrice;
Expand All @@ -55,8 +59,6 @@ public class ReceiptSub implements Serializable {

private Long productExtendId;

private Long warehouseId;

private Long anotherWarehouseId;

private Long correlationId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,13 @@ public class RetailServiceImpl extends ServiceImpl<ReceiptMainMapper, ReceiptMai

private final ProductStockKeepUnitMapper productStockKeepUnitMapper;

private final ProductStockMapper productStockMapper;

public RetailServiceImpl(ReceiptMainMapper receiptMainMapper, ReceiptSubService receiptSubService, MemberService memberService, ISysUserService userService, SysFileMapper fileMapper, ProductStockKeepUnitMapper productStockKeepUnitMapper, ProductStockMapper productStockMapper) {
public RetailServiceImpl(ReceiptMainMapper receiptMainMapper, ReceiptSubService receiptSubService, MemberService memberService, ISysUserService userService, SysFileMapper fileMapper, ProductStockKeepUnitMapper productStockKeepUnitMapper) {
this.receiptMainMapper = receiptMainMapper;
this.receiptSubService = receiptSubService;
this.memberService = memberService;
this.userService = userService;
this.fileMapper = fileMapper;
this.productStockKeepUnitMapper = productStockKeepUnitMapper;
this.productStockMapper = productStockMapper;
}

@Override
Expand Down Expand Up @@ -139,7 +136,6 @@ public Response<String> addOrUpdateRetailShipments(RetailShipmentsDTO shipmentsD
.eq(ReceiptMain::getId, shipmentsDTO.getId())
.set(shipmentsDTO.getMemberId() != null, ReceiptMain::getMemberId, shipmentsDTO.getMemberId())
.set(shipmentsDTO.getAccountId() != null, ReceiptMain::getAccountId, shipmentsDTO.getAccountId())
.set(StringUtils.hasText(shipmentsDTO.getPaymentType()), ReceiptMain::getReceiptType, shipmentsDTO.getPaymentType())
.set(shipmentsDTO.getCollectAmount() != null, ReceiptMain::getChangeAmount, shipmentsDTO.getCollectAmount())
.set(shipmentsDTO.getReceiptAmount() != null, ReceiptMain::getTotalPrice, shipmentsDTO.getReceiptAmount())
.set(shipmentsDTO.getBackAmount() != null, ReceiptMain::getBackAmount, shipmentsDTO.getBackAmount())
Expand All @@ -161,6 +157,7 @@ public Response<String> addOrUpdateRetailShipments(RetailShipmentsDTO shipmentsD
.productNumber(item.getProductNumber())
.productPrice(item.getUnitPrice())
.productTotalPrice(item.getAmount())
.productBarcode(item.getBarCode())
.warehouseId(item.getWarehouseId())
.build())
.collect(Collectors.toList());
Expand Down Expand Up @@ -246,6 +243,7 @@ public Response<String> addOrUpdateRetailShipments(RetailShipmentsDTO shipmentsD
.productNumber(item.getProductNumber())
.productPrice(item.getUnitPrice())
.productTotalPrice(item.getAmount())
.productBarcode(item.getBarCode())
.warehouseId(item.getWarehouseId())
.build())
.collect(Collectors.toList());
Expand Down Expand Up @@ -314,33 +312,24 @@ public Response<RetailShipmentsDetailVO> getRetailShipmentsDetail(Long id) {

var tableData = new ArrayList<ShipmentsDataBO>(receiptSubList.size() + 1);
for (ReceiptSub item : receiptSubList) {

var wrapper = new LambdaQueryWrapper<ProductStockKeepUnit>()
.eq(ProductStockKeepUnit::getProductId, item.getProductId());
var skuList = productStockKeepUnitMapper.selectList(wrapper);
// if(!skuList.isEmpty()) {
// var stocksWrapper = new LambdaQueryWrapper<ProductStock>()
// .in(ProductStock::getProductSkuId, skuList.stream().map(ProductStockKeepUnit::getId).toList())
// .eq(ProductStock::getWarehouseId, item.getWarehouseId());
//
// var stocks = productStockMapper.selectList(stocksWrapper);
// for (ProductStock stock : stocks) {
// var data = productStockKeepUnitMapper.getProductSkuByProductId(item.getProductId(), item.getWarehouseId());
// // System.err.println(data);
// }
// }

var data = productStockKeepUnitMapper.getProductSkuByProductId(item.getProductId(), item.getWarehouseId());
System.err.println(data);

var shipmentBo = ShipmentsDataBO.builder()
.productId(item.getProductId())
.barCode(item.getProductBarcode())
.productNumber(item.getProductNumber())
.unitPrice(item.getProductPrice())
.amount(item.getProductTotalPrice())
.warehouseId(item.getWarehouseId())
.build();

var data = productStockKeepUnitMapper.getProductSkuByBarCode(item.getProductBarcode(), item.getWarehouseId());
if(data != null) {
shipmentBo.setProductName(data.getProductName());
shipmentBo.setProductStandard(data.getProductStandard());
shipmentBo.setProductUnit(data.getProductUnit());
shipmentBo.setStock(data.getStock());

}

tableData.add(shipmentBo);
}

Expand Down
1 change: 1 addition & 0 deletions web/src/api/product/model/productModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export interface ProductExtendPriceResp {
id: number | string;
productId: number | string;
productCategoryId: number | string;
warehouseId: number | string;
barCode: string;
productName: string;
productStandard: string;
Expand Down
24 changes: 12 additions & 12 deletions web/src/views/retail/shipments/components/AddEditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<vxe-input v-model="row.amount"></vxe-input>
</template>
<template #barCode_edit="{ row }">
<vxe-input type="search" clearable v-model="row.barcode" @search-click="productModal"></vxe-input>
<vxe-input type="search" clearable v-model="row.barCode" @search-click="productModal"></vxe-input>
</template>
</vxe-grid>
</div>
Expand Down Expand Up @@ -302,6 +302,7 @@ export default defineComponent({
const fileList = ref([]);
const payTypeList = ref<any>([]);
const minWidth = ref(1100);
const backAmount = ref('¥0.00');
const model = ref({});
const labelCol = ref({
xs: {span: 24},
Expand Down Expand Up @@ -406,6 +407,10 @@ export default defineComponent({
warehouseId: item.warehouseId,
productId: item.productId,
barCode: item.barCode,
productName: item.productName,
productStandard: item.productStandard,
productUnit: item.productUnit,
stock: item.stock,
productNumber: item.productNumber,
amount: item.amount,
retailPrice: item.unitPrice,
Expand All @@ -416,7 +421,6 @@ export default defineComponent({
}
}
const backAmount = ref('¥0.00');
function onChangePaymentAmount() {
const sum = receiptAmount.value
const collect = collectAmount.value
Expand Down Expand Up @@ -445,9 +449,7 @@ export default defineComponent({
if (table) {
//根据productExtendPrice.id判断表格中如果是同一个商品,数量加1 否则新增一行
const tableData = table.getTableData().tableData
const index = tableData.findIndex(item => item.id === productExtendPrice.id)
const defaultWarehouse = warehouseList.value.find(item => item.isDefault === 1)
const warehouseId = defaultWarehouse ? defaultWarehouse.id : warehouseList.value[0].id
const index = tableData.findIndex(item => item.barCode === productExtendPrice.barCode && item.warehouseId === productExtendPrice.warehouseId)
if (index > -1) {
const row = tableData[index]
row.productNumber = row.productNumber + 1
Expand All @@ -456,7 +458,7 @@ export default defineComponent({
} else {
table.insert({
id: productExtendPrice.id,
warehouseId: warehouseId,
warehouseId: productExtendPrice.warehouseId,
productId: productExtendPrice.productId,
barCode: productExtendPrice.barCode,
productName: productExtendPrice.productName,
Expand All @@ -473,6 +475,7 @@ export default defineComponent({
})
// 清除扫码框的值
formState.scanBarCode = ''
onChangePaymentAmount()
}
function scanEnter() {
Expand Down Expand Up @@ -553,7 +556,7 @@ export default defineComponent({
table.getInsertRecords().forEach(item => {
const data: ShipmentsData = {
warehouseId: item.warehouseId,
barcode: item.barCode,
barCode: item.barCode,
productId: item.productId,
productNumber: item.productNumber,
unitPrice: item.retailPrice,
Expand Down Expand Up @@ -596,7 +599,7 @@ export default defineComponent({
formState.scanBarCode = ''
receiptAmount.value = ''
collectAmount.value = ''
backAmount.value = ''
backAmount.value = '¥0.00'
fileList.value = []
const table = xGrid.value
if(table) {
Expand Down Expand Up @@ -642,11 +645,8 @@ export default defineComponent({
function handleCheckSuccess(data) {
const table = xGrid.value
if(table) {
const defaultWarehouse = warehouseList.value.find(item => item.isDefault === 1)
const warehouseId = defaultWarehouse ? defaultWarehouse.id : warehouseList.value[0].id
data.forEach(item => {
item.productNumber = 1,
item.warehouseId = warehouseId
item.productNumber = 1
})
table.insert(data)
}
Expand Down
1 change: 0 additions & 1 deletion web/src/views/retail/shipments/model/addEditModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export interface RowVO {
productNumber: number,
retailPrice: number,
amount: number,
remark: string
}

const xGrid = ref<VxeGridInstance<RowVO>>()
Expand Down

0 comments on commit 4694d96

Please sign in to comment.