|
@@ -2,19 +2,30 @@ package com.zanxiang.manage.service.Impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.zanxiang.advertising.oceanengine.track.base.pojo.PlatformServer;
|
|
|
+import com.zanxiang.advertising.oceanengine.track.base.pojo.dto.AppOrderRpcDTO;
|
|
|
+import com.zanxiang.advertising.oceanengine.track.base.pojo.rpc.IAppOrderRpc;
|
|
|
+import com.zanxiang.advertising.oceanengine.track.base.pojo.vo.AppReportLogRpcVO;
|
|
|
+import com.zanxiang.common.enums.CallBackEnum;
|
|
|
import com.zanxiang.common.enums.PayDeviceEnum;
|
|
|
+import com.zanxiang.common.enums.PayWayEnum;
|
|
|
+import com.zanxiang.common.exception.BaseException;
|
|
|
import com.zanxiang.common.utils.bean.BeanUtils;
|
|
|
import com.zanxiang.manage.domain.dto.*;
|
|
|
import com.zanxiang.manage.domain.params.OrderParam;
|
|
|
import com.zanxiang.manage.domain.params.UserOrderListParam;
|
|
|
import com.zanxiang.manage.domain.vo.*;
|
|
|
import com.zanxiang.manage.service.*;
|
|
|
+import com.zanxiang.module.util.JsonUtil;
|
|
|
+import com.zanxiang.module.util.pojo.ResultVO;
|
|
|
import com.zanxiang.mybatis.entity.Order;
|
|
|
import com.zanxiang.mybatis.mapper.OrderMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -58,6 +69,62 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
@Autowired
|
|
|
private PayWayService payWayService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OrderService orderService;
|
|
|
+
|
|
|
+ @DubboReference(providedBy = PlatformServer.SERVER_DUBBO_NAME)
|
|
|
+ private IAppOrderRpc appOrderRpc;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单上报
|
|
|
+ *
|
|
|
+ * @param orderId : 订单id
|
|
|
+ * @return : 返回上报结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean callBack(String orderId) {
|
|
|
+ Order order = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderId, orderId));
|
|
|
+ if (order == null) {
|
|
|
+ throw new BaseException("参数错误, 订单信息不存在");
|
|
|
+ }
|
|
|
+ if (Objects.equals(order.getCallBackStatus(), CallBackEnum.SUCCESS_CALL_BACK.getCallBackStatus())) {
|
|
|
+ throw new BaseException("订单已经上报, 请勿重复操作");
|
|
|
+ }
|
|
|
+ AppOrderRpcDTO dto = AppOrderRpcDTO.builder()
|
|
|
+ .appKey(String.valueOf(order.getGameId()))
|
|
|
+ .orderId(order.getOrderId())
|
|
|
+ .userId(String.valueOf(order.getUserId()))
|
|
|
+ .amount(order.getAmount().multiply(new BigDecimal("100")).longValue())
|
|
|
+ .realAmount(order.getRealAmount().multiply(new BigDecimal("100")).longValue())
|
|
|
+ .tranNo(order.getMerchantOrderNo())
|
|
|
+ .orderStatus(order.getStatus())
|
|
|
+ .payType(PayWayEnum.getByPayType(order.getPayWayId()))
|
|
|
+ .payTime(order.getPayTime())
|
|
|
+ .createTime(order.getCreateTime())
|
|
|
+ .build();
|
|
|
+ //调接口
|
|
|
+ ResultVO<AppReportLogRpcVO> result;
|
|
|
+ try {
|
|
|
+ result = appOrderRpc.order(dto);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单回传上报异常, order : {}, e : {}", JsonUtil.toString(order), e.getMessage());
|
|
|
+ throw new BaseException("订单回传上报异常");
|
|
|
+ }
|
|
|
+ log.error("订单回传结果, orderId : {}, result : {}", order.getOrderId(), JsonUtil.toString(result));
|
|
|
+ String adId = "AD_ID";
|
|
|
+ Integer callBackStatus = CallBackEnum.FAIL_CALL_BACK.getCallBackStatus();
|
|
|
+ //成功
|
|
|
+ if (result.isSuccess() && result.getData() != null && result.getData().getAid() != null) {
|
|
|
+ adId = result.getData().getAid().toString();
|
|
|
+ callBackStatus = CallBackEnum.SUCCESS_CALL_BACK.getCallBackStatus();
|
|
|
+ }
|
|
|
+ //更新数据库
|
|
|
+ return orderService.update(new LambdaUpdateWrapper<Order>()
|
|
|
+ .set(Order::getAdId, adId)
|
|
|
+ .set(Order::getCallBackStatus, callBackStatus)
|
|
|
+ .eq(Order::getOrderId, order.getOrderId()));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取用户下单记录
|
|
|
*
|