新增:订单核销功能
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.gxwebsoft.booking.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.booking.service.FieldService;
|
||||
import com.gxwebsoft.booking.entity.Field;
|
||||
@@ -9,14 +10,23 @@ import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.Role;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.entity.OrderInfo;
|
||||
import com.gxwebsoft.shop.service.OrderInfoService;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 场馆场地控制器
|
||||
@@ -30,6 +40,10 @@ import java.util.List;
|
||||
public class FieldController extends BaseController {
|
||||
@Resource
|
||||
private FieldService fieldService;
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
@ApiOperation("分页查询场馆场地")
|
||||
@GetMapping("/page")
|
||||
@@ -106,5 +120,38 @@ public class FieldController extends BaseController {
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
@PreAuthorize("hasAuthority('booking:field:verification')")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@ApiOperation("根据orderNo核销订单")
|
||||
@GetMapping("/verification/{orderNo}")
|
||||
public ApiResult<?> verification(@PathVariable("orderNo") String orderNo){
|
||||
final User loginUser = getLoginUser();
|
||||
if(loginUser == null){
|
||||
return fail("请先登录");
|
||||
}
|
||||
// 订单信息
|
||||
final Order order = orderService.getByOutTradeNo(orderNo);
|
||||
order.setOrderInfo(orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getOrderId,order.getOrderId())));
|
||||
System.out.println("order = " + order);
|
||||
if (order.getPayStatus().equals(0)) {
|
||||
return fail("该订单未支付");
|
||||
}
|
||||
if (!order.getOrderStatus().equals(0)){
|
||||
return fail("订单状态异常");
|
||||
}
|
||||
if (!loginUser.getMerchants().contains(order.getMerchantId().toString())) {
|
||||
return fail("权限不足");
|
||||
}
|
||||
// 处理订单状态
|
||||
final Set<String> collect = loginUser.getRoles().stream().map(Role::getRoleCode).collect(Collectors.toSet());
|
||||
collect.forEach(d -> {
|
||||
if(d.equals("merchant") || d.equals("merchantClerk")){
|
||||
orderInfoService.updateBatchById(order.getOrderInfo());
|
||||
order.setOrderStatus(1);
|
||||
orderService.updateById(order);
|
||||
}
|
||||
});
|
||||
return success("核销成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -127,7 +127,6 @@ public class PeriodController extends BaseController {
|
||||
// 字符串转集合(从redis取数据并转为List)
|
||||
final List<Field> fieldList = JSONObject.parseArray(string, Field.class);
|
||||
fieldList.forEach(f -> {
|
||||
System.out.println("是否可重复预定= " + f);
|
||||
final String key = getKey(param.getDateTime().concat(d.getTimePeriod().concat(d.getMerchantId().toString()).concat(f.getFieldId().toString())));
|
||||
final List<OrderInfo> orderInfos = collectKey.get(key);
|
||||
if (!CollectionUtils.isEmpty(orderInfos)) {
|
||||
|
||||
@@ -124,7 +124,6 @@ public class RequestUtil {
|
||||
String path = "/wx-login/getOrderQRCode/";
|
||||
try {
|
||||
// 链式构建请求
|
||||
System.out.println("path = " + host.concat(path).concat(orderNo));
|
||||
final String body = HttpRequest.get(host.concat(path).concat(orderNo))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("tenantId", TENANT_ID)
|
||||
@@ -138,4 +137,25 @@ public class RequestUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getOrderQRCodeUnlimited(String orderNo) {
|
||||
String path = "/wx-login/getOrderQRCodeUnlimited/";
|
||||
try {
|
||||
// 链式构建请求
|
||||
final String body = HttpRequest.get(host.concat(path).concat(orderNo))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("tenantId", TENANT_ID)
|
||||
.timeout(20000)
|
||||
.execute().body();
|
||||
System.out.println("body = " + body);
|
||||
final JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
final String qrCode = jsonObject.getString("message");
|
||||
System.out.println("qrCode = " + qrCode);
|
||||
return qrCode;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -201,6 +201,9 @@ public class User implements UserDetails {
|
||||
@ApiModelProperty(value = "客户端ID")
|
||||
private String clientId;
|
||||
|
||||
@ApiModelProperty(value = "可管理的商户")
|
||||
private String merchants;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sortNumber;
|
||||
|
||||
|
||||
@@ -108,23 +108,41 @@ public class OrderController extends BaseController {
|
||||
return fail("请先登录",null);
|
||||
}
|
||||
|
||||
// final Set<String> collect = loginUser.getRoles().stream().map(Role::getRoleCode).collect(Collectors.toSet());
|
||||
// final boolean superAdmin = Arrays.asList(collect).contains("superAdmin");
|
||||
// if(superAdmin){
|
||||
//
|
||||
// }
|
||||
|
||||
final Order order = orderService.getByOutTradeNo(orderNo);
|
||||
if(order != null){
|
||||
final List<OrderInfo> orderInfoList = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getOrderId, order.getOrderId()));
|
||||
order.setOrderInfo(orderInfoList);
|
||||
// 生成订单核销码
|
||||
requestUtil.setTenantId(order.getTenantId().toString());
|
||||
order.setQrcode(requestUtil.getMpOrderQrCode(orderNo));
|
||||
}
|
||||
return success(order);
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:verification')")
|
||||
@ApiOperation("根据orderNo核销订单")
|
||||
@GetMapping("/verification/{orderNo}")
|
||||
public ApiResult<Order> verification(@PathVariable("orderNo") String orderNo){
|
||||
final User loginUser = getLoginUser();
|
||||
if(loginUser == null){
|
||||
return fail("请先登录",null);
|
||||
}
|
||||
|
||||
final Set<String> collect = loginUser.getRoles().stream().map(Role::getRoleCode).collect(Collectors.toSet());
|
||||
final boolean merchant = Arrays.asList(collect).contains("merchant");
|
||||
final boolean merchantClerk = Arrays.asList(collect).contains("merchantClerk");
|
||||
|
||||
if(merchant || merchantClerk){
|
||||
System.out.println("merchant = " + merchant);
|
||||
System.out.println("merchantClerk = " + merchantClerk);
|
||||
final Order order = orderService.getByOutTradeNo(orderNo);
|
||||
if(order != null){
|
||||
final List<OrderInfo> orderInfoList = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getOrderId, order.getOrderId()));
|
||||
order.setOrderInfo(orderInfoList);
|
||||
}
|
||||
return success(order);
|
||||
}
|
||||
return fail("核销失败",null);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:order:save')")
|
||||
@ApiOperation("下单")
|
||||
@PostMapping()
|
||||
|
||||
@@ -163,8 +163,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
final int i = orderInfo.getDateTime().compareTo(DateUtil.today());
|
||||
}
|
||||
// 生成订单核销码
|
||||
requestUtil.setTenantId(order.getTenantId().toString());
|
||||
order.setQrcode(requestUtil.getMpOrderQrCode(order.getOrderNo()));
|
||||
// requestUtil.setTenantId(order.getTenantId().toString());
|
||||
// order.setQrcode(requestUtil.getOrderQRCodeUnlimited(order.getOrderNo()));
|
||||
return order;
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user