Forráskód Böngészése

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

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SellOrderDao.java
#	mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml
Joburgess 5 éve
szülő
commit
8ed55281f6

+ 15 - 0
cms/src/main/java/com/ym/mec/cms/controller/NewsController.java

@@ -2,11 +2,14 @@ package com.ym.mec.cms.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
 
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
@@ -17,9 +20,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.ym.mec.cms.controller.queryinfo.NewsInformationQueryInfo;
+import com.ym.mec.cms.dal.dao.SysNewsInformationDao;
 import com.ym.mec.cms.dal.entity.SysNewsInformation;
 import com.ym.mec.cms.service.SysNewsInformationService;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.util.collection.MapUtil;
 
 @RestController
 @RequestMapping("news")
@@ -30,6 +35,9 @@ public class NewsController extends BaseController {
 	private SysNewsInformationService sysNewsInformationService;
 	
 	@Autowired
+	private SysNewsInformationDao sysNewsInformationDao;
+	
+	@Autowired
 	private SysUserFeignService sysUserFeignService;
 
 	@ApiOperation("资讯列表分页查询")
@@ -38,6 +46,13 @@ public class NewsController extends BaseController {
 		if(queryInfo.getTenantId() == null){
 			queryInfo.setTenantId(1);
 		}
+		
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+		int count = sysNewsInformationDao.queryCount(params);
+		if(count == 0){
+			queryInfo.setMemo(null);
+		}
 		return succeed(sysNewsInformationService.queryPage(queryInfo));
 	}
 

+ 10 - 0
cms/src/main/java/com/ym/mec/cms/controller/queryinfo/NewsInformationQueryInfo.java

@@ -27,6 +27,8 @@ public class NewsInformationQueryInfo extends QueryInfo {
 	@ApiModelProperty(value = "租客编号", required = false)
 	private Integer tenantId;
 	
+	private String clientName;
+	
 	private Date date;
 
 	public Integer getType() {
@@ -84,4 +86,12 @@ public class NewsInformationQueryInfo extends QueryInfo {
 	public void setTenantId(Integer tenantId) {
 		this.tenantId = tenantId;
 	}
+
+	public String getClientName() {
+		return clientName;
+	}
+
+	public void setClientName(String clientName) {
+		this.clientName = clientName;
+	}
 }

+ 3 - 2
cms/src/main/java/com/ym/mec/cms/service/impl/SysNewsInformationServiceImpl.java

@@ -72,9 +72,9 @@ public class SysNewsInformationServiceImpl extends BaseServiceImpl<Long, SysNews
 		String memo = queryInfo.getMemo();
 		
 		Map<String, Object> params = new HashMap<String, Object>();
-		MapUtil.populateMap(params, queryInfo);
 
-		queryInfo.setType(3); 
+		queryInfo.setType(3);
+		MapUtil.populateMap(params, queryInfo);
 		int count = sysNewsInformationDao.queryHomeCount(params);
 		if(count == 0){
 			queryInfo.setMemo(null);
@@ -113,6 +113,7 @@ public class SysNewsInformationServiceImpl extends BaseServiceImpl<Long, SysNews
 		
 		queryInfo.setMemo(memo);
 		queryInfo.setType(6);
+		MapUtil.populateMap(params, queryInfo);
 		count = sysNewsInformationDao.queryHomeCount(params);
 		if(count == 0){
 			queryInfo.setMemo(null);

+ 30 - 16
cms/src/main/resources/config/mybatis/SysNewsInformationMapper.xml

@@ -48,6 +48,16 @@
 			<if test="search != null">
 				and title_ like '%' #{search} '%'
 			</if>
+			<if test="clientName != 'manage'">
+				<choose>
+					<when test="memo != null and memo != ''">
+						and memo_ = #{memo}
+					</when>
+					<otherwise>
+						and (memo_ is null or memo_ = '')
+					</otherwise>
+				</choose>
+			</if>
 		</where>
 	</sql>
 	
@@ -179,14 +189,16 @@
 		<if test="tenantId != null">
 			and tenant_id_ = #{tenantId}
 		</if>
-		<choose>
-			<when test="memo != null and memo != ''">
-				and memo_ = #{memo}
-			</when>
-			<otherwise>
-				and (memo_ is null or memo_ = '')
-			</otherwise>
-		</choose>
+		<if test="clientName != 'manage'">
+			<choose>
+				<when test="memo != null and memo != ''">
+					and memo_ = #{memo}
+				</when>
+				<otherwise>
+					and (memo_ is null or memo_ = '')
+				</otherwise>
+			</choose>
+		</if>
 		order by status_ desc,order_ desc,update_time_ desc
 		<include refid="global.limit" />
 	</select>
@@ -213,13 +225,15 @@
 		<if test="tenantId != null">
 			and tenant_id_ = #{tenantId}
 		</if>
-		<choose>
-			<when test="memo != null and memo != ''">
-				and memo_ = #{memo}
-			</when>
-			<otherwise>
-				and (memo_ is null or memo_ = '')
-			</otherwise>
-		</choose>
+		<if test="clientName != 'manage'">
+			<choose>
+				<when test="memo != null and memo != ''">
+					and memo_ = #{memo}
+				</when>
+				<otherwise>
+					and (memo_ is null or memo_ = '')
+				</otherwise>
+			</choose>
+		</if>
 	</select>
 </mapper>

+ 12 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SellOrderDao.java

@@ -124,6 +124,7 @@ public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
 
     /**
      * 获取声部更换的销售、总收入
+     *
      * @param startTime
      * @param endTime
      * @return
@@ -131,11 +132,11 @@ public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
     List<OperatingReport> getSubjectChangeMonthReport(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
 
     /**
+     * @param sellOrderIds:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.SellOrder>
      * @describe 获取指定的销售记录
      * @author Joburgess
      * @date 2020.10.13
-     * @param sellOrderIds:
-     * @return java.util.List<com.ym.mec.biz.dal.entity.SellOrder>
      */
     List<SellOrder> getSellOrders(@Param("sellOrderIds") List<Integer> sellOrderIds);
 
@@ -146,4 +147,13 @@ public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
      * @return java.util.List<com.ym.mec.biz.dal.entity.SellOrder>
      */
     List<SellOrder> getNoneBatchNoSellOrders();
+
+
+    /**
+     * 获取订单组合商品的子商品
+     * @param orderId
+     * @param parentGoodsId
+     * @return
+     */
+    List<SellOrder> getSellOrderByParentGoodsId(@Param("orderId") Long orderId, @Param("parentGoodsId") Integer parentGoodsId);
 }

+ 1 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SellStatus.java

@@ -5,9 +5,7 @@ import com.ym.mec.common.enums.BaseEnum;
 
 public enum SellStatus implements BaseEnum<Integer, SellStatus> {
     NORMAL(0, "正常"),
-    ONLY_RETURNED(1, "仅退货"),
-    REFUND(2, "退货退费");
-
+    REFUND(1, "已退货");
     private Integer code;
     private String msg;
 

+ 24 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/page/EndCourseScheduleQueryInfo.java

@@ -43,11 +43,17 @@ public class EndCourseScheduleQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "教师名称")
     private String teacherName;
 
-    @ApiModelProperty(value = "开始时间")
+    @ApiModelProperty(value = "上课开始时间")
     private Date startTime;
 
-    @ApiModelProperty(value = "结束时间")
+    @ApiModelProperty(value = "上课结束时间")
     private Date endTime;
+    
+    @ApiModelProperty(value = "课程创建开始时间")
+    private Date createStartDate;
+    
+    @ApiModelProperty(value = "课程创建结束时间")
+    private Date createEndDate;
 
     @ApiModelProperty(value = "课程状态")
     private CourseStatusEnum courseStatus;
@@ -201,4 +207,20 @@ public class EndCourseScheduleQueryInfo extends QueryInfo {
     public void setClassGroupId(Integer classGroupId) {
         this.classGroupId = classGroupId;
     }
+
+	public Date getCreateStartDate() {
+		return createStartDate;
+	}
+
+	public void setCreateStartDate(Date createStartDate) {
+		this.createStartDate = createStartDate;
+	}
+
+	public Date getCreateEndDate() {
+		return createEndDate;
+	}
+
+	public void setCreateEndDate(Date createEndDate) {
+		this.createEndDate = createEndDate;
+	}
 }

+ 10 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/SellOrderService.java

@@ -35,9 +35,17 @@ public interface SellOrderService extends BaseService<Integer, SellOrder> {
 
 
     /**
+     * 获取组合商品的相关商品
+     * @param orderId
+     * @param parentGoodsId
+     * @return
+     */
+    List<SellOrder> getSellOrderByParentGoodsId(Long orderId,Integer parentGoodsId);
+
+    /**
      * 退货
-     * @param id
+     * @param sellOrders
      * @return
      */
-    SellOrder refund(Integer id);
+    List<SellOrder> refund(List<SellOrder> sellOrders);
 }

+ 21 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -34,6 +34,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
     private SysPaymentConfigService sysPaymentConfigService;
     @Autowired
     private SysUserCashAccountService sysUserCashAccountService;
+    @Autowired
+    private GoodsService goodsService;
 
     @Override
     public BaseDAO<Integer, SellOrder> getDAO() {
@@ -264,28 +266,29 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
     }
 
     @Override
+    public List<SellOrder> getSellOrderByParentGoodsId(Long orderId, Integer parentGoodsId) {
+        return sellOrderDao.getSellOrderByParentGoodsId(orderId, parentGoodsId);
+    }
+
+    @Override
     @Transactional(rollbackFor = Exception.class)
-    public SellOrder refund(Integer id) {
-        SellOrder sellOrder = sellOrderDao.get(id);
+    public List<SellOrder> refund(List<SellOrder> sellOrders) {
+        for (SellOrder sellOrder : sellOrders) {
+            //1、更改销售列表状态
+            sellOrder.setStatus(SellStatus.REFUND);
+            sellOrder.setUpdateTime(new Date());
+            sellOrderDao.update(sellOrder);
 
-        if (!sellOrder.getStatus().equals(SellStatus.NORMAL)) {
-            throw new BizException("当前状态不能退货,请核查");
-        }
-        if (!sellOrder.getType().equals(SellTypeEnum.SCHOOL_BUY)) {
-            throw new BizException("学校采购不能退货");
+            //2、金额退到余额
+            if (sellOrder.getActualAmount().compareTo(BigDecimal.ZERO) > 0) {
+                sysUserCashAccountService.updateBalance(sellOrder.getUserId(), sellOrder.getActualAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "订单:" + sellOrder.getOrderId() + " 商品id:" + sellOrder.getGoodsId() + "退货");
+            }
         }
-        //1、更改销售列表状态
-        sellOrder.setStatus(SellStatus.REFUND);
-        sellOrder.setUpdateTime(new Date());
-        sellOrderDao.update(sellOrder);
-
-        //2、金额退到余额
-        if (sellOrder.getActualAmount().compareTo(BigDecimal.ZERO) > 0) {
-            sysUserCashAccountService.updateBalance(sellOrder.getUserId(), sellOrder.getActualAmount().negate(), PlatformCashAccountDetailTypeEnum.REFUNDS, "退货");
+        //3、退货
+        if (sellOrders.get(0).getAccountType() != null) {
+            goodsService.increaseStock(sellOrders, sellOrders.get(0).getAccountType());
         }
-        //3、商品退回库存 TODO
-
-        return sellOrder;
+        return sellOrders;
     }
 
 }

+ 18 - 20
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java

@@ -258,26 +258,24 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
         subjectChange.setVersion(0);
         subjectChangeDao.insert(subjectChange);
 
-        //
-        if (amountMargin.compareTo(BigDecimal.ZERO) <= 0) {
-            String orderNo = idGeneratorService.generatorId("payment") + "";
-            StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
-            studentPaymentOrder.setUserId(subjectChange.getStudentId());
-            studentPaymentOrder.setGroupType(GroupType.SUBJECT_CHANGE);
-            studentPaymentOrder.setOrderNo(orderNo);
-            studentPaymentOrder.setType(OrderTypeEnum.SUBJECT_CHANGE);
-            studentPaymentOrder.setExpectAmount(BigDecimal.ZERO);
-            studentPaymentOrder.setActualAmount(BigDecimal.ZERO);
-            studentPaymentOrder.setBalancePaymentAmount(BigDecimal.ZERO);
-            studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
-            studentPaymentOrder.setMusicGroupId(subjectChange.getId().toString());
-            studentPaymentOrder.setPaymentChannel("BALANCE");
-            studentPaymentOrder.setUpdateTime(nowDate);
-            studentPaymentOrder.setOrganId(subjectChange.getOrganId());
-            studentPaymentOrder.setRoutingOrganId(subjectChange.getOrganId());
-            studentPaymentOrderService.insert(studentPaymentOrder);
-
-        }
+//        if (amountMargin.compareTo(BigDecimal.ZERO) <= 0) {
+//            String orderNo = idGeneratorService.generatorId("payment") + "";
+//            StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+//            studentPaymentOrder.setUserId(subjectChange.getStudentId());
+//            studentPaymentOrder.setGroupType(GroupType.SUBJECT_CHANGE);
+//            studentPaymentOrder.setOrderNo(orderNo);
+//            studentPaymentOrder.setType(OrderTypeEnum.SUBJECT_CHANGE);
+//            studentPaymentOrder.setExpectAmount(BigDecimal.ZERO);
+//            studentPaymentOrder.setActualAmount(BigDecimal.ZERO);
+//            studentPaymentOrder.setBalancePaymentAmount(BigDecimal.ZERO);
+//            studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
+//            studentPaymentOrder.setMusicGroupId(subjectChange.getId().toString());
+//            studentPaymentOrder.setPaymentChannel("BALANCE");
+//            studentPaymentOrder.setUpdateTime(nowDate);
+//            studentPaymentOrder.setOrganId(subjectChange.getOrganId());
+//            studentPaymentOrder.setRoutingOrganId(subjectChange.getOrganId());
+//            studentPaymentOrderService.insert(studentPaymentOrder);
+//        }
         return subjectChange;
     }
 

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -857,6 +857,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			throw new BizException("请指定vip课程");
 		}
 		VipGroupManageDetailDto vipGroupBaseInfo = vipGroupDao.getVipGroupBaseInfo(vipGroupId);
+		if(Objects.nonNull(vipGroupBaseInfo.getEducationalTeacherId())){
+			SysUser eduUser = sysUserFeignService.queryUserById(vipGroupBaseInfo.getEducationalTeacherId());
+			if(Objects.nonNull(eduUser)){
+				vipGroupBaseInfo.setEducationalTeacherName(eduUser.getRealName());
+			}
+		}
 		vipGroupBaseInfo.setSubjectName(StringUtils.join(subjectDao.findBySubIds(vipGroupBaseInfo.getSubjectIdList()),","));
 		ClassGroupTeacherSalary byVipGoupAndTeacher = classGroupTeacherSalaryDao.findByVipGoupAndTeacher(vipGroupId.intValue(), vipGroupBaseInfo.getUserId());
 		Integer onlineNum = courseScheduleDao.countCourseNum(vipGroupId,"ONLINE");

+ 13 - 7
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -2417,21 +2417,27 @@
         <if test="isCallNames != null and isCallNames == 0">
             AND sa.id_ IS NULL
         </if>
-        <if test="startTime!=null and endTime==null">
-            AND cs.class_date_ &gt; DATE_FORMAT(#{startTime},"%Y-%m-%d")
+        <if test="startTime!=null">
+            AND cs.class_date_ &gt;= DATE_FORMAT(#{startTime},"%Y-%m-%d")
         </if>
-        <if test="startTime==null and endTime!=null">
-            AND cs.class_date_ &lt; DATE_FORMAT(#{endTime},"%Y-%m-%d")
-        </if>
-        <if test="startTime!=null and endTime!=null">
-            AND cs.class_date_ BETWEEN DATE_FORMAT(#{startTime},"%Y-%m-%d") AND DATE_FORMAT(#{endTime},"%Y-%m-%d")
+        <if test="endTime!=null">
+            AND cs.class_date_ &lt;= DATE_FORMAT(#{endTime},"%Y-%m-%d")
         </if>
         <if test="courseStatus!=null">
             AND cs.status_ = #{courseStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
         </if>
+        <if test="createStartDate!=null">
+            AND date(cs.create_time_) &gt;= date(#{createStartDate})
+        </if>
+        <if test="createEndDate!=null">
+            AND date(cs.create_time_) &lt;= date(#{createEndDate})
+        </if>
         <if test="courseType!=null">
             AND cs.type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
         </if>
+        <if test="groupType!=null">
+            AND cs.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        </if>
         <if test="schoolId!=null">
             AND cs.schoole_id_ = #{schoolId}
         </if>

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -490,6 +490,10 @@
         </foreach>
     </select>
 
+    <select id="getSellOrderByParentGoodsId" resultMap="SellOrder">
+        SELECT * FROM sell_order WHERE order_id_ = #{orderId} AND parent_goods_id_ = #{parentGoodsId}
+    </select>
+
     <select id="getNoneBatchNoSellOrders" resultMap="SellOrder">
         SELECT * FROM sell_order WHERE stock_type_ IS NOT NULL AND batch_no_ IS NULL
     </select>

+ 25 - 4
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherController.java

@@ -1,6 +1,8 @@
 package com.ym.mec.teacher.controller;
 
-import com.ym.mec.biz.service.ImGroupNoticeService;
+import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.service.*;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.QueryInfo;
 
 import io.swagger.annotations.Api;
@@ -28,9 +30,6 @@ import com.ym.mec.biz.dal.page.TeacherCloseQueryInfo;
 import com.ym.mec.biz.dal.page.TeacherMusicClassQueryInfo;
 import com.ym.mec.biz.dal.page.VipClassQueryInfo;
 import com.ym.mec.biz.dal.page.queryMusicGroupStudentQueryInfo;
-import com.ym.mec.biz.service.ClassGroupService;
-import com.ym.mec.biz.service.SubjectService;
-import com.ym.mec.biz.service.TeacherService;
 import com.ym.mec.common.controller.BaseController;
 
 @RequestMapping("teacher")
@@ -50,6 +49,8 @@ public class TeacherController extends BaseController {
     private SysUserFeignService sysUserFeignService;
 	@Autowired
 	private SubjectDao subjectDao;
+	@Autowired
+    private EmployeeService employeeService;
 
     @ApiOperation(value = "修改教师个人中心信息")
     @PostMapping("/update")
@@ -182,4 +183,24 @@ public class TeacherController extends BaseController {
 		teacherService.realNameAuthentication(user.getId(), realName, idcardNo, idcardFrontImg, idcardBackImg, idcardHandImg);
 		return succeed();
 	}
+
+    @ApiOperation(value = "获取教务人员")
+    @GetMapping("/findEducationUsers")
+    public HttpResponseResult findEducationUsers(Integer userId){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        String organIds = new String();
+        if (!sysUser.getIsSuperAdmin()) {
+            Teacher teacher = teacherService.get(sysUser.getId());
+            if (StringUtils.isEmpty(organIds)) {
+                organIds = teacher.getTeacherOrganId() + "";
+            }
+            if(StringUtils.isNotBlank(teacher.getFlowOrganRange())){
+                organIds = organIds + "," + teacher.getFlowOrganRange();
+            }
+        }
+        return succeed(employeeService.findByRole("4,5",organIds));
+    }
 }

+ 24 - 2
mec-web/src/main/java/com/ym/mec/web/controller/SellOrderController.java

@@ -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));
     }
 
 }