发送订阅消息增加token

This commit is contained in:
谭凯凯
2024-10-21 11:06:11 +08:00
committed by Tankaikai
parent 7425f0a4d5
commit af1d4faa03
3 changed files with 11 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package cn.ysk.cashier.controller.product;
import cn.ysk.cashier.annotation.AnonymousAccess; import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.config.security.security.TokenProvider;
import cn.ysk.cashier.dto.shoptable.*; import cn.ysk.cashier.dto.shoptable.*;
import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.service.product.TbProductService; import cn.ysk.cashier.service.product.TbProductService;
@@ -13,6 +14,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.validation.Valid;
@RestController @RestController
@@ -21,6 +24,8 @@ public class TbPlaceController {
private final TbShopTableService tbShopTableService; private final TbShopTableService tbShopTableService;
private final TbProductService tbProductService; private final TbProductService tbProductService;
private final RabbitMsgUtils rabbitMsgUtils; private final RabbitMsgUtils rabbitMsgUtils;
@Resource
private TokenProvider tokenProvider;
@GetMapping("/activate") @GetMapping("/activate")
@ApiOperation("查询/product") @ApiOperation("查询/product")
@@ -138,7 +143,9 @@ public class TbPlaceController {
@PutMapping("/pay") @PutMapping("/pay")
@ApiOperation("代客下单 支付订单") @ApiOperation("代客下单 支付订单")
public ResponseEntity<Object> pay(@Validated @RequestBody PayDTO payDTO) { public ResponseEntity<Object> pay(HttpServletRequest request, @Validated @RequestBody PayDTO payDTO) {
String token = tokenProvider.getToken(request);
payDTO.setToken(token);
return ResponseEntity.ok(tbShopTableService.pay(payDTO)); return ResponseEntity.ok(tbShopTableService.pay(payDTO));
} }

View File

@@ -20,4 +20,6 @@ public class PayDTO {
private Double discount; private Double discount;
private Integer vipUserId; private Integer vipUserId;
private String code; private String code;
private String token;
} }

View File

@@ -1602,7 +1602,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
.set(TbOrderDetail::getStatus, "closed")); .set(TbOrderDetail::getStatus, "closed"));
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("token", null); jsonObject.put("token", payDTO.getToken());
jsonObject.put("type", "create"); jsonObject.put("type", "create");
jsonObject.put("orderId", orderInfo.getId()); jsonObject.put("orderId", orderInfo.getId());
rabbitMsgUtils.sendOrderCollectMsg(jsonObject,3); rabbitMsgUtils.sendOrderCollectMsg(jsonObject,3);