Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
c06b69ae
提交
c06b69ae
authored
12月 09, 2020
作者:
wudepeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
full activity
上级
472551bf
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
19 行增加
和
43 行删除
+19
-43
FlutterWaveController.java
...xample/afrishop_v3/controllers/FlutterWaveController.java
+1
-1
TbCfOrder.java
src/main/java/com/example/afrishop_v3/models/TbCfOrder.java
+16
-40
Condition.java
src/main/java/com/example/afrishop_v3/vo/Condition.java
+2
-2
没有找到文件。
src/main/java/com/example/afrishop_v3/controllers/FlutterWaveController.java
浏览文件 @
c06b69ae
...
...
@@ -81,7 +81,7 @@ public class FlutterWaveController extends Controller {
public
ResponseEntity
<
String
>
payForOrderByCard
(
@RequestParam
(
"orderId"
)
String
orderId
,
@RequestBody
FlutterWaveCard
flutterWaveCard
)
{
RaveConstant
.
PUBLIC_KEY
=
PUBLIC_KEY
;
RaveConstant
.
SECRET_KEY
=
SECRET_KEY
;
RaveConstant
.
ENVIRONMENT
=
Environment
.
STAGING
;
//or live
RaveConstant
.
ENVIRONMENT
=
Environment
.
LIVE
;
//or live
// Result result = new Result();
Optional
<
TbCfOrder
>
byId
=
repository
.
findById
(
orderId
);
...
...
src/main/java/com/example/afrishop_v3/models/TbCfOrder.java
浏览文件 @
c06b69ae
...
...
@@ -267,10 +267,10 @@ public class TbCfOrder {
itemOrderList
.
forEach
(
item
->
{
BigDecimal
itemPrice
=
item
.
getItemPriceTotal
();
TbCfExpressTemplate
template
=
item
.
getTemplate
();
if
(
template
!=
null
)
{
System
.
out
.
println
(
template
.
getHandlingFee
());
System
.
out
.
println
(
template
.
getTariff
());
}
//
if (template != null) {
//
System.out.println(template.getHandlingFee());
//
System.out.println(template.getTariff());
//
}
Optional
<
TbCfStationItem
>
optionalTbCfStationItem
=
itemRepository
.
findById
(
item
.
getItemId
());
...
...
@@ -290,6 +290,7 @@ public class TbCfOrder {
});
Map
<
String
,
List
<
TemplateVo
>>
map
=
templateList
.
stream
().
collect
(
Collectors
.
groupingBy
(
TemplateVo:
:
getTemplateId
));
//按模板分组计算商品价格
Integer
itemSum
=
0
;
List
<
TemplateVo
>
list
=
new
ArrayList
<>();
for
(
String
key
:
map
.
keySet
())
{
TemplateVo
templateVo
=
new
TemplateVo
();
...
...
@@ -299,6 +300,7 @@ public class TbCfOrder {
for
(
TemplateVo
template
:
map
.
get
(
key
))
{
totalPrice
=
totalPrice
.
add
(
template
.
getItemPrice
());
count
+=
template
.
getItemCount
();
itemSum
+=
template
.
getItemCount
();
_template
=
template
.
getTemplate
();
}
templateVo
.
setTemplateId
(
key
);
...
...
@@ -329,7 +331,7 @@ public class TbCfOrder {
}
/**
* 活动模块:活动类型 1:满减 2:满折 3:满件打折(type)
*
使用类型 1:全场 2:分类商品 3:特定商品(use_type)
* 使用类型 1:全场 2:分类商品 3:特定商品(use_type)
*/
boolean
act1
=
activityRepository
.
existsByUseType
(
1
);
if
(
act1
)
{
...
...
@@ -338,17 +340,16 @@ public class TbCfOrder {
Activity
activity
=
allAct
.
get
();
String
type
=
String
.
valueOf
(
activity
.
getType
());
if
(
"1"
.
equals
(
type
))
{
// reduceAmount = caculateFullReduction(activity, itemsPrice
);
caculateActFee
(
false
,
false
,
activity
,
itemsPrice
,
null
);
reduceAmount
=
caculateActFee
(
false
,
false
,
activity
,
itemsPrice
,
null
);
System
.
out
.
println
(
"减免金额:"
+
reduceAmount
);
}
else
if
(
"2"
.
equals
(
type
))
{
// BigDecimal discount = caculateFullReduction(activity, itemsPrice);
// BigDecimal rate = new BigDecimal(1).subtract(discount.divide(new BigDecimal(100)));
BigDecimal
rate
=
caculateActFee
(
false
,
true
,
activity
,
itemsPrice
,
null
);
System
.
out
.
println
(
"折扣比例:"
+
rate
);
itemsPrice
=
rate
.
multiply
(
itemsPrice
);
}
else
if
(
"3"
.
equals
(
type
))
{
// BigDecimal discount = caculateFullCount(activity, itemOrderList.size()
);
// BigDecimal rate = new BigDecimal(1).subtract(discount.divide(new BigDecimal(100))
);
BigDecimal
rate
=
caculateActFee
(
true
,
true
,
activity
,
itemsPrice
,
itemOrderList
.
size
()
);
BigDecimal
rate
=
caculateActFee
(
true
,
true
,
activity
,
itemsPrice
,
itemSum
);
System
.
out
.
println
(
"购买件数:"
+
itemSum
);
System
.
out
.
println
(
"折扣比例:"
+
rate
);
itemsPrice
=
rate
.
multiply
(
itemsPrice
);
}
}
...
...
@@ -363,11 +364,12 @@ public class TbCfOrder {
List
<
Condition
>
conList
=
JSONObject
.
parseArray
(
activity
.
getCondition
(),
Condition
.
class
);
Collections
.
sort
(
conList
,
Comparator
.
comparing
(
Condition:
:
getKey
));
System
.
out
.
println
(
conList
);
BigDecimal
result
=
new
BigDecimal
(
"0.0"
);
for
(
int
i
=
0
;
i
<
conList
.
size
();
i
++)
{
if
(
isCount
)
{
if
(
itemCount
>=
Integer
.
parseInt
(
conList
.
get
(
i
).
getKey
()
))
{
if
(
itemCount
>=
conList
.
get
(
i
).
getKey
(
))
{
result
=
new
BigDecimal
(
conList
.
get
(
i
).
getValue
());
}
}
else
{
...
...
@@ -383,33 +385,7 @@ public class TbCfOrder {
return
result
;
}
// //计算活动减免费用
// public BigDecimal caculateFullReduction(Activity activity, BigDecimal itemsPrice) {
//
// List<Condition> conList = JSONObject.parseArray(activity.getCondition(), Condition.class);
// Collections.sort(conList, Comparator.comparing(Condition::getKey));
// BigDecimal result = new BigDecimal("0.0");
// for (Condition con : conList) {
// if (itemsPrice.compareTo(new BigDecimal(con.getKey())) >= 0) {
// result = new BigDecimal(con.getValue());
// }
// }
//
// return result;
// }
//
// public BigDecimal caculateFullCount(Activity activity, Integer itemCount) {
// List<Condition> conList = JSONObject.parseArray(activity.getCondition(), Condition.class);
// Collections.sort(conList, Comparator.comparing(Condition::getKey));
// BigDecimal result = new BigDecimal("0.0");
//
// for (int i = 0; i < conList.size(); i++) {
// if (itemCount >= Integer.parseInt(conList.get(i).getKey())) {
// result = new BigDecimal(conList.get(i).getValue());
// }
// }
// return result;
// }
@Transient
private
TbCfCoupon
coupon
;
...
...
src/main/java/com/example/afrishop_v3/vo/Condition.java
浏览文件 @
c06b69ae
...
...
@@ -14,7 +14,7 @@ import java.math.BigDecimal;
@AllArgsConstructor
public
class
Condition
{
private
String
key
;
private
String
value
;
private
double
key
;
private
double
value
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论