|
@@ -0,0 +1,140 @@
|
|
|
+package com.ym.mec.teacher.controller;
|
|
|
+
|
|
|
+import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
+import com.ym.mec.auth.api.entity.SysUser;
|
|
|
+import com.ym.mec.biz.dal.dao.EmployeeDao;
|
|
|
+import com.ym.mec.biz.dal.dto.BasicUserDto;
|
|
|
+import com.ym.mec.biz.dal.entity.Employee;
|
|
|
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
|
|
|
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
|
|
|
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
|
|
|
+import com.ym.mec.biz.dal.page.GoodsCategoryQueryInfo;
|
|
|
+import com.ym.mec.biz.dal.page.GoodsQueryInfo;
|
|
|
+import com.ym.mec.biz.dal.page.GoodsSellQueryInfo;
|
|
|
+import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
+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 io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+@RequestMapping("eduRepair")
|
|
|
+@Api(tags = "教务维修服务")
|
|
|
+@RestController
|
|
|
+public class EduRepairController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
+ @Autowired
|
|
|
+ private EmployeeDao employeeDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentRepairService studentRepairService;
|
|
|
+ @Autowired
|
|
|
+ private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
+ @Autowired
|
|
|
+ private GoodsService goodsService;
|
|
|
+ @Autowired
|
|
|
+ private GoodsCategoryService goodsCategoryService;
|
|
|
+ @Autowired
|
|
|
+ private StudentGoodsSellService studentGoodsSellService;
|
|
|
+
|
|
|
+ @ApiOperation("获取学生列表")
|
|
|
+ @GetMapping(value = "/getStudents")
|
|
|
+ public HttpResponseResult<PageInfo<BasicUserDto>> getStudents(RepairStudentQueryInfo queryInfo) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ Employee employee = employeeDao.get(sysUser.getId());
|
|
|
+ if (Objects.isNull(employee)) {
|
|
|
+ return failed(HttpStatus.NOT_ACCEPTABLE, "员工信息不存在");
|
|
|
+ }
|
|
|
+ queryInfo.setEmployeeId(sysUser.getId());
|
|
|
+ queryInfo.setOrganIdList(employee.getOrganIdList());
|
|
|
+ return succeed(studentRepairService.getStudents(queryInfo));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("添加商品销售订单")
|
|
|
+ @PostMapping(value = "/addGoodsSellOrder")
|
|
|
+ public HttpResponseResult addGoodsSellOrder(@RequestBody StudentGoodsSell studentGoodsSell) throws Exception {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ throw new BizException("请登录");
|
|
|
+ }
|
|
|
+ if (studentGoodsSell.getIsRepeatPay() == false) {
|
|
|
+ List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.GOODS_SELL, null, studentGoodsSell.getUserId(), DealStatusEnum.ING,
|
|
|
+ OrderTypeEnum.RENEW);
|
|
|
+ if (list.size() > 0) {
|
|
|
+ return failed(HttpStatus.CONTINUE, "该学员有待支付的订单");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ studentGoodsSell.setTeacherId(sysUser.getId());
|
|
|
+ studentGoodsSell.setAuthorUser(sysUser.getId());
|
|
|
+ Map map = studentRepairService.addGoodsSellOrder(studentGoodsSell);
|
|
|
+ if (map.containsKey("tradeState")) {
|
|
|
+ return failed(HttpStatus.CREATED, map, "恭喜您,购买成功!");
|
|
|
+ }
|
|
|
+ return succeed(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("获取学生信息")
|
|
|
+ @GetMapping(value = "/getStudentInfo")
|
|
|
+ public HttpResponseResult getStudentInfo(Integer studentId) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed("用户信息获取失败");
|
|
|
+ }
|
|
|
+ return succeed(studentRepairService.getStudentInfo(studentId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "分页查询商品(教材、辅件)列表")
|
|
|
+ @GetMapping("/queryGoodsPage")
|
|
|
+ public Object queryPage(GoodsQueryInfo queryInfo) {
|
|
|
+ queryInfo.setOrganId(null);
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed("用户信息获取失败");
|
|
|
+ }
|
|
|
+ Employee employee = employeeDao.get(sysUser.getId());
|
|
|
+ if (queryInfo.getStudentShowOrganId() == null &&
|
|
|
+ queryInfo.getEducationShowOrganId() == null &&
|
|
|
+ queryInfo.getCourseFeeShowOrganId() == null &&
|
|
|
+ queryInfo.getMemberFeeShowOrganId() == null &&
|
|
|
+ queryInfo.getReplacementShowOrganId() == null) {
|
|
|
+ queryInfo.setEducationShowOrganId(employee.getOrganIdList());
|
|
|
+ } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
|
|
|
+ return failed("用户所在分部异常");
|
|
|
+ }
|
|
|
+ return succeed(goodsService.queryPage(queryInfo));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "分页查询商品分类列表")
|
|
|
+ @GetMapping("/queryGoodsCategoryPage")
|
|
|
+ public Object queryGoodsCategoryPage(GoodsCategoryQueryInfo queryInfo) {
|
|
|
+ return succeed(goodsCategoryService.queryPage(queryInfo));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "分页查询教务老师关联的学员商品订单")
|
|
|
+ @GetMapping("/queryStudentGoodsOrders")
|
|
|
+ public Object queryStudentGoodsOrders(GoodsSellQueryInfo queryInfo) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ queryInfo.setTeacherId(sysUser.getId());
|
|
|
+ return succeed(studentGoodsSellService.queryStudentGoodsOrders(queryInfo));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|