|
|
@@ -12,7 +12,6 @@ import com.ruoyi.app.order.dto.OrderCreateInput;
|
|
|
import com.ruoyi.app.order.dto.OrderPushBodyDto;
|
|
|
import com.ruoyi.app.pay.LinePayOrderGuard;
|
|
|
import com.ruoyi.app.pay.LinePayRefundService;
|
|
|
-import com.ruoyi.app.user.MerchantTokenSessionService;
|
|
|
import com.ruoyi.app.utils.PayPush;
|
|
|
import com.ruoyi.app.utils.event.PushEventService;
|
|
|
import com.ruoyi.common.annotation.Anonymous;
|
|
|
@@ -25,6 +24,7 @@ import com.ruoyi.framework.manager.AsyncManager;
|
|
|
import com.ruoyi.system.domain.*;
|
|
|
import com.ruoyi.system.service.*;
|
|
|
import com.ruoyi.system.utils.Auth;
|
|
|
+import com.ruoyi.system.utils.AuthContext;
|
|
|
import com.ruoyi.system.utils.JwtUtil;
|
|
|
import com.ruoyi.system.domain.dto.InvalidInvoiceDto;
|
|
|
import com.ruoyi.system.utils.OrderLogHelper;
|
|
|
@@ -75,8 +75,6 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
private DeliveryOrderNotificationService deliveryOrderNotificationService;
|
|
|
@Autowired
|
|
|
private MerchantStoreAccessService merchantStoreAccessService;
|
|
|
- @Autowired
|
|
|
- private MerchantTokenSessionService merchantTokenSessionService;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -85,10 +83,10 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/getInvoice")
|
|
|
- @Auth
|
|
|
+ @Auth(session = true)
|
|
|
@Anonymous
|
|
|
public AjaxResult getInvoice(@RequestHeader String token, @RequestParam Long orderId) {
|
|
|
- MerchantAccessContext context = requireManagedOrder(token, orderId);
|
|
|
+ MerchantAccessContext context = requireManagedOrder(orderId);
|
|
|
return AjaxResult.success(orderInvoiceService.getInvoiceForMerchant(orderId, context.ownerUserId()));
|
|
|
}
|
|
|
|
|
|
@@ -97,11 +95,11 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
*/
|
|
|
|
|
|
@PutMapping("/invalidInvoice/{orderId}")
|
|
|
- @Auth
|
|
|
+ @Auth(session = true)
|
|
|
@Anonymous
|
|
|
public AjaxResult invalidInvoice(@RequestHeader String token, @PathVariable Long orderId,
|
|
|
@RequestBody(required = false) InvalidInvoiceDto dto) {
|
|
|
- MerchantAccessContext context = requireManagedOrder(token, orderId);
|
|
|
+ MerchantAccessContext context = requireManagedOrder(orderId);
|
|
|
String reason = dto == null ? null : dto.getInvalidReason();
|
|
|
return toAjax(orderInvoiceService.invalidForMerchant(orderId, reason, context.ownerUserId()));
|
|
|
}
|
|
|
@@ -110,12 +108,12 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
* 商家端下单
|
|
|
*/
|
|
|
@PostMapping("/createOrder")
|
|
|
- @Auth
|
|
|
+ @Auth(session = true)
|
|
|
@Anonymous
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public AjaxResult createOrder(@RequestHeader String token, @RequestBody OrderCreateInput input)
|
|
|
{
|
|
|
- Long loginUserId = merchantTokenSessionService.requireUserId(token);
|
|
|
+ Long loginUserId = AuthContext.requireUserId();
|
|
|
InfoUser merchant = infoUserService.getOne(new LambdaQueryWrapper<InfoUser>()
|
|
|
.eq(InfoUser::getUserId, loginUserId));
|
|
|
validateMerchantOrderInput(merchant, input);
|
|
|
@@ -301,11 +299,11 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
* 商家接单:state 从 0 改为 1
|
|
|
*/
|
|
|
@Anonymous
|
|
|
- @Auth
|
|
|
+ @Auth(session = true)
|
|
|
@GetMapping("/acceptOrder")
|
|
|
public AjaxResult acceptOrder(@RequestHeader String token, @RequestParam Long id) {
|
|
|
PosOrder order = posOrderService.getOne(new LambdaQueryWrapper<PosOrder>().eq(PosOrder::getId, id));
|
|
|
- InfoUser currentUser = requireMerchantOrderAccess(token, order);
|
|
|
+ InfoUser currentUser = requireMerchantOrderAccess(order);
|
|
|
if (order == null || order.getState() == null || order.getState() != 0L) {
|
|
|
throw new ServiceException("订单不存在或状态不允许接单");
|
|
|
}
|
|
|
@@ -326,11 +324,11 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
* 外送订单保持 deliveryStatus=1(骑手已接单)
|
|
|
*/
|
|
|
@Anonymous
|
|
|
- @Auth
|
|
|
+ @Auth(session = true)
|
|
|
@GetMapping("/dispatchOrder")
|
|
|
public AjaxResult dispatchOrder(@RequestHeader String token, @RequestParam Long id) {
|
|
|
PosOrder order = posOrderService.getOne(new LambdaQueryWrapper<PosOrder>().eq(PosOrder::getId, id));
|
|
|
- requireMerchantOrderAccess(token, order);
|
|
|
+ requireMerchantOrderAccess(order);
|
|
|
if (order == null || order.getState() == null || order.getState() != 1L) {
|
|
|
throw new ServiceException("订单不存在或状态不允许出餐");
|
|
|
}
|
|
|
@@ -357,12 +355,12 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
* 商家完成(自取/堂食):state 从 2 改为 3,payStatus 从 0 改为 1
|
|
|
*/
|
|
|
@Anonymous
|
|
|
- @Auth
|
|
|
+ @Auth(session = true)
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@GetMapping("/completeOrder")
|
|
|
public AjaxResult completeOrder(@RequestHeader String token, @RequestParam Long id) {
|
|
|
PosOrder order = posOrderService.getOne(new LambdaQueryWrapper<PosOrder>().eq(PosOrder::getId, id));
|
|
|
- requireMerchantOrderAccess(token, order);
|
|
|
+ requireMerchantOrderAccess(order);
|
|
|
if (order == null || order.getState() == null || order.getState() != 2L) {
|
|
|
throw new ServiceException("订单不存在或状态不允许完成");
|
|
|
}
|
|
|
@@ -395,11 +393,11 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
* 商家确认现金收款:payType=4 的订单 payStatus 0→1(现金单创建时未支付,商家收到现金后在App触发)
|
|
|
*/
|
|
|
@Anonymous
|
|
|
- @Auth
|
|
|
+ @Auth(session = true)
|
|
|
@GetMapping("/confirmCashPayment")
|
|
|
public AjaxResult confirmCashPayment(@RequestHeader String token, @RequestParam Long id) {
|
|
|
PosOrder order = posOrderService.getOne(new LambdaQueryWrapper<PosOrder>().eq(PosOrder::getId, id));
|
|
|
- requireMerchantOrderAccess(token, order);
|
|
|
+ requireMerchantOrderAccess(order);
|
|
|
if (order == null) {
|
|
|
throw new ServiceException(MessageUtils.message("no.order.not.exist"));
|
|
|
}
|
|
|
@@ -427,11 +425,11 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
* 商家取消订单:校验 state IN (0,1),设 state=4
|
|
|
*/
|
|
|
@Anonymous
|
|
|
- @Auth
|
|
|
+ @Auth(session = true)
|
|
|
@GetMapping("/cancelOrder")
|
|
|
public AjaxResult cancelOrder(@RequestHeader String token, @RequestParam Long id) {
|
|
|
PosOrder order = posOrderService.getOne(new LambdaQueryWrapper<PosOrder>().eq(PosOrder::getId, id));
|
|
|
- InfoUser currentUser = requireMerchantOrderAccess(token, order);
|
|
|
+ InfoUser currentUser = requireMerchantOrderAccess(order);
|
|
|
if (order == null || order.getState() == null) {
|
|
|
throw new ServiceException("订单不存在");
|
|
|
}
|
|
|
@@ -464,8 +462,8 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private InfoUser currentMerchant(String token) {
|
|
|
- Long userId = merchantTokenSessionService.requireUserId(token);
|
|
|
+ private InfoUser currentMerchant() {
|
|
|
+ Long userId = AuthContext.requireUserId();
|
|
|
InfoUser user = infoUserService.getOne(new LambdaQueryWrapper<InfoUser>()
|
|
|
.eq(InfoUser::getUserId, userId));
|
|
|
if (user == null) {
|
|
|
@@ -474,8 +472,8 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
- private InfoUser requireMerchantOrderAccess(String token, PosOrder order) {
|
|
|
- InfoUser user = currentMerchant(token);
|
|
|
+ private InfoUser requireMerchantOrderAccess(PosOrder order) {
|
|
|
+ InfoUser user = currentMerchant();
|
|
|
if ("1".equals(user.getUserType()) || "5".equals(user.getUserType())) {
|
|
|
merchantStoreAccessService.requireOrderAccess(user.getUserId(), order == null ? null : order.getId());
|
|
|
} else {
|
|
|
@@ -484,8 +482,8 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
- private MerchantAccessContext requireManagedOrder(String token, Long orderId) {
|
|
|
- Long loginUserId = merchantTokenSessionService.requireUserId(token);
|
|
|
+ private MerchantAccessContext requireManagedOrder(Long orderId) {
|
|
|
+ Long loginUserId = AuthContext.requireUserId();
|
|
|
InfoUser user = infoUserService.getOne(new LambdaQueryWrapper<InfoUser>()
|
|
|
.eq(InfoUser::getUserId, loginUserId));
|
|
|
if (user != null && ("1".equals(user.getUserType()) || "5".equals(user.getUserType()))) {
|
|
|
@@ -562,7 +560,7 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
* ta
|
|
|
*/
|
|
|
@Anonymous
|
|
|
- @Auth
|
|
|
+ @Auth(session = true)
|
|
|
@GetMapping("/orderList")
|
|
|
public AjaxResult orderList(@RequestHeader String token,
|
|
|
@RequestParam(defaultValue = "1") int page,
|
|
|
@@ -570,7 +568,7 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
@RequestParam(required = false) String tab,
|
|
|
@RequestParam(required = false) Long mdId,
|
|
|
@RequestParam(required = false) String type) {
|
|
|
- Long loginUserId = merchantTokenSessionService.requireUserId(token);
|
|
|
+ Long loginUserId = AuthContext.requireUserId();
|
|
|
// 查询当前用户信息
|
|
|
InfoUser currentUser = infoUserService.getOne(new LambdaQueryWrapper<InfoUser>().eq(InfoUser::getUserId, loginUserId));
|
|
|
if (currentUser == null) {
|
|
|
@@ -638,10 +636,10 @@ public class PosOrderShOprateController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@Anonymous
|
|
|
- @Auth
|
|
|
+ @Auth(session = true)
|
|
|
@GetMapping("/orderDetail")
|
|
|
public AjaxResult orderDetail(@RequestHeader String token, @RequestParam Long id) {
|
|
|
- requireManagedOrder(token, id);
|
|
|
+ requireManagedOrder(id);
|
|
|
PosOrder order = posOrderService.getById(id);
|
|
|
if (order == null) {
|
|
|
throw new ServiceException(MessageUtils.message("merchant.order.not.found"));
|