|
@@ -1,29 +1,30 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ym.mec.biz.dal.dao.TenantOrderRecordDao;
|
|
|
import com.ym.mec.biz.dal.dto.TenantOrderRecordDto;
|
|
|
-import com.ym.mec.biz.dal.entity.PlatformServe;
|
|
|
-import com.ym.mec.biz.dal.entity.PlatformServeDetail;
|
|
|
-import com.ym.mec.biz.dal.entity.TenantOrderRecord;
|
|
|
-import com.ym.mec.biz.dal.entity.TenantProductInfo;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
|
|
|
import com.ym.mec.biz.dal.enums.TenantOrderRecordEnum;
|
|
|
-import com.ym.mec.biz.service.PlatformServeDetailService;
|
|
|
-import com.ym.mec.biz.service.PlatformServeService;
|
|
|
-import com.ym.mec.biz.service.TenantOrderRecordService;
|
|
|
-import com.ym.mec.biz.service.TenantProductInfoService;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.page.PageUtil;
|
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
|
+import com.ym.mec.thirdparty.adapay.Payment;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.joda.time.LocalDateTime;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* 机构付款记录表(TenantOrderRecord)表服务实现类
|
|
@@ -41,6 +42,8 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
|
|
|
private PlatformServeService platformServeService;
|
|
|
@Autowired
|
|
|
private PlatformServeDetailService platformServeDetailService;
|
|
|
+ @Autowired
|
|
|
+ private TenantInfoService tenantInfoService;
|
|
|
|
|
|
@Override
|
|
|
public PageInfo<TenantOrderRecord> queryPage(TenantOrderRecordDto dto) {
|
|
@@ -55,6 +58,24 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
|
|
|
public Map<String, Object> checkTenantOrder(String orderNo) {
|
|
|
TenantOrderRecord orderRecord = this.getOne(new WrapperUtil<TenantOrderRecord>()
|
|
|
.hasEq("order_no_", orderNo).queryWrapper());
|
|
|
+ if (StringUtils.equals(orderRecord.getPaymentChannel(), PaymentChannelEnum.ADAPAY.getCode())) {
|
|
|
+ Map<String, Object> payment = null;
|
|
|
+ try {
|
|
|
+ payment = Payment.queryPayment(orderRecord.getTransNo());
|
|
|
+ if (Objects.nonNull(payment.get("status"))) {
|
|
|
+ String status = (String) payment.get("status");
|
|
|
+ if (status.equals("succeeded")) {
|
|
|
+ orderRecord.setOrderState(1);
|
|
|
+ } else if (status.equals("failed")) {
|
|
|
+ orderRecord.setOrderState(2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("checkTenantOrder payment >>>>> {}", JSON.toJSONString(orderRecord));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("checkTenantOrder payment error>>>>> {}", JSON.toJSONString(orderRecord));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//返回
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("groupType", orderRecord.getOrderType());
|
|
@@ -68,6 +89,7 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
|
|
|
Map<String, Object> detail = new HashMap<>();
|
|
|
result.put("detail", detail);
|
|
|
|
|
|
+ log.info("checkTenantOrder getOrderState>>>>> {}", JSON.toJSONString(orderRecord));
|
|
|
getOrderState(orderRecord, result);
|
|
|
return result;
|
|
|
}
|
|
@@ -83,9 +105,16 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
|
|
|
tenantOrderSuccess(orderRecord, detail);
|
|
|
}
|
|
|
code = DealStatusEnum.SUCCESS.getCode();
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ orderRecord.setPayDate(now.toLocalDate().toDate());
|
|
|
+ orderRecord.setPayTime(now.toDate());
|
|
|
+ //修改流水
|
|
|
+ baseMapper.updateById(orderRecord);
|
|
|
break;
|
|
|
case 2:
|
|
|
code = DealStatusEnum.FAILED.getCode();
|
|
|
+ //修改流水
|
|
|
+ baseMapper.updateById(orderRecord);
|
|
|
break;
|
|
|
default:
|
|
|
code = DealStatusEnum.ING.getCode();
|
|
@@ -105,7 +134,16 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
|
|
|
.hasEq("id_", productInfo.getServeDetailId()).queryWrapper());
|
|
|
detail.put("platformServeName", platformServe.getName());
|
|
|
detail.put("mode", serveDetail.getMode());
|
|
|
- detail.put("num",productInfo.getExpiryCount());
|
|
|
+ detail.put("num", productInfo.getExpiryCount());
|
|
|
+
|
|
|
+ TenantInfo tenantInfo = new TenantInfo();
|
|
|
+ tenantInfo.setId(orderRecord.getTenantId());
|
|
|
+ tenantInfo.setPayState(1);
|
|
|
+ tenantInfoService.updateById(tenantInfo);
|
|
|
+
|
|
|
+ productInfo.setPayDate(new Date());
|
|
|
+ productInfo.setTenantId(orderRecord.getTenantId());
|
|
|
+ tenantProductInfoService.updateById(productInfo);
|
|
|
}
|
|
|
|
|
|
}
|