|
|
@@ -31,6 +31,37 @@ public class WxOrderController extends BaseController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private WxOrderService wxOrderService; |
|
|
private WxOrderService wxOrderService; |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "免费领取", notes = "{\"couponId\":\"String\"}") |
|
|
|
|
|
@PostMapping("freeCoupon") |
|
|
|
|
|
public ResultData freeCoupon(@RequestBody Map<String, String> paramMap) { |
|
|
|
|
|
//Assert.notNull(wxOrders.getName(), "角色名不能为空"); |
|
|
|
|
|
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); |
|
|
|
|
|
String couponIdStr = paramMap.get("couponId"); |
|
|
|
|
|
if (StringUtils.isBlank(couponIdStr)) { |
|
|
|
|
|
return new ResultData(ErrorCode.PARAMETER_NOT_NULL.getCode(), "couponId不能为空"); |
|
|
|
|
|
} |
|
|
|
|
|
Long couponId = 0L; |
|
|
|
|
|
try { |
|
|
|
|
|
couponId = Long.valueOf(couponIdStr); |
|
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
|
logger.error("couponId convert error, " + couponIdStr + ", e:" + e.getMessage()); |
|
|
|
|
|
return new ResultData(ErrorCode.PARAMETER_CAST_ERROR.getCode(), "couponId: " + couponIdStr + ", e:" + e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Long cUserId = getUserId(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
WxOrder order = wxOrderService.sendUserFreeCoupon(cUserId, couponId); |
|
|
|
|
|
return new ResultData(order); |
|
|
|
|
|
} catch (MallinkException e) { |
|
|
|
|
|
logger.error(e.getMessage()); |
|
|
|
|
|
return new ResultData(e.getErrorCode(), e.getMessage()); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error(e.getMessage()); |
|
|
|
|
|
return new ResultData(ErrorCode.ORDER_IS_FAIL, e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ApiOperation(value = "下订单", notes = "{\"couponId\":\"String\"}") |
|
|
@ApiOperation(value = "下订单", notes = "{\"couponId\":\"String\"}") |
|
|
@PostMapping("save") |
|
|
@PostMapping("save") |
|
|
public ResultData saveOrder(@RequestBody Map<String, String> paramMap) { |
|
|
public ResultData saveOrder(@RequestBody Map<String, String> paramMap) { |
|
|
@@ -40,7 +71,13 @@ public class WxOrderController extends BaseController { |
|
|
if (StringUtils.isBlank(couponIdStr)) { |
|
|
if (StringUtils.isBlank(couponIdStr)) { |
|
|
return new ResultData(ErrorCode.PARAMETER_NOT_NULL.getCode(), "couponId不能为空"); |
|
|
return new ResultData(ErrorCode.PARAMETER_NOT_NULL.getCode(), "couponId不能为空"); |
|
|
} |
|
|
} |
|
|
Long couponId = Long.valueOf(couponIdStr); |
|
|
|
|
|
|
|
|
Long couponId = 0L; |
|
|
|
|
|
try { |
|
|
|
|
|
couponId = Long.valueOf(couponIdStr); |
|
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
|
logger.error("couponId convert error, " + couponIdStr + ", e:" + e.getMessage()); |
|
|
|
|
|
return new ResultData(ErrorCode.PARAMETER_CAST_ERROR.getCode(), "couponId: " + couponIdStr + ", e:" + e.getMessage()); |
|
|
|
|
|
} |
|
|
WxCUser user = getUser(); |
|
|
WxCUser user = getUser(); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
|