parent
62b5edea60
commit
bcde92c9e2
@ -0,0 +1,77 @@ |
|||||||
|
package com.cweb.controller; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.github.pagehelper.PageHelper; |
||||||
|
import com.github.pagehelper.PageInfo; |
||||||
|
import com.hai.common.exception.ErrorCode; |
||||||
|
import com.hai.common.exception.ErrorHelp; |
||||||
|
import com.hai.common.exception.SysCode; |
||||||
|
import com.hai.common.security.SessionObject; |
||||||
|
import com.hai.common.security.UserCenter; |
||||||
|
import com.hai.common.utils.DateUtil; |
||||||
|
import com.hai.common.utils.ResponseMsgUtil; |
||||||
|
import com.hai.entity.*; |
||||||
|
import com.hai.model.ResponseData; |
||||||
|
import com.hai.model.UserInfoModel; |
||||||
|
import com.hai.service.*; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
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.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Auther: 胡锐 |
||||||
|
* @Description: |
||||||
|
* @Date: 2021/4/20 23:47 |
||||||
|
*/ |
||||||
|
@Controller |
||||||
|
@RequestMapping(value = "/couponAgent") |
||||||
|
@Api(value = "代理商接口") |
||||||
|
public class HighCouponAgentController { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(HighCouponAgentController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighCouponAgentService highCouponAgentService; |
||||||
|
|
||||||
|
@RequestMapping(value = "/useConvertCode", method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "兑换码使用") |
||||||
|
public ResponseData useConvertCode(@RequestBody JSONObject body) { |
||||||
|
try { |
||||||
|
|
||||||
|
if (body == null || StringUtils.isBlank(body.getString("code"))) { |
||||||
|
log.error("HighCouponAgentController -> queryConvertCode() error!",""); |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||||
|
} |
||||||
|
|
||||||
|
// 查询兑换码
|
||||||
|
HighCouponAgentCode convertCode = highCouponAgentService.getConvertCode(body.getString("code")); |
||||||
|
if (convertCode == null) { |
||||||
|
log.error("HighCouponAgentController -> queryConvertCode() error!","无效的兑换码"); |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的兑换码"); |
||||||
|
} |
||||||
|
if (convertCode.getStatus() != 1) { |
||||||
|
log.error("HighCouponAgentController -> queryConvertCode() error!","兑换码已被使用"); |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); |
||||||
|
} |
||||||
|
|
||||||
|
return ResponseMsgUtil.success(highCouponAgentService.useConvertCode(body.getString("code"))); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("HighCouponAgentController --> useConvertCode() error!", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue