Merge remote-tracking branch 'origin/2.0-dev' into 2.0-dev

# Conflicts:
#	hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java
new-dev
袁野 1 year ago
commit bfb297ab08
  1. 54
      hai-order/src/main/java/com/web/controller/business/OrderCouponController.java
  2. 9
      hai-service/src/main/java/com/hai/service/HighCouponCodeService.java
  3. 89
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java

@ -8,8 +8,12 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighGasOrder;
import com.hai.entity.HighOrder;
import com.hai.enum_type.GoodsType;
import com.hai.enum_type.OrderStatusEnum;
import com.hai.enum_type.UserObjectTypeEnum;
import com.hai.enum_type.UserRoleTypeEnum;
import com.hai.model.ResponseData;
@ -19,11 +23,14 @@ import com.hai.order.model.OrderCouponModel;
import com.hai.order.service.OrderService;
import com.hai.order.service.OrderServiceExt;
import com.hai.order.type.OrderOilStatus;
import com.hai.order.type.OrderProductType;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighCouponService;
import com.hai.service.HighGasOrderService;
import com.web.config.SysConst;
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.stereotype.Controller;
@ -37,7 +44,9 @@ import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.net.SocketTimeoutException;
import java.util.*;
import java.util.stream.Collectors;
@Controller
@RequestMapping(value = "coupon")
@ -58,6 +67,9 @@ public class OrderCouponController {
@Resource
private OrderServiceExt orderServiceExt;
@Resource
private HighCouponCodeService couponCodeService;
@RequestMapping(value = "/getOrderList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询卡券订单列表")
@ -214,4 +226,46 @@ public class OrderCouponController {
}
}
@RequestMapping(value="/reissue",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "补发")
public ResponseData reissue(@RequestParam(name = "orderNo", required = true) String orderNo) {
try {
// 订单
HighOrder order = orderService.getOrderDetailByNo(orderNo);
if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的交易");
}
if (!order.getProductType().equals(OrderProductType.PRODUCT_TYPE5.getNumber())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "只支持卡券交易补发");
}
if (order.getOrderStatus().equals(OrderStatusEnum.type2.getType())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "补发失败!交易未处于已支付状态");
}
if (!order.getExceptionStatus().equals(true)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "补发失败!订单未出现异常");
}
// 过滤出卡券订单
List<HighChildOrder> childOrderList = order.getHighChildOrderList().stream()
.filter(o ->
o.getGoodsType().equals(GoodsType.goodsType1.getType())
&& o.getGiveawayType().equals(false)
).collect(Collectors.toList());
if (childOrderList.size() == 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知找到子交易订单");
}
HighChildOrder childOrder = childOrderList.get(0);
// 补发
couponCodeService.reissueCoupon(order,childOrder,couponService.getCouponById(childOrder.getGoodsId()));
return ResponseMsgUtil.success("补发成功");
} catch (Exception e) {
log.error("OrderCouponController -> reissue() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -135,6 +135,15 @@ public interface HighCouponCodeService {
*/
HighCouponCode getCouponStockCode(Long couponId);
/**
* 补发卡券
* @param order
* @param childOrder
* @param coupon
* @throws Exception
*/
void reissueCoupon(HighOrder order,HighChildOrder childOrder, HighCoupon coupon) throws Exception;
/**
* 购买卡券
* @param order 交易订单信息

@ -26,11 +26,13 @@ import com.hai.service.*;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.net.SocketTimeoutException;
import java.util.*;
/**
@ -334,6 +336,93 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
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
public void payCoupon(HighOrder order,HighChildOrder childOrder, HighCoupon coupon) throws Exception {
// 贵州中石化

Loading…
Cancel
Save