|
@@ -1,18 +1,31 @@
|
|
|
package com.gree.mall.miniapp.logic.common;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
import com.gree.mall.miniapp.constant.SybConstants;
|
|
|
+import com.gree.mall.miniapp.enums.IsYesNoEnum;
|
|
|
+import com.gree.mall.miniapp.enums.PayOrderTypeEnum;
|
|
|
+import com.gree.mall.miniapp.enums.material.PartsOrderStatusEnum;
|
|
|
+import com.gree.mall.miniapp.enums.material.PartsPayFlagEnum;
|
|
|
import com.gree.mall.miniapp.exception.RemoteServiceException;
|
|
|
+import com.gree.mall.miniapp.logic.material.parts.WebsitPartsSalesOrderLogic;
|
|
|
+import com.gree.mall.miniapp.plus.entity.WebsitPartsSales;
|
|
|
+import com.gree.mall.miniapp.plus.entity.WebsitSales;
|
|
|
import com.gree.mall.miniapp.plus.entity.WebsitSalesPayOrder;
|
|
|
+import com.gree.mall.miniapp.plus.service.WebsitPartsSalesService;
|
|
|
+import com.gree.mall.miniapp.plus.service.WebsitSalesService;
|
|
|
import com.gree.mall.miniapp.utils.ArithUtils;
|
|
|
+import com.gree.mall.miniapp.utils.DateUtils;
|
|
|
import com.gree.mall.miniapp.utils.HttpUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.ParseException;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
|
@@ -28,7 +41,12 @@ public class AllInPayLogic {
|
|
|
|
|
|
@Resource
|
|
|
CommonLogic commonLogic;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ WebsitSalesService websitSalesService;
|
|
|
+ @Resource
|
|
|
+ WebsitPartsSalesService websitPartsSalesService;
|
|
|
+ @Resource
|
|
|
+ WebsitPartsSalesOrderLogic websitPartsSalesOrderLogic;
|
|
|
|
|
|
/**
|
|
|
* 通联支付
|
|
@@ -170,4 +188,70 @@ public class AllInPayLogic {
|
|
|
// log.error("通联交易关闭接口执行失败: {}", resMap);
|
|
|
// throw new RemoteServiceException("通联交易关闭接口执行失败:" + resMap.get("message"));
|
|
|
// }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void queryAllinpayOrder(WebsitSalesPayOrder order) throws ParseException {
|
|
|
+ Map<String, String> resMap = this.serviceQueryOrder(order);
|
|
|
+ String fintime = resMap.get("fintime"); // 交易完成时间
|
|
|
+ String chnltrxid = resMap.get("chnltrxid"); // 渠道流水号
|
|
|
+ String acct = resMap.get("acct"); // 支付平台用户标识
|
|
|
+ String trxstatus = resMap.get("trxstatus"); // 交易状态
|
|
|
+ String errmsg = resMap.get("errmsg"); // 原因
|
|
|
+
|
|
|
+ switch(trxstatus.trim()) {
|
|
|
+ case "0000":
|
|
|
+ // 支付成功
|
|
|
+ if (order.getOrderId().contains("X") && order.getOrderType().equals(PayOrderTypeEnum.S.getKey())) {
|
|
|
+ websitSalesService.lambdaUpdate()
|
|
|
+ .set(WebsitSales::getPayFlag, IsYesNoEnum.YES.getKey())
|
|
|
+ .set(WebsitSales::getFlag, "PAY_NOT_TAKE")
|
|
|
+ .set(WebsitSales::getPayTime, DateUtils.parseDate2(fintime))
|
|
|
+ .set(WebsitSales::getPayNo, chnltrxid)
|
|
|
+ .eq(WebsitSales::getSalesId, order.getOrderId())
|
|
|
+ .update();
|
|
|
+ } else if (order.getOrderId().contains("PJ") && order.getOrderType().equals(PayOrderTypeEnum.S.getKey())) {
|
|
|
+ try {
|
|
|
+ log.info("执行配件库存处理方法");
|
|
|
+ websitPartsSalesOrderLogic.handlePaySuccessMethod(order);
|
|
|
+ } catch (RemoteServiceException rse) {
|
|
|
+ websitPartsSalesService.lambdaUpdate()
|
|
|
+ .set(WebsitPartsSales::getPayFlag, PartsPayFlagEnum.PAY_NOT_STOCK.getKey())
|
|
|
+ .set(WebsitPartsSales::getStatus, PartsOrderStatusEnum.EXCEPTION.getKey())
|
|
|
+ .set(WebsitPartsSales::getPayTime, DateUtils.parseDate2(fintime))
|
|
|
+ .set(WebsitPartsSales::getTransactionId, chnltrxid)
|
|
|
+ .set(WebsitPartsSales::getOpenid, acct)
|
|
|
+ .set(WebsitPartsSales::getErr, rse.getMessage())
|
|
|
+ .eq(WebsitPartsSales::getId, order.getOrderId())
|
|
|
+ .update();
|
|
|
+ log.info("配件销售单库存处理异常,更新订单:" + rse.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("配件销售单库存处理异常:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ order.setPayFlag(IsYesNoEnum.YES.getKey())
|
|
|
+ .setPayTime(DateUtils.parseDate2(fintime))
|
|
|
+ .setTransactionId(chnltrxid)
|
|
|
+ .setOpenid(acct)
|
|
|
+ .setLastStatus(trxstatus)
|
|
|
+ .setLastMsg(errmsg)
|
|
|
+ .updateById();
|
|
|
+ break;
|
|
|
+ case "2000":
|
|
|
+ // 交易处理中
|
|
|
+ int count = order.getRunCount() + 1;
|
|
|
+ order.setRunCount(count)
|
|
|
+ .setRunTime(DateUtil.offsetSecond(DateUtil.date(), count * 5))
|
|
|
+ .setLastStatus(trxstatus)
|
|
|
+ .setLastMsg(errmsg)
|
|
|
+ .updateById();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ log.info("未定义交易状态:" + trxstatus);
|
|
|
+ order.setRunCount(50)
|
|
|
+ .setLastStatus(trxstatus)
|
|
|
+ .setLastMsg(errmsg)
|
|
|
+ .updateById();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|