/* * 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> page(PageParam page,MarsWantbuy wantbuy) { IPage userInvoicePage = marsWantbuyService.getPage(page,wantbuy ); return ServerResponseEntity.success(userInvoicePage); } @GetMapping("/getMarsWantbuyPage") @Operation(summary = "分页查询寄售(求购表)列表信息") public ServerResponseEntity> getMarsWantbuyPage(PageParam page,MarsWantbuy wantbuy) { IPage userInvoicePage = marsWantbuyService.getMarsWantbuyPage(page,wantbuy ); return ServerResponseEntity.success(userInvoicePage); } @GetMapping("/info/{id}") @Operation(summary = "通过寄售(求购表)id查询寄售(求购表)信息") @Parameter(name = "id", description = "寄售(求购表)id" , required = true) public ServerResponseEntity getMarsWantbuyById(@PathVariable("id") Long id) { MarsWantbuy card = marsWantbuyService.getById(id); return ServerResponseEntity.success(card); } @PostMapping("/getMarsWantbuys") @Operation(summary = "获取寄售(求购表)信息") public ServerResponseEntity> getMarsWantbuys(@RequestBody MarsWantbuy wantbuy) { List list = marsWantbuyService.getMarsWantbuys(wantbuy); return ServerResponseEntity.success(list); } @PostMapping("/saveMarsWantbuy") @Operation(summary = "新增寄售(求购表)信息") public ServerResponseEntity 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 cancelMarsWantbuy(@RequestBody MarsWantbuy wantbuy) { MarsTranOrder marsTranOrder = new MarsTranOrder(); marsTranOrder.setProductId(String.valueOf(wantbuy.getId())); List 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 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 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 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()); } } }