Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
soss
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hooloo
ms
soss
Commits
2ddadc35
Commit
2ddadc35
authored
Jun 10, 2022
by
张新旗
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复bug中
parent
c57c1a45
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
41 deletions
+53
-41
soss-admin/src/main/java/com/soss/web/controller/coffee/WeixinController.java
+14
-7
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
+37
-33
soss-system/src/main/java/com/soss/system/jiguang/impl/JiGuangPushServiceImpl.java
+1
-0
soss-system/src/main/java/com/soss/system/weixin/util/SendMessageUtils.java
+1
-1
No files found.
soss-admin/src/main/java/com/soss/web/controller/coffee/WeixinController.java
View file @
2ddadc35
...
...
@@ -3,14 +3,11 @@ package com.soss.web.controller.coffee;
import
com.alibaba.fastjson.JSONObject
;
import
com.soss.common.constant.Constants
;
import
com.soss.common.core.domain.AjaxResult
;
import
com.soss.common.utils.spring.SpringUtils
;
import
com.soss.framework.web.service.WeixinServiceImpl
;
import
com.soss.system.domain.Order
;
import
com.soss.system.mapper.OrderMapper
;
import
com.soss.system.service.impl.AppServiceImpl
;
import
com.soss.system.service.impl.OrderServiceImpl
;
import
com.soss.system.service.impl.OrderTakingServiceImpl
;
import
com.soss.system.weixin.util.SendMessageUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -40,15 +37,25 @@ public class WeixinController {
public
AjaxResult
login
(
@RequestBody
String
body
){
JSONObject
param
=
JSONObject
.
parseObject
(
body
);
String
code
=
param
.
getString
(
"code"
);
return
AjaxResult
.
success
(
weixinService
.
login
(
code
));
}
@PostMapping
(
"/decrypt"
)
public
AjaxResult
decrypt
(
@RequestBody
String
body
){
JSONObject
param
=
JSONObject
.
parseObject
(
body
);
String
encryptedData
=
param
.
getString
(
"encryptedData"
);
String
iv
=
param
.
getString
(
"iv"
);
String
source
=
param
.
getString
(
"source"
);
String
openId
=
param
.
getString
(
"openId"
);
String
sessionKey
=
param
.
getString
(
"session_key"
);
AjaxResult
ajax
=
AjaxResult
.
success
();
Map
<
String
,
String
>
map
=
weixinService
.
login
(
code
,
encryptedData
,
iv
,
source
);
ajax
.
put
(
Constants
.
TOKEN
,
map
.
get
(
"token"
));
ajax
.
put
(
"phoneNumber"
,
map
.
get
(
"phoneNumber"
));
ajax
.
put
(
"customerName"
,
map
.
get
(
"customerName"
));
Map
<
String
,
String
>
decrypt
=
weixinService
.
decrypt
(
encryptedData
,
iv
,
source
,
openId
,
sessionKey
);
ajax
.
put
(
Constants
.
TOKEN
,
decrypt
.
get
(
"token"
));
ajax
.
put
(
"phoneNumber"
,
decrypt
.
get
(
"phoneNumber"
));
ajax
.
put
(
"customerName"
,
decrypt
.
get
(
"customerName"
));
return
ajax
;
}
@PostMapping
(
"/refreshToken"
)
public
AjaxResult
getRefreshToken
(
@RequestBody
String
body
){
...
...
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
View file @
2ddadc35
...
...
@@ -159,40 +159,12 @@ public class WeixinServiceImpl {
}
public
Map
<
String
,
String
>
login
(
String
code
,
String
encryptedData
,
String
iv
,
String
source
)
{
try
{
public
String
login
(
String
code
)
{
String
sessionKeyOrOpenId
=
getSessionKeyOrOpenId
(
code
);
JSONObject
openInfo
=
JSONObject
.
parseObject
(
sessionKeyOrOpenId
);
String
cutomerId
=
openInfo
.
getString
(
"openid"
);
// Thread.sleep(1000);
String
encData
=
this
.
wxDecrypt
(
encryptedData
,
sessionKeyOrOpenId
,
iv
);
log
.
info
(
"当前用户的信息为:【{}】"
,
encData
);
Customer
customer
=
customerMapper
.
selectCustomerById
(
cutomerId
);
JSONObject
encDataInf
=
JSONObject
.
parseObject
(
encData
);
if
(
customer
==
null
){
customer
=
new
Customer
();
customer
.
setId
(
cutomerId
);
customer
.
setHeadSculpturePath
(
encDataInf
.
getString
(
"avatarUrl"
));
customer
.
setUserName
(
"小呼噜"
+
encDataInf
.
getString
(
"phoneNumber"
).
substring
(
encDataInf
.
getString
(
"phoneNumber"
).
length
()-
4
));
customer
.
setPhone
(
encDataInf
.
getString
(
"phoneNumber"
));
customer
.
setCreateTime
(
new
Date
());
if
(
StringUtils
.
isNotEmpty
(
source
)){
customer
.
setSoucre
(
source
);
}
customerMapper
.
insertCustomer
(
customer
);
}
return
sessionKeyOrOpenId
;
String
token
=
tokenService
.
createToken
(
transLoginUser
(
customer
));
Map
map
=
new
HashMap
();
map
.
put
(
"token"
,
token
);
map
.
put
(
"phoneNumber"
,
encDataInf
.
getString
(
"phoneNumber"
));
map
.
put
(
"customerName"
,
customer
.
getUserName
());
return
map
;
}
catch
(
Exception
e
){
log
.
error
(
"微信登录发生异常"
,
e
);
throw
new
ServiceException
(
"微信登录异常,请重新登录"
);
}
}
private
LoginUser
transLoginUser
(
Customer
customer
){
SysUser
user
=
new
SysUser
();
user
.
setUserName
(
customer
.
getUserName
());
...
...
@@ -206,8 +178,7 @@ public class WeixinServiceImpl {
public
String
wxDecrypt
(
String
encryptedData
,
String
json
,
String
vi
)
throws
Exception
{
// 开始解密
//:{"session_key":"G59Evf\/Em54X6WsFsrpA1g==","openid":"o2ttv5L2yufc4-VoSPhTyUnToY60"}
JSONObject
jsonObject
=
JSON
.
parseObject
(
json
);
String
sessionKey
=
(
String
)
jsonObject
.
get
(
"session_key"
);
String
sessionKey
=
json
;
byte
[]
encData
=
Base64
.
decode
(
encryptedData
);
byte
[]
iv
=
Base64
.
decode
(
vi
);
byte
[]
key
=
Base64
.
decode
(
sessionKey
);
...
...
@@ -671,4 +642,37 @@ public class WeixinServiceImpl {
}
public
Map
<
String
,
String
>
decrypt
(
String
encryptedData
,
String
iv
,
String
source
,
String
openId
,
String
sessionKey
)
{
try
{
String
cutomerId
=
openId
;
String
encData
=
this
.
wxDecrypt
(
encryptedData
,
sessionKey
,
iv
);
log
.
info
(
"当前用户的信息为:【{}】"
,
encData
);
Customer
customer
=
customerMapper
.
selectCustomerById
(
cutomerId
);
JSONObject
encDataInf
=
JSONObject
.
parseObject
(
encData
);
if
(
customer
==
null
){
customer
=
new
Customer
();
customer
.
setId
(
cutomerId
);
customer
.
setHeadSculpturePath
(
encDataInf
.
getString
(
"avatarUrl"
));
customer
.
setUserName
(
"小呼噜"
+
encDataInf
.
getString
(
"phoneNumber"
).
substring
(
encDataInf
.
getString
(
"phoneNumber"
).
length
()-
4
));
customer
.
setPhone
(
encDataInf
.
getString
(
"phoneNumber"
));
customer
.
setCreateTime
(
new
Date
());
if
(
StringUtils
.
isNotEmpty
(
source
)){
customer
.
setSoucre
(
source
);
}
customerMapper
.
insertCustomer
(
customer
);
}
String
token
=
tokenService
.
createToken
(
transLoginUser
(
customer
));
Map
map
=
new
HashMap
();
map
.
put
(
"token"
,
token
);
map
.
put
(
"phoneNumber"
,
encDataInf
.
getString
(
"phoneNumber"
));
map
.
put
(
"customerName"
,
customer
.
getUserName
());
return
map
;
}
catch
(
Exception
e
){
log
.
error
(
"微信登录发生异常"
,
e
);
throw
new
ServiceException
(
"微信登录异常,请重新登录"
);
}
}
}
soss-system/src/main/java/com/soss/system/jiguang/impl/JiGuangPushServiceImpl.java
View file @
2ddadc35
...
...
@@ -123,6 +123,7 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"orderId"
,
order
.
getId
());
data
.
put
(
"orderNo"
,
order
.
getOrderNo
());
data
.
put
(
"orderNumber"
,
order
.
getOrderNum
());
data
.
put
(
"state"
,
order
.
getState
());
jsonObject
.
put
(
"data"
,
data
);
PushBean
pushBean
=
new
PushBean
();
...
...
soss-system/src/main/java/com/soss/system/weixin/util/SendMessageUtils.java
View file @
2ddadc35
...
...
@@ -60,7 +60,7 @@ public class SendMessageUtils {
"\"thing2\": \"$.shop.name\","
+
"\"thing7\": \"$.shop.address\","
+
"\"time6\": \"now\","
+
"\"thing11\": \"您的订单
已经
制作完成了,现在可以去取餐啦!\""
+
"\"thing11\": \"您的订单制作完成了,现在可以去取餐啦!\""
+
"}"
+
"}]"
;
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment