From efdb99f8cecc4afb592afad79c761081d5d5cf22 Mon Sep 17 00:00:00 2001 From: lee <4766465@qq.com> Date: Wed, 18 Dec 2024 13:27:00 +0800 Subject: [PATCH] init --- yami-shop-api/src/main/java/com/yami/shop/api/controller/MarsTranOrderController.java | 184 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 184 insertions(+), 0 deletions(-) diff --git a/yami-shop-api/src/main/java/com/yami/shop/api/controller/MarsTranOrderController.java b/yami-shop-api/src/main/java/com/yami/shop/api/controller/MarsTranOrderController.java new file mode 100644 index 0000000..c899b6b --- /dev/null +++ b/yami-shop-api/src/main/java/com/yami/shop/api/controller/MarsTranOrderController.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ +package com.yami.shop.api.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.yami.shop.bean.model.MarsTranOrder; +import com.yami.shop.bean.model.User; +import com.yami.shop.common.constants.DictConstant; +import com.yami.shop.common.constants.ResultMsg; +import com.yami.shop.common.response.ResponseEnum; +import com.yami.shop.common.response.ServerResponseEntity; +import com.yami.shop.common.util.PageParam; +import com.yami.shop.security.api.util.SecurityUtils; +import com.yami.shop.service.*; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +/** + * @author LGH + */ +@RestController +@RequestMapping("/p/tranOrder") +@Tag(name = "寄售(交易明细表)接口") +@AllArgsConstructor +public class MarsTranOrderController { + + @Resource + private MarsTranOrderService marsTranOrderService; + @Resource + private MarsSalesService marsSalesService; + @Resource + private UserService userService; + @Resource + private CdnUserWalletService cdnUserWalletService; + + @GetMapping("/page") + @Operation(summary = "分页查询寄售(交易明细表)列表信息") + public ServerResponseEntity<IPage<MarsTranOrder>> getMarsTranOrderPage(PageParam<MarsTranOrder> page, MarsTranOrder marsTranOrder) { + IPage<MarsTranOrder> userInvoicePage = marsTranOrderService.getMarsTranOrderPage(page,marsTranOrder ); + return ServerResponseEntity.success(userInvoicePage); + } + + @GetMapping("/info/{id}") + @Operation(summary = "通过寄售(交易明细表)id查询寄售(交易明细表)信息") + @Parameter(name = "id", description = "寄售(交易明细表)id" , required = true) + public ServerResponseEntity<MarsTranOrder> getMarsTranOrderById(@PathVariable("id") Long id) { + MarsTranOrder card = marsTranOrderService.getById(id); + return ServerResponseEntity.success(card); + } + + @PostMapping("/getMarsTranOrders") + @Operation(summary = "获取寄售(交易明细表)信息") + public ServerResponseEntity<List<MarsTranOrder>> getMarsTranOrders(@RequestBody MarsTranOrder marsTranOrder) { + List<MarsTranOrder> list = marsTranOrderService.getMarsTranOrders(marsTranOrder); + return ServerResponseEntity.success(list); + } + + @PostMapping("/saveMarsTranOrder") + @Operation(summary = "新增寄售(交易明细表)信息") + public ServerResponseEntity<String> saveMarsTranOrder(@RequestBody MarsTranOrder marsTranOrder) { + //获取用户信息,查询单日冻结次数,如果>=3,单日不可交易 + String userId = SecurityUtils.getUser().getUserId(); + //检测用户是否可以进行交易 + String returnMsg = userService.checkTranByUser(marsTranOrder,userId); + if(!ResponseEnum.OK.getMsg().equals(returnMsg)){ + return ServerResponseEntity.showFailMsg(returnMsg); + } + //修改售卖、求购状态 + String msg = marsSalesService.updateMarsByOrder(marsTranOrder); + if(ResponseEnum.OK.getMsg().equals(msg)){ + marsTranOrder.setStatus(DictConstant.ORDER_STATUS_1); + Integer num = marsTranOrderService.saveMarsTranOrder(marsTranOrder); + if(num >0 ){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + }else{ + return ServerResponseEntity.showFailMsg(msg); + } + } + + @PostMapping("/cacelMarsTranOrder") + @Operation(summary = "用户取消订单信息") + public ServerResponseEntity<String> cacelMarsTranOrder(@RequestBody MarsTranOrder marsTranOrder) { + Boolean result =marsTranOrderService.cacelMarsTranOrder(marsTranOrder); + if(result){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + } + + @PostMapping("/timeOutOrder") + @Operation(summary = "超时订单信息") + public ServerResponseEntity<String> timeOutOrder(@RequestBody MarsTranOrder marsTranOrder) { + //修改售卖、求购状态 + marsSalesService.updateMarsByCacelOrder(marsTranOrder); + //修改当前用户的单日取消次数 + User user = userService.getUserByUserId(marsTranOrder.getBuyUserId()); + user.setDayCancel(new BigDecimal(user.getDayCancel()).add(new BigDecimal(DictConstant.CONSTANT_1)).intValue()); + userService.updateById(user); + //修改订单状态为超时 + marsTranOrder.setTimeOutTime(new Date()); + marsTranOrder.setStatus(DictConstant.ORDER_STATUS_6); + Integer num = marsTranOrderService.updateMarsTranOrder(marsTranOrder); + //修改用户的成交数量以及成交率 + marsTranOrderService.updateUserCountRate(marsTranOrder); + if(num >0 ){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + } + + @PostMapping("/sendRedTranOrder") + @Operation(summary = "售卖方点击发流量,订单结束") + public ServerResponseEntity<String> sendRedTranOrder(@RequestBody MarsTranOrder marsTranOrder) { + Boolean result =marsTranOrderService.sendRedTranOrder(marsTranOrder); + if(result){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + } + + @PostMapping("/lockTranOrder") + @Operation(summary = "锁定订单/申诉订单") + public ServerResponseEntity<String> lockTranOrder(@RequestBody MarsTranOrder marsTranOrder) { + //修改售卖、求购状态 + marsSalesService.updateMarsBylockTranOrder(marsTranOrder); + //修改订单状态为“订单锁定” + marsTranOrder.setLockTime(new Date()); + marsTranOrder.setStatus(DictConstant.ORDER_STATUS_4); + marsTranOrderService.updateMarsTranOrder(marsTranOrder); + //冻结双方账号 + Integer num = marsTranOrderService.updateUserFreeze(marsTranOrder); + if(num > 0 ){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + } + + @PostMapping("/updateMarsTranOrder") + @Operation(summary = "修改寄售(交易明细表)信息") + public ServerResponseEntity<String> updateMarsTranOrder(@RequestBody MarsTranOrder marsTranOrder) { + Integer num = marsTranOrderService.updateMarsTranOrder(marsTranOrder); + if(num >0 ){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + } + + @GetMapping("/delete/{id}") + @Operation(summary = "通过寄售流水id查询寄售信息") + @Parameter(name = "id", description = "寄售id" , required = true) + public ServerResponseEntity<String> deleteMarsTranOrderById(@PathVariable("id") Long id) { + Integer num = marsTranOrderService.deleteMarsTranOrder(id); + if(num >0 ){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + } + +} -- Gitblit v1.9.3