Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
mall
Commits
61a67c9a
"...src/main/java/me/git@ustchcs.com:gujinli1118/eladmin.git" did not exist on "0f0392d78297c17909726b3cd5b76b2da708958a"
Commit
61a67c9a
authored
Aug 29, 2018
by
zhh
Browse files
添加获取购物车中商品可用优惠券接口
parent
201b405a
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
document/pdm/mall.pdb
View file @
61a67c9a
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<?PowerDesigner AppLocale="UTF16" ID="{7BB41C87-EFE8-409A-A86E-B1C3FCE34F8C}" Label="" LastModificationDate="1535
445127
" Name="mall" Objects="10
23
" Symbols="127" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.5.0.3982"?>
<?PowerDesigner AppLocale="UTF16" ID="{7BB41C87-EFE8-409A-A86E-B1C3FCE34F8C}" Label="" LastModificationDate="1535
522371
" Name="mall" Objects="10
11
" Symbols="127" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.5.0.3982"?>
<!-- do not edit this file -->
<!-- do not edit this file -->
<Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
<Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
...
@@ -11087,10 +11087,10 @@ LABL 0 新宋体,8,N</a:FontList>
...
@@ -11087,10 +11087,10 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>platform</a:Code>
<a:Code>platform</a:Code>
<a:CreationDate>1522215086</a:CreationDate>
<a:CreationDate>1522215086</a:CreationDate>
<a:Creator>zhenghong</a:Creator>
<a:Creator>zhenghong</a:Creator>
<a:ModificationDate>15
22215279
</a:ModificationDate>
<a:ModificationDate>15
35445907
</a:ModificationDate>
<a:Modifier>zhenghong</a:Modifier>
<a:Modifier>zhenghong</a:Modifier>
<a:Comment>使用平台:0->全部;1->移动;2->PC</a:Comment>
<a:Comment>使用平台:0->全部;1->移动;2->PC</a:Comment>
<a:DataType>
varchar
(1)</a:DataType>
<a:DataType>
int
(1)</a:DataType>
<a:Length>1</a:Length>
<a:Length>1</a:Length>
</o:Column>
</o:Column>
<o:Column Id="o559">
<o:Column Id="o559">
...
@@ -11413,9 +11413,10 @@ LABL 0 新宋体,8,N</a:FontList>
...
@@ -11413,9 +11413,10 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>id</a:Code>
<a:Code>id</a:Code>
<a:CreationDate>1522217090</a:CreationDate>
<a:CreationDate>1522217090</a:CreationDate>
<a:Creator>zhenghong</a:Creator>
<a:Creator>zhenghong</a:Creator>
<a:ModificationDate>15
2221713
1</a:ModificationDate>
<a:ModificationDate>15
3552237
1</a:ModificationDate>
<a:Modifier>zhenghong</a:Modifier>
<a:Modifier>zhenghong</a:Modifier>
<a:DataType>bigint</a:DataType>
<a:DataType>bigint</a:DataType>
<a:Identity>1</a:Identity>
<a:Column.Mandatory>1</a:Column.Mandatory>
<a:Column.Mandatory>1</a:Column.Mandatory>
</o:Column>
</o:Column>
<o:Column Id="o583">
<o:Column Id="o583">
...
...
document/pdm/mall.pdm
View file @
61a67c9a
This diff is collapsed.
Click to expand it.
mall-admin/src/main/java/com/macro/mall/controller/SmsCouponController.java
View file @
61a67c9a
...
@@ -66,4 +66,12 @@ public class SmsCouponController {
...
@@ -66,4 +66,12 @@ public class SmsCouponController {
List
<
SmsCoupon
>
couponList
=
couponService
.
list
(
name
,
type
,
pageSize
,
pageNum
);
List
<
SmsCoupon
>
couponList
=
couponService
.
list
(
name
,
type
,
pageSize
,
pageNum
);
return
new
CommonResult
().
pageSuccess
(
couponList
);
return
new
CommonResult
().
pageSuccess
(
couponList
);
}
}
@ApiOperation
(
"获取单个优惠券的详细信息"
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
getItem
(
@PathVariable
Long
id
)
{
SmsCouponParam
couponParam
=
couponService
.
getItem
(
id
);
return
new
CommonResult
().
success
(
couponParam
);
}
}
}
mall-admin/src/main/java/com/macro/mall/dao/SmsCouponDao.java
0 → 100644
View file @
61a67c9a
package
com.macro.mall.dao
;
import
com.macro.mall.dto.SmsCouponParam
;
import
org.apache.ibatis.annotations.Param
;
/**
* 优惠券管理自定义查询Dao
* Created by macro on 2018/8/29.
*/
public
interface
SmsCouponDao
{
SmsCouponParam
getItem
(
@Param
(
"id"
)
Long
id
);
}
mall-admin/src/main/java/com/macro/mall/service/SmsCouponService.java
View file @
61a67c9a
...
@@ -33,4 +33,10 @@ public interface SmsCouponService {
...
@@ -33,4 +33,10 @@ public interface SmsCouponService {
* 分页获取优惠券列表
* 分页获取优惠券列表
*/
*/
List
<
SmsCoupon
>
list
(
String
name
,
Integer
type
,
Integer
pageSize
,
Integer
pageNum
);
List
<
SmsCoupon
>
list
(
String
name
,
Integer
type
,
Integer
pageSize
,
Integer
pageNum
);
/**
* 获取优惠券详情
* @param id 优惠券表id
*/
SmsCouponParam
getItem
(
Long
id
);
}
}
mall-admin/src/main/java/com/macro/mall/service/impl/SmsCouponServiceImpl.java
View file @
61a67c9a
package
com.macro.mall.service.impl
;
package
com.macro.mall.service.impl
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.dao.SmsCouponDao
;
import
com.macro.mall.dao.SmsCouponProductCategoryRelationDao
;
import
com.macro.mall.dao.SmsCouponProductCategoryRelationDao
;
import
com.macro.mall.dao.SmsCouponProductRelationDao
;
import
com.macro.mall.dao.SmsCouponProductRelationDao
;
import
com.macro.mall.dto.SmsCouponParam
;
import
com.macro.mall.dto.SmsCouponParam
;
...
@@ -31,6 +32,8 @@ public class SmsCouponServiceImpl implements SmsCouponService {
...
@@ -31,6 +32,8 @@ public class SmsCouponServiceImpl implements SmsCouponService {
private
SmsCouponProductRelationDao
productRelationDao
;
private
SmsCouponProductRelationDao
productRelationDao
;
@Autowired
@Autowired
private
SmsCouponProductCategoryRelationDao
productCategoryRelationDao
;
private
SmsCouponProductCategoryRelationDao
productCategoryRelationDao
;
@Autowired
private
SmsCouponDao
couponDao
;
@Override
@Override
public
int
add
(
SmsCouponParam
couponParam
)
{
public
int
add
(
SmsCouponParam
couponParam
)
{
//插入优惠券表
//插入优惠券表
...
@@ -112,4 +115,9 @@ public class SmsCouponServiceImpl implements SmsCouponService {
...
@@ -112,4 +115,9 @@ public class SmsCouponServiceImpl implements SmsCouponService {
PageHelper
.
startPage
(
pageNum
,
pageSize
);
PageHelper
.
startPage
(
pageNum
,
pageSize
);
return
couponMapper
.
selectByExample
(
example
);
return
couponMapper
.
selectByExample
(
example
);
}
}
@Override
public
SmsCouponParam
getItem
(
Long
id
)
{
return
couponDao
.
getItem
(
id
);
}
}
}
mall-admin/src/main/resources/dao/SmsCouponDao.xml
0 → 100644
View file @
61a67c9a
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.macro.mall.dao.SmsCouponDao"
>
<resultMap
id=
"couponItemParam"
type=
"com.macro.mall.dto.SmsCouponParam"
extends=
"com.macro.mall.mapper.SmsCouponMapper.BaseResultMap"
>
<collection
property=
"productRelationList"
columnPrefix=
"cpr_"
resultMap=
"com.macro.mall.mapper.SmsCouponProductRelationMapper.BaseResultMap"
>
</collection>
<collection
property=
"productCategoryRelationList"
columnPrefix=
"cpcr_"
resultMap=
"com.macro.mall.mapper.SmsCouponProductCategoryRelationMapper.BaseResultMap"
>
</collection>
</resultMap>
<select
id=
"getItem"
resultMap=
"couponItemParam"
>
SELECT
c.*,
cpr.id cpr_id,
cpr.product_id cpr_product_id,
cpcr.id cpcr_id,
cpcr.product_category_id cpcr_product_category_id
FROM
sms_coupon c
LEFT JOIN sms_coupon_product_relation cpr ON c.id = cpr.coupon_id
LEFT JOIN sms_coupon_product_category_relation cpcr ON c.id = cpcr.coupon_id
WHERE
c.id = #{id}
</select>
</mapper>
\ No newline at end of file
mall-mbg/src/main/java/com/macro/mall/model/OmsCartItem.java
View file @
61a67c9a
...
@@ -104,6 +104,13 @@ public class OmsCartItem implements Serializable {
...
@@ -104,6 +104,13 @@ public class OmsCartItem implements Serializable {
*/
*/
private
Integer
deleteStatus
;
private
Integer
deleteStatus
;
/**
* 商品分类
*
* @mbggenerated
*/
private
Long
productCategoryId
;
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
public
Long
getId
()
{
public
Long
getId
()
{
...
@@ -242,6 +249,14 @@ public class OmsCartItem implements Serializable {
...
@@ -242,6 +249,14 @@ public class OmsCartItem implements Serializable {
this
.
deleteStatus
=
deleteStatus
;
this
.
deleteStatus
=
deleteStatus
;
}
}
public
Long
getProductCategoryId
()
{
return
productCategoryId
;
}
public
void
setProductCategoryId
(
Long
productCategoryId
)
{
this
.
productCategoryId
=
productCategoryId
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
...
@@ -265,6 +280,7 @@ public class OmsCartItem implements Serializable {
...
@@ -265,6 +280,7 @@ public class OmsCartItem implements Serializable {
sb
.
append
(
", createDate="
).
append
(
createDate
);
sb
.
append
(
", createDate="
).
append
(
createDate
);
sb
.
append
(
", modifyDate="
).
append
(
modifyDate
);
sb
.
append
(
", modifyDate="
).
append
(
modifyDate
);
sb
.
append
(
", deleteStatus="
).
append
(
deleteStatus
);
sb
.
append
(
", deleteStatus="
).
append
(
deleteStatus
);
sb
.
append
(
", productCategoryId="
).
append
(
productCategoryId
);
sb
.
append
(
", serialVersionUID="
).
append
(
serialVersionUID
);
sb
.
append
(
", serialVersionUID="
).
append
(
serialVersionUID
);
sb
.
append
(
"]"
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
return
sb
.
toString
();
...
...
mall-mbg/src/main/java/com/macro/mall/model/OmsCartItemExample.java
View file @
61a67c9a
...
@@ -1205,6 +1205,66 @@ public class OmsCartItemExample {
...
@@ -1205,6 +1205,66 @@ public class OmsCartItemExample {
addCriterion
(
"delete_status not between"
,
value1
,
value2
,
"deleteStatus"
);
addCriterion
(
"delete_status not between"
,
value1
,
value2
,
"deleteStatus"
);
return
(
Criteria
)
this
;
return
(
Criteria
)
this
;
}
}
public
Criteria
andProductCategoryIdIsNull
()
{
addCriterion
(
"product_category_id is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProductCategoryIdIsNotNull
()
{
addCriterion
(
"product_category_id is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProductCategoryIdEqualTo
(
Long
value
)
{
addCriterion
(
"product_category_id ="
,
value
,
"productCategoryId"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProductCategoryIdNotEqualTo
(
Long
value
)
{
addCriterion
(
"product_category_id <>"
,
value
,
"productCategoryId"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProductCategoryIdGreaterThan
(
Long
value
)
{
addCriterion
(
"product_category_id >"
,
value
,
"productCategoryId"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProductCategoryIdGreaterThanOrEqualTo
(
Long
value
)
{
addCriterion
(
"product_category_id >="
,
value
,
"productCategoryId"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProductCategoryIdLessThan
(
Long
value
)
{
addCriterion
(
"product_category_id <"
,
value
,
"productCategoryId"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProductCategoryIdLessThanOrEqualTo
(
Long
value
)
{
addCriterion
(
"product_category_id <="
,
value
,
"productCategoryId"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProductCategoryIdIn
(
List
<
Long
>
values
)
{
addCriterion
(
"product_category_id in"
,
values
,
"productCategoryId"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProductCategoryIdNotIn
(
List
<
Long
>
values
)
{
addCriterion
(
"product_category_id not in"
,
values
,
"productCategoryId"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProductCategoryIdBetween
(
Long
value1
,
Long
value2
)
{
addCriterion
(
"product_category_id between"
,
value1
,
value2
,
"productCategoryId"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProductCategoryIdNotBetween
(
Long
value1
,
Long
value2
)
{
addCriterion
(
"product_category_id not between"
,
value1
,
value2
,
"productCategoryId"
);
return
(
Criteria
)
this
;
}
}
}
public
static
class
Criteria
extends
GeneratedCriteria
{
public
static
class
Criteria
extends
GeneratedCriteria
{
...
...
mall-mbg/src/main/resources/com/macro/mall/mapper/OmsCartItemMapper.xml
View file @
61a67c9a
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
<result
column=
"create_date"
jdbcType=
"TIMESTAMP"
property=
"createDate"
/>
<result
column=
"create_date"
jdbcType=
"TIMESTAMP"
property=
"createDate"
/>
<result
column=
"modify_date"
jdbcType=
"TIMESTAMP"
property=
"modifyDate"
/>
<result
column=
"modify_date"
jdbcType=
"TIMESTAMP"
property=
"modifyDate"
/>
<result
column=
"delete_status"
jdbcType=
"INTEGER"
property=
"deleteStatus"
/>
<result
column=
"delete_status"
jdbcType=
"INTEGER"
property=
"deleteStatus"
/>
<result
column=
"product_category_id"
jdbcType=
"BIGINT"
property=
"productCategoryId"
/>
</resultMap>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<sql
id=
"Example_Where_Clause"
>
<where>
<where>
...
@@ -81,7 +82,7 @@
...
@@ -81,7 +82,7 @@
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
id, product_id, product_sku_id, member_id, quantity, price, sp1, sp2, sp3, product_pic,
id, product_id, product_sku_id, member_id, quantity, price, sp1, sp2, sp3, product_pic,
product_name, product_sub_title, product_sku_code, member_nickname, create_date,
product_name, product_sub_title, product_sku_code, member_nickname, create_date,
modify_date, delete_status
modify_date, delete_status
, product_category_id
</sql>
</sql>
<select
id=
"selectByExample"
parameterType=
"com.macro.mall.model.OmsCartItemExample"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByExample"
parameterType=
"com.macro.mall.model.OmsCartItemExample"
resultMap=
"BaseResultMap"
>
select
select
...
@@ -122,13 +123,13 @@
...
@@ -122,13 +123,13 @@
sp2, sp3, product_pic,
sp2, sp3, product_pic,
product_name, product_sub_title, product_sku_code,
product_name, product_sub_title, product_sku_code,
member_nickname, create_date, modify_date,
member_nickname, create_date, modify_date,
delete_status)
delete_status
, product_category_id
)
values (#{productId,jdbcType=BIGINT}, #{productSkuId,jdbcType=BIGINT}, #{memberId,jdbcType=BIGINT},
values (#{productId,jdbcType=BIGINT}, #{productSkuId,jdbcType=BIGINT}, #{memberId,jdbcType=BIGINT},
#{quantity,jdbcType=INTEGER}, #{price,jdbcType=DECIMAL}, #{sp1,jdbcType=VARCHAR},
#{quantity,jdbcType=INTEGER}, #{price,jdbcType=DECIMAL}, #{sp1,jdbcType=VARCHAR},
#{sp2,jdbcType=VARCHAR}, #{sp3,jdbcType=VARCHAR}, #{productPic,jdbcType=VARCHAR},
#{sp2,jdbcType=VARCHAR}, #{sp3,jdbcType=VARCHAR}, #{productPic,jdbcType=VARCHAR},
#{productName,jdbcType=VARCHAR}, #{productSubTitle,jdbcType=VARCHAR}, #{productSkuCode,jdbcType=VARCHAR},
#{productName,jdbcType=VARCHAR}, #{productSubTitle,jdbcType=VARCHAR}, #{productSkuCode,jdbcType=VARCHAR},
#{memberNickname,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, #{modifyDate,jdbcType=TIMESTAMP},
#{memberNickname,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, #{modifyDate,jdbcType=TIMESTAMP},
#{deleteStatus,jdbcType=INTEGER})
#{deleteStatus,jdbcType=INTEGER}
, #{productCategoryId,jdbcType=BIGINT}
)
</insert>
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.macro.mall.model.OmsCartItem"
>
<insert
id=
"insertSelective"
parameterType=
"com.macro.mall.model.OmsCartItem"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
...
@@ -184,6 +185,9 @@
...
@@ -184,6 +185,9 @@
<if
test=
"deleteStatus != null"
>
<if
test=
"deleteStatus != null"
>
delete_status,
delete_status,
</if>
</if>
<if
test=
"productCategoryId != null"
>
product_category_id,
</if>
</trim>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"productId != null"
>
<if
test=
"productId != null"
>
...
@@ -234,6 +238,9 @@
...
@@ -234,6 +238,9 @@
<if
test=
"deleteStatus != null"
>
<if
test=
"deleteStatus != null"
>
#{deleteStatus,jdbcType=INTEGER},
#{deleteStatus,jdbcType=INTEGER},
</if>
</if>
<if
test=
"productCategoryId != null"
>
#{productCategoryId,jdbcType=BIGINT},
</if>
</trim>
</trim>
</insert>
</insert>
<select
id=
"countByExample"
parameterType=
"com.macro.mall.model.OmsCartItemExample"
resultType=
"java.lang.Integer"
>
<select
id=
"countByExample"
parameterType=
"com.macro.mall.model.OmsCartItemExample"
resultType=
"java.lang.Integer"
>
...
@@ -296,6 +303,9 @@
...
@@ -296,6 +303,9 @@
<if
test=
"record.deleteStatus != null"
>
<if
test=
"record.deleteStatus != null"
>
delete_status = #{record.deleteStatus,jdbcType=INTEGER},
delete_status = #{record.deleteStatus,jdbcType=INTEGER},
</if>
</if>
<if
test=
"record.productCategoryId != null"
>
product_category_id = #{record.productCategoryId,jdbcType=BIGINT},
</if>
</set>
</set>
<if
test=
"_parameter != null"
>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
<include
refid=
"Update_By_Example_Where_Clause"
/>
...
@@ -319,7 +329,8 @@
...
@@ -319,7 +329,8 @@
member_nickname = #{record.memberNickname,jdbcType=VARCHAR},
member_nickname = #{record.memberNickname,jdbcType=VARCHAR},
create_date = #{record.createDate,jdbcType=TIMESTAMP},
create_date = #{record.createDate,jdbcType=TIMESTAMP},
modify_date = #{record.modifyDate,jdbcType=TIMESTAMP},
modify_date = #{record.modifyDate,jdbcType=TIMESTAMP},
delete_status = #{record.deleteStatus,jdbcType=INTEGER}
delete_status = #{record.deleteStatus,jdbcType=INTEGER},
product_category_id = #{record.productCategoryId,jdbcType=BIGINT}
<if
test=
"_parameter != null"
>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</if>
...
@@ -375,6 +386,9 @@
...
@@ -375,6 +386,9 @@
<if
test=
"deleteStatus != null"
>
<if
test=
"deleteStatus != null"
>
delete_status = #{deleteStatus,jdbcType=INTEGER},
delete_status = #{deleteStatus,jdbcType=INTEGER},
</if>
</if>
<if
test=
"productCategoryId != null"
>
product_category_id = #{productCategoryId,jdbcType=BIGINT},
</if>
</set>
</set>
where id = #{id,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
</update>
...
@@ -395,7 +409,8 @@
...
@@ -395,7 +409,8 @@
member_nickname = #{memberNickname,jdbcType=VARCHAR},
member_nickname = #{memberNickname,jdbcType=VARCHAR},
create_date = #{createDate,jdbcType=TIMESTAMP},
create_date = #{createDate,jdbcType=TIMESTAMP},
modify_date = #{modifyDate,jdbcType=TIMESTAMP},
modify_date = #{modifyDate,jdbcType=TIMESTAMP},
delete_status = #{deleteStatus,jdbcType=INTEGER}
delete_status = #{deleteStatus,jdbcType=INTEGER},
product_category_id = #{productCategoryId,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
</update>
</mapper>
</mapper>
\ No newline at end of file
mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberCouponController.java
0 → 100644
View file @
61a67c9a
package
com.macro.mall.portal.controller
;
import
com.macro.mall.model.SmsCouponHistory
;
import
com.macro.mall.portal.domain.CartPromotionItem
;
import
com.macro.mall.portal.domain.CommonResult
;
import
com.macro.mall.portal.domain.SmsCouponHistoryDetail
;
import
com.macro.mall.portal.service.OmsCartItemService
;
import
com.macro.mall.portal.service.UmsMemberCouponService
;
import
com.macro.mall.portal.service.UmsMemberService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* 用户优惠券管理Controller
* Created by macro on 2018/8/29.
*/
@Controller
@Api
(
tags
=
"UmsMemberCouponController"
,
description
=
"用户优惠券管理"
)
@RequestMapping
(
"/member/coupon"
)
public
class
UmsMemberCouponController
{
@Autowired
private
UmsMemberCouponService
memberCouponService
;
@Autowired
private
OmsCartItemService
cartItemService
;
@Autowired
private
UmsMemberService
memberService
;
@ApiOperation
(
"领取指定优惠券"
)
@RequestMapping
(
value
=
"/add/{couponId}"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
add
(
@PathVariable
Long
couponId
)
{
return
memberCouponService
.
add
(
couponId
);
}
@ApiOperation
(
"获取用户优惠券列表"
)
@ApiImplicitParam
(
name
=
"useStatus"
,
value
=
"优惠券筛选类型:0->未使用;1->已使用;2->已过期"
,
allowableValues
=
"0,1,2"
,
paramType
=
"query"
,
dataType
=
"integer"
)
@RequestMapping
(
value
=
"/list"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
list
(
@RequestParam
(
value
=
"useStatus"
,
required
=
false
)
Integer
useStatus
)
{
List
<
SmsCouponHistory
>
couponHistoryList
=
memberCouponService
.
list
(
useStatus
);
return
new
CommonResult
().
success
(
couponHistoryList
);
}
@ApiOperation
(
"获取登录会员购物车的相关优惠券"
)
@ApiImplicitParam
(
name
=
"type"
,
value
=
"使用可用:0->不可用;1->可用"
,
defaultValue
=
"1"
,
allowableValues
=
"0,1"
,
paramType
=
"query"
,
dataType
=
"integer"
)
@RequestMapping
(
value
=
"/list/cart/{type}"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
listCart
(
@PathVariable
Integer
type
)
{
List
<
CartPromotionItem
>
cartPromotionItemList
=
cartItemService
.
listPromotion
(
memberService
.
getCurrentMember
().
getId
());
List
<
SmsCouponHistoryDetail
>
couponHistoryList
=
memberCouponService
.
listCart
(
cartPromotionItemList
,
type
);
return
new
CommonResult
().
success
(
couponHistoryList
);
}
}
mall-portal/src/main/java/com/macro/mall/portal/dao/SmsCouponHistoryDao.java
0 → 100644
View file @
61a67c9a
package
com.macro.mall.portal.dao
;
import
com.macro.mall.portal.domain.SmsCouponHistoryDetail
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* 会员优惠券领取历史自定义Dao
* Created by macro on 2018/8/29.
*/
public
interface
SmsCouponHistoryDao
{
List
<
SmsCouponHistoryDetail
>
getDetailList
(
@Param
(
"memberId"
)
Long
memberId
);
}
mall-portal/src/main/java/com/macro/mall/portal/domain/SmsCouponHistoryDetail.java
0 → 100644
View file @
61a67c9a
package
com.macro.mall.portal.domain
;
import
com.macro.mall.model.SmsCoupon
;
import
com.macro.mall.model.SmsCouponHistory
;
import
com.macro.mall.model.SmsCouponProductCategoryRelation
;
import
com.macro.mall.model.SmsCouponProductRelation
;
import
java.util.List
;
/**
* 优惠券领取历史详情封装
* Created by macro on 2018/8/29.
*/
public
class
SmsCouponHistoryDetail
extends
SmsCouponHistory
{
//相关优惠券信息
private
SmsCoupon
coupon
;
//优惠券关联商品
private
List
<
SmsCouponProductRelation
>
productRelationList
;
//优惠券关联商品分类
private
List
<
SmsCouponProductCategoryRelation
>
categoryRelationList
;
public
SmsCoupon
getCoupon
()
{
return
coupon
;
}
public
void
setCoupon
(
SmsCoupon
coupon
)
{
this
.
coupon
=
coupon
;
}
public
List
<
SmsCouponProductRelation
>
getProductRelationList
()
{
return
productRelationList
;
}
public
void
setProductRelationList
(
List
<
SmsCouponProductRelation
>
productRelationList
)
{
this
.
productRelationList
=
productRelationList
;
}
public
List
<
SmsCouponProductCategoryRelation
>
getCategoryRelationList
()
{
return
categoryRelationList
;
}
public
void
setCategoryRelationList
(
List
<
SmsCouponProductCategoryRelation
>
categoryRelationList
)
{
this
.
categoryRelationList
=
categoryRelationList
;
}
}
mall-portal/src/main/java/com/macro/mall/portal/service/UmsMemberCouponService.java
0 → 100644
View file @
61a67c9a
package
com.macro.mall.portal.service
;
import
com.macro.mall.model.SmsCouponHistory
;
import
com.macro.mall.portal.domain.CartPromotionItem
;
import
com.macro.mall.portal.domain.CommonResult
;
import
com.macro.mall.portal.domain.SmsCouponHistoryDetail
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
/**
* 用户优惠券管理Service
* Created by macro on 2018/8/29.
*/
public
interface
UmsMemberCouponService
{
/**
* 会员添加优惠券
*/
@Transactional
CommonResult
add
(
Long
couponId
);
/**
* 获取优惠券列表
* @param useStatus 优惠券的使用状态
*/
List
<
SmsCouponHistory
>
list
(
Integer
useStatus
);
/**
* 根据购物车信息获取可用优惠券
*/
List
<
SmsCouponHistoryDetail
>
listCart
(
List
<
CartPromotionItem
>
cartItemList
,
Integer
type
);
}
mall-portal/src/main/java/com/macro/mall/portal/service/impl/UmsMemberCouponServiceImpl.java
0 → 100644
View file @
61a67c9a
package
com.macro.mall.portal.service.impl
;
import
com.macro.mall.mapper.SmsCouponHistoryMapper
;
import
com.macro.mall.mapper.SmsCouponMapper
;
import
com.macro.mall.model.*
;
import
com.macro.mall.portal.dao.SmsCouponHistoryDao
;
import
com.macro.mall.portal.domain.CartPromotionItem
;
import
com.macro.mall.portal.domain.CommonResult
;
import
com.macro.mall.portal.domain.SmsCouponHistoryDetail
;
import
com.macro.mall.portal.service.UmsMemberCouponService
;
import
com.macro.mall.portal.service.UmsMemberService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* 会员优惠券管理Service实现类
* Created by macro on 2018/8/29.
*/
@Service
public
class
UmsMemberCouponServiceImpl
implements
UmsMemberCouponService
{
@Autowired
private
UmsMemberService
memberService
;
@Autowired
private
SmsCouponMapper
couponMapper
;
@Autowired
private
SmsCouponHistoryMapper
couponHistoryMapper
;
@Autowired
private
SmsCouponHistoryDao
couponHistoryDao
;
@Override
public
CommonResult
add
(
Long
couponId
)
{
UmsMember
currentMember
=
memberService
.
getCurrentMember
();
//获取优惠券信息,判断数量
SmsCoupon
coupon
=
couponMapper
.
selectByPrimaryKey
(
couponId
);
if
(
coupon
==
null
){
return
new
CommonResult
().
failed
(
"优惠券不存在"
);
}
if
(
coupon
.
getCount
()<=
0
){
return
new
CommonResult
().
failed
(
"优惠券已经领完了"
);
}
Date
now
=
new
Date
();
if
(
now
.
before
(
coupon
.
getEnableTime
())){
return
new
CommonResult
().
failed
(
"优惠券还没到领取时间"
);
}
//判断用户领取的优惠券数量是否超过限制
SmsCouponHistoryExample
couponHistoryExample
=
new
SmsCouponHistoryExample
();
couponHistoryExample
.
createCriteria
().
andCouponIdEqualTo
(
couponId
).
andMemberIdEqualTo
(
currentMember
.
getId
());
int
count
=
couponHistoryMapper
.
countByExample
(
couponHistoryExample
);
if
(
count
>=
coupon
.
getPerLimit
()){
return
new
CommonResult
().
failed
(
"您已经领取过该优惠券"
);
}
//生成领取优惠券历史
SmsCouponHistory
couponHistory
=
new
SmsCouponHistory
();
couponHistory
.
setCouponId
(
couponId
);
couponHistory
.
setCouponCode
(
coupon
.
getCode
());
couponHistory
.
setCreateTime
(
now
);
couponHistory
.
setMemberId
(
currentMember
.
getId
());
couponHistory
.
setMemberNickname
(
currentMember
.
getNickname
());
//主动领取
couponHistory
.
setGetType
(
1
);
//未使用
couponHistory
.
setUseStatus
(
0
);
couponHistoryMapper
.
insert
(
couponHistory
);
//修改优惠券表的数量、领取数量
coupon
.
setCount
(
coupon
.
getCount
()-
1
);
coupon
.
setReceiveCount
(
coupon
.
getReceiveCount
()==
null
?
1
:
coupon
.
getReceiveCount
()+
1
);
couponMapper
.
updateByPrimaryKey
(
coupon
);
return
new
CommonResult
().
success
(
"领取成功"
,
null
);
}
@Override
public
List
<
SmsCouponHistory
>
list
(
Integer
useStatus
)
{
UmsMember
currentMember
=
memberService
.
getCurrentMember
();
SmsCouponHistoryExample
couponHistoryExample
=
new
SmsCouponHistoryExample
();
SmsCouponHistoryExample
.
Criteria
criteria
=
couponHistoryExample
.
createCriteria
();
criteria
.
andMemberIdEqualTo
(
currentMember
.
getId
());
if
(
useStatus
!=
null
){
criteria
.
andUseStatusEqualTo
(
useStatus
);
}
return
couponHistoryMapper
.
selectByExample
(
couponHistoryExample
);
}
@Override
public
List
<
SmsCouponHistoryDetail
>
listCart
(
List
<
CartPromotionItem
>
cartItemList
,
Integer
type
)
{
UmsMember
currentMember
=
memberService
.
getCurrentMember
();
Date
now
=
new
Date
();
//获取该用户所有优惠券
List
<
SmsCouponHistoryDetail
>
allList
=
couponHistoryDao
.
getDetailList
(
currentMember
.
getId
());
//根据优惠券使用类型来判断优惠券是否可用
List
<
SmsCouponHistoryDetail
>
enableList
=
new
ArrayList
<>();
List
<
SmsCouponHistoryDetail
>
disableList
=
new
ArrayList
<>();
for
(
SmsCouponHistoryDetail
couponHistoryDetail
:
allList
)
{
Integer
useType
=
couponHistoryDetail
.
getCoupon
().
getUseType
();
BigDecimal
minPoint
=
couponHistoryDetail
.
getCoupon
().
getMinPoint
();
Date
endTime
=
couponHistoryDetail
.
getCoupon
().
getEndTime
();
if
(
useType
.
equals
(
0
)){
//0->全场通用
//判断是否满足优惠起点
//计算购物车商品的总价
BigDecimal
totalAmount
=
calcTotalAmount
(
cartItemList
);
if
(
now
.
before
(
endTime
)&&
totalAmount
.
subtract
(
minPoint
).
intValue
()>=
0
){
enableList
.
add
(
couponHistoryDetail
);
}
else
{
disableList
.
add
(
couponHistoryDetail
);
}
}
else
if
(
useType
.
equals
(
1
)){
//1->指定分类
//计算指定分类商品的总价
List
<
Long
>
productCategoryIds
=
new
ArrayList
<>();
for
(
SmsCouponProductCategoryRelation
categoryRelation
:
couponHistoryDetail
.
getCategoryRelationList
())
{
productCategoryIds
.
add
(
categoryRelation
.
getProductCategoryId
());
}
BigDecimal
totalAmount
=
calcTotalAmountByproductCategoryId
(
cartItemList
,
productCategoryIds
);
if
(
now
.
before
(
endTime
)&&
totalAmount
.
intValue
()>
0
&&
totalAmount
.
subtract
(
minPoint
).
intValue
()>=
0
){
enableList
.
add
(
couponHistoryDetail
);
}
else
{
disableList
.
add
(
couponHistoryDetail
);
}
}
else
if
(
useType
.
equals
(
2
)){
//2->指定商品
//计算指定商品的总价
List
<
Long
>
productIds
=
new
ArrayList
<>();
for
(
SmsCouponProductRelation
productRelation
:
couponHistoryDetail
.
getProductRelationList
())
{
productIds
.
add
(
productRelation
.
getProductId
());
}
BigDecimal
totalAmount
=
calcTotalAmountByProductId
(
cartItemList
,
productIds
);
if
(
now
.
before
(
endTime
)&&
totalAmount
.
intValue
()>
0
&&
totalAmount
.
subtract
(
minPoint
).
intValue
()>=
0
){
enableList
.
add
(
couponHistoryDetail
);
}
else
{
disableList
.
add
(
couponHistoryDetail
);
}
}
}
if
(
type
.
equals
(
1
)){
return
enableList
;
}
else
{
return
disableList
;
}
}
private
BigDecimal
calcTotalAmount
(
List
<
CartPromotionItem
>
cartItemList
)
{
BigDecimal
total
=
new
BigDecimal
(
"0"
);
for
(
CartPromotionItem
item
:
cartItemList
)
{
BigDecimal
realPrice
=
item
.
getPrice
().
subtract
(
item
.
getReduceAmount
());
total
=
total
.
add
(
realPrice
.
multiply
(
new
BigDecimal
(
item
.
getQuantity
())));
}
return
total
;
}
private
BigDecimal
calcTotalAmountByproductCategoryId
(
List
<
CartPromotionItem
>
cartItemList
,
List
<
Long
>
productCategoryIds
)
{
BigDecimal
total
=
new
BigDecimal
(
"0"
);
for
(
CartPromotionItem
item
:
cartItemList
)
{
if
(
productCategoryIds
.
contains
(
item
.
getProductCategoryId
())){
BigDecimal
realPrice
=
item
.
getPrice
().
subtract
(
item
.
getReduceAmount
());
total
=
total
.
add
(
realPrice
.
multiply
(
new
BigDecimal
(
item
.
getQuantity
())));
}
}
return
total
;
}
private
BigDecimal
calcTotalAmountByProductId
(
List
<
CartPromotionItem
>
cartItemList
,
List
<
Long
>
productIds
)
{
BigDecimal
total
=
new
BigDecimal
(
"0"
);
for
(
CartPromotionItem
item
:
cartItemList
)
{
if
(
productIds
.
contains
(
item
.
getProductId
())){
BigDecimal
realPrice
=
item
.
getPrice
().
subtract
(
item
.
getReduceAmount
());
total
=
total
.
add
(
realPrice
.
multiply
(
new
BigDecimal
(
item
.
getQuantity
())));
}
}
return
total
;
}
}
mall-portal/src/main/resources/dao/SmsCouponHistoryDao.xml
0 → 100644
View file @
61a67c9a
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.macro.mall.portal.dao.SmsCouponHistoryDao"
>
<resultMap
id=
"couponHistoryDetailMap"
type=
"com.macro.mall.portal.domain.SmsCouponHistoryDetail"
extends=
"com.macro.mall.mapper.SmsCouponHistoryMapper.BaseResultMap"
>
<association
property=
"coupon"
resultMap=
"com.macro.mall.mapper.SmsCouponMapper.BaseResultMap"
columnPrefix=
"c_"
>
</association>
<collection
property=
"productRelationList"
columnPrefix=
"cpr_"
resultMap=
"com.macro.mall.mapper.SmsCouponProductRelationMapper.BaseResultMap"
>
</collection>
<collection
property=
"categoryRelationList"
columnPrefix=
"cpcr_"
resultMap=
"com.macro.mall.mapper.SmsCouponProductCategoryRelationMapper.BaseResultMap"
>
</collection>
</resultMap>
<select
id=
"getDetailList"
resultMap=
"couponHistoryDetailMap"
>
SELECT
ch.*,
c.id c_id,
c.name c_name,
c.amount c_amount,
c.min_point c_min_point,
c.platform c_platform,
c.start_time c_start_time,
c.end_time c_end_time,
c.note c_note,
c.use_type c_use_type,
c.type c_type,
cpr.id cpr_id,cpr.product_id cpr_product_id,
cpcr.id cpcr_id,cpcr.product_category_id cpcr_product_category_id
FROM
sms_coupon_history ch
LEFT JOIN sms_coupon c ON ch.coupon_id = c.id
LEFT JOIN sms_coupon_product_relation cpr ON cpr.coupon_id = c.id
LEFT JOIN sms_coupon_product_category_relation cpcr ON cpcr.coupon_id = c.id
WHERE ch.member_id = #{memberId}
</select>
</mapper>
\ No newline at end of file
Write
Preview
Supports
Markdown
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