|
@@ -6,12 +6,15 @@ import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.EmployeeDao;
|
|
|
import com.ym.mec.biz.dal.entity.Employee;
|
|
|
import com.ym.mec.biz.dal.entity.SellOrder;
|
|
|
+import com.ym.mec.biz.dal.enums.SellStatus;
|
|
|
+import com.ym.mec.biz.dal.enums.SellTypeEnum;
|
|
|
import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
|
|
|
import com.ym.mec.biz.dal.page.SellOrderQueryInfo;
|
|
|
import com.ym.mec.biz.service.SellOrderService;
|
|
|
import com.ym.mec.biz.service.StudentRepairService;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -19,6 +22,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.snaker.engine.access.Page;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -26,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -83,8 +88,25 @@ public class SellOrderController extends BaseController {
|
|
|
@ApiOperation("退货")
|
|
|
@PostMapping(value = "/refund")
|
|
|
@PreAuthorize("@pcs.hasPermissions('sellOrder/refund')")
|
|
|
- public HttpResponseResult<SellOrder> refund(Integer id) {
|
|
|
- return succeed(sellOrderService.refund(id));
|
|
|
+ public HttpResponseResult<List<SellOrder>> refund(Integer id, Boolean reTry) {
|
|
|
+ SellOrder sellOrder = sellOrderService.get(id);
|
|
|
+
|
|
|
+ if (!sellOrder.getStatus().equals(SellStatus.NORMAL)) {
|
|
|
+ return failed("当前状态不能退货,请核查");
|
|
|
+ }
|
|
|
+ if (!sellOrder.getType().equals(SellTypeEnum.SCHOOL_BUY)) {
|
|
|
+ return failed("学校采购不能退货");
|
|
|
+ }
|
|
|
+ if (sellOrder.getParentGoodsId() != null && (reTry == null || !reTry)) {
|
|
|
+ return failed(HttpStatus.CONTINUE, "组合商品,相关商品将一起退货");
|
|
|
+ }
|
|
|
+ List<SellOrder> sellOrders = new ArrayList<>();
|
|
|
+ if (sellOrder.getParentGoodsId() != null) {
|
|
|
+ sellOrders = sellOrderService.getSellOrderByParentGoodsId(sellOrder.getOrderId(), sellOrder.getParentGoodsId());
|
|
|
+ } else {
|
|
|
+ sellOrders.add(sellOrder);
|
|
|
+ }
|
|
|
+ return succeed(sellOrderService.refund(sellOrders));
|
|
|
}
|
|
|
|
|
|
}
|