1、仓库库存功能实现
This commit is contained in:
parent
28b064ba8e
commit
77e3e32585
|
|
@ -1,5 +1,6 @@
|
|||
<template>
|
||||
<el-dialog
|
||||
width="500px"
|
||||
:title="!dataForm.id ? '新增' : '修改'"
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="visible"
|
||||
|
|
@ -9,10 +10,10 @@
|
|||
:rules="dataRule"
|
||||
ref="dataForm"
|
||||
@keyup.enter.native="dataFormSubmit()"
|
||||
label-width="120px"
|
||||
label-width="90px"
|
||||
>
|
||||
<el-form-item label="sku_id" prop="skuId">
|
||||
<el-input v-model="dataForm.skuId" placeholder="sku_id"></el-input>
|
||||
<el-input v-model="dataForm.skuId" placeholder="请输入商品id"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库" prop="wareId">
|
||||
<el-select v-model="dataForm.wareId" placeholder="请选择仓库" clearable>
|
||||
|
|
@ -20,13 +21,13 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="库存数" prop="stock">
|
||||
<el-input v-model="dataForm.stock" placeholder="库存数"></el-input>
|
||||
<el-input-number v-model.number="dataForm.stock" :min="0" :max="9999999" label="库存数"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="sku_name" prop="skuName">
|
||||
<el-input v-model="dataForm.skuName" placeholder="sku_name"></el-input>
|
||||
<el-input v-model="dataForm.skuName" placeholder="请输入商品名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="锁定库存" prop="stockLocked">
|
||||
<el-input v-model="dataForm.stockLocked" placeholder="锁定库存"></el-input>
|
||||
<el-input-number v-model.number="dataForm.stockLocked" :min="0" :max="9999999" label="锁定库存"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
|
|
@ -37,7 +38,11 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {getWareInfoList} from "@/api/mall/ware/ware-info";
|
||||
import {editWareSku, getWareSku, saveWareSku} from "@/api/mall/ware/ware-sku";
|
||||
|
||||
export default {
|
||||
name: "WareSku-add-or-update",
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
|
|
@ -51,87 +56,64 @@ export default {
|
|||
stockLocked: 0
|
||||
},
|
||||
dataRule: {
|
||||
skuId: [{ required: true, message: "sku_id不能为空", trigger: "blur" }],
|
||||
skuId: [{required: true, message: "sku_id不能为空", trigger: "blur"}],
|
||||
wareId: [
|
||||
{ required: true, message: "仓库id不能为空", trigger: "blur" }
|
||||
{required: true, message: "仓库id不能为空", trigger: "blur"}
|
||||
],
|
||||
stock: [{ required: true, message: "库存数不能为空", trigger: "blur" }],
|
||||
stock: [{required: true, message: "库存数不能为空", trigger: "blur"}],
|
||||
skuName: [
|
||||
{ required: true, message: "sku_name不能为空", trigger: "blur" }
|
||||
{required: true, message: "sku_name不能为空", trigger: "blur"}
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
created(){
|
||||
created() {
|
||||
this.getWares();
|
||||
},
|
||||
methods: {
|
||||
//获取仓库信息
|
||||
getWares() {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl("/ware/wareinfo/list"),
|
||||
method: "get",
|
||||
params: this.$http.adornParams({
|
||||
page: 1,
|
||||
limit: 500
|
||||
})
|
||||
}).then(({ data }) => {
|
||||
this.wareList = data.page.list;
|
||||
});
|
||||
let params = {
|
||||
page: 1,
|
||||
limit: 500
|
||||
}
|
||||
getWareInfoList(params).then(res => {
|
||||
this.wareList = res.page.list;
|
||||
})
|
||||
},
|
||||
|
||||
init(id) {
|
||||
this.dataForm.id = id || 0;
|
||||
this.dataForm.id = id;
|
||||
this.visible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs["dataForm"].resetFields();
|
||||
if (this.dataForm.id) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/ware/waresku/info/${this.dataForm.id}`),
|
||||
method: "get",
|
||||
params: this.$http.adornParams()
|
||||
}).then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataForm.skuId = data.wareSku.skuId;
|
||||
this.dataForm.wareId = data.wareSku.wareId;
|
||||
this.dataForm.stock = data.wareSku.stock;
|
||||
this.dataForm.skuName = data.wareSku.skuName;
|
||||
this.dataForm.stockLocked = data.wareSku.stockLocked;
|
||||
}
|
||||
});
|
||||
getWareSku(this.dataForm.id).then(res => {
|
||||
this.dataForm = res.wareSku
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
this.$refs["dataForm"].validate(valid => {
|
||||
if (valid) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(
|
||||
`/ware/waresku/${!this.dataForm.id ? "save" : "update"}`
|
||||
),
|
||||
method: "post",
|
||||
data: this.$http.adornData({
|
||||
id: this.dataForm.id || undefined,
|
||||
skuId: this.dataForm.skuId,
|
||||
wareId: this.dataForm.wareId,
|
||||
stock: this.dataForm.stock,
|
||||
skuName: this.dataForm.skuName,
|
||||
stockLocked: this.dataForm.stockLocked
|
||||
|
||||
if (!this.dataForm.id) {
|
||||
saveWareSku(this.dataForm).then(res => {
|
||||
this.$modal.notifySuccess("保存成功")
|
||||
this.visible = false;
|
||||
this.$emit("refreshDataList");
|
||||
})
|
||||
}).then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: "操作成功",
|
||||
type: "success",
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false;
|
||||
this.$emit("refreshDataList");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$message.error(data.msg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
editWareSku(this.dataForm).then(res => {
|
||||
this.$modal.notifySuccess("修改成功")
|
||||
this.visible = false;
|
||||
this.$emit("refreshDataList");
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@
|
|||
type="danger"
|
||||
@click="deleteHandle()"
|
||||
:disabled="dataListSelections.length <= 0"
|
||||
>批量删除</el-button>
|
||||
>批量删除
|
||||
</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-button-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
|
@ -31,7 +33,7 @@
|
|||
>
|
||||
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
||||
<el-table-column prop="skuId" header-align="center" align="center" label="sku_id"></el-table-column>
|
||||
<el-table-column prop="wareId" header-align="center" align="center" label="仓库id"></el-table-column>
|
||||
<el-table-column prop="wareName" header-align="center" align="center" label="仓库名称"></el-table-column>
|
||||
<el-table-column prop="stock" header-align="center" align="center" label="库存数"></el-table-column>
|
||||
<el-table-column prop="skuName" header-align="center" align="center" label="商品名称"></el-table-column>
|
||||
<el-table-column prop="stockLocked" header-align="center" align="center" label="锁定库存"></el-table-column>
|
||||
|
|
@ -58,8 +60,11 @@
|
|||
|
||||
<script>
|
||||
import AddOrUpdate from "./waresku-add-or-update";
|
||||
import {getWareInfoList} from "@/api/mall/ware/ware-info";
|
||||
import {delWareSku, getWareSkuList} from "@/api/mall/ware/ware-sku";
|
||||
|
||||
export default {
|
||||
name:"WareSku",
|
||||
name: "WareSku",
|
||||
data() {
|
||||
return {
|
||||
wareList: [],
|
||||
|
|
@ -80,7 +85,6 @@ export default {
|
|||
AddOrUpdate
|
||||
},
|
||||
created() {
|
||||
console.log("接收到", this.$route.query.skuId);
|
||||
if (this.$route.query.skuId) {
|
||||
this.dataForm.skuId = this.$route.query.skuId;
|
||||
}
|
||||
|
|
@ -88,41 +92,34 @@ export default {
|
|||
this.getDataList();
|
||||
},
|
||||
methods: {
|
||||
//获取仓库信息
|
||||
getWares() {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl("/ware/wareinfo/list"),
|
||||
method: "get",
|
||||
params: this.$http.adornParams({
|
||||
page: 1,
|
||||
limit: 500
|
||||
})
|
||||
}).then(({ data }) => {
|
||||
this.wareList = data.page.list;
|
||||
});
|
||||
let params = {
|
||||
page: 1,
|
||||
limit: 500
|
||||
}
|
||||
getWareInfoList(params).then(res => {
|
||||
this.wareList = res.page.list;
|
||||
})
|
||||
},
|
||||
|
||||
// 获取数据列表
|
||||
getDataList() {
|
||||
this.dataListLoading = true;
|
||||
this.$http({
|
||||
url: this.$http.adornUrl("/ware/waresku/list"),
|
||||
method: "get",
|
||||
params: this.$http.adornParams({
|
||||
page: this.pageIndex,
|
||||
limit: this.pageSize,
|
||||
skuId: this.dataForm.skuId,
|
||||
wareId: this.dataForm.wareId
|
||||
})
|
||||
}).then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataList = data.page.list;
|
||||
this.totalPage = data.page.totalCount;
|
||||
} else {
|
||||
this.dataList = [];
|
||||
this.totalPage = 0;
|
||||
}
|
||||
let params = {
|
||||
page: this.pageIndex,
|
||||
limit: this.pageSize,
|
||||
skuId: this.dataForm.skuId,
|
||||
wareId: this.dataForm.wareId
|
||||
}
|
||||
getWareSkuList(params).then(res => {
|
||||
this.dataList = res.page.list;
|
||||
this.totalPage = res.page.totalCount;
|
||||
this.dataListLoading = false;
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
// 每页数
|
||||
sizeChangeHandle(val) {
|
||||
this.pageSize = val;
|
||||
|
|
@ -147,11 +144,9 @@ export default {
|
|||
},
|
||||
// 删除
|
||||
deleteHandle(id) {
|
||||
var ids = id
|
||||
? [id]
|
||||
: this.dataListSelections.map(item => {
|
||||
return item.id;
|
||||
});
|
||||
var ids = id ? [id] : this.dataListSelections.map(item => {
|
||||
return item.id;
|
||||
});
|
||||
this.$confirm(
|
||||
`确定对[id=${ids.join(",")}]进行[${id ? "删除" : "批量删除"}]操作?`,
|
||||
"提示",
|
||||
|
|
@ -161,26 +156,21 @@ export default {
|
|||
type: "warning"
|
||||
}
|
||||
).then(() => {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl("/ware/waresku/delete"),
|
||||
method: "post",
|
||||
data: this.$http.adornData(ids, false)
|
||||
}).then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: "操作成功",
|
||||
type: "success",
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$message.error(data.msg);
|
||||
}
|
||||
});
|
||||
|
||||
delWareSku(ids).then(res => {
|
||||
this.$modal.notifySuccess("删除成功")
|
||||
this.getDataList();
|
||||
})
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dataForm = {}
|
||||
this.pageIndex = 1;
|
||||
this.getDataList();
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
package com.xjs.mall.ware.controller;
|
||||
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.xjs.mall.ware.entity.PurchaseDetailEntity;
|
||||
import com.xjs.mall.ware.service.PurchaseDetailService;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.mall.other.R;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
@ -11,16 +15,16 @@ import java.util.Arrays;
|
|||
import java.util.Map;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 采购需求
|
||||
*
|
||||
* @author xiejs
|
||||
* @email 1294405880@qq.com
|
||||
* @date 2022-03-15 09:56:19
|
||||
* @since 2022-03-15 09:56:19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("ware/purchasedetail")
|
||||
@Api(tags = "商城-仓库-采购需求")
|
||||
public class PurchaseDetailController {
|
||||
@Autowired
|
||||
private PurchaseDetailService purchaseDetailService;
|
||||
|
|
@ -28,8 +32,9 @@ public class PurchaseDetailController {
|
|||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("列表")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = purchaseDetailService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
|
|
@ -40,8 +45,9 @@ public class PurchaseDetailController {
|
|||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
PurchaseDetailEntity purchaseDetail = purchaseDetailService.getById(id);
|
||||
@ApiOperation("信息")
|
||||
public R info(@PathVariable("id") Long id) {
|
||||
PurchaseDetailEntity purchaseDetail = purchaseDetailService.getById(id);
|
||||
|
||||
return R.ok().put("purchaseDetail", purchaseDetail);
|
||||
}
|
||||
|
|
@ -50,8 +56,10 @@ public class PurchaseDetailController {
|
|||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody PurchaseDetailEntity purchaseDetail){
|
||||
purchaseDetailService.save(purchaseDetail);
|
||||
@ApiOperation("保存")
|
||||
@Log(title = "采购需求", businessType = BusinessType.INSERT)
|
||||
public R save(@RequestBody PurchaseDetailEntity purchaseDetail) {
|
||||
purchaseDetailService.save(purchaseDetail);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
|
@ -60,8 +68,10 @@ public class PurchaseDetailController {
|
|||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody PurchaseDetailEntity purchaseDetail){
|
||||
purchaseDetailService.updateById(purchaseDetail);
|
||||
@ApiOperation("修改")
|
||||
@Log(title = "采购需求", businessType = BusinessType.UPDATE)
|
||||
public R update(@RequestBody PurchaseDetailEntity purchaseDetail) {
|
||||
purchaseDetailService.updateById(purchaseDetail);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
|
@ -70,8 +80,10 @@ public class PurchaseDetailController {
|
|||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
purchaseDetailService.removeByIds(Arrays.asList(ids));
|
||||
@ApiOperation("删除")
|
||||
@Log(title = "采购需求", businessType = BusinessType.DELETE)
|
||||
public R delete(@RequestBody Long[] ids) {
|
||||
purchaseDetailService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.xjs.mall.ware.controller;
|
||||
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.xjs.business.api.domain.Area;
|
||||
import com.xjs.mall.other.R;
|
||||
import com.xjs.mall.ware.entity.WareInfoEntity;
|
||||
|
|
@ -76,6 +78,7 @@ public class WareInfoController extends MyBaseController<WareInfoEntity> {
|
|||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperation("保存")
|
||||
@Log(title = "仓库信息", businessType = BusinessType.INSERT)
|
||||
public R save(@Validated(AddGroup.class) @RequestBody WareInfoEntity wareInfo) {
|
||||
wareInfoService.save(wareInfo);
|
||||
|
||||
|
|
@ -87,6 +90,7 @@ public class WareInfoController extends MyBaseController<WareInfoEntity> {
|
|||
*/
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("修改")
|
||||
@Log(title = "仓库信息", businessType = BusinessType.UPDATE)
|
||||
public R update(@Validated(UpdateGroup.class)@RequestBody WareInfoEntity wareInfo) {
|
||||
wareInfoService.updateById(wareInfo);
|
||||
|
||||
|
|
@ -98,6 +102,7 @@ public class WareInfoController extends MyBaseController<WareInfoEntity> {
|
|||
*/
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除")
|
||||
@Log(title = "仓库信息", businessType = BusinessType.DELETE)
|
||||
public R delete(@RequestBody Long[] ids) {
|
||||
wareInfoService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,29 @@
|
|||
package com.xjs.mall.ware.controller;
|
||||
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.xjs.mall.ware.entity.WareSkuEntity;
|
||||
import com.xjs.mall.ware.service.WareSkuService;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.mall.other.R;
|
||||
import com.xjs.validation.group.AddGroup;
|
||||
import com.xjs.validation.group.UpdateGroup;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商品库存
|
||||
*
|
||||
* @author xiejs
|
||||
* @email 1294405880@qq.com
|
||||
* @since 2022-03-15 09:56:19
|
||||
* @since 2022-03-15 09:56:19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("ware/waresku")
|
||||
|
|
@ -33,7 +37,7 @@ public class WareSkuController {
|
|||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("列表")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = wareSkuService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
|
|
@ -43,10 +47,10 @@ public class WareSkuController {
|
|||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
@GetMapping("/info/{id}")
|
||||
@ApiOperation("信息")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
WareSkuEntity wareSku = wareSkuService.getById(id);
|
||||
public R info(@PathVariable("id") Long id) {
|
||||
WareSkuEntity wareSku = wareSkuService.getById(id);
|
||||
|
||||
return R.ok().put("wareSku", wareSku);
|
||||
}
|
||||
|
|
@ -54,10 +58,11 @@ public class WareSkuController {
|
|||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@PostMapping("/save")
|
||||
@ApiOperation("保存")
|
||||
public R save(@RequestBody WareSkuEntity wareSku){
|
||||
wareSkuService.save(wareSku);
|
||||
@Log(title = "商品库存", businessType = BusinessType.INSERT)
|
||||
public R save(@Validated(AddGroup.class) @RequestBody WareSkuEntity wareSku) {
|
||||
wareSkuService.save(wareSku);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
|
@ -65,10 +70,11 @@ public class WareSkuController {
|
|||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("修改")
|
||||
public R update(@RequestBody WareSkuEntity wareSku){
|
||||
wareSkuService.updateById(wareSku);
|
||||
@Log(title = "商品库存", businessType = BusinessType.UPDATE)
|
||||
public R update(@Validated(UpdateGroup.class) @RequestBody WareSkuEntity wareSku) {
|
||||
wareSkuService.updateById(wareSku);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
|
@ -76,10 +82,11 @@ public class WareSkuController {
|
|||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
wareSkuService.removeByIds(Arrays.asList(ids));
|
||||
@Log(title = "商品库存", businessType = BusinessType.DELETE)
|
||||
public R delete(@RequestBody Long[] ids) {
|
||||
wareSkuService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,19 @@ package com.xjs.mall.ware.entity;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.xjs.validation.group.AddGroup;
|
||||
import com.xjs.validation.group.UpdateGroup;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品库存
|
||||
*
|
||||
*
|
||||
* @author xiejs
|
||||
* @email 1294405880@qq.com
|
||||
* @date 2022-03-15 09:56:19
|
||||
|
|
@ -17,32 +22,41 @@ import lombok.Data;
|
|||
@Data
|
||||
@TableName("wms_ware_sku")
|
||||
public class WareSkuEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* sku_id
|
||||
*/
|
||||
private Long skuId;
|
||||
/**
|
||||
* 仓库id
|
||||
*/
|
||||
private Long wareId;
|
||||
/**
|
||||
* 库存数
|
||||
*/
|
||||
private Integer stock;
|
||||
/**
|
||||
* sku_name
|
||||
*/
|
||||
private String skuName;
|
||||
/**
|
||||
* 锁定库存
|
||||
*/
|
||||
private Integer stockLocked;
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* sku_id
|
||||
*/
|
||||
@NotNull(message = "sku_id不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||
private Long skuId;
|
||||
/**
|
||||
* 仓库id
|
||||
*/
|
||||
@NotNull(message = "仓库id不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||
private Long wareId;
|
||||
/**
|
||||
* 库存数
|
||||
*/
|
||||
@NotNull(message = "库存数不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||
@Min(value = 0,message = "库存不能小于零",groups = {AddGroup.class,UpdateGroup.class})
|
||||
@Max(value = 9999999,message = "库存不能大于9999999",groups = {AddGroup.class,UpdateGroup.class})
|
||||
private Integer stock;
|
||||
/**
|
||||
* sku_name
|
||||
*/
|
||||
@NotBlank(message = "sku_name不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||
private String skuName;
|
||||
/**
|
||||
* 锁定库存
|
||||
*/
|
||||
@NotNull(message = "锁定库存不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||
@Min(value = 0,message = "锁定库存不能小于零",groups = {AddGroup.class,UpdateGroup.class})
|
||||
@Max(value = 9999999,message = "锁定库存不能大于9999999",groups = {AddGroup.class,UpdateGroup.class})
|
||||
private Integer stockLocked;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
package com.xjs.mall.ware.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.xjs.mall.ware.dao.PurchaseDetailDao;
|
||||
import com.xjs.mall.ware.entity.PurchaseDetailEntity;
|
||||
import com.xjs.mall.ware.service.PurchaseDetailService;
|
||||
|
|
@ -18,12 +19,23 @@ public class PurchaseDetailServiceImpl extends ServiceImpl<PurchaseDetailDao, Pu
|
|||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PurchaseDetailEntity> page = this.page(
|
||||
new Query<PurchaseDetailEntity>().getPage(params),
|
||||
new QueryWrapper<PurchaseDetailEntity>()
|
||||
);
|
||||
LambdaQueryWrapper<PurchaseDetailEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
String key = (String) params.get(Query.KEY_NAME);
|
||||
String status = (String) params.get("status");
|
||||
String wareId = (String) params.get("wareId");
|
||||
|
||||
wrapper.and(StringUtils.isNotEmpty(key), w -> {
|
||||
w.eq(PurchaseDetailEntity::getPurchaseId, key)
|
||||
.or()
|
||||
.eq(PurchaseDetailEntity::getSkuId, key);
|
||||
})
|
||||
.eq(StringUtils.isNotEmpty(status), PurchaseDetailEntity::getStatus, status)
|
||||
.eq(StringUtils.isNotEmpty(wareId), PurchaseDetailEntity::getWareId, wareId);
|
||||
|
||||
IPage<PurchaseDetailEntity> page = this.page(new Query<PurchaseDetailEntity>().getPage(params), wrapper);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,33 +4,55 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.core.utils.bean.BeanUtils;
|
||||
import com.xjs.mall.ware.dao.WareSkuDao;
|
||||
import com.xjs.mall.ware.entity.WareInfoEntity;
|
||||
import com.xjs.mall.ware.entity.WareSkuEntity;
|
||||
import com.xjs.mall.ware.service.WareInfoService;
|
||||
import com.xjs.mall.ware.service.WareSkuService;
|
||||
import com.xjs.mall.ware.vo.WareSkuVo;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.utils.Query;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service("wareSkuService")
|
||||
public class WareSkuServiceImpl extends ServiceImpl<WareSkuDao, WareSkuEntity> implements WareSkuService {
|
||||
|
||||
@Autowired
|
||||
private WareInfoService wareInfoService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
LambdaQueryWrapper<WareSkuEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
String key = (String) params.get(Query.KEY_NAME);
|
||||
if (StringUtils.isNotEmpty(key)) {
|
||||
wrapper.eq(WareSkuEntity::getSkuName, key).or()
|
||||
.eq(WareSkuEntity::getSkuId, key).or()
|
||||
.eq(WareSkuEntity::getWareId, key);
|
||||
}
|
||||
String skuId = (String) params.get("skuId");
|
||||
String wareId = (String) params.get("wareId");
|
||||
wrapper.like(StringUtils.isNotEmpty(key), WareSkuEntity::getSkuName, key).or()
|
||||
.eq(StringUtils.isNotEmpty(skuId), WareSkuEntity::getSkuId, skuId).or()
|
||||
.eq(StringUtils.isNotEmpty(wareId), WareSkuEntity::getWareId, wareId);
|
||||
|
||||
IPage<WareSkuEntity> page = this.page(new Query<WareSkuEntity>().getPage(params),wrapper);
|
||||
IPage<WareSkuEntity> page = this.page(new Query<WareSkuEntity>().getPage(params), wrapper);
|
||||
|
||||
return new PageUtils(page);
|
||||
List<Object> collect = page.getRecords().stream().map(wareSkuEntity -> {
|
||||
WareSkuVo wareSkuVo = new WareSkuVo();
|
||||
BeanUtils.copyProperties(wareSkuEntity,wareSkuVo);
|
||||
//获取仓库信息
|
||||
WareInfoEntity wareInfoEntity = wareInfoService.getById(wareSkuVo.getWareId());
|
||||
wareSkuVo.setWareName(wareInfoEntity.getName());
|
||||
return wareSkuVo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
PageUtils pageUtils = new PageUtils(page);
|
||||
pageUtils.setList(collect);
|
||||
|
||||
return pageUtils;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
package com.xjs.mall.ware.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商品库存vo
|
||||
* @author xiejs
|
||||
* @since 2022-03-23
|
||||
*/
|
||||
@Data
|
||||
public class WareSkuVo {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* sku_id
|
||||
*/
|
||||
private Long skuId;
|
||||
/**
|
||||
* 仓库id
|
||||
*/
|
||||
private Long wareId;
|
||||
/**
|
||||
* 库存数
|
||||
*/
|
||||
private Integer stock;
|
||||
/**
|
||||
* sku_name
|
||||
*/
|
||||
private String skuName;
|
||||
/**
|
||||
* 锁定库存
|
||||
*/
|
||||
private Integer stockLocked;
|
||||
|
||||
/**
|
||||
* 仓库名称
|
||||
*/
|
||||
private String wareName;
|
||||
}
|
||||
Loading…
Reference in New Issue