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
1cac5c58
Commit
1cac5c58
authored
Oct 09, 2022
by
caiyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
极光推送逻辑修改,上传文件名逻辑修改
parent
423995a5
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
230 additions
and
130 deletions
+230
-130
soss-admin/src/main/java/com/soss/web/controller/coffee/ApplicationController.java
+43
-32
soss-admin/src/main/java/com/soss/web/controller/coffee/MachineController.java
+7
-3
soss-admin/src/main/resources/application.yml
+1
-0
soss-framework/src/main/java/com/soss/framework/config/SecurityConfig.java
+19
-5
soss-framework/src/main/java/com/soss/framework/security/filter/JwtAuthenticationTokenFilter.java
+12
-13
soss-framework/src/main/java/com/soss/framework/web/service/OssFileServiceImpl.java
+11
-1
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
+27
-1
soss-system/src/main/java/com/soss/system/domain/Machine.java
+1
-1
soss-system/src/main/java/com/soss/system/jiguang/impl/JiGuangPushServiceImpl.java
+11
-13
soss-system/src/main/java/com/soss/system/mapper/GoodsSkuMapper.java
+3
-0
soss-system/src/main/java/com/soss/system/mapper/MachineMapper.java
+8
-2
soss-system/src/main/java/com/soss/system/service/IMachineService.java
+4
-0
soss-system/src/main/java/com/soss/system/service/impl/GoodsServiceImpl.java
+9
-6
soss-system/src/main/java/com/soss/system/service/impl/MachineApiServiceImpl.java
+12
-19
soss-system/src/main/java/com/soss/system/service/impl/MachineServiceImpl.java
+15
-5
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
+9
-9
soss-system/src/main/java/com/soss/system/service/impl/ShopRecommendServiceImpl.java
+5
-5
soss-system/src/main/java/com/soss/system/service/impl/ShopServiceImpl.java
+12
-12
soss-system/src/main/resources/mapper/system/GoodsSkuMapper.xml
+5
-0
soss-system/src/main/resources/mapper/system/MachineMapper.xml
+16
-3
No files found.
soss-admin/src/main/java/com/soss/web/controller/coffee/ApplicationController.java
View file @
1cac5c58
...
...
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
import
com.soss.common.core.domain.AjaxResult
;
import
com.soss.common.exception.ServiceException
;
import
com.soss.common.utils.StringUtils
;
import
com.soss.common.utils.uuid.UUID
;
import
com.soss.system.domain.Machine
;
import
com.soss.system.domain.Shop
;
import
com.soss.system.jiguang.impl.JiGuangPushServiceImpl
;
...
...
@@ -17,10 +16,7 @@ import com.soss.system.utils.DistanceUtil;
import
io.jsonwebtoken.lang.Assert
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -42,10 +38,15 @@ public class ApplicationController {
@Autowired
private
ICustomerService
customerService
;
@RequestMapping
(
"/saveData"
)
public
AjaxResult
saveApplicationData
(
@RequestParam
(
"machineCode"
)
String
machineCode
,
@RequestBody
String
body
)
{
String
id
=
UUID
.
randomUUID
().
toString
();
String
key
=
machineCode
;
//+"_"+id;
@PostMapping
(
"/saveData"
)
public
AjaxResult
saveApplicationData
(
@RequestBody
String
body
)
{
JSONObject
bodyJson
=
JSONObject
.
parseObject
(
body
);
String
machineCode
=
bodyJson
.
getString
(
"machineCode"
);
Integer
screenNo
=
bodyJson
.
getInteger
(
"screenNo"
);
if
(
screenNo
==
null
)
{
screenNo
=
1
;
}
String
key
=
machineCode
+
"_"
+
screenNo
;
stringRedisTemplate
.
opsForValue
().
set
(
key
,
body
);
stringRedisTemplate
.
expire
(
key
,
60
,
TimeUnit
.
SECONDS
);
return
AjaxResult
.
success
(
"处理成功"
,
key
);
...
...
@@ -53,48 +54,58 @@ public class ApplicationController {
@RequestMapping
(
"/getData"
)
public
AjaxResult
getApplicationData
(
@RequestBody
String
body
)
{
JSONObject
jj
=
JSONObject
.
parseObject
(
body
);
String
key
=
jj
.
getString
(
"key"
);
JSONObject
location
=
jj
.
getJSONObject
(
"location"
);
String
s
=
stringRedisTemplate
.
opsForValue
().
get
(
k
ey
);
if
(
StringUtils
.
isEmpty
(
s
))
{
JSONObject
bodyJson
=
JSONObject
.
parseObject
(
body
);
String
redisKey
=
bodyJson
.
getString
(
"key"
);
JSONObject
location
=
bodyJson
.
getJSONObject
(
"location"
);
String
redisVal
=
stringRedisTemplate
.
opsForValue
().
get
(
redisK
ey
);
if
(
StringUtils
.
isEmpty
(
redisVal
))
{
throw
new
ServiceException
(
"该二维码已经过期"
);
}
String
openId
=
jj
.
getString
(
"openId"
);
String
faceInfoId
=
jj
.
getString
(
"faceInfoId"
);
String
openId
=
bodyJson
.
getString
(
"openId"
);
String
faceInfoId
=
bodyJson
.
getString
(
"faceInfoId"
);
if
(
StringUtils
.
isNotEmpty
(
openId
))
{
Assert
.
isTrue
(
StringUtils
.
isNotEmpty
(
faceInfoId
),
"faceInfoId还未传递"
);
customerService
.
insertCustFaceInfo
(
openId
,
faceInfoId
);
}
JSONObject
info
=
JSONObject
.
parseObject
(
s
);
String
machineCode
=
info
.
getString
(
"machineCode"
);
JSONObject
redisJson
=
JSONObject
.
parseObject
(
redisVal
);
String
machineCode
=
redisJson
.
getString
(
"machineCode"
);
Integer
screenNo
=
redisJson
.
getInteger
(
"screenNo"
);
Machine
machine
=
machineService
.
selectMachineByCode
(
machineCode
);
Shop
shop
=
shopService
.
selectShopById
(
machine
.
getShopId
());
shop
.
setDistance
(
DistanceUtil
.
getDistanceDesc
(
Double
.
parseDouble
(
shop
.
getLng
()),
Double
.
parseDouble
(
shop
.
getLat
()),
Double
.
parseDouble
(
location
.
getString
(
"lng"
)),
Double
.
parseDouble
(
location
.
getString
(
"lat"
))));
info
.
put
(
"shop"
,
shop
);
String
[]
keys
=
key
.
split
(
"_"
);
redisJson
.
put
(
"shop"
,
shop
);
//推送数据给安卓
JSONObject
j
sonObject
=
new
JSONObject
();
j
sonObject
.
put
(
"action"
,
"QRCODE_VISITED"
);
j
sonObject
.
put
(
"timestamp"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
JSONObject
j
gBody
=
new
JSONObject
();
j
gBody
.
put
(
"action"
,
"QRCODE_VISITED"
);
j
gBody
.
put
(
"timestamp"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"seqNo"
,
k
ey
);
j
sonObject
.
put
(
"data"
,
data
);
jiGuangPushService
.
push
(
keys
[
0
],
jsonObject
);
// stringRedisTemplate.delete(
k
ey);
return
AjaxResult
.
success
(
"处理成功"
,
info
.
toJSONString
());
data
.
put
(
"seqNo"
,
redisK
ey
);
j
gBody
.
put
(
"data"
,
data
);
jiGuangPushService
.
push
(
Integer
.
parseInt
(
machine
.
getId
()),
screenNo
,
jgBody
);
// stringRedisTemplate.delete(
redisK
ey);
return
AjaxResult
.
success
(
"处理成功"
,
redisJson
.
toJSONString
());
}
@RequestMapping
(
"/jgRegister"
)
public
AjaxResult
jgRegister
(
@RequestParam
String
machineCode
,
@RequestParam
String
registerId
)
{
public
AjaxResult
jgRegister
(
@RequestParam
String
machineCode
,
@RequestParam
(
required
=
false
)
Integer
screenNo
,
@RequestParam
String
registerId
)
{
Machine
machine
=
machineService
.
selectMachineByCode
(
machineCode
);
if
(
machine
==
null
)
{
if
(
machine
==
null
||
machine
.
getShopId
()
==
null
)
{
throw
new
ServiceException
(
"该机器未绑定店铺,请先绑定店铺"
);
}
machine
.
setRegister
(
registerId
);
return
AjaxResult
.
success
(
machineService
.
updateMachine
(
machine
));
if
(
screenNo
==
null
)
{
screenNo
=
1
;
}
Assert
.
isTrue
(
StringUtils
.
isNotEmpty
(
machineCode
),
"machineCode不能为空"
);
Assert
.
isTrue
(
StringUtils
.
isNotEmpty
(
registerId
),
"registerId不能为空"
);
// machine.setRegister(registerId);
// machineService.updateMachine(machine);
machineService
.
saveMachineScreenRef
(
Integer
.
parseInt
(
machine
.
getId
()),
screenNo
,
registerId
);
return
AjaxResult
.
success
();
}
@RequestMapping
(
"/getOrderTaking"
)
public
AjaxResult
getOrderTaking
(
String
machineCode
){
...
...
soss-admin/src/main/java/com/soss/web/controller/coffee/MachineController.java
View file @
1cac5c58
...
...
@@ -9,6 +9,7 @@ import com.soss.system.domain.Machine;
import
com.soss.system.service.IMachineService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
...
...
@@ -73,10 +74,13 @@ public class MachineController extends BaseController
*/
@Log
(
title
=
"机器"
,
businessType
=
BusinessType
.
UPDATE
)
@GetMapping
(
"/unbound"
)
public
AjaxResult
unbound
(
String
id
)
{
public
AjaxResult
unbound
(
String
id
)
{
return
toAjax
(
machineService
.
unbound
(
id
));
}
@GetMapping
(
"/bind/check/{shopId}"
)
public
AjaxResult
isShopBindMachine
(
@PathVariable
Long
shopId
)
{
List
<
Machine
>
machines
=
machineService
.
getMachines
(
shopId
);
return
AjaxResult
.
success
(!
CollectionUtils
.
isEmpty
(
machines
));
}
}
soss-admin/src/main/resources/application.yml
View file @
1cac5c58
...
...
@@ -91,6 +91,7 @@ weixin:
templateId
:
Fu_CPIXa0cnJ4EDdVKqFQ4T3qTxBqv8vXMU7-sQgerg
pagePath
:
orderSubPackage/pages/orderInfo/index?orderId=
program
:
trial
qr-size
:
455*455
# refund-no-prefix: RD
# program: formal
#mqtt:
...
...
soss-framework/src/main/java/com/soss/framework/config/SecurityConfig.java
View file @
1cac5c58
package
com
.
soss
.
framework
.
config
;
import
com.soss.framework.interceptor.GlobalExceptionHandlerFilter
;
import
com.soss.framework.security.filter.JwtAuthenticationTokenFilter
;
import
com.soss.framework.security.handle.AuthenticationEntryPointImpl
;
import
com.soss.framework.security.handle.LogoutSuccessHandlerImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.http.HttpMethod
;
...
...
@@ -8,6 +11,7 @@ import org.springframework.security.authentication.AuthenticationManager;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.builders.WebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.config.http.SessionCreationPolicy
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
...
...
@@ -15,10 +19,8 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import
org.springframework.security.web.access.channel.ChannelProcessingFilter
;
import
org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
;
import
org.springframework.security.web.authentication.logout.LogoutFilter
;
import
org.springframework.security.web.firewall.StrictHttpFirewall
;
import
org.springframework.web.filter.CorsFilter
;
import
com.soss.framework.security.filter.JwtAuthenticationTokenFilter
;
import
com.soss.framework.security.handle.AuthenticationEntryPointImpl
;
import
com.soss.framework.security.handle.LogoutSuccessHandlerImpl
;
/**
* spring security配置
...
...
@@ -142,8 +144,20 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
* 身份认证接口
*/
@Override
protected
void
configure
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
protected
void
configure
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
userDetailsService
(
userDetailsService
).
passwordEncoder
(
bCryptPasswordEncoder
());
}
@Override
public
void
configure
(
WebSecurity
web
)
throws
Exception
{
super
.
configure
(
web
);
StrictHttpFirewall
firewall
=
new
StrictHttpFirewall
();
firewall
.
setAllowSemicolon
(
true
);
firewall
.
setAllowUrlEncodedSlash
(
true
);
firewall
.
setAllowUrlEncodedPeriod
(
true
);
firewall
.
setAllowUrlEncodedPercent
(
true
);
//设置允许双 //
firewall
.
setAllowUrlEncodedDoubleSlash
(
true
);
web
.
httpFirewall
(
firewall
);
}
}
soss-framework/src/main/java/com/soss/framework/security/filter/JwtAuthenticationTokenFilter.java
View file @
1cac5c58
package
com
.
soss
.
framework
.
security
.
filter
;
import
java.io.IOException
;
import
javax.servlet.FilterChain
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.soss.common.core.domain.model.LoginUser
;
import
com.soss.common.utils.SecurityUtils
;
import
com.soss.common.utils.StringUtils
;
import
com.soss.framework.web.service.TokenService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.web.authentication.WebAuthenticationDetailsSource
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.filter.OncePerRequestFilter
;
import
com.soss.common.core.domain.model.LoginUser
;
import
com.soss.common.utils.SecurityUtils
;
import
com.soss.common.utils.StringUtils
;
import
com.soss.framework.web.service.TokenService
;
import
javax.servlet.FilterChain
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
/**
* token过滤器 验证token有效性
...
...
@@ -29,11 +30,9 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
@Override
protected
void
doFilterInternal
(
HttpServletRequest
request
,
HttpServletResponse
response
,
FilterChain
chain
)
throws
ServletException
,
IOException
{
throws
ServletException
,
IOException
{
LoginUser
loginUser
=
tokenService
.
getLoginUser
(
request
);
if
(
StringUtils
.
isNotNull
(
loginUser
)
&&
StringUtils
.
isNull
(
SecurityUtils
.
getAuthentication
()))
{
if
(
StringUtils
.
isNotNull
(
loginUser
)
&&
StringUtils
.
isNull
(
SecurityUtils
.
getAuthentication
()))
{
tokenService
.
verifyToken
(
loginUser
);
UsernamePasswordAuthenticationToken
authenticationToken
=
new
UsernamePasswordAuthenticationToken
(
loginUser
,
null
,
loginUser
.
getAuthorities
());
authenticationToken
.
setDetails
(
new
WebAuthenticationDetailsSource
().
buildDetails
(
request
));
...
...
soss-framework/src/main/java/com/soss/framework/web/service/OssFileServiceImpl.java
View file @
1cac5c58
...
...
@@ -4,6 +4,7 @@ import com.aliyun.oss.OSS;
import
com.aliyun.oss.OSSClientBuilder
;
import
com.aliyun.oss.OSSException
;
import
com.aliyun.oss.model.CannedAccessControlList
;
import
com.soss.common.utils.sign.Md5Utils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
...
...
@@ -14,6 +15,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.UUID
;
@Service
@Slf4j
...
...
@@ -62,7 +64,7 @@ public class OssFileServiceImpl {
//构建日期目录
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy/MM/dd"
);
String
datePath
=
dateFormat
.
format
(
new
Date
());
String
fileUrl
=
dir
+
"/"
+
datePath
+
"/"
+
originName
;
String
fileUrl
=
dir
+
"/"
+
datePath
+
"/"
+
getSaveName
(
originName
)
;
//文件上传到云服务器
ossClient
.
putObject
(
bucketName
,
fileUrl
,
inputStream
);
return
"https://"
+
bucketName
+
"."
+
endpoint
+
"/"
+
fileUrl
;
...
...
@@ -76,4 +78,12 @@ public class OssFileServiceImpl {
}
return
null
;
}
//文件存储路径
private
static
String
getSaveName
(
String
fileName
)
{
int
lasIdx
=
fileName
.
lastIndexOf
(
"."
);
String
fileNameSuf
=
fileName
.
substring
(
lasIdx
);
String
nameKey
=
Md5Utils
.
hash
(
fileName
+
UUID
.
randomUUID
().
toString
()
+
System
.
currentTimeMillis
());
return
nameKey
+
fileNameSuf
;
}
}
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
View file @
1cac5c58
...
...
@@ -117,6 +117,8 @@ public class WeixinServiceImpl {
private
String
queryUrl
;
@Value
(
"${weixin.refund-url}"
)
private
String
refundUrl
;
@Value
(
"${weixin.qr-size}"
)
private
String
qrSize
;
private
String
areaData
;
public
String
getSessionKeyOrOpenId
(
String
code
)
{
...
...
@@ -730,7 +732,12 @@ public class WeixinServiceImpl {
hints
.
put
(
EncodeHintType
.
CHARACTER_SET
,
"utf-8"
);
String
fileName
=
System
.
currentTimeMillis
()
+
".png"
;
try
{
BitMatrix
bitMatrix
=
qrCodeWriter
.
encode
(
content
,
BarcodeFormat
.
QR_CODE
,
350
,
350
,
hints
);
String
[]
qrSizeArr
=
qrSize
.
split
(
"\\*"
);
int
width
=
Integer
.
parseInt
(
qrSizeArr
[
0
]);
int
height
=
Integer
.
parseInt
(
qrSizeArr
[
1
]);
log
.
info
(
"qr with: {} height: {}"
,
width
,
height
);
BitMatrix
bitMatrix
=
qrCodeWriter
.
encode
(
content
,
BarcodeFormat
.
QR_CODE
,
width
,
height
,
hints
);
bitMatrix
=
deleteWhite
(
bitMatrix
);
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
MatrixToImageWriter
.
writeToStream
(
bitMatrix
,
"PNG"
,
byteArrayOutputStream
);
return
ossFileService
.
uploadFile
(
new
ByteArrayInputStream
(
byteArrayOutputStream
.
toByteArray
()),
fileName
);
...
...
@@ -739,4 +746,23 @@ public class WeixinServiceImpl {
}
return
null
;
}
/**
* 删除白边
*/
private
BitMatrix
deleteWhite
(
BitMatrix
matrix
)
{
int
[]
rec
=
matrix
.
getEnclosingRectangle
();
int
resWidth
=
rec
[
2
]
+
1
;
int
resHeight
=
rec
[
3
]
+
1
;
BitMatrix
resMatrix
=
new
BitMatrix
(
resWidth
,
resHeight
);
resMatrix
.
clear
();
for
(
int
i
=
0
;
i
<
resWidth
;
i
++)
{
for
(
int
j
=
0
;
j
<
resHeight
;
j
++)
{
if
(
matrix
.
get
(
i
+
rec
[
0
],
j
+
rec
[
1
]))
{
resMatrix
.
set
(
i
,
j
);
}
}
}
return
resMatrix
;
}
}
soss-system/src/main/java/com/soss/system/domain/Machine.java
View file @
1cac5c58
...
...
@@ -54,7 +54,7 @@ public class Machine extends BaseEntity
@Excel
(
name
=
"更新时间"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd"
)
private
Date
updatedAt
;
private
String
register
;
//
private String register;
@Override
public
String
toString
()
{
...
...
soss-system/src/main/java/com/soss/system/jiguang/impl/JiGuangPushServiceImpl.java
View file @
1cac5c58
package
com
.
soss
.
system
.
jiguang
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.soss.common.utils.StringUtils
;
import
com.soss.system.domain.Machine
;
import
com.soss.system.domain.Order
;
import
com.soss.system.domain.vo.PushBean
;
import
com.soss.system.jiguang.JiGuangPushService
;
import
com.soss.system.jiguang.MyJiGuangPushService
;
...
...
@@ -14,7 +11,6 @@ import org.springframework.stereotype.Service;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
/**
* 推送服务
...
...
@@ -87,29 +83,31 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
public
String
[]
checkRegistids
(
String
[]
registids
)
{
List
<
String
>
regList
=
new
ArrayList
<
String
>(
registids
.
length
);
for
(
String
registid
:
registids
)
{
if
(
registid
!=
null
&&
!
""
.
equals
(
registid
.
trim
()))
{
if
(
registid
!=
null
&&
!
""
.
equals
(
registid
.
trim
()))
{
regList
.
add
(
registid
);
}
}
return
regList
.
toArray
(
new
String
[
0
]);
}
public
void
push
(
String
key
,
JSONObject
jsonObject
)
{
String
s
=
machineMapper
.
selectRegister
(
key
);
if
(
StringUtils
.
isNotEmpty
(
s
)){
public
void
push
(
Integer
machineId
,
Integer
screenNo
,
JSONObject
jsonObject
)
{
// String s = machineMapper.selectRegister(key);
String
[]
registerIds
=
machineMapper
.
selectRegister
(
machineId
,
screenNo
);
if
(
registerIds
!=
null
&&
registerIds
.
length
>
0
)
{
PushBean
pushBean
=
new
PushBean
();
pushBean
.
setMessageCount
(
jsonObject
);
pushAndroid
(
pushBean
,
s
);
pushAndroid
(
pushBean
,
registerId
s
);
}
}
public
void
pushMachine
(
String
machineId
,
Map
<
String
,
String
>
map
)
{
/*public void pushMachine(String machineId, Map<String, String> map) {
Machine machine = machineMapper.selectMachineById(machineId);
if
(
StringUtils
.
isNotEmpty
(
machine
.
getRegister
()))
{
if
(StringUtils.isNotEmpty(machine.getRegister()))
{
PushBean pushBean = new PushBean();
pushBean.setExtras(map);
pushBean.setAlert("新消息");
pushAndroid
(
pushBean
,
machine
.
getRegister
());
pushAndroid(pushBean,
machine.getRegister());
}
}
...
...
@@ -130,5 +128,5 @@ public class JiGuangPushServiceImpl implements JiGuangPushService {
pushBean.setMessageCount(jsonObject);
pushAndroid(pushBean,machine.getRegister());
}
}
}
*/
}
soss-system/src/main/java/com/soss/system/mapper/GoodsSkuMapper.java
View file @
1cac5c58
...
...
@@ -3,6 +3,7 @@ package com.soss.system.mapper;
import
com.soss.system.domain.GoodsSku
;
import
org.apache.ibatis.annotations.Param
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
...
...
@@ -72,4 +73,6 @@ public interface GoodsSkuMapper
void
deleteGoodsSkuByGoodsId
(
@Param
(
"goodsId"
)
String
id
);
List
<
GoodsSku
>
selectSpec
(
String
query
);
void
updateSkuPrice
(
@Param
(
"goodsId"
)
long
id
,
@Param
(
"discountDiff"
)
BigDecimal
discountDiff
,
@Param
(
"priceDiff"
)
BigDecimal
priceDiff
);
}
soss-system/src/main/java/com/soss/system/mapper/MachineMapper.java
View file @
1cac5c58
package
com
.
soss
.
system
.
mapper
;
import
com.soss.system.domain.Machine
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
...
...
@@ -58,12 +59,17 @@ public interface MachineMapper
/**
* 批量删除机器
*
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public
int
deleteMachineByIds
(
String
[]
ids
);
int
unbound
(
String
id
);
String
selectRegister
(
String
id
);
// String selectRegister(String id);
void
saveMachineScreenRef
(
@Param
(
"machineId"
)
Integer
machineId
,
@Param
(
"screenNo"
)
Integer
screenNo
,
@Param
(
"registerId"
)
String
registerId
);
String
[]
selectRegister
(
@Param
(
"machineId"
)
Integer
machineId
,
@Param
(
"screenNo"
)
Integer
screenNo
);
}
soss-system/src/main/java/com/soss/system/service/IMachineService.java
View file @
1cac5c58
...
...
@@ -59,7 +59,11 @@ public interface IMachineService
*/
public
int
deleteMachineById
(
String
id
);
List
<
Machine
>
getMachines
(
Long
shopId
);
String
bindMachine
(
String
code
,
Long
shopId
);
int
unbound
(
String
id
);
void
saveMachineScreenRef
(
Integer
machineId
,
Integer
screenNo
,
String
registerId
);
}
soss-system/src/main/java/com/soss/system/service/impl/GoodsServiceImpl.java
View file @
1cac5c58
...
...
@@ -299,7 +299,13 @@ public class GoodsServiceImpl implements IGoodsService {
goodsTagMapper
.
deleteGoodsTagByGoodsId
(
String
.
valueOf
(
goods
.
getId
()));
insertGoodsTags
(
goods
);
if
(
StringUtils
.
isEmpty
(
goods
.
getSpec
())
||
Objects
.
equals
(
goodsOri
.
getSpec
(),
goods
.
getSpec
()))
{
if
((
StringUtils
.
isEmpty
(
goods
.
getSpec
())
||
Objects
.
equals
(
goodsOri
.
getSpec
(),
goods
.
getSpec
())))
{
BigDecimal
discountDiff
=
goods
.
getDiscount
().
subtract
(
goodsOri
.
getDiscount
());
BigDecimal
priceDiff
=
goods
.
getPrice
().
subtract
(
goodsOri
.
getPrice
());
if
(
discountDiff
.
compareTo
(
BigDecimal
.
ZERO
)
!=
0
||
priceDiff
.
compareTo
(
BigDecimal
.
ZERO
)
!=
0
)
{
goodsSkuMapper
.
updateSkuPrice
(
goods
.
getId
(),
discountDiff
,
priceDiff
);
}
return
i
;
}
/*if(StringUtils.isNotEmpty(goods.getSpec())){
...
...
@@ -329,9 +335,7 @@ public class GoodsServiceImpl implements IGoodsService {
*/
@Override
public
int
deleteGoodsById
(
String
id
)
{
return
1
;
}
@Override
...
...
@@ -398,10 +402,9 @@ public class GoodsServiceImpl implements IGoodsService {
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"action"
,
"GOODS_CHANGED"
);
jsonObject
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
jiGuangPushService
.
push
(
machines
.
get
(
0
).
getCode
(),
jsonObject
);
int
machineId
=
Integer
.
parseInt
(
machines
.
get
(
0
).
getId
());
jiGuangPushService
.
push
(
machineId
,
null
,
jsonObject
);
}
}
@Override
...
...
soss-system/src/main/java/com/soss/system/service/impl/MachineApiServiceImpl.java
View file @
1cac5c58
...
...
@@ -10,7 +10,6 @@ import com.soss.system.domain.*;
import
com.soss.system.domain.vo.ResultVo
;
import
com.soss.system.jiguang.impl.JiGuangPushServiceImpl
;
import
com.soss.system.mapper.*
;
import
com.soss.system.weixin.util.SendMessageUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -49,12 +48,6 @@ public class MachineApiServiceImpl {
@Autowired
private
JiGuangPushServiceImpl
jiGuangPushService
;
@Autowired
private
GoodsCategoryMapper
goodsCategoryMapper
;
@Autowired
private
WechatMessageServiceImpl
wechatMessageService
;
@Autowired
private
SendMessageUtils
sendMessageUtils
;
@Autowired
private
OrderOperationLogServiceImpl
operationLogService
;
public
String
shopGoodsUpdate
(
JSONObject
jsonObject
)
{
...
...
@@ -90,9 +83,8 @@ public class MachineApiServiceImpl {
int
i
=
shopGoodsSkuMapper
.
updateSkuStatus
(
skuIds
,
robotID
,
shopID
,
status
);
//推送给极光
Machine
machine
=
machineMapper
.
selectMachineById
(
robotID
);
String
code
=
machine
.
getCode
();
this
.
push
(
code
,
status
,
map
);
this
.
push
(
machine
,
status
,
map
);
return
""
+
i
;
}
...
...
@@ -111,24 +103,25 @@ public class MachineApiServiceImpl {
* "state": 2
* }
* }
* @param
cod
e
* @param
machin
e
* @param status
* @param map
*/
private
void
push
(
String
code
,
String
status
,
Map
<
Long
,
List
<
Long
>>
map
)
{
private
void
push
(
Machine
machine
,
String
status
,
Map
<
Long
,
List
<
Long
>>
map
)
{
for
(
Long
aLong
:
map
.
keySet
())
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"action"
,
"SKU_STATE_CHANGED"
);
jsonObject
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
jsonObject
.
put
(
"action"
,
"SKU_STATE_CHANGED"
);
jsonObject
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
JSONObject
data
=
new
JSONObject
();
jsonObject
.
put
(
"data"
,
data
);
data
.
put
(
"machineCode"
,
code
);
data
.
put
(
"goodsId"
,
aLong
);
data
.
put
(
"skuIds"
,
map
.
get
(
aLong
));
data
.
put
(
"state"
,
status
);
jiGuangPushService
.
push
(
code
,
jsonObject
);
jsonObject
.
put
(
"data"
,
data
);
data
.
put
(
"machineCode"
,
machine
.
getCode
());
data
.
put
(
"goodsId"
,
aLong
);
data
.
put
(
"skuIds"
,
map
.
get
(
aLong
));
data
.
put
(
"state"
,
status
);
int
machineId
=
Integer
.
parseInt
(
machine
.
getId
());
jiGuangPushService
.
push
(
machineId
,
null
,
jsonObject
);
}
}
...
...
soss-system/src/main/java/com/soss/system/service/impl/MachineServiceImpl.java
View file @
1cac5c58
...
...
@@ -89,22 +89,27 @@ public class MachineServiceImpl implements IMachineService {
/**
* 删除机器信息
*
*
* @param id 机器主键
* @return 结果
*/
@Override
public
int
deleteMachineById
(
String
id
)
{
public
int
deleteMachineById
(
String
id
)
{
return
machineMapper
.
deleteMachineById
(
id
);
}
@Override
@Transactional
public
String
bindMachine
(
String
code
,
Long
shopId
)
{
public
List
<
Machine
>
getMachines
(
Long
shopId
)
{
Machine
machine
=
new
Machine
();
machine
.
setShopId
(
shopId
);
List
<
Machine
>
machines
=
machineMapper
.
selectMachineList
(
machine
);
return
machines
;
}
@Override
@Transactional
public
String
bindMachine
(
String
code
,
Long
shopId
)
{
List
<
Machine
>
machines
=
getMachines
(
shopId
);
if
(!
machines
.
isEmpty
())
{
throw
new
ServiceException
(
"目前只允许一个店铺绑定一台机器"
);
}
...
...
@@ -134,4 +139,9 @@ public class MachineServiceImpl implements IMachineService {
public
Machine
selectMachineByCode
(
String
machineCode
)
{
return
machineMapper
.
selectMachineByCode
(
machineCode
);
}
@Override
public
void
saveMachineScreenRef
(
Integer
machineId
,
Integer
screenNo
,
String
registerId
)
{
machineMapper
.
saveMachineScreenRef
(
machineId
,
screenNo
,
registerId
);
}
}
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
View file @
1cac5c58
...
...
@@ -260,7 +260,7 @@ public class OrderServiceImpl implements IOrderService {
}
private
void
timeoutState
(
Order
order
)
{
jiGuangPushService
.
pushOrderState
(
order
);
//
jiGuangPushService.pushOrderState(order);
if
(
BooleanUtils
.
isTrue
(
order
.
getSendMsgFlag2
()))
{
sendMessageUtils
.
sendWxMsg
(
order
);
}
...
...
@@ -272,7 +272,7 @@ public class OrderServiceImpl implements IOrderService {
* @param order
*/
private
void
partialRefundState
(
Order
order
)
{
jiGuangPushService
.
pushOrderState
(
order
);
//
jiGuangPushService.pushOrderState(order);
machineApiService
.
updateOrder
(
order
);
}
...
...
@@ -286,7 +286,7 @@ public class OrderServiceImpl implements IOrderService {
private
void
completedState
(
Order
order
)
{
order
.
setFinishTime
(
new
Date
());
orderOperationLogService
.
insertOrderOperationLog
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
//
jiGuangPushService.pushOrderState(order);
if
(
BooleanUtils
.
isTrue
(
order
.
getSendMsgFlag3
()))
{
sendMessageUtils
.
sendWxMsg
(
order
);
}
...
...
@@ -300,7 +300,7 @@ public class OrderServiceImpl implements IOrderService {
* @param order
*/
private
void
refundingState
(
Order
order
)
{
jiGuangPushService
.
pushOrderState
(
order
);
//
jiGuangPushService.pushOrderState(order);
machineApiService
.
updateOrder
(
order
);
}
...
...
@@ -315,7 +315,7 @@ public class OrderServiceImpl implements IOrderService {
private
void
unpaidCancelState
(
Order
order
)
{
orderOperationLogService
.
insertOrderOperationLog
(
order
);
machineApiService
.
updateOrder
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
//
jiGuangPushService.pushOrderState(order);
}
...
...
@@ -327,7 +327,7 @@ public class OrderServiceImpl implements IOrderService {
*/
private
void
takingState
(
Order
order
)
{
orderOperationLogService
.
insertOrderOperationLog
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
//
jiGuangPushService.pushOrderState(order);
}
/**
...
...
@@ -341,7 +341,7 @@ public class OrderServiceImpl implements IOrderService {
*/
private
void
productionCompletedState
(
Order
order
)
{
orderOperationLogService
.
insertOrderOperationLog
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
//
jiGuangPushService.pushOrderState(order);
wechatMessageService
.
insertWechatMessage
(
order
.
getUserId
(),
order
.
getId
(),
"制作完成,您的订单已经制作完成,现在可以去取餐啦!"
);
if
(
BooleanUtils
.
isTrue
(
order
.
getSendMsgFlag2
()))
{
sendMessageUtils
.
sendWxMsg
(
order
);
...
...
@@ -360,7 +360,7 @@ public class OrderServiceImpl implements IOrderService {
*/
private
void
productionState
(
Order
order
)
{
orderOperationLogService
.
insertOrderOperationLog
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
//
jiGuangPushService.pushOrderState(order);
wechatMessageService
.
insertWechatMessage
(
order
.
getUserId
(),
order
.
getId
(),
"制作提醒,您的订单已经开始制作,马上就能享受美味了!"
);
if
(
BooleanUtils
.
isTrue
(
order
.
getSendMsgFlag2
()))
{
sendMessageUtils
.
sendWxMsg
(
order
);
...
...
@@ -381,7 +381,7 @@ public class OrderServiceImpl implements IOrderService {
orderOperationLogService
.
insertOrderOperationLog
(
order
);
machineApiService
.
updateOrder
(
order
);
//极光推送
jiGuangPushService
.
pushOrderState
(
order
);
//
jiGuangPushService.pushOrderState(order);
wechatMessageService
.
insertWechatMessage
(
order
.
getUserId
(),
order
.
getId
(),
"下单成功,您已经下单成功了~"
);
if
(
BooleanUtils
.
isTrue
(
order
.
getSendMsgFlag1
()))
{
sendMessageUtils
.
sendWxMsg
(
order
);
...
...
soss-system/src/main/java/com/soss/system/service/impl/ShopRecommendServiceImpl.java
View file @
1cac5c58
...
...
@@ -92,13 +92,13 @@ public class ShopRecommendServiceImpl implements IShopRecommendService
List
<
Machine
>
machines
=
machineMapper
.
selectMachineList
(
machine
);
if
(!
machines
.
isEmpty
()){
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"action"
,
"GOODS_CHANGED"
);
jsonObject
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
jiGuangPushService
.
push
(
machines
.
get
(
0
).
getCode
(),
jsonObject
);
jsonObject
.
put
(
"action"
,
"GOODS_CHANGED"
);
jsonObject
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
int
machineId
=
Integer
.
parseInt
(
machines
.
get
(
0
).
getId
());
jiGuangPushService
.
push
(
machineId
,
null
,
jsonObject
);
}
}
/**
* 修改推荐和今日特惠
*
...
...
soss-system/src/main/java/com/soss/system/service/impl/ShopServiceImpl.java
View file @
1cac5c58
...
...
@@ -46,21 +46,17 @@ public class ShopServiceImpl implements IShopService
private
ShopGoodsSkuMapper
shopGoodsSkuMapper
;
@Autowired
private
GoodsCategoryMapper
goodsCategoryMapper
;
@Autowired
private
OrderMapper
orderMapper
;
@Autowired
private
GoodsMapper
goodsMapper
;
@Autowired
private
ShopRecommendMapper
shopRecommendMapper
;
@Autowired
private
JiGuangPushServiceImpl
jiGuangPushService
;
@Autowired
private
GoodsTagMapper
goodsTagMapper
;
/**
* 查询店铺
*
...
...
@@ -195,6 +191,7 @@ public class ShopServiceImpl implements IShopService
}
@Override
@Transactional
public
String
addGoods
(
long
shopId
,
String
goodsIds
)
{
String
[]
goodsIdString
=
goodsIds
.
split
(
","
);
for
(
String
s
:
goodsIdString
)
{
...
...
@@ -204,6 +201,7 @@ public class ShopServiceImpl implements IShopService
}
return
null
;
}
@Transactional
public
String
addGoods
(
long
shopId
,
Long
goodsId
)
{
ShopGoods
shopGoods
=
new
ShopGoods
();
...
...
@@ -236,18 +234,20 @@ public class ShopServiceImpl implements IShopService
shopGoodsSku
.
setUpdatedAt
(
new
Date
());
shopGoodsSkuMapper
.
insertShopGoodsSku
(
shopGoodsSku
);
}
updateApplication
(
machine1
.
getCode
(
));
updateApplication
(
Integer
.
parseInt
(
machine1
.
getId
()
));
}
return
null
;
}
public
void
updateApplication
(
String
code
){
public
void
updateApplication
(
Integer
machineId
)
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"action"
,
"GOODS_CHANGED"
);
jsonObject
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
jiGuangPushService
.
push
(
code
,
jsonObject
);
jsonObject
.
put
(
"action"
,
"GOODS_CHANGED"
);
jsonObject
.
put
(
"timestamp"
,
System
.
currentTimeMillis
());
jiGuangPushService
.
push
(
machineId
,
null
,
jsonObject
);
}
@Override
public
List
<
GoodsCategory
>
getCategoryGoods
(
long
shopId
)
{
public
List
<
GoodsCategory
>
getCategoryGoods
(
long
shopId
)
{
List
<
String
>
categoryIdStrList
=
goodsCategoryMapper
.
selectCategoryIdByShopId
(
shopId
);
if
(
CollectionUtils
.
isEmpty
(
categoryIdStrList
))
{
return
new
ArrayList
<>();
...
...
@@ -359,7 +359,7 @@ public class ShopServiceImpl implements IShopService
List
<
Machine
>
machines
=
machineMapper
.
selectMachineList
(
machine
);
if
(!
machines
.
isEmpty
()){
Machine
machine1
=
machines
.
get
(
0
);
updateApplication
(
machine1
.
getCode
(
));
updateApplication
(
Integer
.
parseInt
(
machine1
.
getId
()
));
}
return
null
;
}
...
...
@@ -393,7 +393,7 @@ public class ShopServiceImpl implements IShopService
List
<
Machine
>
machines
=
machineMapper
.
selectMachineList
(
machine
);
if
(!
machines
.
isEmpty
())
{
Machine
machine1
=
machines
.
get
(
0
);
updateApplication
(
machine1
.
getCode
(
));
updateApplication
(
Integer
.
parseInt
(
machine1
.
getId
()
));
}
return
null
;
}
...
...
soss-system/src/main/resources/mapper/system/GoodsSkuMapper.xml
View file @
1cac5c58
...
...
@@ -97,4 +97,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include
refid=
"selectGoodsSkuVo"
/>
where is_deleted in (0, 2) and rule_list like concat('%',#{query},'%')
</select>
<update
id=
"updateSkuPrice"
>
UPDATE goods_sku set price= price + #{priceDiff}, discount = discount + #{discountDiff} where goods_id = #{goodsId}
</update>
</mapper>
\ No newline at end of file
soss-system/src/main/resources/mapper/system/MachineMapper.xml
View file @
1cac5c58
...
...
@@ -13,7 +13,7 @@ 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
>
<
!--<result property="register" column="register"></result>--
>
</resultMap>
<sql
id=
"selectMachineVo"
>
...
...
@@ -79,7 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"state != null and state != ''"
>
state = #{state},
</if>
<if
test=
"bindTime != null"
>
bind_time = #{bindTime},
</if>
<if
test=
"updatedAt != null"
>
updated_at = #{updatedAt},
</if>
<
if
test=
"register != null"
>
register = #{register},
</if
>
<
!--<if test="register != null">register = #{register},</if>--
>
</trim>
where id = #{id}
</update>
...
...
@@ -99,7 +99,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update machine set shopId =null where code =#{id}
</update>
<select
id=
"selectRegister"
resultType=
"string"
>
<
!--<
select id="selectRegister" resultType="string">
select register from machine where code =#{id}
</select>-->
<insert
id=
"saveMachineScreenRef"
>
insert into machine_screen_ref values (#{machineId}, #{screenNo}, #{registerId})
on duplicate key update register_id = #{registerId}
</insert>
<select
id=
"selectRegister"
resultType=
"java.lang.String"
>
select register_id from machine_screen_ref where machine_id = #{machineId}
<if
test=
"screenNo != null"
>
and screen_no = #{screenNo}
</if>
</select>
</mapper>
\ No newline at end of file
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