Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
62642346
提交
62642346
authored
12月 09, 2020
作者:
吴德鹏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
活动
上级
f24368a3
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
101 行增加
和
321 行删除
+101
-321
ActivityController.java
...m/example/afrishop_v3/controllers/ActivityController.java
+13
-7
BonusController.java
.../com/example/afrishop_v3/controllers/BonusController.java
+67
-67
FlutterWaveController.java
...xample/afrishop_v3/controllers/FlutterWaveController.java
+1
-1
Activity.java
src/main/java/com/example/afrishop_v3/models/Activity.java
+11
-237
ActivityRepository.java
...om/example/afrishop_v3/repository/ActivityRepository.java
+2
-2
WebSecurityConfig.java
...a/com/example/afrishop_v3/security/WebSecurityConfig.java
+1
-1
application-prod.yml
src/main/resources/application-prod.yml
+5
-5
application.properties
src/main/resources/application.properties
+1
-1
没有找到文件。
src/main/java/com/example/afrishop_v3/controllers/ActivityController.java
浏览文件 @
62642346
...
@@ -5,12 +5,12 @@ import com.example.afrishop_v3.models.Activity;
...
@@ -5,12 +5,12 @@ import com.example.afrishop_v3.models.Activity;
import
com.example.afrishop_v3.repository.ActivityRepository
;
import
com.example.afrishop_v3.repository.ActivityRepository
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
/**
/**
* @Auther: wudepeng
* @Auther: wudepeng
...
@@ -28,10 +28,16 @@ public class ActivityController {
...
@@ -28,10 +28,16 @@ public class ActivityController {
}
}
@GetMapping
(
"/getAllActivity"
)
@GetMapping
(
"/getAllActivity"
)
public
Result
getAllActivity
(
@RequestParam
(
"pageNum
"
)
Integer
pageNum
,
public
Result
getAllActivity
(
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"0
"
)
Integer
pageNum
,
@RequestParam
(
"pageSize
"
)
Integer
pageSize
)
{
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"12
"
)
Integer
pageSize
)
{
return
new
Result
(
activityRepository
.
getAllActivity
());
return
new
Result
(
activityRepository
.
getAllActivity
(
PageRequest
.
of
(
pageNum
,
pageSize
)));
}
@GetMapping
(
"/info/{id}"
)
public
Result
getActivityInfo
(
@PathVariable
(
"id"
)
String
id
)
{
return
new
Result
(
activityRepository
.
findById
(
id
));
}
}
...
...
src/main/java/com/example/afrishop_v3/controllers/BonusController.java
浏览文件 @
62642346
...
@@ -184,73 +184,73 @@ public class BonusController extends Controller {
...
@@ -184,73 +184,73 @@ public class BonusController extends Controller {
TbCfUserInfo
info
=
user
.
user
();
TbCfUserInfo
info
=
user
.
user
();
Optional
<
String
>
userIdOptional
=
bonus
.
userId
();
//
Optional<String> userIdOptional = bonus.userId();
//
String
orderId
=
bonus
.
getOrderId
();
//
String orderId = bonus.getOrderId();
//
if
(
orderId
==
null
)
//
if( orderId == null )
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Order is missing !!!"
);
//
return new Result(ResultCodeEnum.VALIDATE_ERROR.getCode(),"Order is missing !!!");
//
Optional
<
TbCfOrder
>
orderOptional
=
orderRepository
.
findById
(
orderId
);
//
Optional<TbCfOrder> orderOptional = orderRepository.findById(orderId);
//
if
(
!
orderOptional
.
isPresent
()
)
//
if( !orderOptional.isPresent() )
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Order is missing !!!"
);
//
return new Result(ResultCodeEnum.VALIDATE_ERROR.getCode(),"Order is missing !!!");
//
TbCfOrder
order
=
orderOptional
.
get
();
//
TbCfOrder order = orderOptional.get();
//
if
(
!
OrderStatusEnum
.
PAID
.
getValue
().
equals
(
order
.
getPayStatus
())
){
//
if( !OrderStatusEnum.PAID.getValue().equals(order.getPayStatus()) ){
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Invalid order status"
);
//
return new Result(ResultCodeEnum.VALIDATE_ERROR.getCode(),"Invalid order status");
}
//
}
//
if
(
repository
.
existsByOrderId
(
orderId
)
){
//
if( repository.existsByOrderId(orderId) ){
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Transaction already done !!!"
);
//
return new Result(ResultCodeEnum.VALIDATE_ERROR.getCode(),"Transaction already done !!!");
}
//
}
//
//
BigDecimal
amount
=
bonus
.
getAmount
();
//
BigDecimal amount = bonus.getAmount();
//
if
(
userIdOptional
.
isPresent
())
{
//
if (userIdOptional.isPresent()) {
//
Optional
<
TbCfUserInfo
>
optionalUser
=
userRepository
.
findById
(
userIdOptional
.
get
());
//
Optional<TbCfUserInfo> optionalUser = userRepository.findById(userIdOptional.get());
//
if
(
optionalUser
.
isPresent
())
{
//
if (optionalUser.isPresent()) {
//
TbCfUserInfo
user
=
optionalUser
.
get
();
//
TbCfUserInfo user = optionalUser.get();
//
Post
post
=
bonus
.
getPost
();
//
Post post = bonus.getPost();
//
Optional
<
Post
>
postOptional
=
post
==
null
?
Optional
.
empty
()
:
postRepository
.
findById
(
post
.
getId
());
//
Optional<Post> postOptional = post == null ? Optional.empty() : postRepository.findById(post.getId());
//
String
productSharer
=
bonus
.
getProductSharer
();
//
String productSharer = bonus.getProductSharer();
//
Optional
<
TbCfUserInfo
>
sharer
=
Optional
.
empty
();
//
Optional<TbCfUserInfo> sharer = Optional.empty();
//
if
(
productSharer
!=
null
){
//
if( productSharer != null){
sharer
=
userRepository
.
findByCode
(
productSharer
);
//
sharer = userRepository.findByCode(productSharer);
}
//
}
//
//
if
(
user
.
invited
())
{
//
if (user.invited()) {
BigDecimal
v
=
amount
.
multiply
(
BigDecimal
.
valueOf
(
10
)).
divide
(
BigDecimal
.
valueOf
(
100
),
RoundingMode
.
CEILING
);
//
BigDecimal v = amount.multiply(BigDecimal.valueOf(10)).divide(BigDecimal.valueOf(100),RoundingMode.CEILING);
bonus
.
setAmount
(
v
);
//
bonus.setAmount(v);
bonus
.
setUserInfo
(
user
);
//
bonus.setUserInfo(user);
bonus
.
setPercentage
(
10
);
//
bonus.setPercentage(10);
bonus
=
repository
.
save
(
bonus
);
//
bonus = repository.save(bonus);
if
(
user
.
hasFcm
()
){
//
if( user.hasFcm() ){
sendNotification
(
user
.
getFcm
(),
"Bonus alert !!"
,
user
.
display
()+
", You received bonus of $"
+
formatter
.
format
(
v
)+
" in your account"
);
//
sendNotification(user.getFcm(),"Bonus alert !!",user.display()+", You received bonus of $"+formatter.format(v)+" in your account");
}
//
}
}
//
}
//
//
TbCfUserInfo
bonusInc
=
runBonusInc
(
user
,
amount
,
5
,
false
,
orderId
);
//
TbCfUserInfo bonusInc = runBonusInc(user, amount, 5,false, orderId);
if
(
sharer
.
isPresent
()&&
sharer
.
get
().
getUserId
().
equals
(
user
.
getUserId
())){
//
if (sharer.isPresent()&&sharer.get().getUserId().equals(user.getUserId())){
runBonusInc
(
bonusInc
,
amount
,
5
,
false
,
orderId
);
//
runBonusInc(bonusInc, amount, 5,false, orderId);
}
//
}
runBonusInc
(
sharer
.
orElseGet
(()
->
(
postOptional
.
isPresent
()&&
!
postOptional
.
get
().
getUserId
().
equals
(
user
.
getUserId
()))?
postOptional
.
get
().
getRealUser
()
:
bonusInc
),
//
runBonusInc(sharer.orElseGet(() -> (postOptional.isPresent()&& !postOptional.get().getUserId().equals(user.getUserId()))? postOptional.get().getRealUser() : bonusInc),
amount
,
5
,
postOptional
.
isPresent
()
||
sharer
.
isPresent
(),
orderId
);
//
amount, 5,postOptional.isPresent() || sharer.isPresent(), orderId);
//runBonusInc(bonusInc, amount, 0);
//
//runBonusInc(bonusInc, amount, 0);
}
//
}
}
//
}
return
new
Result
<>(
bonus
);
return
new
Result
<>(
bonus
);
}
}
...
...
src/main/java/com/example/afrishop_v3/controllers/FlutterWaveController.java
浏览文件 @
62642346
...
@@ -81,7 +81,7 @@ public class FlutterWaveController extends Controller {
...
@@ -81,7 +81,7 @@ public class FlutterWaveController extends Controller {
public
ResponseEntity
<
String
>
payForOrderByCard
(
@RequestParam
(
"orderId"
)
String
orderId
,
@RequestBody
FlutterWaveCard
flutterWaveCard
)
{
public
ResponseEntity
<
String
>
payForOrderByCard
(
@RequestParam
(
"orderId"
)
String
orderId
,
@RequestBody
FlutterWaveCard
flutterWaveCard
)
{
RaveConstant
.
PUBLIC_KEY
=
PUBLIC_KEY
;
RaveConstant
.
PUBLIC_KEY
=
PUBLIC_KEY
;
RaveConstant
.
SECRET_KEY
=
SECRET_KEY
;
RaveConstant
.
SECRET_KEY
=
SECRET_KEY
;
RaveConstant
.
ENVIRONMENT
=
Environment
.
STAGING
;
//or live
RaveConstant
.
ENVIRONMENT
=
Environment
.
LIVE
;
//or live
// Result result = new Result();
// Result result = new Result();
Optional
<
TbCfOrder
>
byId
=
repository
.
findById
(
orderId
);
Optional
<
TbCfOrder
>
byId
=
repository
.
findById
(
orderId
);
...
...
src/main/java/com/example/afrishop_v3/models/Activity.java
浏览文件 @
62642346
package
com
.
example
.
afrishop_v3
.
models
;
package
com
.
example
.
afrishop_v3
.
models
;
import
lombok.Data
;
import
lombok.ToString
;
import
javax.persistence.Entity
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
javax.persistence.Id
;
import
javax.persistence.Transient
;
import
javax.persistence.Transient
;
...
@@ -17,6 +20,8 @@ import java.util.List;
...
@@ -17,6 +20,8 @@ import java.util.List;
*/
*/
@Entity
@Entity
@Data
@ToString
public
class
Activity
implements
Serializable
{
public
class
Activity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
@@ -30,7 +35,7 @@ public class Activity implements Serializable {
...
@@ -30,7 +35,7 @@ public class Activity implements Serializable {
*/
*/
private
String
name
;
private
String
name
;
/**
/**
* 活动类型 1:满减 2:满折 3:满
几
件打折
* 活动类型 1:满减 2:满折 3:满件打折
*/
*/
private
Integer
type
;
private
Integer
type
;
/**
/**
...
@@ -46,21 +51,13 @@ public class Activity implements Serializable {
...
@@ -46,21 +51,13 @@ public class Activity implements Serializable {
*/
*/
private
String
picture
;
private
String
picture
;
/**
/**
* 满减金额
* 活动条件(json)
*/
private
BigDecimal
fullAmount
;
/**
* 抵扣金额
*/
*/
private
BigDecimal
reducedAmount
;
private
String
condition
;
/**
/**
*
折扣率
*
特定商品链接
*/
*/
private
Double
discountRate
;
private
String
link
;
/**
* 商品IDS
*/
private
String
itemIds
;
/**
/**
* 活动状态 0:关闭 1:开启
* 活动状态 0:关闭 1:开启
*/
*/
...
@@ -77,233 +74,10 @@ public class Activity implements Serializable {
...
@@ -77,233 +74,10 @@ public class Activity implements Serializable {
* 创建时间
* 创建时间
*/
*/
private
Date
createTime
;
private
Date
createTime
;
/**
/**
* 更新时间
* 更新时间
*/
*/
private
Date
updateTime
;
private
Date
updateTime
;
// @Transient
// private List<TbCfStationItem> itemList;
/**
* 设置:活动ID
*/
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
/**
* 获取:活动ID
*/
public
String
getId
()
{
return
id
;
}
/**
* 设置:活动名称
*/
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
/**
* 获取:活动名称
*/
public
String
getName
()
{
return
name
;
}
/**
* 设置:活动类型 1:满减 2:满折 3:满几件打折
*/
public
void
setType
(
Integer
type
)
{
this
.
type
=
type
;
}
/**
* 获取:活动类型 1:满减 2:满折 3:满几件打折
*/
public
Integer
getType
()
{
return
type
;
}
/**
* 设置:使用类型 1:全场 2:分类商品 3:特定商品
*/
public
void
setUseType
(
Integer
useType
)
{
this
.
useType
=
useType
;
}
/**
* 获取:使用类型 1:全场 2:分类商品 3:特定商品
*/
public
Integer
getUseType
()
{
return
useType
;
}
/**
* 设置:商品分类ID
*/
public
void
setCategoryId
(
String
categoryId
)
{
this
.
categoryId
=
categoryId
;
}
/**
* 获取:商品分类ID
*/
public
String
getCategoryId
()
{
return
categoryId
;
}
/**
* 设置:活动图片
*/
public
void
setPicture
(
String
picture
)
{
this
.
picture
=
picture
;
}
/**
* 获取:活动图片
*/
public
String
getPicture
()
{
return
picture
;
}
/**
* 设置:满减金额
*/
public
void
setFullAmount
(
BigDecimal
fullAmount
)
{
this
.
fullAmount
=
fullAmount
;
}
/**
* 获取:满减金额
*/
public
BigDecimal
getFullAmount
()
{
return
fullAmount
;
}
/**
* 设置:抵扣金额
*/
public
void
setReducedAmount
(
BigDecimal
reducedAmount
)
{
this
.
reducedAmount
=
reducedAmount
;
}
/**
* 获取:抵扣金额
*/
public
BigDecimal
getReducedAmount
()
{
return
reducedAmount
;
}
/**
* 设置:折扣率
*/
public
void
setdiscountRate
(
Double
discountRate
)
{
this
.
discountRate
=
discountRate
;
}
/**
* 获取:折扣率
*/
public
Double
getdiscountRate
()
{
return
discountRate
;
}
/**
* 设置:商品IDS
*/
public
void
setItemIds
(
String
itemIds
)
{
this
.
itemIds
=
itemIds
;
}
/**
* 获取:商品IDS
*/
public
String
getItemIds
()
{
return
itemIds
;
}
/**
* 设置:活动状态 0:关闭 1:开启
*/
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
/**
* 获取:活动状态 0:关闭 1:开启
*/
public
Integer
getStatus
()
{
return
status
;
}
/**
* 设置:活动开始时间
*/
public
void
setStartTime
(
Date
startTime
)
{
this
.
startTime
=
startTime
;
}
/**
* 获取:活动开始时间
*/
public
Date
getStartTime
()
{
return
startTime
;
}
/**
* 设置:活动结束时间
*/
public
void
setEndTime
(
Date
endTime
)
{
this
.
endTime
=
endTime
;
}
/**
* 获取:活动结束时间
*/
public
Date
getEndTime
()
{
return
endTime
;
}
/**
* 设置:创建时间
*/
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
/**
* 获取:创建时间
*/
public
Date
getCreateTime
()
{
return
createTime
;
}
/**
* 设置:更新时间
*/
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
/**
* 获取:更新时间
*/
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
Double
getDiscountRate
()
{
return
discountRate
;
}
public
void
setDiscountRate
(
Double
discountRate
)
{
this
.
discountRate
=
discountRate
;
}
}
}
src/main/java/com/example/afrishop_v3/repository/ActivityRepository.java
浏览文件 @
62642346
...
@@ -15,6 +15,6 @@ import java.util.List;
...
@@ -15,6 +15,6 @@ import java.util.List;
*/
*/
public
interface
ActivityRepository
extends
JpaRepository
<
Activity
,
String
>
{
public
interface
ActivityRepository
extends
JpaRepository
<
Activity
,
String
>
{
@Query
(
value
=
"select a from Activity a where CURRENT_TIMESTAMP between startTime and endTime and status=1"
)
@Query
(
value
=
"select a from Activity a where CURRENT_TIMESTAMP between startTime and endTime and status=1
order by a.createTime desc
"
)
List
<
Activity
>
getAllActivity
(
);
Page
<
Activity
>
getAllActivity
(
Pageable
pageable
);
}
}
src/main/java/com/example/afrishop_v3/security/WebSecurityConfig.java
浏览文件 @
62642346
...
@@ -66,7 +66,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
...
@@ -66,7 +66,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.
sessionManagement
().
sessionCreationPolicy
(
SessionCreationPolicy
.
STATELESS
).
and
()
.
sessionManagement
().
sessionCreationPolicy
(
SessionCreationPolicy
.
STATELESS
).
and
()
.
authorizeRequests
().
antMatchers
(
"/api/auth/**"
,
"/search/image/**"
,
"/itemStation/**"
,
"/startPage/**"
,
.
authorizeRequests
().
antMatchers
(
"/api/auth/**"
,
"/search/image/**"
,
"/itemStation/**"
,
"/startPage/**"
,
"/goodsType/**"
,
"/home/**"
,
"/spider/**"
,
"/store/**"
,
"/shopify/**"
,
"/community/**"
,
"/version/**"
,
"/goodsType/**"
,
"/home/**"
,
"/spider/**"
,
"/store/**"
,
"/shopify/**"
,
"/community/**"
,
"/version/**"
,
"/flutterwave/notify/**"
,
"/dpo/notify/**"
,
"/advertisement/**"
,
"/website/**"
,
"/paypal/**"
,
"/discover/bonus/**"
,
"/problem/**"
,
"/cube
/**"
).
permitAll
()
"/flutterwave/notify/**"
,
"/dpo/notify/**"
,
"/advertisement/**"
,
"/website/**"
,
"/paypal/**"
,
"/discover/bonus/**"
,
"/problem/**"
,
"/cube/**"
,
"/activity
/**"
).
permitAll
()
.
antMatchers
(
"/api/test/**"
).
permitAll
()
.
antMatchers
(
"/api/test/**"
).
permitAll
()
.
anyRequest
().
authenticated
();
.
anyRequest
().
authenticated
();
...
...
src/main/resources/application-prod.yml
浏览文件 @
62642346
server
:
#
server:
servlet
:
#
servlet:
context-path
:
/afrishop
#
context-path: /afrishop
port
:
8099
#
port: 8099
spring
:
spring
:
datasource
:
datasource
:
url
:
jdbc:mysql://159.138.48.71:3306/chinafrica
_ref_test
?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
url
:
jdbc:mysql://159.138.48.71:3306/chinafrica?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
username
:
root
username
:
root
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
password
:
Diaoyunnuli.8
password
:
Diaoyunnuli.8
...
...
src/main/resources/application.properties
浏览文件 @
62642346
server.servlet.context-path
=
/zion
server.servlet.context-path
=
/zion
spring.jpa.hibernate.ddl-auto
=
update
spring.jpa.hibernate.ddl-auto
=
update
server.port
=
8083
server.port
=
8083
spring.profiles.active
=
test
spring.profiles.active
=
prod
#spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/afrishop_test?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
#spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/afrishop_test?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
#spring.datasource.username=root
#spring.datasource.username=root
#spring.datasource.password=Diaoyunnuli.8
#spring.datasource.password=Diaoyunnuli.8
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论