Merge remote-tracking branch 'origin/master'

This commit is contained in:
sin 2019-04-01 23:41:26 +08:00
commit fb8053ef7a
31 changed files with 758 additions and 153 deletions

View File

@ -7,6 +7,12 @@ export default {
changeOrigin: true, changeOrigin: true,
pathRewrite: {}, pathRewrite: {},
}, },
'/product-api/': {
// target: 'http://180.167.213.26:18083/',
target: 'http://127.0.0.1:18081/',
changeOrigin: true,
pathRewrite: {},
},
'/order-api/': { '/order-api/': {
target: 'http://127.0.0.1:18084/', target: 'http://127.0.0.1:18084/',
changeOrigin: true, changeOrigin: true,

View File

@ -110,11 +110,11 @@ export default [
name: 'promotion-banner-list', name: 'promotion-banner-list',
component: './Promotion/BannerList', component: './Promotion/BannerList',
}, },
// { {
// path: '/product/product-spu-add', path: '/promotion/product-recommend-list',
// name: 'product-spu-add', name: 'product-recommend-list',
// component: './Product/ProductSpuAddOrUpdate', component: './Promotion/ProductRecommendList',
// }, },
// { // {
// path: '/product/product-category-list', // path: '/product/product-category-list',
// name: 'product-category-list', // name: 'product-category-list',

View File

@ -55,4 +55,5 @@ export default {
'menu.order.order-refunds': '退货维权', 'menu.order.order-refunds': '退货维权',
// 营销相关 // 营销相关
'menu.promotion.promotion-banner-list': 'Banner 管理', 'menu.promotion.promotion-banner-list': 'Banner 管理',
'menu.promotion.product-recommend-list': '商品推荐',
}; };

View File

@ -1,15 +1,10 @@
import {message} from 'antd'; import {message} from 'antd';import {
import {buildTreeNode, findCheckedKeys} from '../../utils/tree.utils';
import {
addBanner, addBanner,
adminRoleAssign,
deleteBanner, deleteBanner,
queryBanner, queryBanner,
queryBannerRoleList,
updateBanner, updateBanner,
updateBannerStatus, updateBannerStatus,
} from '../../services/promotion'; } from '../../services/promotion';
import {arrayToStringParams} from '../../utils/request.qs';
import PaginationHelper from '../../../helpers/PaginationHelper'; import PaginationHelper from '../../../helpers/PaginationHelper';
const SEARCH_PARAMS_DEFAULT = { const SEARCH_PARAMS_DEFAULT = {
@ -31,12 +26,6 @@ export default {
modalType: undefined, // 'add' or 'update' 表单 modalType: undefined, // 'add' or 'update' 表单
formVals: {}, // 当前表单值 formVals: {}, // 当前表单值
modalLoading: false, modalLoading: false,
// 分配角色表单相关
roleList: [],
roleModalVisible: false,
roleCheckedKeys: [], // 此处的 Key ,就是角色编号
roleAssignLoading: false,
}, },
effects: { effects: {
@ -161,78 +150,10 @@ export default {
} }
}, },
* queryRoleList({ payload }, { call, put }) {
// 显示加载中
yield put({
type: 'changeRoleAssignLoading',
payload: true,
});
// 请求
const response = yield call(queryBannerRoleList, payload);
// 响应
if (response.code === 0) {
const roleList = response.data;
const roleTreeData = buildTreeNode(roleList, 'name', 'id');
const roleCheckedKeys = findCheckedKeys(roleList);
yield put({
type: 'setAll',
payload: {
roleList: roleTreeData,
roleCheckedKeys,
},
});
}
// 隐藏加载中
yield put({
type: 'changeRoleAssignLoading',
payload: false,
});
},
* roleAssign({ payload }, { call, put }) {
const { callback, body } = payload;
// 显示加载中
yield put({
type: 'changeRoleAssignLoading',
payload: true,
});
// 请求
const response = yield call(adminRoleAssign, {
id: body.id,
roleIds: arrayToStringParams(body.roleIds),
});
// 响应
if (response.code === 0) {
if (callback) {
callback(response);
}
}
// 隐藏加载中
yield put({
type: 'changeRoleAssignLoading',
payload: false,
});
},
}, },
reducers: { reducers: {
changeRoleCheckedKeys(state, { payload }) {
return {
...state,
roleCheckedKeys: payload,
};
},
// 修改加载中的状态 // 修改加载中的状态
changeRoleAssignLoading(state, { payload }) {
return {
...state,
roleAssignLoading: payload,
};
},
changeModalLoading(state, { payload }) { changeModalLoading(state, { payload }) {
return { return {
...state, ...state,

View File

@ -0,0 +1,178 @@
import {message} from 'antd';
import {
addProductRecommend,
deleteProductRecommend,
queryProductRecommend,
updateProductRecommend,
updateProductRecommendStatus,
} from '../../services/promotion';
import PaginationHelper from '../../../helpers/PaginationHelper';
const SEARCH_PARAMS_DEFAULT = {
type: undefined,
};
export default {
namespace: 'productRecommendList',
state: {
// 分页列表相关
list: [],
listLoading: false,
pagination: PaginationHelper.defaultPaginationConfig,
searchParams: SEARCH_PARAMS_DEFAULT,
// 添加 or 修改表单相关
modalVisible: false,
modalType: undefined, // 'add' or 'update' 表单
formVals: {}, // 当前表单值
modalLoading: false,
},
effects: {
// 查询列表
* query({ payload }, { call, put }) {
// 显示加载中
yield put({
type: 'changeListLoading',
payload: true,
});
// 请求
const response = yield call(queryProductRecommend, payload);
// 响应
yield put({
type: 'setAll',
payload: {
list: response.data.list,
pagination: PaginationHelper.formatPagination(response.data, payload),
searchParams: {
type: payload.type
}
},
});
// 隐藏加载中
yield put({
type: 'changeListLoading',
payload: false,
});
},
* add({ payload }, { call, put }) {
const { callback, body } = payload;
// 显示加载中
yield put({
type: 'changeModalLoading',
payload: true,
});
// 请求
const response = yield call(addProductRecommend, body);
// 响应
if (response.code === 0) {
if (callback) {
callback(response);
}
// 刷新列表
yield put({
type: 'query',
payload: {
...PaginationHelper.defaultPayload
},
});
}
// 隐藏加载中
yield put({
type: 'changeModalLoading',
payload: false,
});
},
* update({ payload }, { call, put }) {
const { callback, body } = payload;
// 显示加载中
yield put({
type: 'changeModalLoading',
payload: true,
});
// 请求
const response = yield call(updateProductRecommend, body);
// 响应
if (response.code === 0) {
if (callback) {
callback(response);
}
// 刷新列表
yield put({
type: 'query',
payload: {
...PaginationHelper.defaultPayload
},
});
}
// 隐藏加载中
yield put({
type: 'changeModalLoading',
payload: false,
});
},
* updateStatus({ payload }, { call, put }) {
// 请求
const response = yield call(updateProductRecommendStatus, payload);
// 响应
if (response.code === 0) {
message.info('更新状态成功!');
// 刷新列表
yield put({
type: 'query',
payload: {
...PaginationHelper.defaultPayload
},
});
}
},
* delete({ payload }, { call, put }) {
// 请求
const response = yield call(deleteProductRecommend, payload);
// 响应
if (response.code === 0) {
message.info('删除成功!');
// 刷新列表
yield put({
type: 'query',
payload: {
...PaginationHelper.defaultPayload
},
});
}
},
},
reducers: {
// 修改加载中的状态
changeModalLoading(state, { payload }) {
return {
...state,
modalLoading: payload,
};
},
changeListLoading(state, { payload }) {
return {
...state,
listLoading: payload,
};
},
// 设置所有属性
setAll(state, { payload }) {
return {
...state,
...payload,
};
}
},
};

View File

@ -342,24 +342,12 @@ class BannerList extends PureComponent {
}); });
}; };
handleRoleAssignModalVisible = (roleModalVisible, record) => {
const { dispatch } = this.props;
dispatch({
type: 'bannerList/setAll',
payload: {
roleModalVisible: roleModalVisible,
formVals: record || {}
},
});
};
render() { render() {
// let that = this; // let that = this;
const { dispatch, const { dispatch,
list, listLoading, searchParams, pagination, list, listLoading, searchParams, pagination,
modalVisible, modalType, formVals, modalVisible, modalType, formVals,
confirmLoading, confirmLoading,} = this.props;
roleList, roleModalVisible, roleAssignLoading, roleCheckedKeys } = this.props;
// 列表属性 // 列表属性
const listProps = { const listProps = {

View File

@ -0,0 +1,398 @@
/* eslint-disable */
import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import {
Card,
Form,
Input,
Button,
Modal,
message,
Table,
Divider,
Tree,
Spin,
Row,
Col,
Select,
Icon,
InputNumber
} from 'antd';
import { checkTypeWithEnglishAndNumbers } from '../../../helpers/validator'
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import styles from './BannerList.less';
import moment from "moment";
import PaginationHelper from "../../../helpers/PaginationHelper";
const FormItem = Form.Item;
const SelectOption = Select.Option;
const { TreeNode } = Tree;
const status = ['未知', '正常', '禁用'];
const types = ['未知', '新品推荐', '热卖推荐'];
// 列表
function List ({ dataSource, loading, pagination, searchParams, dispatch,
handleModalVisible}) {
function handleStatus(record) {
Modal.confirm({
title: record.status === 1 ? '确认禁用' : '取消禁用',
content: `${record.productSpuId}`,
onOk() {
dispatch({
type: 'productRecommendList/updateStatus',
payload: {
id: record.id,
status: record.status === 1 ? 2 : 1,
},
});
},
onCancel() {},
});
}
function handleDelete(record) {
Modal.confirm({
title: `确认删除?`,
content: `${record.productSpuId}`,
onOk() {
dispatch({
type: 'productRecommendList/delete',
payload: {
id: record.id,
},
});
},
onCancel() {},
});
}
const columns = [
{
title: '推荐类型',
dataIndex: 'type',
render(val) {
return <span>{types[val]}</span>; // TODO 芋艿此处要改
},
},
{
title: '商品',
dataIndex: 'productSpuId',
},
{
title: '排序值',
dataIndex: 'sort',
},
{
title: '状态',
dataIndex: 'status',
render(val) {
return <span>{status[val]}</span>; // TODO 芋艿此处要改
},
},
{
title: '备注',
dataIndex: 'memo',
},
{
title: '创建时间',
dataIndex: 'createTime',
render: val => <span>{moment(val).format('YYYY-MM-DD HH:mm')}</span>,
},
{
title: '操作',
width: 360,
render: (text, record) => {
const statusText = record.status === 1 ? '禁用' : '开启'; // TODO 芋艿,此处要改
return (
<Fragment>
<a onClick={() => handleModalVisible(true, 'update', record)}>编辑</a>
<Divider type="vertical" />
<a className={styles.tableDelete} onClick={() => handleStatus(record)}>
{statusText}
</a>
{
record.status === 2 ?
<span>
<Divider type="vertical" />
<a className={styles.tableDelete} onClick={() => handleDelete(record)}>
删除
</a>
</span> : null
}
</Fragment>
);
},
},
];
function onPageChange(page) { // 翻页
dispatch({
type: 'productRecommendList/query',
payload: {
pageNo: page.current,
pageSize: page.pageSize,
...searchParams
}
})
}
return (
<Table
columns={columns}
dataSource={dataSource}
loading={loading}
rowKey="id"
pagination={pagination}
onChange={onPageChange}
/>
)
}
// 搜索表单
// TODO 芋艿,有没办法换成上面那种写法
const SearchForm = Form.create()(props => {
const {
form,
form: { getFieldDecorator },
dispatch
} = props;
function search() {
dispatch({
type: 'productRecommendList/query',
payload: {
...PaginationHelper.defaultPayload,
...form.getFieldsValue()
}
})
}
// 提交搜索
function handleSubmit(e) {
// 阻止默认事件
e.preventDefault();
// 提交搜索
search();
}
// 重置搜索
function handleReset() {
// 重置表单
form.resetFields();
// 执行搜索
search();
}
return (
<Form onSubmit={handleSubmit} layout="inline">
<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
<Col md={8} sm={24}>
<FormItem label="标题">
{getFieldDecorator('title')(<Input placeholder="请输入" />)}
</FormItem>
</Col>
<Col md={8} sm={24}>
<span className={styles.submitButtons}>
<Button type="primary" htmlType="submit">
查询
</Button>
<Button style={{ marginLeft: 8 }} onClick={handleReset}>
重置
</Button>
</span>
</Col>
</Row>
</Form>
);
});
// 添加 or 修改 Form 表单
const AddOrUpdateForm = Form.create()(props => {
const { dispatch, modalVisible, form, handleModalVisible, modalType, formVals } = props;
const okHandle = () => {
form.validateFields((err, fields) => {
if (err) return;
// 添加表单
if (modalType === 'add') {
dispatch({
type: 'productRecommendList/add',
payload: {
body: {
...fields,
},
callback: () => {
// 清空表单
form.resetFields();
// 提示
message.success('添加成功');
// 关闭弹窗
handleModalVisible();
},
},
});
// 修改表单
} else {
dispatch({
type: 'productRecommendList/update',
payload: {
body: {
id: formVals.id,
...fields,
},
callback: () => {
// 清空表单
form.resetFields();
// 提示
message.success('更新成功');
// 关闭弹窗
handleModalVisible();
},
},
});
}
});
};
const title = modalType === 'add' ? '新建 Banner' : '更新 Banner';
return (
<Modal
destroyOnClose
title={title}
visible={modalVisible}
onOk={okHandle}
okText='保存'
onCancel={() => handleModalVisible()}
>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="推荐类型">
{form.getFieldDecorator('type', {
rules: [{ required: true, message: '请输入推荐类型!'},
],
initialValue: formVals.type,
})(
<Select placeholder="请选择" style={{ maxWidth: 200, width: '100%' }}>
<SelectOption value="1">{ types[1] }</SelectOption>
<SelectOption value="2">{ types[2] }</SelectOption>
</Select>
)}
</FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="商品">
{form.getFieldDecorator('productSpuId', {
rules: [{ required: true, message: '请输入商品!'}, // TODO 芋艿,临时先输入商品编号,后面做成搜索。
],
initialValue: formVals.productSpuId,
})(<Input placeholder="请输入" />)}
</FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="排序值">
{form.getFieldDecorator('sort', {
rules: [{ required: true, message: '请输入排序值!' }],
initialValue: formVals.sort,
})(<InputNumber placeholder="请输入" />)}
</FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="备注">
{form.getFieldDecorator('memo', {
rules: [{ required: false, message: '请输入备注!' },
{max: 255, message: '最大长度为 255 位'},
],
initialValue: formVals.memo,
})(<Input.TextArea placeholder="请输入" />)}
</FormItem>
</Modal>
);
});
@connect(({ productRecommendList }) => ({
// list: productRecommend.list,
// pagination: productRecommend.pagination,
...productRecommendList,
}))
// 主界面
@Form.create()
class BannerList extends PureComponent {
componentDidMount() {
const { dispatch } = this.props;
dispatch({
type: 'productRecommendList/query',
payload: {
...PaginationHelper.defaultPayload
},
});
}
handleModalVisible = (modalVisible, modalType, record) => {
const { dispatch } = this.props;
dispatch({
type: 'productRecommendList/setAll',
payload: {
modalVisible,
modalType,
formVals: record || {}
},
});
};
render() {
// let that = this;
const { dispatch,
list, listLoading, searchParams, pagination,
modalVisible, modalType, formVals,
confirmLoading, } = this.props;
// 列表属性
const listProps = {
dataSource: list,
pagination,
searchParams,
dispatch,
loading: listLoading,
confirmLoading,
handleModalVisible: this.handleModalVisible, // Function
};
// 搜索表单属性
const searchFormProps = {
dispatch,
};
// 添加 or 更新表单属性
const addOrUpdateFormProps = {
modalVisible,
modalType,
formVals,
dispatch,
handleModalVisible: this.handleModalVisible, // Function
};
return (
<PageHeaderWrapper>
<Card bordered={false}>
<div className={styles.tableList}>
<div className={styles.tableListForm}>
<SearchForm {...searchFormProps} />
</div>
<div className={styles.tableListOperator}>
<Button
icon="plus"
type="primary"
onClick={() => this.handleModalVisible(true, 'add', {})}
>
新建商品推荐
</Button>
</div>
</div>
<List {...listProps} />
</Card>
<AddOrUpdateForm {...addOrUpdateFormProps} />
</PageHeaderWrapper>
);
}
}
export default BannerList;

View File

@ -0,0 +1,47 @@
@import '~antd/lib/style/themes/default.less';
@import '~@/utils/utils.less';
.tableList {
.tableListOperator {
margin-bottom: 16px;
button {
margin-right: 8px;
}
}
}
.tableDelete {
color: red;
}
.tableListForm {
:global {
.ant-form-item {
display: flex;
margin-right: 0;
margin-bottom: 24px;
> .ant-form-item-label {
width: auto;
padding-right: 8px;
line-height: 32px;
}
.ant-form-item-control {
line-height: 32px;
}
}
.ant-form-item-control-wrapper {
flex: 1;
}
}
.submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
}
@media screen and (max-width: @screen-lg) {
.tableListForm :global(.ant-form-item) {
margin-right: 24px;
}
}

View File

@ -32,3 +32,35 @@ export async function deleteBanner(params) {
method: 'POST', method: 'POST',
}); });
} }
// product recommend
export async function queryProductRecommend(params) {
return request(`/promotion-api/admins/product_recommend/page?${stringify(params)}`, {
method: 'GET',
});
}
export async function addProductRecommend(params) {
return request(`/promotion-api/admins/product_recommend/add?${stringify(params)}`, {
method: 'POST',
});
}
export async function updateProductRecommend(params) {
return request(`/promotion-api/admins/product_recommend/update?${stringify(params)}`, {
method: 'POST',
});
}
export async function updateProductRecommendStatus(params) {
return request(`/promotion-api/admins/product_recommend/update_status?${stringify(params)}`, {
method: 'POST',
});
}
export async function deleteProductRecommend(params) {
return request(`/promotion-api/admins/product_recommend/delete?${stringify(params)}`, {
method: 'POST',
});
}

View File

@ -8,3 +8,12 @@ export function getBannerList() {
method: 'get', method: 'get',
}); });
} }
// Product Recommend
export function getProductRecommendList() {
return request({
url: 'promotion-api/users/product_recommend/list',
method: 'get',
});
}

View File

@ -19,8 +19,8 @@ if (process.env.NODE_ENV == 'development') {
// baseUrl = 'http://127.0.0.1'; // baseUrl = 'http://127.0.0.1';
// baseUrl = 'http://180.167.213.26:18099'; // baseUrl = 'http://180.167.213.26:18099';
// dataSources = 'remote'; dataSources = 'remote';
dataSources = 'local'; // dataSources = 'local';
export { export {
baseUrl, baseUrl,

View File

@ -13,14 +13,15 @@
</van-swipe-item> </van-swipe-item>
</van-swipe> </van-swipe>
<van-panel title="新品推荐"> <van-panel title="新品推荐">
<div v-for="(item,index) in page.Sections" :key="index"> <!-- <product :data="productRecommends['1']" ></product>-->
<product v-if="item.Code=='Product'" :data="item" ></product> <div v-for="(product,i) in productRecommends['1']" :key="i">
<product-card :product='product' @click="showProduct(product)" />
</div> </div>
</van-panel> </van-panel>
<van-panel title="热卖推荐"> <van-panel title="热卖推荐">
<div v-for="(item,index) in page.Sections" :key="index"> <div v-for="(product,i) in productRecommends['2']" :key="i">
<product v-if="item.Code=='Product'" :data="item" ></product> <product-card :product='product' @click="showProduct(product)" />
</div> </div>
</van-panel> </van-panel>
@ -39,7 +40,7 @@ import imageAd from "../../components/page/imageAd.vue";
import imageText from "../../components/page/imageText.vue"; import imageText from "../../components/page/imageText.vue";
import product from "../../components/page/product.vue"; import product from "../../components/page/product.vue";
import { GetPage } from "../../api/page.js"; import { GetPage } from "../../api/page.js";
import { getBannerList } from '../../api/promotion.js'; import { getBannerList, getProductRecommendList } from '../../api/promotion.js';
export default { export default {
name:"page", name:"page",
@ -60,6 +61,7 @@ export default {
topheight:0, topheight:0,
page:{}, page:{},
banners: [], // Banner banners: [], // Banner
productRecommends: [], //
} }
}, },
created:function(){ created:function(){
@ -69,18 +71,30 @@ export default {
}, },
mounted: function() { mounted: function() {
// Banner // Banner
let response = getBannerList(); {
response.then(data => { let response = getBannerList();
this.banners = data; response.then(data => {
}); this.banners = data;
});
}
// getProductRecommendList
{
let response = getProductRecommendList();
response.then(data => {
this.productRecommends = data;
});
}
}, },
methods:{ methods:{
onBannerClick: function(event, index) { // onBannerClick: function(event, index) {
debugger; // debugger;
console.log(event); // console.log(event);
}, // },
settopheight:function(value){ settopheight:function(value){
this.topheight=value; this.topheight=value;
},
showProduct(product){
this.$router.push('/product/'+product.id);
} }
} }
} }

View File

@ -1,9 +1,11 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
/** /**
* 商品规格明细 BO * 商品规格明细 BO
*/ */
public class ProductAttrAndValuePairBO { public class ProductAttrAndValuePairBO implements Serializable {
/** /**
* 规格编号 * 规格编号

View File

@ -1,11 +1,12 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
* 商品规格 VO * 商品规格 VO
*/ */
public class ProductAttrBO { public class ProductAttrBO implements Serializable {
/** /**
* 规格编号 * 规格编号

View File

@ -1,12 +1,13 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
/** /**
* 商品规格明细 VO * 商品规格明细 VO
*/ */
public class ProductAttrDetailBO { public class ProductAttrDetailBO implements Serializable {
/** /**
* 规格编号 * 规格编号

View File

@ -1,11 +1,12 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* 商品规格明细分页 BO * 商品规格明细分页 BO
*/ */
public class ProductAttrPageBO { public class ProductAttrPageBO implements Serializable {
/** /**
* 规格数组 * 规格数组

View File

@ -1,11 +1,12 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* 商品规格精简 VO * 商品规格精简 VO
*/ */
public class ProductAttrSimpleBO { public class ProductAttrSimpleBO implements Serializable {
/** /**
* 规格编号 * 规格编号

View File

@ -1,11 +1,12 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
* 商品规格值 VO * 商品规格值 VO
*/ */
public class ProductAttrValueBO { public class ProductAttrValueBO implements Serializable {
/** /**
* 规格值编号 * 规格值编号

View File

@ -1,11 +1,12 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
* 商品规格值 VO * 商品规格值 VO
*/ */
public class ProductAttrValueDetailBO { public class ProductAttrValueDetailBO implements Serializable {
/** /**
* 规格值编号 * 规格值编号

View File

@ -1,9 +1,11 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
/** /**
* 商品规格值 VO * 商品规格值 VO
*/ */
public class ProductAttrValueSimpleBO { public class ProductAttrValueSimpleBO implements Serializable {
/** /**
* 规格值编号 * 规格值编号

View File

@ -1,11 +1,12 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
* 商品分类 BO * 商品分类 BO
*/ */
public class ProductCategoryBO { public class ProductCategoryBO implements Serializable {
/** /**
* 分类编号 * 分类编号

View File

@ -1,6 +1,8 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
public class ProductSkuBO { import java.io.Serializable;
public class ProductSkuBO implements Serializable {
private Integer id; private Integer id;

View File

@ -1,11 +1,12 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* 商品 Sku 明细 BO * 商品 Sku 明细 BO
*/ */
public class ProductSkuDetailBO { public class ProductSkuDetailBO implements Serializable {
/** /**
* sku 编号 * sku 编号

View File

@ -1,8 +1,9 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
import java.util.List; import java.util.List;
public class ProductSpuBO { public class ProductSpuBO implements Serializable {
/** /**
* SPU 编号 * SPU 编号

View File

@ -1,11 +1,12 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* 商品 Spu 明细 BO包括 Sku 明细 * 商品 Spu 明细 BO包括 Sku 明细
*/ */
public class ProductSpuDetailBO { public class ProductSpuDetailBO implements Serializable {
/** /**
* SPU 编号 * SPU 编号

View File

@ -1,8 +1,9 @@
package cn.iocoder.mall.product.api.bo; package cn.iocoder.mall.product.api.bo;
import java.io.Serializable;
import java.util.List; import java.util.List;
public class ProductSpuPageBO { public class ProductSpuPageBO implements Serializable {
/** /**
* Spu 数组 * Spu 数组

View File

@ -12,7 +12,7 @@ public interface ProductSpuMapper {
ProductSpuDO selectById(Integer id); ProductSpuDO selectById(Integer id);
List<ProductSpuDO> selectByIds(Collection<Integer> ids); List<ProductSpuDO> selectByIds(@Param("ids") Collection<Integer> ids);
void insert(ProductSpuDO productSpuDO); void insert(ProductSpuDO productSpuDO);

View File

@ -17,13 +17,14 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@RestController @RestController
@RequestMapping("users/banner") @RequestMapping("users/product_recommend")
@Api("商品推荐模块") @Api("商品推荐模块")
public class UsersProductRecommendController { public class UsersProductRecommendController {
@ -34,7 +35,7 @@ public class UsersProductRecommendController {
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("获得所有 Banner 列表") @ApiOperation("获得所有 Banner 列表")
public CommonResult<Multimap<Integer, UsersProductRecommendVO>> list() { public CommonResult<Map<Integer, Collection<UsersProductRecommendVO>>> list() {
// 查询商品推荐列表 // 查询商品推荐列表
List<ProductRecommendBO> productRecommends = productRecommendService.getProductRecommendList( List<ProductRecommendBO> productRecommends = productRecommendService.getProductRecommendList(
null, CommonStatusEnum.ENABLE.getValue()).getData(); null, CommonStatusEnum.ENABLE.getValue()).getData();
@ -43,11 +44,11 @@ public class UsersProductRecommendController {
productRecommends.stream().map(ProductRecommendBO::getProductSpuId).collect(Collectors.toSet())).getData(); productRecommends.stream().map(ProductRecommendBO::getProductSpuId).collect(Collectors.toSet())).getData();
Map<Integer, ProductSpuBO> spuMap = spus.stream().collect(Collectors.toMap(ProductSpuBO::getId, account -> account)); Map<Integer, ProductSpuBO> spuMap = spus.stream().collect(Collectors.toMap(ProductSpuBO::getId, account -> account));
// 组合结果返回 // 组合结果返回
Multimap<Integer, UsersProductRecommendVO> result = new HashMultimap<>(); Multimap<Integer, UsersProductRecommendVO> result = HashMultimap.create();
productRecommends.sort(Comparator.comparing(ProductRecommendBO::getSort)); // 排序按照 sort 升序 productRecommends.sort(Comparator.comparing(ProductRecommendBO::getSort)); // 排序按照 sort 升序
productRecommends.forEach(productRecommendBO -> result.put(productRecommendBO.getType(), productRecommends.forEach(productRecommendBO -> result.put(productRecommendBO.getType(),
ProductRecommendConvert.INSTANCE.convert(spuMap.get(productRecommendBO.getProductSpuId())))); // ProductSpuBO 添加到 results ProductRecommendConvert.INSTANCE.convert(spuMap.get(productRecommendBO.getProductSpuId())))); // ProductSpuBO 添加到 results
return CommonResult.success(result); return CommonResult.success(result.asMap());
} }
} }

View File

@ -65,13 +65,6 @@
<version>27.0.1-jre</version> <version>27.0.1-jre</version>
</dependency> </dependency>
<dependency>
<groupId>Pingplusplus</groupId>
<artifactId>pingpp-java</artifactId>
<version>2.2.4</version>
<type>jar</type>
</dependency>
<dependency> <dependency>
<groupId>com.xuxueli</groupId> <groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId> <artifactId>xxl-job-core</artifactId>

View File

@ -1,7 +1,7 @@
package cn.iocoder.mall.promotion.biz.config; package cn.iocoder.mall.promotion.biz.config;
import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.mall.user.service.api.constant.UserErrorCodeEnum; import cn.iocoder.mall.promotion.api.constant.PromotionErrorCodeEnum;
import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
@ -18,7 +18,7 @@ public class ServiceExceptionConfiguration {
// } catch (IOException e) { // } catch (IOException e) {
// throw new RuntimeException(e); // throw new RuntimeException(e);
// } // }
for (UserErrorCodeEnum item : UserErrorCodeEnum.values()) { for (PromotionErrorCodeEnum item : PromotionErrorCodeEnum.values()) {
ServiceExceptionUtil.put(item.getCode(), item.getMessage()); ServiceExceptionUtil.put(item.getCode(), item.getMessage());
} }
} }

View File

@ -7,7 +7,7 @@
status, memo, create_time status, memo, create_time
</sql> </sql>
<!-- <select id="selectListByPidAndStatusOrderBySort" resultType="BannerDO">--> <!-- <select id="selectListByPidAndStatusOrderBySort" resultType="ProductRecommendDO">-->
<!-- SELECT--> <!-- SELECT-->
<!-- <include refid="FIELDS" />--> <!-- <include refid="FIELDS" />-->
<!-- FROM product_recommend--> <!-- FROM product_recommend-->
@ -17,14 +17,14 @@
<!-- ORDER BY sort ASC--> <!-- ORDER BY sort ASC-->
<!-- </select>--> <!-- </select>-->
<!-- <select id="selectList" resultType="BannerDO">--> <!-- <select id="selectList" resultType="ProductRecommendDO">-->
<!-- SELECT--> <!-- SELECT-->
<!-- <include refid="FIELDS" />--> <!-- <include refid="FIELDS" />-->
<!-- FROM product_recommend--> <!-- FROM product_recommend-->
<!-- WHERE deleted = 0--> <!-- WHERE deleted = 0-->
<!-- </select>--> <!-- </select>-->
<select id="selectById" parameterType="Integer" resultType="BannerDO"> <select id="selectById" parameterType="Integer" resultType="ProductRecommendDO">
SELECT SELECT
<include refid="FIELDS" /> <include refid="FIELDS" />
FROM product_recommend FROM product_recommend
@ -32,7 +32,7 @@
AND deleted = 0 AND deleted = 0
</select> </select>
<select id="selectByProductSpuIdAndType" resultType="BannerDO"> <select id="selectByProductSpuIdAndType" resultType="ProductRecommendDO">
SELECT SELECT
<include refid="FIELDS" /> <include refid="FIELDS" />
FROM product_recommend FROM product_recommend
@ -41,13 +41,13 @@
product_spu_id = #{productSpuId} product_spu_id = #{productSpuId}
</if> </if>
<if test="type != null"> <if test="type != null">
type = #{type} AND type = #{type}
</if> </if>
AND deleted = 0 AND deleted = 0
</where> </where>
</select> </select>
<select id="selectListByTypeAndStatus" parameterType="Integer" resultType="BannerDO"> <select id="selectListByTypeAndStatus" parameterType="Integer" resultType="ProductRecommendDO">
SELECT SELECT
<include refid="FIELDS" /> <include refid="FIELDS" />
FROM product_recommend FROM product_recommend
@ -56,13 +56,13 @@
type = #{type} type = #{type}
</if> </if>
<if test="status != null"> <if test="status != null">
status = #{status} AND status = #{status}
</if> </if>
AND deleted = 0 AND deleted = 0
</where> </where>
</select> </select>
<select id="selectPageByType" resultType="BannerDO"> <select id="selectPageByType" resultType="ProductRecommendDO">
SELECT SELECT
<include refid="FIELDS" /> <include refid="FIELDS" />
FROM product_recommend FROM product_recommend
@ -87,7 +87,7 @@
</where> </where>
</select> </select>
<insert id="insert" parameterType="BannerDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id"> <insert id="insert" parameterType="ProductRecommendDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO product_recommend ( INSERT INTO product_recommend (
type, product_spu_id, sort, status, memo, type, product_spu_id, sort, status, memo,
create_time, deleted create_time, deleted
@ -97,7 +97,7 @@
) )
</insert> </insert>
<update id="update" parameterType="BannerDO"> <update id="update" parameterType="ProductRecommendDO">
UPDATE product_recommend UPDATE product_recommend
<set> <set>
<if test="type != null"> <if test="type != null">