parent
9e5cf88db9
commit
19c7504036
File diff suppressed because one or more lines are too long
@ -0,0 +1,99 @@ |
||||
package com.web.rocketmq.consumer; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.config.CommonSysConst; |
||||
import com.hai.config.RechargeConfig; |
||||
import com.hai.entity.OutRechargeChildOrder; |
||||
import com.hai.entity.OutRechargeOrder; |
||||
import com.hai.service.OutRechargeChildOrderService; |
||||
import com.hai.service.OutRechargeOrderService; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; |
||||
import org.apache.rocketmq.spring.core.RocketMQListener; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
|
||||
@Component |
||||
@Slf4j |
||||
@RocketMQMessageListener(consumerGroup = "order-mobile-recharge-group", topic = "order-topic",selectorExpression = "mobile-recharge") |
||||
public class OrderMobileRechargeConsumer implements RocketMQListener<OutRechargeChildOrder> { |
||||
|
||||
@Resource |
||||
private OutRechargeOrderService outRechargeOrderService; |
||||
|
||||
@Resource |
||||
private OutRechargeChildOrderService outRechargeChildOrderService; |
||||
|
||||
@Override |
||||
public void onMessage(OutRechargeChildOrder childOrder) { |
||||
|
||||
JSONObject object = new JSONObject(); |
||||
|
||||
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); |
||||
|
||||
object.put("rechargePrice" , outRechargeOrder.getRechargePrice()); |
||||
object.put("rechargeMobile" , outRechargeOrder.getRechargeContent()); |
||||
object.put("productId" , outRechargeOrder.getGoodsId()); |
||||
object.put("parentOrderId" , outRechargeOrder.getId()); |
||||
|
||||
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
|
||||
Integer status = outRechargeOrderService.getRechargeOrderLegality(childOrder); |
||||
|
||||
if (status == 2 || status == -1) { |
||||
// 补充下单参数
|
||||
object = outRechargeOrderService.prepaidRechargeOrderHandle(object); |
||||
|
||||
// 尖椒充值
|
||||
if (object.getInteger("rechargePlatform") == 1) { |
||||
object.put("out_order_id", childOrder.getOrderNo()); |
||||
object.put("amount", object.getBigDecimal("rechargePrice")); |
||||
object.put("mobile", object.getString("rechargeMobile")); |
||||
object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl()); |
||||
JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object); |
||||
childOrder.setExt1(returnObject.toJSONString()); |
||||
} |
||||
|
||||
// 龙阅
|
||||
if (object.getInteger("rechargePlatform") == 2) { |
||||
|
||||
if (object.getString("code") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
object.put("out_trade_num", childOrder.getOrderNo()); |
||||
object.put("product_id", object.getString("code")); |
||||
object.put("mobile", object.getString("rechargeMobile")); |
||||
object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl()); |
||||
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object); |
||||
childOrder.setExt1(returnObject.toJSONString()); |
||||
} |
||||
|
||||
// 畅停充值
|
||||
if (object.getInteger("rechargePlatform") == 4) { |
||||
|
||||
if (object.getString("code") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
object.put("orderid", childOrder.getOrderNo()); |
||||
object.put("product_id", object.getString("code")); |
||||
object.put("phone", object.getString("rechargeMobile")); |
||||
object.put("price", object.getBigDecimal("rechargePrice")); |
||||
JSONObject returnObject = RechargeConfig.rechargeOrderByHg(object); |
||||
childOrder.setExt1(returnObject.toJSONString()); |
||||
} |
||||
|
||||
|
||||
System.out.println("消费内容:" + childOrder); |
||||
|
||||
childOrder.setUpdateTime(new Date()); |
||||
outRechargeChildOrderService.updateOrder(childOrder); |
||||
} |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue