Commit f45e0f2a by weijiguang

下单时校验订单中sku数量

parent ff201708
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));
}
......
......@@ -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;
......
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