Sfoglia il codice sorgente

[订单接口][新增]:频道下架检查

release_toaliyun_real
Stormeye.Wu 7 anni fa
parent
commit
5a3c76732c
3 ha cambiato i file con 86 aggiunte e 14 eliminazioni
  1. +47
    -14
      mallinkCApi/src/main/java/com/simple/controller/WxOrderController.java
  2. +1
    -0
      mallinkService/src/main/java/com/simple/common/ErrorCode.java
  3. +38
    -0
      mallinkService/src/main/java/com/simple/enums/EnumCouponChannelStatus.java

+ 47
- 14
mallinkCApi/src/main/java/com/simple/controller/WxOrderController.java Vedi File

@@ -2,8 +2,12 @@ package com.simple.controller;

import com.simple.common.ErrorCode;
import com.simple.domain.po.WxCUser;
import com.simple.domain.po.WxCouponChannel;
import com.simple.enums.EnumCouponChannelStatus;
import com.simple.enums.EnumCouponStatus;
import com.simple.enums.EnumOrderStatus;
import com.simple.exception.MallinkException;
import com.simple.service.WxCouponChannelService;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
@@ -28,24 +32,40 @@ import java.util.Map;
public class WxOrderController extends BaseController {
private Logger logger = Logger.getLogger(WxOrderController.class);

@Autowired
private WxCouponChannelService wxCouponChannelService;

@Autowired
private WxOrderService wxOrderService;

@ApiOperation(value = "免费领取", notes = "{\"couponId\":\"String\"}")
@ApiOperation(value = "免费领取", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\"}")
@PostMapping("freeCoupon")
public ResultData freeCoupon(@RequestBody Map<String, String> paramMap) {
//Assert.notNull(wxOrders.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
String couponChannelIdStr = paramMap.get("couponChannelId");
String couponIdStr = paramMap.get("couponId");
if (StringUtils.isBlank(couponIdStr)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponId不能为空");
if (StringUtils.isBlank(couponChannelIdStr)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId不能为空");
}
Long couponId = 0L;
Long couponChannelId = 0L, couponId = 0L;
try {
couponId = Long.valueOf(couponIdStr);
couponChannelId = Long.valueOf(couponChannelIdStr);
} catch (NumberFormatException e) {
logger.error("couponId convert error, " + couponIdStr + ", e:" + e.getMessage());
return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "couponId: " + couponIdStr + ", e:" + e.getMessage());
logger.error("couponChannelId convert error, " + couponChannelIdStr + ", e:" + e.getMessage());
return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "couponChannelId: " + couponChannelIdStr + ", e:" + e.getMessage());
}
WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(couponChannelId);
if (wxCouponChannel == null) {
logger.error("couponChannelId convert error, " + couponChannelIdStr);
return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "找不到发布的频道");
}
if (wxCouponChannel.getStatus() == EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()) {
logger.error("此券已下架:" + couponChannelIdStr);
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(), "此券已下架");
}
if (StringUtils.isBlank(couponIdStr)) {
couponId = wxCouponChannel.getCouponId();
}

WxCUser user = getUser();
@@ -64,21 +84,34 @@ public class WxOrderController extends BaseController {
}
}

@ApiOperation(value = "下订单", notes = "{\"couponId\":\"String\"}")
@ApiOperation(value = "下订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\"}")
@PostMapping("save")
public ResultData saveOrder(@RequestBody Map<String, String> paramMap) {
//Assert.notNull(wxOrders.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
String couponChannelIdStr = paramMap.get("couponChannelId");
String couponIdStr = paramMap.get("couponId");
if (StringUtils.isBlank(couponIdStr)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponId不能为空");
if (StringUtils.isBlank(couponChannelIdStr)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId不能为空");
}
Long couponId = 0L;
Long couponChannelId = 0L, couponId = 0L;
try {
couponId = Long.valueOf(couponIdStr);
couponChannelId = Long.valueOf(couponChannelIdStr);
} catch (NumberFormatException e) {
logger.error("couponId convert error, " + couponIdStr + ", e:" + e.getMessage());
return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "couponId: " + couponIdStr + ", e:" + e.getMessage());
logger.error("couponChannelId convert error, " + couponChannelIdStr + ", e:" + e.getMessage());
return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "couponChannelId: " + couponChannelIdStr + ", e:" + e.getMessage());
}
WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(couponChannelId);
if (wxCouponChannel == null) {
logger.error("couponChannelId convert error, " + couponChannelIdStr);
return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "找不到发布的频道");
}
if (wxCouponChannel.getStatus() == EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()) {
logger.error("此券已下架:" + couponChannelIdStr);
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF.getCode(), "此券已下架");
}
if (StringUtils.isBlank(couponIdStr)) {
couponId = wxCouponChannel.getCouponId();
}
WxCUser user = getUser();



+ 1
- 0
mallinkService/src/main/java/com/simple/common/ErrorCode.java Vedi File

@@ -69,6 +69,7 @@ public enum ErrorCode{
*/
COUPON_IS_EMPTY(2020, "券不存在"),
COUPON_IS_NOT_FREE(2021, "券不免费"),
COUPON_IS_TAKE_OFF(2022, "此券已下架"),

/**
* 车流 2040


+ 38
- 0
mallinkService/src/main/java/com/simple/enums/EnumCouponChannelStatus.java Vedi File

@@ -0,0 +1,38 @@
package com.simple.enums;

/**
* Created by Stormeye on 2018/08/09.
*/
public enum EnumCouponChannelStatus {

// 0-草稿/待生效;1-已生效/已发布/已投放;2-已下架;

STATUS_THROW_IN(0, "已上架"),
STATUS_TAKE_OFFF(1, "已下架"),
;

public static EnumCouponChannelStatus getEnum(Integer code) {
for (EnumCouponChannelStatus value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumCouponChannelStatus(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

Caricamento…
Annulla
Salva