Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
OSmall
/
linjiashop
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 275bb914
authored
Dec 21, 2020
by
王能兵
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'dev' into 'master'
Dev See merge request
!5
2 parents
11aac9af
47fea9b0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
63 deletions
doc/database-open-platform.sql
shop-core/src/main/java/com/glsx/shop/bean/entity/shop/PlatformUser.java
shop-core/src/main/java/com/glsx/shop/service/shop/OrderService.java
shop-mobile-api/src/main/java/com/glsx/shop/mobile/controller/AppLoginController.java
shop-mobile-api/src/main/java/com/glsx/shop/mobile/controller/OrderController.java
shop-mobile-api/src/main/java/com/glsx/shop/mobile/controller/PayController.java
shop-mobile-api/src/main/java/com/glsx/shop/service/WeixinPayService.java
doc/database-open-platform.sql
View file @
275bb91
...
...
@@ -69,7 +69,7 @@ CREATE TABLE `t_platform_user`
`last_login_time`
DATETIME
DEFAULT
NULL
COMMENT
'最后登录时间'
,
`status`
TINYINT
(
2
)
DEFAULT
1
COMMENT
'用户状态 0 注销 1 正常'
,
`app_account_id`
INT
(
11
)
DEFAULT
NULL
COMMENT
'APP 账户ID'
,
`tu_ya_id`
INT
(
11
)
DEFAULT
NULL
COMMENT
'涂鸦平台ID'
,
`tu_ya_id`
VARCHAR
(
50
)
DEFAULT
NULL
COMMENT
'涂鸦平台ID'
,
`create_time`
DATETIME
DEFAULT
NULL
COMMENT
'创建时间 注册时间'
,
`update_time`
DATETIME
DEFAULT
NULL
COMMENT
'更新时间'
,
`create_by`
INT
(
11
)
DEFAULT
NULL
COMMENT
'创建人'
,
...
...
shop-core/src/main/java/com/glsx/shop/bean/entity/shop/PlatformUser.java
View file @
275bb91
...
...
@@ -44,8 +44,8 @@ public class PlatformUser implements Serializable {
private
Integer
status
;
@Column
(
columnDefinition
=
"INT(11) COMMENT 'APP 账户ID'"
)
private
Integer
appAccountId
;
@Column
(
columnDefinition
=
"
INT(11
) COMMENT '涂鸦平台ID'"
)
private
Integer
tuYaId
;
@Column
(
columnDefinition
=
"
VARCHAR(50
) COMMENT '涂鸦平台ID'"
)
private
String
tuYaId
;
@Column
(
columnDefinition
=
"INT(11) COMMENT '创建人'"
)
private
Integer
createBy
;
@Column
(
columnDefinition
=
"INT(11) COMMENT '更新人'"
)
...
...
shop-core/src/main/java/com/glsx/shop/service/shop/OrderService.java
View file @
275bb91
package
com
.
glsx
.
shop
.
service
.
shop
;
import
java.util.Date
;
import
java.util.List
;
import
com.glsx.shop.bean.entity.shop.Order
;
import
com.glsx.shop.bean.entity.shop.OrderItem
;
import
com.glsx.shop.bean.entity.shop.OrderLog
;
...
...
@@ -20,6 +18,9 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
@Service
public
class
OrderService
extends
BaseService
<
Order
,
Long
,
OrderRepository
>
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
...
...
@@ -65,10 +66,8 @@ public class OrderService extends BaseService<Order, Long, OrderRepository> {
public
void
cancel
(
String
orderSn
)
{
Order
order
=
getByOrderSn
(
orderSn
);
order
.
setStatus
(
OrderEnum
.
OrderStatusEnum
.
CANCEL
.
getId
());
String
descript
=
"用户取消订单"
;
saveOrderLog
(
order
,
descript
);
saveOrderLog
(
order
,
"用户取消订单"
);
updateOrder
(
order
);
}
public
Order
getByOrderSn
(
String
orderSn
)
{
...
...
@@ -83,8 +82,7 @@ public class OrderService extends BaseService<Order, Long, OrderRepository> {
public
Order
confirmReceive
(
String
orderSn
)
{
Order
order
=
getByOrderSn
(
orderSn
);
order
.
setStatus
(
OrderEnum
.
OrderStatusEnum
.
FINISHED
.
getId
());
String
descript
=
"客户确认收货"
;
saveOrderLog
(
order
,
descript
);
saveOrderLog
(
order
,
"客户确认收货"
);
updateOrder
(
order
);
return
order
;
}
...
...
@@ -132,15 +130,12 @@ public class OrderService extends BaseService<Order, Long, OrderRepository> {
order
.
setRealPrice
(
order
.
getTotalPrice
());
order
.
setPayType
(
payType
);
updateOrder
(
order
);
String
descript
=
"用户付款成功"
;
saveOrderLog
(
order
,
descript
);
saveOrderLog
(
order
,
"用户付款成功"
);
}
public
void
send
(
Order
order
)
{
String
descript
=
"管理员("
+
JwtUtil
.
getUsername
()
+
")已发货"
;
updateOrder
(
order
);
saveOrderLog
(
order
,
descript
);
saveOrderLog
(
order
,
"管理员("
+
JwtUtil
.
getUsername
()
+
")已发货"
);
}
}
shop-mobile-api/src/main/java/com/glsx/shop/mobile/controller/AppLoginController.java
View file @
275bb91
...
...
@@ -13,6 +13,7 @@ import com.glsx.shop.security.UserService;
import
com.glsx.shop.service.shop.PlatformCustomerService
;
import
com.glsx.shop.service.shop.PlatformUserService
;
import
com.glsx.shop.utils.HttpUtils
;
import
com.glsx.shop.utils.MD5
;
import
com.glsx.shop.utils.StringUtil
;
import
com.glsx.shop.web.controller.BaseController
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -63,10 +64,12 @@ public class AppLoginController extends BaseController {
return
Rets
.
failure
(
ApplicationExceptionEnum
.
PARAM_ERROR
);
}
JwtUser
jwtUser
=
new
JwtUser
();
//JWT用户信息封装
Date
now
=
new
Date
();
Date
now
=
new
Date
();
PlatformUser
user
=
platformUserService
.
findByContactNumber
(
userDTO
.
getContactNumber
());
String
password
=
new
StringBuffer
(
userDTO
.
getContactNumber
())
.
append
(
userDTO
.
getChannel
()).
toString
();
String
tuYaId
=
null
;
if
(
user
!=
null
){
result
.
put
(
"tuYaId"
,
user
.
getTuYaId
());
jwtUser
.
setId
(
user
.
getId
());
jwtUser
.
setUserName
(
user
.
getNickname
());
BeanUtils
.
copyProperties
(
userDTO
,
user
);
...
...
@@ -76,6 +79,14 @@ public class AppLoginController extends BaseController {
user
.
setUpdateTime
(
now
);
user
.
setCustomerId
(
customer
.
getId
().
intValue
());
}
//防止注册时涂鸦平台服务异常
if
(
user
.
getTuYaId
()
==
null
){
tuYaId
=
this
.
syncUser
(
userDTO
.
getContactNumber
(),
userDTO
.
getNickname
(),
MD5
.
md5
(
password
,
userDTO
.
getChannel
()));
//同步用户到涂鸦
user
.
setTuYaId
(
tuYaId
);
}
else
{
tuYaId
=
user
.
getTuYaId
();
}
platformUserService
.
update
(
user
);
}
else
{
//用户首次注册
PlatformUser
pUser
=
new
PlatformUser
();
...
...
@@ -85,42 +96,44 @@ public class AppLoginController extends BaseController {
pUser
.
setCreateBy
(-
1
);
pUser
.
setStatus
(
1
);
//默认用户正常
pUser
.
setLastLoginTime
(
now
);
Integer
tuYaId
=
this
.
syncUser
(
userDTO
.
getContactNumber
());
//同步用户到涂鸦
tuYaId
=
this
.
syncUser
(
userDTO
.
getContactNumber
(),
userDTO
.
getNickname
(),
MD5
.
md5
(
password
,
userDTO
.
getChannel
()));
//同步用户到涂鸦
pUser
.
setTuYaId
(
tuYaId
);
PlatformUser
returnUser
=
platformUserService
.
insert
(
pUser
);
jwtUser
.
setId
(
returnUser
.
getId
());
result
.
put
(
"tuYaId"
,
tuYaId
);
jwtUser
.
setUserName
(
returnUser
.
getNickname
()
);
}
//JWT信息缓存
jwtUser
.
setPassword
(
userDTO
.
getChannel
());
String
token
=
userService
.
loginForToken
(
jwtUser
);
result
.
put
(
"tuYaId"
,
tuYaId
);
result
.
put
(
"token"
,
token
);
return
Rets
.
success
(
result
);
}
private
Integer
syncUser
(
String
mobile
){
private
String
syncUser
(
String
mobile
,
String
nickName
,
String
password
){
JSONObject
object
=
new
JSONObject
();
object
.
put
(
"schema"
,
"glsx"
);
object
.
put
(
"country_code"
,
"86"
);
object
.
put
(
"username"
,
mobile
);
object
.
put
(
"username_type"
,
"1"
);
// object.put("nick_name", "wnb"
);
// object.put("password", "dsadada"
);
object
.
put
(
"username_type"
,
1
);
object
.
put
(
"nick_name"
,
nickName
);
object
.
put
(
"password"
,
password
);
try
{
logger
.
info
(
"请求注册涂鸦平台接口地址:{}
"
,
syncUserUrl
);
logger
.
info
(
"请求注册涂鸦平台接口地址:{}
,参数:{}"
,
syncUserUrl
,
object
.
toJSONString
()
);
String
result
=
HttpUtils
.
postJson
(
syncUserUrl
,
object
.
toJSONString
());
logger
.
info
(
"注册涂鸦平台返回结果:{}"
,
result
);
if
(
StringUtils
.
isNotEmpty
(
result
))
{
JSONObject
json
=
JSON
.
parseObject
(
result
);
if
(
json
.
containsKey
(
"result"
))
{
JSONObject
jsonObject
=
json
.
getJSONObject
(
"result"
);
return
jsonObject
.
get
Integer
(
"uid"
);
return
jsonObject
.
get
String
(
"uid"
);
}
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"同步涂鸦平台失败:{}"
,
e
);
}
return
-
1
;
return
null
;
}
/**
...
...
shop-mobile-api/src/main/java/com/glsx/shop/mobile/controller/OrderController.java
View file @
275bb91
package
com
.
glsx
.
shop
.
mobile
.
controller
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.Map
;
import
com.glsx.shop.bean.constant.CfgKey
;
import
com.glsx.shop.bean.constant.factory.PageFactory
;
import
com.glsx.shop.bean.entity.shop.Address
;
...
...
@@ -30,11 +27,11 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.web.bind.annotation.
PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.
*
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author glsx
...
...
@@ -99,8 +96,7 @@ public class OrderController extends BaseController {
public
Object
save
(
@RequestParam
(
"idAddress"
)
Long
idAddress
,
@RequestParam
(
value
=
"message"
,
required
=
false
)
String
message
,
@RequestParam
(
value
=
"idCarts"
)
String
idCarts
)
{
@RequestParam
(
value
=
"idCarts"
)
String
idCarts
)
{
Long
idUser
=
getIdUser
();
List
<
SearchFilter
>
filters
=
Lists
.
newArrayList
(
...
...
@@ -108,7 +104,6 @@ public class OrderController extends BaseController {
SearchFilter
.
build
(
"id"
,
SearchFilter
.
Operator
.
IN
,
StringUtil
.
splitForLong
(
idCarts
,
","
))
);
List
<
Cart
>
cartList
=
cartService
.
queryAll
(
filters
);
Order
order
=
new
Order
();
order
.
setIdUser
(
idUser
);
Address
address
=
addressService
.
get
(
idAddress
);
...
...
@@ -153,16 +148,15 @@ public class OrderController extends BaseController {
@RequestMapping
(
value
=
"getExpressInfo/{orderSn}"
,
method
=
RequestMethod
.
GET
)
public
Object
getExpressInfo
(
@PathVariable
(
value
=
"orderSn"
)
String
orderSn
)
{
Order
order
=
orderService
.
getByOrderSn
(
orderSn
);
String
apiKd
niaoUseri
d
=
cfgService
.
getCfgValue
(
CfgKey
.
API_KDNIAO_USERID
);
if
(
StringUtil
.
isEmpty
(
apiKd
niaoUseri
d
))
{
String
apiKd
UserI
d
=
cfgService
.
getCfgValue
(
CfgKey
.
API_KDNIAO_USERID
);
if
(
StringUtil
.
isEmpty
(
apiKd
UserI
d
))
{
//该商城暂无配置物流查询服务
throw
new
ApplicationException
(
ApplicationExceptionEnum
.
SERVER_ERROR
);
}
KdniaoResponse
response
=
kdniaoService
.
realTimeQuery
(
order
.
getShippingSn
(),
order
.
getExpress
().
getCode
());
Map
data
=
Maps
.
newHashMap
(
"order"
,
order
,
"expressInfo"
,
response
);
KdniaoResponse
response
=
kdniaoService
.
realTimeQuery
(
order
.
getShippingSn
(),
order
.
getExpress
().
getCode
());
Map
data
=
Maps
.
newHashMap
(
"order"
,
order
,
"expressInfo"
,
response
);
return
Rets
.
success
(
data
);
}
}
shop-mobile-api/src/main/java/com/glsx/shop/mobile/controller/PayController.java
View file @
275bb91
...
...
@@ -11,11 +11,7 @@ import com.glsx.shop.service.shop.ShopUserService;
import
com.glsx.shop.utils.StringUtil
;
import
com.glsx.shop.web.controller.BaseController
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
/**
* @author glsx
...
...
@@ -56,6 +52,21 @@ public class PayController extends BaseController {
return
msg
;
}
@RequestMapping
(
value
=
"success/{orderSn}/{payId}"
,
method
=
RequestMethod
.
POST
)
public
Object
cancel
(
@PathVariable
(
"orderSn"
)
String
orderSn
,
@PathVariable
(
"payId"
)
String
payId
)
{
Order
order
=
orderService
.
getByOrderSn
(
orderSn
);
if
(
order
==
null
)
{
return
Rets
.
failure
(
"订单不存在sn = "
+
orderSn
);
}
if
(
order
.
hasPayed
())
{
// 检查这个订单是否已经处理过
return
Rets
.
success
(
"订单已经处理成功!"
);
}
order
.
setPayId
(
payId
);
orderService
.
paySuccess
(
order
,
OrderEnum
.
PayTypeEnum
.
UN_SEND
.
getKey
());
return
Rets
.
success
();
}
/**
* 查询支付结果
*
...
...
shop-mobile-api/src/main/java/com/glsx/shop/service/WeixinPayService.java
View file @
275bb91
package
com
.
glsx
.
shop
.
service
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse
;
import
com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult
;
import
com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult
;
...
...
@@ -22,6 +19,10 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
/**
* 微信支付
*
...
...
@@ -59,20 +60,16 @@ public class WeixinPayService {
public
String
resultNotify
()
{
String
xmlResult
=
null
;
try
{
HttpServletRequest
request
=
HttpUtil
.
getRequest
();
xmlResult
=
IOUtils
.
toString
(
request
.
getInputStream
(),
request
.
getCharacterEncoding
());
}
catch
(
IOException
e
)
{
logger
.
error
(
"解析微信支付结果通知异常"
,
e
);
return
WxPayNotifyResponse
.
fail
(
e
.
getMessage
());
}
WxPayOrderNotifyResult
result
=
null
;
try
{
result
=
wxPayService
.
parseOrderNotifyResult
(
xmlResult
);
if
(!
WxPayConstants
.
ResultCode
.
SUCCESS
.
equals
(
result
.
getResultCode
()))
{
logger
.
error
(
xmlResult
);
throw
new
WxPayException
(
"微信通知支付失败!"
);
...
...
@@ -82,31 +79,24 @@ public class WeixinPayService {
throw
new
WxPayException
(
"微信通知支付失败!"
);
}
}
catch
(
WxPayException
e
)
{
e
.
printStackTrace
();
return
WxPayNotifyResponse
.
fail
(
e
.
getMessage
());
}
logger
.
info
(
"处理腾讯支付平台的订单支付"
,
Json
.
toJson
(
result
));
String
orderSn
=
result
.
getOutTradeNo
();
String
payId
=
result
.
getTransactionId
();
Integer
totalFee
=
result
.
getTotalFee
();
Order
order
=
orderService
.
getByOrderSn
(
orderSn
);
if
(
order
==
null
)
{
return
WxPayNotifyResponse
.
fail
(
"订单不存在 sn="
+
orderSn
);
}
// 检查这个订单是否已经处理过
if
(
order
.
hasPayed
())
{
return
WxPayNotifyResponse
.
success
(
"订单已经处理成功!"
);
}
// 检查支付订单金额
if
(
totalFee
.
intValue
()
!=
order
.
getTotalPrice
().
intValue
())
{
return
WxPayNotifyResponse
.
fail
(
order
.
getOrderSn
()
+
" : 支付金额不符合 totalFee="
+
totalFee
);
}
order
.
setPayId
(
payId
);
orderService
.
paySuccess
(
order
,
OrderEnum
.
PayTypeEnum
.
UN_SEND
.
getKey
());
//todo 发送短信通知
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment