Commit f45e0f2a by weijiguang

下单时校验订单中sku数量

parent ff201708
package com.soss.web.controller.coffee; package com.soss.web.controller.coffee;
import java.util.List; import com.soss.common.annotation.Log;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.soss.common.constant.HttpStatus; 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.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.common.exception.ServiceException;
import com.soss.framework.web.service.TokenService; import com.soss.framework.web.service.TokenService;
import com.soss.framework.web.service.WeixinServiceImpl; import com.soss.framework.web.service.WeixinServiceImpl;
import com.soss.system.domain.Order;
import com.soss.system.domain.vo.OrderQuery; import com.soss.system.domain.vo.OrderQuery;
import com.soss.system.service.impl.CustomerServiceImpl;
import com.soss.system.service.impl.OrderServiceImpl; import com.soss.system.service.impl.OrderServiceImpl;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable; import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestBody; import java.util.List;
import org.springframework.web.bind.annotation.RequestMapping; import java.util.Map;
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;
/** /**
* 订单Controller * 订单Controller
...@@ -37,8 +29,7 @@ import com.soss.common.core.page.TableDataInfo; ...@@ -37,8 +29,7 @@ import com.soss.common.core.page.TableDataInfo;
*/ */
@RestController @RestController
@RequestMapping("/order") @RequestMapping("/order")
public class OrderController extends BaseController public class OrderController extends BaseController {
{
@Autowired @Autowired
private OrderServiceImpl orderService; private OrderServiceImpl orderService;
@Autowired @Autowired
...@@ -51,8 +42,7 @@ public class OrderController extends BaseController ...@@ -51,8 +42,7 @@ public class OrderController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('system:order:list')") @PreAuthorize("@ss.hasPermi('system:order:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(OrderQuery orderQuery) public TableDataInfo list(OrderQuery orderQuery) {
{
startPage(); startPage();
List<Order> list = orderService.selectOrderList(orderQuery); List<Order> list = orderService.selectOrderList(orderQuery);
return getDataTable(list); return getDataTable(list);
...@@ -63,15 +53,13 @@ public class OrderController extends BaseController ...@@ -63,15 +53,13 @@ public class OrderController extends BaseController
* 获取订单详细信息 * 获取订单详细信息
*/ */
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) public AjaxResult getInfo(@PathVariable("id") String id) {
{
return AjaxResult.success(orderService.selectOrderById(id)); return AjaxResult.success(orderService.selectOrderById(id));
} }
@PostMapping("/check") @PostMapping("/check")
public AjaxResult check(@RequestBody Order order) public AjaxResult check(@RequestBody Order order) {
{
return orderService.check(order); return orderService.check(order);
} }
...@@ -80,34 +68,34 @@ public class OrderController extends BaseController ...@@ -80,34 +68,34 @@ public class OrderController extends BaseController
*/ */
@Log(title = "订单", businessType = BusinessType.INSERT) @Log(title = "订单", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(HttpServletRequest request, @RequestBody Order order) public AjaxResult add(HttpServletRequest request, @RequestBody Order order) {
{
LoginUser loginUser = tokenService.getLoginUser(request); LoginUser loginUser = tokenService.getLoginUser(request);
AjaxResult ajaxResult = orderService.insertOrder(loginUser,order);
if(HttpStatus.SUCCESS != (int)ajaxResult.get(AjaxResult.CODE_TAG)){ AjaxResult ajaxResult = orderService.insertOrder(loginUser, order);
if (HttpStatus.SUCCESS != (int) ajaxResult.get(AjaxResult.CODE_TAG)) {
return ajaxResult; return ajaxResult;
} }
int amount = order.getAmount().movePointRight(2).intValue(); int amount = order.getAmount().movePointRight(2).intValue();
Map payInfo = weixinService.pay(request, "hooloo", order.getOrderNo(), order.getUserId(), amount); Map payInfo = weixinService.pay(request, "hooloo", order.getOrderNo(), order.getUserId(), amount);
if(payInfo !=null){ if (payInfo != null) {
payInfo.put("orderId",order.getId()); payInfo.put("orderId", order.getId());
return AjaxResult.success(payInfo); return AjaxResult.success(payInfo);
}else{ } else {
throw new ServiceException("微信支付发生异常"); throw new ServiceException("微信支付发生异常");
} }
} }
@RequestMapping("/payOrder") @RequestMapping("/payOrder")
public AjaxResult cancel(HttpServletRequest request, String orderId) public AjaxResult cancel(HttpServletRequest request, String orderId) {
{
Order order = orderService.selectOrderById(orderId); Order order = orderService.selectOrderById(orderId);
order.setOrderNo(orderService.getOrderNo(order.getSource())); order.setOrderNo(orderService.getOrderNo(order.getSource()));
orderService.updateOrder(order); orderService.updateOrder(order);
int amount = order.getAmount().movePointRight(2).intValue(); int amount = order.getAmount().movePointRight(2).intValue();
Map payInfo = weixinService.pay(request, "hooloo", order.getOrderNo(), order.getUserId(), amount); Map payInfo = weixinService.pay(request, "hooloo", order.getOrderNo(), order.getUserId(), amount);
if(payInfo !=null){ if (payInfo != null) {
return AjaxResult.success(payInfo); return AjaxResult.success(payInfo);
}else{ } else {
throw new ServiceException("微信支付发生异常"); throw new ServiceException("微信支付发生异常");
} }
} }
...@@ -119,13 +107,12 @@ public class OrderController extends BaseController ...@@ -119,13 +107,12 @@ public class OrderController extends BaseController
@PreAuthorize("@ss.hasPermi('system:order:edit')") @PreAuthorize("@ss.hasPermi('system:order:edit')")
@Log(title = "订单", businessType = BusinessType.UPDATE) @Log(title = "订单", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody Order order) public AjaxResult edit(@RequestBody Order order) {
{
return toAjax(orderService.updateOrder(order)); return toAjax(orderService.updateOrder(order));
} }
@RequestMapping("/cancel") @RequestMapping("/cancel")
public AjaxResult cancel(String orderId) public AjaxResult cancel(String orderId) {
{
return toAjax(orderService.cancel(orderId)); return toAjax(orderService.cancel(orderId));
} }
......
...@@ -4,6 +4,8 @@ import java.util.HashMap; ...@@ -4,6 +4,8 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
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.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -26,6 +28,7 @@ import io.jsonwebtoken.SignatureAlgorithm; ...@@ -26,6 +28,7 @@ import io.jsonwebtoken.SignatureAlgorithm;
* @author zxq * @author zxq
*/ */
@Component @Component
@Slf4j
public class TokenService public class TokenService
{ {
// 令牌自定义标识 // 令牌自定义标识
...@@ -71,6 +74,7 @@ public class TokenService ...@@ -71,6 +74,7 @@ public class TokenService
} }
catch (Exception e) catch (Exception e)
{ {
log.error("", e);
} }
} }
return null; return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment