Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
wxShop
api
Commits
913a6600
Commit
913a6600
authored
Jul 28, 2020
by
不悦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ycf0728
parent
14c7a993
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
426 additions
and
112 deletions
+426
-112
BargainController.java
...ava/com/yami/shop/admin/controller/BargainController.java
+82
-31
admin.properties
yami-shop-admin/src/main/resources/admin.properties
+2
-1
application-dev.yml
yami-shop-admin/src/main/resources/application-dev.yml
+8
-8
AreaController.java
...ain/java/com/yami/shop/api/controller/AreaController.java
+1
-1
BargainController.java
.../java/com/yami/shop/api/controller/BargainController.java
+58
-21
MiniAppAuthenticationProvider.java
...yami/shop/api/security/MiniAppAuthenticationProvider.java
+1
-1
api.properties
yami-shop-api/src/main/resources/api.properties
+3
-2
application-dev.yml
yami-shop-api/src/main/resources/application-dev.yml
+7
-7
Bargain.java
...-bean/src/main/java/com/yami/shop/bean/model/Bargain.java
+6
-4
BargainParm.java
...n/src/main/java/com/yami/shop/bean/model/BargainParm.java
+0
-5
BargainSend.java
...n/src/main/java/com/yami/shop/bean/model/BargainSend.java
+11
-0
apiclient_cert.p12
yami-shop-mp/src/main/resources/apiclient_cert.p12
+0
-0
ma.properties
yami-shop-mp/src/main/resources/ma.properties
+3
-2
mp.properties
yami-shop-mp/src/main/resources/mp.properties
+2
-1
pay.properties
yami-shop-mp/src/main/resources/pay.properties
+7
-4
BargainMapper.java
...ervice/src/main/java/com/yami/shop/dao/BargainMapper.java
+12
-2
BargainService.java
...e/src/main/java/com/yami/shop/service/BargainService.java
+11
-3
BargainServiceImpl.java
...n/java/com/yami/shop/service/impl/BargainServiceImpl.java
+21
-6
BargainMapper.xml
...-shop-service/src/main/resources/mapper/BargainMapper.xml
+186
-12
BargainSendMapper.xml
...p-service/src/main/resources/mapper/BargainSendMapper.xml
+5
-1
No files found.
yami-shop-admin/src/main/java/com/yami/shop/admin/controller/BargainController.java
View file @
913a6600
package
com
.
yami
.
shop
.
admin
.
controller
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yami.shop.bean.app.dto.ProductDto
;
import
com.yami.shop.bean.model.Bargain
;
import
com.yami.shop.bean.model.BargainDetailParm
;
import
com.yami.shop.bean.model.BargainParm
;
...
...
@@ -10,6 +12,7 @@ import com.yami.shop.service.BargainService;
import
com.yami.shop.service.ProductService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -17,9 +20,10 @@ import org.springframework.web.bind.annotation.*;
import
javax.validation.Valid
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
@RestController
@RequestMapping
(
"/bargain"
)
@RequestMapping
(
"/
admin/
bargain"
)
@Api
(
tags
=
"砍价后台"
)
public
class
BargainController
{
...
...
@@ -29,48 +33,88 @@ public class BargainController {
@Autowired
private
ProductService
productService
;
/**
* 保存
*/
@PostMapping
@ApiOperation
(
value
=
"
砍价活动设置参数"
,
notes
=
"砍价活动设置参数
"
)
public
ResponseEntity
<
String
>
save
(
@Valid
@RequestBody
Bargain
bargain
)
{
String
userId
=
SecurityUtils
.
getUser
().
getUserId
();
@PostMapping
(
"/save"
)
@ApiOperation
(
value
=
"
新增"
,
notes
=
"新增
"
)
public
ResponseEntity
<
Bargain
>
save
(
@Valid
@RequestBody
Bargain
bargain
)
{
bargain
.
setCreatedAt
(
new
Date
());
bargain
.
setCreatedUser
(
userId
);
bargainService
.
saveBargain
(
bargain
);
return
ResponseEntity
.
ok
().
build
();
bargain
.
setStatus
(
0
);
bargain
.
setStartTime
(
new
Date
());
bargain
.
setOverTime
(
new
Date
());
Long
id
=
bargainService
.
insertSelective
(
bargain
);
Bargain
rebargain
=
bargainService
.
getBargainById
(
id
);
return
ResponseEntity
.
ok
(
rebargain
);
}
// /**
// * 获取信息
// */
// @GetMapping("/info/{id}")
// @ApiOperation(value = "砍价活动查询", notes = "砍价活动查询")
// public ResponseEntity<Bargain> info (@PathVariable("id") Long id) {
// System.out.print("---------------------------------------------------------------------------------");
// Bargain bargain = bargainService.getBargainById(id);
// if(ObjectUtil.isNotNull(bargain)){
// Product product = productService.getProductByProdId(bargain.getProdId());
// bargain.setProduct(product);
// }
// return ResponseEntity.ok(bargain);
// @PostMapping("/saveBargain")
// @ApiOperation(value = "测试", notes = "测试")
// public ResponseEntity<String> saveBargain(@Valid @RequestBody Bargain bargain){
// String userId = SecurityUtils.getUser().getUserId();
// bargain.setCreatedAt(new Date());
// bargain.setCreatedUser(userId);
// bargain.setStatus(0);
// bargain.setStartTime(new Date());
// bargain.setOverTime(new Date());
// Long id = bargainService.insertSelective(bargain);
// return ResponseEntity.ok(""+id);
// }
@PostMapping
(
"/edit"
)
@ApiOperation
(
value
=
"砍价活动:设置参数"
,
notes
=
"砍价活动设置参数"
)
public
ResponseEntity
<
String
>
edit
(
@Valid
@RequestBody
Bargain
bargain
)
{
// if(bargain.getStatus()==1){
// if(ObjectUtil.isNotNull(bargain.getStartTime())||ObjectUtil.isNotNull(bargain.getOverTime())){
// return ResponseEntity.ok("活动开始时间和结束时间不能为空");
// }
// }
bargainService
.
updateByPrimaryKeySelective
(
bargain
);
return
ResponseEntity
.
ok
().
build
();
}
@GetMapping
(
"/delete/{id}"
)
@ApiOperation
(
value
=
"设置参数:删除"
,
notes
=
"删除"
)
public
ResponseEntity
<
String
>
delete
(
@PathVariable
(
"id"
)
Long
id
)
{
bargainService
.
deleteByPrimaryKey
(
id
);
return
ResponseEntity
.
ok
().
build
();
}
/**
* 获取信息
*/
@PostMapping
(
"/info"
)
@ApiOperation
(
value
=
"砍价活动查询"
,
notes
=
"砍价活动查询"
)
public
ResponseEntity
<
List
<
Bargain
>>
info
(
@Valid
@RequestBody
Bargain
bargain
)
{
List
<
Bargain
>
bargainList
=
bargainService
.
list
(
new
LambdaQueryWrapper
<
Bargain
>()
.
like
(
bargain
.
getProdName
()
!=
null
,
Bargain:
:
getProdName
,
bargain
.
getProdName
()));
for
(
Bargain
BG:
bargainList
){
Product
product
=
productService
.
getProductByProdId
(
BG
.
getProdId
());
BG
.
setCostPrice
(
product
.
getPrice
());
}
return
ResponseEntity
.
ok
(
bargainList
);
}
/**
* 砍价统计
* @param
prodName
* @param
* @return
*/
@
GetMapping
(
"/infoTotal/{prodName}
"
)
@
PostMapping
(
"/infoTotal
"
)
@ApiOperation
(
value
=
"砍价统计"
,
notes
=
"砍价统计"
)
public
ResponseEntity
<
List
<
BargainParm
>>
infoTotal
(
@PathVariable
(
"prodName"
)
String
prodName
)
{
if
(
prodName
.
equals
(
"\"\""
)){
prodName
=
""
;
public
ResponseEntity
<
List
<
BargainParm
>>
infoTotal
(
@Valid
@RequestBody
Bargain
bargain
)
{
if
(
bargain
.
getProdName
().
equals
(
"\"\""
)){
bargain
.
setProdName
(
""
);
}
List
<
BargainParm
>
bargainParmList
=
bargainService
.
selectBargainTotalList
(
bargain
.
getProdName
());
if
(
bargainParmList
.
size
()>
0
){
for
(
BargainParm
bargainParm:
bargainParmList
){
bargainParm
.
setBargainNum
(
bargainService
.
selectBargainNum
(
bargainParm
.
getId
()));
}
}
String
userId
=
SecurityUtils
.
getUser
().
getUserId
();
List
<
BargainParm
>
bargainParmList
=
bargainService
.
selectBargainTotalList
(
prodName
,
userId
);
return
ResponseEntity
.
ok
(
bargainParmList
);
}
...
...
@@ -81,10 +125,17 @@ public class BargainController {
*/
@GetMapping
(
"/infoDetail/{id}"
)
@ApiOperation
(
value
=
"砍价详情"
,
notes
=
"砍价详情"
)
public
ResponseEntity
<
BargainDetailParm
>
infoDetail
(
@PathVariable
(
"id"
)
Long
id
)
{
BargainDetailParm
bargainDetail
=
bargainService
.
selectBargainDetail
(
id
);
bargainDetail
.
setResidueMoney
(
bargainDetail
.
getPrice
()-
bargainDetail
.
getCutMoney
());
public
ResponseEntity
<
List
<
BargainDetailParm
>>
infoDetail
(
@PathVariable
(
"id"
)
Long
id
)
{
List
<
BargainDetailParm
>
bargainDetail
=
bargainService
.
selectBargainDetail
(
id
);
if
(
bargainDetail
.
size
()>
0
){
for
(
BargainDetailParm
bargainDetailParm:
bargainDetail
){
bargainDetailParm
.
setResidueMoney
(
bargainDetailParm
.
getPrice
()-
bargainDetailParm
.
getCutMoney
());
}
}
return
ResponseEntity
.
ok
(
bargainDetail
);
}
}
yami-shop-admin/src/main/resources/admin.properties
View file @
913a6600
admin.datacenterId
=
1
admin.workerId
=
0
admin.workerId
=
0
\ No newline at end of file
yami-shop-admin/src/main/resources/application-dev.yml
View file @
913a6600
...
...
@@ -2,16 +2,16 @@ server:
port
:
8085
spring
:
datasource
:
url
:
jdbc:mysql://rm-m5ee12omj4y0g741d0o.mysql.rds.aliyuncs.com:3306/retail_shops?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
username
:
kszzshop
password
:
eE12omj4y0g7#
driver-class-name
:
com.mysql.cj.jdbc.Driver
type
:
com.zaxxer.hikari.HikariDataSource
# url: jdbc:mysql://localhost:3306/yami_shops?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
# username: root
# password: root
# url: jdbc:mysql://rm-m5ee12omj4y0g741d0o.mysql.rds.aliyuncs.com:3306/retail_shops?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
# username: kszzshop
# password: eE12omj4y0g7#
# driver-class-name: com.mysql.cj.jdbc.Driver
# type: com.zaxxer.hikari.HikariDataSource
url
:
jdbc:mysql://localhost:3306/yami_shops?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
username
:
root
password
:
root
driver-class-name
:
com.mysql.cj.jdbc.Driver
type
:
com.zaxxer.hikari.HikariDataSource
hikari
:
minimum-idle
:
0
maximum-pool-size
:
20
...
...
yami-shop-api/src/main/java/com/yami/shop/api/controller/AreaController.java
View file @
913a6600
...
...
@@ -47,5 +47,5 @@ public class AreaController {
List
<
Area
>
list
=
areaService
.
listByPid
(
pid
);
return
ResponseEntity
.
ok
(
list
);
}
}
yami-shop-api/src/main/java/com/yami/shop/api/controller/BargainController.java
View file @
913a6600
...
...
@@ -19,6 +19,8 @@ import org.springframework.transaction.annotation.Transactional;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.Valid
;
import
java.text.ParsePosition
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
@RestController
...
...
@@ -56,16 +58,19 @@ public class BargainController {
public
ResponseEntity
<
IPage
<
Bargain
>>
page
(
PageParam
<
Bargain
>
page
)
{
IPage
<
Bargain
>
bargains
=
bargainService
.
page
(
page
,
new
LambdaQueryWrapper
<
Bargain
>()
.
eq
(
Bargain:
:
getStatus
,
1
)
.
orderByDesc
(
Bargain:
:
getCreatedAt
));
for
(
Bargain
bargain:
bargains
.
getRecords
()){
List
<
BargainSend
>
bargainSendList
=
bargainSendService
.
selectBargainSendList
(
bargain
.
getId
());
if
(
bargainSendList
.
size
()>
0
){
bargain
.
setBargainSendList
(
bargainSendList
);
if
(
bargains
.
getRecords
().
size
()>
0
){
for
(
Bargain
bargain:
bargains
.
getRecords
()){
List
<
BargainSend
>
bargainSendList
=
bargainSendService
.
selectBargainSendList
(
bargain
.
getId
());
if
(
bargainSendList
.
size
()>
0
){
bargain
.
setBargainSendList
(
bargainSendList
);
}
int
count
=
bargainSendService
.
selectFinishOrderTask
(
bargain
.
getId
(),
1
);
bargain
.
setSendCount
(
count
);
ProductDto
product
=
prodController
.
prodInfoBargain
(
bargain
.
getProdId
());
bargain
.
setProductDto
(
product
);
}
int
count
=
bargainSendService
.
selectFinishOrderTask
(
bargain
.
getId
(),
1
);
bargain
.
setSendCount
(
count
);
ProductDto
product
=
prodController
.
prodInfoBargain
(
bargain
.
getProdId
());
bargain
.
setProductDto
(
product
);
}
return
ResponseEntity
.
ok
(
bargains
);
...
...
@@ -98,19 +103,49 @@ public class BargainController {
@ApiOperation
(
value
=
"发起人砍价任务详情"
,
notes
=
"新增发起人信息&&获取发起人砍价任务详情"
)
public
ResponseEntity
<
BargainSend
>
saveInfoBargainSend
(
@Valid
@RequestBody
BargainSend
bargainSend
)
{
String
userId
=
SecurityUtils
.
getUser
().
getUserId
();
User
user
=
userService
.
getById
(
userId
);
String
userImg
=
""
;
String
userNikeNmae
=
""
;
if
(
bargainSend
.
getUserId
()!=
null
&&
!
bargainSend
.
getUserId
().
equals
(
""
)){
userId
=
bargainSend
.
getUserId
();
User
user1
=
userService
.
getById
(
bargainSend
.
getUserId
());
userImg
=
user1
.
getPic
();
userNikeNmae
=
user1
.
getNickName
();
}
int
isFirstTime
=
0
;
BargainSend
BS
=
bargainSendService
.
selectBargainTask
(
userId
,
bargainSend
.
getActivityId
());
if
(
ObjectUtil
.
isNull
(
BS
)){
Bargain
bargain
=
bargainService
.
getBargainById
(
bargainSend
.
getActivityId
());
//取能砍的最低价格
isFirstTime
=
1
;
bargainSend
.
setCreatedAt
(
new
Date
());
bargainSend
.
setIsAddorder
(
0
);
//未下单
bargainSend
.
set
CreatedUser
(
userId
);
bargainSend
.
set
UserId
(
userId
);
bargainSend
.
setCreatedUser
(
userId
);
bargainSendService
.
saveBargainSend
(
bargainSend
);
BS
=
bargainSendService
.
selectBargainTask
(
userId
,
bargainSend
.
getActivityId
());
long
nowData
=
new
Date
().
getTime
();
long
startData
=
bargain
.
getStartTime
().
getTime
();
long
overData
=
bargain
.
getOverTime
().
getTime
();
if
(
nowData
>=
startData
&&
nowData
<=
overData
){
BargainHelp
bargainHelp
=
new
BargainHelp
();
Random
rand
=
new
Random
();
double
MAX
=
0
;
double
MIN
=
0
;
double
randNumber
=
0
;
MAX
=
bargain
.
getOldMax
();
MIN
=
bargain
.
getOldMin
();
randNumber
=
rand
.
nextDouble
()
*
(
MAX
-
MIN
)
+
MIN
;
bargainHelp
.
setBargainOrderId
(
BS
.
getId
());
bargainHelp
.
setCreatedAt
(
new
Date
());
bargainHelp
.
setAssistorId
(
user
.
getUserId
());
bargainHelp
.
setNickName
(
user
.
getNickName
());
bargainHelp
.
setHeadImg
(
user
.
getPic
());
bargainHelp
.
setBargainMoney
(
randNumber
);
bargainHelp
.
setIsUser
(
2
);
bargainHelpService
.
saveBargainHelp
(
bargainHelp
);
}
bargainSendService
.
updateCount
(
BS
.
getId
());
}
// Product product = productService.getProductByProdId(bargainSend.getProdId());
ProductDto
product
=
prodController
.
prodInfoBargain
(
bargainSend
.
getProdId
());
BS
.
setProductDto
(
product
);
Bargain
bargain
=
bargainService
.
getBargainById
(
bargainSend
.
getActivityId
());
...
...
@@ -123,7 +158,10 @@ public class BargainController {
cutMoney
+=
bargainHelp
.
getBargainMoney
();
}
}
BS
.
setUserImg
(
userImg
);
BS
.
setUserNikeName
(
userNikeNmae
);
BS
.
setCutMoney
(
cutMoney
);
BS
.
setIsFirstTime
(
isFirstTime
);
return
ResponseEntity
.
ok
(
BS
);
}
...
...
@@ -225,17 +263,15 @@ public class BargainController {
}
public
static
void
main
(
String
[]
args
)
{
long
time
=
(
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
)).
parse
(
"2018-06-30 20:00:00"
,
new
ParsePosition
(
0
)).
getTime
()
/
1000
;
Random
rand
=
new
Random
();
// int randNumber =rand.nextInt(MAX - MIN + 1) + MIN;
Scanner
sc
=
new
Scanner
(
System
.
in
);
while
(
true
)
{
System
.
out
.
println
(
"输入最大值值(true/false):"
);
double
MAX
=
sc
.
nextDouble
();
System
.
out
.
println
(
"输入最小值值(true/false):"
);
double
MIN
=
sc
.
nextDouble
();
double
randNumber
=
rand
.
nextDouble
()
*
(
MAX
-
MIN
)
+
MIN
;
System
.
out
.
println
(
"============="
+
randNumber
);
}
//获取时间戳
long
now1
=
System
.
currentTimeMillis
();
long
now2
=
new
Date
().
getTime
();
System
.
out
.
println
(
"获取指定时间的时间戳:"
+
time
);
System
.
out
.
println
(
"当前时间戳:"
+
now1
);
System
.
out
.
println
(
"当前时间戳:"
+
now2
);
}
}
\ No newline at end of file
yami-shop-api/src/main/java/com/yami/shop/api/security/MiniAppAuthenticationProvider.java
View file @
913a6600
...
...
@@ -43,7 +43,7 @@ public class MiniAppAuthenticationProvider extends AbstractUserDetailsAuthentica
private
final
CacheManagerUtil
cacheManagerUtil
;
private
final
static
String
APPID
=
"wx
50a14d592be6735e
"
;
private
final
static
String
APPID
=
"wx
72780b89fe2ee6f4
"
;
@Override
protected
Authentication
createSuccessAuthentication
(
Authentication
authentication
,
UserDetails
user
)
{
...
...
yami-shop-api/src/main/resources/api.properties
View file @
913a6600
api.datacenterId
=
1
api.workerId
=
1
api.domainName
=
https://retailmall.xmkszz.cn
\ No newline at end of file
api.domainName
=
https://retailmall.xmkszz.cn
#
api.domainName
=
https://mall.xmkszz.cn
\ No newline at end of file
yami-shop-api/src/main/resources/application-dev.yml
View file @
913a6600
...
...
@@ -2,16 +2,16 @@ server:
port
:
8086
spring
:
datasource
:
url
:
jdbc:mysql://127.0.0.1:3306/retail_shops?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
username
:
root
password
:
123
driver-class-name
:
com.mysql.cj.jdbc.Driver
type
:
com.zaxxer.hikari.HikariDataSource
# url: jdbc:mysql://127.0.0.1:3306/yami_shops?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
# url: jdbc:mysql://127.0.0.1:3306/retail_shops?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
# username: root
# password:
root
# password:
123
# driver-class-name: com.mysql.cj.jdbc.Driver
# type: com.zaxxer.hikari.HikariDataSource
url
:
jdbc:mysql://127.0.0.1:3306/yami_shops?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
username
:
root
password
:
root
driver-class-name
:
com.mysql.cj.jdbc.Driver
type
:
com.zaxxer.hikari.HikariDataSource
hikari
:
minimum-idle
:
0
maximum-pool-size
:
20
...
...
yami-shop-bean/src/main/java/com/yami/shop/bean/model/Bargain.java
View file @
913a6600
...
...
@@ -56,13 +56,13 @@ public class Bargain implements Serializable {
/**
* 状态:0未开始,1进行中,2已结束
*/
@ApiModelProperty
(
value
=
"状态:0
未开始,1进行中,2已结束
"
,
required
=
false
)
@ApiModelProperty
(
value
=
"状态:0
禁用,1启用
"
,
required
=
false
)
private
Integer
status
;
/**
* 序号
*/
@ApiModelProperty
(
value
=
"序号"
,
required
=
false
)
@ApiModelProperty
(
value
=
"序号
(预留字段,页面展示序号用主键id)
"
,
required
=
false
)
private
Long
sort
;
/**
...
...
@@ -139,6 +139,8 @@ public class Bargain implements Serializable {
@TableField
(
exist
=
false
)
private
Integer
SendCount
;
@ApiModelProperty
(
value
=
"单品id"
,
required
=
false
)
private
Long
skuId
;
@ApiModelProperty
(
value
=
"商品现价"
,
required
=
false
)
@TableField
(
exist
=
false
)
private
Double
costPrice
;
}
yami-shop-bean/src/main/java/com/yami/shop/bean/model/BargainParm.java
View file @
913a6600
...
...
@@ -11,11 +11,6 @@ public class BargainParm {
@ApiModelProperty
(
value
=
"砍价活动id"
,
required
=
false
)
private
Long
id
;
/**
* 序号
*/
@ApiModelProperty
(
value
=
"序号"
,
required
=
false
)
private
Long
sort
;
/**
* 活动名称
...
...
yami-shop-bean/src/main/java/com/yami/shop/bean/model/BargainSend.java
View file @
913a6600
...
...
@@ -93,4 +93,15 @@ public class BargainSend {
@ApiModelProperty
(
value
=
"砍掉的金额"
,
required
=
false
)
@TableField
(
exist
=
false
)
private
double
cutMoney
;
@ApiModelProperty
(
value
=
"头像"
,
required
=
false
)
@TableField
(
exist
=
false
)
private
String
userImg
;
@ApiModelProperty
(
value
=
"昵称"
,
required
=
false
)
@TableField
(
exist
=
false
)
private
String
userNikeName
;
@ApiModelProperty
(
value
=
"是否第一次发起砍价,1是,0否"
,
required
=
false
)
@TableField
(
exist
=
false
)
private
Integer
isFirstTime
;
}
yami-shop-mp/src/main/resources/apiclient_cert.p12
0 → 100644
View file @
913a6600
File added
yami-shop-mp/src/main/resources/ma.properties
View file @
913a6600
ma.appid
=
wx72780b89fe2ee6f4
ma.secret
=
75eb13974cd5b027941e8a779a10729d
\ No newline at end of file
ma.secret
=
78837e61297df3135e60c3701ab0b005
#
ma.secret
=
75eb13974cd5b027941e8a779a10729d
\ No newline at end of file
yami-shop-mp/src/main/resources/mp.properties
View file @
913a6600
mp.appid
=
wx72780b89fe2ee6f4
mp.secret
=
75eb13974cd5b027941e8a779a10729d
mp.secret
=
78837e61297df3135e60c3701ab0b005
#mp.secret=75eb13974cd5b027941e8a779a10729d
mp.token
=
mp.aesKey
=
yami-shop-mp/src/main/resources/pay.properties
View file @
913a6600
pay.mchId
=
1570890061
pay.mchKey
=
5d41402abc4b2a76b9719d911017c592
pay.keyPath
=
classpath:xxx.p12
\ No newline at end of file
pay.mchId
=
1600352176
#pay.mchId=1570890061
#pay.mchKey=5d41402abc4b2a76b9719d911017c592
pay.mchKey
=
9db5b7176865482695f9b5534e47171b
#pay.keyPath=classpath:apiclient_cert.p12
pay.keyPath
=
classpath:xxx.p12
yami-shop-service/src/main/java/com/yami/shop/dao/BargainMapper.java
View file @
913a6600
...
...
@@ -10,8 +10,18 @@ import java.util.List;
public
interface
BargainMapper
extends
BaseMapper
<
Bargain
>
{
List
<
BargainParm
>
selectBargainTotalList
(
@Param
(
"prodName"
)
String
prodName
,
@Param
(
"createdUser"
)
String
createdUser
);
int
insertSelective
(
Bargain
bargain
);
BargainDetailParm
selectBargainDetail
(
@Param
(
"id"
)
Long
id
);
int
updateByPrimaryKeySelective
(
Bargain
bargain
);
int
deleteByPrimaryKey
(
Long
id
);
List
<
BargainParm
>
selectBargainTotalList
(
@Param
(
"prodName"
)
String
prodName
);
int
selectBargainNum
(
@Param
(
"id"
)
Long
id
);
List
<
BargainDetailParm
>
selectBargainDetail
(
@Param
(
"id"
)
Long
id
);
Bargain
getBargainById
(
@Param
(
"id"
)
Long
id
);
}
yami-shop-service/src/main/java/com/yami/shop/service/BargainService.java
View file @
913a6600
...
...
@@ -5,6 +5,7 @@ import com.yami.shop.bean.model.Bargain;
import
com.yami.shop.bean.model.BargainDetailParm
;
import
com.yami.shop.bean.model.BargainParm
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
...
...
@@ -14,8 +15,13 @@ public interface BargainService extends IService<Bargain> {
*
* @param bargain 砍价信息
*/
void
saveBargain
(
Bargain
bargain
);
@Transactional
Long
insertSelective
(
Bargain
bargain
);
void
updateByPrimaryKeySelective
(
Bargain
bargain
);
void
deleteByPrimaryKey
(
Long
id
);
/**
* 根据id获取砍价商品信息
*
...
...
@@ -29,12 +35,14 @@ public interface BargainService extends IService<Bargain> {
* @param prodName
* @return
*/
List
<
BargainParm
>
selectBargainTotalList
(
String
prodName
,
String
createdUser
);
List
<
BargainParm
>
selectBargainTotalList
(
String
prodName
);
/**
* 砍价详情
* @param id
* @return
*/
BargainDetailParm
selectBargainDetail
(
Long
id
);
List
<
BargainDetailParm
>
selectBargainDetail
(
Long
id
);
int
selectBargainNum
(
Long
id
);
}
yami-shop-service/src/main/java/com/yami/shop/service/impl/BargainServiceImpl.java
View file @
913a6600
...
...
@@ -17,22 +17,37 @@ public class BargainServiceImpl extends ServiceImpl<BargainMapper, Bargain> impl
private
BargainMapper
bargainMapper
;
@Override
public
void
saveBargain
(
Bargain
bargain
)
{
bargainMapper
.
insert
(
bargain
);
public
Long
insertSelective
(
Bargain
bargain
)
{
bargainMapper
.
insertSelective
(
bargain
);
return
bargain
.
getId
();
}
@Override
public
void
updateByPrimaryKeySelective
(
Bargain
bargain
)
{
bargainMapper
.
updateByPrimaryKeySelective
(
bargain
);
}
@Override
public
void
deleteByPrimaryKey
(
Long
id
)
{
bargainMapper
.
deleteByPrimaryKey
(
id
);
}
@Override
public
Bargain
getBargainById
(
Long
id
)
{
return
bargainMapper
.
select
ById
(
id
);
return
bargainMapper
.
getBargain
ById
(
id
);
}
@Override
public
List
<
BargainParm
>
selectBargainTotalList
(
String
prodName
,
String
createdUser
)
{
return
bargainMapper
.
selectBargainTotalList
(
prodName
,
createdUser
);
public
List
<
BargainParm
>
selectBargainTotalList
(
String
prodName
)
{
return
bargainMapper
.
selectBargainTotalList
(
prodName
);
}
@Override
public
BargainDetailParm
selectBargainDetail
(
Long
id
)
{
public
List
<
BargainDetailParm
>
selectBargainDetail
(
Long
id
)
{
return
bargainMapper
.
selectBargainDetail
(
id
);
}
public
int
selectBargainNum
(
Long
id
){
return
bargainMapper
.
selectBargainNum
(
id
);
}
}
yami-shop-service/src/main/resources/mapper/BargainMapper.xml
View file @
913a6600
...
...
@@ -20,39 +20,200 @@
<result
column=
"stocks"
jdbcType=
"INTEGER"
property=
"stocks"
/>
<result
column=
"created_user"
jdbcType=
"VARCHAR"
property=
"createdUser"
/>
<result
column=
"created_at"
jdbcType=
"TIMESTAMP"
property=
"createdAt"
/>
<result
column=
"
sku_id"
jdbcType=
"BIGINT"
property=
"skuId
"
/>
<result
column=
"
costPrice"
jdbcType=
"DECIMAL"
property=
"costPrice
"
/>
</resultMap>
<insert
id=
"insertSelective"
parameterType=
"com.yami.shop.bean.model.Bargain"
>
<selectKey
keyProperty=
"id"
resultType=
"Long"
order=
"AFTER"
>
SELECT LAST_INSERT_ID()
</selectKey>
insert into tz_bargain
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
id,
</if>
<if
test=
"prodId != null"
>
prod_id,
</if>
<if
test=
"prodName != null"
>
prod_name,
</if>
<if
test=
"startTime != null"
>
start_time,
</if>
<if
test=
"overTime != null"
>
over_time,
</if>
<if
test=
"status != null"
>
status,
</if>
<if
test=
"sort != null"
>
sort,
</if>
<if
test=
"newMax != null"
>
new_max,
</if>
<if
test=
"newMin != null"
>
new_min,
</if>
<if
test=
"oldMax != null"
>
old_max,
</if>
<if
test=
"oldMin != null"
>
old_min,
</if>
<if
test=
"minPrice != null"
>
min_price,
</if>
<if
test=
"stocks != null"
>
stocks,
</if>
<if
test=
"createdUser != null"
>
created_user,
</if>
<if
test=
"createdAt != null"
>
created_at,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
#{id,jdbcType=BIGINT},
</if>
<if
test=
"prodId != null"
>
#{prodId,jdbcType=BIGINT},
</if>
<if
test=
"prodName != null"
>
#{prodName,jdbcType=VARCHAR},
</if>
<if
test=
"startTime != null"
>
#{startTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"overTime != null"
>
#{overTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"status != null"
>
#{status,jdbcType=TINYINT},
</if>
<if
test=
"sort != null"
>
#{sort,jdbcType=BIGINT},
</if>
<if
test=
"newMax != null"
>
#{newMax,jdbcType=DECIMAL},
</if>
<if
test=
"newMin != null"
>
#{newMin,jdbcType=DECIMAL},
</if>
<if
test=
"oldMax != null"
>
#{oldMax,jdbcType=DECIMAL},
</if>
<if
test=
"oldMin != null"
>
#{oldMin,jdbcType=DECIMAL},
</if>
<if
test=
"minPrice != null"
>
#{minPrice,jdbcType=DECIMAL},
</if>
<if
test=
"stocks != null"
>
#{stocks,jdbcType=INTEGER},
</if>
<if
test=
"createdUser != null"
>
#{createdUser,jdbcType=VARCHAR},
</if>
<if
test=
"createdAt != null"
>
#{createdAt,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.yami.shop.bean.model.Bargain"
>
update tz_bargain
<set
>
<if
test=
"prodId != null"
>
prod_id = #{prodId,jdbcType=BIGINT},
</if>
<if
test=
"prodName != null"
>
prod_name = #{prodName,jdbcType=VARCHAR},
</if>
<if
test=
"startTime != null"
>
start_time = #{startTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"overTime != null"
>
over_time = #{overTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"status != null"
>
status = #{status,jdbcType=TINYINT},
</if>
<if
test=
"sort != null"
>
sort = #{sort,jdbcType=BIGINT},
</if>
<if
test=
"newMax != null"
>
new_max = #{newMax,jdbcType=DECIMAL},
</if>
<if
test=
"newMin != null"
>
new_min = #{newMin,jdbcType=DECIMAL},
</if>
<if
test=
"oldMax != null"
>
old_max = #{oldMax,jdbcType=DECIMAL},
</if>
<if
test=
"oldMin != null"
>
old_min = #{oldMin,jdbcType=DECIMAL},
</if>
<if
test=
"minPrice != null"
>
min_price = #{minPrice,jdbcType=DECIMAL},
</if>
<if
test=
"stocks != null"
>
stocks = #{stocks,jdbcType=INTEGER},
</if>
<if
test=
"createdUser != null"
>
created_user = #{createdUser,jdbcType=VARCHAR},
</if>
<if
test=
"createdAt != null"
>
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Long"
>
delete from tz_bargain
where id = #{id,jdbcType=BIGINT}
</delete>
<select
id=
"selectBargainTotalList"
resultType=
"com.yami.shop.bean.model.BargainParm"
>
select
b.id,
b.sort,
b.prod_name,
count(
*
) userNum,
count(
bs.id!=0 or null
) userNum,
SUM(CASE WHEN bs.is_addorder=1 then bs.is_addorder else 0 end) successNum,
SUM(CASE WHEN bs.is_addorder=1 then bs.end_price else 0 end) endPriceNum,
sum(CASE WHEN bh.id !="" then 1 else 0 end) bargainNum
SUM(CASE WHEN bs.is_addorder=1 then bs.end_price else 0 end) endPriceNum
from tz_bargain b
left join tz_bargain_send bs
on b.id =bs.activity_id
left join tz_bargain_help bh
on bs.id= bh.bargain_order_id
where 1=1
<if
test=
"createdUser != null and createdUser != ''"
>
AND created_user = #{createdUser}
</if>
<if
test=
"prodName != null and prodName != ''"
>
AND b.prod_name like'%#{prodName}%'
</if>
group by b.id
</select>
<select
id=
"selectBargainNum"
resultType=
"java.lang.Integer"
>
select
count(*)
from tz_bargain b
left join tz_bargain_send bs
on b.id =bs.activity_id
left join tz_bargain_help bh
on bs.id= bh.bargain_order_id
where 1=1
<if
test=
"id != null and id != ''"
>
and b.id=#{id}
</if>
</select>
<select
id=
"selectBargainDetail"
resultType=
"com.yami.shop.bean.model.BargainDetailParm"
>
select
b.id id,
u.nick_name nickName,
u.user_mobile userMobile,
SUM(CASE WHEN bs.id != "" then bh.bargain_money else 0 end) cutMoney,
SUM
(CASE WHEN b.prod_id != "" then p.price else 0 end) price,
MAX
(CASE WHEN b.prod_id != "" then p.price else 0 end) price,
count(bh.id!=0 or null) cutNum,
count(bh.is_user=0 OR NULL) newNum,
count(bh.is_user=1 OR NULL) oldNum
...
...
@@ -66,5 +227,18 @@
left join tz_prod p
on b.prod_id=p.prod_id
where b.id=#{id}
group by b.id,bs.id
</select>
<select
id=
"getBargainById"
resultType=
"com.yami.shop.bean.model.Bargain"
>
select
b.*,p.price costPrice
from tz_bargain b
left join tz_prod p
on b.prod_id =p.prod_id
where b.id=#{id}
</select>
</mapper>
yami-shop-service/src/main/resources/mapper/BargainSendMapper.xml
View file @
913a6600
...
...
@@ -13,11 +13,15 @@
<result
column=
"end_price"
jdbcType=
"DECIMAL"
property=
"endPrice"
/>
<result
column=
"is_addorder"
jdbcType=
"INTEGER"
property=
"isAddorder"
/>
<result
column=
"created_at"
jdbcType=
"TIMESTAMP"
property=
"createdAT"
/>
<result
column=
"userImg"
jdbcType=
"VARCHAR"
property=
"userImg"
/>
</resultMap>
<select
id=
"selectBargainSendList"
resultType=
"com.yami.shop.bean.model.BargainSend"
>
select * from tz_bargain_send WHERE activity_id = #{activityId} limit 5
select bs.*,u.pic userImg from tz_bargain_send bs
left join tz_user u
on bs.user_id = u.user_id
WHERE activity_id = #{activityId} limit 3
</select>
<select
id=
"selectFinishOrderTask"
resultType=
"java.lang.Integer"
>
...
...
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