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/MarsSalesController.java | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 156 insertions(+), 0 deletions(-) diff --git a/yami-shop-api/src/main/java/com/yami/shop/api/controller/MarsSalesController.java b/yami-shop-api/src/main/java/com/yami/shop/api/controller/MarsSalesController.java new file mode 100644 index 0000000..89dd5f6 --- /dev/null +++ b/yami-shop-api/src/main/java/com/yami/shop/api/controller/MarsSalesController.java @@ -0,0 +1,156 @@ +/* + * 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.MarsSales; +import com.yami.shop.bean.model.MarsTranOrder; +import com.yami.shop.bean.vo.mars.MarsSalesVo; +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.CdnUserWalletService; +import com.yami.shop.service.MarsSalesService; +import com.yami.shop.service.MarsTranOrderService; +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.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; + +/** + * @author LGH + */ +@RestController +@RequestMapping("/p/sales") +@Tag(name = "寄售(售卖)接口") +@AllArgsConstructor +public class MarsSalesController { + + @Resource + private MarsSalesService marsSalesService; + @Resource + private CdnUserWalletService cdnUserWalletService; + @Resource + private CdnConfigService cdnConfigService; + @Resource + private MarsTranOrderService marsTranOrderService; + + @GetMapping("/page") + @Operation(summary = "分页查询在线寄售(售卖)列表信息") + public ServerResponseEntity<IPage<MarsSalesVo>> page(PageParam<MarsSales> page, MarsSalesVo marsSales) { + IPage<MarsSalesVo> returnPage = marsSalesService.getPage(page,marsSales); + return ServerResponseEntity.success(returnPage); + } + + @GetMapping("/getMarsSalesPage") + @Operation(summary = "分页查询寄售(售卖)列表信息") + public ServerResponseEntity<IPage<MarsSales>> getMarsSalesPage(PageParam<MarsSales> page,MarsSales marsSales) { + IPage<MarsSales> userInvoicePage = marsSalesService.getMarsSalesPage(page,marsSales ); + return ServerResponseEntity.success(userInvoicePage); + } + + @GetMapping("/info/{id}") + @Operation(summary = "通过寄售(售卖)id查询寄售(售卖)信息") + @Parameter(name = "id", description = "寄售(售卖)id" , required = true) + public ServerResponseEntity<MarsSales> getMarsSalesById(@PathVariable("id") Long id) { + MarsSales card = marsSalesService.getById(id); + return ServerResponseEntity.success(card); + } + + @PostMapping("/getMarsSaless") + @Operation(summary = "获取寄售(售卖)信息") + public ServerResponseEntity<List<MarsSales>> getMarsSaless(@RequestBody MarsSales marsSales) { + List<MarsSales> list = marsSalesService.getMarsSaless(marsSales); + return ServerResponseEntity.success(list); + } + + @PostMapping("/saveMarsSales") + @Operation(summary = "新增寄售(售卖)信息") + public ServerResponseEntity<String> saveMarsSales(@RequestBody MarsSales marsSales) { + String tranFee = cdnConfigService.selectValueByName(DictConstant.TRAN_FEE); + String maxTranNum = cdnConfigService.selectValueByName(DictConstant.MAX_TRAN_NUM); + String userId = SecurityUtils.getUser().getUserId(); + marsSales.setSalesUerId(userId); + String msg = cdnUserWalletService.checkRedMoney(marsSales); + if(ResponseEnum.OK.getMsg().equals(msg)){ + marsSales.setProductRealPrice(marsSales.getProductPrice().multiply + ((new BigDecimal(DictConstant.CONSTANT_1).subtract(new BigDecimal(tranFee)))).setScale(2, RoundingMode.HALF_UP)); + marsSales.setResiTranPrice(marsSales.getProductRealPrice()); + marsSales.setResiTranNum(new BigDecimal(maxTranNum)); + Integer num = marsSalesService.saveMarsSales(marsSales); + if(num > 0 ){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + }else{ + return ServerResponseEntity.showFailMsg(msg); + } + } + + @PostMapping("/cancelMarsSales") + @Operation(summary = "售卖人取消寄售(售卖)信息") + public ServerResponseEntity<String> cancelMarsSales(@RequestBody MarsSales marsSales) { + MarsTranOrder marsTranOrder = new MarsTranOrder(); + marsTranOrder.setProductId(String.valueOf(marsSales.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); + } + marsSales.setProductStatus(DictConstant.PRODUCT_STATUS_5); + Integer num = marsSalesService.updateMarsSales(marsSales); + if(num >0 ){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + } + + @PostMapping("/updateMarsSales") + @Operation(summary = "修改寄售(售卖)信息") + public ServerResponseEntity<String> updateMarsSales(@RequestBody MarsSales marsSales) { + Integer num = marsSalesService.updateMarsSales(marsSales); + 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> deleteMarsSalesById(@PathVariable("id") Long id) { + Integer num = marsSalesService.deleteMarsSales(id); + if(num >0 ){ + return ServerResponseEntity.success(ResponseEnum.OK.getMsg()); + }else{ + return ServerResponseEntity.showFailMsg(ResponseEnum.ERROR.getMsg()); + } + } + +} -- Gitblit v1.9.3