Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
Z
zion
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
zion
Commits
e60c245d
提交
e60c245d
authored
11月 21, 2019
作者:
zgy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改bug
上级
2318bb9c
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
194 行增加
和
137 行删除
+194
-137
KeyConstant.java
...ava/com/diaoyun/zion/chinafrica/constant/KeyConstant.java
+2
-0
LoginController.java
...m/diaoyun/zion/chinafrica/controller/LoginController.java
+12
-12
ShopifyController.java
...diaoyun/zion/chinafrica/controller/ShopifyController.java
+13
-0
TbCfOrderController.java
...aoyun/zion/chinafrica/controller/TbCfOrderController.java
+16
-15
ShopifyService.java
...a/com/diaoyun/zion/chinafrica/service/ShopifyService.java
+1
-0
TbCfOrderService.java
...com/diaoyun/zion/chinafrica/service/TbCfOrderService.java
+1
-1
ShopifyServiceImpl.java
...oyun/zion/chinafrica/service/impl/ShopifyServiceImpl.java
+48
-14
TbCfOrderServiceImpl.java
...un/zion/chinafrica/service/impl/TbCfOrderServiceImpl.java
+33
-28
JwtTokenProvider.java
...va/com/diaoyun/zion/master/security/JwtTokenProvider.java
+64
-64
PayTest.java
src/test/java/com/diaoyun/zion/PayTest.java
+4
-3
没有找到文件。
src/main/java/com/diaoyun/zion/chinafrica/constant/KeyConstant.java
浏览文件 @
e60c245d
...
...
@@ -36,4 +36,6 @@ public class KeyConstant {
public
final
static
String
SHOPIFY_ITEM
=
"shopify_item"
;
//商品类型
public
final
static
String
SHOPIFY_TYPE
=
"shopify_item"
;
//所有商品
public
final
static
String
SHOPIFY_ITEMS_ALL
=
"shopify_item_all"
;
}
src/main/java/com/diaoyun/zion/chinafrica/controller/LoginController.java
浏览文件 @
e60c245d
...
...
@@ -45,15 +45,15 @@ public class LoginController extends BaseController {
@ApiOperation
(
value
=
"注册并登录"
)
@PostMapping
(
value
=
"/registerByPhone"
)
public
Result
<
TbCfUserInfoVo
>
registerByPhone
(
@ApiParam
(
"用户信息"
)
@RequestBody
TbCfUserInfoVo
tbCfUserInfoVo
,
@ApiParam
(
value
=
"验证码"
)
@RequestParam
(
"code"
)
String
code
)
throws
ParseException
{
return
tbCfUserInfoService
.
registerByPhone
(
tbCfUserInfoVo
,
code
);
public
Result
<
TbCfUserInfoVo
>
registerByPhone
(
@ApiParam
(
"用户信息"
)
@RequestBody
TbCfUserInfoVo
tbCfUserInfoVo
,
@ApiParam
(
value
=
"验证码"
)
@RequestParam
(
"code"
)
String
code
)
throws
ParseException
{
return
tbCfUserInfoService
.
registerByPhone
(
tbCfUserInfoVo
,
code
);
}
@ApiOperation
(
"登录"
)
@PostMapping
public
Result
<
TbCfUserInfoVo
>
login
(
@ApiParam
(
value
=
"登录名"
)
String
account
,
@ApiParam
(
value
=
"密码"
)
String
password
)
{
return
tbCfUserInfoService
.
login
(
getIpAddr
(
request
),
account
,
password
);
public
Result
<
TbCfUserInfoVo
>
login
(
@ApiParam
(
value
=
"登录名"
)
@ValidateParam
({
Validator
.
NOT_BLANK
})
String
account
,
@ApiParam
(
value
=
"密码"
)
@ValidateParam
({
Validator
.
NOT_BLANK
})
String
password
)
{
return
tbCfUserInfoService
.
login
(
getIpAddr
(
request
),
account
,
password
);
}
@ApiOperation
(
"使用token登录"
)
...
...
@@ -65,12 +65,12 @@ public class LoginController extends BaseController {
@ApiOperation
(
"使用手机号登录"
)
@GetMapping
(
"/phone"
)
public
Result
<
TbCfUserInfoVo
>
loginByPhone
(
@ApiParam
(
value
=
"手机号"
)
@RequestParam
(
"phone"
)
String
phone
,
@ApiParam
(
value
=
"验证码"
)
@RequestParam
(
"code"
)
String
code
){
return
tbCfUserInfoService
.
loginByPhone
(
getIpAddr
(
request
),
phone
,
code
);
@ApiParam
(
value
=
"验证码"
)
@RequestParam
(
"code"
)
String
code
)
{
return
tbCfUserInfoService
.
loginByPhone
(
getIpAddr
(
request
),
phone
,
code
);
}
/**
* 获取短信验证码
*
*/
@ApiOperation
(
value
=
"获取短信验证码"
)
@GetMapping
(
value
=
"/register/identifyCode/{phone}"
)
...
...
@@ -86,6 +86,6 @@ public class LoginController extends BaseController {
public
Result
<
TbCfUserInfoVo
>
loginByThirdParty
(
@ApiParam
(
"第三方账号"
)
@RequestParam
(
required
=
false
)
String
amount
,
@ApiParam
(
"用户昵称 url编码"
)
@RequestParam
(
required
=
false
)
String
nick
,
@ApiParam
(
"账号类型"
)
@RequestParam
(
required
=
false
)
String
userType
)
throws
UnsupportedEncodingException
{
return
tbCfUserInfoService
.
loginByThirdParty
(
getIpAddr
(
request
),
amount
,
nick
,
userType
);
return
tbCfUserInfoService
.
loginByThirdParty
(
getIpAddr
(
request
),
amount
,
nick
,
userType
);
}
}
src/main/java/com/diaoyun/zion/chinafrica/controller/ShopifyController.java
浏览文件 @
e60c245d
...
...
@@ -69,6 +69,19 @@ public class ShopifyController {
return
shopifyService
.
queryProductsDetails
(
product_id
);
}
/**
* 查询所有商品
*
* @param product_id 商品ID
* @return
*/
@ApiOperation
(
value
=
"查询所有商品"
)
@GetMapping
(
"/queryallproducts"
)
public
Result
queryAllProducts
(
@ApiParam
(
"商品ID"
)
@RequestParam
(
value
=
"product_id"
,
required
=
false
)
String
product_id
)
{
return
shopifyService
.
queryAllProducts
(
product_id
);
}
/**
* 查询商品最新一条评论
*
...
...
src/main/java/com/diaoyun/zion/chinafrica/controller/TbCfOrderController.java
浏览文件 @
e60c245d
...
...
@@ -31,15 +31,15 @@ public class TbCfOrderController {
@ApiOperation
(
"用户结算,返回订单"
)
@GetMapping
(
"/settle"
)
public
Result
<
TbCfOrderVo
>
settleAccount
(
@ApiParam
(
"发放ID"
)
@RequestParam
(
value
=
"iss_coupon_id"
,
required
=
false
)
String
iss_coupon_id
)
throws
IOException
,
URISyntaxException
,
ExecutionException
,
InterruptedException
,
TimeoutException
{
public
Result
<
TbCfOrderVo
>
settleAccount
(
@ApiParam
(
"发放ID"
)
@RequestParam
(
value
=
"iss_coupon_id"
,
required
=
false
)
String
iss_coupon_id
)
throws
IOException
,
URISyntaxException
,
ExecutionException
,
InterruptedException
,
TimeoutException
{
return
tbCfOrderService
.
settleAccount
(
iss_coupon_id
);
}
@ApiOperation
(
"用户确定下单"
)
@PostMapping
(
"/place"
)
public
Result
placeOrder
(
@ApiParam
(
"订单详情"
)
@RequestBody
TbCfOrderVo
tbCfOrderVo
,
@ApiParam
(
"发放ID"
)
@RequestParam
(
value
=
"iss_coupon_id"
,
required
=
false
)
String
iss_coupon_id
)
throws
IOException
,
URISyntaxException
,
ExecutionException
,
InterruptedException
,
TimeoutException
{
System
.
out
.
println
(
"发放Id"
+
iss_coupon_id
);
return
tbCfOrderService
.
placeOrder
(
tbCfOrderVo
,
iss_coupon_id
);
public
Result
placeOrder
(
@ApiParam
(
"订单详情"
)
@RequestBody
TbCfOrderVo
tbCfOrderVo
,
@ApiParam
(
"发放ID"
)
@RequestParam
(
value
=
"iss_coupon_id"
,
required
=
false
)
String
iss_coupon_id
)
throws
IOException
,
URISyntaxException
,
ExecutionException
,
InterruptedException
,
TimeoutException
{
System
.
out
.
println
(
"发放Id"
+
iss_coupon_id
);
return
tbCfOrderService
.
placeOrder
(
tbCfOrderVo
,
iss_coupon_id
);
}
/**
...
...
@@ -48,16 +48,17 @@ public class TbCfOrderController {
*/
@ApiOperation
(
"获取用户订单 默认10条"
)
@GetMapping
public
Result
<
PageInfo
>
getUserOrderList
(
@ApiParam
(
value
=
"页数"
)
@RequestParam
(
required
=
false
)
Integer
pageNum
,
@ApiParam
(
value
=
"每页大小"
)
@RequestParam
(
required
=
false
)
Integer
pageSize
,
@ApiParam
(
value
=
"订单状态"
)
@RequestParam
(
required
=
false
)
Integer
orderStatus
)
{
public
Result
<
PageInfo
>
getUserOrderList
(
@ApiParam
(
value
=
"页数"
)
@RequestParam
(
value
=
"pageNum"
,
required
=
false
)
Integer
pageNum
,
@ApiParam
(
value
=
"每页大小"
)
@RequestParam
(
value
=
"pageSize"
,
required
=
false
)
Integer
pageSize
,
@ApiParam
(
value
=
"订单状态"
)
@RequestParam
(
value
=
"orderStatus"
,
required
=
false
)
Integer
orderStatus
,
@ApiParam
(
value
=
"订单状态"
)
@RequestParam
(
value
=
"userId"
)
String
userId
)
{
if
(
pageNum
==
null
)
{
pageNum
=
1
;
}
if
(
pageSize
==
null
)
{
pageSize
=
10
;
}
return
tbCfOrderService
.
getUserOrderList
(
pageNum
,
pageSize
,
orderStatus
);
return
tbCfOrderService
.
getUserOrderList
(
pageNum
,
pageSize
,
orderStatus
,
userId
);
}
@ApiOperation
(
"获取stripe公钥"
)
...
...
@@ -68,13 +69,13 @@ public class TbCfOrderController {
@ApiOperation
(
"发起订单支付"
)
@PostMapping
(
"/pay/{orderId}/{token}"
)
public
Result
payForOrder
(
@ApiParam
(
"订单id"
)
@PathVariable
(
"orderId"
)
String
orderId
,
@ApiParam
(
"支付token"
)
@PathVariable
(
"token"
)
String
token
)
{
return
tbCfOrderService
.
payForOrder
(
orderId
,
token
);
public
Result
payForOrder
(
@ApiParam
(
"订单id"
)
@PathVariable
(
"orderId"
)
String
orderId
,
@ApiParam
(
"支付token"
)
@PathVariable
(
"token"
)
String
token
)
{
return
tbCfOrderService
.
payForOrder
(
orderId
,
token
);
}
@ApiOperation
(
"根据订单id,查询物流详情"
)
@GetMapping
(
"/express/{orderId}"
)
public
Result
queryOrderExpressInfo
(
@ApiParam
(
"订单id"
)
@PathVariable
String
orderId
)
throws
IOException
{
public
Result
queryOrderExpressInfo
(
@ApiParam
(
"订单id"
)
@PathVariable
String
orderId
)
throws
IOException
{
return
tbCfOrderService
.
queryOrderExpressInfo
(
orderId
);
}
...
...
@@ -88,8 +89,8 @@ public class TbCfOrderController {
* 根据订单号获取详细订单数据
*/
@ApiOperation
(
value
=
"根据订单号获取详细订单数据"
)
@GetMapping
(
value
=
"/detail/{orderId}"
)
public
Result
getOrderDetail
(
@PathVariable
(
"orderId"
)
String
orderId
)
{
@GetMapping
(
value
=
"/detail/{orderId}"
)
public
Result
getOrderDetail
(
@PathVariable
(
"orderId"
)
String
orderId
)
{
return
tbCfOrderService
.
getOrderDetail
(
orderId
);
}
}
src/main/java/com/diaoyun/zion/chinafrica/service/ShopifyService.java
浏览文件 @
e60c245d
...
...
@@ -14,4 +14,5 @@ public interface ShopifyService {
public
Result
queryShopifyProducts
();
public
Result
queryProductsByType
(
String
product_type
,
String
product_id
);
public
Result
queryProductsDetails
(
String
product_id
);
public
Result
queryAllProducts
(
String
product_id
);
}
src/main/java/com/diaoyun/zion/chinafrica/service/TbCfOrderService.java
浏览文件 @
e60c245d
...
...
@@ -95,7 +95,7 @@ public interface TbCfOrderService {
* @param orderStatus 订单状态 OrderStatusEnum
* @return
*/
Result
getUserOrderList
(
Integer
pageNum
,
Integer
pageSize
,
Integer
orderStatus
);
Result
getUserOrderList
(
Integer
pageNum
,
Integer
pageSize
,
Integer
orderStatus
,
String
userId
);
/**
* 取消订单
...
...
src/main/java/com/diaoyun/zion/chinafrica/service/impl/ShopifyServiceImpl.java
浏览文件 @
e60c245d
...
...
@@ -15,10 +15,7 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
/**
...
...
@@ -29,6 +26,7 @@ import java.util.Map;
@Service
(
"shopifyService"
)
public
class
ShopifyServiceImpl
implements
ShopifyService
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ShopifyServiceImpl
.
class
);
@Resource
private
RedisCache
<
Object
>
redisCache
;
...
...
@@ -39,26 +37,28 @@ public class ShopifyServiceImpl implements ShopifyService {
*/
@Override
public
Result
queryShopifyProducts
()
{
List
type
=
Arrays
.
asList
(
"Christmas"
,
"Men"
,
"Women"
,
"Face"
,
"virgin hair"
,
"Afri Home"
,
"Children"
);
Result
result
=
new
Result
();
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
List
<
String
>
list
=
new
ArrayList
();
try
{
List
products
=
(
List
)
redisCache
.
get
(
KeyConstant
.
SHOPIFY_ITEMS
);
if
(
products
!=
null
)
{
if
(
products
!=
null
&&
products
.
size
()
==
type
.
size
()
)
{
JSONArray
jsonArray
=
JSONArray
.
fromObject
(
products
);
result
.
setData
(
jsonArray
);
return
result
;
}
List
type
=
(
List
)
redisCache
.
get
(
KeyConstant
.
SHOPIFY_TYPE
);
if
(
type
==
null
)
{
type
=
getProductType
();
}
// List type = (List) redisCache.get(KeyConstant.SHOPIFY_TYPE);
// if (type == null) {
// type = getProductType();
// }
for
(
int
i
=
0
;
i
<
type
.
size
();
i
++)
{
params
.
put
(
"product_type"
,
type
.
get
(
i
));
params
.
put
(
"limit"
,
ShopifyConstant
.
SHOPIFY_LIMIT
);
String
data
=
HttpClientUtil
.
createConnection
(
ShopifyConstant
.
productTypeUrl
(),
params
,
"UTF-8"
);
list
.
add
(
data
);
redisCache
.
set
(
KeyConstant
.
SHOPIFY_ITEMS
,
list
);
redisCache
.
set
(
KeyConstant
.
SHOPIFY_ITEMS
,
list
,
86400
);
}
System
.
out
.
println
(
list
);
JSONArray
jsonArr
=
JSONArray
.
fromObject
(
list
);
...
...
@@ -80,7 +80,7 @@ public class ShopifyServiceImpl implements ShopifyService {
@Override
public
Result
queryProductsByType
(
String
product_type
,
String
product_id
)
{
Result
result
=
new
Result
();
String
typeProducts
=
(
String
)
redisCache
.
get
(
KeyConstant
.
SHOPIFY_TYPE_ITEMS
+
product_id
);
String
typeProducts
=
(
String
)
redisCache
.
get
(
KeyConstant
.
SHOPIFY_TYPE_ITEMS
+
product_
type
+
product_
id
);
if
(
typeProducts
!=
null
)
{
JSONObject
object
=
JSONObject
.
fromObject
(
typeProducts
);
result
.
setData
(
object
);
...
...
@@ -88,13 +88,13 @@ public class ShopifyServiceImpl implements ShopifyService {
}
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"product_type"
,
product_type
);
params
.
put
(
"limit"
,
ShopifyConstant
.
SHOPIFY_PAGE_SIZE
);
params
.
put
(
"limit"
,
/*ShopifyConstant.SHOPIFY_PAGE_SIZE*/
"250"
);
params
.
put
(
"since_id"
,
product_id
);
try
{
String
data
=
HttpClientUtil
.
createConnection
(
ShopifyConstant
.
productTypeUrl
(),
params
,
"UTF-8"
);
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
data
);
result
.
setData
(
jsonObject
);
redisCache
.
set
(
KeyConstant
.
SHOPIFY_TYPE_ITEMS
+
product_id
,
data
);
//redisCache.set(KeyConstant.SHOPIFY_TYPE_ITEMS + product_type + product_id, data, 86400
);
}
catch
(
IOException
e
)
{
result
.
setCode
(
ResultCodeEnum
.
QUERY_ERROR
.
getCode
()).
setMessage
(
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
(),
e
);
...
...
@@ -122,7 +122,7 @@ public class ShopifyServiceImpl implements ShopifyService {
params
.
put
(
"ids"
,
product_id
);
String
data
=
HttpClientUtil
.
createConnection
(
ShopifyConstant
.
productTypeUrl
(),
params
,
"UTF-8"
);
jsonProduct
=
JSONObject
.
fromObject
(
data
);
redisCache
.
set
(
KeyConstant
.
SHOPIFY_ITEM
+
product_id
,
data
);
redisCache
.
set
(
KeyConstant
.
SHOPIFY_ITEM
+
product_id
,
data
,
86400
);
}
result
.
setData
(
jsonProduct
);
}
catch
(
IOException
e
)
{
...
...
@@ -133,6 +133,38 @@ public class ShopifyServiceImpl implements ShopifyService {
return
result
;
}
/**
* 查询所有商品
*
* @param product_id
* @return
*/
public
Result
queryAllProducts
(
String
product_id
)
{
Result
result
=
new
Result
();
try
{
JSONObject
jsonObject
=
null
;
String
allProducts
=
(
String
)
redisCache
.
get
(
KeyConstant
.
SHOPIFY_ITEMS_ALL
+
product_id
);
if
(
allProducts
!=
null
)
{
jsonObject
=
JSONObject
.
fromObject
(
allProducts
);
result
.
setData
(
jsonObject
);
return
result
;
}
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"limit"
,
ShopifyConstant
.
SHOPIFY_PAGE_SIZE
);
params
.
put
(
"since_id"
,
product_id
);
String
data
=
HttpClientUtil
.
createConnection
(
ShopifyConstant
.
productTypeUrl
(),
params
,
"UTF-8"
);
redisCache
.
set
(
KeyConstant
.
SHOPIFY_ITEMS_ALL
+
product_id
,
data
);
jsonObject
=
JSONObject
.
fromObject
(
data
);
result
.
setData
(
jsonObject
);
}
catch
(
Exception
e
)
{
result
.
setCode
(
ResultCodeEnum
.
QUERY_ERROR
.
getCode
()).
setMessage
(
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
(),
e
);
return
result
;
}
return
result
;
}
/**
* 查询所有商品分类
*
...
...
@@ -155,4 +187,6 @@ public class ShopifyServiceImpl implements ShopifyService {
redisCache
.
set
(
KeyConstant
.
SHOPIFY_TYPE
,
list
);
return
list
;
}
}
src/main/java/com/diaoyun/zion/chinafrica/service/impl/TbCfOrderServiceImpl.java
浏览文件 @
e60c245d
...
...
@@ -91,7 +91,8 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
@Autowired
private
SpiderService
spiderService
;
@Autowired
private
TbCfUserInfoDao
tbCfUserInfoDao
;
@Resource
private
RedisCache
<
Object
>
orderRedisCache
;
...
...
@@ -147,6 +148,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
/**
* 用户计算1
*
* @param iss_coupon_id
* @return
* @throws IOException
...
...
@@ -167,15 +169,15 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
result
.
setCode
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
()).
setMessage
(
"There are no items in the shopping cart"
);
}
else
{
//获取订单数据
TbCfOrderVo
tbCfOrder
=
getOrderData
(
tbCfUserInfoVo
,
tbCfCartItemDetailList
,
iss_coupon_id
);
TbCfOrderVo
tbCfOrder
=
getOrderData
(
tbCfUserInfoVo
,
tbCfCartItemDetailList
,
iss_coupon_id
);
result
.
setData
(
tbCfOrder
).
setMessage
(
"Order pending settlement"
);
}
return
result
;
}
@Override
public
Result
placeOrder
(
TbCfOrderVo
pageOrder
,
String
iss_coupon_id
)
throws
IOException
,
URISyntaxException
,
ExecutionException
,
InterruptedException
,
TimeoutException
{
System
.
out
.
println
(
iss_coupon_id
+
"发放ID"
);
public
Result
placeOrder
(
TbCfOrderVo
pageOrder
,
String
iss_coupon_id
)
throws
IOException
,
URISyntaxException
,
ExecutionException
,
InterruptedException
,
TimeoutException
{
System
.
out
.
println
(
iss_coupon_id
+
"发放ID"
);
Result
<
TbCfOrderVo
>
result
=
new
Result
<>();
//获取用户
String
token
=
jwtTokenProvider
.
resolveToken
(
request
);
...
...
@@ -187,7 +189,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
result
.
setCode
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
()).
setMessage
(
"There are no items in the shopping cart"
);
}
else
{
//获取下单的订单数据
TbCfOrderVo
definiteOrder
=
ensureOrder
(
tbCfUserInfoVo
,
pageOrder
,
tbCfCartItemDetailList
,
iss_coupon_id
);
TbCfOrderVo
definiteOrder
=
ensureOrder
(
tbCfUserInfoVo
,
pageOrder
,
tbCfCartItemDetailList
,
iss_coupon_id
);
//持久化订单数据
TbCfOrderEntity
tbCfOrderEntity
=
new
TbCfOrderEntity
();
BeanUtils
.
copyProperties
(
definiteOrder
,
tbCfOrderEntity
);
...
...
@@ -202,11 +204,12 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
}
@Override
public
Result
getUserOrderList
(
Integer
pageNum
,
Integer
pageSize
,
Integer
orderStatus
)
{
public
synchronized
Result
getUserOrderList
(
Integer
pageNum
,
Integer
pageSize
,
Integer
orderStatus
,
String
userId
)
{
Result
<
PageInfo
<
TbCfOrderVo
>>
result
=
new
Result
<>();
//获取用户
String
token
=
jwtTokenProvider
.
resolveToken
(
request
);
TbCfUserInfoVo
tbCfUserInfoVo
=
tokenManager
.
validate
(
token
);
// String token = jwtTokenProvider.resolveToken(request);
// TbCfUserInfoVo tbCfUserInfoVo = tokenManager.validate(token);
TbCfUserInfoEntity
tbCfUserInfoVo
=
tbCfUserInfoDao
.
queryObject
(
userId
);
//订单数据
List
<
TbCfOrderEntity
>
orderList
=
tbCfOrderDao
.
getUserOrderList
(
tbCfUserInfoVo
.
getUserId
(),
orderStatus
);
startPage
(
pageNum
,
pageSize
);
...
...
@@ -279,8 +282,8 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
//更改订单状态
changeOrderState
(
charge
.
getId
(),
tbCfOrderVo
);
//修改使用的优惠券的状态
if
(
tbCfOrderVo
.
getOrderStatus
()==
20
)
{
tbCfToiCouponDao
.
changeCoupnStatus
(
tbCfOrderVo
.
getUserId
(),
tbCfOrderVo
.
getCouponId
());
if
(
tbCfOrderVo
.
getOrderStatus
()
==
20
)
{
tbCfToiCouponDao
.
changeCoupnStatus
(
tbCfOrderVo
.
getUserId
(),
tbCfOrderVo
.
getCouponId
());
}
//生成流水记录
TbCfFinanceEntity
tbCfFinance
=
createFinance
(
charge
,
tbCfOrderVo
);
...
...
@@ -314,6 +317,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
/**
* 查询物流信息
*
* @param orderId
* @return
* @throws IOException
...
...
@@ -372,7 +376,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
public
Result
getOrderDetailThird
(
String
orderId
)
{
Result
<
OrderEntity
>
result
=
new
Result
<>();
OrderEntity
order
=
tbCfOrderDao
.
getOrder
(
orderId
);
OrderEntity
orderEntity
=
new
OrderEntity
();
OrderEntity
orderEntity
=
new
OrderEntity
();
orderEntity
.
setOrderId
(
order
.
getOrderId
());
orderEntity
.
setDeliveryPhone
(
order
.
getDeliveryPhone
());
orderEntity
.
setDeliveryName
(
order
.
getDeliveryName
());
...
...
@@ -384,7 +388,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
//返回的订单商品详情
List
<
ItemEntity
>
itemList
=
new
ArrayList
<>();
for
(
ItemEntity
item
:
items
)
{
ItemEntity
entity
=
new
ItemEntity
();
ItemEntity
entity
=
new
ItemEntity
();
entity
.
setItemNum
(
item
.
getItemNum
());
entity
.
setItemCategory
(
item
.
getItemCategory
());
entity
.
setItemPrice
(
item
.
getItemPrice
());
...
...
@@ -419,14 +423,14 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
Result
<
TbCfOrderVo
>
result
=
new
Result
<>();
TbCfOrderEntity
tbCfOrderEntity
=
tbCfOrderDao
.
queryObject
(
orderId
);
TbCfOrderVo
tbCfOrderVo
=
new
TbCfOrderVo
();
BeanUtils
.
copyProperties
(
tbCfOrderEntity
,
tbCfOrderVo
);
BeanUtils
.
copyProperties
(
tbCfOrderEntity
,
tbCfOrderVo
);
//获取订单内商品
List
<
TbCfItemDetailEntity
>
tbCfItemDetailList
=
tbCfOrderDao
.
getOrderItemList
(
orderId
);
//返回的订单商品详情
List
<
TbCfCartItemDetailVo
>
itemDetailVoList
=
new
ArrayList
<>();
for
(
TbCfItemDetailEntity
tbCfItemDetail
:
tbCfItemDetailList
)
{
TbCfCartItemDetailVo
tbCfCartItemDetailVo
=
new
TbCfCartItemDetailVo
();
BeanUtils
.
copyProperties
(
tbCfItemDetail
,
tbCfCartItemDetailVo
);
BeanUtils
.
copyProperties
(
tbCfItemDetail
,
tbCfCartItemDetailVo
);
itemDetailVoList
.
add
(
tbCfCartItemDetailVo
);
}
tbCfOrderVo
.
setItemDetailList
(
itemDetailVoList
);
...
...
@@ -543,7 +547,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
}
/**
* 增加已使用记录
// */
// */
// TbCfCouponUseEntity tbCfCouponUse = new TbCfCouponUseEntity();
// tbCfCouponUse.setUseId(IdUtil.createIdbyUUID());
// tbCfCouponUse.setCouponId(couponId);
...
...
@@ -597,7 +601,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
* @throws IOException
* @throws URISyntaxException
*/
private
TbCfOrderVo
ensureOrder
(
TbCfUserInfoVo
tbCfUserInfoVo
,
TbCfOrderVo
pageOrder
,
List
<
TbCfCartItemDetailVo
>
tbCfCartItemDetailList
,
String
iss_coupon_id
)
{
private
TbCfOrderVo
ensureOrder
(
TbCfUserInfoVo
tbCfUserInfoVo
,
TbCfOrderVo
pageOrder
,
List
<
TbCfCartItemDetailVo
>
tbCfCartItemDetailList
,
String
iss_coupon_id
)
{
TbCfOrderVo
definiteOrder
=
getGenericOrder
(
tbCfCartItemDetailList
);
/*//获取可以使用的优惠券,后续还有判断此订单是否可以使用
...
...
@@ -619,7 +623,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
}*/
//计算实际需要付款
countRealityPay
(
definiteOrder
,
iss_coupon_id
);
countRealityPay
(
definiteOrder
,
iss_coupon_id
);
//获取订单地址
String
deliveryAddressId
=
pageOrder
.
getDeliveryAddressId
();
Validator
.
NOT_BLANK
.
validate
(
"address"
,
deliveryAddressId
);
...
...
@@ -660,7 +664,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
BigDecimal
totalExpressCost
=
BigDecimal
.
ZERO
;
for
(
TbCfCartItemDetailVo
tbCfCartItemDetailVo
:
tbCfCartItemDetailList
)
{
BigDecimal
itemNum
=
BigDecimal
.
valueOf
(
tbCfCartItemDetailVo
.
getItemNum
());
BigDecimal
itemSourcePrice
=
tbCfCartItemDetailVo
.
getItemPrice
();
BigDecimal
itemSourcePrice
=
tbCfCartItemDetailVo
.
getItemPrice
();
itemsPrice
=
itemsPrice
.
add
(
itemSourcePrice
.
multiply
(
itemNum
));
//计算运费
BigDecimal
expressCost
=
getExpressTemplate
(
tbCfCartItemDetailVo
.
getItemCategory
());
...
...
@@ -715,6 +719,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
/**
* 用户计算价格2
*
* @param tbCfUserInfoVo
* @param tbCfCartItemDetailList
* @param iss_coupon_id
...
...
@@ -725,7 +730,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
* @throws InterruptedException
* @throws TimeoutException
*/
private
TbCfOrderVo
getOrderData
(
TbCfUserInfoVo
tbCfUserInfoVo
,
List
<
TbCfCartItemDetailVo
>
tbCfCartItemDetailList
,
String
iss_coupon_id
)
throws
IOException
,
URISyntaxException
,
ExecutionException
,
InterruptedException
,
TimeoutException
{
private
TbCfOrderVo
getOrderData
(
TbCfUserInfoVo
tbCfUserInfoVo
,
List
<
TbCfCartItemDetailVo
>
tbCfCartItemDetailList
,
String
iss_coupon_id
)
throws
IOException
,
URISyntaxException
,
ExecutionException
,
InterruptedException
,
TimeoutException
{
TbCfOrderVo
tbCfOrder
=
getGenericOrder
(
tbCfCartItemDetailList
);
/* //获取可以使用的优惠券,后续还有判断此订单是否可以使用
List<TbCfCouponEntity> tbCfCouponList = tbCfCouponDao.queryUserAvailableCoupon(tbCfUserInfoVo.getUserId(), new Date());
...
...
@@ -740,7 +745,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
}*/
//计算实际需要付款
countRealityPay
(
tbCfOrder
,
iss_coupon_id
);
countRealityPay
(
tbCfOrder
,
iss_coupon_id
);
tbCfOrder
.
setUserId
(
tbCfUserInfoVo
.
getUserId
());
tbCfOrder
.
setUserName
(
tbCfUserInfoVo
.
getNick
());
...
...
@@ -753,10 +758,10 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
*
* @param tbCfOrder
*/
private
void
countRealityPay
(
TbCfOrderVo
tbCfOrder
,
String
iss_coupon_id
)
{
if
(
iss_coupon_id
!=
null
)
{
private
void
countRealityPay
(
TbCfOrderVo
tbCfOrder
,
String
iss_coupon_id
)
{
if
(
iss_coupon_id
!=
null
)
{
TbCfCouponEntity
couponEntity
=
tbCfOrderDao
.
queryCouponPrice
(
iss_coupon_id
);
if
(
couponEntity
!=
null
)
{
if
(
couponEntity
!=
null
)
{
tbCfOrder
.
setCouponPrice
(
couponEntity
.
getDeductAmount
());
tbCfOrder
.
setCouponId
(
couponEntity
.
getCouponId
());
}
...
...
@@ -774,7 +779,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
tbCfOrder
.
setRealityPay
(
tbCfOrder
.
getTotalPrice
());
}
removeRedisCache
(
tbCfOrder
);
orderRedisCache
.
set
(
KeyConstant
.
ORDER_DET
+
tbCfOrder
.
getOrderId
(),
tbCfOrder
);
orderRedisCache
.
set
(
KeyConstant
.
ORDER_DET
+
tbCfOrder
.
getOrderId
(),
tbCfOrder
);
}
/**
...
...
src/main/java/com/diaoyun/zion/master/security/JwtTokenProvider.java
浏览文件 @
e60c245d
...
...
@@ -81,13 +81,13 @@ public class JwtTokenProvider {
public
boolean
validateToken
(
String
token
)
{
try
{
Jwts
.
parser
().
setSigningKey
(
secretKey
).
parseClaimsJws
(
token
);
TbCfUserInfoVo
loginUser
=
tokenManager
.
validate
(
token
);
if
(
loginUser
==
null
)
{
throw
new
ApplicationException
(
ResultCodeEnum
.
NEED_LOGIN
.
getCode
(),
"Expired or invalid JWT token"
);
TbCfUserInfoVo
loginUser
=
tokenManager
.
validate
(
token
);
if
(
loginUser
==
null
)
{
throw
new
ApplicationException
(
ResultCodeEnum
.
NEED_LOGIN
.
getCode
(),
"Expired or invalid JWT token"
);
}
return
true
;
}
catch
(
JwtException
|
IllegalArgumentException
e
)
{
throw
new
ApplicationException
(
ResultCodeEnum
.
NEED_LOGIN
.
getCode
(),
"Expired or invalid JWT token"
);
throw
new
ApplicationException
(
ResultCodeEnum
.
NEED_LOGIN
.
getCode
(),
"Expired or invalid JWT token"
);
}
}
...
...
src/test/java/com/diaoyun/zion/PayTest.java
浏览文件 @
e60c245d
...
...
@@ -42,6 +42,7 @@ public class PayTest {
}
}
System
.
out
.
println
(
list
);
}
@Test
...
...
@@ -84,9 +85,9 @@ public class PayTest {
}
@Test
public
void
test3
(){
Integer
count
=
0
;
while
(
count
<
4
)
{
public
void
test3
()
{
Integer
count
=
0
;
while
(
count
<
4
)
{
System
.
out
.
println
(
"helloworld!"
);
count
++;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论