Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mall-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yimu
mall-server
Commits
8aff1693
Commit
8aff1693
authored
Feb 18, 2022
by
wlx@33.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优惠券指定商品时,如果商品销售方式为盲盒销售,则默认指定该商品的所有规格
parent
fa88ccc7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
22 deletions
+60
-22
Spu.java
...ava/com/fzm/mall/server/admin/goods_center/model/Spu.java
+8
-0
Coupon.java
...ava/com/fzm/mall/server/admin/marketing/model/Coupon.java
+45
-20
CouponServiceImpl.java
...erver/admin/marketing/service/impl/CouponServiceImpl.java
+6
-2
SpuMapper.xml
...dmin/src/main/resources/mapper/goods_center/SpuMapper.xml
+1
-0
No files found.
mall-server-admin/src/main/java/com/fzm/mall/server/admin/goods_center/model/Spu.java
View file @
8aff1693
...
...
@@ -51,6 +51,11 @@ public class Spu implements Serializable {
public
static
final
Integer
NFT_SALES_TYPE_COPY
=
2
;
/**
* 盲盒销售
*/
public
static
final
Integer
BLIND_BOX_SALES
=
2
;
private
static
final
long
serialVersionUID
=
1L
;
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
...
...
@@ -151,6 +156,9 @@ public class Spu implements Serializable {
@ApiModelProperty
(
value
=
"延迟提货(0--否 1--是)"
)
private
Integer
delayDelivery
;
@ApiModelProperty
(
value
=
"销售方式 1.普通 2.盲盒"
)
private
Integer
salesType
;
@ApiModelProperty
(
value
=
"ntf文件"
)
private
String
nftFile
;
...
...
mall-server-admin/src/main/java/com/fzm/mall/server/admin/marketing/model/Coupon.java
View file @
8aff1693
...
...
@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.annotation.TableName;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.SystemClock
;
import
com.fzm.mall.server.admin.
constant.MallResponseErro
r
;
import
com.fzm.mall.server.admin.
exception.MyException
;
import
com.fzm.mall.server.admin.
goods_center.mapper.SkuMappe
r
;
import
com.fzm.mall.server.admin.
goods_center.mapper.SpuMapper
;
import
com.fzm.mall.server.admin.goods_center.model.Category
;
import
com.fzm.mall.server.admin.goods_center.model.Sku
;
import
com.fzm.mall.server.admin.goods_center.model.Spu
;
import
com.fzm.mall.server.admin.goods_center.service.ICategoryService
;
import
com.fzm.mall.server.admin.marketing.service.ICouponCategoryService
;
import
com.fzm.mall.server.admin.marketing.service.ICouponSkuService
;
...
...
@@ -23,6 +25,7 @@ import org.apache.commons.lang3.StringUtils;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -141,20 +144,48 @@ public class Coupon implements Serializable {
setAmt
(
circulation
);
}
public
void
saveCouponSku
(
ICouponSkuService
couponSkuService
)
{
List
<
CouponSku
>
skuList
=
getCouponSkuList
();
if
(
CollectionUtils
.
isNotEmpty
(
skuList
))
{
skuList
.
forEach
(
couponSku
->
{
couponSku
.
setMerchantId
(
this
.
getMerchantId
());
couponSku
.
setCouponId
(
this
.
getCouponId
());
couponSku
.
setStatus
(
CouponSku
.
COUPON_SKU_STATUS_EFFECTIVE
);
});
couponSkuService
.
saveBatch
(
skuList
);
public
void
saveCouponSku
(
ICouponSkuService
couponSkuService
,
SpuMapper
spuMapper
,
SkuMapper
skuMapper
)
{
batchSaveCouponSku
(
this
.
couponSkuList
,
couponSkuService
,
spuMapper
,
skuMapper
);
}
public
void
batchSaveCouponSku
(
List
<
CouponSku
>
paramList
,
ICouponSkuService
couponSkuService
,
SpuMapper
spuMapper
,
SkuMapper
skuMapper
)
{
if
(
CollectionUtils
.
isEmpty
(
paramList
))
{
return
;
}
/**
* 如果商品销售类型为盲盒,默认勾选盲盒的所有规格(即使前台勾选不完全)
*/
List
<
String
>
goodsIdList
=
paramList
.
stream
().
map
(
CouponSku:
:
getGoodsId
).
collect
(
Collectors
.
toList
());
QueryWrapper
<
Spu
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
in
(
"goods_id"
,
goodsIdList
);
List
<
Spu
>
spuList
=
spuMapper
.
selectList
(
queryWrapper
);
List
<
String
>
blindBoxSpuIdList
=
spuList
.
stream
().
filter
(
spu
->
spu
.
getSalesType
().
equals
(
Spu
.
BLIND_BOX_SALES
)).
map
(
Spu:
:
getGoodsId
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
blindBoxSpuIdList
))
{
List
<
String
>
paramSkuIdList
=
paramList
.
stream
().
map
(
CouponSku:
:
getSkuId
).
collect
(
Collectors
.
toList
());
QueryWrapper
<
Sku
>
skuQueryWrapper
=
new
QueryWrapper
<>();
skuQueryWrapper
.
in
(
"goods_id"
,
goodsIdList
);
List
<
Sku
>
dataSkuList
=
skuMapper
.
selectList
(
skuQueryWrapper
);
List
<
Sku
>
skuToAddList
=
dataSkuList
.
stream
().
filter
(
sku
->
!
paramSkuIdList
.
contains
(
sku
.
getSkuId
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
skuToAddList
))
{
skuToAddList
.
forEach
(
sku
->
{
CouponSku
couponSku
=
new
CouponSku
();
couponSku
.
setSkuId
(
sku
.
getSkuId
());
couponSku
.
setGoodsId
(
sku
.
getGoodsId
());
paramList
.
add
(
couponSku
);
});
}
}
paramList
.
forEach
(
couponSku
->
{
couponSku
.
setMerchantId
(
this
.
getMerchantId
());
couponSku
.
setCouponId
(
this
.
getCouponId
());
couponSku
.
setStatus
(
CouponSku
.
COUPON_SKU_STATUS_EFFECTIVE
);
});
couponSkuService
.
saveBatch
(
paramList
);
}
public
void
updateCouponSku
(
ICouponSkuService
couponSkuService
)
{
List
<
CouponSku
>
paramSkuList
=
getCouponSkuList
()
;
public
void
updateCouponSku
(
ICouponSkuService
couponSkuService
,
SpuMapper
spuMapper
,
SkuMapper
skuMapper
)
{
List
<
CouponSku
>
paramSkuList
=
this
.
couponSkuList
;
List
<
CouponSku
>
dataSkuList
=
couponSkuService
.
list
(
new
QueryWrapper
<
CouponSku
>().
eq
(
"coupon_id"
,
this
.
getCouponId
())
.
eq
(
"merchant_id"
,
this
.
getMerchantId
())
.
eq
(
"status"
,
CouponSku
.
COUPON_SKU_STATUS_EFFECTIVE
));
...
...
@@ -163,13 +194,7 @@ public class Coupon implements Serializable {
List
<
CouponSku
>
reaminList
=
paramSkuList
;
reaminList
.
removeAll
(
toAddList
);
toAddList
.
forEach
(
couponSku
->
{
couponSku
.
setCouponId
(
this
.
getCouponId
());
couponSku
.
setMerchantId
(
this
.
getMerchantId
());
couponSku
.
setStatus
(
CouponSku
.
COUPON_SKU_STATUS_EFFECTIVE
);
});
couponSkuService
.
saveBatch
(
toAddList
);
batchSaveCouponSku
(
toAddList
,
couponSkuService
,
spuMapper
,
skuMapper
);
List
<
String
>
reaminCouponIdList
=
reaminList
.
stream
().
map
(
CouponSku:
:
getGoodsId
).
collect
(
Collectors
.
toList
());
...
...
mall-server-admin/src/main/java/com/fzm/mall/server/admin/marketing/service/impl/CouponServiceImpl.java
View file @
8aff1693
...
...
@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.fzm.mall.server.admin.constant.MallResponseError
;
import
com.fzm.mall.server.admin.exception.MyException
;
import
com.fzm.mall.server.admin.goods_center.mapper.SkuMapper
;
import
com.fzm.mall.server.admin.goods_center.mapper.SpuMapper
;
import
com.fzm.mall.server.admin.goods_center.service.ICategoryService
;
import
com.fzm.mall.server.admin.marketing.entity.dto.CouponDTO
;
import
com.fzm.mall.server.admin.marketing.entity.dto.CouponSaveDTO
;
...
...
@@ -44,6 +46,8 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
private
final
ICouponSkuService
couponSkuService
;
private
final
ICouponCategoryService
couponCategoryService
;
private
final
ICategoryService
categoryService
;
private
final
SpuMapper
spuMapper
;
private
final
SkuMapper
skuMapper
;
@Override
public
List
<
Coupon
>
listByOid
(
String
oid
,
String
uid
,
List
<
String
>
goodsIdList
)
{
...
...
@@ -58,7 +62,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
coupon
.
init
();
coupon
.
saveCouponSku
(
couponSkuService
);
coupon
.
saveCouponSku
(
couponSkuService
,
spuMapper
,
skuMapper
);
coupon
.
saveCategory
(
couponCategoryService
);
couponMapper
.
insert
(
coupon
);
...
...
@@ -86,7 +90,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
throw
new
MyException
(
MallResponseError
.
UPDATE_FAIL
);
}
coupon
.
updateCouponSku
(
couponSkuService
);
coupon
.
updateCouponSku
(
couponSkuService
,
spuMapper
,
skuMapper
);
coupon
.
updateCategory
(
couponCategoryService
);
}
...
...
mall-server-admin/src/main/resources/mapper/goods_center/SpuMapper.xml
View file @
8aff1693
...
...
@@ -26,6 +26,7 @@
<result
column=
"delay_delivery"
property=
"delayDelivery"
/>
<result
column=
"nft_file"
property=
"nftFile"
/>
<result
column=
"hash"
property=
"hash"
/>
<result
column=
"sales_type"
property=
"salesType"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
</resultMap>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment