提交代码

dev-discount
胡锐 2 years ago
parent dfeeb2e945
commit a2fb1d474c
  1. 69
      hai-service/src/main/java/com/hai/order/service/impl/OrderRefundHandleServiceImpl.java

@ -1,18 +1,31 @@
package com.hai.order.service.impl;
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.PayloService;
import com.hai.config.ShellGroupService;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighGasOrder;
import com.hai.entity.HighMerchantStore;
import com.hai.entity.HighOrderRefund;
import com.hai.enum_type.GasChannel;
import com.hai.enum_type.GasChannelPayPlatformType;
import com.hai.enum_type.MerStoreAmountSourceTypeEnum;
import com.hai.enum_type.MerStoreAmountTypeEnum;
import com.hai.msg.entity.MsgTopic;
import com.hai.order.service.OrderRefundHandleService;
import com.hai.order.type.OrderOilStatus;
import com.hai.service.HighGasOrderService;
import com.hai.service.HighMerchantStoreService;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @className: OrderRefundHandleServiceImpl
@ -22,9 +35,18 @@ import java.util.Date;
@Service("orderRefundHandleService")
public class OrderRefundHandleServiceImpl implements OrderRefundHandleService {
@Resource
private RedisTemplate redisTemplate;
@Resource
private HighMerchantStoreService storeService;
@Resource
private HighGasOrderService gasOrderService;
@Resource
private ShellGroupService shellGroupService;
@Resource
private PayloService payloService;
@Override
public void couponHandle(HighOrderRefund orderRefund) {
@ -43,5 +65,52 @@ public class OrderRefundHandleServiceImpl implements OrderRefundHandleService {
gasOrder.setRefundTime(orderRefund.getRefundTime());
gasOrder.setStatus(OrderOilStatus.STATUS4.getNumber());
gasOrderService.updateGasOrder(gasOrder);
try {
// 油站渠道,根据不同的渠道,请求不同的退款业务接口。
// 团油 退款需要申请。不是实时退款
// 加好油 实时退款,退款成功就可以退款给用户
// 金猪加油 没有线上退款接口,线下核实后直接退款给用户。
if (gasOrder.getChannelType().equals(GasChannel.type1.getType())) {
// 查询门店信息
HighMerchantStore store = storeService.getDetailById(gasOrder.getId());
if (store == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油站");
}
// 预存类型 0:非预存 1:预存门店
if (store.getPrestoreType().equals(1)) {
Map<String, Object> pushParam = new HashMap<>();
pushParam.put("businessType", MerStoreAmountTypeEnum.type1.getType());
pushParam.put("storeId", store.getId());
pushParam.put("price", gasOrder.getGasRefuelPrice());
pushParam.put("sourceType", MerStoreAmountSourceTypeEnum.type3.getType());
pushParam.put("sourceId", gasOrder.getOrderNo());
pushParam.put("sourceContent", "订单号:" + gasOrder.getOrderNo() + ",退款金额:¥" + gasOrder.getGasRefuelPrice());
pushParam.put("opUserId", orderRefund.getOpUserId());
pushParam.put("opUserName", orderRefund.getOpUserName());
// 退款到预存余额
this.redisTemplate.boundListOps(MsgTopic.MerStoreAccount.getName()).leftPush(pushParam);
}
} else if (gasOrder.getChannelType().equals(GasChannel.type2.getType())) {
} else if (gasOrder.getChannelType().equals(GasChannel.type3.getType())) {
JSONObject object = shellGroupService.gasSyncRefund(gasOrder.getPayTime(), gasOrder.getOrderNo());
if (!object.getString("status").equals("SUCCESS")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败,原因:" + object.getString("message"));
}
} else if (gasOrder.getChannelType().equals(GasChannel.type4.getType())) {
} else if (gasOrder.getChannelType().equals(GasChannel.type5.getType())) {
JSONObject object = payloService.syncYcShellRefundNotify(gasOrder.getPayTime(), gasOrder.getOrderNo());
if (!object.getString("status").equals("SUCCESS")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败,原因:" + object.getString("message"));
}
}
} catch (Exception e) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, e);
}
}
}

Loading…
Cancel
Save