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/MarsWantBuyController.java | 145 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 145 insertions(+), 0 deletions(-) diff --git a/yami-shop-api/src/main/java/com/yami/shop/api/controller/MarsWantBuyController.java b/yami-shop-api/src/main/java/com/yami/shop/api/controller/MarsWantBuyController.java new file mode 100644 index 0000000..1db69f8 --- /dev/null +++ b/yami-shop-api/src/main/java/com/yami/shop/api/controller/MarsWantBuyController.java @@ -0,0 +1,145 @@ +/* + * 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.MarsWantbuy; +import com.yami.shop.bean.vo.mars.MarsWantbuyVo; +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.CdnConfigService; +import com.yami.shop.service.MarsTranOrderService; +import com.yami.shop.service.MarsWantbuyService; +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.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +/** + * @author LGH + */ +@RestController +@RequestMapping("/p/wantBuy") +@Tag(name = "寄售(求购表)接口") +@AllArgsConstructor +public class MarsWantBuyController { + + @Resource + private MarsWantbuyService marsWantbuyService; + @Resource + private CdnConfigService cdnConfigService; + @Resource + private MarsTranOrderService marsTranOrderService; + + @GetMapping("/page") + @Operation(summary = "分页查询在线寄售(求购表)列表信息") + public ServerResponseEntity<IPage<MarsWantbuyVo>> page(PageParam<MarsWantbuy> page,MarsWantbuy wantbuy) { + IPage<MarsWantbuyVo> userInvoicePage = marsWantbuyService.getPage(page,wantbuy ); + return ServerResponseEntity.success(userInvoicePage); + } + + @GetMapping("/getMarsWantbuyPage") + @Operation(summary = "分页查询寄售(求购表)列表信息") + public ServerResponseEntity<IPage<MarsWantbuy>> getMarsWantbuyPage(PageParam<MarsWantbuy> page,MarsWantbuy wantbuy) { + IPage<MarsWantbuy> userInvoicePage = marsWantbuyService.getMarsWantbuyPage(page,wantbuy ); + return ServerResponseEntity.success(userInvoicePage); + } + + @GetMapping("/info/{id}") + @Operation(summary = "通过寄售(求购表)id查询寄售(求购表)信息") + @Parameter(name = "id", description = "寄售(求购表)id" , required = true) + public ServerResponseEntity<MarsWantbuy> getMarsWantbuyById(@PathVariable("id") Long id) { + MarsWantbuy card = marsWantbuyService.getById(id); + return ServerResponseEntity.success(card); + } + + @PostMapping("/getMarsWantbuys") + @Operation(summary = "获取寄售(求购表)信息") + public ServerResponseEntity<List<MarsWantbuy>> getMarsWantbuys(@RequestBody MarsWantbuy wantbuy) { + List<MarsWantbuy> list = marsWantbuyService.getMarsWantbuys(wantbuy); + return ServerResponseEntity.success(list); + } + + @PostMapping("/saveMarsWantbuy") + @Operation(summary = "新增寄售(求购表)信息") + public ServerResponseEntity<String> saveMarsWantbuy(@RequestBody MarsWantbuy wantbuy) { + String maxTranNum = cdnConfigService.selectValueByName(DictConstant.MAX_TRAN_NUM); + String userId = SecurityUtils.getUser().getUserId(); + wantbuy.setWantUerId(userId); + wantbuy.setResiTranPrice(wantbuy.getWantRealPrice()); + wantbuy.setResiTranNum(new BigDecimal(maxTranNum)); + Integer num = marsWantbuyService.saveMarsWantbuy(wantbuy); + if(num >0 ){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + } + + @PostMapping("/cancelMarsWantbuy") + @Operation(summary = "求购人取消寄售(求购表)信息") + public ServerResponseEntity<String> cancelMarsWantbuy(@RequestBody MarsWantbuy wantbuy) { + MarsTranOrder marsTranOrder = new MarsTranOrder(); + marsTranOrder.setProductId(String.valueOf(wantbuy.getId())); + List<String> statusList = new ArrayList<>(); + statusList.add(DictConstant.ORDER_STATUS_1); + statusList.add(DictConstant.ORDER_STATUS_2); + statusList.add(DictConstant.ORDER_STATUS_3); + statusList.add(DictConstant.ORDER_STATUS_4); + statusList.add(DictConstant.ORDER_STATUS_6); + List<MarsTranOrder> orders = marsTranOrderService.getMarsTranOrders(marsTranOrder); + if(null != orders && orders.size() > 0){ + return ServerResponseEntity.showFailMsg(ResultMsg.BUSSINESS_BEING); + } + wantbuy.setWantStatus(DictConstant.WANT_STATUS_5); + Integer num = marsWantbuyService.updateMarsWantbuy(wantbuy); + if(num >0 ){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + } + + @PostMapping("/updateMarsWantbuy") + @Operation(summary = "修改寄售(求购表)信息") + public ServerResponseEntity<String> updateMarsWantbuy(@RequestBody MarsWantbuy wantbuy) { + Integer num = marsWantbuyService.updateMarsWantbuy(wantbuy); + 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> deleteMarsWantbuyById(@PathVariable("id") Long id) { + Integer num = marsWantbuyService.deleteMarsWantbuy(id); + if(num >0 ){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + } + +} -- Gitblit v1.9.3