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
c6e5b0f2
Commit
c6e5b0f2
authored
Jun 24, 2022
by
张新旗
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加退款失败,和发送短信接入
parent
771078ff
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
38 deletions
+75
-38
soss-admin/src/main/java/com/soss/web/controller/coffee/WeixinController.java
+3
-0
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
+25
-0
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
+8
-4
soss-system/src/main/java/com/soss/system/utils/SendSmsUtil.java
+39
-34
No files found.
soss-admin/src/main/java/com/soss/web/controller/coffee/WeixinController.java
View file @
c6e5b0f2
...
@@ -8,6 +8,7 @@ import com.soss.system.mapper.OrderMapper;
...
@@ -8,6 +8,7 @@ import com.soss.system.mapper.OrderMapper;
import
com.soss.system.service.impl.AppServiceImpl
;
import
com.soss.system.service.impl.AppServiceImpl
;
import
com.soss.system.service.impl.OrderServiceImpl
;
import
com.soss.system.service.impl.OrderServiceImpl
;
import
com.soss.system.service.impl.OrderTakingServiceImpl
;
import
com.soss.system.service.impl.OrderTakingServiceImpl
;
import
com.soss.system.utils.SendSmsUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -112,4 +113,6 @@ public class WeixinController {
...
@@ -112,4 +113,6 @@ public class WeixinController {
return
weixinService
.
refundNotify
(
xmlData
);
return
weixinService
.
refundNotify
(
xmlData
);
}
}
}
}
soss-framework/src/main/java/com/soss/framework/web/service/WeixinServiceImpl.java
View file @
c6e5b0f2
...
@@ -171,6 +171,7 @@ public class WeixinServiceImpl {
...
@@ -171,6 +171,7 @@ public class WeixinServiceImpl {
LoginUser
loginUser
=
new
LoginUser
(
user
,
null
);
LoginUser
loginUser
=
new
LoginUser
(
user
,
null
);
loginUser
.
setLoginTime
(
System
.
currentTimeMillis
());
loginUser
.
setLoginTime
(
System
.
currentTimeMillis
());
loginUser
.
setOpenId
(
customer
.
getId
());
loginUser
.
setOpenId
(
customer
.
getId
());
user
.
setPhonenumber
(
customer
.
getPhone
());
return
loginUser
;
return
loginUser
;
}
}
...
@@ -524,6 +525,30 @@ public class WeixinServiceImpl {
...
@@ -524,6 +525,30 @@ public class WeixinServiceImpl {
// */
// */
// return WxPayNotifyResponse.success("退款成功!");
// return WxPayNotifyResponse.success("退款成功!");
// }
// }
}
else
{
WxPayRefundNotifyResult
.
ReqInfo
reqInfo
=
wxPayRefundNotifyResult
.
getReqInfo
();
String
outRefundNo
=
reqInfo
.
getOutRefundNo
();
OrderRefund
orderRefund
=
new
OrderRefund
();
orderRefund
.
setRefundNo
(
outRefundNo
);
List
<
OrderRefund
>
orderRefunds
=
orderRefundMapper
.
selectOrderRefundList
(
orderRefund
);
if
(
orderRefunds
.
isEmpty
()){
log
.
error
(
"找不到该退款订单:【{}】"
,
outRefundNo
);
return
WxPayNotifyResponse
.
fail
(
"退款失败"
);
}
OrderRefund
orderRefund1
=
orderRefunds
.
get
(
0
);
Order
order
=
orderService
.
selectById
(
orderRefund1
.
getOrderId
());
if
(
"1"
.
equals
(
orderRefund1
.
getState
())){
orderRefund1
.
setState
(
"3"
);
orderRefundMapper
.
updateOrderRefund
(
orderRefund1
);
OrderOperationLog
orderOperationLog
=
new
OrderOperationLog
();
orderOperationLog
.
setOrderId
(
orderRefund1
.
getOrderId
());
order
.
setState
(
OrderStatusConstant
.
refundFailed
);
orderRefund1
.
setOrder
(
order
);
orderService
.
updateOrder
(
order
);
orderOperationLogService
.
insertOrderOperationLog
(
orderRefund1
);
return
WxPayNotifyResponse
.
success
(
""
);
}
}
}
return
WxPayNotifyResponse
.
fail
(
"回调有误!"
);
return
WxPayNotifyResponse
.
fail
(
"回调有误!"
);
}
}
...
...
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
View file @
c6e5b0f2
...
@@ -24,6 +24,7 @@ import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
...
@@ -24,6 +24,7 @@ import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import
com.soss.system.service.IOrderService
;
import
com.soss.system.service.IOrderService
;
import
com.soss.system.domain.vo.OrderQuery
;
import
com.soss.system.domain.vo.OrderQuery
;
import
com.soss.system.mapper.*
;
import
com.soss.system.mapper.*
;
import
com.soss.system.utils.SendSmsUtil
;
import
com.soss.system.weixin.util.SendMessageUtils
;
import
com.soss.system.weixin.util.SendMessageUtils
;
import
org.aspectj.weaver.ast.Or
;
import
org.aspectj.weaver.ast.Or
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -72,7 +73,8 @@ public class OrderServiceImpl implements IOrderService
...
@@ -72,7 +73,8 @@ public class OrderServiceImpl implements IOrderService
@Autowired
@Autowired
private
CustomerMapper
customerMapper
;
private
CustomerMapper
customerMapper
;
@Autowired
SendSmsUtil
sendSmsUtil
;
/**
/**
* 查询订单
* 查询订单
...
@@ -137,6 +139,7 @@ public class OrderServiceImpl implements IOrderService
...
@@ -137,6 +139,7 @@ public class OrderServiceImpl implements IOrderService
order
.
setState
(
OrderStatusConstant
.
Unpaid
);
order
.
setState
(
OrderStatusConstant
.
Unpaid
);
order
.
setUserId
(
loginUser
.
getOpenId
());
order
.
setUserId
(
loginUser
.
getOpenId
());
order
.
setUserName
(
loginUser
.
getUsername
());
order
.
setUserName
(
loginUser
.
getUsername
());
order
.
setUserPhone
(
loginUser
.
getUser
().
getPhonenumber
());
order
.
setCreatedAt
(
new
Date
());
order
.
setCreatedAt
(
new
Date
());
order
.
setOrderNum
(
getOrderNum
(
order
.
getShopId
()));
order
.
setOrderNum
(
getOrderNum
(
order
.
getShopId
()));
order
.
setOrderNo
(
getOrderNo
(
order
.
getSource
()));
order
.
setOrderNo
(
getOrderNo
(
order
.
getSource
()));
...
@@ -245,11 +248,8 @@ public class OrderServiceImpl implements IOrderService
...
@@ -245,11 +248,8 @@ public class OrderServiceImpl implements IOrderService
order
.
setFinishTime
(
new
Date
());
order
.
setFinishTime
(
new
Date
());
orderOperationLogService
.
insertOrderOperationLog
(
order
);
orderOperationLogService
.
insertOrderOperationLog
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
Customer
customer
=
customerMapper
.
selectCustomerById
(
order
.
getUserId
());
sendMessageUtils
.
sendWxMsg
(
order
);
sendMessageUtils
.
sendWxMsg
(
order
);
if
(!
"1"
.
equals
(
customer
.
getAllow
())){
}
}
}
...
@@ -301,6 +301,10 @@ public class OrderServiceImpl implements IOrderService
...
@@ -301,6 +301,10 @@ public class OrderServiceImpl implements IOrderService
jiGuangPushService
.
pushOrderState
(
order
);
jiGuangPushService
.
pushOrderState
(
order
);
wechatMessageService
.
insertWechatMessage
(
order
.
getUserId
(),
"制作完成,您的订单已经制作完成,现在可以去取餐啦!"
);
wechatMessageService
.
insertWechatMessage
(
order
.
getUserId
(),
"制作完成,您的订单已经制作完成,现在可以去取餐啦!"
);
sendMessageUtils
.
sendWxMsg
(
order
);
sendMessageUtils
.
sendWxMsg
(
order
);
Customer
customer
=
customerMapper
.
selectCustomerById
(
order
.
getUserId
());
if
(!
"1"
.
equals
(
customer
.
getAllow
())){
sendSmsUtil
.
sendSms
(
order
.
getUserPhone
(),
"SMS_243650242"
,
null
);
}
}
}
...
...
soss-system/src/main/java/com/soss/system/utils/SendSmsUtil.java
View file @
c6e5b0f2
...
@@ -36,44 +36,49 @@ public class SendSmsUtil {
...
@@ -36,44 +36,49 @@ public class SendSmsUtil {
//phone:要发送的手机号
//phone:要发送的手机号
//templateCode:申请的短信模板
//templateCode:申请的短信模板
//paramsJson:模板里面的参数和对应的值,处理成json字符串直接传进来
//paramsJson:模板里面的参数和对应的值,处理成json字符串直接传进来
public
Boolean
sendSms
(
String
phone
,
String
templateCode
,
String
paramsJson
)
throws
ClientException
{
public
Boolean
sendSms
(
String
phone
,
String
templateCode
,
String
paramsJson
)
{
// 超时时间
try
{
System
.
setProperty
(
"sun.net.client.defaultConnectTimeout"
,
"10000"
);
// 超时时间
System
.
setProperty
(
"sun.net.client.defaultReadTimeout"
,
"10000"
);
System
.
setProperty
(
"sun.net.client.defaultConnectTimeout"
,
"10000"
);
System
.
setProperty
(
"sun.net.client.defaultReadTimeout"
,
"10000"
);
// 初始化acsClient,暂不支持region化
// 初始化acsClient,暂不支持region化
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
accessKeyId
,
accessKeySecret
);
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
accessKeyId
,
accessKeySecret
);
DefaultProfile
.
addEndpoint
(
"cn-hangzhou"
,
"cn-hangzhou"
,
product
,
domain
);
DefaultProfile
.
addEndpoint
(
"cn-hangzhou"
,
"cn-hangzhou"
,
product
,
domain
);
IAcsClient
acsClient
=
new
DefaultAcsClient
(
profile
);
IAcsClient
acsClient
=
new
DefaultAcsClient
(
profile
);
// 组装请求对象-具体描述见控制台-文档部分内容
// 组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest
request
=
new
SendSmsRequest
();
SendSmsRequest
request
=
new
SendSmsRequest
();
// 必填:待发送手机号
// 必填:待发送手机号
request
.
setPhoneNumbers
(
phone
);
request
.
setPhoneNumbers
(
phone
);
// 必填:短信签名-可在短信控制台中找到
// 必填:短信签名-可在短信控制台中找到
request
.
setSignName
(
signName
);
request
.
setSignName
(
signName
);
// 必填:短信模板code-可在短信控制台中找到
// 必填:短信模板code-可在短信控制台中找到
request
.
setTemplateCode
(
templateCode
);
request
.
setTemplateCode
(
templateCode
);
// 可选:模板中的变量替换JSON串
// 可选:模板中的变量替换JSON串
request
.
setTemplateParam
(
paramsJson
);
request
.
setTemplateParam
(
paramsJson
);
//可能会抛出异常,try catch一下
//可能会抛出异常,try catch一下
SendSmsResponse
sendSmsResponse
;
SendSmsResponse
sendSmsResponse
;
try
{
try
{
//调用阿里云短信服务
//调用阿里云短信服务
sendSmsResponse
=
acsClient
.
getAcsResponse
(
request
);
sendSmsResponse
=
acsClient
.
getAcsResponse
(
request
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
log
.
error
(
"调用阿里云短信服务异常!异常信息:"
+
e
.
getMessage
());
log
.
error
(
"调用阿里云短信服务异常!异常信息:"
+
e
.
getMessage
());
return
false
;
return
false
;
}
}
Boolean
result
;
Boolean
result
;
if
(
result
=
sendSmsResponse
.
getCode
()
!=
null
&&
sendSmsResponse
.
getCode
().
equals
(
"OK"
))
{
if
(
result
=
sendSmsResponse
.
getCode
()
!=
null
&&
sendSmsResponse
.
getCode
().
equals
(
"OK"
))
{
log
.
info
(
"短信发送成功!内容:"
+
sendSmsResponse
.
getMessage
());
log
.
info
(
"短信发送成功!内容:"
+
sendSmsResponse
.
getMessage
());
}
else
{
}
else
{
log
.
error
(
"短信发送失败!异常信息:"
+
sendSmsResponse
.
getMessage
());
log
.
error
(
"短信发送失败!异常信息:"
+
sendSmsResponse
.
getMessage
());
}
return
result
;
}
catch
(
Exception
e
){
log
.
error
(
"发送短信失败"
,
e
);
}
}
return
result
;
return
null
;
}
}
}
}
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