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
237ec4d9
Commit
237ec4d9
authored
Nov 19, 2018
by
zhh
Browse files
限时购接口修改
parent
313e0cde
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
document/sql/mall.sql
View file @
237ec4d9
This diff is collapsed.
Click to expand it.
mall-admin/src/main/java/com/macro/mall/controller/SmsFlashPromotionSessionController.java
View file @
237ec4d9
package
com.macro.mall.controller
;
import
com.macro.mall.dto.CommonResult
;
import
com.macro.mall.dto.SmsFlashPromotionSessionDetail
;
import
com.macro.mall.model.SmsFlashPromotionSession
;
import
com.macro.mall.service.SmsFlashPromotionSessionService
;
import
io.swagger.annotations.Api
;
...
...
@@ -73,11 +74,19 @@ public class SmsFlashPromotionSessionController {
return
new
CommonResult
().
success
(
promotionSession
);
}
@ApiOperation
(
"
根据状态
获取全部场次"
)
@ApiOperation
(
"获取全部场次"
)
@RequestMapping
(
value
=
"/list"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
list
(
Integer
status
)
{
List
<
SmsFlashPromotionSession
>
promotionSessionList
=
flashPromotionSessionService
.
list
(
status
);
return
new
CommonResult
().
pageS
uccess
(
promotionSessionList
);
public
Object
list
()
{
List
<
SmsFlashPromotionSession
>
promotionSessionList
=
flashPromotionSessionService
.
list
();
return
new
CommonResult
().
s
uccess
(
promotionSessionList
);
}
}
@ApiOperation
(
"获取全部可选场次及其数量"
)
@RequestMapping
(
value
=
"/selectList"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
selectList
(
Long
flashPromotionId
)
{
List
<
SmsFlashPromotionSessionDetail
>
promotionSessionList
=
flashPromotionSessionService
.
selectList
(
flashPromotionId
);
return
new
CommonResult
().
success
(
promotionSessionList
);
}
}
\ No newline at end of file
mall-admin/src/main/java/com/macro/mall/dto/SmsFlashPromotionSessionDetail.java
0 → 100644
View file @
237ec4d9
package
com.macro.mall.dto
;
import
com.macro.mall.model.SmsFlashPromotionSession
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* 包含商品数量的场次信息
* Created by macro on 2018/11/19.
*/
public
class
SmsFlashPromotionSessionDetail
extends
SmsFlashPromotionSession
{
@Setter
@Getter
private
Integer
productCount
;
}
mall-admin/src/main/java/com/macro/mall/service/SmsFlashPromotionProductRelationService.java
View file @
237ec4d9
...
...
@@ -39,4 +39,12 @@ public interface SmsFlashPromotionProductRelationService {
* @param flashPromotionSessionId 限时购场次id
*/
List
<
SmsFlashPromotionProduct
>
list
(
Long
flashPromotionId
,
Long
flashPromotionSessionId
,
Integer
pageSize
,
Integer
pageNum
);
/**
* 根据活动和场次id获取商品关系数量
* @param flashPromotionId
* @param flashPromotionSessionId
* @return
*/
int
getCount
(
Long
flashPromotionId
,
Long
flashPromotionSessionId
);
}
mall-admin/src/main/java/com/macro/mall/service/SmsFlashPromotionSessionService.java
View file @
237ec4d9
package
com.macro.mall.service
;
import
com.macro.mall.dto.SmsFlashPromotionSessionDetail
;
import
com.macro.mall.model.SmsFlashPromotionSession
;
import
java.util.List
;
...
...
@@ -37,5 +38,10 @@ public interface SmsFlashPromotionSessionService {
/**
* 根据启用状态获取场次列表
*/
List
<
SmsFlashPromotionSession
>
list
(
Integer
status
);
List
<
SmsFlashPromotionSession
>
list
();
/**
* 获取全部可选场次及其数量
*/
List
<
SmsFlashPromotionSessionDetail
>
selectList
(
Long
flashPromotionId
);
}
mall-admin/src/main/java/com/macro/mall/service/impl/SmsFlashPromotionProductRelationServiceImpl.java
View file @
237ec4d9
...
...
@@ -5,6 +5,7 @@ import com.macro.mall.dao.SmsFlashPromotionProductRelationDao;
import
com.macro.mall.dto.SmsFlashPromotionProduct
;
import
com.macro.mall.mapper.SmsFlashPromotionProductRelationMapper
;
import
com.macro.mall.model.SmsFlashPromotionProductRelation
;
import
com.macro.mall.model.SmsFlashPromotionProductRelationExample
;
import
com.macro.mall.service.SmsFlashPromotionProductRelationService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -50,4 +51,13 @@ public class SmsFlashPromotionProductRelationServiceImpl implements SmsFlashProm
PageHelper
.
startPage
(
pageNum
,
pageSize
);
return
relationDao
.
getList
(
flashPromotionId
,
flashPromotionSessionId
);
}
@Override
public
int
getCount
(
Long
flashPromotionId
,
Long
flashPromotionSessionId
)
{
SmsFlashPromotionProductRelationExample
example
=
new
SmsFlashPromotionProductRelationExample
();
example
.
createCriteria
()
.
andFlashPromotionIdEqualTo
(
flashPromotionId
)
.
andFlashPromotionSessionIdEqualTo
(
flashPromotionSessionId
);
return
relationMapper
.
countByExample
(
example
);
}
}
mall-admin/src/main/java/com/macro/mall/service/impl/SmsFlashPromotionSessionServiceImpl.java
View file @
237ec4d9
package
com.macro.mall.service.impl
;
import
com.macro.mall.dto.SmsFlashPromotionSessionDetail
;
import
com.macro.mall.mapper.SmsFlashPromotionSessionMapper
;
import
com.macro.mall.model.SmsFlashPromotionSession
;
import
com.macro.mall.model.SmsFlashPromotionSessionExample
;
import
com.macro.mall.service.SmsFlashPromotionProductRelationService
;
import
com.macro.mall.service.SmsFlashPromotionSessionService
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -18,6 +22,8 @@ import java.util.List;
public
class
SmsFlashPromotionSessionServiceImpl
implements
SmsFlashPromotionSessionService
{
@Autowired
private
SmsFlashPromotionSessionMapper
promotionSessionMapper
;
@Autowired
private
SmsFlashPromotionProductRelationService
relationService
;
@Override
public
int
create
(
SmsFlashPromotionSession
promotionSession
)
{
...
...
@@ -50,11 +56,24 @@ public class SmsFlashPromotionSessionServiceImpl implements SmsFlashPromotionSes
}
@Override
public
List
<
SmsFlashPromotionSession
>
list
(
Integer
status
)
{
public
List
<
SmsFlashPromotionSession
>
list
()
{
SmsFlashPromotionSessionExample
example
=
new
SmsFlashPromotionSessionExample
();
if
(
status
!=
null
)
{
example
.
createCriteria
().
andStatusEqualTo
(
status
);
}
return
promotionSessionMapper
.
selectByExample
(
example
);
}
@Override
public
List
<
SmsFlashPromotionSessionDetail
>
selectList
(
Long
flashPromotionId
)
{
List
<
SmsFlashPromotionSessionDetail
>
result
=
new
ArrayList
<>();
SmsFlashPromotionSessionExample
example
=
new
SmsFlashPromotionSessionExample
();
example
.
createCriteria
().
andStatusEqualTo
(
1
);
List
<
SmsFlashPromotionSession
>
list
=
promotionSessionMapper
.
selectByExample
(
example
);
for
(
SmsFlashPromotionSession
promotionSession
:
list
)
{
SmsFlashPromotionSessionDetail
detail
=
new
SmsFlashPromotionSessionDetail
();
BeanUtils
.
copyProperties
(
promotionSession
,
detail
);
int
count
=
relationService
.
getCount
(
flashPromotionId
,
promotionSession
.
getId
());
detail
.
setProductCount
(
count
);
result
.
add
(
detail
);
}
return
result
;
}
}
mall-admin/src/main/resources/dao/SmsFlashPromotionProductRelationDao.xml
View file @
237ec4d9
...
...
@@ -10,6 +10,9 @@
r.flash_promotion_price,
r.flash_promotion_count,
r.flash_promotion_limit,
r.flash_promotion_id,
r.flash_promotion_session_id,
r.product_id,
r.sort,
p.id p_id,
p.`name` p_name,
...
...
@@ -22,5 +25,6 @@
WHERE
r.flash_promotion_id = #{flashPromotionId}
AND r.flash_promotion_session_id = #{flashPromotionSessionId}
ORDER BY r.sort DESC
</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