Jelajahi Sumber

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/main/java/org/springblade/modules/finance/service/impl/AfterSalesServiceImpl.java
pangqijun 3 bulan lalu
induk
melakukan
8e0b35e800
21 mengubah file dengan 199 tambahan dan 90 penghapusan
  1. 18 13
      src/main/java/org/springblade/modules/api/controller/ApiAfterSalesController.java
  2. 1 0
      src/main/java/org/springblade/modules/api/controller/ApiMerchantOrderController.java
  3. 11 0
      src/main/java/org/springblade/modules/api/controller/ApiOrderGoodsController.java
  4. 3 0
      src/main/java/org/springblade/modules/api/controller/ApiVendingController.java
  5. 17 6
      src/main/java/org/springblade/modules/api/controller/LoginController.java
  6. 5 1
      src/main/java/org/springblade/modules/api/request/AfterSalesRequest.java
  7. 2 2
      src/main/java/org/springblade/modules/api/vo/MerchantIncomeVO.java
  8. 18 0
      src/main/java/org/springblade/modules/finance/entity/AfterSales.java
  9. 1 1
      src/main/java/org/springblade/modules/finance/mapper/AfterSalesMapper.java
  10. 1 5
      src/main/java/org/springblade/modules/finance/mapper/AfterSalesMapper.xml
  11. 4 1
      src/main/java/org/springblade/modules/finance/mapper/OrderGoodsMapper.xml
  12. 1 0
      src/main/java/org/springblade/modules/finance/service/IAfterSalesGoodsService.java
  13. 2 1
      src/main/java/org/springblade/modules/finance/service/IAfterSalesService.java
  14. 9 0
      src/main/java/org/springblade/modules/finance/service/impl/AfterSalesGoodsServiceImpl.java
  15. 65 56
      src/main/java/org/springblade/modules/finance/service/impl/AfterSalesServiceImpl.java
  16. 20 1
      src/main/java/org/springblade/modules/finance/service/impl/OrderGoodsServiceImpl.java
  17. 1 0
      src/main/java/org/springblade/modules/finance/service/impl/OrderGrouponServiceImpl.java
  18. 1 0
      src/main/java/org/springblade/modules/finance/service/impl/OrderServiceImpl.java
  19. 4 0
      src/main/java/org/springblade/modules/finance/vo/AfterSalesVO.java
  20. 12 0
      src/main/java/org/springblade/modules/finance/vo/OrderGoodsVO.java
  21. 3 3
      src/main/resources/application-dev.yml

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

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.enums.AfterSalesStatusEnum;
 import org.springblade.common.enums.AfterSalesTypeEnum;
@@ -66,13 +67,17 @@ public class ApiAfterSalesController {
     @ApiOperation(value = "提交售后")
     @PostMapping("submit")
     public R submit(@Valid @RequestBody AfterSalesRequest request) {
-        if (AfterSalesTypeEnum.RETURN_GOODS.getValue().equals(request.getAfterSalesType())) {
-            afterSalesService.submit(request);
-        } else if (AfterSalesTypeEnum.PART_REFUND.getValue().equals(request.getAfterSalesType())) {
-            afterSalesService.refundSubmit(request);
-        } else if (AfterSalesTypeEnum.NOT_ARRIVE_REFUND.getValue().equals(request.getAfterSalesType())) {
-            afterSalesService.applyGrouponAfterRefund(request.getOrderId());
-        }
+
+        afterSalesService.submit(request);
+
+
+//        if (AfterSalesTypeEnum.RETURN_GOODS.getValue().equals(request.getAfterSalesType())) {
+//            afterSalesService.submit(request);
+//        } else if (AfterSalesTypeEnum.PART_REFUND.getValue().equals(request.getAfterSalesType())) {
+//            afterSalesService.refundSubmit(request);
+//        } else if (AfterSalesTypeEnum.NOT_ARRIVE_REFUND.getValue().equals(request.getAfterSalesType())) {
+//            afterSalesService.applyGrouponAfterRefund(request.getOrderId());
+//        }
         return R.success("ok");
     }
 
@@ -119,19 +124,19 @@ public class ApiAfterSalesController {
         return R.data(list);
     }
 
-    @PostMapping("/user/list")
+    @GetMapping("/user/list")
     @ApiOperationSupport(order = 9)
     @ApiOperation(value = "获取用户售后列表")
-    public R<IPage<AfterSalesVO>> getUserAfterSalesList(@RequestBody Query query,
-                                                        @RequestParam(name = "state,0-处理中 1-完成 2-关闭") Integer state) {
+    public R<IPage<AfterSalesVO>> getUserAfterSalesList(Query query,
+                                                        @ApiParam(value = "售后状态 0-处理中 1-完成 2-关闭", required = true) @RequestParam(name = "state") Integer state) {
         return R.data(afterSalesService.getUserAfterSalesList(Condition.getPage(query), AuthUtil.getUserId(), state));
     }
 
-    @PostMapping("/merchant/list")
+    @GetMapping("/merchant/list")
     @ApiOperationSupport(order = 9)
     @ApiOperation(value = "获取商家售后列表")
-    public R<IPage<AfterSalesVO>> getMerchantAfterSalesList(@RequestBody Query query,
-                                                            @RequestParam(name = "state,0-处理中 1-完成 2-关闭") Integer state) {
+    public R<IPage<AfterSalesVO>> getMerchantAfterSalesList(Query query,
+                                                            @ApiParam(value = "售后状态 0-处理中 1-完成 2-关闭", required = true) @RequestParam(name = "state") Integer state) {
         return R.data(afterSalesService.getUserAfterSalesList(Condition.getPage(query), AuthUtil.getUserId(), state));
     }
 

+ 1 - 0
src/main/java/org/springblade/modules/api/controller/ApiMerchantOrderController.java

@@ -38,6 +38,7 @@ public class ApiMerchantOrderController {
     @Lazy
     private final IOrderGoodsService iOrderGoodsService;
 
+    @Lazy
     private final IOrderService iOrderService;
 
     @ApiLog("订单列表(订单管理)")

+ 11 - 0
src/main/java/org/springblade/modules/api/controller/ApiOrderGoodsController.java

@@ -1,6 +1,7 @@
 package org.springblade.modules.api.controller;
 
 import cn.hutool.core.lang.Assert;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
@@ -13,8 +14,10 @@ import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.modules.finance.entity.AfterSales;
 import org.springblade.modules.finance.entity.Order;
 import org.springblade.modules.finance.entity.OrderGoods;
+import org.springblade.modules.finance.service.IAfterSalesService;
 import org.springblade.modules.finance.service.IOrderGoodsService;
 import org.springblade.modules.finance.service.IOrderService;
 import org.springblade.modules.finance.vo.MerchantPageOrderVO;
@@ -38,6 +41,8 @@ public class ApiOrderGoodsController {
 
     private final IOrderGoodsService iOrderGoodsService;
     private final IOrderService iOrderService;
+    private final IAfterSalesService afterSalesService;
+
 
     @GetMapping("/user")
     @ApiOperationSupport(order = 1)
@@ -73,6 +78,12 @@ public class ApiOrderGoodsController {
         orderGoodsVO.setPaymentAmount(order.getPaymentAmount());
         orderGoodsVO.setTotalAmount(order.getTotalAmount());
         orderGoodsVO.setDiscountAmount(order.getDiscountAmount());
+        if (order.getIsAftersales() == 1){
+            LambdaQueryWrapper<AfterSales> q = new LambdaQueryWrapper<>();
+            q.eq(AfterSales::getOrderId,order.getId());
+            AfterSales afterSales = afterSalesService.getOne(q);
+            orderGoodsVO.setAfterSales(afterSales);
+        }
         return R.data(orderGoodsVO);
     }
 

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

@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springblade.common.aspect.VendingFlag;
 import org.springblade.common.constant.CommonConstant;
+import org.springblade.core.log.annotation.ApiLog;
 import org.springblade.modules.api.request.VendingOrderReq;
 import org.springblade.modules.api.response.VendingOrderRes;
 import org.springblade.modules.api.service.VendingOrderService;
@@ -37,6 +38,7 @@ public class ApiVendingController {
     private final VendingOrderService vendingOrderService;
 
 
+    @ApiLog("查询设备订单信息")
     @VendingFlag
     @ApiOperation(value = "查询订单信息", notes = "传入售货机编号")
     @PostMapping("/getOrder")
@@ -74,6 +76,7 @@ public class ApiVendingController {
 
     }
 
+    @ApiLog("设备出货成功回调")
     @ApiOperation(value = "出货成功回调", notes = "出货成功回调")
     @PostMapping("callback")
     public void callback() {

+ 17 - 6
src/main/java/org/springblade/modules/api/controller/LoginController.java

@@ -40,9 +40,7 @@ import org.springblade.core.log.annotation.ApiLog;
 import org.springblade.core.redis.cache.BladeRedis;
 import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.AuthUtil;
-import org.springblade.core.sms.model.SmsCode;
 import org.springblade.core.tool.api.R;
-import org.springblade.core.tool.support.Kv;
 import org.springblade.core.tool.utils.*;
 import org.springblade.modules.api.request.MerchantRegisterRequest;
 import org.springblade.modules.auth.enums.UserEnum;
@@ -56,7 +54,6 @@ import org.springblade.modules.platform.entity.UserScores;
 import org.springblade.modules.platform.service.IUserRecomService;
 import org.springblade.modules.platform.service.IUserScoresService;
 import org.springblade.modules.platform.service.UserAppService;
-import org.springblade.modules.resource.builder.sms.SmsBuilder;
 import org.springblade.modules.system.entity.User;
 import org.springblade.modules.system.entity.UserApp;
 import org.springblade.modules.system.entity.UserInfo;
@@ -68,13 +65,11 @@ import org.springblade.modules.system.vo.UserMerchantVO;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
+import java.util.Objects;
 
 import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE;
 import static org.springblade.modules.resource.utils.SmsUtil.VALIDATE_FAIL;
-import static org.springblade.modules.resource.utils.SmsUtil.VALIDATE_SUCCESS;
 
 /**
  * 控制器
@@ -275,6 +270,13 @@ public class LoginController extends BladeController {
 		if (StringUtil.isEmpty(captchaCode) ||StringUtil.isEmpty(captchaId)){
 			return R.fail("请输入手机验证码!");
 		}
+
+		User user = userService.getByAccount(username);
+
+		if (Objects.isNull(user)){
+			return R.fail("请先注册!");
+		}
+
 		String tenantId = WebUtil.getRequest().getHeader(TokenUtil.TENANT_HEADER_KEY);
 		String grantType = "phone";
 		String userType = Func.toStr(WebUtil.getRequest().getHeader(TokenUtil.USER_TYPE_HEADER_KEY), UserEnum.APP.getName());
@@ -287,6 +289,15 @@ public class LoginController extends BladeController {
 			.set("userType", userType);
 		ITokenGranter granter = TokenGranterBuilder.getGranter(grantType);
 		UserInfo userInfo = granter.grant(tokenParameter);
+		if (UserEnum.MERCHANT.getName().equals(userType)) {
+			UserMerchantVO vo = iUserMerchantService.getByUserId(user.getId());
+			if (AuditStatusEnum.WAIT.getValue().equals(vo.getAuditStatus())) {
+				return R.fail("账号审核中");
+			}
+		}
+		if(ObjectUtil.isNotNull(user.getLogOut()) && user.getLogOut() == 1){
+			return R.fail("用户已注销无法正常使用,如需使用请联系管理员");
+		}
 		return R.data(TokenUtil.createAuthInfo(userInfo));
 	}
 

+ 5 - 1
src/main/java/org/springblade/modules/api/request/AfterSalesRequest.java

@@ -35,7 +35,11 @@ public class  AfterSalesRequest {
     @ApiModelProperty("售后原因")
     private String reason;
 
+    @ApiModelProperty("补充描述")
+    private String afterSaleDescribe;
+
+
     @ApiModelProperty("售后商品图片")
     private List<String> images;
-    
+
 }

+ 2 - 2
src/main/java/org/springblade/modules/api/vo/MerchantIncomeVO.java

@@ -62,10 +62,10 @@ public class MerchantIncomeVO  {
     @ApiModelProperty(value = "设备id")
     private Long deviceId;
     /**
-     * 设备id
+     * 设备名称
      */
     @ApiModelProperty(value = "设备名称")
-    private Long deviceName;
+    private String deviceName;
     /**
      * 商家id
      */

+ 18 - 0
src/main/java/org/springblade/modules/finance/entity/AfterSales.java

@@ -39,8 +39,26 @@ public class AfterSales extends BaseEntity {
 	/**
 	* 售后原因
 	*/
+	@ApiModelProperty(value = "售后原因ID")
+	private Long reasonId;
+
+	/**
+	 * 补充描述
+	 */
 	@ApiModelProperty(value = "售后原因")
 	private String reason;
+
+	/**
+	 * 补充描述
+	 */
+	@ApiModelProperty(value = "补充描述")
+	private String afterSaleDescribe;
+
+	/**
+	 * 图片集合
+	 */
+	@ApiModelProperty(value = "图片集合")
+	private String imgListStr;
 	/**
 	* 售后状态 0-处理中 1-完成 2-关闭
 	*/

+ 1 - 1
src/main/java/org/springblade/modules/finance/mapper/AfterSalesMapper.java

@@ -39,7 +39,7 @@ public interface AfterSalesMapper extends BaseMapper<AfterSales> {
 	 */
 	List<AfterSalesVO> selectAfterSalesPage(IPage page, AfterSalesVO afterSales);
 
-	List<AfterSalesVO> selectUserAfterSalesList(IPage pag, Long userId, Integer state);
+	IPage<AfterSalesVO> selectUserAfterSalesList(IPage pag, Long userId,Integer state);
 
     List<AfterSalesVO> getByGrouponIds(List<Long> gIds);
 

+ 1 - 5
src/main/java/org/springblade/modules/finance/mapper/AfterSalesMapper.xml

@@ -24,13 +24,9 @@
     </select>
     <select id="selectUserAfterSalesList" resultType="org.springblade.modules.finance.vo.AfterSalesVO">
         SELECT
-            s.*,
-            g.main_title,
-            g.groupon_start_time,
-            g.groupon_end_time
+            s.*
         FROM
             t_after_sales s
-            JOIN t_groupon g ON s.groupon_id = g.id
             WHERE s.user_id = #{userId}
             <if test="state != null">
                 <if test="state == 1">

+ 4 - 1
src/main/java/org/springblade/modules/finance/mapper/OrderGoodsMapper.xml

@@ -86,9 +86,12 @@
             t_order o
             JOIN t_order_goods og ON o.id = og.order_id
         WHERE o.is_delete = 0 and o.user_id = #{p.userId}
-        <if test="p.orderState != 0">
+        <if test="p.orderState != 0 and p.orderState != null">
             and o.order_state = #{p.orderState}
         </if>
+        <if test="p.isAfterSales != null">
+            and o.is_aftersales = #{p.isAfterSales}
+        </if>
         ORDER BY o.create_time desc
     </select>
 

+ 1 - 0
src/main/java/org/springblade/modules/finance/service/IAfterSalesGoodsService.java

@@ -43,4 +43,5 @@ public interface IAfterSalesGoodsService extends IService<AfterSalesGoods> {
 
 	List<OrderGoods> getGoodsByAfterSalesId(Long afterSalesId);
 
+    List<AfterSalesGoods> getByAfterSalesId(Long id);
 }

+ 2 - 1
src/main/java/org/springblade/modules/finance/service/IAfterSalesService.java

@@ -19,6 +19,7 @@ package org.springblade.modules.finance.service;
 import org.springblade.common.enums.AfterSalesTypeEnum;
 import org.springblade.modules.api.request.AfterSalesRequest;
 import org.springblade.modules.finance.entity.AfterSales;
+import org.springblade.modules.finance.entity.AfterSalesGoods;
 import org.springblade.modules.finance.vo.AfterSalesVO;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -65,7 +66,7 @@ public interface IAfterSalesService extends IService<AfterSales> {
 
 	void bindLogisticsNo(String afterSalesNo, String logisticsNo);
 
-	IPage<AfterSalesVO> getUserAfterSalesList(IPage<Object> page, Long userId, Integer state);
+	IPage<AfterSalesVO> getUserAfterSalesList(IPage<Object> page, Long userId,Integer state);
 
 	AfterSalesVO getUserAfterSalesDetail(Long afterSalesId);
 

+ 9 - 0
src/main/java/org/springblade/modules/finance/service/impl/AfterSalesGoodsServiceImpl.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.modules.finance.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springblade.modules.finance.entity.AfterSalesGoods;
@@ -41,6 +42,14 @@ public class AfterSalesGoodsServiceImpl extends ServiceImpl<AfterSalesGoodsMappe
 		return this.baseMapper.selectGoodsByAfterSalesId(afterSalesId);
 	}
 
+	@Override
+	public List<AfterSalesGoods> getByAfterSalesId(Long id) {
+		LambdaQueryWrapper<AfterSalesGoods> q = new LambdaQueryWrapper<>();
+		q.eq(AfterSalesGoods::getAfterSalesId,id);
+		List<AfterSalesGoods> list = this.list(q);
+		return list;
+	}
+
 	@Override
 	public IPage<AfterSalesGoodsVO> selectAfterSalesGoodsPage(IPage<AfterSalesGoodsVO> page, AfterSalesGoodsVO afterSalesGoods) {
 		return page.setRecords(baseMapper.selectAfterSalesGoodsPage(page, afterSalesGoods));

+ 65 - 56
src/main/java/org/springblade/modules/finance/service/impl/AfterSalesServiceImpl.java

@@ -17,6 +17,7 @@
 package org.springblade.modules.finance.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import com.alibaba.fastjson.JSON;
 import org.springblade.common.base.BaseEntity;
 import org.springblade.common.cache.ParamCache;
 import org.springblade.common.constant.CacheBizConstant;
@@ -38,6 +39,7 @@ import org.springblade.modules.finance.wrapper.OrderWrapper;
 import org.springblade.modules.groupon.entity.Groupon;
 import org.springblade.modules.groupon.service.IGrouponService;
 import org.springblade.modules.mall.service.IStoreService;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.transaction.annotation.Transactional;
@@ -46,10 +48,7 @@ import org.springframework.util.Assert;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -63,14 +62,19 @@ import java.util.stream.Collectors;
 public class AfterSalesServiceImpl extends ServiceImpl<AfterSalesMapper, AfterSales> implements IAfterSalesService {
 
 	@Resource
+	@Lazy
 	private IOrderGoodsService orderGoodsService;
 	@Resource
+	@Lazy
 	private IOrderService orderService;
 	@Resource
+	@Lazy
 	private IOrderGrouponService orderGrouponService;
 	@Resource
+	@Lazy
 	private IOrderRefundService orderRefundService;
 	@Resource
+	@Lazy
 	private IStoreService storeService;
 	@Resource
 	private ICommissionService commissionService;
@@ -79,6 +83,7 @@ public class AfterSalesServiceImpl extends ServiceImpl<AfterSalesMapper, AfterSa
 	@Resource
 	private IGrouponService grouponService;
 	@Resource
+	@Lazy
 	private IAfterSalesGoodsService afterSalesGoodsService;
 	@Resource
 	private IAppointGoodsService appointGoodsService;
@@ -122,45 +127,51 @@ public class AfterSalesServiceImpl extends ServiceImpl<AfterSalesMapper, AfterSa
 	@Transactional
 	@Override
 	public void submit(AfterSalesRequest request) {
-		Order order = orderService.getById(request.getOrderId());
-		Assert.notNull(order, "订单数据不存在");
-
-		order.setIsAftersales(YesOrNoEnum.YES.getValue());
-		orderService.updateById(order);
-
-
-		// 校验商品是否已经申请过售后
-		List<Long> collect = request.getAfterGoodsList().stream().map(BaseEntity::getId).collect(Collectors.toList());
-		List<OrderGoods> list = orderGoodsService.lambdaQuery().in(BaseEntity::getId, collect).list();
-		for (OrderGoods orderGoods : list) {
-			if (YesOrNoEnum.YES.getValue().equals(orderGoods.getIsAfterSales())) {
-				throw new ServiceException("商品【"+orderGoods.getGoodsName()+"】已申请过售后");
-			}
-			orderGoods.setIsAfterSales(YesOrNoEnum.YES.getValue());
-		}
-		// 更新售后状态
-		orderGoodsService.updateBatchById(list);
-
-		Map<Long, OrderGoods> map = request.getAfterGoodsList().stream().collect(Collectors.toMap(BaseEntity::getId, Function.identity()));
-		List<AfterSales> afterSalesList = new ArrayList<>();
-		for (OrderGoods goods : list) {
-			AfterSales afterSales = init();
-			afterSales.setOrderId(request.getOrderId());
-			afterSales.setReason(request.getReason());
-			afterSales.setType(request.getAfterSalesType());
-			afterSales.setOrderGoodsId(goods.getId());
-
-			OrderGoods o = map.get(goods.getId());
-			afterSales.setReturnGoodsNum(o.getGoodsNum());
-			afterSales.setIsArrived(YesOrNoEnum.NO.getValue());
-			afterSales.setUserId(AuthUtil.getUserId());
-			afterSales.setStoreId(goods.getShopId());
-			afterSalesList.add(afterSales);
-		}
-		saveBatch(afterSalesList);
-
-		// TODO: 2024/7/29   将分销收益改为无效,所有售后结束后重新计算收益
-		//commissionService.invalidCommission(order.getId());
+        Order order = orderService.getById(request.getOrderId());
+        Assert.notNull(order, "订单数据不存在");
+
+        order.setIsAftersales(YesOrNoEnum.YES.getValue());
+        orderService.updateById(order);
+//		OrderGroupon orderGroupon = orderGrouponService.lambdaQuery().eq(OrderGroupon::getOrderId, request.getOrderId()).one();
+//		Assert.notNull(orderGroupon, "orderGroupon数据不存在");
+//		Groupon groupon = grouponService.getById(orderGroupon.getGrouponId());
+//		Assert.notNull(orderGroupon, "groupon数据不存在");
+
+        int afterSalesDays = Integer.parseInt(ParamCache.getValueDefault(CacheBizConstant.ORDER_AFTER_SALES_DAYS, "3"));
+        // 校验是否能申请售后
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(order.getCreateTime());
+        calendar.add(Calendar.DAY_OF_MONTH,afterSalesDays);
+        Date time = calendar.getTime();
+//		LocalDateTime time = groupon.getTakeStartTime().plusDays(afterSalesDays);
+        if (time.compareTo(new Date()) <= 0) {
+            throw new ServiceException("已过售后期");
+        }
+
+        // 校验商品是否已经申请过售后
+        List<Long> goodsIds = request.getAfterGoodsList().stream().map(OrderGoods::getGoodsId).collect(Collectors.toList());
+        List<OrderGoods> list = orderGoodsService.lambdaQuery()
+                .eq(OrderGoods::getOrderId,request.getOrderId())
+                .in(OrderGoods::getGoodsId, goodsIds).list();
+        for (OrderGoods orderGoods : list) {
+            if (YesOrNoEnum.YES.getValue().equals(orderGoods.getIsAfterSales())) {
+                throw new ServiceException("商品【"+orderGoods.getGoodsName()+"】已申请过售后");
+            }
+            orderGoods.setIsAfterSales(YesOrNoEnum.YES.getValue());
+        }
+        // 更新售后状态
+        orderGoodsService.updateBatchById(list);
+        AfterSales afterSales = init();
+        afterSales.setOrderId(request.getOrderId());
+        afterSales.setType(request.getAfterSalesType());
+        afterSales.setReason(request.getReason());
+        afterSales.setReasonId(request.getReasonId());
+        afterSales.setAfterSaleDescribe(request.getAfterSaleDescribe());
+        afterSales.setImgListStr(JSON.toJSONString(request.getImages()));
+        afterSales.setIsArrived(YesOrNoEnum.NO.getValue());
+        afterSales.setUserId(AuthUtil.getUserId());
+        afterSales.setReturnGoodsNum(request.getAfterGoodsList().get(0).getRefundGoodsNum());
+        this.save(afterSales);
 	}
 
 	@Override
@@ -470,20 +481,18 @@ public class AfterSalesServiceImpl extends ServiceImpl<AfterSalesMapper, AfterSa
 	}
 
 	@Override
-	public IPage<AfterSalesVO> getUserAfterSalesList(IPage page, Long userId, Integer state) {
-		List<AfterSalesVO> afterSalesVOS = baseMapper.selectUserAfterSalesList(page, userId, state);
-		if (CollUtil.isNotEmpty(afterSalesVOS)) {
-			for (AfterSalesVO vo : afterSalesVOS) {
-				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);
-				}
-			}
+	public IPage<AfterSalesVO> getUserAfterSalesList(IPage page, Long userId,Integer state ) {
+		IPage<AfterSalesVO> afterSalesVOS = baseMapper.selectUserAfterSalesList(page, userId,state);
+		if (CollUtil.isEmpty(afterSalesVOS.getRecords())){
+			return afterSalesVOS;
+		}
+		for (AfterSalesVO vo : afterSalesVOS.getRecords()) {
+			List<OrderGoods> list = orderGoodsService.lambdaQuery().eq(OrderGoods::getOrderId, vo.getOrderId()).list();
+			vo.setGoodsList(list);
+			List<AfterSalesGoods> list1 = afterSalesGoodsService.lambdaQuery().eq(AfterSalesGoods::getAfterSalesId,vo.getId()).list();
+			vo.setAfterSalesGoodsList(list1);
 		}
-		return page.setRecords(afterSalesVOS);
+		return afterSalesVOS;
 	}
 
 	@Override

+ 20 - 1
src/main/java/org/springblade/modules/finance/service/impl/OrderGoodsServiceImpl.java

@@ -1,16 +1,22 @@
 package org.springblade.modules.finance.service.impl;
 
 import cn.hutool.core.lang.Assert;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
+import org.springblade.common.enums.YesOrNoEnum;
 import org.springblade.modules.api.request.SubmitOrderRequest;
 import org.springblade.modules.api.service.SubmitOrderService;
 import org.springblade.modules.business.entity.FacilityCargoWay;
 import org.springblade.modules.business.entity.Shop;
 import org.springblade.modules.business.service.IFacilityCargoWayService;
 import org.springblade.modules.business.service.IShopService;
+import org.springblade.modules.finance.entity.AfterSales;
+import org.springblade.modules.finance.entity.AfterSalesGoods;
 import org.springblade.modules.finance.entity.Order;
 import org.springblade.modules.finance.entity.OrderGoods;
+import org.springblade.modules.finance.service.IAfterSalesGoodsService;
+import org.springblade.modules.finance.service.IAfterSalesService;
 import org.springblade.modules.finance.service.IOrderService;
 import org.springblade.modules.finance.vo.MerchantPageOrderVO;
 import org.springblade.modules.finance.vo.OrderGoodsVO;
@@ -21,11 +27,14 @@ import org.springblade.modules.mall.entity.GoodsInfo;
 import org.springblade.modules.mall.service.IGoodsInfoService;
 import org.springblade.modules.system.entity.User;
 import org.springblade.modules.system.service.IUserService;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * 商品订单表 服务实现类
@@ -42,6 +51,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
 	private final IFacilityCargoWayService iFacilityCargoWayService;
 	private final IShopService iShopService;
 	private final IUserService iUserService;
+	private final IAfterSalesService afterSalesService;
 
 	@Override
 	public IPage<OrderGoodsVO> selectOrderGoodsPage(IPage<OrderGoodsVO> page, OrderGoodsVO orderGoods) {
@@ -50,7 +60,16 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
 
 	@Override
 	public IPage<OrderGoodsVO> selectUserOrder(IPage<OrderGoodsVO> page, OrderGoodsVO orderGoods) {
-		return page.setRecords(baseMapper.selectUserOrder(page, orderGoods));
+		List<OrderGoodsVO> orderGoodsVOS = baseMapper.selectUserOrder(page, orderGoods);
+		for (OrderGoodsVO order : orderGoodsVOS) {
+			if (YesOrNoEnum.YES.getValue().equals(order.getIsAfterSales())){
+				LambdaQueryWrapper<AfterSales> q = new LambdaQueryWrapper<>();
+				q.eq(AfterSales::getOrderId,order.getOrderId());
+				AfterSales afterSales = afterSalesService.getOne(q);
+				order.setAfterSales(afterSales);
+			}
+		}
+		return page.setRecords(orderGoodsVOS);
 	}
 
 	@Override

+ 1 - 0
src/main/java/org/springblade/modules/finance/service/impl/OrderGrouponServiceImpl.java

@@ -80,6 +80,7 @@ public class OrderGrouponServiceImpl extends ServiceImpl<OrderGrouponMapper, Ord
 	@Resource
 	private IAfterSalesService afterSalesService;
 	@Resource
+	@Lazy
 	private IAfterSalesGoodsService afterSalesGoodsService;
 
 	@Override

+ 1 - 0
src/main/java/org/springblade/modules/finance/service/impl/OrderServiceImpl.java

@@ -84,6 +84,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	@Resource
 	private ICommissionService commissionService;
 	@Resource
+	@Lazy
 	private IAfterSalesGoodsService afterSalesGoodsService;
 
 	@Override

+ 4 - 0
src/main/java/org/springblade/modules/finance/vo/AfterSalesVO.java

@@ -23,6 +23,7 @@ import lombok.EqualsAndHashCode;
 import org.springblade.common.enums.AfterSalesStatusEnum;
 import org.springblade.common.enums.AfterSalesTypeEnum;
 import org.springblade.modules.finance.entity.AfterSales;
+import org.springblade.modules.finance.entity.AfterSalesGoods;
 import org.springblade.modules.finance.entity.OrderGoods;
 import org.springblade.modules.finance.entity.OrderRefund;
 import org.springblade.modules.mall.vo.StoreVO;
@@ -53,6 +54,9 @@ public class AfterSalesVO extends AfterSales {
 	@ApiModelProperty(value = "退款商品信息")
 	private List<OrderGoodsVO> refundGoodsList;
 
+	@ApiModelProperty(value = "退款商品信息")
+	private List<AfterSalesGoods> afterSalesGoodsList;
+
 	@ApiModelProperty(value = "退款信息")
 	private OrderRefund refund;
 

+ 12 - 0
src/main/java/org/springblade/modules/finance/vo/OrderGoodsVO.java

@@ -19,6 +19,8 @@ package org.springblade.modules.finance.vo;
 import io.swagger.annotations.ApiModelProperty;
 import org.springblade.common.enums.OrderStateEnum;
 import org.springblade.common.enums.PaymentTypeEnum;
+import org.springblade.modules.finance.entity.AfterSales;
+import org.springblade.modules.finance.entity.AfterSalesGoods;
 import org.springblade.modules.finance.entity.OrderGoods;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -26,6 +28,7 @@ import io.swagger.annotations.ApiModel;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 商品订单表视图实体类
@@ -82,6 +85,15 @@ public class OrderGoodsVO extends OrderGoods {
 	@ApiModelProperty(value = "优惠金额")
 	private BigDecimal discountAmount;
 
+	@ApiModelProperty(value = "是否售后")
+	private Integer isAfterSales;
+
+	@ApiModelProperty(value = "售后实体")
+	private AfterSales afterSales;
+
+	@ApiModelProperty(value = "售后商品")
+	private List<AfterSalesGoods> afterSalesGoodsList;
+
 	public String getPayModeDesc() {
 		return PaymentTypeEnum.getNameByValue(paymentMode);
 	}

+ 3 - 3
src/main/resources/application-dev.yml

@@ -1,13 +1,13 @@
 #数据源配置
 spring:
   redis:
-    host: 192.168.1.74
-    port: 6379
+    host: www.gzzzyd.com
+    port: 10896
     database: 10
     ssl: false
     password: 123456789
   datasource:
-    url: jdbc:mysql://192.168.1.74:3306/vend?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
+    url: jdbc:mysql://www.gzzzyd.com:10895/vend?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
     username: root
     password: root_123
     # PostgreSQL