| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 | 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.dao.StudentDao;import com.ym.mec.biz.dal.dto.DegreeFeeDto;import com.ym.mec.biz.dal.dto.DegreePayDto;import com.ym.mec.biz.dal.entity.ChildrenDayDegreeDetail;import com.ym.mec.biz.dal.entity.ChildrenDayReserve;import com.ym.mec.biz.dal.enums.YesOrNoEnum;import com.ym.mec.biz.service.ChildrenDayDegreeDetailService;import com.ym.mec.biz.service.ChildrenDayReserveService;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;import java.util.Objects;@RequestMapping("childrenDay")@Api(tags = "6.1儿童节活动")@RestControllerpublic class ChildrenDayController extends BaseController {    @Autowired    private SysUserFeignService sysUserFeignService;    @Autowired    private ChildrenDayReserveService childrenDayReserveService;    @Autowired    private StudentDao studentDao;    @Autowired    private ChildrenDayDegreeDetailService childrenDayDegreeDetailService;    @ApiOperation(value = "占位")    @PostMapping("/reserve")    public HttpResponseResult<ChildrenDayReserve> reserve() {        SysUser user = sysUserFeignService.queryUserInfo();        if (Objects.isNull(user)) {            return failed(HttpStatus.FORBIDDEN, "请登录");        }        return succeed(childrenDayReserveService.addReserve(user, YesOrNoEnum.YES));    }    @ApiOperation(value = "获取占位信息")    @GetMapping("/getReserve")    public HttpResponseResult<ChildrenDayReserve> getReserve() {        SysUser user = sysUserFeignService.queryUserInfo();        if (Objects.isNull(user)) {            return failed(HttpStatus.FORBIDDEN, "请登录");        }        return succeed(childrenDayReserveService.getUserReserve(user.getId()));    }    @ApiOperation(value = "获取考级相关的价格")    @GetMapping("/getFeeInfo")    public HttpResponseResult<DegreeFeeDto> getFeeInfo() {        SysUser user = sysUserFeignService.queryUserInfo();        if (Objects.isNull(user)) {            return failed(HttpStatus.FORBIDDEN, "请登录");        }        return succeed(childrenDayReserveService.getFeeInfo(user.getOrganId()));    }    @ApiOperation(value = "6.1考级支付")    @PostMapping("/pay")    public HttpResponseResult pay(@RequestBody DegreePayDto degreePayDto) throws Exception {        SysUser sysUser = sysUserFeignService.queryUserInfo();        if (sysUser == null) {            throw new BizException("用户信息获取失败,请重新登陆");        }        studentDao.lockUser(sysUser.getId());        degreePayDto.setUserId(sysUser.getId());        degreePayDto.setOrganId(sysUser.getOrganId());        degreePayDto.setUser(sysUser);        List<ChildrenDayDegreeDetail> ingDetails = childrenDayDegreeDetailService.getByUserIdAndStatus(sysUser.getId(), 1);        if (!degreePayDto.getRePay() && ingDetails.size() > 0) {            return failed(HttpStatus.CONTINUE, "您有待支付的订单");        }        Map payMap = childrenDayReserveService.pay(degreePayDto);        if (payMap.containsKey("tradeState")) {            return failed(HttpStatus.CREATED, payMap, "恭喜您,支付成功!");        }        return succeed(payMap);    }}
 |