|
|
|
@@ -3,16 +3,12 @@ package com.simple.controller; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.simple.annotation.AuthIgnore; |
|
|
|
import com.simple.common.ErrorCode; |
|
|
|
import com.simple.common.Result; |
|
|
|
import com.simple.common.ResultData; |
|
|
|
import com.simple.domain.po.*; |
|
|
|
import com.simple.domain.vo.WxCouponOrderCarCVo; |
|
|
|
import com.simple.enums.EnumCarVendor; |
|
|
|
import com.simple.enums.EnumCouponOrderStatus; |
|
|
|
import com.simple.enums.EnumETCPCode; |
|
|
|
import com.simple.enums.EnumTJDCode; |
|
|
|
import com.simple.enums.*; |
|
|
|
import com.simple.service.*; |
|
|
|
import com.simple.utils.ETCPUtil; |
|
|
|
import com.simple.utils.TJDCarUtil; |
|
|
|
@@ -591,7 +587,7 @@ public class WxCarController extends BaseController |
|
|
|
* 优免券领取 |
|
|
|
* 优免券不可退 |
|
|
|
*/ |
|
|
|
@ApiOperation(value = "优免券领取", notes="ETCP:={\"etcpToken\":\"string\",\"carNumber\":\"string\",\"couponFreeId\":\"string\",\"merchantId\":\"string\"},输出\n{}") |
|
|
|
@ApiOperation(value = "优免券领取", notes="ETCP:={\"etcpToken\":\"string\",\"carNumber\":\"string\",\"couponOrderId\"=\"String\"},输出\n{}") |
|
|
|
@PostMapping("/getCoupon") |
|
|
|
public ResultData getCoupon(@RequestBody Map<String, String > paramMap) { |
|
|
|
WxCUser user = getUser(); |
|
|
|
@@ -600,20 +596,34 @@ public class WxCarController extends BaseController |
|
|
|
if (park.getVendorType() == EnumCarVendor.CAR_ETCP.getCode()) { |
|
|
|
String etcpToken = paramMap.get("etcpToken"); |
|
|
|
String carNumber = paramMap.get("carNumber"); |
|
|
|
String couponFreeId = paramMap.get("couponFreeId"); |
|
|
|
String merchantIdStr = paramMap.get("merchantId"); |
|
|
|
String couponOrderIdStr = paramMap.get("couponOrderId"); |
|
|
|
if (StringUtils.isBlank(etcpToken)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "etcpToken为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(carNumber)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "carNumber为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(couponFreeId)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponFreeId为空"); |
|
|
|
if (StringUtils.isBlank(couponOrderIdStr)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponOrderId为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(merchantIdStr)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "merchantId为空"); |
|
|
|
|
|
|
|
Long couponOrderId = 0L; |
|
|
|
try { |
|
|
|
couponOrderId = Long.valueOf(couponOrderIdStr); |
|
|
|
} catch (NumberFormatException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponOrderId转化失败"); |
|
|
|
} |
|
|
|
|
|
|
|
WxCouponOrderCarCVo userCar = null; |
|
|
|
WxCouponOrderCarCVo userCarQ = new WxCouponOrderCarCVo(); |
|
|
|
userCarQ.setTenantId(user.getTenantId()); |
|
|
|
userCarQ.setId(couponOrderId); |
|
|
|
List<WxCouponOrderCarCVo> list = wxCouponOrderService.carlistCUserVo(userCarQ); |
|
|
|
if (list.size() > 0) { |
|
|
|
userCar = list.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
String params = park.getVendorParams(); |
|
|
|
JSONObject objParams = JSON.parseObject(params); |
|
|
|
String url = objParams.getString("url"); |
|
|
|
@@ -622,16 +632,29 @@ public class WxCarController extends BaseController |
|
|
|
String version = objParams.getString("version"); |
|
|
|
String businessId = ""; |
|
|
|
// 优先从从商户表里取 |
|
|
|
businessId = getETCPBusinessID(merchantIdStr); |
|
|
|
businessId = getETCPBusinessID(String.valueOf(userCar.getMerchantId())); |
|
|
|
if (StringUtils.isBlank(businessId)) { |
|
|
|
// 1期只有一个虚拟商户,可以写在商场配置里 |
|
|
|
businessId = objParams.getString("businessId"); |
|
|
|
} |
|
|
|
|
|
|
|
String ret = etcp.bCouponRecord(url, merchantNo, merchantKey, version, |
|
|
|
etcpToken, park.getParkId(), businessId, carNumber, couponFreeId); |
|
|
|
etcpToken, park.getParkId(), businessId, carNumber, String.valueOf(userCar.getCouponFreeId())); |
|
|
|
JSONObject retObj = JSON.parseObject(ret); |
|
|
|
if (retObj.getIntValue("code") == EnumETCPCode.SUCCESS.getCode()) { |
|
|
|
|
|
|
|
// 券状态设为已使用 |
|
|
|
WxCouponOrder couponOrder = new WxCouponOrder(); |
|
|
|
couponOrder.setId(userCar.getId()); |
|
|
|
couponOrder.setTenantId(user.getTenantId()); |
|
|
|
couponOrder.setUpdateDate(new Date()); |
|
|
|
couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); |
|
|
|
try { |
|
|
|
wxCouponOrderService.saveOrUpdate(couponOrder); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("券包状态更新失败:" + couponOrderIdStr); |
|
|
|
return new ResultData(ErrorCode.DB_FAIL.getCode(), "券包状态更新失败"); |
|
|
|
} |
|
|
|
return new ResultData(); |
|
|
|
} else { |
|
|
|
return new ResultData(ErrorCode.ETCP_QUAN_SEND_FAIL.getCode(), retObj.getString("message")); |
|
|
|
|