Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
7f1bb22f
提交
7f1bb22f
authored
12月 11, 2020
作者:
吴德鹏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update activity
上级
bab3516d
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
147 行增加
和
6 行删除
+147
-6
ActivityVo.java
src/main/java/com/example/afrishop_v3/models/ActivityVo.java
+27
-0
TbCfOrder.java
src/main/java/com/example/afrishop_v3/models/TbCfOrder.java
+120
-6
没有找到文件。
src/main/java/com/example/afrishop_v3/models/ActivityVo.java
0 → 100644
浏览文件 @
7f1bb22f
package
com
.
example
.
afrishop_v3
.
models
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.math.BigDecimal
;
/**
* @Auther: wudepeng
* @Date: 2020/12/11
* @Description:活动模板
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ActivityVo
{
private
Activity
activity
;
private
String
activityId
;
private
Integer
itemNum
;
private
BigDecimal
itemPrice
;
public
String
getActivityId
()
{
return
activity
==
null
?
null
:
activity
.
getId
();
}
}
src/main/java/com/example/afrishop_v3/models/TbCfOrder.java
浏览文件 @
7f1bb22f
package
com
.
example
.
afrishop_v3
.
models
;
package
com
.
example
.
afrishop_v3
.
models
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.example.afrishop_v3.base.Result
;
import
com.example.afrishop_v3.base.StateConstant
;
import
com.example.afrishop_v3.base.StateConstant
;
import
com.example.afrishop_v3.enums.OrderStatusEnum
;
import
com.example.afrishop_v3.enums.OrderStatusEnum
;
import
com.example.afrishop_v3.enums.ResultCodeEnum
;
import
com.example.afrishop_v3.repository.ActivityRepository
;
import
com.example.afrishop_v3.repository.ActivityRepository
;
import
com.example.afrishop_v3.repository.TbCfStationItemRepository
;
import
com.example.afrishop_v3.repository.TbCfStationItemRepository
;
import
com.example.afrishop_v3.util.IdUtil
;
import
com.example.afrishop_v3.util.IdUtil
;
...
@@ -13,10 +15,13 @@ import lombok.Data;
...
@@ -13,10 +15,13 @@ import lombok.Data;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONArray
;
import
org.hibernate.annotations.Where
;
import
org.hibernate.annotations.Where
;
import
org.springframework.data.relational.core.sql.In
;
import
org.springframework.data.relational.core.sql.In
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.math.RoundingMode
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -249,7 +254,7 @@ public class TbCfOrder {
...
@@ -249,7 +254,7 @@ public class TbCfOrder {
return
itemOrderList
;
return
itemOrderList
;
}
}
public
void
getItemOrderListFromCartList
(
List
<
TbCfCartRecordR
>
cartList
,
TbCfStationItemRepository
itemRepository
,
ActivityRepository
activityRepository
)
{
public
void
getItemOrderListFromCartList
(
List
<
TbCfCartRecordR
>
cartList
,
TbCfStationItemRepository
itemRepository
,
ActivityRepository
activityRepository
)
throws
ParseException
{
itemOrderList
=
cartList
.
stream
().
map
(
f
->
f
.
getOrderItem
(
orderId
)).
collect
(
Collectors
.
toList
());
itemOrderList
=
cartList
.
stream
().
map
(
f
->
f
.
getOrderItem
(
orderId
)).
collect
(
Collectors
.
toList
());
doSomeCalculations
(
itemRepository
,
activityRepository
);
doSomeCalculations
(
itemRepository
,
activityRepository
);
setOrderTime
(
new
Date
());
setOrderTime
(
new
Date
());
...
@@ -262,13 +267,14 @@ public class TbCfOrder {
...
@@ -262,13 +267,14 @@ public class TbCfOrder {
this
.
defaultTemplate
=
defaultTemplate
;
this
.
defaultTemplate
=
defaultTemplate
;
}
}
private
void
doSomeCalculations
(
TbCfStationItemRepository
itemRepository
,
ActivityRepository
activityRepository
)
{
private
void
doSomeCalculations
(
TbCfStationItemRepository
itemRepository
,
ActivityRepository
activityRepository
)
throws
ParseException
{
itemsPrice
=
itemsPrice
==
null
?
new
BigDecimal
(
0.0
)
:
itemsPrice
;
itemsPrice
=
itemsPrice
==
null
?
new
BigDecimal
(
0.0
)
:
itemsPrice
;
expressCost
=
expressCost
==
null
?
new
BigDecimal
(
0.0
)
:
expressCost
;
expressCost
=
expressCost
==
null
?
new
BigDecimal
(
0.0
)
:
expressCost
;
fee
=
fee
==
null
?
new
BigDecimal
(
0.0
)
:
fee
;
fee
=
fee
==
null
?
new
BigDecimal
(
0.0
)
:
fee
;
tax
=
tax
==
null
?
new
BigDecimal
(
0.0
)
:
tax
;
tax
=
tax
==
null
?
new
BigDecimal
(
0.0
)
:
tax
;
reduceAmount
=
reduceAmount
==
null
?
new
BigDecimal
(
0.0
)
:
reduceAmount
;
reduceAmount
=
reduceAmount
==
null
?
new
BigDecimal
(
0.0
)
:
reduceAmount
;
List
<
TemplateVo
>
templateList
=
new
ArrayList
<>();
List
<
TemplateVo
>
templateList
=
new
ArrayList
<>();
// List<ActivityVo> activityList = new ArrayList<>();
itemOrderList
.
forEach
(
item
->
{
itemOrderList
.
forEach
(
item
->
{
BigDecimal
itemPrice
=
item
.
getItemPriceTotal
();
BigDecimal
itemPrice
=
item
.
getItemPriceTotal
();
...
@@ -281,9 +287,16 @@ public class TbCfOrder {
...
@@ -281,9 +287,16 @@ public class TbCfOrder {
Optional
<
TbCfStationItem
>
optionalTbCfStationItem
=
itemRepository
.
findById
(
item
.
getItemId
());
Optional
<
TbCfStationItem
>
optionalTbCfStationItem
=
itemRepository
.
findById
(
item
.
getItemId
());
boolean
categoriesAct
=
activityRepository
.
existsByUseType
(
2
);
boolean
categoriesAct
=
activityRepository
.
existsByUseType
(
2
);
boolean
specialAct
=
activityRepository
.
existsByUseType
(
3
);
boolean
specialAct
=
activityRepository
.
existsByUseType
(
3
);
if
(
categoriesAct
||
specialAct
)
{
// Activity activity = new Activity();
// if (categoriesAct || specialAct) {
}
// try {
// activity = getItemActivity(activityRepository, itemRepository, item.getItemId());
// } catch (ParseException e) {
// e.printStackTrace();
// }
//
// activityList.add(new ActivityVo(activity, activity.getId(), item.getItemNum(), itemPrice));
// }
if
(
optionalTbCfStationItem
.
isPresent
())
{
if
(
optionalTbCfStationItem
.
isPresent
())
{
TbCfStationItem
stationItem
=
optionalTbCfStationItem
.
get
();
TbCfStationItem
stationItem
=
optionalTbCfStationItem
.
get
();
if
(
stationItem
.
getExpress
()
!=
null
)
{
if
(
stationItem
.
getExpress
()
!=
null
)
{
...
@@ -299,6 +312,8 @@ public class TbCfOrder {
...
@@ -299,6 +312,8 @@ public class TbCfOrder {
templateList
.
add
(
new
TemplateVo
(
template
,
template
.
getTemplateId
(),
item
.
getItemNum
(),
itemPrice
));
templateList
.
add
(
new
TemplateVo
(
template
,
template
.
getTemplateId
(),
item
.
getItemNum
(),
itemPrice
));
});
});
Map
<
String
,
List
<
TemplateVo
>>
map
=
templateList
.
stream
().
collect
(
Collectors
.
groupingBy
(
TemplateVo:
:
getTemplateId
));
Map
<
String
,
List
<
TemplateVo
>>
map
=
templateList
.
stream
().
collect
(
Collectors
.
groupingBy
(
TemplateVo:
:
getTemplateId
));
// Map<String, List<ActivityVo>> actMap = activityList.stream().collect(Collectors.groupingBy(ActivityVo::getActivityId));
//按模板分组计算商品价格
//按模板分组计算商品价格
Integer
itemSum
=
0
;
Integer
itemSum
=
0
;
List
<
TemplateVo
>
list
=
new
ArrayList
<>();
List
<
TemplateVo
>
list
=
new
ArrayList
<>();
...
@@ -362,8 +377,48 @@ public class TbCfOrder {
...
@@ -362,8 +377,48 @@ public class TbCfOrder {
System
.
out
.
println
(
"折扣比例:"
+
rate
);
System
.
out
.
println
(
"折扣比例:"
+
rate
);
itemsPrice
=
rate
.
multiply
(
itemsPrice
);
itemsPrice
=
rate
.
multiply
(
itemsPrice
);
}
}
}
/*else {
//按活动类型计算优惠价格
Integer sum = 0;
List<ActivityVo> actlist = new ArrayList<>();
for (String key : actMap.keySet()) {
Activity activity = null;
ActivityVo activityVo = new ActivityVo();
Integer count = 0;
BigDecimal totalPrice = BigDecimal.ZERO;
for (ActivityVo act : actMap.get(key)) {
totalPrice = totalPrice.add(act.getItemPrice());
count += act.getItemNum();
sum += act.getItemNum();
activity = act.getActivity();
}
activityVo.setActivity(activity);
activityVo.setActivityId(key);
activityVo.setItemNum(count);
activityVo.setItemPrice(totalPrice);
actlist.add(activityVo);
}
}
actlist.forEach(act -> {
while (act.getActivityId() == null) {
continue;
}
if ("1".equals(act.getActivity().getUseType())) {
reduceAmount = caculateActFee(false, false, act.getActivity(), act.getItemPrice(), null);
System.out.println("减免金额:" + reduceAmount);
} else if ("2".equals(act.getActivity().getUseType())) {
rate = caculateActFee(false, true, act.getActivity(), act.getItemPrice(), null);
System.out.println("折扣比例:" + rate);
itemsPrice = rate.multiply(itemsPrice);
} else if ("3".equals(act.getActivity().getUseType())) {
rate = caculateActFee(true, true, act.getActivity(), act.getItemPrice(), act.getItemNum());
System.out.println("购买件数:" + act.getItemNum());
System.out.println("折扣比例:" + rate);
itemsPrice = rate.multiply(itemsPrice);
}
});
}*/
totalPrice
=
itemsPrice
.
add
(
fee
).
add
(
tax
).
add
(
expressCost
).
subtract
(
reduceAmount
);
totalPrice
=
itemsPrice
.
add
(
fee
).
add
(
tax
).
add
(
expressCost
).
subtract
(
reduceAmount
);
countRealityPay
();
countRealityPay
();
...
@@ -893,4 +948,63 @@ public class TbCfOrder {
...
@@ -893,4 +948,63 @@ public class TbCfOrder {
public
String
getRemarkInfo
()
{
public
String
getRemarkInfo
()
{
return
remarkInfo
;
return
remarkInfo
;
}
}
public
Activity
getItemActivity
(
ActivityRepository
activityRepository
,
TbCfStationItemRepository
itemRepository
,
String
itemId
)
throws
ParseException
{
Activity
activity
=
null
;
//
//全场活动
if
(
activityRepository
.
existsByUseType
(
1
))
{
List
<
Activity
>
fullList
=
activityRepository
.
findAllByUseType
(
1
);
activity
=
fullList
.
get
(
0
);
}
//商品分类活动
if
(
activityRepository
.
existsByUseType
(
2
))
{
Optional
<
TbCfStationItem
>
byId
=
itemRepository
.
findById
(
itemId
);
if
(
byId
.
isPresent
())
{
TbCfStationItem
item
=
byId
.
get
();
String
category1
=
item
.
getItemCategory
();
String
category2
=
item
.
getItemCategorytwo
();
String
category3
=
item
.
getItemDescritionId
();
String
con2
=
category1
+
","
+
category2
;
String
con3
=
category1
+
","
+
category2
+
","
+
category3
;
List
<
Activity
>
activityList
=
activityRepository
.
findAllByUseType
(
2
);
List
<
Activity
>
actList
=
new
ArrayList
<>();
for
(
Activity
act2
:
activityList
)
{
if
(
category1
.
equals
(
act2
.
getCategoryId
()))
{
act2
.
setOrder
(
3
);
actList
.
add
(
act2
);
}
if
(
con2
.
equals
(
act2
.
getCategoryId
()))
{
act2
.
setOrder
(
2
);
actList
.
add
(
act2
);
}
if
(
con3
.
equals
(
act2
.
getCategoryId
()))
{
act2
.
setOrder
(
1
);
actList
.
add
(
act2
);
}
}
Collections
.
sort
(
actList
,
Comparator
.
comparing
(
Activity:
:
getOrder
));
if
(
actList
.
size
()
>
0
&&
actList
!=
null
)
activity
=
actList
.
get
(
0
);
}
}
//特定商品
if
(
activityRepository
.
existsByUseType
(
3
))
{
List
<
Activity
>
list
=
activityRepository
.
findAllByUseType
(
3
);
for
(
Activity
act3
:
list
)
{
String
[]
itemIdArr
=
act3
.
getItemIds
().
split
(
","
);
List
<
String
>
idList
=
Arrays
.
asList
(
itemIdArr
);
if
(
idList
.
contains
(
itemId
))
activity
=
act3
;
break
;
}
}
return
activity
;
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论