Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
4300ce14
提交
4300ce14
authored
4月 10, 2019
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
后端:商品确认下单的信息 api 接口,后续需要结合促销,完善这个接口。
上级
50d8ec33
隐藏空白字符变更
内嵌
并排
正在显示
29 个修改的文件
包含
688 行增加
和
84 行删除
+688
-84
order.js
mobile-web/src/api/order.js
+11
-0
productcard.vue
mobile-web/src/components/common/productcard.vue
+12
-7
order.vue
mobile-web/src/page/shipping/order.vue
+36
-5
UsersOrderController.java
...er/application/controller/users/UsersOrderController.java
+26
-2
CartConvert.java
...n/iocoder/mall/order/application/convert/CartConvert.java
+15
-0
UsersOrderConfirmCreateVO.java
.../mall/order/application/vo/UsersOrderConfirmCreateVO.java
+152
-0
pom.xml
order/order-service-api/pom.xml
+8
-3
CartService.java
.../src/main/java/cn/iocoder/mall/order/api/CartService.java
+10
-0
OrderService.java
...src/main/java/cn/iocoder/mall/order/api/OrderService.java
+0
-8
CalcOrderPriceBO.java
...n/java/cn/iocoder/mall/order/api/bo/CalcOrderPriceBO.java
+19
-3
OrderErrorCodeEnum.java
...n/iocoder/mall/order/api/constant/OrderErrorCodeEnum.java
+1
-1
CalcOrderPriceDTO.java
...java/cn/iocoder/mall/order/api/dto/CalcOrderPriceDTO.java
+10
-2
CartConvert.java
...n/java/cn/iocoder/mall/order/biz/convert/CartConvert.java
+15
-0
ProductSpuServiceMock.java
...cn/iocoder/mall/order/biz/mock/ProductSpuServiceMock.java
+9
-1
CartServiceImpl.java
...va/cn/iocoder/mall/order/biz/service/CartServiceImpl.java
+120
-0
OrderServiceImpl.java
...a/cn/iocoder/mall/order/biz/service/OrderServiceImpl.java
+0
-5
AdminsProductSpuController.java
...ication/controller/admins/AdminsProductSpuController.java
+2
-3
UsersProductSpuController.java
...plication/controller/users/UsersProductSpuController.java
+2
-3
ProductSpuService.java
...n/java/cn/iocoder/mall/product/api/ProductSpuService.java
+9
-10
ProductSkuDetailBO.java
...va/cn/iocoder/mall/product/api/bo/ProductSkuDetailBO.java
+53
-3
ProductSpuDetailBO.java
...va/cn/iocoder/mall/product/api/bo/ProductSpuDetailBO.java
+35
-1
ProductSpuConvert.java
...va/cn/iocoder/mall/product/convert/ProductSpuConvert.java
+37
-4
ProductSkuMapper.java
...in/java/cn/iocoder/mall/product/dao/ProductSkuMapper.java
+4
-2
ProductSpuServiceImpl.java
...n/iocoder/mall/product/service/ProductSpuServiceImpl.java
+25
-11
ProductSkuMapper.xml
...rvice-impl/src/main/resources/mapper/ProductSkuMapper.xml
+13
-3
pom.xml
promotion/promotion-application/pom.xml
+0
-3
PromotionActivityTypeEnum.java
...all/promotion/api/constant/PromotionActivityTypeEnum.java
+34
-0
PromotionActivityDO.java
...er/mall/promotion/biz/dataobject/PromotionActivityDO.java
+27
-0
ProductRecommendServiceImpl.java
...ll/promotion/biz/service/ProductRecommendServiceImpl.java
+3
-4
没有找到文件。
mobile-web/src/api/order.js
浏览文件 @
4300ce14
...
...
@@ -21,6 +21,17 @@ export function cancelOrder(id) {
});
}
export
function
getConfirmCreateOrder
(
skuId
,
quantity
)
{
return
request
({
url
:
'/order-api/users/order/confirm_create_order'
,
method
:
'get'
,
params
:
{
skuId
,
quantity
,
}
});
}
export
function
createOrder
(
params
)
{
return
request
({
headers
:
{
...
...
mobile-web/src/components/common/productcard.vue
浏览文件 @
4300ce14
...
...
@@ -8,17 +8,22 @@
style=
"background:#fff"
>
<template
slot=
"thumb"
>
<img
:src=
"product.picUrl"
/>
<p
v-if=
"product.imageTag!=null&&product.imageTag!=''"
class=
"image_tag"
>
{{
product
.
imageTag
}}
</p>
<!-- TODO 芋艿 暂时去掉,等会就恢复 -->
<!--
<img
:src=
"product.picUrls[0]"
/>
-->
<!-- TODO 芋艿 暂时去掉 -->
<!--
<p
v-if=
"product.imageTag!=null&&product.imageTag!=''"
class=
"image_tag"
>
{{
product
.
imageTag
}}
</p>
-->
</
template
>
<
template
slot=
"tags"
>
<p
class=
"price"
v-if=
"product.price!=null
&&product.price!=
''"
>
<p
class=
"price"
v-if=
"product.price!=null
&& product.price !==
''"
>
¥
<span>
{{
product
.
price
}}
</span>
<van-tag
v-if=
"product.tags!=null"
v-for=
"tag in product.tags"
:key=
"tag"
plain
type=
"danger"
>
{{
tag
}}
</van-tag>
<!-- TODO 芋艿 暂时去掉 -->
<!--
<van-tag
v-if=
"product.tags!=null"
v-for=
"tag in product.tags"
:key=
"tag"
plain
type=
"danger"
>
-->
<!--
{{
tag
}}
-->
<!--
</van-tag>
-->
</p>
<van-stepper
v-if=
"iscard"
v-model=
"product.quantity"
:max=
"product.max"
:min=
"product.min"
/>
<!-- TODO 芋艿 暂时去掉 -->
<!--
<van-stepper
v-if=
"iscard"
v-model=
"product.quantity"
:max=
"product.max"
:min=
"product.min"
/>
-->
</
template
>
</van-card>
<!-- TODO 芋艿,暂时去掉赠品 -->
...
...
mobile-web/src/page/shipping/order.vue
浏览文件 @
4300ce14
...
...
@@ -17,9 +17,11 @@
</
template
>
</van-cell>
<div
style=
"height:15px;"
></div>
<div
class=
"card"
v-for=
"(product,i) in products"
:key=
"i"
>
<product-card
:product=
'product'
/>
</div>
<div
style=
"height:15px;"
></div>
<van-cell-group>
<van-field
...
...
@@ -37,10 +39,10 @@
<div
style=
"height:15px;"
></div>
<van-cell-group
class=
"total"
>
<van-cell
title=
"商品总额"
value=
"9.99
"
/>
<van-cell
title=
"运费"
value=
"+ 0.00
"
/>
<van-cell
title=
"折扣"
value=
"- 5.00
"
/>
<van-cell
title=
"实付金额"
value=
"4.99
"
style=
"font-weight: 700;"
/>
<van-cell
title=
"商品总额"
:value=
"fee.originalTotal
"
/>
<van-cell
title=
"运费"
:value=
"+ fee.postageTotal
"
/>
<van-cell
title=
"折扣"
:value=
"- fee.discountTotal
"
/>
<van-cell
title=
"实付金额"
:value=
"fee.presentTotal
"
style=
"font-weight: 700;"
/>
</van-cell-group>
<div
style=
"height:50px;"
></div>
...
...
@@ -56,7 +58,7 @@
<
script
>
import
{
createOrder
}
from
'../../api/order'
;
import
{
createOrder
,
getConfirmCreateOrder
}
from
'../../api/order'
;
import
{
GetDefaultAddress
}
from
'../../api/user'
;
import
orderStore
from
'../../store/order'
import
eventBus
from
'../eventBus'
;
...
...
@@ -64,10 +66,25 @@
export
default
{
data
()
{
return
{
from
:
'direct_order'
,
// 目前有两个来源。direct_order:直接下单; card: 购物车下单。
// 如下两个参数,在直接下单时使用
skuId
:
this
.
$route
.
query
.
skuId
,
quantity
:
this
.
$route
.
query
.
quantity
,
type
:
"add"
,
addressData
:
{
},
itemGroups
:
[],
fee
:
{
originalTotal
:
undefined
,
discountTotal
:
undefined
,
postageTotal
:
undefined
,
presentTotal
:
undefined
,
},
products
:
[
{
imageURL
:
...
...
@@ -124,6 +141,9 @@
remark
,
})
},
convertProduct
()
{
}
},
mounted
:
function
()
{
if
(
this
.
$store
.
state
.
addressData
.
name
)
{
...
...
@@ -132,14 +152,25 @@
this
.
type
=
'add'
;
}
this
.
addressData
=
this
.
$store
.
state
.
addressData
;
// 加载商品信息
if
(
this
.
from
===
'direct_order'
)
{
getConfirmCreateOrder
(
this
.
skuId
,
this
.
quantity
).
then
(
data
=>
{
this
.
itemGroups
=
data
.
itemGroups
;
this
.
fee
=
data
.
fee
;
})
}
},
created
()
{
// 加载地址
GetDefaultAddress
().
then
((
result
)
=>
{
if
(
result
)
{
this
.
type
=
'add1'
this
.
addressData
=
result
}
})
// 处理来源
},
store
:
orderStore
,
};
...
...
order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/UsersOrderController.java
浏览文件 @
4300ce14
package
cn
.
iocoder
.
mall
.
order
.
application
.
controller
.
users
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.order.api.CartService
;
import
cn.iocoder.mall.order.api.OrderService
;
import
cn.iocoder.mall.order.api.bo.CalcOrderPriceBO
;
import
cn.iocoder.mall.order.api.bo.OrderCreateBO
;
import
cn.iocoder.mall.order.api.bo.OrderPageBO
;
import
cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO
;
import
cn.iocoder.mall.order.api.dto.OrderCreateDTO
;
import
cn.iocoder.mall.order.api.dto.OrderQueryDTO
;
import
cn.iocoder.mall.order.application.convert.CartConvert
;
import
cn.iocoder.mall.order.application.convert.OrderConvertAPP
;
import
cn.iocoder.mall.order.application.po.user.OrderCreatePO
;
import
cn.iocoder.mall.order.application.vo.UsersOrderConfirmCreateVO
;
import
cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.alibaba.dubbo.config.annotation.Reference
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Collections
;
/**
* 订单API(users)
*
...
...
@@ -23,8 +30,10 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping
(
"users/order"
)
public
class
UsersOrderController
{
@
Autowired
@
Reference
(
validation
=
"true"
)
private
OrderService
orderService
;
@Reference
(
validation
=
"true"
)
private
CartService
cartService
;
@GetMapping
(
"order_page"
)
public
CommonResult
<
OrderPageBO
>
getOrderPage
(
@Validated
OrderQueryDTO
orderQueryDTO
)
{
...
...
@@ -40,4 +49,19 @@ public class UsersOrderController {
orderCreateDTO
.
setUserId
(
userId
);
return
orderService
.
createOrder
(
orderCreateDTO
);
}
@GetMapping
(
"/confirm_create_order"
)
public
CommonResult
<
UsersOrderConfirmCreateVO
>
getConfirmCreateOrder
(
@RequestParam
(
"skuId"
)
Integer
skuId
,
@RequestParam
(
"quantity"
)
Integer
quantity
)
{
// 创建 CalcOrderPriceDTO 对象,并执行价格计算
CalcOrderPriceDTO
calcOrderPriceDTO
=
new
CalcOrderPriceDTO
()
.
setItems
(
Collections
.
singletonList
(
new
CalcOrderPriceDTO
.
Item
(
skuId
,
quantity
,
true
)));
CommonResult
<
CalcOrderPriceBO
>
calcOrderPriceResult
=
cartService
.
calcOrderPrice
(
calcOrderPriceDTO
);
if
(
calcOrderPriceResult
.
isError
())
{
return
CommonResult
.
error
(
calcOrderPriceResult
);
}
// 执行数据拼装
return
CommonResult
.
success
(
CartConvert
.
INSTANCE
.
convert
(
calcOrderPriceResult
.
getData
()));
}
}
order/order-application/src/main/java/cn/iocoder/mall/order/application/convert/CartConvert.java
0 → 100644
浏览文件 @
4300ce14
package
cn
.
iocoder
.
mall
.
order
.
application
.
convert
;
import
cn.iocoder.mall.order.api.bo.CalcOrderPriceBO
;
import
cn.iocoder.mall.order.application.vo.UsersOrderConfirmCreateVO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.factory.Mappers
;
@Mapper
public
interface
CartConvert
{
CartConvert
INSTANCE
=
Mappers
.
getMapper
(
CartConvert
.
class
);
UsersOrderConfirmCreateVO
convert
(
CalcOrderPriceBO
calcOrderPriceBO
);
}
order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/UsersOrderConfirmCreateVO.java
0 → 100644
浏览文件 @
4300ce14
package
cn
.
iocoder
.
mall
.
order
.
application
.
vo
;
import
cn.iocoder.mall.product.api.bo.ProductAttrAndValuePairBO
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.util.List
;
@Data
@Accessors
(
chain
=
true
)
public
class
UsersOrderConfirmCreateVO
{
/**
* 商品分组数组
*/
private
List
<
ItemGroup
>
itemGroups
;
/**
* 费用
*/
private
Fee
fee
;
/**
* 商品分组
*
* 多个商品,参加同一个活动,从而形成分组。
*/
@Data
@Accessors
(
chain
=
true
)
public
static
class
ItemGroup
{
// TODO 优惠活动
private
Object
activity
;
/**
* 商品数组
*/
private
List
<
Sku
>
items
;
}
@Data
@Accessors
(
chain
=
true
)
public
static
class
Sku
{
// SKU 自带信息
/**
* sku 编号
*/
private
Integer
id
;
/**
* SPU 信息
*/
private
Spu
spu
;
/**
* 图片地址
*/
private
String
picURL
;
/**
* 规格值数组
*/
private
List
<
ProductAttrAndValuePairBO
>
attrs
;
// TODO 后面改下
/**
* 价格,单位:分
*/
private
Integer
price
;
/**
* 库存数量
*/
private
Integer
quantity
;
// 非 SKU 自带信息
/**
* 购买数量
*/
private
Integer
buyQuantity
;
}
@Data
@Accessors
(
chain
=
true
)
public
static
class
Spu
{
/**
* SPU 编号
*/
private
Integer
id
;
// ========== 基本信息 =========
/**
* SPU 名字
*/
private
String
name
;
/**
* 分类编号
*/
private
Integer
cid
;
/**
* 商品主图地址
*
* 数组,以逗号分隔
*
* 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张
*/
private
List
<
String
>
picUrls
;
}
/**
* 费用(合计)
*/
@Data
@Accessors
(
chain
=
true
)
public
static
class
Fee
{
/**
* 总价
*/
private
Integer
originalTotal
;
/**
* 优惠总价
*
* 注意,满多少元包邮,不算在优惠中。
*/
private
Integer
discountTotal
;
/**
* 邮费
*/
private
Integer
postageTotal
;
/**
* 最终价格
*
* 计算公式 = 总价 - 优惠总价 + 邮费
*/
private
Integer
presentTotal
;
}
/**
* 邮费信息
*/
@Data
@Accessors
(
chain
=
true
)
public
static
class
Postage
{
/**
* 需要满足多少钱,可以包邮。单位:分
*/
private
Integer
threshold
;
}
}
order/order-service-api/pom.xml
浏览文件 @
4300ce14
...
...
@@ -16,8 +16,13 @@
<groupId>
cn.iocoder.mall
</groupId>
<artifactId>
common-framework
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
cn.iocoder.mall
</groupId>
<artifactId>
product-service-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
javax.validation
</groupId>
<artifactId>
validation-api
</artifactId>
...
...
@@ -34,5 +39,6 @@
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
</project>
order/order-service-api/src/main/java/cn/iocoder/mall/order/api/CartService.java
浏览文件 @
4300ce14
package
cn
.
iocoder
.
mall
.
order
.
api
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.order.api.bo.CalcOrderPriceBO
;
import
cn.iocoder.mall.order.api.bo.CartBO
;
import
cn.iocoder.mall.order.api.bo.CartItemBO
;
import
cn.iocoder.mall.order.api.bo.OrderCreateBO
;
import
cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO
;
import
org.springframework.lang.Nullable
;
import
java.util.List
;
...
...
@@ -78,6 +80,14 @@ public interface CartService {
// ========== 购物车与订单相关的逻辑 ==========
/**
* 计算订单金额,返回计算结果
*
* @param calcOrderPriceDTO 计算订单金额 DTO
* @return 计算订单金额结果
*/
CommonResult
<
CalcOrderPriceBO
>
calcOrderPrice
(
CalcOrderPriceDTO
calcOrderPriceDTO
);
/**
* 获得购物车明细
*
...
...
order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderService.java
浏览文件 @
4300ce14
...
...
@@ -38,14 +38,6 @@ public interface OrderService {
*/
CommonResult
<
OrderRecipientBO
>
getOrderRecipientBO
(
Integer
orderId
);
/**
* 计算订单金额,返回计算结果
*
* @param calcOrderPriceDTO 计算订单金额 DTO
* @return 计算订单金额结果
*/
CalcOrderPriceBO
calcOrderPrice
(
CalcOrderPriceDTO
calcOrderPriceDTO
);
/**
* 订单 - 创建
*
...
...
order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/CalcOrderPriceBO.java
浏览文件 @
4300ce14
package
cn
.
iocoder
.
mall
.
order
.
api
.
bo
;
import
cn.iocoder.mall.product.api.bo.ProductSkuDetailBO
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
...
...
@@ -45,10 +46,16 @@ public class CalcOrderPriceBO {
@Data
@Accessors
(
chain
=
true
)
public
static
class
Item
{
// TODO 信息要相当完整
public
static
class
Item
extends
ProductSkuDetailBO
{
// TODO 芋艿,此处先偷懒继承
/**
* 是否选中
*/
private
Boolean
selected
;
/**
* 购买数量
*/
private
Integer
buyQuantity
;
}
...
...
@@ -80,6 +87,15 @@ public class CalcOrderPriceBO {
*/
private
Integer
presentTotal
;
public
Fee
()
{
}
public
Fee
(
Integer
originalTotal
,
Integer
discountTotal
,
Integer
postageTotal
,
Integer
presentTotal
)
{
this
.
originalTotal
=
originalTotal
;
this
.
discountTotal
=
discountTotal
;
this
.
postageTotal
=
postageTotal
;
this
.
presentTotal
=
presentTotal
;
}
}
/**
...
...
order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderErrorCodeEnum.java
浏览文件 @
4300ce14
...
...
@@ -25,7 +25,7 @@ public enum OrderErrorCodeEnum {
// order item
ORDER_ITEM_ONLY_ONE
(
1008000004
,
"订单Item只有一个!"
),
ORDER_ITEM_SOME_NOT_EXISTS
(-
1
,
"有不存在的商品"
),
// TODO 芋艿 后面改下错误码
;
...
...
order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/CalcOrderPriceDTO.java
浏览文件 @
4300ce14
...
...
@@ -15,11 +15,11 @@ public class CalcOrderPriceDTO {
/**
* 商品数组
*/
private
List
<
I
nteger
>
items
;
private
List
<
I
tem
>
items
;
@Data
@Accessors
(
chain
=
true
)
p
rivate
static
class
Item
{
p
ublic
static
class
Item
{
/**
* SKU 编号
...
...
@@ -36,6 +36,14 @@ public class CalcOrderPriceDTO {
*/
private
Boolean
selected
;
public
Item
()
{
}
public
Item
(
Integer
skuId
,
Integer
quantity
,
Boolean
selected
)
{
this
.
skuId
=
skuId
;
this
.
quantity
=
quantity
;
this
.
selected
=
selected
;
}
}
}
order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/convert/CartConvert.java
0 → 100644
浏览文件 @
4300ce14
package
cn
.
iocoder
.
mall
.
order
.
biz
.
convert
;
import
cn.iocoder.mall.order.api.bo.CalcOrderPriceBO
;
import
cn.iocoder.mall.product.api.bo.ProductSkuDetailBO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.factory.Mappers
;
@Mapper
public
interface
CartConvert
{
CartConvert
INSTANCE
=
Mappers
.
getMapper
(
CartConvert
.
class
);
CalcOrderPriceBO
.
Item
convert
(
ProductSkuDetailBO
sku
);
}
order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/mock/ProductSpuServiceMock.java
浏览文件 @
4300ce14
...
...
@@ -2,6 +2,7 @@ package cn.iocoder.mall.order.biz.mock;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.product.api.ProductSpuService
;
import
cn.iocoder.mall.product.api.bo.ProductSkuDetailBO
;
import
cn.iocoder.mall.product.api.bo.ProductSpuBO
;
import
cn.iocoder.mall.product.api.bo.ProductSpuDetailBO
;
import
cn.iocoder.mall.product.api.bo.ProductSpuPageBO
;
...
...
@@ -17,8 +18,9 @@ import java.util.List;
* @time 2019-03-24 15:24
*/
public
class
ProductSpuServiceMock
implements
ProductSpuService
{
@Override
public
CommonResult
<
ProductSpuDetailBO
>
getProductSpu
(
Integer
id
)
{
public
CommonResult
<
ProductSpuDetailBO
>
getProductSpu
Detail
(
Integer
id
)
{
return
null
;
}
...
...
@@ -46,4 +48,10 @@ public class ProductSpuServiceMock implements ProductSpuService {
public
CommonResult
<
List
<
ProductSpuBO
>>
getProductSpuList
(
Collection
<
Integer
>
ids
)
{
return
null
;
}
@Override
public
CommonResult
<
List
<
ProductSkuDetailBO
>>
getProductSkuDetailList
(
Collection
<
Integer
>
ids
)
{
return
null
;
}
}
order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/CartServiceImpl.java
0 → 100644
浏览文件 @
4300ce14
package
cn
.
iocoder
.
mall
.
order
.
biz
.
service
;
import
cn.iocoder.common.framework.util.ServiceExceptionUtil
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.order.api.CartService
;
import
cn.iocoder.mall.order.api.bo.CalcOrderPriceBO
;
import
cn.iocoder.mall.order.api.bo.CartBO
;
import
cn.iocoder.mall.order.api.bo.CartItemBO
;
import
cn.iocoder.mall.order.api.bo.OrderCreateBO
;
import
cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum
;
import
cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO
;
import
cn.iocoder.mall.order.biz.convert.CartConvert
;
import
cn.iocoder.mall.product.api.ProductSpuService
;
import
cn.iocoder.mall.product.api.bo.ProductSkuDetailBO
;
import
com.alibaba.dubbo.config.annotation.Reference
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* 购物车服务 Service 实现类
*/
@Service
@com
.
alibaba
.
dubbo
.
config
.
annotation
.
Service
(
validation
=
"true"
)
public
class
CartServiceImpl
implements
CartService
{
@Reference
(
validation
=
"true"
)
private
ProductSpuService
productSpuService
;
@Override
public
CommonResult
<
Boolean
>
add
(
Integer
userId
,
Integer
skuId
,
Integer
quantity
)
{
return
null
;
}
@Override
public
CommonResult
<
Boolean
>
updateQuantity
(
Integer
userId
,
Integer
skuId
,
Integer
quantity
)
{
return
null
;
}
@Override
public
CommonResult
<
Boolean
>
updateSelected
(
Integer
userId
,
Integer
skuId
)
{
return
null
;
}
@Override
public
CommonResult
<
Boolean
>
delete
(
Integer
userId
,
List
<
Integer
>
skuIds
)
{
return
null
;
}
@Override
public
CommonResult
<
Boolean
>
deleteAll
(
Integer
userId
)
{
return
null
;
}
@Override
public
CommonResult
<
Integer
>
count
(
Integer
userId
,
String
nobody
,
Integer
shopId
)
{
return
null
;
}
@Override
public
List
<
CartItemBO
>
list
(
Integer
userId
,
Boolean
selected
)
{
return
null
;
}
@Override
public
CommonResult
<
CalcOrderPriceBO
>
calcOrderPrice
(
CalcOrderPriceDTO
calcOrderPriceDTO
)
{
// 校验商品都存在
Map
<
Integer
,
CalcOrderPriceDTO
.
Item
>
calcOrderItemMap
=
calcOrderPriceDTO
.
getItems
().
stream
()
.
collect
(
Collectors
.
toMap
(
CalcOrderPriceDTO
.
Item
::
getSkuId
,
item
->
item
));
List
<
ProductSkuDetailBO
>
skus
=
productSpuService
.
getProductSkuDetailList
(
calcOrderItemMap
.
keySet
()).
getData
();
if
(
skus
.
size
()
!=
calcOrderPriceDTO
.
getItems
().
size
())
{
return
ServiceExceptionUtil
.
error
(
OrderErrorCodeEnum
.
ORDER_ITEM_SOME_NOT_EXISTS
.
getCode
());
}
// TODO 库存相关
// TODO 获得促销活动
// TODO 处理促销相关信息
// 拼装结果
CalcOrderPriceBO
calcOrderPriceBO
=
new
CalcOrderPriceBO
();
// 1. 商品分组
CalcOrderPriceBO
.
ItemGroup
itemGroup0
=
new
CalcOrderPriceBO
.
ItemGroup
()
.
setItems
(
new
ArrayList
<>());
for
(
ProductSkuDetailBO
sku
:
skus
)
{
CalcOrderPriceBO
.
Item
item
=
CartConvert
.
INSTANCE
.
convert
(
sku
);
// 将是否选中,购物数量,复制到 item 中
CalcOrderPriceDTO
.
Item
calcOrderItem
=
calcOrderItemMap
.
get
(
sku
.
getId
());
item
.
setSelected
(
calcOrderItem
.
getSelected
());
item
.
setBuyQuantity
(
calcOrderItem
.
getQuantity
());
// 添加到 itemGroup 中
itemGroup0
.
getItems
().
add
(
item
);
}
calcOrderPriceBO
.
setItemGroups
(
Collections
.
singletonList
(
itemGroup0
));
// 2. 计算价格
CalcOrderPriceBO
.
Fee
fee
=
new
CalcOrderPriceBO
.
Fee
(
0
,
0
,
0
,
0
);
for
(
CalcOrderPriceBO
.
ItemGroup
itemGroup
:
calcOrderPriceBO
.
getItemGroups
())
{
int
originalTotal
=
0
;
for
(
CalcOrderPriceBO
.
Item
item
:
itemGroup
.
getItems
())
{
if
(!
item
.
getSelected
())
{
// 未选中,则不计算到其中
continue
;
}
originalTotal
+=
item
.
getPrice
()
*
item
.
getBuyQuantity
();
}
fee
.
setOriginalTotal
(
fee
.
getOriginalTotal
()
+
originalTotal
);
fee
.
setPresentTotal
(
fee
.
getOriginalTotal
());
// TODO 芋艿,后续要计算优惠价格
}
calcOrderPriceBO
.
setFee
(
fee
);
// 返回
return
CommonResult
.
success
(
calcOrderPriceBO
);
}
@Override
public
CommonResult
<
CartBO
>
details
(
Integer
userId
)
{
return
null
;
}
@Override
public
CommonResult
<
OrderCreateBO
>
createOrder
(
Integer
userId
)
{
return
null
;
}
}
order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderServiceImpl.java
浏览文件 @
4300ce14
...
...
@@ -157,11 +157,6 @@ public class OrderServiceImpl implements OrderService {
return
CommonResult
.
success
(
orderRecipientBO
);
}
@Override
public
CalcOrderPriceBO
calcOrderPrice
(
CalcOrderPriceDTO
calcOrderPriceDTO
)
{
return
null
;
}
@Override
@Transactional
public
CommonResult
<
OrderCreateBO
>
createOrder
(
OrderCreateDTO
orderCreateDTO
)
{
...
...
product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java
浏览文件 @
4300ce14
...
...
@@ -123,7 +123,7 @@ public class AdminsProductSpuController {
@ApiOperation
(
"商品 SPU 明细"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"SPU 编号"
,
required
=
true
,
example
=
"100"
)
public
CommonResult
<
AdminsProductSpuDetailVO
>
info
(
@RequestParam
(
"id"
)
Integer
id
)
{
return
ProductSpuConvert
.
INSTANCE
.
convert
(
productSpuService
.
getProductSpu
(
id
));
return
ProductSpuConvert
.
INSTANCE
.
convert
(
productSpuService
.
getProductSpu
Detail
(
id
));
}
private
<
T
>
List
<
T
>
parseSkus
(
String
skuStr
,
Class
<
T
>
clazz
)
{
...
...
@@ -135,4 +135,4 @@ public class AdminsProductSpuController {
}
}
}
\ No newline at end of file
}
product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductSpuController.java
浏览文件 @
4300ce14
...
...
@@ -29,7 +29,7 @@ public class UsersProductSpuController {
@ApiOperation
(
"商品 SPU 明细"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"SPU 编号"
,
required
=
true
,
example
=
"100"
)
public
CommonResult
<
UsersProductSpuDetailVO
>
info
(
@RequestParam
(
"id"
)
Integer
id
)
{
return
ProductSpuConvert
.
INSTANCE
.
convert4
(
productSpuService
.
getProductSpu
(
id
));
return
ProductSpuConvert
.
INSTANCE
.
convert4
(
productSpuService
.
getProductSpu
Detail
(
id
));
}
@GetMapping
(
"/page"
)
...
...
@@ -51,4 +51,4 @@ public class UsersProductSpuController {
return
ProductSpuConvert
.
INSTANCE
.
convert3
(
result
);
}
}
\ No newline at end of file
}
product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductSpuService.java
浏览文件 @
4300ce14
package
cn
.
iocoder
.
mall
.
product
.
api
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.product.api.bo.ProductSpuBO
;
import
cn.iocoder.mall.product.api.bo.ProductSpuDetailBO
;
import
cn.iocoder.mall.product.api.bo.ProductSpuPageBO
;
import
cn.iocoder.mall.product.api.bo.*
;
import
cn.iocoder.mall.product.api.dto.ProductSpuAddDTO
;
import
cn.iocoder.mall.product.api.dto.ProductSpuPageDTO
;
import
cn.iocoder.mall.product.api.dto.ProductSpuUpdateDTO
;
...
...
@@ -13,7 +11,13 @@ import java.util.List;
public
interface
ProductSpuService
{
CommonResult
<
ProductSpuDetailBO
>
getProductSpu
(
Integer
id
);
CommonResult
<
ProductSpuDetailBO
>
getProductSpuDetail
(
Integer
id
);
CommonResult
<
ProductSpuPageBO
>
getProductSpuPage
(
ProductSpuPageDTO
productSpuPageDTO
);
CommonResult
<
List
<
ProductSpuBO
>>
getProductSpuList
(
Collection
<
Integer
>
ids
);
CommonResult
<
List
<
ProductSkuDetailBO
>>
getProductSkuDetailList
(
Collection
<
Integer
>
ids
);
CommonResult
<
ProductSpuDetailBO
>
addProductSpu
(
Integer
adminId
,
ProductSpuAddDTO
productSpuAddDTO
);
...
...
@@ -21,8 +25,4 @@ public interface ProductSpuService {
CommonResult
<
Boolean
>
updateProductSpuSort
(
Integer
adminId
,
Integer
spuId
,
Integer
sort
);
CommonResult
<
ProductSpuPageBO
>
getProductSpuPage
(
ProductSpuPageDTO
productSpuPageDTO
);
CommonResult
<
List
<
ProductSpuBO
>>
getProductSpuList
(
Collection
<
Integer
>
ids
);
}
\ No newline at end of file
}
product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSkuDetailBO.java
浏览文件 @
4300ce14
...
...
@@ -7,7 +7,7 @@ import java.io.Serializable;
import
java.util.List
;
/**
* 商品 Sku 明细 BO
* 商品 Sku 明细 BO
(包括 Spu 明细)
*/
@Data
@Accessors
(
chain
=
true
)
...
...
@@ -18,9 +18,9 @@ public class ProductSkuDetailBO implements Serializable {
*/
private
Integer
id
;
/**
*
商品编号
*
SPU 信息
*/
private
Integer
spuId
;
private
Spu
spu
;
/**
* 图片地址
*/
...
...
@@ -38,4 +38,54 @@ public class ProductSkuDetailBO implements Serializable {
*/
private
Integer
quantity
;
@Data
@Accessors
(
chain
=
true
)
public
static
class
Spu
implements
Serializable
{
/**
* SPU 编号
*/
private
Integer
id
;
// ========== 基本信息 =========
/**
* SPU 名字
*/
private
String
name
;
/**
* 卖点
*/
private
String
sellPoint
;
/**
* 描述
*/
private
String
description
;
/**
* 分类编号
*/
private
Integer
cid
;
/**
* 商品主图地址
*
* 数组,以逗号分隔
*
* 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张
*/
private
List
<
String
>
picUrls
;
// ========== 其他信息 =========
/**
* 是否上架商品(是否可见)。
*
* true 为已上架
* false 为已下架
*/
private
Boolean
visible
;
/**
* 排序字段
*/
private
Integer
sort
;
}
}
product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSpuDetailBO.java
浏览文件 @
4300ce14
...
...
@@ -62,6 +62,40 @@ public class ProductSpuDetailBO implements Serializable {
/**
* SKU 数组
*/
private
List
<
ProductSkuDetailBO
>
skus
;
private
List
<
Sku
>
skus
;
/**
* 商品 Sku 明细 BO
*/
@Data
@Accessors
(
chain
=
true
)
public
static
class
Sku
implements
Serializable
{
/**
* sku 编号
*/
private
Integer
id
;
/**
* 商品编号
*/
private
Integer
spuId
;
/**
* 图片地址
*/
private
String
picURL
;
/**
* 规格值数组
*/
private
List
<
ProductAttrAndValuePairBO
>
attrs
;
/**
* 价格,单位:分
*/
private
Integer
price
;
/**
* 库存数量
*/
private
Integer
quantity
;
}
}
product/product-service-impl/src/main/java/cn/iocoder/mall/product/convert/ProductSpuConvert.java
浏览文件 @
4300ce14
...
...
@@ -58,10 +58,20 @@ public interface ProductSpuConvert {
})
ProductSpuDetailBO
convert2
(
ProductSpuDO
spu
);
@Mappings
({
@Mapping
(
source
=
"picUrls"
,
target
=
"picUrls"
,
ignore
=
true
)
})
ProductSkuDetailBO
.
Spu
convert3
(
ProductSpuDO
spu
);
@Mappings
({
@Mapping
(
source
=
"attrs"
,
target
=
"attrs"
,
ignore
=
true
)
})
ProductSkuDetailBO
convert2
(
ProductSkuDO
sku
);
ProductSpuDetailBO
.
Sku
convert2
(
ProductSkuDO
sku
);
@Mappings
({
@Mapping
(
source
=
"attrs"
,
target
=
"attrs"
,
ignore
=
true
)
})
ProductSkuDetailBO
convert3
(
ProductSkuDO
sku
);
@Mappings
({})
// TODO 芋艿,后续细看下 mapstruct 的 API ,优化这块
default
ProductSpuDetailBO
convert2
(
ProductSpuDO
spu
,
List
<
ProductSkuDO
>
skus
,
List
<
ProductAttrAndValuePairBO
>
productAttrDetailBOs
)
{
...
...
@@ -74,7 +84,7 @@ public interface ProductSpuConvert {
spuDetail
.
setSkus
(
new
ArrayList
<>());
skus
.
forEach
(
sku
->
{
// 创建 ProductSpuDetailBO 对象
ProductS
kuDetailBO
skuDetail
=
ProductSpuConvert
.
this
.
convert2
(
sku
)
ProductS
puDetailBO
.
Sku
skuDetail
=
ProductSpuConvert
.
this
.
convert2
(
sku
)
.
setAttrs
(
new
ArrayList
<>());
spuDetail
.
getSkus
().
add
(
skuDetail
);
// 设置 ProductSpuDetailBO 的 attrs 规格属性
...
...
@@ -85,9 +95,33 @@ public interface ProductSpuConvert {
return
spuDetail
;
}
@Mappings
({})
// TODO 芋艿,后续细看下 mapstruct 的 API ,优化这块
default
List
<
ProductSkuDetailBO
>
convert3
(
List
<
ProductSkuDO
>
skus
,
List
<
ProductSpuDO
>
spus
,
List
<
ProductAttrAndValuePairBO
>
productAttrDetailBOs
)
{
// 创建 ProductAttrDetailBO 的映射。其中,KEY 为 ProductAttrDetailBO.attrValueId ,即规格值的编号
Map
<
Integer
,
ProductAttrAndValuePairBO
>
productAttrDetailBOMap
=
productAttrDetailBOs
.
stream
().
collect
(
Collectors
.
toMap
(
ProductAttrAndValuePairBO:
:
getAttrValueId
,
productAttrDetailBO
->
productAttrDetailBO
));
// 创建 ProductSpuDO 的映射
Map
<
Integer
,
ProductSkuDetailBO
.
Spu
>
spuMap
=
spus
.
stream
().
collect
(
Collectors
.
toMap
(
ProductSpuDO:
:
getId
,
spu
->
ProductSpuConvert
.
this
.
convert3
(
spu
).
setPicUrls
(
StringUtil
.
split
(
spu
.
getPicUrls
(),
","
))));
// 拼装结果
List
<
ProductSkuDetailBO
>
spuDetailList
=
new
ArrayList
<>(
skus
.
size
());
for
(
ProductSkuDO
sku
:
skus
)
{
// 创建 ProductSkuDetailBO 对象
ProductSkuDetailBO
skuDetail
=
ProductSpuConvert
.
this
.
convert3
(
sku
)
.
setAttrs
(
new
ArrayList
<>())
.
setSpu
(
spuMap
.
get
(
sku
.
getSpuId
()));
spuDetailList
.
add
(
skuDetail
);
// 设置 ProductSpuDetailBO 的 attrs 规格属性
List
<
String
>
attrs
=
StringUtil
.
split
(
sku
.
getAttrs
(),
","
);
attrs
.
forEach
(
attr
->
skuDetail
.
getAttrs
().
add
(
productAttrDetailBOMap
.
get
(
Integer
.
valueOf
(
attr
))));
}
// 返回
return
spuDetailList
;
}
@Named
(
"translatePicUrlsFromString"
)
default
List
<
String
>
translatePicUrlsFromString
(
String
picUrls
)
{
return
StringUtil
.
split
(
picUrls
,
","
);
}
}
\ No newline at end of file
}
product/product-service-impl/src/main/java/cn/iocoder/mall/product/dao/ProductSkuMapper.java
浏览文件 @
4300ce14
...
...
@@ -4,6 +4,7 @@ import cn.iocoder.mall.product.dataobject.ProductSkuDO;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.Collection
;
import
java.util.List
;
@Repository
...
...
@@ -11,6 +12,8 @@ public interface ProductSkuMapper {
ProductSkuDO
selectById
(
Integer
id
);
List
<
ProductSkuDO
>
selectByIds
(
@Param
(
"ids"
)
Collection
<
Integer
>
ids
);
List
<
ProductSkuDO
>
selectListBySpuIdAndStatus
(
@Param
(
"spuId"
)
Integer
spuId
,
@Param
(
"status"
)
Integer
status
);
...
...
@@ -20,4 +23,4 @@ public interface ProductSkuMapper {
int
updateToDeleted
(
@Param
(
"ids"
)
List
<
Integer
>
ids
);
}
\ No newline at end of file
}
product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java
浏览文件 @
4300ce14
...
...
@@ -6,10 +6,7 @@ import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import
cn.iocoder.common.framework.util.StringUtil
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.product.api.ProductSpuService
;
import
cn.iocoder.mall.product.api.bo.ProductAttrAndValuePairBO
;
import
cn.iocoder.mall.product.api.bo.ProductSpuBO
;
import
cn.iocoder.mall.product.api.bo.ProductSpuDetailBO
;
import
cn.iocoder.mall.product.api.bo.ProductSpuPageBO
;
import
cn.iocoder.mall.product.api.bo.*
;
import
cn.iocoder.mall.product.api.constant.ProductErrorCodeEnum
;
import
cn.iocoder.mall.product.api.constant.ProductSpuConstants
;
import
cn.iocoder.mall.product.api.dto.ProductSkuAddOrUpdateDTO
;
...
...
@@ -44,14 +41,14 @@ public class ProductSpuServiceImpl implements ProductSpuService {
private
ProductAttrServiceImpl
productAttrService
;
// @Override
// public ProductSpuBO getProductSpu(Integer id) {
// public ProductSpuBO getProductSpu
Detail
(Integer id) {
// ProductSpuDO productSpuDO = productSpuMapper.selectById(id);
// // 转换成 BO
// return ProductSpuConvert.INSTANCE.convert(productSpuDO);
// }
@Override
public
CommonResult
<
ProductSpuDetailBO
>
getProductSpu
(
Integer
id
)
{
public
CommonResult
<
ProductSpuDetailBO
>
getProductSpu
Detail
(
Integer
id
)
{
// 校验商品 spu 存在
ProductSpuDO
spu
=
productSpuMapper
.
selectById
(
id
);
if
(
spu
==
null
)
{
...
...
@@ -64,9 +61,6 @@ public class ProductSpuServiceImpl implements ProductSpuService {
skus
.
forEach
(
sku
->
productAttrValueIds
.
addAll
(
StringUtil
.
splitToInt
(
sku
.
getAttrs
(),
","
)));
CommonResult
<
List
<
ProductAttrAndValuePairBO
>>
validAttrResult
=
productAttrService
.
validProductAttrAndValue
(
productAttrValueIds
,
false
);
// 读取规格时,不考虑规格是否被禁用
if
(
validAttrResult
.
isError
())
{
return
CommonResult
.
error
(
validAttrResult
);
}
// 返回成功
return
CommonResult
.
success
(
ProductSpuConvert
.
INSTANCE
.
convert2
(
spu
,
skus
,
validAttrResult
.
getData
()));
}
...
...
@@ -219,6 +213,27 @@ public class ProductSpuServiceImpl implements ProductSpuService {
return
CommonResult
.
success
(
ProductSpuConvert
.
INSTANCE
.
convert
(
spus
));
}
@Override
public
CommonResult
<
List
<
ProductSkuDetailBO
>>
getProductSkuDetailList
(
Collection
<
Integer
>
ids
)
{
// 查询 SKU 数组
List
<
ProductSkuDO
>
skus
=
productSkuMapper
.
selectByIds
(
ids
);
if
(
skus
.
isEmpty
())
{
return
CommonResult
.
success
(
Collections
.
emptyList
());
}
// 查询 SPU 数组
List
<
ProductSpuDO
>
spus
=
productSpuMapper
.
selectByIds
(
skus
.
stream
().
map
(
ProductSkuDO:
:
getSpuId
).
collect
(
Collectors
.
toSet
()));
if
(
spus
.
isEmpty
())
{
return
CommonResult
.
success
(
Collections
.
emptyList
());
}
// 获得规格
Set
<
Integer
>
productAttrValueIds
=
new
HashSet
<>();
skus
.
forEach
(
sku
->
productAttrValueIds
.
addAll
(
StringUtil
.
splitToInt
(
sku
.
getAttrs
(),
","
)));
CommonResult
<
List
<
ProductAttrAndValuePairBO
>>
validAttrResult
=
productAttrService
.
validProductAttrAndValue
(
productAttrValueIds
,
false
);
// 读取规格时,不考虑规格是否被禁用
// 返回成功
return
CommonResult
.
success
(
ProductSpuConvert
.
INSTANCE
.
convert3
(
skus
,
spus
,
validAttrResult
.
getData
()));
}
/**
* 校验 sku 是否合法
*
...
...
@@ -289,4 +304,4 @@ public class ProductSpuServiceImpl implements ProductSpuService {
spu
.
setQuantity
(
skus
.
stream
().
mapToInt
(
ProductSkuAddOrUpdateDTO:
:
getQuantity
).
sum
());
// 求库存之和
}
}
\ No newline at end of file
}
product/product-service-impl/src/main/resources/mapper/ProductSkuMapper.xml
浏览文件 @
4300ce14
...
...
@@ -12,7 +12,18 @@
<include
refid=
"FIELDS"
/>
FROM product_sku
WHERE id = #{id}
AND delete = 0
AND deleted = 0
</select>
<select
id=
"selectByIds"
resultType=
"ProductSkuDO"
>
SELECT
<include
refid=
"FIELDS"
/>
FROM product_sku
WHERE id IN
<foreach
item=
"id"
collection=
"ids"
separator=
","
open=
"("
close=
")"
index=
""
>
#{id}
</foreach>
AND deleted = 0
</select>
<insert
id=
"insertList"
useGeneratedKeys=
"true"
keyColumn=
"id"
keyProperty=
"id"
>
...
...
@@ -73,4 +84,4 @@
</foreach>
</update>
</mapper>
\ No newline at end of file
</mapper>
promotion/promotion-application/pom.xml
浏览文件 @
4300ce14
...
...
@@ -93,9 +93,6 @@
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<fork>
true
</fork>
</configuration>
</plugin>
</plugins>
...
...
promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionActivityTypeEnum.java
0 → 100644
浏览文件 @
4300ce14
package
cn
.
iocoder
.
mall
.
promotion
.
api
.
constant
;
/**
* 推广活动类型枚举
*/
public
enum
PromotionActivityTypeEnum
{
LIMIT_DISCOUNT
(
1
,
"限时折扣"
),
MEET_REDUCE
(
2
,
"满减送"
),
;
/**
* 类型值
*/
private
final
Integer
value
;
/**
* 类型名
*/
private
final
String
name
;
PromotionActivityTypeEnum
(
Integer
value
,
String
name
)
{
this
.
value
=
value
;
this
.
name
=
name
;
}
public
Integer
getValue
()
{
return
value
;
}
public
String
getName
()
{
return
name
;
}
}
promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/PromotionActivityDO.java
0 → 100644
浏览文件 @
4300ce14
package
cn
.
iocoder
.
mall
.
promotion
.
biz
.
dataobject
;
import
cn.iocoder.common.framework.dataobject.BaseDO
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
/**
* 促销活动 DO
*/
@Data
@Accessors
(
chain
=
true
)
public
class
PromotionActivityDO
extends
BaseDO
{
/**
* 活动编号
*/
private
Integer
id
;
/**
* 活动标题
*/
private
String
title
;
/**
* 活动类型
*/
private
Integer
type
;
}
promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/ProductRecommendServiceImpl.java
浏览文件 @
4300ce14
...
...
@@ -58,7 +58,7 @@ public class ProductRecommendServiceImpl implements ProductRecommendService {
return
CommonResult
.
error
(
SysErrorCodeEnum
.
VALIDATION_REQUEST_PARAM_ERROR
.
getCode
(),
"推荐类型必须是新品(1)或热卖(2)"
);
// TODO 有点搓
}
// 校验商品不存在
if
(
productSpuService
.
getProductSpu
(
productRecommendAddDTO
.
getProductSpuId
())
==
null
)
{
if
(
productSpuService
.
getProductSpu
Detail
(
productRecommendAddDTO
.
getProductSpuId
())
==
null
)
{
return
ServiceExceptionUtil
.
error
(
PromotionErrorCodeEnum
.
PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS
.
getCode
());
}
// 校验商品是否已经推荐
...
...
@@ -84,7 +84,7 @@ public class ProductRecommendServiceImpl implements ProductRecommendService {
return
ServiceExceptionUtil
.
error
(
PromotionErrorCodeEnum
.
PRODUCT_RECOMMEND_NOT_EXISTS
.
getCode
());
}
// 校验商品不存在
if
(
productSpuService
.
getProductSpu
(
productRecommendUpdateDTO
.
getProductSpuId
())
==
null
)
{
if
(
productSpuService
.
getProductSpu
Detail
(
productRecommendUpdateDTO
.
getProductSpuId
())
==
null
)
{
return
ServiceExceptionUtil
.
error
(
PromotionErrorCodeEnum
.
PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS
.
getCode
());
}
// 校验商品是否已经推荐
...
...
@@ -130,4 +130,4 @@ public class ProductRecommendServiceImpl implements ProductRecommendService {
return
CommonResult
.
success
(
true
);
}
}
\ No newline at end of file
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论