|
|
|
@ -1,17 +1,21 @@ |
|
|
|
|
package com.cweb.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.cweb.config.SysConst; |
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
import com.hai.common.QRCodeGenerator; |
|
|
|
|
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.IDGenerator; |
|
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hai.entity.BsCompany; |
|
|
|
|
import com.hai.entity.HighCoupon; |
|
|
|
|
import com.hai.entity.HighUserCoupon; |
|
|
|
|
import com.hai.entity.SecRegion; |
|
|
|
|
import com.hai.config.ChongQingCNPCService; |
|
|
|
|
import com.hai.config.CommonSysConst; |
|
|
|
|
import com.hai.entity.*; |
|
|
|
|
import com.hai.model.HighUserCouponModel; |
|
|
|
|
import com.hai.model.HighUserModel; |
|
|
|
|
import com.hai.model.ResponseData; |
|
|
|
@ -27,6 +31,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -56,6 +61,12 @@ public class HighCouponController { |
|
|
|
|
@Resource |
|
|
|
|
private HighUserCouponService highUserCouponService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighCouponCodeOtherService couponCodeOtherService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighOrderService orderService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HighMerchantStoreService highMerchantStoreService; |
|
|
|
|
|
|
|
|
@ -201,6 +212,58 @@ public class HighCouponController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getVerifyQRCode", method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "获取核销二维码") |
|
|
|
|
public ResponseData getVerifyQRCode(@RequestParam(name = "userCouponId", required = true) Long userCouponId) { |
|
|
|
|
try { |
|
|
|
|
// 用户
|
|
|
|
|
HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); |
|
|
|
|
if (userInfoModel == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户信息错误"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询最新一张可用的卡券
|
|
|
|
|
HighUserCoupon userCoupon = highUserCouponService.getDetailById(userCouponId); |
|
|
|
|
if (userCoupon == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); |
|
|
|
|
} |
|
|
|
|
if (!userCoupon.getStatus().equals(1)) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "状态异常,无法生成"); |
|
|
|
|
} |
|
|
|
|
if (!userCoupon.getUserId().equals(userInfoModel.getHighUser().getId())) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户异常,无法生成"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HighCouponCodeOther couponCodeOther = couponCodeOtherService.getDetailByCouNo(userCoupon.getQrCodeImg()); |
|
|
|
|
if (couponCodeOther == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到卡券订单"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HighOrder order = orderService.getOrderById(couponCodeOther.getOrderId()); |
|
|
|
|
if (order == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到交易订单"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 类型: 1 贵州中石化 2 重庆中石油
|
|
|
|
|
if (couponCodeOther.getType() != null && couponCodeOther.getType().equals(2)) { |
|
|
|
|
// 获取动态核销码
|
|
|
|
|
JSONObject code = ChongQingCNPCService.getCNPCCheckCode(couponCodeOther.getCouNo(), order.getOrderNo()); |
|
|
|
|
|
|
|
|
|
// 生成二维码
|
|
|
|
|
String qrCodeImgUrl = DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(1) +".jpg"; |
|
|
|
|
QRCodeGenerator.generateQRCodeImage(code.getString("checkCode"), 350, 350, SysConst.getSysConfig().getFileUrl()+"/temporary/"+qrCodeImgUrl); |
|
|
|
|
return ResponseMsgUtil.success(qrCodeImgUrl); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "生成失败"); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighCouponController --> getVerifyQRCode() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/againReceiveCoupon", method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "卡卷过期,再次领取") |
|
|
|
|