|
|
|
@@ -1,27 +1,24 @@ |
|
|
|
package com.iformall.controller; |
|
|
|
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.WxCUser; |
|
|
|
import com.iformall.domain.po.WxCoupon; |
|
|
|
import com.iformall.domain.po.WxOrder; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.service.WxCouponService; |
|
|
|
import com.iformall.service.WxOrderPressService; |
|
|
|
import com.iformall.service.WxOrderService; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiImplicitParam; |
|
|
|
import io.swagger.annotations.ApiImplicitParams; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@RestController |
|
|
|
@RequestMapping("/api/press") |
|
|
|
@@ -46,10 +43,21 @@ public class WxPressOrderController extends BaseController { |
|
|
|
|
|
|
|
// 砍价券详情 - /api/order/pressOrderDetail |
|
|
|
|
|
|
|
@ApiOperation("参与砍价") |
|
|
|
@ApiOperation(value = "参与砍价", notes = "{\"orderId\":\"String\"}") |
|
|
|
@PostMapping("pressOrderJoin") |
|
|
|
public ResultData pressOrderJoin(Long orderId) { |
|
|
|
public ResultData pressOrderJoin(@RequestBody Map<String, String> paramMap) { |
|
|
|
Date curDate = new Date(); |
|
|
|
String orderIdStr = paramMap.get("orderId"); |
|
|
|
if (StringUtils.isBlank(orderIdStr)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); |
|
|
|
} |
|
|
|
Long orderId = 0L; |
|
|
|
try { |
|
|
|
orderId = Long.valueOf(orderIdStr); |
|
|
|
} catch (NumberFormatException e) { |
|
|
|
logger.error("orderId convert error, " + orderIdStr + ", e:" + e.getMessage()); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "orderId: " + orderIdStr + ", e:" + e.getMessage()); |
|
|
|
} |
|
|
|
WxCUser user = getUser(); |
|
|
|
WxOrder order = wxOrderService.getById(orderId); |
|
|
|
if(order == null) { |
|
|
|
@@ -72,7 +80,12 @@ public class WxPressOrderController extends BaseController { |
|
|
|
return new ResultData(ErrorCode.COUPON_PRESS_HAD_FINISHED); |
|
|
|
} |
|
|
|
|
|
|
|
wxOrderPressService.pressCouponJoin(order, coupon, user); |
|
|
|
try { |
|
|
|
wxOrderPressService.pressCouponJoin(order, coupon, user); |
|
|
|
} catch (MallinkException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(e.getErrorCode(), e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|