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
c9c60799
Commit
c9c60799
authored
2 years ago
by
张新旗
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码提交
parent
87485666
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
542 additions
and
35 deletions
+542
-35
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
+2
-1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/coffee/WeixinController.java
+4
-4
ruoyi-admin/src/main/resources/application.yml
+1
-1
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
+1
-1
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/WeixinServiceImpl.java
+44
-0
ruoyi-system/src/main/java/com/ruoyi/system/domain/Order.java
+6
-8
ruoyi-system/src/main/java/com/ruoyi/system/domain/OrderDetail.java
+4
-4
ruoyi-system/src/main/java/com/ruoyi/system/domain/OrderOperationLog.java
+123
-0
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/orderTaking/SkuVo.java
+2
-2
ruoyi-system/src/main/java/com/ruoyi/system/mapper/OrderOperationLogMapper.java
+61
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/IOrderOperationLogService.java
+61
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MachineApiServiceImpl.java
+45
-8
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderOperationLogServiceImpl.java
+93
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java
+13
-6
ruoyi-system/src/main/resources/mapper/system/OrderOperationLogMapper.xml
+82
-0
No files found.
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
View file @
c9c60799
...
@@ -21,6 +21,7 @@ public class RuoYiApplication
...
@@ -21,6 +21,7 @@ public class RuoYiApplication
}
}
@Bean
@Bean
public
RestTemplate
restTemplate
(){
public
RestTemplate
restTemplate
(){
return
new
RestTemplate
();
RestTemplate
restTemplate
=
new
RestTemplate
();
return
restTemplate
;
}
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/coffee/WeixinController.java
View file @
c9c60799
...
@@ -2,6 +2,8 @@ package com.ruoyi.web.controller.coffee;
...
@@ -2,6 +2,8 @@ package com.ruoyi.web.controller.coffee;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse
;
import
com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse
;
import
com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult
;
import
com.github.binarywang.wxpay.exception.WxPayException
;
import
com.github.wxpay.sdk.WXPayUtil
;
import
com.github.wxpay.sdk.WXPayUtil
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.domain.AjaxResult
;
...
@@ -89,9 +91,7 @@ public class WeixinController {
...
@@ -89,9 +91,7 @@ public class WeixinController {
*/
*/
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/refundNotify"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/refundNotify"
)
public
String
refundNotify
(
@RequestBody
String
xmlData
)
{
public
String
refundNotify
(
@RequestBody
String
xmlData
)
{
// 实现自己的逻辑
return
weixinService
.
refundNotify
(
xmlData
);
//
// 必须要返回 SUCCESS 不过有 WxPayNotifyResponse 给整合成了 xml了
return
WxPayNotifyResponse
.
success
(
"成功"
);
}
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-admin/src/main/resources/application.yml
View file @
c9c60799
...
@@ -158,4 +158,4 @@ push:
...
@@ -158,4 +158,4 @@ push:
appkey
:
123
appkey
:
123
secret
:
123
secret
:
123
machine
:
machine
:
url
:
http://47.94.24
7
.71:10003
url
:
http://47.94.24
1
.71:10003
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
View file @
c9c60799
...
@@ -97,7 +97,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
...
@@ -97,7 +97,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求
// 过滤请求
.
authorizeRequests
()
.
authorizeRequests
()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
.
antMatchers
(
"/login"
,
"/register"
,
"/captchaImage"
,
"/weixin/**"
,
"/application/**"
).
anonymous
()
.
antMatchers
(
"/login"
,
"/register"
,
"/captchaImage"
,
"/weixin/**"
,
"/application/**"
,
"/v1/**"
,
"/tool/**"
).
anonymous
()
.
antMatchers
(
.
antMatchers
(
HttpMethod
.
GET
,
HttpMethod
.
GET
,
"/"
,
"/"
,
...
...
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/WeixinServiceImpl.java
View file @
c9c60799
...
@@ -3,6 +3,8 @@ package com.ruoyi.framework.web.service;
...
@@ -3,6 +3,8 @@ package com.ruoyi.framework.web.service;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse
;
import
com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult
;
import
com.github.binarywang.wxpay.bean.request.WxPayRefundRequest
;
import
com.github.binarywang.wxpay.bean.request.WxPayRefundRequest
;
import
com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest
;
import
com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest
;
import
com.github.binarywang.wxpay.bean.result.WxPayRefundResult
;
import
com.github.binarywang.wxpay.bean.result.WxPayRefundResult
;
...
@@ -25,9 +27,12 @@ import com.ruoyi.common.utils.sign.Base64;
...
@@ -25,9 +27,12 @@ import com.ruoyi.common.utils.sign.Base64;
import
com.ruoyi.framework.web.domain.server.Sys
;
import
com.ruoyi.framework.web.domain.server.Sys
;
import
com.ruoyi.system.domain.Customer
;
import
com.ruoyi.system.domain.Customer
;
import
com.ruoyi.system.domain.Order
;
import
com.ruoyi.system.domain.Order
;
import
com.ruoyi.system.domain.OrderOperationLog
;
import
com.ruoyi.system.mapper.CustomerMapper
;
import
com.ruoyi.system.mapper.CustomerMapper
;
import
com.ruoyi.system.mapper.OrderMapper
;
import
com.ruoyi.system.mapper.OrderMapper
;
import
com.ruoyi.system.service.impl.MachineApiServiceImpl
;
import
com.ruoyi.system.service.impl.OrderOperationLogServiceImpl
;
import
com.ruoyi.system.weixin.entity.OrderInfo
;
import
com.ruoyi.system.weixin.entity.OrderInfo
;
import
com.ruoyi.system.weixin.entity.OrderReturnInfo
;
import
com.ruoyi.system.weixin.entity.OrderReturnInfo
;
import
com.ruoyi.system.weixin.entity.QueryReturnInfo
;
import
com.ruoyi.system.weixin.entity.QueryReturnInfo
;
...
@@ -92,6 +97,10 @@ public class WeixinServiceImpl {
...
@@ -92,6 +97,10 @@ public class WeixinServiceImpl {
private
TokenService
tokenService
;
private
TokenService
tokenService
;
@Autowired
@Autowired
private
OrderMapper
orderMapper
;
private
OrderMapper
orderMapper
;
@Autowired
private
OrderOperationLogServiceImpl
orderOperationLogService
;
@Autowired
private
MachineApiServiceImpl
machineApiService
;
private
final
ReentrantLock
lock
=
new
ReentrantLock
();
private
final
ReentrantLock
lock
=
new
ReentrantLock
();
...
@@ -413,6 +422,15 @@ public class WeixinServiceImpl {
...
@@ -413,6 +422,15 @@ public class WeixinServiceImpl {
jsonObject
.
put
(
"userId"
,
order
.
getUserId
());
jsonObject
.
put
(
"userId"
,
order
.
getUserId
());
order1
.
setPickCode
(
QRCodeUtil
.
getBase64QRCode
(
jsonObject
.
toJSONString
()));
order1
.
setPickCode
(
QRCodeUtil
.
getBase64QRCode
(
jsonObject
.
toJSONString
()));
orderMapper
.
updateOrder
(
order1
);
orderMapper
.
updateOrder
(
order1
);
OrderOperationLog
orderOperationLog
=
new
OrderOperationLog
();
orderOperationLog
.
setOrderId
(
String
.
valueOf
(
order
.
getId
()));
orderOperationLog
.
setOperation
(
"付款"
);
orderOperationLog
.
setOperationUser
(
order
.
getUserName
());
orderOperationLog
.
setCreateAt
(
new
Date
());
orderOperationLog
.
setContent
(
"付款成功"
);
orderOperationLog
.
setStatus
(
"付款"
);
orderOperationLogService
.
insertOrderOperationLog
(
orderOperationLog
);
machineApiService
.
updateOrder
(
order1
);
}
}
...
@@ -456,4 +474,30 @@ public class WeixinServiceImpl {
...
@@ -456,4 +474,30 @@ public class WeixinServiceImpl {
}
}
}
}
}
}
public
String
refundNotify
(
String
xmlData
)
{
WxPayRefundNotifyResult
wxPayRefundNotifyResult
;
try
{
wxPayRefundNotifyResult
=
wxPayService
.
parseRefundNotifyResult
(
xmlData
);
}
catch
(
WxPayException
e
)
{
log
.
error
(
"退款失败,失败信息:{}"
,
e
);
return
WxPayNotifyResponse
.
fail
(
"退款失败"
);
}
//判断你返回状态信息是否正确
if
(
"SUCCESS"
.
equals
(
wxPayRefundNotifyResult
.
getReturnCode
()))
{
WxPayRefundNotifyResult
.
ReqInfo
reqInfo
=
wxPayRefundNotifyResult
.
getReqInfo
();
reqInfo
.
getOutRefundNo
();
//判断退款状态
// if (REFUND_SUCCESS.equals(reqInfo.getRefundStatus())) {
// //内部订单号
// String outTradeNo = reqInfo.getOutTradeNo();
// /**
// * 一、可能会重复回调,需要做防重判断
// * 二、处理我们系统内部业务,做修改订单状态,释放资源等!
// */
// return WxPayNotifyResponse.success("退款成功!");
// }
}
return
WxPayNotifyResponse
.
fail
(
"回调有误!"
);
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/system/domain/Order.java
View file @
c9c60799
...
@@ -22,7 +22,7 @@ public class Order implements Serializable
...
@@ -22,7 +22,7 @@ public class Order implements Serializable
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/** 主键 */
/** 主键 */
private
Stri
ng
id
;
private
lo
ng
id
;
/** 订单号 */
/** 订单号 */
@Excel
(
name
=
"订单号"
)
@Excel
(
name
=
"订单号"
)
...
@@ -78,7 +78,6 @@ public class Order implements Serializable
...
@@ -78,7 +78,6 @@ public class Order implements Serializable
@Excel
(
name
=
"点单屏序号"
)
@Excel
(
name
=
"点单屏序号"
)
private
String
source
;
private
String
source
;
/** 订单状态 0 创建未校验 1 未支付 2 已支付 3 支付制作中 4 制作完成未取 5 待取超时 6 正常完成 7 未支付取消 8 支付后制作前取消 9 制作中取消 10 制作完成取消 11 已退款 12 部分退款 50 其他人工干预状态 */
@Excel
(
name
=
"订单状态 0 未支付取消 1 未支付 2 已支付 3 待制作 4 支付制作中 5 制作完成未取 6 取餐中 7 取餐完成 8 支付后制作前取消 9 制作中取消 10 制作完成取消 11 已退款 12 部分退款 50 其他人工干预状态"
)
@Excel
(
name
=
"订单状态 0 未支付取消 1 未支付 2 已支付 3 待制作 4 支付制作中 5 制作完成未取 6 取餐中 7 取餐完成 8 支付后制作前取消 9 制作中取消 10 制作完成取消 11 已退款 12 部分退款 50 其他人工干预状态"
)
private
String
state
;
private
String
state
;
...
@@ -112,15 +111,14 @@ public class Order implements Serializable
...
@@ -112,15 +111,14 @@ public class Order implements Serializable
this
.
orderDetails
=
orderDetails
;
this
.
orderDetails
=
orderDetails
;
}
}
public
void
setId
(
String
id
)
public
long
getId
()
{
{
return
id
;
this
.
id
=
id
;
}
}
public
String
getId
()
public
void
setId
(
long
id
)
{
{
this
.
id
=
id
;
return
id
;
}
}
public
void
setOrderNo
(
String
orderNo
)
public
void
setOrderNo
(
String
orderNo
)
{
{
this
.
orderNo
=
orderNo
;
this
.
orderNo
=
orderNo
;
...
...
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/system/domain/OrderDetail.java
View file @
c9c60799
...
@@ -24,7 +24,7 @@ public class OrderDetail implements Serializable
...
@@ -24,7 +24,7 @@ public class OrderDetail implements Serializable
/** 订单ID */
/** 订单ID */
@Excel
(
name
=
"订单ID"
)
@Excel
(
name
=
"订单ID"
)
private
Stri
ng
orderId
;
private
lo
ng
orderId
;
/** 商品ID */
/** 商品ID */
@Excel
(
name
=
"商品ID"
)
@Excel
(
name
=
"商品ID"
)
...
@@ -77,7 +77,7 @@ public class OrderDetail implements Serializable
...
@@ -77,7 +77,7 @@ public class OrderDetail implements Serializable
private
Goods
goods
;
private
Goods
goods
;
/** 创建时间 */
/** 创建时间 */
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd
"
)
@Excel
(
name
=
"创建时间"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd"
)
@Excel
(
name
=
"创建时间"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd"
)
private
Date
createdAt
;
private
Date
createdAt
;
...
@@ -95,12 +95,12 @@ public class OrderDetail implements Serializable
...
@@ -95,12 +95,12 @@ public class OrderDetail implements Serializable
{
{
return
id
;
return
id
;
}
}
public
void
setOrderId
(
String
orderId
)
public
void
setOrderId
(
long
orderId
)
{
{
this
.
orderId
=
orderId
;
this
.
orderId
=
orderId
;
}
}
public
String
getOrderId
()
public
long
getOrderId
()
{
{
return
orderId
;
return
orderId
;
}
}
...
...
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/system/domain/OrderOperationLog.java
0 → 100644
View file @
c9c60799
package
com
.
ruoyi
.
system
.
domain
;
import
java.util.Date
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
com.ruoyi.common.annotation.Excel
;
import
com.ruoyi.common.core.domain.BaseEntity
;
/**
* 【请填写功能名称】对象 order_operation_log
*
* @author ruoyi
* @date 2022-05-17
*/
public
class
OrderOperationLog
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
/** $column.columnComment */
private
String
id
;
/** $column.columnComment */
@Excel
(
name
=
"${comment}"
,
readConverterExp
=
"$column.readConverterExp()"
)
private
String
status
;
/** $column.columnComment */
@Excel
(
name
=
"${comment}"
,
readConverterExp
=
"$column.readConverterExp()"
)
private
String
operation
;
/** $column.columnComment */
@Excel
(
name
=
"${comment}"
,
readConverterExp
=
"$column.readConverterExp()"
)
private
Date
createAt
;
/** $column.columnComment */
@Excel
(
name
=
"${comment}"
,
readConverterExp
=
"$column.readConverterExp()"
)
private
String
operationUser
;
/** $column.columnComment */
@Excel
(
name
=
"${comment}"
,
readConverterExp
=
"$column.readConverterExp()"
)
private
String
content
;
/** $column.columnComment */
@Excel
(
name
=
"${comment}"
,
readConverterExp
=
"$column.readConverterExp()"
)
private
String
orderId
;
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getId
()
{
return
id
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setOperation
(
String
operation
)
{
this
.
operation
=
operation
;
}
public
String
getOperation
()
{
return
operation
;
}
public
void
setCreateAt
(
Date
createAt
)
{
this
.
createAt
=
createAt
;
}
public
Date
getCreateAt
()
{
return
createAt
;
}
public
void
setOperationUser
(
String
operationUser
)
{
this
.
operationUser
=
operationUser
;
}
public
String
getOperationUser
()
{
return
operationUser
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setOrderId
(
String
orderId
)
{
this
.
orderId
=
orderId
;
}
public
String
getOrderId
()
{
return
orderId
;
}
@Override
public
String
toString
()
{
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
.
append
(
"id"
,
getId
())
.
append
(
"status"
,
getStatus
())
.
append
(
"operation"
,
getOperation
())
.
append
(
"createAt"
,
getCreateAt
())
.
append
(
"operationUser"
,
getOperationUser
())
.
append
(
"content"
,
getContent
())
.
append
(
"orderId"
,
getOrderId
())
.
toString
();
}
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/orderTaking/SkuVo.java
View file @
c9c60799
...
@@ -66,11 +66,11 @@ public class SkuVo implements Serializable {
...
@@ -66,11 +66,11 @@ public class SkuVo implements Serializable {
this
.
rulesString
=
rulesString
;
this
.
rulesString
=
rulesString
;
}
}
public
String
getDis
C
ount
()
{
public
String
getDis
c
ount
()
{
return
discount
;
return
discount
;
}
}
public
void
setDis
C
ount
(
String
discount
)
{
public
void
setDis
c
ount
(
String
discount
)
{
this
.
discount
=
discount
;
this
.
discount
=
discount
;
}
}
...
...
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/system/mapper/OrderOperationLogMapper.java
0 → 100644
View file @
c9c60799
package
com
.
ruoyi
.
system
.
mapper
;
import
java.util.List
;
import
com.ruoyi.system.domain.OrderOperationLog
;
/**
* 【请填写功能名称】Mapper接口
*
* @author ruoyi
* @date 2022-05-17
*/
public
interface
OrderOperationLogMapper
{
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
public
OrderOperationLog
selectOrderOperationLogById
(
String
id
);
/**
* 查询【请填写功能名称】列表
*
* @param orderOperationLog 【请填写功能名称】
* @return 【请填写功能名称】集合
*/
public
List
<
OrderOperationLog
>
selectOrderOperationLogList
(
OrderOperationLog
orderOperationLog
);
/**
* 新增【请填写功能名称】
*
* @param orderOperationLog 【请填写功能名称】
* @return 结果
*/
public
int
insertOrderOperationLog
(
OrderOperationLog
orderOperationLog
);
/**
* 修改【请填写功能名称】
*
* @param orderOperationLog 【请填写功能名称】
* @return 结果
*/
public
int
updateOrderOperationLog
(
OrderOperationLog
orderOperationLog
);
/**
* 删除【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 结果
*/
public
int
deleteOrderOperationLogById
(
String
id
);
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public
int
deleteOrderOperationLogByIds
(
String
[]
ids
);
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/system/service/IOrderOperationLogService.java
0 → 100644
View file @
c9c60799
package
com
.
ruoyi
.
system
.
service
;
import
java.util.List
;
import
com.ruoyi.system.domain.OrderOperationLog
;
/**
* 【请填写功能名称】Service接口
*
* @author ruoyi
* @date 2022-05-17
*/
public
interface
IOrderOperationLogService
{
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
public
OrderOperationLog
selectOrderOperationLogById
(
String
id
);
/**
* 查询【请填写功能名称】列表
*
* @param orderOperationLog 【请填写功能名称】
* @return 【请填写功能名称】集合
*/
public
List
<
OrderOperationLog
>
selectOrderOperationLogList
(
OrderOperationLog
orderOperationLog
);
/**
* 新增【请填写功能名称】
*
* @param orderOperationLog 【请填写功能名称】
* @return 结果
*/
public
int
insertOrderOperationLog
(
OrderOperationLog
orderOperationLog
);
/**
* 修改【请填写功能名称】
*
* @param orderOperationLog 【请填写功能名称】
* @return 结果
*/
public
int
updateOrderOperationLog
(
OrderOperationLog
orderOperationLog
);
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的【请填写功能名称】主键集合
* @return 结果
*/
public
int
deleteOrderOperationLogByIds
(
String
[]
ids
);
/**
* 删除【请填写功能名称】信息
*
* @param id 【请填写功能名称】主键
* @return 结果
*/
public
int
deleteOrderOperationLogById
(
String
id
);
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MachineApiServiceImpl.java
View file @
c9c60799
package
com
.
ruoyi
.
system
.
service
.
impl
;
package
com
.
ruoyi
.
system
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.ruoyi.common.exception.ServiceException
;
import
com.ruoyi.common.exception.ServiceException
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.system.domain.*
;
import
com.ruoyi.system.domain.*
;
...
@@ -9,6 +10,9 @@ import com.ruoyi.system.mapper.*;
...
@@ -9,6 +10,9 @@ import com.ruoyi.system.mapper.*;
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.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
...
@@ -27,7 +31,7 @@ public class MachineApiServiceImpl {
...
@@ -27,7 +31,7 @@ public class MachineApiServiceImpl {
private
ShopGoodsSkuMapper
shopGoodsSkuMapper
;
private
ShopGoodsSkuMapper
shopGoodsSkuMapper
;
@Autowired
@Autowired
private
OrderDetailMapper
orderDetailMapper
;
private
OrderDetailMapper
orderDetailMapper
;
@Value
(
"
machine.url
"
)
@Value
(
"
${machine.url}
"
)
private
String
url
;
private
String
url
;
@Autowired
@Autowired
private
RestTemplate
restTemplate
;
private
RestTemplate
restTemplate
;
...
@@ -45,7 +49,7 @@ public class MachineApiServiceImpl {
...
@@ -45,7 +49,7 @@ public class MachineApiServiceImpl {
}
}
public
String
updateOrder
(
JSONObject
jsonObject
)
{
public
String
updateOrder
(
JSONObject
jsonObject
)
{
String
orderID
=
jsonObject
.
getStri
ng
(
"orderId"
);
long
orderID
=
jsonObject
.
getLo
ng
(
"orderId"
);
String
status
=
jsonObject
.
getString
(
"status"
);
String
status
=
jsonObject
.
getString
(
"status"
);
Order
order
=
new
Order
();
Order
order
=
new
Order
();
order
.
setId
(
orderID
);
order
.
setId
(
orderID
);
...
@@ -56,6 +60,7 @@ public class MachineApiServiceImpl {
...
@@ -56,6 +60,7 @@ public class MachineApiServiceImpl {
}
}
public
void
testOrder
(
String
orderId
)
{
public
void
testOrder
(
String
orderId
)
{
try
{
if
(
StringUtils
.
isEmpty
(
orderId
)){
if
(
StringUtils
.
isEmpty
(
orderId
)){
orderId
=
"8"
;
orderId
=
"8"
;
}
}
...
@@ -64,8 +69,9 @@ public class MachineApiServiceImpl {
...
@@ -64,8 +69,9 @@ public class MachineApiServiceImpl {
orderDetail
.
setOrderId
(
order
.
getId
());
orderDetail
.
setOrderId
(
order
.
getId
());
List
<
OrderDetail
>
orderDetails
=
orderDetailMapper
.
selectOrderDetailList
(
orderDetail
);
List
<
OrderDetail
>
orderDetails
=
orderDetailMapper
.
selectOrderDetailList
(
orderDetail
);
order
.
setOrderDetails
(
orderDetails
);
order
.
setOrderDetails
(
orderDetails
);
String
orderInfo
=
JSONObject
.
toJSONString
(
order
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
ResultVo
resultVo
=
createOrder
(
orderInfo
,
"/v1/order"
);
String
orderInfo
=
objectMapper
.
writeValueAsString
(
order
);
ResultVo
resultVo
=
sendRequest
(
orderInfo
,
"/v1/order"
);
String
code
=
resultVo
.
getCode
();
String
code
=
resultVo
.
getCode
();
if
(
"2001"
.
equals
(
code
)){
if
(
"2001"
.
equals
(
code
)){
...
@@ -73,17 +79,44 @@ public class MachineApiServiceImpl {
...
@@ -73,17 +79,44 @@ public class MachineApiServiceImpl {
}
else
if
(
"3001"
.
equals
(
code
)){
}
else
if
(
"3001"
.
equals
(
code
)){
throw
new
ServiceException
(
"机器繁忙"
);
throw
new
ServiceException
(
"机器繁忙"
);
}
}
}
catch
(
Exception
e
){
log
.
error
(
""
,
e
);
}
}
}
public
ResultVo
createOrder
(
Order
order
){
String
orderInfo
=
null
;
try
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
orderInfo
=
objectMapper
.
writeValueAsString
(
order
);
}
catch
(
Exception
e
){
throw
new
ServiceException
(
"初始订单数据异常,请重试"
);
}
ResultVo
resultVo
=
sendRequest
(
orderInfo
,
"/v1/order"
);
public
ResultVo
createOrder
(
String
param
,
String
interfaceName
){
String
code
=
resultVo
.
getCode
();
if
(
"2001"
.
equals
(
code
)){
throw
new
ServiceException
(
"库存不足"
);
}
else
if
(
"3001"
.
equals
(
code
)){
throw
new
ServiceException
(
"机器繁忙"
);
}
return
resultVo
;
}
public
ResultVo
sendRequest
(
String
param
,
String
interfaceName
){
try
{
try
{
String
postUrl
=
url
+
interfaceName
;
String
postUrl
=
url
+
interfaceName
;
log
.
info
(
"请求创建订单接口:【{}】"
,
param
);
log
.
info
(
"请求创建订单接口:【{}】"
,
param
);
ResponseEntity
<
String
>
stringResponseEntity
=
restTemplate
.
postForEntity
(
postUrl
,
param
,
String
.
class
);
HttpHeaders
requestHeaders
=
new
HttpHeaders
();
requestHeaders
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
HttpEntity
requestEntity
=
new
HttpEntity
(
param
,
requestHeaders
);
ResponseEntity
<
String
>
stringResponseEntity
=
restTemplate
.
postForEntity
(
postUrl
,
requestEntity
,
String
.
class
);
log
.
info
(
"请求创建订单接口返回结果为:【{}】"
,
stringResponseEntity
.
getBody
());
log
.
info
(
"请求创建订单接口返回结果为:【{}】"
,
stringResponseEntity
.
getBody
());
ResultVo
resultVo
=
JSONObject
.
parseObject
(
stringResponseEntity
.
getBody
(),
ResultVo
.
class
);
ResultVo
resultVo
=
JSONObject
.
parseObject
(
stringResponseEntity
.
getBody
(),
ResultVo
.
class
);
return
resultVo
;
return
resultVo
;
...
@@ -104,7 +137,7 @@ public class MachineApiServiceImpl {
...
@@ -104,7 +137,7 @@ public class MachineApiServiceImpl {
data
.
put
(
"payTime"
,
new
Date
());
data
.
put
(
"payTime"
,
new
Date
());
param
.
put
(
"data"
,
data
);
param
.
put
(
"data"
,
data
);
param
.
put
(
"orderId"
,
orderId
);
param
.
put
(
"orderId"
,
orderId
);
createOrder
(
param
.
toJSONString
(),
"/v1/order/update"
);
sendRequest
(
param
.
toJSONString
(),
"/v1/order/update"
);
}
}
public
Object
robotUpdate
(
JSONObject
jsonObject
)
{
public
Object
robotUpdate
(
JSONObject
jsonObject
)
{
...
@@ -123,4 +156,8 @@ public class MachineApiServiceImpl {
...
@@ -123,4 +156,8 @@ public class MachineApiServiceImpl {
}
}
public
void
updateOrder
(
Order
order1
)
{
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderOperationLogServiceImpl.java
0 → 100644
View file @
c9c60799
package
com
.
ruoyi
.
system
.
service
.
impl
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.system.mapper.OrderOperationLogMapper
;
import
com.ruoyi.system.domain.OrderOperationLog
;
import
com.ruoyi.system.service.IOrderOperationLogService
;
/**
* 【请填写功能名称】Service业务层处理
*
* @author ruoyi
* @date 2022-05-17
*/
@Service
public
class
OrderOperationLogServiceImpl
implements
IOrderOperationLogService
{
@Autowired
private
OrderOperationLogMapper
orderOperationLogMapper
;
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
@Override
public
OrderOperationLog
selectOrderOperationLogById
(
String
id
)
{
return
orderOperationLogMapper
.
selectOrderOperationLogById
(
id
);
}
/**
* 查询【请填写功能名称】列表
*
* @param orderOperationLog 【请填写功能名称】
* @return 【请填写功能名称】
*/
@Override
public
List
<
OrderOperationLog
>
selectOrderOperationLogList
(
OrderOperationLog
orderOperationLog
)
{
return
orderOperationLogMapper
.
selectOrderOperationLogList
(
orderOperationLog
);
}
/**
* 新增【请填写功能名称】
*
* @param orderOperationLog 【请填写功能名称】
* @return 结果
*/
@Override
public
int
insertOrderOperationLog
(
OrderOperationLog
orderOperationLog
)
{
return
orderOperationLogMapper
.
insertOrderOperationLog
(
orderOperationLog
);
}
/**
* 修改【请填写功能名称】
*
* @param orderOperationLog 【请填写功能名称】
* @return 结果
*/
@Override
public
int
updateOrderOperationLog
(
OrderOperationLog
orderOperationLog
)
{
return
orderOperationLogMapper
.
updateOrderOperationLog
(
orderOperationLog
);
}
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的【请填写功能名称】主键
* @return 结果
*/
@Override
public
int
deleteOrderOperationLogByIds
(
String
[]
ids
)
{
return
orderOperationLogMapper
.
deleteOrderOperationLogByIds
(
ids
);
}
/**
* 删除【请填写功能名称】信息
*
* @param id 【请填写功能名称】主键
* @return 结果
*/
@Override
public
int
deleteOrderOperationLogById
(
String
id
)
{
return
orderOperationLogMapper
.
deleteOrderOperationLogById
(
id
);
}
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java
View file @
c9c60799
...
@@ -11,9 +11,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
...
@@ -11,9 +11,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import
com.ruoyi.common.core.domain.model.LoginUser
;
import
com.ruoyi.common.core.domain.model.LoginUser
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.system.domain.Machine
;
import
com.ruoyi.system.domain.*
;
import
com.ruoyi.system.domain.OrderDetail
;
import
com.ruoyi.system.domain.ShopGoodsSku
;
import
com.ruoyi.system.service.IOrderService
;
import
com.ruoyi.system.service.IOrderService
;
import
com.ruoyi.system.domain.vo.OrderQuery
;
import
com.ruoyi.system.domain.vo.OrderQuery
;
import
com.ruoyi.system.mapper.*
;
import
com.ruoyi.system.mapper.*
;
...
@@ -21,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -21,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.support.atomic.RedisAtomicInteger
;
import
org.springframework.data.redis.support.atomic.RedisAtomicInteger
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.system.domain.Order
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
/**
/**
...
@@ -44,9 +41,11 @@ public class OrderServiceImpl implements IOrderService
...
@@ -44,9 +41,11 @@ public class OrderServiceImpl implements IOrderService
@Autowired
@Autowired
private
MachineMapper
machineMapper
;
private
MachineMapper
machineMapper
;
@Autowired
@Autowired
private
RobotServiceImpl
robot
Service
;
private
MachineApiServiceImpl
machineApi
Service
;
@Autowired
@Autowired
private
ShopMapper
shopMapper
;
private
ShopMapper
shopMapper
;
@Autowired
private
OrderOperationLogServiceImpl
orderOperationLogService
;
...
@@ -130,7 +129,15 @@ public class OrderServiceImpl implements IOrderService
...
@@ -130,7 +129,15 @@ public class OrderServiceImpl implements IOrderService
}
}
}
}
//发送数据给机器
//发送数据给机器
//robotService.createOrder(order);
machineApiService
.
createOrder
(
order
);
OrderOperationLog
orderOperationLog
=
new
OrderOperationLog
();
orderOperationLog
.
setOrderId
(
String
.
valueOf
(
order
.
getId
()));
orderOperationLog
.
setOperation
(
"创建订单"
);
orderOperationLog
.
setOperationUser
(
order
.
getUserName
());
orderOperationLog
.
setCreateAt
(
new
Date
());
orderOperationLog
.
setContent
(
"创建了订单"
);
orderOperationLog
.
setStatus
(
"待付款"
);
orderOperationLogService
.
insertOrderOperationLog
(
orderOperationLog
);
return
AjaxResult
.
success
(
order
.
getOrderNo
());
return
AjaxResult
.
success
(
order
.
getOrderNo
());
}
}
...
...
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/resources/mapper/system/OrderOperationLogMapper.xml
0 → 100644
View file @
c9c60799
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.ruoyi.system.mapper.OrderOperationLogMapper"
>
<resultMap
type=
"OrderOperationLog"
id=
"OrderOperationLogResult"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"operation"
column=
"operation"
/>
<result
property=
"createAt"
column=
"create_at"
/>
<result
property=
"operationUser"
column=
"operation_user"
/>
<result
property=
"content"
column=
"content"
/>
<result
property=
"orderId"
column=
"order_id"
/>
</resultMap>
<sql
id=
"selectOrderOperationLogVo"
>
select id, status, operation, create_at, operation_user, content, order_id from order_operation_log
</sql>
<select
id=
"selectOrderOperationLogList"
parameterType=
"OrderOperationLog"
resultMap=
"OrderOperationLogResult"
>
<include
refid=
"selectOrderOperationLogVo"
/>
<where>
<if
test=
"status != null and status != ''"
>
and status = #{status}
</if>
<if
test=
"operation != null and operation != ''"
>
and operation = #{operation}
</if>
<if
test=
"createAt != null "
>
and create_at = #{createAt}
</if>
<if
test=
"operationUser != null and operationUser != ''"
>
and operation_user = #{operationUser}
</if>
<if
test=
"content != null and content != ''"
>
and content = #{content}
</if>
<if
test=
"orderId != null and orderId != ''"
>
and order_id = #{orderId}
</if>
</where>
</select>
<select
id=
"selectOrderOperationLogById"
parameterType=
"String"
resultMap=
"OrderOperationLogResult"
>
<include
refid=
"selectOrderOperationLogVo"
/>
where id = #{id}
</select>
<insert
id=
"insertOrderOperationLog"
parameterType=
"OrderOperationLog"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into order_operation_log
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"status != null and status != ''"
>
status,
</if>
<if
test=
"operation != null and operation != ''"
>
operation,
</if>
<if
test=
"createAt != null"
>
create_at,
</if>
<if
test=
"operationUser != null and operationUser != ''"
>
operation_user,
</if>
<if
test=
"content != null and content != ''"
>
content,
</if>
<if
test=
"orderId != null"
>
order_id,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"status != null and status != ''"
>
#{status},
</if>
<if
test=
"operation != null and operation != ''"
>
#{operation},
</if>
<if
test=
"createAt != null"
>
#{createAt},
</if>
<if
test=
"operationUser != null and operationUser != ''"
>
#{operationUser},
</if>
<if
test=
"content != null and content != ''"
>
#{content},
</if>
<if
test=
"orderId != null"
>
#{orderId},
</if>
</trim>
</insert>
<update
id=
"updateOrderOperationLog"
parameterType=
"OrderOperationLog"
>
update order_operation_log
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"status != null and status != ''"
>
status = #{status},
</if>
<if
test=
"operation != null and operation != ''"
>
operation = #{operation},
</if>
<if
test=
"createAt != null"
>
create_at = #{createAt},
</if>
<if
test=
"operationUser != null and operationUser != ''"
>
operation_user = #{operationUser},
</if>
<if
test=
"content != null and content != ''"
>
content = #{content},
</if>
<if
test=
"orderId != null"
>
order_id = #{orderId},
</if>
</trim>
where id = #{id}
</update>
<delete
id=
"deleteOrderOperationLogById"
parameterType=
"String"
>
delete from order_operation_log where id = #{id}
</delete>
<delete
id=
"deleteOrderOperationLogByIds"
parameterType=
"String"
>
delete from order_operation_log where id in
<foreach
item=
"id"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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