开发订单查询

This commit is contained in:
yovinchen 2024-01-30 16:06:23 +08:00
parent c01d765e90
commit ecfc4546d9
10 changed files with 273 additions and 127 deletions

16
.idea/GrepConsole.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GrepConsole">
<option name="tailHistory">
<TailHistory>
<option name="items">
<set>
<TailItem>
<option name="path" value="$PROJECT_DIR$/README.md" />
</TailItem>
</set>
</option>
</TailHistory>
</option>
</component>
</project>

View File

@ -1,11 +1,10 @@
import Vue from 'vue' import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
Vue.use(Router)
/* Layout */ /* Layout */
import Layout from '@/layout' import Layout from '@/layout'
Vue.use(Router)
/** /**
* Note: sub-menu only appear when route children.length >= 1 * Note: sub-menu only appear when route children.length >= 1
* Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
@ -315,20 +314,20 @@ export const constantRoutes = [
component: Layout, component: Layout,
redirect: '/user/leader/list', redirect: '/user/leader/list',
name: 'Leader', name: 'Leader',
meta: { title: '团长管理', icon: 'table' }, meta: {title: '配送员管理', icon: 'table'},
alwaysShow: true, alwaysShow: true,
children: [ children: [
{ {
path: 'leader/checkList', path: 'leader/checkList',
name: 'LeaderCheck', name: 'LeaderCheck',
component: () => import('@/views/user/leader/checkList'), component: () => import('@/views/user/leader/checkList'),
meta: { title: '团长待审核' } meta: {title: '配送员待审核'}
}, },
{ {
path: 'leader/list', path: 'leader/list',
name: 'leader', name: 'leader',
component: () => import('@/views/user/leader/list'), component: () => import('@/views/user/leader/list'),
meta: { title: '团长已审核' } meta: {title: '配送员已审核'}
} }
] ]
}, },

View File

@ -3,41 +3,41 @@
<!-- 工具条 --> <!-- 工具条 -->
<div class="tools-div"> <div class="tools-div">
<el-button type="success" icon="el-icon-plus" size="mini" @click="add()"> </el-button> <el-button icon="el-icon-plus" size="mini" type="success" @click="add()"> </el-button>
</div> </div>
<el-table <el-table
:data="sysMenuList" :data="sysMenuList"
style="width: 100%;margin-bottom: 20px;margin-top: 10px;"
row-key="id"
border
:default-expand-all="false" :default-expand-all="false"
:tree-props="{children: 'children'}" :tree-props="{children: 'children'}"
border
row-key="id"
style="width: 100%;margin-bottom: 20px;margin-top: 10px;"
> >
<el-table-column prop="name" label="菜单名称" width="200" /> <el-table-column label="菜单名称" prop="name" width="200"/>
<el-table-column prop="code" label="权限标识" width="180" /> <el-table-column label="权限标识" prop="code" width="180"/>
<el-table-column prop="createTime" label="创建时间" width="200" /> <el-table-column label="创建时间" prop="createTime" width="200"/>
<el-table-column prop="updateTime" label="修改时间" width="200" /> <el-table-column label="修改时间" prop="updateTime" width="200"/>
<el-table-column label="操作" align="center"> <el-table-column align="center" label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-if="scope.row.type !== 2" v-if="scope.row.type !== 2"
type="success"
icon="el-icon-plus" icon="el-icon-plus"
size="mini" size="mini"
title="添加下级节点" title="添加下级节点"
type="success"
@click="add(scope.row)" @click="add(scope.row)"
/> />
<el-button type="primary" icon="el-icon-edit" size="mini" title="修改" @click="edit(scope.row)" /> <el-button icon="el-icon-edit" size="mini" title="修改" type="primary" @click="edit(scope.row)"/>
<el-button <el-button
type="danger" :disabled="scope.row.children.length > 0"
icon="el-icon-delete" icon="el-icon-delete"
size="mini" size="mini"
title="删除" title="删除"
:disabled="scope.row.children.length > 0" type="danger"
@click="removeDataById(scope.row.id)" @click="removeDataById(scope.row.id)"
/> />
</template> </template>
@ -47,36 +47,36 @@
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="40%"> <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="40%">
<el-form ref="dataForm" :model="sysMenu" label-width="150px" size="small" style="padding-right: 40px;"> <el-form ref="dataForm" :model="sysMenu" label-width="150px" size="small" style="padding-right: 40px;">
<el-form-item v-if="sysMenu.id === ''" label="上级部门"> <el-form-item v-if="sysMenu.id === ''" label="上级部门">
<el-input v-model="sysMenu.parentName" disabled="true" /> <el-input v-model="sysMenu.parentName" disabled="true"/>
</el-form-item> </el-form-item>
<el-form-item label="菜单类型" prop="type"> <el-form-item label="菜单类型" prop="type">
<el-radio-group v-model="sysMenu.type" :disabled="typeDisabled"> <el-radio-group v-model="sysMenu.type" :disabled="typeDisabled">
<el-radio :label="0" :disabled="type0Disabled">目录</el-radio> <el-radio :disabled="type0Disabled" :label="0">目录</el-radio>
<el-radio :label="1" :disabled="type1Disabled">菜单</el-radio> <el-radio :disabled="type1Disabled" :label="1">菜单</el-radio>
<el-radio :label="2" :disabled="type2Disabled">按钮</el-radio> <el-radio :disabled="type2Disabled" :label="2">按钮</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="菜单名称" prop="name"> <el-form-item label="菜单名称" prop="name">
<el-input v-model="sysMenu.name" /> <el-input v-model="sysMenu.name"/>
</el-form-item> </el-form-item>
<el-form-item v-if="sysMenu.type !== 0" prop="to_code"> <el-form-item v-if="sysMenu.type !== 0" prop="to_code">
<span slot="label"> <span slot="label">
<el-tooltip content="访问的组件路径,如:`system/user/index`,默认在`views`目录下" placement="top"> <el-tooltip content="访问的组件路径,如:`system/user/index`,默认在`views`目录下" placement="top">
<i class="el-icon-question" /> <i class="el-icon-question"/>
</el-tooltip> </el-tooltip>
组件路径 组件路径
</span> </span>
<el-input v-model="sysMenu.to_code" placeholder="请输入组件路径" /> <el-input v-model="sysMenu.to_code" placeholder="请输入组件路径"/>
</el-form-item> </el-form-item>
<el-form-item v-if="sysMenu.type === 2"> <el-form-item v-if="sysMenu.type === 2">
<el-input v-model="sysMenu.code" placeholder="请输入权限标识" maxlength="100" /> <el-input v-model="sysMenu.code" maxlength="100" placeholder="请输入权限标识"/>
<span slot="label"> <span slot="label">
<el-tooltip <el-tooltip
content="控制器中定义的权限字符,如:@PreAuthorize(hasAuthority('bnt.sysRole.list'))" content="控制器中定义的权限字符,如:@PreAuthorize(hasAuthority('bnt.sysRole.list'))"
placement="top" placement="top"
> >
<i class="el-icon-question" /> <i class="el-icon-question"/>
</el-tooltip> </el-tooltip>
权限字符 权限字符
</span> </span>
@ -84,8 +84,8 @@
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button size="small" icon="el-icon-refresh-right" @click="dialogVisible = false"> </el-button> <el-button icon="el-icon-refresh-right" size="small" @click="dialogVisible = false"> </el-button>
<el-button type="primary" icon="el-icon-check" size="small" @click="saveOrUpdate()"> </el-button> <el-button icon="el-icon-check" size="small" type="primary" @click="saveOrUpdate()"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>

View File

@ -3,12 +3,12 @@
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<div style="margin-top: 15px"> <div style="margin-top: 15px">
<el-form :inline="true" size="small" label-width="140px"> <el-form :inline="true" label-width="140px" size="small">
<el-form-item label="输入搜索:"> <el-form-item label="输入搜索:">
<el-input v-model="tempSearchObj.roleName" style="width: 203px" placeholder="角色名称" /> <el-input v-model="tempSearchObj.roleName" placeholder="角色名称" style="width: 203px"/>
</el-form-item> </el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button> <el-button icon="el-icon-search" type="primary" @click="search()">查询</el-button>
<el-button type="default" @click="resetSearch()">清空</el-button> <el-button type="default" @click="resetSearch()">清空</el-button>
</el-form> </el-form>
</div> </div>
@ -16,14 +16,14 @@
<!-- 工具条 --> <!-- 工具条 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets" style="margin-top: 5px" /> <i class="el-icon-tickets" style="margin-top: 5px"/>
<span style="margin-top: 5px">数据列表</span> <span style="margin-top: 5px">数据列表</span>
<el-button class="btn-add" size="mini" @click="addRole">添加</el-button> <el-button class="btn-add" size="mini" @click="addRole">添加</el-button>
<el-button <el-button
:disabled="selectedRoles.length === 0"
class="btn-add" class="btn-add"
size="mini" size="mini"
:disabled="selectedRoles.length === 0"
style="margin: 0 10px;" style="margin: 0 10px;"
@click="removeRoles()" @click="removeRoles()"
>批量删除 >批量删除
@ -32,9 +32,9 @@
<el-table <el-table
v-loading="listLoading" v-loading="listLoading"
:data="roles"
border border
stripe stripe
:data="roles"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
> >
@ -44,20 +44,20 @@
/> />
<el-table-column <el-table-column
type="index"
label="序号"
width="100"
align="center" align="center"
label="序号"
type="index"
width="100"
/> />
<el-table-column label="角色名称" width="500" align="center"> <el-table-column align="center" label="角色名称" width="500">
<template slot-scope="{row}"> <template slot-scope="{row}">
<template v-if="row.edit"> <template v-if="row.edit">
<el-input v-model="row.roleName" class="edit-input" size="small" /> <el-input v-model="row.roleName" class="edit-input" size="small"/>
<el-button <el-button
class="cancel-btn" class="cancel-btn"
size="small"
icon="el-icon-refresh" icon="el-icon-refresh"
size="small"
type="warning" type="warning"
@click="cancelEdit(row)" @click="cancelEdit(row)"
> >
@ -68,37 +68,37 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center"> <el-table-column align="center" label="操作">
<template slot-scope="{row}"> <template slot-scope="{row}">
<HintButton <HintButton
size="mini"
type="info"
icon="el-icon-info" icon="el-icon-info"
size="mini"
title="分配权限" title="分配权限"
type="info"
@click="$router.push(`/acl/role/auth/${row.id}?roleName=${row.roleName}`)" @click="$router.push(`/acl/role/auth/${row.id}?roleName=${row.roleName}`)"
/> />
<HintButton <HintButton
v-if="row.edit" v-if="row.edit"
size="mini"
type="primary"
icon="el-icon-check" icon="el-icon-check"
size="mini"
title="确定" title="确定"
type="primary"
@click="updateRole(row)" @click="updateRole(row)"
/> />
<HintButton <HintButton
v-if="!row.edit" v-if="!row.edit"
size="mini"
type="primary"
icon="el-icon-edit" icon="el-icon-edit"
size="mini"
title="修改角色" title="修改角色"
type="primary"
@click="row.edit= true" @click="row.edit= true"
/> />
<HintButton <HintButton
size="mini"
type="danger"
icon="el-icon-delete" icon="el-icon-delete"
size="mini"
title="删除角色" title="删除角色"
type="danger"
@click="removeRole(row)" @click="removeRole(row)"
/> />
</template> </template>
@ -108,11 +108,11 @@
<!-- 分页组件 --> <!-- 分页组件 -->
<el-pagination <el-pagination
:current-page="page" :current-page="page"
:total="total"
:page-size="limit" :page-size="limit"
:page-sizes="[5, 10, 20]" :page-sizes="[5, 10, 20]"
style="padding: 10px;" :total="total"
layout="prev, pager, next, jumper, ->, sizes, total" layout="prev, pager, next, jumper, ->, sizes, total"
style="padding: 10px;"
@current-change="getRoles" @current-change="getRoles"
@size-change="handleSizeChange" @size-change="handleSizeChange"
/> />
@ -161,7 +161,7 @@ export default {
更新角色 更新角色
*/ */
updateRole(role) { updateRole(role) {
this.$API.role.updateById({ id: role.id, roleName: role.roleName }) this.$API.role.updateById({id: role.id, roleName: role.roleName})
.then(result => { .then(result => {
this.$message.success(result.message || '更新角色成功!') this.$message.success(result.message || '更新角色成功!')
this.getRoles(this.page) this.getRoles(this.page)
@ -184,8 +184,8 @@ export default {
this.$prompt('请输入新名称', '添加角色', { this.$prompt('请输入新名称', '添加角色', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消' cancelButtonText: '取消'
}).then(({ value }) => { }).then(({value}) => {
this.$API.role.save({ roleName: value }).then(result => { this.$API.role.save({roleName: value}).then(result => {
this.$message.success(result.message || '添加角色成功') this.$message.success(result.message || '添加角色成功')
this.getRoles() this.getRoles()
}) })
@ -200,10 +200,10 @@ export default {
getRoles(page = 1) { getRoles(page = 1) {
this.page = page this.page = page
this.listLoading = true this.listLoading = true
const { limit, searchObj } = this const {limit, searchObj} = this
this.$API.role.getPageList(page, limit, searchObj).then( this.$API.role.getPageList(page, limit, searchObj).then(
result => { result => {
const { records, total } = result.data const {records, total} = result.data
this.roles = records.map(item => { this.roles = records.map(item => {
item.edit = false // item.edit = false //
item.originRoleName = item.roleName // , item.originRoleName = item.roleName // ,
@ -220,7 +220,7 @@ export default {
根据搜索条件进行搜索 根据搜索条件进行搜索
*/ */
search() { search() {
this.searchObj = { ...this.tempSearchObj } this.searchObj = {...this.tempSearchObj}
this.getRoles() this.getRoles()
}, },
@ -240,10 +240,10 @@ export default {
/* /*
删除指定的角色 删除指定的角色
*/ */
removeRole({ id, roleName }) { removeRole({id, roleName}) {
this.$confirm(`确定删除 '${roleName}' 吗?`, '提示', { this.$confirm(`确定删除 '${roleName}' 吗?`, '提示', {
type: 'warning' type: 'warning'
}).then(async() => { }).then(async () => {
const result = await this.$API.role.removeById(id) const result = await this.$API.role.removeById(id)
this.getRoles(this.roles.length === 1 ? this.page - 1 : this.page) this.getRoles(this.roles.length === 1 ? this.page - 1 : this.page)
this.$message.success(result.message || '删除成功!') this.$message.success(result.message || '删除成功!')
@ -265,7 +265,7 @@ export default {
removeRoles() { removeRoles() {
this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', { this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
type: 'warning' type: 'warning'
}).then(async() => { }).then(async () => {
const ids = this.selectedRoles.map(role => role.id) const ids = this.selectedRoles.map(role => role.id)
const result = await this.$API.role.removeRoles(ids) const result = await this.$API.role.removeRoles(ids)
this.getRoles() this.getRoles()

View File

@ -10,7 +10,7 @@
> >
<div class="title-container"> <div class="title-container">
<h3 class="title">购物商城管理端</h3> <h3 class="title">小鹿超市管理端</h3>
</div> </div>
<el-form-item prop="username"> <el-form-item prop="username">

View File

@ -25,7 +25,7 @@ public class CodeGet {
// 2全局配置 // 2全局配置
// 全局配置 // 全局配置
GlobalConfig gc = new GlobalConfig(); GlobalConfig gc = new GlobalConfig();
gc.setOutputDir("xlcs-parent/service/service-acl" + "/src/main/java"); gc.setOutputDir("xlcs-parent/service/service-user" + "/src/main/java");
gc.setServiceName("%sService"); //去掉Service接口的首字母I gc.setServiceName("%sService"); //去掉Service接口的首字母I
gc.setAuthor("yovinchen"); gc.setAuthor("yovinchen");
@ -34,17 +34,17 @@ public class CodeGet {
// 3数据源配置 // 3数据源配置
DataSourceConfig dsc = new DataSourceConfig(); DataSourceConfig dsc = new DataSourceConfig();
dsc.setUrl("jdbc:mysql://82.157.68.223:3306/shequ-acl?serverTimezone=GMT%2B8&useSSL=false"); dsc.setUrl("jdbc:mysql://82.157.68.223:3306/shequ-user?serverTimezone=GMT%2B8&useSSL=false");
dsc.setDriverName("com.mysql.cj.jdbc.Driver"); dsc.setDriverName("com.mysql.cj.jdbc.Driver");
dsc.setUsername("shequ-acl"); dsc.setUsername("shequ-user");
dsc.setPassword("shequ-acl"); dsc.setPassword("shequ-user");
dsc.setDbType(DbType.MYSQL); dsc.setDbType(DbType.MYSQL);
mpg.setDataSource(dsc); mpg.setDataSource(dsc);
// 4包配置 // 4包配置
PackageConfig pc = new PackageConfig(); PackageConfig pc = new PackageConfig();
pc.setParent("com.yovinchen.xlcs"); pc.setParent("com.yovinchen.xlcs");
pc.setModuleName("acl"); //模块名 pc.setModuleName("user"); //模块名
pc.setController("controller"); pc.setController("controller");
pc.setService("service"); pc.setService("service");
pc.setMapper("mapper"); pc.setMapper("mapper");
@ -53,7 +53,7 @@ public class CodeGet {
// 5策略配置 // 5策略配置
StrategyConfig strategy = new StrategyConfig(); StrategyConfig strategy = new StrategyConfig();
strategy.setInclude("role_permission", "admin_login_log"); strategy.setInclude("driver", "leader", "leader_account", "leader_bank", "leader_bill", "leader_user", "region", "user_delivery", "user_login_log");
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略 strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略

View File

@ -0,0 +1,56 @@
package com.yovinchen.xlcs.order.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yovinchen.xlcs.common.result.Result;
import com.yovinchen.xlcs.model.order.OrderInfo;
import com.yovinchen.xlcs.order.service.OrderInfoService;
import com.yovinchen.xlcs.vo.order.OrderQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* ClassName: OrderInfoAdminController
* Package: com.yovinchen.xlcs.order.controller
*
* @author yovinchen
* @since 2024/1/30 10:47
*/
@Api(value = "订单管理", tags = "订单管理")
@RestController
@RequestMapping("/admin/order/orderInfo")
public class OrderInfoAdminController {
@Autowired
private OrderInfoService orderInfoService;
@ApiOperation(value = "获取订单分页列表")
@GetMapping("{page}/{limit}")
public Result<IPage<OrderInfo>> index(@ApiParam(name = "page", value = "当前页码", required = true) @PathVariable Long page, @ApiParam(name = "limit", value = "每页记录数", required = true) @PathVariable Long limit, @ApiParam(name = "OrderQueryVo", value = "查询对象", required = false) OrderQueryVo orderQueryVo) {
try {
Page<OrderInfo> pageParam = new Page<>(page, limit);
IPage<OrderInfo> pageModel = orderInfoService.selectPage(pageParam, orderQueryVo);
return Result.ok(pageModel);
} catch (Exception e) {
throw new RuntimeException("获取sku分页列表异常", e);
}
}
@ApiOperation("获取订单详情信息")
@GetMapping("get/{orderId}")
public Result<OrderInfo> show(@ApiParam(name = "orderNo", value = "订单id", readOnly = true) @PathVariable Long orderId) {
try {
OrderInfo orderInfo = orderInfoService.getOrderInfoById(orderId);
return Result.ok(orderInfo);
} catch (Exception e) {
throw new RuntimeException("获取订单详情信息异常", e);
}
}
}

View File

@ -1,12 +1,13 @@
package com.yovinchen.xlcs.order.service; package com.yovinchen.xlcs.order.service;
import com.yovinchen.xlcs.model.order.OrderInfo;
import com.yovinchen.xlcs.vo.order.OrderConfirmVo;
import com.yovinchen.xlcs.vo.order.OrderSubmitVo;
import com.yovinchen.xlcs.vo.order.OrderUserQueryVo;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yovinchen.xlcs.model.order.OrderInfo;
import com.yovinchen.xlcs.vo.order.OrderConfirmVo;
import com.yovinchen.xlcs.vo.order.OrderQueryVo;
import com.yovinchen.xlcs.vo.order.OrderSubmitVo;
import com.yovinchen.xlcs.vo.order.OrderUserQueryVo;
/** /**
* <p> * <p>
@ -57,11 +58,20 @@ public interface OrderInfoService extends IService<OrderInfo> {
void orderPay(String orderNo); void orderPay(String orderNo);
/** /**
* 订单查询 * 订单用户查询
* *
* @param pageParam * @param pageParam
* @param orderUserQueryVo * @param orderUserQueryVo
* @return * @return
*/ */
IPage<OrderInfo> getOrderInfoByUserIdPage(Page<OrderInfo> pageParam, OrderUserQueryVo orderUserQueryVo); IPage<OrderInfo> getOrderInfoByUserIdPage(Page<OrderInfo> pageParam, OrderUserQueryVo orderUserQueryVo);
/**
* 订单后台查询
*
* @param pageParam
* @param orderQueryVo
* @return
*/
IPage<OrderInfo> selectPage(Page<OrderInfo> pageParam, OrderQueryVo orderQueryVo);
} }

View File

@ -1,5 +1,9 @@
package com.yovinchen.xlcs.order.service.impl; package com.yovinchen.xlcs.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yovinchen.xlcs.client.activity.ActivityFeignClient; import com.yovinchen.xlcs.client.activity.ActivityFeignClient;
import com.yovinchen.xlcs.client.cart.CartFeignClient; import com.yovinchen.xlcs.client.cart.CartFeignClient;
import com.yovinchen.xlcs.client.product.ProductFeignClient; import com.yovinchen.xlcs.client.product.ProductFeignClient;
@ -15,23 +19,15 @@ import com.yovinchen.xlcs.model.activity.CouponInfo;
import com.yovinchen.xlcs.model.order.CartInfo; import com.yovinchen.xlcs.model.order.CartInfo;
import com.yovinchen.xlcs.model.order.OrderInfo; import com.yovinchen.xlcs.model.order.OrderInfo;
import com.yovinchen.xlcs.model.order.OrderItem; import com.yovinchen.xlcs.model.order.OrderItem;
import com.yovinchen.xlcs.enums.*;
import com.yovinchen.xlcs.mq.constant.MqConst; import com.yovinchen.xlcs.mq.constant.MqConst;
import com.yovinchen.xlcs.mq.service.RabbitService; import com.yovinchen.xlcs.mq.service.RabbitService;
import com.yovinchen.xlcs.order.mapper.OrderInfoMapper; import com.yovinchen.xlcs.order.mapper.OrderInfoMapper;
import com.yovinchen.xlcs.order.mapper.OrderItemMapper; import com.yovinchen.xlcs.order.mapper.OrderItemMapper;
import com.yovinchen.xlcs.order.service.OrderInfoService; import com.yovinchen.xlcs.order.service.OrderInfoService;
import com.yovinchen.xlcs.order.service.OrderItemService; import com.yovinchen.xlcs.order.service.OrderItemService;
import com.yovinchen.xlcs.vo.order.CartInfoVo; import com.yovinchen.xlcs.vo.order.*;
import com.yovinchen.xlcs.vo.order.OrderConfirmVo;
import com.yovinchen.xlcs.vo.order.OrderSubmitVo;
import com.yovinchen.xlcs.vo.order.OrderUserQueryVo;
import com.yovinchen.xlcs.vo.product.SkuStockLockVo; import com.yovinchen.xlcs.vo.product.SkuStockLockVo;
import com.yovinchen.xlcs.vo.user.LeaderAddressVo; import com.yovinchen.xlcs.vo.user.LeaderAddressVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundHashOperations; import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
@ -98,7 +94,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
//唯一标识订单 //唯一标识订单
String orderNo = System.currentTimeMillis() + ""; String orderNo = System.currentTimeMillis() + "";
redisTemplate.opsForValue().set(RedisConst.ORDER_REPEAT + orderNo, orderNo, 24, TimeUnit.HOURS); redisTemplate.opsForValue()
.set(RedisConst.ORDER_REPEAT + orderNo, orderNo, 24, TimeUnit.HOURS);
//获取购物车满足条件活动和优惠卷信息 //获取购物车满足条件活动和优惠卷信息
OrderConfirmVo orderConfirmVo = activityFeignClient.findCartActivityAndCoupon(cartInfoList, userId); OrderConfirmVo orderConfirmVo = activityFeignClient.findCartActivityAndCoupon(cartInfoList, userId);
@ -147,17 +144,21 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
List<CartInfo> cartInfoList = cartFeignClient.getCartCheckedList(userId); List<CartInfo> cartInfoList = cartFeignClient.getCartCheckedList(userId);
//2购物车有很多商品商品不同类型重点处理普通类型商品 //2购物车有很多商品商品不同类型重点处理普通类型商品
List<CartInfo> commonSkuList = cartInfoList.stream().filter(cartInfo -> Objects.equals(cartInfo.getSkuType(), SkuType.COMMON.getCode())).collect(Collectors.toList()); List<CartInfo> commonSkuList = cartInfoList.stream()
.filter(cartInfo -> Objects.equals(cartInfo.getSkuType(), SkuType.COMMON.getCode()))
.collect(Collectors.toList());
//3把获取购物车里面普通类型商品list集合 //3把获取购物车里面普通类型商品list集合
// List<CartInfo>转换List<SkuStockLockVo> // List<CartInfo>转换List<SkuStockLockVo>
if (!CollectionUtils.isEmpty(commonSkuList)) { if (!CollectionUtils.isEmpty(commonSkuList)) {
List<SkuStockLockVo> commonStockLockVoList = commonSkuList.stream().map(item -> { List<SkuStockLockVo> commonStockLockVoList = commonSkuList.stream()
SkuStockLockVo skuStockLockVo = new SkuStockLockVo(); .map(item -> {
skuStockLockVo.setSkuId(item.getSkuId()); SkuStockLockVo skuStockLockVo = new SkuStockLockVo();
skuStockLockVo.setSkuNum(item.getSkuNum()); skuStockLockVo.setSkuId(item.getSkuId());
return skuStockLockVo; skuStockLockVo.setSkuNum(item.getSkuNum());
}).collect(Collectors.toList()); return skuStockLockVo;
})
.collect(Collectors.toList());
//4远程调用service-product模块实现锁定商品 //4远程调用service-product模块实现锁定商品
//// 验证库存并锁定库存保证具备原子性 //// 验证库存并锁定库存保证具备原子性
@ -187,7 +188,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
if (CollectionUtils.isEmpty(cartInfoList)) { if (CollectionUtils.isEmpty(cartInfoList)) {
throw new xlcsException(ResultCodeEnum.DATA_ERROR); throw new xlcsException(ResultCodeEnum.DATA_ERROR);
} }
//查询用户提货点和配送员信息 //查询用户配送点和配送员信息
Long userId = AuthContextHolder.getUserId(); Long userId = AuthContextHolder.getUserId();
LeaderAddressVo leaderAddressVo = userFeignClient.getUserAddressByUserId(userId); LeaderAddressVo leaderAddressVo = userFeignClient.getUserAddressByUserId(userId);
if (leaderAddressVo == null) { if (leaderAddressVo == null) {
@ -231,9 +232,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
orderItem.setSplitCouponAmount(couponAmount); orderItem.setSplitCouponAmount(couponAmount);
//总金额 //总金额
BigDecimal skuTotalAmount = orderItem.getSkuPrice().multiply(new BigDecimal(orderItem.getSkuNum())); BigDecimal skuTotalAmount = orderItem.getSkuPrice()
.multiply(new BigDecimal(orderItem.getSkuNum()));
//优惠之后金额 //优惠之后金额
BigDecimal splitTotalAmount = skuTotalAmount.subtract(activityAmount).subtract(couponAmount); BigDecimal splitTotalAmount = skuTotalAmount.subtract(activityAmount)
.subtract(couponAmount);
orderItem.setSplitTotalAmount(splitTotalAmount); orderItem.setSplitTotalAmount(splitTotalAmount);
orderItemList.add(orderItem); orderItemList.add(orderItem);
} }
@ -247,14 +250,14 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
orderInfo.setLeaderName(leaderAddressVo.getLeaderName());//配送员名称 orderInfo.setLeaderName(leaderAddressVo.getLeaderName());//配送员名称
orderInfo.setLeaderPhone(leaderAddressVo.getLeaderPhone()); orderInfo.setLeaderPhone(leaderAddressVo.getLeaderPhone());
orderInfo.setTakeName(leaderAddressVo.getTakeName());
orderInfo.setReceiverName(orderParamVo.getReceiverName()); orderInfo.setReceiverName(orderParamVo.getReceiverName());
orderInfo.setReceiverPhone(orderParamVo.getReceiverPhone()); orderInfo.setReceiverPhone(orderParamVo.getReceiverPhone());
orderInfo.setReceiverProvince(leaderAddressVo.getProvince()); orderInfo.setReceiverProvince(leaderAddressVo.getProvince());
orderInfo.setReceiverCity(leaderAddressVo.getCity()); orderInfo.setReceiverCity(leaderAddressVo.getCity());
orderInfo.setReceiverDistrict(leaderAddressVo.getDistrict()); orderInfo.setReceiverDistrict(leaderAddressVo.getDistrict());
orderInfo.setReceiverAddress(leaderAddressVo.getDetailAddress()); orderInfo.setReceiverAddress(leaderAddressVo.getDetailAddress());
orderInfo.setWareId(cartInfoList.get(0).getWareId()); orderInfo.setWareId(cartInfoList.get(0)
.getWareId());
orderInfo.setProcessStatus(ProcessStatus.UNPAID); orderInfo.setProcessStatus(ProcessStatus.UNPAID);
//计算订单金额 //计算订单金额
@ -265,7 +268,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
BigDecimal couponAmount = couponInfoSplitAmount.get("coupon:total"); BigDecimal couponAmount = couponInfoSplitAmount.get("coupon:total");
if (null == couponAmount) couponAmount = new BigDecimal(0); if (null == couponAmount) couponAmount = new BigDecimal(0);
BigDecimal totalAmount = originalTotalAmount.subtract(activityAmount).subtract(couponAmount); BigDecimal totalAmount = originalTotalAmount.subtract(activityAmount)
.subtract(couponAmount);
//计算订单金额 //计算订单金额
orderInfo.setOriginalTotalAmount(originalTotalAmount); orderInfo.setOriginalTotalAmount(originalTotalAmount);
orderInfo.setActivityAmount(activityAmount); orderInfo.setActivityAmount(activityAmount);
@ -274,7 +278,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
//计算配送员佣金 //计算配送员佣金
BigDecimal profitRate = new BigDecimal(0);//orderSetService.getProfitRate(); BigDecimal profitRate = new BigDecimal(0);//orderSetService.getProfitRate();
BigDecimal commissionAmount = orderInfo.getTotalAmount().multiply(profitRate); BigDecimal commissionAmount = orderInfo.getTotalAmount()
.multiply(profitRate);
orderInfo.setCommissionAmount(commissionAmount); orderInfo.setCommissionAmount(commissionAmount);
//添加数据到订单基本信息表 //添加数据到订单基本信息表
@ -295,9 +300,12 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
String orderSkuKey = RedisConst.ORDER_SKU_MAP + orderParamVo.getUserId(); String orderSkuKey = RedisConst.ORDER_SKU_MAP + orderParamVo.getUserId();
BoundHashOperations<String, String, Integer> hashOperations = redisTemplate.boundHashOps(orderSkuKey); BoundHashOperations<String, String, Integer> hashOperations = redisTemplate.boundHashOps(orderSkuKey);
cartInfoList.forEach(cartInfo -> { cartInfoList.forEach(cartInfo -> {
if (Boolean.TRUE.equals(hashOperations.hasKey(cartInfo.getSkuId().toString()))) { if (Boolean.TRUE.equals(hashOperations.hasKey(cartInfo.getSkuId()
Integer orderSkuNum = hashOperations.get(cartInfo.getSkuId().toString()) + cartInfo.getSkuNum(); .toString()))) {
hashOperations.put(cartInfo.getSkuId().toString(), orderSkuNum); Integer orderSkuNum = hashOperations.get(cartInfo.getSkuId()
.toString()) + cartInfo.getSkuNum();
hashOperations.put(cartInfo.getSkuId()
.toString(), orderSkuNum);
} }
}); });
redisTemplate.expire(orderSkuKey, DateUtil.getCurrentExpireTimes(), TimeUnit.SECONDS); redisTemplate.expire(orderSkuKey, DateUtil.getCurrentExpireTimes(), TimeUnit.SECONDS);
@ -355,7 +363,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
} }
/** /**
* 订单查询 * 订单用户查询
* *
* @param pageParam * @param pageParam
* @param orderUserQueryVo * @param orderUserQueryVo
@ -376,7 +384,57 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
//把订单项集合封装到每个订单里面 //把订单项集合封装到每个订单里面
orderInfo.setOrderItemList(orderItemList); orderInfo.setOrderItemList(orderItemList);
//封装订单状态名称 //封装订单状态名称
orderInfo.getParam().put("orderStatusName", orderInfo.getOrderStatus().getComment()); orderInfo.getParam()
.put("orderStatusName", orderInfo.getOrderStatus()
.getComment());
}
return pageModel;
}
/**
* 订单后台查询
*
* @param pageParam
* @param orderQueryVo
* @return
*/
@Override
public IPage<OrderInfo> selectPage(Page<OrderInfo> pageParam, OrderQueryVo orderQueryVo) {
LambdaQueryWrapper<OrderInfo> wrapper = new LambdaQueryWrapper<>();
//获取查询信息
String receiver = orderQueryVo.getReceiver();
String orderNo = orderQueryVo.getOrderNo();
OrderStatus orderStatus = orderQueryVo.getOrderStatus();
Long leaderId = orderQueryVo.getLeaderId();
Long wareId = orderQueryVo.getWareId();
String createTimeBegin = orderQueryVo.getCreateTimeBegin();
String createTimeEnd = orderQueryVo.getCreateTimeEnd();
//拼接查询信息
wrapper.like(!StringUtils.isEmpty(receiver), OrderInfo::getReceiverName, receiver)
.or()
.like(!StringUtils.isEmpty(receiver), OrderInfo::getReceiverPhone, receiver)
.eq(!StringUtils.isEmpty(orderNo), OrderInfo::getOrderNo, orderNo)
.eq(!StringUtils.isEmpty(orderStatus), OrderInfo::getOrderStatus, orderStatus)
.eq(!StringUtils.isEmpty(leaderId), OrderInfo::getLeaderId, leaderId)
.eq(!StringUtils.isEmpty(wareId), OrderInfo::getWareId, wareId)
.ge(!StringUtils.isEmpty(createTimeBegin), OrderInfo::getCreateTime, createTimeBegin)
.le(!StringUtils.isEmpty(createTimeEnd), OrderInfo::getCreateTime, createTimeEnd);
IPage<OrderInfo> pageModel = baseMapper.selectPage(pageParam, wrapper);
//获取每个订单把每个订单里面订单项查询封装
List<OrderInfo> orderInfoList = pageModel.getRecords();
for (OrderInfo orderInfo : orderInfoList) {
//根据订单id查询里面所有订单项列表
List<OrderItem> orderItemList = orderItemMapper.selectList(new LambdaQueryWrapper<OrderItem>()
.eq(OrderItem::getOrderId, orderInfo.getId()));
//把订单项集合封装到每个订单里面
orderInfo.setOrderItemList(orderItemList);
//封装订单状态名称
orderInfo.getParam()
.put("orderStatusName", orderInfo.getOrderStatus()
.getComment());
} }
return pageModel; return pageModel;
} }
@ -393,7 +451,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
private BigDecimal computeTotalAmount(List<CartInfo> cartInfoList) { private BigDecimal computeTotalAmount(List<CartInfo> cartInfoList) {
BigDecimal total = new BigDecimal(0); BigDecimal total = new BigDecimal(0);
for (CartInfo cartInfo : cartInfoList) { for (CartInfo cartInfo : cartInfoList) {
BigDecimal itemTotal = cartInfo.getCartPrice().multiply(new BigDecimal(cartInfo.getSkuNum())); BigDecimal itemTotal = cartInfo.getCartPrice()
.multiply(new BigDecimal(cartInfo.getSkuNum()));
total = total.add(itemTotal); total = total.add(itemTotal);
} }
return total; return total;
@ -424,12 +483,14 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
BigDecimal reduceAmount = activityRule.getReduceAmount(); BigDecimal reduceAmount = activityRule.getReduceAmount();
activityReduceAmount = activityReduceAmount.add(reduceAmount); activityReduceAmount = activityReduceAmount.add(reduceAmount);
if (cartInfoList.size() == 1) { if (cartInfoList.size() == 1) {
activitySplitAmountMap.put("activity:" + cartInfoList.get(0).getSkuId(), reduceAmount); activitySplitAmountMap.put("activity:" + cartInfoList.get(0)
.getSkuId(), reduceAmount);
} else { } else {
//总金额 //总金额
BigDecimal originalTotalAmount = new BigDecimal(0); BigDecimal originalTotalAmount = new BigDecimal(0);
for (CartInfo cartInfo : cartInfoList) { for (CartInfo cartInfo : cartInfoList) {
BigDecimal skuTotalAmount = cartInfo.getCartPrice().multiply(new BigDecimal(cartInfo.getSkuNum())); BigDecimal skuTotalAmount = cartInfo.getCartPrice()
.multiply(new BigDecimal(cartInfo.getSkuNum()));
originalTotalAmount = originalTotalAmount.add(skuTotalAmount); originalTotalAmount = originalTotalAmount.add(skuTotalAmount);
} }
//记录除最后一项是所有分摊金额 最后一项=总的 - skuPartReduceAmount //记录除最后一项是所有分摊金额 最后一项=总的 - skuPartReduceAmount
@ -438,9 +499,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
for (int i = 0, len = cartInfoList.size(); i < len; i++) { for (int i = 0, len = cartInfoList.size(); i < len; i++) {
CartInfo cartInfo = cartInfoList.get(i); CartInfo cartInfo = cartInfoList.get(i);
if (i < len - 1) { if (i < len - 1) {
BigDecimal skuTotalAmount = cartInfo.getCartPrice().multiply(new BigDecimal(cartInfo.getSkuNum())); BigDecimal skuTotalAmount = cartInfo.getCartPrice()
.multiply(new BigDecimal(cartInfo.getSkuNum()));
//sku分摊金额 //sku分摊金额
BigDecimal skuReduceAmount = skuTotalAmount.divide(originalTotalAmount, 2, RoundingMode.HALF_UP).multiply(reduceAmount); BigDecimal skuReduceAmount = skuTotalAmount.divide(originalTotalAmount, 2, RoundingMode.HALF_UP)
.multiply(reduceAmount);
activitySplitAmountMap.put("activity:" + cartInfo.getSkuId(), skuReduceAmount); activitySplitAmountMap.put("activity:" + cartInfo.getSkuId(), skuReduceAmount);
skuPartReduceAmount = skuPartReduceAmount.add(skuReduceAmount); skuPartReduceAmount = skuPartReduceAmount.add(skuReduceAmount);
@ -453,10 +516,12 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
for (int i = 0, len = cartInfoList.size(); i < len; i++) { for (int i = 0, len = cartInfoList.size(); i < len; i++) {
CartInfo cartInfo = cartInfoList.get(i); CartInfo cartInfo = cartInfoList.get(i);
if (i < len - 1) { if (i < len - 1) {
BigDecimal skuTotalAmount = cartInfo.getCartPrice().multiply(new BigDecimal(cartInfo.getSkuNum())); BigDecimal skuTotalAmount = cartInfo.getCartPrice()
.multiply(new BigDecimal(cartInfo.getSkuNum()));
//sku分摊金额 //sku分摊金额
BigDecimal skuDiscountTotalAmount = skuTotalAmount.multiply(activityRule.getBenefitDiscount().divide(new BigDecimal("10"))); BigDecimal skuDiscountTotalAmount = skuTotalAmount.multiply(activityRule.getBenefitDiscount()
.divide(new BigDecimal("10")));
BigDecimal skuReduceAmount = skuTotalAmount.subtract(skuDiscountTotalAmount); BigDecimal skuReduceAmount = skuTotalAmount.subtract(skuDiscountTotalAmount);
activitySplitAmountMap.put("activity:" + cartInfo.getSkuId(), skuReduceAmount); activitySplitAmountMap.put("activity:" + cartInfo.getSkuId(), skuReduceAmount);
@ -497,13 +562,15 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
BigDecimal reduceAmount = couponInfo.getAmount(); BigDecimal reduceAmount = couponInfo.getAmount();
if (skuIdList.size() == 1) { if (skuIdList.size() == 1) {
//sku的优化金额 //sku的优化金额
couponInfoSplitAmountMap.put("coupon:" + skuIdToCartInfoMap.get(skuIdList.get(0)).getSkuId(), reduceAmount); couponInfoSplitAmountMap.put("coupon:" + skuIdToCartInfoMap.get(skuIdList.get(0))
.getSkuId(), reduceAmount);
} else { } else {
//总金额 //总金额
BigDecimal originalTotalAmount = new BigDecimal(0); BigDecimal originalTotalAmount = new BigDecimal(0);
for (Long skuId : skuIdList) { for (Long skuId : skuIdList) {
CartInfo cartInfo = skuIdToCartInfoMap.get(skuId); CartInfo cartInfo = skuIdToCartInfoMap.get(skuId);
BigDecimal skuTotalAmount = cartInfo.getCartPrice().multiply(new BigDecimal(cartInfo.getSkuNum())); BigDecimal skuTotalAmount = cartInfo.getCartPrice()
.multiply(new BigDecimal(cartInfo.getSkuNum()));
originalTotalAmount = originalTotalAmount.add(skuTotalAmount); originalTotalAmount = originalTotalAmount.add(skuTotalAmount);
} }
//记录除最后一项是所有分摊金额 最后一项=总的 - skuPartReduceAmount //记录除最后一项是所有分摊金额 最后一项=总的 - skuPartReduceAmount
@ -512,9 +579,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
for (int i = 0, len = skuIdList.size(); i < len; i++) { for (int i = 0, len = skuIdList.size(); i < len; i++) {
CartInfo cartInfo = skuIdToCartInfoMap.get(skuIdList.get(i)); CartInfo cartInfo = skuIdToCartInfoMap.get(skuIdList.get(i));
if (i < len - 1) { if (i < len - 1) {
BigDecimal skuTotalAmount = cartInfo.getCartPrice().multiply(new BigDecimal(cartInfo.getSkuNum())); BigDecimal skuTotalAmount = cartInfo.getCartPrice()
.multiply(new BigDecimal(cartInfo.getSkuNum()));
//sku分摊金额 //sku分摊金额
BigDecimal skuReduceAmount = skuTotalAmount.divide(originalTotalAmount, 2, RoundingMode.HALF_UP).multiply(reduceAmount); BigDecimal skuReduceAmount = skuTotalAmount.divide(originalTotalAmount, 2, RoundingMode.HALF_UP)
.multiply(reduceAmount);
couponInfoSplitAmountMap.put("coupon:" + cartInfo.getSkuId(), skuReduceAmount); couponInfoSplitAmountMap.put("coupon:" + cartInfo.getSkuId(), skuReduceAmount);
skuPartReduceAmount = skuPartReduceAmount.add(skuReduceAmount); skuPartReduceAmount = skuPartReduceAmount.add(skuReduceAmount);

View File

@ -1,5 +1,9 @@
package com.yovinchen.xlcs.product.service.impl; package com.yovinchen.xlcs.product.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yovinchen.xlcs.common.constant.RedisConst; import com.yovinchen.xlcs.common.constant.RedisConst;
import com.yovinchen.xlcs.common.exception.xlcsException; import com.yovinchen.xlcs.common.exception.xlcsException;
import com.yovinchen.xlcs.common.result.ResultCodeEnum; import com.yovinchen.xlcs.common.result.ResultCodeEnum;
@ -17,10 +21,6 @@ import com.yovinchen.xlcs.product.service.SkuPosterService;
import com.yovinchen.xlcs.vo.product.SkuInfoQueryVo; import com.yovinchen.xlcs.vo.product.SkuInfoQueryVo;
import com.yovinchen.xlcs.vo.product.SkuInfoVo; import com.yovinchen.xlcs.vo.product.SkuInfoVo;
import com.yovinchen.xlcs.vo.product.SkuStockLockVo; import com.yovinchen.xlcs.vo.product.SkuStockLockVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -74,15 +74,11 @@ public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoMapper, SkuInfo> impl
Long categoryId = skuInfoQueryVo.getCategoryId(); Long categoryId = skuInfoQueryVo.getCategoryId();
//封装条件 //封装条件
LambdaQueryWrapper<SkuInfo> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SkuInfo> wrapper = new LambdaQueryWrapper<>();
if (!StringUtils.isEmpty(keyword)) { // 动态添加条件
wrapper.like(SkuInfo::getSkuName, keyword); wrapper.like(!StringUtils.isEmpty(keyword), SkuInfo::getSkuName, keyword)
} .eq(!StringUtils.isEmpty(skuType), SkuInfo::getSkuType, skuType)
if (!StringUtils.isEmpty(skuType)) { .eq(!StringUtils.isEmpty(categoryId), SkuInfo::getCategoryId, categoryId);
wrapper.eq(SkuInfo::getSkuType, skuType);
}
if (!StringUtils.isEmpty(categoryId)) {
wrapper.eq(SkuInfo::getCategoryId, categoryId);
}
//调用方法查询 //调用方法查询
return baseMapper.selectPage(pageParam, wrapper); return baseMapper.selectPage(pageParam, wrapper);
} }