Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
244f87dc
提交
244f87dc
authored
12月 30, 2020
作者:
wudepeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
批量添加购物车时间处理
上级
cafa215c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
27 行增加
和
6 行删除
+27
-6
pom.xml
pom.xml
+7
-0
CartController.java
...a/com/example/afrishop_v3/controllers/CartController.java
+18
-6
TbCfCartRecordR.java
.../java/com/example/afrishop_v3/models/TbCfCartRecordR.java
+2
-0
没有找到文件。
pom.xml
浏览文件 @
244f87dc
...
@@ -31,6 +31,13 @@
...
@@ -31,6 +31,13 @@
</dependencyManagement>
</dependencyManagement>
<dependencies>
<dependencies>
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
5.5.1
</version>
</dependency>
<dependency>
<dependency>
<groupId>
com.squareup.okhttp
</groupId>
<groupId>
com.squareup.okhttp
</groupId>
<artifactId>
okhttp
</artifactId>
<artifactId>
okhttp
</artifactId>
...
...
src/main/java/com/example/afrishop_v3/controllers/CartController.java
浏览文件 @
244f87dc
package
com
.
example
.
afrishop_v3
.
controllers
;
package
com
.
example
.
afrishop_v3
.
controllers
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
com.example.afrishop_v3.base.Result
;
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.ResultCodeEnum
;
import
com.example.afrishop_v3.enums.ResultCodeEnum
;
...
@@ -14,10 +16,8 @@ import com.example.afrishop_v3.util.ValidateUtils;
...
@@ -14,10 +16,8 @@ import com.example.afrishop_v3.util.ValidateUtils;
import
com.example.afrishop_v3.util.WordposHelper
;
import
com.example.afrishop_v3.util.WordposHelper
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
import
net.sf.json.JSONObject
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -26,6 +26,7 @@ import java.net.URISyntaxException;
...
@@ -26,6 +26,7 @@ import java.net.URISyntaxException;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.TimeoutException
;
import
java.util.concurrent.TimeoutException
;
import
java.util.concurrent.atomic.AtomicInteger
;
@RestController
@RestController
@RequestMapping
(
"/cart"
)
@RequestMapping
(
"/cart"
)
...
@@ -172,7 +173,8 @@ public class CartController extends Controller {
...
@@ -172,7 +173,8 @@ public class CartController extends Controller {
repository
.
save
(
cart
);
repository
.
save
(
cart
);
}
else
{
}
else
{
//detail.setItemNum(itemDetail.getItemNum());
//detail.setItemNum(itemDetail.getItemNum());
insertRecord
(
itemDetail
,
userId
,
flag
);
Integer
index
=
itemDetail
.
getIndex
();
insertRecord
(
itemDetail
,
userId
,
flag
,
index
);
}
}
if
(
user
.
hasFcm
())
{
if
(
user
.
hasFcm
())
{
...
@@ -186,7 +188,13 @@ public class CartController extends Controller {
...
@@ -186,7 +188,13 @@ public class CartController extends Controller {
@PostMapping
(
"/addCartList"
)
@PostMapping
(
"/addCartList"
)
public
Result
addCartList
(
@RequestBody
List
<
TbCfCartRecordR
>
cartList
)
{
public
Result
addCartList
(
@RequestBody
List
<
TbCfCartRecordR
>
cartList
)
{
cartList
.
forEach
(
cart
->
addToCart
(
cart
));
AtomicInteger
index
=
new
AtomicInteger
(
0
);
cartList
.
forEach
(
cart
->{
logger
.
info
(
cart
.
getItemId
()+
"的index:"
+
index
);
cart
.
setIndex
(
index
.
get
());
index
.
getAndIncrement
();
addToCart
(
cart
);
});
return
new
Result
();
return
new
Result
();
}
}
...
@@ -223,12 +231,16 @@ public class CartController extends Controller {
...
@@ -223,12 +231,16 @@ public class CartController extends Controller {
}
}
//Insert
//Insert
private
void
insertRecord
(
TbCfCartRecordR
itemDetail
,
String
userId
,
Integer
checkFlag
)
{
private
void
insertRecord
(
TbCfCartRecordR
itemDetail
,
String
userId
,
Integer
checkFlag
,
Integer
index
)
{
//日期处理:因为批量加入购物车时日期都是相同的,所以需要加入索引,确保每个时间不相同,才能按时间降序排列
String
now
=
DateUtil
.
now
();
if
(
index
==
null
)
index
=
0
;
DateTime
dateTime
=
DateUtil
.
offsetSecond
(
DateUtil
.
parse
(
now
),
index
);
itemDetail
.
setCartRecordId
(
uid
());
itemDetail
.
setCartRecordId
(
uid
());
itemDetail
.
setCheckFlag
(
checkFlag
);
itemDetail
.
setCheckFlag
(
checkFlag
);
itemDetail
.
setEnableFlag
(
StateConstant
.
VALID
);
itemDetail
.
setEnableFlag
(
StateConstant
.
VALID
);
itemDetail
.
setUserId
(
userId
);
itemDetail
.
setUserId
(
userId
);
itemDetail
.
setCreateTime
(
new
Date
()
);
itemDetail
.
setCreateTime
(
dateTime
);
repository
.
save
(
itemDetail
);
repository
.
save
(
itemDetail
);
}
}
...
...
src/main/java/com/example/afrishop_v3/models/TbCfCartRecordR.java
浏览文件 @
244f87dc
...
@@ -101,6 +101,8 @@ public class TbCfCartRecordR {
...
@@ -101,6 +101,8 @@ public class TbCfCartRecordR {
@Formula
(
value
=
"(SELECT sk.sku_price FROM tb_cf_item_skus sk WHERE sk.id=item_sku_id limit 1)"
)
@Formula
(
value
=
"(SELECT sk.sku_price FROM tb_cf_item_skus sk WHERE sk.id=item_sku_id limit 1)"
)
private
BigDecimal
skuPrice
;
private
BigDecimal
skuPrice
;
@Transient
private
Integer
index
;
public
TbCfCartRecordR
(){
public
TbCfCartRecordR
(){
this
.
shopName
=
"afrishop"
;
this
.
shopName
=
"afrishop"
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论