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
ef275933
Commit
ef275933
authored
May 26, 2022
by
张新旗
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码永远在路上
parent
059709dc
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
97 additions
and
48 deletions
+97
-48
soss-admin/src/main/java/com/soss/web/controller/coffee/WeixinController.java
+13
-1
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
+36
-13
soss-system/src/main/java/com/soss/system/jiguang/impl/JiGuangPushServiceImpl.java
+1
-0
soss-system/src/main/java/com/soss/system/jiguang/impl/MyJiGuangPushServiceImpl.java
+2
-0
soss-system/src/main/java/com/soss/system/service/impl/AppServiceImpl.java
+13
-16
soss-system/src/main/java/com/soss/system/service/impl/GoodsServiceImpl.java
+13
-13
soss-system/src/main/java/com/soss/system/service/impl/MachineApiServiceImpl.java
+5
-3
soss-system/src/main/java/com/soss/system/service/impl/ShopRecommendServiceImpl.java
+1
-1
soss-system/src/main/java/com/soss/system/service/impl/ShopServiceImpl.java
+11
-0
soss-system/src/main/resources/mapper/system/MachineMapper.xml
+2
-1
No files found.
soss-admin/src/main/java/com/soss/web/controller/coffee/WeixinController.java
View file @
ef275933
...
...
@@ -39,11 +39,23 @@ public class WeixinController {
String
iv
=
param
.
getString
(
"iv"
);
String
source
=
param
.
getString
(
"source"
);
AjaxResult
ajax
=
AjaxResult
.
success
();
String
token
=
weixinService
.
login
(
code
,
encryptedData
,
iv
,
source
);
Map
<
String
,
String
>
map
=
weixinService
.
login
(
code
,
encryptedData
,
iv
,
source
);
ajax
.
put
(
Constants
.
TOKEN
,
map
.
get
(
"token"
));
ajax
.
put
(
"phoneNumber"
,
map
.
get
(
"phoneNumber"
));
return
ajax
;
}
@PostMapping
(
"/refreshToken"
)
public
AjaxResult
getRefreshToken
(
@RequestBody
String
body
){
JSONObject
param
=
JSONObject
.
parseObject
(
body
);
String
phoneNumber
=
param
.
getString
(
"phoneNumber"
);
String
token
=
weixinService
.
refresh
(
phoneNumber
);
AjaxResult
ajax
=
AjaxResult
.
success
();
ajax
.
put
(
Constants
.
TOKEN
,
token
);
return
ajax
;
}
/**
* 支付通知
* 微信支付通过支付通知接口将用户支付成功消息通知给商户
...
...
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
View file @
ef275933
...
...
@@ -127,6 +127,7 @@ public class WeixinServiceImpl {
String
url
=
"https://api.weixin.qq.com/sns/jscode2session?appid={0}&secret={1}&js_code={2}&grant_type=authorization_code"
;
String
replaceUrl
=
url
.
replace
(
"{0}"
,
appid
).
replace
(
"{1}"
,
secret
).
replace
(
"{2}"
,
code
);
String
res
=
restTemplate
.
getForObject
(
replaceUrl
,
String
.
class
);
log
.
info
(
"微信返回的信息为:【{}】"
,
res
);
return
res
;
}
@PostConstruct
...
...
@@ -147,11 +148,12 @@ public class WeixinServiceImpl {
}
public
String
login
(
String
code
,
String
encryptedData
,
String
iv
,
String
source
)
{
public
Map
<
String
,
String
>
login
(
String
code
,
String
encryptedData
,
String
iv
,
String
source
)
{
try
{
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
);
...
...
@@ -160,9 +162,8 @@ public class WeixinServiceImpl {
customer
=
new
Customer
();
customer
.
setId
(
cutomerId
);
customer
.
setHeadSculpturePath
(
encDataInf
.
getString
(
"avatarUrl"
));
customer
.
setUserName
(
encDataInf
.
getString
(
"nickName"
));
customer
.
setPhone
(
encDataInf
.
getString
(
"phoneNumber"
));
customer
.
setUserName
(
"小呼噜"
+
customer
.
getPhone
().
substring
(
customer
.
getPhone
().
length
()-
4
));
customer
.
setPhone
(
encDataInf
.
getString
(
"phoneNumber"
));
customer
.
setCreateTime
(
new
Date
());
if
(
StringUtils
.
isNotEmpty
(
source
)){
customer
.
setSoucre
(
source
);
...
...
@@ -170,23 +171,22 @@ public class WeixinServiceImpl {
customerMapper
.
insertCustomer
(
customer
);
}
return
tokenService
.
createToken
(
transLoginUser
(
customer
,
encData
));
String
token
=
tokenService
.
createToken
(
transLoginUser
(
customer
));
Map
map
=
new
HashMap
();
map
.
put
(
"token"
,
token
);
map
.
put
(
"phoneNumber"
,
encDataInf
.
getString
(
"phoneNumber"
));
return
map
;
}
catch
(
Exception
e
){
log
.
error
(
"微信登录发生异常"
,
e
);
throw
new
ServiceException
(
"微信登录异常,请重新登录"
);
}
}
private
LoginUser
transLoginUser
(
Customer
customer
,
String
encData
){
private
LoginUser
transLoginUser
(
Customer
customer
){
SysUser
user
=
new
SysUser
();
user
.
setUserName
(
customer
.
getUserName
());
LoginUser
loginUser
=
new
LoginUser
(
user
,
null
);
loginUser
.
setLoginTime
(
System
.
currentTimeMillis
());
loginUser
.
setOpenId
(
customer
.
getId
());
loginUser
.
setExt
(
encData
);
return
loginUser
;
}
...
...
@@ -456,9 +456,6 @@ public class WeixinServiceImpl {
orderOperationLogService
.
insertOrderOperationLog
(
"已付款"
,
order
.
getId
(),
"付款成功"
,
order
.
getUserName
(),
"付款"
);
machineApiService
.
updateOrder
(
order
);
//极光推送
jiGuangPushService
.
pushOrderState
(
order
);
}
}
finally
{
...
...
@@ -663,4 +660,30 @@ public class WeixinServiceImpl {
{
return
d
*
Math
.
PI
/
180.0
;
}
public
String
refresh
(
String
phoneNumber
)
{
Customer
customer
=
new
Customer
();
customer
.
setPhone
(
phoneNumber
);
List
<
Customer
>
customers
=
customerMapper
.
selectCustomerList
(
customer
);
if
(
customers
!=
null
&&!
customers
.
isEmpty
()){
Customer
customer1
=
customers
.
get
(
0
);
return
tokenService
.
createToken
(
transLoginUser
(
customer
));
}
throw
new
ServiceException
(
"该用户没有注册,请先注册"
);
}
public
String
getPhone
(
String
code
,
String
iv
,
String
encryptedData
)
{
try
{
String
sessionKeyOrOpenId
=
getSessionKeyOrOpenId
(
code
);
String
infoString
=
this
.
wxDecrypt
(
encryptedData
,
sessionKeyOrOpenId
,
iv
);
JSONObject
info
=
JSONObject
.
parseObject
(
infoString
);
return
info
.
getString
(
"phoneNumber"
);
}
catch
(
Exception
e
){
log
.
error
(
"获取手机号异常"
,
e
);
throw
new
ServiceException
(
"获取手机号异常"
);
}
}
}
soss-system/src/main/java/com/soss/system/jiguang/impl/JiGuangPushServiceImpl.java
View file @
ef275933
...
...
@@ -124,6 +124,7 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
data
.
put
(
"orderId"
,
order
.
getId
());
data
.
put
(
"orderNo"
,
order
.
getOrderNo
());
data
.
put
(
"state"
,
order
.
getState
());
jsonObject
.
put
(
"data"
,
data
);
PushBean
pushBean
=
new
PushBean
();
pushBean
.
setMessageCount
(
jsonObject
);
pushAndroid
(
pushBean
,
machine
.
getRegister
());
...
...
soss-system/src/main/java/com/soss/system/jiguang/impl/MyJiGuangPushServiceImpl.java
View file @
ef275933
...
...
@@ -9,6 +9,7 @@ import cn.jpush.api.push.model.Platform;
import
cn.jpush.api.push.model.PushPayload
;
import
cn.jpush.api.push.model.audience.Audience
;
import
cn.jpush.api.push.model.notification.Notification
;
import
com.alibaba.fastjson.JSONObject
;
import
com.soss.system.domain.vo.PushBean
;
import
com.soss.system.jiguang.MyJiGuangPushService
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -87,6 +88,7 @@ public class MyJiGuangPushServiceImpl implements MyJiGuangPushService {
public
boolean
pushAndroid
(
PushBean
pushBean
,
String
...
registids
){
Message
build
=
new
Message
.
Builder
().
setMsgContent
(
pushBean
.
getMessageCount
().
toJSONString
()).
build
();
log
.
info
(
"极光推送的内容为:【{}】::[{}]"
,
registids
[
0
],
JSONObject
.
toJSONString
(
build
));
return
sendPush
(
PushPayload
.
newBuilder
()
.
setPlatform
(
Platform
.
android
())
.
setAudience
(
Audience
.
registrationId
(
registids
))
...
...
soss-system/src/main/java/com/soss/system/service/impl/AppServiceImpl.java
View file @
ef275933
...
...
@@ -14,26 +14,23 @@ import java.util.stream.Collectors;
public
class
AppServiceImpl
{
@Autowired
private
ShopMapper
shopMapper
;
public
List
<
Shop
>
getShop
(
String
lng
,
String
lat
)
{
if
(
StringUtils
.
isEmpty
(
lng
)||
StringUtils
.
isEmpty
(
lat
)){
public
Shop
getShop
(
String
lng
,
String
lat
)
{
Shop
shop
=
new
Shop
();
shop
.
setState
(
"1"
);
shop
.
setIsDefault
(
0L
);
shop
.
setIsDefault
(
1L
);
List
<
Shop
>
shops
=
shopMapper
.
selectShopList
(
shop
);
return
shops
;
}
Shop
shop
=
new
Shop
();
shop
.
setState
(
"1"
);
shop
.
setIsDefault
(
0L
);
List
<
Shop
>
shops
=
shopMapper
.
selectShopList
(
shop
);
for
(
Shop
shop1
:
shops
)
{
double
v
=
GetDistance
(
Double
.
parseDouble
(
lng
),
Double
.
parseDouble
(
lat
),
Double
.
parseDouble
(
shop1
.
getLng
()),
Double
.
parseDouble
(
shop1
.
getLat
()));
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
shop1
.
setDistance
(
df
.
format
(
v
));
}
return
shops
.
stream
().
sorted
((
x
,
y
)
->
x
.
getDistance
().
compareTo
(
y
.
getDistance
())).
collect
(
Collectors
.
toList
());
if
(
shops
!=
null
&&!
shops
.
isEmpty
()){
Shop
shop1
=
shops
.
get
(
0
);
double
v
=
GetDistance
(
Double
.
parseDouble
(
lng
),
Double
.
parseDouble
(
lat
),
Double
.
parseDouble
(
shop1
.
getLng
()),
Double
.
parseDouble
(
shop1
.
getLat
()));
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
shop1
.
setDistance
(
df
.
format
(
v
));
return
shop1
;
}
else
{
return
new
Shop
();
}
//return shops.stream().sorted((x, y) -> x.getDistance().compareTo(y.getDistance())).collect(Collectors.toList());
}
...
...
soss-system/src/main/java/com/soss/system/service/impl/GoodsServiceImpl.java
View file @
ef275933
...
...
@@ -14,6 +14,7 @@ import com.soss.common.utils.StringUtils;
import
com.soss.system.domain.*
;
import
com.soss.system.service.IGoodsService
;
import
com.soss.system.mapper.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.ss.formula.functions.T
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -26,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2022-04-28
*/
@Service
@Slf4j
public
class
GoodsServiceImpl
implements
IGoodsService
{
@Autowired
...
...
@@ -44,8 +46,6 @@ public class GoodsServiceImpl implements IGoodsService
private
OrderMapper
orderMapper
;
@Autowired
private
GoodsCategoryMapper
goodsCategoryMapper
;
ThreadLocal
<
BigDecimal
>
discountThread
=
new
ThreadLocal
();
ThreadLocal
<
BigDecimal
>
priceThread
=
new
ThreadLocal
();
/**
...
...
@@ -154,18 +154,12 @@ public class GoodsServiceImpl implements IGoodsService
}
private
void
createSku
(
List
<
RuleNode
>
ruleNodeList
,
long
goodsId
,
BigDecimal
discount
,
BigDecimal
price
)
{
for
(
RuleNode
<
SpecRule
>
ruleNode
:
ruleNodeList
)
{
List
<
SpecRule
>
specRuleList
=
new
ArrayList
<>();
RuleNode
<
SpecRule
>
parentRuleNode
=
ruleNode
.
getParentRuleNode
();
specRuleList
.
add
(
ruleNode
.
getRuleNode
());
priceThread
.
set
(
price
);
discountThread
.
set
(
discount
);
priceThread
.
set
(
priceThread
.
get
().
add
(
ruleNode
.
getRuleNode
().
getAmount
()));
discountThread
.
set
(
discountThread
.
get
().
add
(
ruleNode
.
getRuleNode
().
getAmount
()));
System
.
err
.
println
(
priceThread
.
get
());
System
.
err
.
println
(
discountThread
.
get
());
if
(
parentRuleNode
!=
null
){
findPartentRuleNode
(
parentRuleNode
,
specRuleList
);
}
...
...
@@ -175,8 +169,16 @@ public class GoodsServiceImpl implements IGoodsService
goodsSku
.
setCreatedAt
(
new
Date
());
goodsSku
.
setIsDeleted
(
"0"
);
goodsSku
.
setUpdatedAt
(
new
Date
());
goodsSku
.
setPrice
(
priceThread
.
get
());
goodsSku
.
setDiscount
(
discountThread
.
get
());
BigDecimal
price1
=
new
BigDecimal
(
price
.
toPlainString
());
BigDecimal
discount1
=
new
BigDecimal
(
discount
.
toPlainString
());
log
.
info
(
"商品价格为:{},{}"
,
price
.
toPlainString
(),
discount
.
toPlainString
());
for
(
SpecRule
specRule
:
specRuleList
)
{
price1
=
price1
.
add
(
specRule
.
getAmount
());
discount1
=
discount1
.
add
(
specRule
.
getAmount
());
}
log
.
info
(
"产品价格为:{},{}"
,
price
.
toPlainString
(),
discount
.
toPlainString
());
goodsSku
.
setPrice
(
price1
);
goodsSku
.
setDiscount
(
discount1
);
goodsSku
.
setRuleList
(
JSONArray
.
toJSONString
(
specRuleList
));
goodsSkuMapper
.
insertGoodsSku
(
goodsSku
);
}
...
...
@@ -184,8 +186,6 @@ public class GoodsServiceImpl implements IGoodsService
private
void
findPartentRuleNode
(
RuleNode
<
SpecRule
>
ruleRuleNode
,
List
<
SpecRule
>
specRuleList
)
{
specRuleList
.
add
(
ruleRuleNode
.
getRuleNode
());
priceThread
.
set
(
priceThread
.
get
().
add
(
ruleRuleNode
.
getRuleNode
().
getAmount
()));
discountThread
.
set
(
discountThread
.
get
().
add
(
ruleRuleNode
.
getRuleNode
().
getAmount
()));
RuleNode
<
SpecRule
>
parentRuleNode
=
ruleRuleNode
.
getParentRuleNode
();
if
(
parentRuleNode
!=
null
){
findPartentRuleNode
(
parentRuleNode
,
specRuleList
);
...
...
soss-system/src/main/java/com/soss/system/service/impl/MachineApiServiceImpl.java
View file @
ef275933
...
...
@@ -81,11 +81,13 @@ public class MachineApiServiceImpl {
if
(
order1
==
null
){
throw
new
ServiceException
(
"该订单不存在"
);
}
Order
order
=
new
Order
();
order
.
setId
(
orderID
);
order
.
setState
(
status
);
order
.
setUpdatedAt
(
new
Date
());
if
(
"6"
.
equals
(
status
)){
order
.
setFinishTime
(
new
Date
());
}
int
i
=
orderMapper
.
updateOrder
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
return
i
+
""
;
...
...
@@ -169,13 +171,13 @@ public class MachineApiServiceImpl {
public
ResultVo
sendRequest
(
String
param
,
String
interfaceName
){
try
{
String
postUrl
=
url
+
interfaceName
;
log
.
info
(
"请求
创建订单接口:【{}】"
,
param
);
log
.
info
(
"请求
订单接口[{}]:【{}】"
,
postUrl
,
param
);
HttpHeaders
requestHeaders
=
new
HttpHeaders
();
requestHeaders
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
HttpEntity
requestEntity
=
new
HttpEntity
(
param
,
requestHeaders
);
JSONObject
.
toJSONString
(
param
);
ResponseEntity
<
String
>
stringResponseEntity
=
restTemplate
.
postForEntity
(
postUrl
,
requestEntity
,
String
.
class
);
log
.
info
(
"请求
创建订单接口返回结果为:【{}】"
,
stringResponseEntity
.
getBody
());
log
.
info
(
"请求
接口返回结果为[{}]:【{}】"
,
postUrl
,
stringResponseEntity
.
getBody
());
ResultVo
resultVo
=
JSONObject
.
parseObject
(
stringResponseEntity
.
getBody
(),
ResultVo
.
class
);
return
resultVo
;
}
catch
(
Exception
e
){
...
...
soss-system/src/main/java/com/soss/system/service/impl/ShopRecommendServiceImpl.java
View file @
ef275933
...
...
@@ -58,7 +58,7 @@ public class ShopRecommendServiceImpl implements IShopRecommendService
List
<
Goods
>
goodsList
=
shopRecommendMapper
.
selectShopRecommendGoods
(
shopRecommend
.
getShopId
(),
shopRecommend
.
getType
());
goodsList
=
goodsList
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
for
(
Goods
goods
:
goodsList
)
{
goods
.
setCategoryName
(
goodsCategoryMapper
.
selectGoodsCategoryById
(
String
.
valueOf
(
goods
.
get
Id
())).
getName
());
goods
.
setCategoryName
(
goodsCategoryMapper
.
selectGoodsCategoryById
(
String
.
valueOf
(
goods
.
get
Category
())).
getName
());
goods
.
setSalesVolume
(
orderMapper
.
selectSalesVolume
(
Long
.
parseLong
(
shopRecommend
.
getShopId
()),
goods
.
getId
()));
}
return
goodsList
;
...
...
soss-system/src/main/java/com/soss/system/service/impl/ShopServiceImpl.java
View file @
ef275933
package
com
.
soss
.
system
.
service
.
impl
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -227,7 +228,17 @@ public class ShopServiceImpl implements IShopService
public
String
turn
(
Long
shopId
,
Long
goodsId
,
String
pointer
)
{
ShopGoods
shopGoods
=
new
ShopGoods
();
shopGoods
.
setShopId
(
shopId
);
Goods
goods
=
goodsMapper
.
selectGoodsById
(
String
.
valueOf
(
goodsId
));
List
<
ShopGoods
>
shopGoodsList
=
shopGoodsMapper
.
selectShopGoodsList
(
shopGoods
);
shopGoodsList
=
shopGoodsList
.
stream
().
filter
(
e
->{
String
category
=
goodsMapper
.
selectGoodsById
(
String
.
valueOf
(
goodsId
)).
getCategory
();
if
(
category
.
equals
(
goods
.
getCategory
())){
return
true
;
}
else
{
return
false
;
}
}).
collect
(
Collectors
.
toList
());
int
size
=
shopGoodsList
.
size
();
Long
lastGoodsId
=
null
;
for
(
int
i
=
0
;
i
<
size
;
i
++){
...
...
soss-system/src/main/resources/mapper/system/MachineMapper.xml
View file @
ef275933
...
...
@@ -13,10 +13,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"bindTime"
column=
"bind_time"
/>
<result
property=
"createdAt"
column=
"created_at"
/>
<result
property=
"updatedAt"
column=
"updated_at"
/>
<result
property=
"register"
column=
"register"
></result>
</resultMap>
<sql
id=
"selectMachineVo"
>
select id, shop_id, code, type, state, bind_time, created_at, updated_at from machine
select id, shop_id, code, type, state, bind_time, created_at, updated_at
,register
from machine
</sql>
<select
id=
"selectMachineList"
parameterType=
"Machine"
resultMap=
"MachineResult"
>
...
...
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