ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/RefundPass.java
@@ -30,6 +30,8 @@ @TableId("id") private Long id; @TableField(exist = false) private String idStr; @ApiModelProperty(value = "订单id") @TableField("order_id") ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -92,6 +92,7 @@ }) @GetMapping("/writeOff/{code}") public R<Void> writeOff(@PathVariable("code") String code){ // TODO 待完善 return R.ok(); } @@ -104,9 +105,26 @@ }) @GetMapping("/cancel/{orderId}") public R<Void> cancel(@PathVariable("orderId") Long orderId){ // TODO 待完善 return R.ok(); } /** * 确认收货 */ @ApiOperation(value = "确认收货", tags = {"小程序-个人中心-我的订单-确认收货"}) @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), }) @GetMapping("/confirm/{orderId}") public R<Void> confirm(@PathVariable("orderId") Long orderId){ // TODO 待完善 return R.ok(); } } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/RefundPassController.java
@@ -1,8 +1,21 @@ package com.ruoyi.order.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.model.Order; import com.ruoyi.order.model.RefundPass; import com.ruoyi.order.service.OrderService; import com.ruoyi.order.service.RefundPassService; import com.ruoyi.order.vo.ApplyRefundPass; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.Arrays; /** * <p> @@ -16,5 +29,93 @@ @RequestMapping("/refund-pass") public class RefundPassController { @Resource private RefundPassService refundPassService; @Resource private TokenService tokenService; @Resource private OrderService orderService; @ResponseBody @PostMapping("/applyRefundPass") @ApiOperation(value = "售后申请", tags = {"我的订单-个人中心-小程序"}) public R applyRefundPass(@RequestBody ApplyRefundPass applyRefundPass){ return refundPassService.applyRefundPass(applyRefundPass); } @ResponseBody @GetMapping("/getRefundPass/{orderId}") @ApiOperation(value = "获取售后详情", tags = {"我的订单-个人中心-小程序"}) @ApiImplicitParams({ @ApiImplicitParam(name = "orderId", value = "订单id", required = true, dataType = "long"), }) public R<RefundPass> getRefundPass(@PathVariable("orderId") Long orderId){ Long userid = tokenService.getLoginUserApplet().getUserid(); Order order = orderService.getById(orderId); if(!order.getAppUserId().equals(userid)){ return R.fail("权限不足"); } RefundPass one = refundPassService.getOne(new LambdaQueryWrapper<RefundPass>().eq(RefundPass::getOrderId, orderId) .eq(RefundPass::getDelFlag, 0).last(" order by createTime desc limit 0,1")); one.setIdStr(one.getId().toString()); return R.ok(one); } @ResponseBody @PutMapping("/cancelRefundPass/{id}") @ApiOperation(value = "取消售后", tags = {"我的订单-个人中心-小程序"}) @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "售后数据id", required = true, dataType = "long"), }) public R cancelRefundPass(@PathVariable("id") Long id){ RefundPass refundPass = refundPassService.getById(id); if(null == refundPass){ return R.fail(); } Long userid = tokenService.getLoginUserApplet().getUserid(); Order order = orderService.getById(refundPass.getOrderId()); if(!order.getAppUserId().equals(userid)){ return R.fail("权限不足"); } if(Arrays.asList(2, 3).contains(refundPass.getStatus())){ return R.fail("售后取消失败"); } refundPass.setDelFlag(1); refundPassService.updateById(refundPass); order.setOrderStatus(4); orderService.updateById(order); return R.ok(); } @ResponseBody @PutMapping("/deliverGoodsRefundPass/{id}") @ApiOperation(value = "售后已发货操作", tags = {"我的订单-个人中心-小程序"}) @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "售后数据id", required = true, dataType = "long"), }) public R deliverGoodsRefundPass(@PathVariable("id") Long id){ RefundPass refundPass = refundPassService.getById(id); if(null == refundPass){ return R.fail(); } Long userid = tokenService.getLoginUserApplet().getUserid(); Order order = orderService.getById(refundPass.getOrderId()); if(!order.getAppUserId().equals(userid)){ return R.fail("权限不足"); } if(4 != refundPass.getStatus()){ return R.fail("操作失败"); } refundPass.setStatus(5); refundPassService.updateById(refundPass); return R.ok(); } } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/RefundPassService.java
@@ -1,7 +1,10 @@ package com.ruoyi.order.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.R; import com.ruoyi.order.model.RefundPass; import com.ruoyi.order.vo.ApplyRefundPass; import org.springframework.web.bind.annotation.RequestBody; /** * <p> @@ -12,5 +15,12 @@ * @since 2024-11-21 */ public interface RefundPassService extends IService<RefundPass> { /** * 申请售后 * @param applyRefundPass * @return */ R applyRefundPass(ApplyRefundPass applyRefundPass); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java
@@ -1,10 +1,19 @@ package com.ruoyi.order.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.domain.R; import com.ruoyi.order.mapper.RefundPassMapper; import com.ruoyi.order.model.Order; import com.ruoyi.order.model.RefundPass; import com.ruoyi.order.service.OrderService; import com.ruoyi.order.service.RefundPassService; import com.ruoyi.order.vo.ApplyRefundPass; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneOffset; /** * <p> @@ -16,5 +25,44 @@ */ @Service public class RefundPassServiceImpl extends ServiceImpl<RefundPassMapper, RefundPass> implements RefundPassService { @Resource private OrderService orderService; /** * 申请售后 * @param applyRefundPass * @return */ @Override public R applyRefundPass(ApplyRefundPass applyRefundPass) { RefundPass one = this.getOne(new LambdaQueryWrapper<RefundPass>().eq(RefundPass::getOrderId, applyRefundPass.getId()).eq(RefundPass::getDelFlag, 0) .ne(RefundPass::getStatus, 3)); if(null != one){ return R.fail("不能重复提交售后"); } Order order = orderService.getById(applyRefundPass.getId()); //判断是都已经超过售后时间 LocalDateTime afterSaleTime = order.getAfterSaleTime(); if(null != afterSaleTime && afterSaleTime.toEpochSecond(ZoneOffset.UTC) < LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)){ return R.fail("已超过售后期间"); } //构建售后申请数据 RefundPass refundPass = new RefundPass(); refundPass.setOrderId(applyRefundPass.getId()); refundPass.setStatus(1); refundPass.setRefundMethod(applyRefundPass.getRefundMethod()); refundPass.setRefundReason(applyRefundPass.getRefundReason()); refundPass.setUserRemark(applyRefundPass.getUserRemark()); refundPass.setPics(applyRefundPass.getPics()); refundPass.setPassStatus(1); refundPass.setDelFlag(0); refundPass.setCreateTime(LocalDateTime.now()); this.save(refundPass); order.setOrderStatus(7); orderService.updateById(order); return R.ok(); } } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ApplyRefundPass.java
New file @@ -0,0 +1,25 @@ package com.ruoyi.order.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @author zhibing.pu * @Date 2024/12/6 18:30 */ @Data @ApiModel public class ApplyRefundPass { @ApiModelProperty(value = "订单id", required = true) private Long id; @ApiModelProperty(value = "售后类型(1=退货退款,2=仅退款)", required = true) private Integer refundMethod; @ApiModelProperty(value = "申请原因", required = true) private String refundReason; @ApiModelProperty(value = "备注", required = true) private String userRemark; @ApiModelProperty(value = "图片地址,多个逗号分隔", required = true) private String pics; } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
@@ -87,6 +87,7 @@ Goods goods = goodsService.getById(id); return R.ok(goods); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java
@@ -8,11 +8,10 @@ import com.ruoyi.other.api.domain.Goods; import com.ruoyi.other.api.domain.GoodsEvaluate; import com.ruoyi.other.service.GoodsEvaluateService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @@ -27,6 +26,7 @@ */ @RestController @RequestMapping("/goods-evaluate") @Api("评论") public class GoodsEvaluateController { @Resource private GoodsEvaluateService goodsEvaluateService; @@ -34,7 +34,7 @@ private AppUserClient appUserClient; @GetMapping("/goodsList") @ApiOperation(value = "商品评价", tags = {"小程序-商品评价"}) @ApiOperation(value = "获取商品评价", tags = {"小程序-获取商品评价"}) public R<List<GoodsEvaluate>> goodsList(@ApiParam("商品id") Integer goodsId){ List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery().eq(GoodsEvaluate::getGoodsId, goodsId).list(); for (GoodsEvaluate goodsEvaluate : list) { @@ -45,5 +45,25 @@ return R.ok(list); } /** * 发布商品评价 */ @PostMapping("/addGoodsEvaluate") @ApiOperation(value = "发布商品评价", tags = {"小程序-发布商品评价"}) public R<Void> addGoodsEvaluate(GoodsEvaluate goodsEvaluate){ goodsEvaluateService.save(goodsEvaluate); return R.ok(); } /** * 评论详情 */ @GetMapping("/detail/{id}") @ApiOperation(value = "评论详情", tags = {"小程序-评论详情"}) public R<GoodsEvaluate> detail(@PathVariable("id") Long id){ GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id); return R.ok(goodsEvaluate); } }