|
@@ -19,6 +19,7 @@ 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.apache.poi.util.Internal;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -31,67 +32,87 @@ import java.util.Map;
|
|
|
@RestController
|
|
|
public class SporadicChargeInfoController extends BaseController {
|
|
|
|
|
|
- @Autowired
|
|
|
- private SporadicChargeInfoService sporadicChargeInfoService;
|
|
|
- @Autowired
|
|
|
- private SysUserFeignService sysUserFeignService;
|
|
|
- @Autowired
|
|
|
- private SysUserCashAccountDao sysUserCashAccountDao;
|
|
|
- @Autowired
|
|
|
- private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
- @Autowired
|
|
|
- private MusicGroupService musicGroupService;
|
|
|
+ @Autowired
|
|
|
+ private SporadicChargeInfoService sporadicChargeInfoService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserCashAccountDao sysUserCashAccountDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupService musicGroupService;
|
|
|
|
|
|
- @ApiOperation(value = "单查询")
|
|
|
- @GetMapping("/get")
|
|
|
- public Object get(Integer id,Integer userId) {
|
|
|
- if(userId == null){
|
|
|
- SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
- if (sysUser == null || sysUser.getId() == null) {
|
|
|
- return failed("用户不存在");
|
|
|
- }
|
|
|
- userId = sysUser.getId();
|
|
|
- }
|
|
|
- SporadicChargeInfo chargeInfo = sporadicChargeInfoService.get(id);
|
|
|
- if(chargeInfo != null){
|
|
|
- SysUserCashAccount locked = sysUserCashAccountDao.getLocked(userId);
|
|
|
- chargeInfo.setBalance(locked.getBalance());
|
|
|
- }else {
|
|
|
- throw new BizException("信息不存在");
|
|
|
- }
|
|
|
- return succeed(chargeInfo);
|
|
|
- }
|
|
|
+ @ApiOperation(value = "单查询")
|
|
|
+ @GetMapping("/get")
|
|
|
+ public Object get(Integer id, Integer userId) {
|
|
|
+ if (userId == null) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null || sysUser.getId() == null) {
|
|
|
+ return failed("用户不存在");
|
|
|
+ }
|
|
|
+ userId = sysUser.getId();
|
|
|
+ }
|
|
|
+ SporadicChargeInfo chargeInfo = sporadicChargeInfoService.get(id);
|
|
|
+ if (chargeInfo != null) {
|
|
|
+ SysUserCashAccount locked = sysUserCashAccountDao.getLocked(userId);
|
|
|
+ chargeInfo.setBalance(locked.getBalance());
|
|
|
+ } else {
|
|
|
+ throw new BizException("信息不存在");
|
|
|
+ }
|
|
|
+ return succeed(chargeInfo);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- @ApiOperation(value = "零星支付")
|
|
|
- @PostMapping("/sporadicPay")
|
|
|
- public HttpResponseResult sporadicPay(@RequestBody SporadicPayDto sporadicPayDto) throws Exception {
|
|
|
- if(sporadicPayDto == null ||
|
|
|
- sporadicPayDto.getSporadicId() == null ||
|
|
|
- sporadicPayDto.getAmount() == null){
|
|
|
- throw new BizException("参数校验失败");
|
|
|
- }
|
|
|
- if(sporadicPayDto.getUserId() == null){
|
|
|
- SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
- if (sysUser == null || sysUser.getId() == null) {
|
|
|
- return failed("用户不存在");
|
|
|
- }
|
|
|
+ @ApiOperation(value = "零星支付")
|
|
|
+ @PostMapping("/sporadicPay")
|
|
|
+ public HttpResponseResult sporadicPay(@RequestBody SporadicPayDto sporadicPayDto) throws Exception {
|
|
|
+ if (sporadicPayDto == null ||
|
|
|
+ sporadicPayDto.getSporadicId() == null ||
|
|
|
+ sporadicPayDto.getAmount() == null) {
|
|
|
+ throw new BizException("参数校验失败");
|
|
|
+ }
|
|
|
+ if (sporadicPayDto.getUserId() == null) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null || sysUser.getId() == null) {
|
|
|
+ return failed("用户不存在");
|
|
|
+ }
|
|
|
if(sysUser.getUserType().toLowerCase().indexOf(SysUserType.STUDENT.getCode().toLowerCase()) < 0){
|
|
|
- return failed("用户信息异常");
|
|
|
- }
|
|
|
- sporadicPayDto.setUserId(sysUser.getId());
|
|
|
- }
|
|
|
- if (sporadicPayDto.getIsRepeatPay() == false) {
|
|
|
- Integer ingOrder = studentPaymentOrderService.findOrderByGroupType(sporadicPayDto.getUserId(),sporadicPayDto.getSporadicId(),"SPORADIC", DealStatusEnum.ING);
|
|
|
- if (ingOrder != null && ingOrder > 0) {
|
|
|
- return failed(HttpStatus.CONTINUE, "您有待支付的订单");
|
|
|
- }
|
|
|
- }
|
|
|
- Map payMap = musicGroupService.sporadicPay(sporadicPayDto);
|
|
|
- if(payMap.containsKey("tradeState")){
|
|
|
- return failed(HttpStatus.CREATED, "恭喜您,购买成功!");
|
|
|
- }
|
|
|
- return succeed(payMap);
|
|
|
- }
|
|
|
+ return failed("用户信息异常");
|
|
|
+ }
|
|
|
+ sporadicPayDto.setUserId(sysUser.getId());
|
|
|
+ }
|
|
|
+ if (sporadicPayDto.getIsRepeatPay() == false) {
|
|
|
+ Integer ingOrder = studentPaymentOrderService.findOrderByGroupType(sporadicPayDto.getUserId(), sporadicPayDto.getSporadicId(), "SPORADIC", DealStatusEnum.ING);
|
|
|
+ if (ingOrder != null && ingOrder > 0) {
|
|
|
+ return failed(HttpStatus.CONTINUE, "您有待支付的订单");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map payMap = musicGroupService.sporadicPay(sporadicPayDto);
|
|
|
+ if (payMap.containsKey("tradeState")) {
|
|
|
+ return failed(HttpStatus.CREATED, "恭喜您,支付成功!");
|
|
|
+ }
|
|
|
+ return succeed(payMap);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "福袋活动信息")
|
|
|
+ @RequestMapping("/activityInfo")
|
|
|
+ public HttpResponseResult activityInfo(Integer type) throws Exception {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null || sysUser.getId() == null) {
|
|
|
+ return failed("请先登录");
|
|
|
+ }
|
|
|
+ if (sysUser.getOrganId() == null || sysUser.getOrganId().isEmpty()) {
|
|
|
+ return failed("用户信息有误,没有分部信息");
|
|
|
+ }
|
|
|
+ Integer organId = Integer.parseInt(sysUser.getOrganId());
|
|
|
+
|
|
|
+ if (type == null || type <= 0) {
|
|
|
+ return failed("参数不合法");
|
|
|
+ }
|
|
|
+ SporadicChargeInfo chargeInfo = sporadicChargeInfoService.findByOrganIdAndType(organId, type);
|
|
|
+ return succeed(chargeInfo);
|
|
|
+ }
|
|
|
|
|
|
}
|