1、仓库库存功能实现

pull/254/head
xjs 4 years ago
parent 28b064ba8e
commit 77e3e32585

@ -1,5 +1,6 @@
<template> <template>
<el-dialog <el-dialog
width="500px"
:title="!dataForm.id ? '新增' : '修改'" :title="!dataForm.id ? '新增' : '修改'"
:close-on-click-modal="false" :close-on-click-modal="false"
:visible.sync="visible" :visible.sync="visible"
@ -9,10 +10,10 @@
:rules="dataRule" :rules="dataRule"
ref="dataForm" ref="dataForm"
@keyup.enter.native="dataFormSubmit()" @keyup.enter.native="dataFormSubmit()"
label-width="120px" label-width="90px"
> >
<el-form-item label="sku_id" prop="skuId"> <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>
<el-form-item label="仓库" prop="wareId"> <el-form-item label="仓库" prop="wareId">
<el-select v-model="dataForm.wareId" placeholder="请选择仓库" clearable> <el-select v-model="dataForm.wareId" placeholder="请选择仓库" clearable>
@ -20,13 +21,13 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="库存数" prop="stock"> <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>
<el-form-item label="sku_name" prop="skuName"> <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>
<el-form-item label="锁定库存" prop="stockLocked"> <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-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
@ -37,7 +38,11 @@
</template> </template>
<script> <script>
import {getWareInfoList} from "@/api/mall/ware/ware-info";
import {editWareSku, getWareSku, saveWareSku} from "@/api/mall/ware/ware-sku";
export default { export default {
name: "WareSku-add-or-update",
data() { data() {
return { return {
visible: false, visible: false,
@ -66,72 +71,49 @@ export default {
this.getWares(); this.getWares();
}, },
methods: { methods: {
//
getWares() { getWares() {
this.$http({ let params = {
url: this.$http.adornUrl("/ware/wareinfo/list"),
method: "get",
params: this.$http.adornParams({
page: 1, page: 1,
limit: 500 limit: 500
}
getWareInfoList(params).then(res => {
this.wareList = res.page.list;
}) })
}).then(({ data }) => {
this.wareList = data.page.list;
});
}, },
init(id) { init(id) {
this.dataForm.id = id || 0; this.dataForm.id = id;
this.visible = true; this.visible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs["dataForm"].resetFields(); this.$refs["dataForm"].resetFields();
if (this.dataForm.id) { if (this.dataForm.id) {
this.$http({ getWareSku(this.dataForm.id).then(res => {
url: this.$http.adornUrl(`/ware/waresku/info/${this.dataForm.id}`), this.dataForm = res.wareSku
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;
}
});
} }
}); });
}, },
// //
dataFormSubmit() { dataFormSubmit() {
this.$refs["dataForm"].validate(valid => { this.$refs["dataForm"].validate(valid => {
if (valid) { if (valid) {
this.$http({
url: this.$http.adornUrl( if (!this.dataForm.id) {
`/ware/waresku/${!this.dataForm.id ? "save" : "update"}` saveWareSku(this.dataForm).then(res => {
), this.$modal.notifySuccess("保存成功")
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
})
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => {
this.visible = false; this.visible = false;
this.$emit("refreshDataList"); this.$emit("refreshDataList");
} })
});
} else { } else {
this.$message.error(data.msg); editWareSku(this.dataForm).then(res => {
this.$modal.notifySuccess("修改成功")
this.visible = false;
this.$emit("refreshDataList");
})
} }
});
} }
}); });
} }

@ -18,7 +18,9 @@
type="danger" type="danger"
@click="deleteHandle()" @click="deleteHandle()"
:disabled="dataListSelections.length <= 0" :disabled="dataListSelections.length <= 0"
>批量删除</el-button> >批量删除
</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-button-group> </el-button-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -31,7 +33,7 @@
> >
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column> <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="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="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="skuName" header-align="center" align="center" label="商品名称"></el-table-column>
<el-table-column prop="stockLocked" header-align="center" align="center" label="锁定库存"></el-table-column> <el-table-column prop="stockLocked" header-align="center" align="center" label="锁定库存"></el-table-column>
@ -58,6 +60,9 @@
<script> <script>
import AddOrUpdate from "./waresku-add-or-update"; 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 { export default {
name: "WareSku", name: "WareSku",
data() { data() {
@ -80,7 +85,6 @@ export default {
AddOrUpdate AddOrUpdate
}, },
created() { created() {
console.log("接收到", this.$route.query.skuId);
if (this.$route.query.skuId) { if (this.$route.query.skuId) {
this.dataForm.skuId = this.$route.query.skuId; this.dataForm.skuId = this.$route.query.skuId;
} }
@ -88,41 +92,34 @@ export default {
this.getDataList(); this.getDataList();
}, },
methods: { methods: {
//
getWares() { getWares() {
this.$http({ let params = {
url: this.$http.adornUrl("/ware/wareinfo/list"),
method: "get",
params: this.$http.adornParams({
page: 1, page: 1,
limit: 500 limit: 500
}
getWareInfoList(params).then(res => {
this.wareList = res.page.list;
}) })
}).then(({ data }) => {
this.wareList = data.page.list;
});
}, },
// //
getDataList() { getDataList() {
this.dataListLoading = true; this.dataListLoading = true;
this.$http({ let params = {
url: this.$http.adornUrl("/ware/waresku/list"),
method: "get",
params: this.$http.adornParams({
page: this.pageIndex, page: this.pageIndex,
limit: this.pageSize, limit: this.pageSize,
skuId: this.dataForm.skuId, skuId: this.dataForm.skuId,
wareId: this.dataForm.wareId 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;
} }
getWareSkuList(params).then(res => {
this.dataList = res.page.list;
this.totalPage = res.page.totalCount;
this.dataListLoading = false; this.dataListLoading = false;
}); })
}, },
// //
sizeChangeHandle(val) { sizeChangeHandle(val) {
this.pageSize = val; this.pageSize = val;
@ -147,9 +144,7 @@ export default {
}, },
// //
deleteHandle(id) { deleteHandle(id) {
var ids = id var ids = id ? [id] : this.dataListSelections.map(item => {
? [id]
: this.dataListSelections.map(item => {
return item.id; return item.id;
}); });
this.$confirm( this.$confirm(
@ -161,26 +156,21 @@ export default {
type: "warning" type: "warning"
} }
).then(() => { ).then(() => {
this.$http({
url: this.$http.adornUrl("/ware/waresku/delete"), delWareSku(ids).then(res => {
method: "post", this.$modal.notifySuccess("删除成功")
data: this.$http.adornData(ids, false)
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => {
this.getDataList(); this.getDataList();
} })
});
} else {
this.$message.error(data.msg);
}
});
}); });
} },
/** 重置按钮操作 */
resetQuery() {
this.dataForm = {}
this.pageIndex = 1;
this.getDataList();
},
} }
}; };
</script> </script>

@ -1,9 +1,13 @@
package com.xjs.mall.ware.controller; 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.entity.PurchaseDetailEntity;
import com.xjs.mall.ware.service.PurchaseDetailService; import com.xjs.mall.ware.service.PurchaseDetailService;
import com.xjs.utils.PageUtils; import com.xjs.utils.PageUtils;
import com.xjs.mall.other.R; 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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -11,16 +15,16 @@ import java.util.Arrays;
import java.util.Map; import java.util.Map;
/** /**
* *
* *
* @author xiejs * @author xiejs
* @email 1294405880@qq.com * @email 1294405880@qq.com
* @date 2022-03-15 09:56:19 * @since 2022-03-15 09:56:19
*/ */
@RestController @RestController
@RequestMapping("ware/purchasedetail") @RequestMapping("ware/purchasedetail")
@Api(tags = "商城-仓库-采购需求")
public class PurchaseDetailController { public class PurchaseDetailController {
@Autowired @Autowired
private PurchaseDetailService purchaseDetailService; private PurchaseDetailService purchaseDetailService;
@ -28,7 +32,8 @@ public class PurchaseDetailController {
/** /**
* *
*/ */
@RequestMapping("/list") @GetMapping("/list")
@ApiOperation("列表")
public R list(@RequestParam Map<String, Object> params) { public R list(@RequestParam Map<String, Object> params) {
PageUtils page = purchaseDetailService.queryPage(params); PageUtils page = purchaseDetailService.queryPage(params);
@ -40,6 +45,7 @@ public class PurchaseDetailController {
* *
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
@ApiOperation("信息")
public R info(@PathVariable("id") Long id) { public R info(@PathVariable("id") Long id) {
PurchaseDetailEntity purchaseDetail = purchaseDetailService.getById(id); PurchaseDetailEntity purchaseDetail = purchaseDetailService.getById(id);
@ -50,6 +56,8 @@ public class PurchaseDetailController {
* *
*/ */
@RequestMapping("/save") @RequestMapping("/save")
@ApiOperation("保存")
@Log(title = "采购需求", businessType = BusinessType.INSERT)
public R save(@RequestBody PurchaseDetailEntity purchaseDetail) { public R save(@RequestBody PurchaseDetailEntity purchaseDetail) {
purchaseDetailService.save(purchaseDetail); purchaseDetailService.save(purchaseDetail);
@ -60,6 +68,8 @@ public class PurchaseDetailController {
* *
*/ */
@RequestMapping("/update") @RequestMapping("/update")
@ApiOperation("修改")
@Log(title = "采购需求", businessType = BusinessType.UPDATE)
public R update(@RequestBody PurchaseDetailEntity purchaseDetail) { public R update(@RequestBody PurchaseDetailEntity purchaseDetail) {
purchaseDetailService.updateById(purchaseDetail); purchaseDetailService.updateById(purchaseDetail);
@ -70,6 +80,8 @@ public class PurchaseDetailController {
* *
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
@ApiOperation("删除")
@Log(title = "采购需求", businessType = BusinessType.DELETE)
public R delete(@RequestBody Long[] ids) { public R delete(@RequestBody Long[] ids) {
purchaseDetailService.removeByIds(Arrays.asList(ids)); purchaseDetailService.removeByIds(Arrays.asList(ids));

@ -1,5 +1,7 @@
package com.xjs.mall.ware.controller; 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.business.api.domain.Area;
import com.xjs.mall.other.R; import com.xjs.mall.other.R;
import com.xjs.mall.ware.entity.WareInfoEntity; import com.xjs.mall.ware.entity.WareInfoEntity;
@ -76,6 +78,7 @@ public class WareInfoController extends MyBaseController<WareInfoEntity> {
*/ */
@PostMapping("/save") @PostMapping("/save")
@ApiOperation("保存") @ApiOperation("保存")
@Log(title = "仓库信息", businessType = BusinessType.INSERT)
public R save(@Validated(AddGroup.class) @RequestBody WareInfoEntity wareInfo) { public R save(@Validated(AddGroup.class) @RequestBody WareInfoEntity wareInfo) {
wareInfoService.save(wareInfo); wareInfoService.save(wareInfo);
@ -87,6 +90,7 @@ public class WareInfoController extends MyBaseController<WareInfoEntity> {
*/ */
@PutMapping("/update") @PutMapping("/update")
@ApiOperation("修改") @ApiOperation("修改")
@Log(title = "仓库信息", businessType = BusinessType.UPDATE)
public R update(@Validated(UpdateGroup.class)@RequestBody WareInfoEntity wareInfo) { public R update(@Validated(UpdateGroup.class)@RequestBody WareInfoEntity wareInfo) {
wareInfoService.updateById(wareInfo); wareInfoService.updateById(wareInfo);
@ -98,6 +102,7 @@ public class WareInfoController extends MyBaseController<WareInfoEntity> {
*/ */
@DeleteMapping("/delete") @DeleteMapping("/delete")
@ApiOperation("删除") @ApiOperation("删除")
@Log(title = "仓库信息", businessType = BusinessType.DELETE)
public R delete(@RequestBody Long[] ids) { public R delete(@RequestBody Long[] ids) {
wareInfoService.removeByIds(Arrays.asList(ids)); wareInfoService.removeByIds(Arrays.asList(ids));

@ -1,19 +1,23 @@
package com.xjs.mall.ware.controller; 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.entity.WareSkuEntity;
import com.xjs.mall.ware.service.WareSkuService; import com.xjs.mall.ware.service.WareSkuService;
import com.xjs.utils.PageUtils; import com.xjs.utils.PageUtils;
import com.xjs.mall.other.R; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
/** /**
* *
* *
@ -43,7 +47,7 @@ public class WareSkuController {
/** /**
* *
*/ */
@RequestMapping("/info/{id}") @GetMapping("/info/{id}")
@ApiOperation("信息") @ApiOperation("信息")
public R info(@PathVariable("id") Long id) { public R info(@PathVariable("id") Long id) {
WareSkuEntity wareSku = wareSkuService.getById(id); WareSkuEntity wareSku = wareSkuService.getById(id);
@ -54,9 +58,10 @@ public class WareSkuController {
/** /**
* *
*/ */
@RequestMapping("/save") @PostMapping("/save")
@ApiOperation("保存") @ApiOperation("保存")
public R save(@RequestBody WareSkuEntity wareSku){ @Log(title = "商品库存", businessType = BusinessType.INSERT)
public R save(@Validated(AddGroup.class) @RequestBody WareSkuEntity wareSku) {
wareSkuService.save(wareSku); wareSkuService.save(wareSku);
return R.ok(); return R.ok();
@ -65,9 +70,10 @@ public class WareSkuController {
/** /**
* *
*/ */
@RequestMapping("/update") @PutMapping("/update")
@ApiOperation("修改") @ApiOperation("修改")
public R update(@RequestBody WareSkuEntity wareSku){ @Log(title = "商品库存", businessType = BusinessType.UPDATE)
public R update(@Validated(UpdateGroup.class) @RequestBody WareSkuEntity wareSku) {
wareSkuService.updateById(wareSku); wareSkuService.updateById(wareSku);
return R.ok(); return R.ok();
@ -76,8 +82,9 @@ public class WareSkuController {
/** /**
* *
*/ */
@RequestMapping("/delete") @DeleteMapping("/delete")
@ApiOperation("删除") @ApiOperation("删除")
@Log(title = "商品库存", businessType = BusinessType.DELETE)
public R delete(@RequestBody Long[] ids) { public R delete(@RequestBody Long[] ids) {
wareSkuService.removeByIds(Arrays.asList(ids)); wareSkuService.removeByIds(Arrays.asList(ids));

@ -2,10 +2,15 @@ package com.xjs.mall.ware.entity;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
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; import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/** /**
* *
@ -27,22 +32,31 @@ public class WareSkuEntity implements Serializable {
/** /**
* sku_id * sku_id
*/ */
@NotNull(message = "sku_id不能为空", groups = {AddGroup.class, UpdateGroup.class})
private Long skuId; private Long skuId;
/** /**
* id * id
*/ */
@NotNull(message = "仓库id不能为空", groups = {AddGroup.class, UpdateGroup.class})
private Long wareId; 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; private Integer stock;
/** /**
* sku_name * sku_name
*/ */
@NotBlank(message = "sku_name不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String skuName; 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; private Integer stockLocked;
} }

@ -1,8 +1,9 @@
package com.xjs.mall.ware.service.impl; 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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.dao.PurchaseDetailDao;
import com.xjs.mall.ware.entity.PurchaseDetailEntity; import com.xjs.mall.ware.entity.PurchaseDetailEntity;
import com.xjs.mall.ware.service.PurchaseDetailService; import com.xjs.mall.ware.service.PurchaseDetailService;
@ -18,10 +19,21 @@ public class PurchaseDetailServiceImpl extends ServiceImpl<PurchaseDetailDao, Pu
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
IPage<PurchaseDetailEntity> page = this.page( LambdaQueryWrapper<PurchaseDetailEntity> wrapper = new LambdaQueryWrapper<>();
new Query<PurchaseDetailEntity>().getPage(params),
new QueryWrapper<PurchaseDetailEntity>() 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); 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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.utils.StringUtils; 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.dao.WareSkuDao;
import com.xjs.mall.ware.entity.WareInfoEntity;
import com.xjs.mall.ware.entity.WareSkuEntity; 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.service.WareSkuService;
import com.xjs.mall.ware.vo.WareSkuVo;
import com.xjs.utils.PageUtils; import com.xjs.utils.PageUtils;
import com.xjs.utils.Query; import com.xjs.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
@Service("wareSkuService") @Service("wareSkuService")
public class WareSkuServiceImpl extends ServiceImpl<WareSkuDao, WareSkuEntity> implements WareSkuService { public class WareSkuServiceImpl extends ServiceImpl<WareSkuDao, WareSkuEntity> implements WareSkuService {
@Autowired
private WareInfoService wareInfoService;
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
LambdaQueryWrapper<WareSkuEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<WareSkuEntity> wrapper = new LambdaQueryWrapper<>();
String key = (String) params.get(Query.KEY_NAME); String key = (String) params.get(Query.KEY_NAME);
if (StringUtils.isNotEmpty(key)) { String skuId = (String) params.get("skuId");
wrapper.eq(WareSkuEntity::getSkuName, key).or() String wareId = (String) params.get("wareId");
.eq(WareSkuEntity::getSkuId, key).or() wrapper.like(StringUtils.isNotEmpty(key), WareSkuEntity::getSkuName, key).or()
.eq(WareSkuEntity::getWareId, key); .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…
Cancel
Save