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
f45e0f2a
Commit
f45e0f2a
authored
Jul 11, 2022
by
weijiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下单时校验订单中sku数量
parent
ff201708
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
45 deletions
+36
-45
soss-admin/src/main/java/com/soss/web/controller/coffee/OrderController.java
+32
-45
soss-framework/src/main/java/com/soss/framework/web/service/TokenService.java
+4
-0
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
+0
-0
No files found.
soss-admin/src/main/java/com/soss/web/controller/coffee/OrderController.java
View file @
f45e0f2a
package
com
.
soss
.
web
.
controller
.
coffee
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
com.soss.common.annotation.Log
;
import
com.soss.common.constant.HttpStatus
;
import
com.soss.common.core.controller.BaseController
;
import
com.soss.common.core.domain.AjaxResult
;
import
com.soss.common.core.domain.model.LoginUser
;
import
com.soss.common.core.page.TableDataInfo
;
import
com.soss.common.enums.BusinessType
;
import
com.soss.common.exception.ServiceException
;
import
com.soss.framework.web.service.TokenService
;
import
com.soss.framework.web.service.WeixinServiceImpl
;
import
com.soss.system.domain.Order
;
import
com.soss.system.domain.vo.OrderQuery
;
import
com.soss.system.service.impl.CustomerServiceImpl
;
import
com.soss.system.service.impl.OrderServiceImpl
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.soss.common.annotation.Log
;
import
com.soss.common.core.controller.BaseController
;
import
com.soss.common.core.domain.AjaxResult
;
import
com.soss.common.enums.BusinessType
;
import
com.soss.system.domain.Order
;
import
com.soss.system.service.IOrderService
;
import
com.soss.common.core.page.TableDataInfo
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
/**
* 订单Controller
*
*
* @author zxq
* @date 2022-04-28
*/
@RestController
@RequestMapping
(
"/order"
)
public
class
OrderController
extends
BaseController
{
public
class
OrderController
extends
BaseController
{
@Autowired
private
OrderServiceImpl
orderService
;
@Autowired
...
...
@@ -51,8 +42,7 @@ public class OrderController extends BaseController
*/
@PreAuthorize
(
"@ss.hasPermi('system:order:list')"
)
@GetMapping
(
"/list"
)
public
TableDataInfo
list
(
OrderQuery
orderQuery
)
{
public
TableDataInfo
list
(
OrderQuery
orderQuery
)
{
startPage
();
List
<
Order
>
list
=
orderService
.
selectOrderList
(
orderQuery
);
return
getDataTable
(
list
);
...
...
@@ -63,15 +53,13 @@ public class OrderController extends BaseController
* 获取订单详细信息
*/
@GetMapping
(
value
=
"/{id}"
)
public
AjaxResult
getInfo
(
@PathVariable
(
"id"
)
String
id
)
{
public
AjaxResult
getInfo
(
@PathVariable
(
"id"
)
String
id
)
{
return
AjaxResult
.
success
(
orderService
.
selectOrderById
(
id
));
}
@PostMapping
(
"/check"
)
public
AjaxResult
check
(
@RequestBody
Order
order
)
{
public
AjaxResult
check
(
@RequestBody
Order
order
)
{
return
orderService
.
check
(
order
);
}
...
...
@@ -80,34 +68,34 @@ public class OrderController extends BaseController
*/
@Log
(
title
=
"订单"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
public
AjaxResult
add
(
HttpServletRequest
request
,
@RequestBody
Order
order
)
{
public
AjaxResult
add
(
HttpServletRequest
request
,
@RequestBody
Order
order
)
{
LoginUser
loginUser
=
tokenService
.
getLoginUser
(
request
);
AjaxResult
ajaxResult
=
orderService
.
insertOrder
(
loginUser
,
order
);
if
(
HttpStatus
.
SUCCESS
!=
(
int
)
ajaxResult
.
get
(
AjaxResult
.
CODE_TAG
)){
return
ajaxResult
;
AjaxResult
ajaxResult
=
orderService
.
insertOrder
(
loginUser
,
order
);
if
(
HttpStatus
.
SUCCESS
!=
(
int
)
ajaxResult
.
get
(
AjaxResult
.
CODE_TAG
))
{
return
ajaxResult
;
}
int
amount
=
order
.
getAmount
().
movePointRight
(
2
).
intValue
();
Map
payInfo
=
weixinService
.
pay
(
request
,
"hooloo"
,
order
.
getOrderNo
(),
order
.
getUserId
(),
amount
);
if
(
payInfo
!=
null
)
{
payInfo
.
put
(
"orderId"
,
order
.
getId
());
if
(
payInfo
!=
null
)
{
payInfo
.
put
(
"orderId"
,
order
.
getId
());
return
AjaxResult
.
success
(
payInfo
);
}
else
{
}
else
{
throw
new
ServiceException
(
"微信支付发生异常"
);
}
}
@RequestMapping
(
"/payOrder"
)
public
AjaxResult
cancel
(
HttpServletRequest
request
,
String
orderId
)
{
public
AjaxResult
cancel
(
HttpServletRequest
request
,
String
orderId
)
{
Order
order
=
orderService
.
selectOrderById
(
orderId
);
order
.
setOrderNo
(
orderService
.
getOrderNo
(
order
.
getSource
()));
orderService
.
updateOrder
(
order
);
int
amount
=
order
.
getAmount
().
movePointRight
(
2
).
intValue
();
Map
payInfo
=
weixinService
.
pay
(
request
,
"hooloo"
,
order
.
getOrderNo
(),
order
.
getUserId
(),
amount
);
if
(
payInfo
!=
null
)
{
if
(
payInfo
!=
null
)
{
return
AjaxResult
.
success
(
payInfo
);
}
else
{
}
else
{
throw
new
ServiceException
(
"微信支付发生异常"
);
}
}
...
...
@@ -119,13 +107,12 @@ public class OrderController extends BaseController
@PreAuthorize
(
"@ss.hasPermi('system:order:edit')"
)
@Log
(
title
=
"订单"
,
businessType
=
BusinessType
.
UPDATE
)
@PutMapping
public
AjaxResult
edit
(
@RequestBody
Order
order
)
{
public
AjaxResult
edit
(
@RequestBody
Order
order
)
{
return
toAjax
(
orderService
.
updateOrder
(
order
));
}
@RequestMapping
(
"/cancel"
)
public
AjaxResult
cancel
(
String
orderId
)
{
public
AjaxResult
cancel
(
String
orderId
)
{
return
toAjax
(
orderService
.
cancel
(
orderId
));
}
...
...
soss-framework/src/main/java/com/soss/framework/web/service/TokenService.java
View file @
f45e0f2a
...
...
@@ -4,6 +4,8 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
javax.servlet.http.HttpServletRequest
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
...
...
@@ -26,6 +28,7 @@ import io.jsonwebtoken.SignatureAlgorithm;
* @author zxq
*/
@Component
@Slf4j
public
class
TokenService
{
// 令牌自定义标识
...
...
@@ -71,6 +74,7 @@ public class TokenService
}
catch
(
Exception
e
)
{
log
.
error
(
""
,
e
);
}
}
return
null
;
...
...
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
View file @
f45e0f2a
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