Browse Source

feat:售后退款

zhanghui 3 months ago
parent
commit
8ed89afc0f

+ 3 - 3
src/main/java/org/springblade/modules/api/controller/ApiAfterSalesController.java

@@ -52,9 +52,9 @@ public class ApiAfterSalesController {
     public R submit() {
         List<Map<String, String>> result = new ArrayList<>();
         for (AfterSalesTypeEnum value : AfterSalesTypeEnum.values()) {
-            if (value.equals(AfterSalesTypeEnum.REFUND)) {
-                continue;
-            }
+//            if (value.equals(AfterSalesTypeEnum.REFUND)) {
+//                continue;
+//            }
             Map<String, String> mapTemp = new HashMap<>();
             mapTemp.put("label", value.getName());
             mapTemp.put("value", value.getValue() + "");

+ 4 - 5
src/main/java/org/springblade/modules/finance/controller/AfterSalesController.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.modules.finance.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
@@ -73,10 +74,6 @@ public class AfterSalesController extends BladeController {
 	@ApiOperation(value = "详情", notes = "传入afterSales")
 	public R<AfterSalesVO> detail(AfterSales afterSales) {
 		AfterSalesVO vo = afterSalesService.getUserAfterSalesDetail(afterSales.getId());
-		vo.setOrderNo(vo.getOrder().getOrderNo());
-		for (OrderGoods goods : vo.getGoodsList()) {
-			goods.setGoodsNum(vo.getReturnGoodsNum());
-		}
 		return R.data(vo);
 	}
 
@@ -87,7 +84,9 @@ public class AfterSalesController extends BladeController {
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "分页", notes = "传入afterSales")
 	public R<IPage<AfterSalesVO>> list(AfterSales afterSales, Query query) {
-		IPage<AfterSales> pages = afterSalesService.page(Condition.getPage(query), Condition.getQueryWrapper(afterSales));
+		QueryWrapper<AfterSales> queryWrapper = Condition.getQueryWrapper(afterSales);
+		queryWrapper.orderByDesc("create_time");
+		IPage<AfterSales> pages = afterSalesService.page(Condition.getPage(query), queryWrapper);
 		return R.data(AfterSalesWrapper.build().pageVO(pages));
 	}
 

+ 17 - 0
src/main/java/org/springblade/modules/finance/entity/AfterSalesGoods.java

@@ -6,6 +6,8 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import org.springblade.common.base.BaseEntity;
 
+import java.math.BigDecimal;
+
 /**
  * 售后商品表实体类
  *
@@ -40,4 +42,19 @@ public class AfterSalesGoods extends BaseEntity {
      */
     private Long orderGoodsId;
 
+    /**
+     * 商品id
+     */
+    private String  goodsImg;
+
+    /**
+     * 商品id
+     */
+    private String  goodsName;
+
+    /**
+     * 商品id
+     */
+    private BigDecimal goodsPrice;
+
 }

+ 5 - 8
src/main/java/org/springblade/modules/finance/service/impl/AfterSalesServiceImpl.java

@@ -180,7 +180,9 @@ public class AfterSalesServiceImpl extends ServiceImpl<AfterSalesMapper, AfterSa
 			afterSalesGoods.setAfterSalesId(afterSales.getId());
 			afterSalesGoods.setGoodsNum(orderGoods.getGoodsNum());
 			afterSalesGoods.setOrderGoodsId(orderGoods.getId());
-			//afterSalesGoods.setOrderGrouponGoodsId();
+			afterSalesGoods.setGoodsImg(orderGoods.getGoodsImage());
+			afterSalesGoods.setGoodsName(orderGoods.getGoodsName());
+			afterSalesGoods.setGoodsPrice(orderGoods.getGoodsPrice());
 			afterSalesGoodss.add(afterSalesGoods);
 		}
 		afterSalesGoodsService.saveBatch(afterSalesGoodss);
@@ -424,13 +426,8 @@ public class AfterSalesServiceImpl extends ServiceImpl<AfterSalesMapper, AfterSa
 	public AfterSalesVO getUserAfterSalesDetail(Long afterSalesId) {
 		AfterSales afterSales = getById(afterSalesId);
 		AfterSalesVO vo = AfterSalesWrapper.build().entityVO(afterSales);
-		if (AfterSalesTypeEnum.REFUND.getValue().equals(vo.getType())) {
-			List<OrderGoods> list = orderGoodsService.lambdaQuery().eq(OrderGoods::getOrderId, vo.getOrderId()).list();
-			vo.setGoodsList(list);
-		} else {
-			List<OrderGoods> list = orderGoodsService.lambdaQuery().eq(BaseEntity::getId, vo.getOrderGoodsId()).list();
-			vo.setGoodsList(list);
-		}
+		List<AfterSalesGoods> afterSalesGoods = afterSalesGoodsService.getByAfterSalesId(afterSalesId);
+		vo.setAfterSalesGoodsList(afterSalesGoods);
 		Order order = orderService.getById(afterSales.getOrderId());
 		vo.setOrder(OrderWrapper.build().entityVO(order));
 		vo.setOrderNo(order.getOrderNo());