123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- package com.ym.mec.student.controller;
- import com.ym.mec.auth.api.client.SysUserFeignService;
- import com.ym.mec.auth.api.entity.SysUser;
- import com.ym.mec.biz.dal.entity.StudentGoodsSell;
- import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
- import com.ym.mec.biz.dal.entity.StudentRepair;
- 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.enums.PayStatus;
- 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 io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- 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;
- @RequestMapping("repair")
- @Api(tags = "学生维修服务")
- @RestController
- public class RepairController extends BaseController {
- @Autowired
- private SysUserFeignService sysUserFeignService;
- @Autowired
- private StudentRepairService studentRepairService;
- @Autowired
- private StudentPaymentOrderService studentPaymentOrderService;
- @Autowired
- private GoodsService goodsService;
- @Autowired
- private GoodsCategoryService goodsCategoryService;
- @Autowired
- private StudentGoodsSellService studentGoodsSellService;
- @ApiOperation("添加商品销售订单")
- @PostMapping(value = "/addGoodsSellOrder")
- public HttpResponseResult addGoodsSellOrder(@RequestBody StudentGoodsSell studentGoodsSell) throws Exception {
- if(studentGoodsSell.getUserId() == null){
- SysUser sysUser = sysUserFeignService.queryUserInfo();
- if (sysUser == null) {
- throw new BizException("请登录");
- }
- studentGoodsSell.setUserId(sysUser.getId());
- }
- if (studentGoodsSell.getIsRepeatPay() == false) {
- List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.GOODS_SELL, null, studentGoodsSell.getUserId(), DealStatusEnum.ING,
- OrderTypeEnum.GOODS_SELL);
- if (list.size() > 0) {
- StudentPaymentOrder applyOrder = list.get(list.size() - 1);
- // 查询订单状态
- PayStatus payStatus = studentPaymentOrderService.queryPayStatus(applyOrder.getPaymentChannel(), applyOrder.getOrderNo(), applyOrder.getTransNo());
- if(payStatus == PayStatus.SUCCESSED){
- throw new BizException("订单已支付成功,请勿重复支付");
- }else if(payStatus == PayStatus.PAYING){
- throw new BizException("订单还在交易中,请稍后重试");
- }
- return failed(HttpStatus.CONTINUE, "您有待支付的订单");
- }
- }
- studentGoodsSell.setAuthorUser(studentGoodsSell.getUserId());
- Map map = studentRepairService.addGoodsSellOrder(studentGoodsSell);
- if(map.containsKey("tradeState")){
- return failed(HttpStatus.CREATED, map,"恭喜您,购买成功!");
- }
- return succeed(map);
- }
- @ApiOperation("学员扫码支付")
- @PostMapping(value = "/studentPaymentGoodsOrder")
- public HttpResponseResult studentPaymentGoodsOrder(Integer goodsSellId) throws Exception {
- Map map = studentRepairService.studentPaymentGoodsOrder(goodsSellId);
- if(map.containsKey("tradeState")){
- return failed(HttpStatus.CREATED, map,"恭喜您,购买成功!");
- }
- return succeed(map);
- }
- @ApiOperation("获取维修记录")
- @GetMapping(value = "/getStudentRepairList")
- public HttpResponseResult getStudentRepairList(RepairStudentQueryInfo queryInfo) {
- SysUser sysUser = sysUserFeignService.queryUserInfo();
- if (sysUser == null) {
- return failed("用户信息获取失败");
- }
- queryInfo.setStudentId(sysUser.getId());
- queryInfo.setPayStatus(2);
- return succeed(studentRepairService.queryPage(queryInfo));
- }
- @ApiOperation("获取维修记录详情")
- @GetMapping(value = "/getRepairInfo")
- public HttpResponseResult getRepairInfo(Integer id,Integer studentId) {
- SysUser sysUser = sysUserFeignService.queryUserInfo();
- if ((sysUser == null || sysUser.getId() ==null) && studentId == null) {
- return failed("用户信息获取失败");
- }
- if(sysUser.getId() != null){
- studentId = sysUser.getId();
- }
- StudentRepair repairInfo = studentRepairService.getRepairInfo(id);
- if (!repairInfo.getStudentId().equals(studentId)) {
- return failed("您的维修记录不存在");
- }
- return succeed(repairInfo);
- }
- @ApiOperation("支付维修单")
- @PostMapping(value = "/payRepair")
- public HttpResponseResult payRepair(StudentRepair repairInfo) throws Exception {
- SysUser sysUser = sysUserFeignService.queryUserInfo();
- if (sysUser == null) {
- return failed(HttpStatus.FORBIDDEN, "请登录");
- }
- return succeed(studentRepairService.payRepair(repairInfo));
- }
- @ApiOperation("获取维修技师信息")
- @PostMapping(value = "/getRepairer")
- public HttpResponseResult getRepairer() {
- SysUser sysUser = sysUserFeignService.queryUserInfo();
- if (sysUser == null) {
- return failed(HttpStatus.FORBIDDEN, "请登录");
- }
- return succeed(studentRepairService.getStudentRepairer(sysUser.getId(),sysUser.getOrganId()));
- }
- @ApiOperation(value = "分页查询商品(教材、辅件)列表")
- @GetMapping("/queryGoodsPage")
- public Object queryPage(GoodsQueryInfo queryInfo){
- SysUser sysUser = sysUserFeignService.queryUserInfo();
- if(sysUser == null){
- throw new BizException("请先登录");
- }
- queryInfo.setStudentShowOrganId(sysUser.getOrganId().toString());
- 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.setStudentId(sysUser.getId());
- return succeed(studentGoodsSellService.queryStudentGoodsOrders(queryInfo));
- }
- @ApiOperation(value = "获取学员商品订单")
- @GetMapping("/getStudentGoodsOrder")
- public Object getStudentGoodsOrder(Integer goodsSellId) {
- return succeed(studentGoodsSellService.getStudentGoodsOrder(goodsSellId));
- }
- @ApiOperation(value = "确认收货")
- @PostMapping("/affirmReceive")
- public Object affirmReceive(String orderNo) {
- studentGoodsSellService.affirmReceive(orderNo);
- return succeed();
- }
- }
|