|
|
@ -22,10 +22,12 @@ import com.hai.service.*; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Isolation; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import java.net.SocketTimeoutException; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -323,6 +325,93 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { |
|
|
|
return highCouponCodeMapperExt.getCouponStockCode(couponId); |
|
|
|
return highCouponCodeMapperExt.getCouponStockCode(couponId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional( |
|
|
|
|
|
|
|
propagation= Propagation.REQUIRED, |
|
|
|
|
|
|
|
isolation = Isolation.READ_COMMITTED, |
|
|
|
|
|
|
|
timeout = 20, |
|
|
|
|
|
|
|
rollbackFor = Exception.class) |
|
|
|
|
|
|
|
public void reissueCoupon(HighOrder order,HighChildOrder childOrder, HighCoupon coupon) throws Exception { |
|
|
|
|
|
|
|
order.setExceptionStatus(false); |
|
|
|
|
|
|
|
highOrderService.updateOrder(order); |
|
|
|
|
|
|
|
// 贵州中石化
|
|
|
|
|
|
|
|
if (coupon.getCouponSource().equals(4)) { |
|
|
|
|
|
|
|
// 推送给汇联通
|
|
|
|
|
|
|
|
JSONObject returnParam = HuiLianTongConfig.costRechargeOrder(childOrder.getChannelOrderNo()); |
|
|
|
|
|
|
|
if (returnParam.getString("respCode").equals("0000")) { |
|
|
|
|
|
|
|
// 解密
|
|
|
|
|
|
|
|
JSONObject jsonObject = HuiLianTongUnionCardConfig.resolveResponse(returnParam.getString("data")); |
|
|
|
|
|
|
|
JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); |
|
|
|
|
|
|
|
for (Object data : dataArray) { |
|
|
|
|
|
|
|
JSONObject dataObject = (JSONObject) data; |
|
|
|
|
|
|
|
HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); |
|
|
|
|
|
|
|
couponCodeOther.setType(1); |
|
|
|
|
|
|
|
couponCodeOther.setOrderId(order.getId()); |
|
|
|
|
|
|
|
couponCodeOther.setChildOrderId(childOrder.getId()); |
|
|
|
|
|
|
|
couponCodeOther.setCouTypeCode(dataObject.getString("couTypeCode")); |
|
|
|
|
|
|
|
couponCodeOther.setCouNo(dataObject.getString("couNo")); |
|
|
|
|
|
|
|
couponCodeOther.setActiveTime(dataObject.getDate("activeTime")); |
|
|
|
|
|
|
|
couponCodeOther.setValidStartDate(dataObject.getDate("validStartDate")); |
|
|
|
|
|
|
|
couponCodeOther.setValidEndDate(dataObject.getDate("validEndDate")); |
|
|
|
|
|
|
|
couponCodeOther.setStatus(20); |
|
|
|
|
|
|
|
couponCodeOther.setCreateTime(new Date()); |
|
|
|
|
|
|
|
couponCodeOtherService.insertCouponCodeOther(couponCodeOther); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 卡卷关联用户
|
|
|
|
|
|
|
|
HighUserCoupon highUserCoupon = new HighUserCoupon(); |
|
|
|
|
|
|
|
highUserCoupon.setMerchantId(coupon.getMerchantId()); |
|
|
|
|
|
|
|
highUserCoupon.setCouponId(coupon.getId()); |
|
|
|
|
|
|
|
highUserCoupon.setUserId(order.getMemId()); |
|
|
|
|
|
|
|
highUserCoupon.setCreateTime(new Date()); |
|
|
|
|
|
|
|
highUserCoupon.setQrCodeImg(dataObject.getString("couNo")); |
|
|
|
|
|
|
|
highUserCoupon.setUseEndTime(dataObject.getDate("validEndDate")); |
|
|
|
|
|
|
|
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
|
|
|
highUserCouponService.insertUserCoupon(highUserCoupon); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, returnParam.getString("respMessage")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (coupon.getCouponSource().equals(5)) { |
|
|
|
|
|
|
|
// 预发码
|
|
|
|
|
|
|
|
JSONObject preSendCoupon = ChongQingCNPCService.preSendCoupon(coupon.getCouponKey(), childOrder.getChildOrderNo(), childOrder.getSaleCount(), order.getMemPhone()); |
|
|
|
|
|
|
|
if (preSendCoupon.getInteger("status").equals(1)) { |
|
|
|
|
|
|
|
// 给用户发码
|
|
|
|
|
|
|
|
JSONObject response = ChongQingCNPCService.sendCNPCTicket(coupon.getCouponKey(), childOrder.getChildOrderNo(), childOrder.getSaleCount(), order.getMemPhone()); |
|
|
|
|
|
|
|
JSONObject couponDetail = response.getJSONObject("ticketDetail"); |
|
|
|
|
|
|
|
JSONArray codeList = response.getJSONArray("codeList"); |
|
|
|
|
|
|
|
for (Object data : codeList) { |
|
|
|
|
|
|
|
HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); |
|
|
|
|
|
|
|
couponCodeOther.setType(2); |
|
|
|
|
|
|
|
couponCodeOther.setOrderId(order.getId()); |
|
|
|
|
|
|
|
couponCodeOther.setChildOrderId(childOrder.getId()); |
|
|
|
|
|
|
|
couponCodeOther.setCouTypeCode(couponDetail.getString("requestCode")); |
|
|
|
|
|
|
|
couponCodeOther.setCouNo(ChongQingCNPCService.decryptCouponCode(String.valueOf(data))); |
|
|
|
|
|
|
|
couponCodeOther.setActiveTime(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); |
|
|
|
|
|
|
|
couponCodeOther.setValidStartDate(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); |
|
|
|
|
|
|
|
couponCodeOther.setValidEndDate(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); |
|
|
|
|
|
|
|
couponCodeOther.setStatus(20); |
|
|
|
|
|
|
|
couponCodeOther.setCreateTime(new Date()); |
|
|
|
|
|
|
|
couponCodeOtherService.insertCouponCodeOther(couponCodeOther); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 卡卷关联用户
|
|
|
|
|
|
|
|
HighUserCoupon highUserCoupon = new HighUserCoupon(); |
|
|
|
|
|
|
|
highUserCoupon.setMerchantId(coupon.getMerchantId()); |
|
|
|
|
|
|
|
highUserCoupon.setCouponId(coupon.getId()); |
|
|
|
|
|
|
|
highUserCoupon.setOrderId(order.getId()); |
|
|
|
|
|
|
|
highUserCoupon.setChildOrderId(childOrder.getId()); |
|
|
|
|
|
|
|
highUserCoupon.setUserId(order.getMemId()); |
|
|
|
|
|
|
|
highUserCoupon.setCreateTime(new Date()); |
|
|
|
|
|
|
|
highUserCoupon.setQrCodeImg(couponCodeOther.getCouNo()); |
|
|
|
|
|
|
|
highUserCoupon.setUseEndTime(couponCodeOther.getValidEndDate()); |
|
|
|
|
|
|
|
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
|
|
|
highUserCouponService.insertUserCoupon(highUserCoupon); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "此卡券业务暂不支持补发"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void payCoupon(HighOrder order,HighChildOrder childOrder, HighCoupon coupon) throws Exception { |
|
|
|
public void payCoupon(HighOrder order,HighChildOrder childOrder, HighCoupon coupon) throws Exception { |
|
|
|
// 贵州中石化
|
|
|
|
// 贵州中石化
|
|
|
|