Browse Source

//update push

release_toaliyun_real
xhxu 4 years ago
parent
commit
b486cb72f3
5 changed files with 157 additions and 4 deletions
  1. +27
    -0
      mallinkService/src/main/java/com/iformall/domain/po/TtOrderPushError.java
  2. +14
    -0
      mallinkService/src/main/java/com/iformall/mapper/TtOrderPushErrorMapper.java
  3. +56
    -2
      mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideOrderPushMsgServiceImpl.java
  4. +2
    -2
      mallinkService/src/main/java/com/iformall/service/pay/service/pay/douyin/miniApp/TtMiniAppPayAdapterService.java
  5. +58
    -0
      mallinkService/src/main/resources/mapper/TtOrderPushErrorMapper.xml

+ 27
- 0
mallinkService/src/main/java/com/iformall/domain/po/TtOrderPushError.java View File

@@ -0,0 +1,27 @@
package com.iformall.domain.po;

import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.TenantEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.Date;

@TableName(value = "tt_order_push_error")
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class TtOrderPushError extends TenantEntity {

protected Long id;//batch_order_id

@io.swagger.annotations.ApiModelProperty(value="errMsg",name="errMsg")
private String errMsg;

@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
private Date createDate;
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
private Date updateDate;

}

+ 14
- 0
mallinkService/src/main/java/com/iformall/mapper/TtOrderPushErrorMapper.java View File

@@ -0,0 +1,14 @@
package com.iformall.mapper;

import com.iformall.common.CommonMapper;
import com.iformall.domain.po.TtOrderPushError;

import java.util.List;

public interface TtOrderPushErrorMapper extends CommonMapper<TtOrderPushError, Long> {

List<TtOrderPushError> findList(TtOrderPushError record);

List<Long> findIdList(TtOrderPushError record);

}

+ 56
- 2
mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideOrderPushMsgServiceImpl.java View File

@@ -8,16 +8,20 @@ import com.iformall.enums.EnumComposeOrder;
import com.iformall.enums.EnumPayWay;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.TtCUserMapper;
import com.iformall.mapper.TtOrderPushErrorMapper;
import com.iformall.mapper.WxPayOrderMapper;
import com.iformall.service.*;
import com.iformall.service.msg.MsgSendService;
import com.iformall.service.pay.PayServiceFactory;
import com.iformall.service.pay.service.pay.entity.PayAdapterResult;
import com.iformall.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;
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.List;

/**
@@ -47,6 +51,15 @@ public class FmInsideOrderPushMsgServiceImpl implements MsgSendService {
@Autowired
WxPayOrderMapper wxPayOrderMapper;

@Autowired
TtOrderPushErrorMapper ttOrderPushErrorMapper;

@Autowired
private String fmExceptionEmails;

@Autowired
private MailService mailService;


@Override
public void send(BaseMsg baseMsg) throws Exception{
@@ -70,7 +83,28 @@ public class FmInsideOrderPushMsgServiceImpl implements MsgSendService {
&& EnumComposeOrder.SINGLE.getCode().equals(batchOrder.getOrderType())
&& batchOrder.getOrders().size() == 1){
WxAppinfo appinfo = wxAppinfoService.getCAppInfo(batchOrder,EnumPayWay.PAY_WAY_TT.getPlat());
payOrderPush(appinfo,batchOrder);
try{
payOrderPush(appinfo,batchOrder);
}catch(Exception e){
logger.error("订单同步异常batchOrderId"+batchOrder.getId()+"{}"+e.getMessage());
String[] receivers = fmExceptionEmails.split(",");
StringBuilder sb = new StringBuilder();
sb.append(DateUtils.date2String(new Date()));
sb.append("\n");
sb.append(e.getMessage());
sb.append("\n");
sb.append("batchOrderId="+batchOrder.getId());
//发送邮件
mailService.sendSimpleMail(receivers, "订单同步异常", sb.toString());

TtOrderPushError pushError = new TtOrderPushError();
pushError.setId(batchOrder.getId());
pushError.updateTenantInfo(batchOrder);
pushError.setErrMsg(e.getMessage());
saveOrUpdate(pushError);

}


// WxOrderCouponVo wxOrderCouponVo = batchOrder.getOrders().get(0);
// if(EnumPayType.PAY_PAYMENT.getCode().equals(wxOrderCouponVo.getPaymentType())){
@@ -101,6 +135,20 @@ public class FmInsideOrderPushMsgServiceImpl implements MsgSendService {
}
}

private void saveOrUpdate(TtOrderPushError pushError){
Date now = new Date();
TtOrderPushError pushError1 = ttOrderPushErrorMapper.selectById(pushError.getId());
if(pushError1 != null){
pushError1.setErrMsg(pushError.getErrMsg());
pushError1.setUpdateDate(now);
ttOrderPushErrorMapper.updateById(pushError1);
}else{
pushError.setCreateDate(now);
pushError.setUpdateDate(now);
ttOrderPushErrorMapper.insert(pushError);
}
}


private void payOrderPush(WxAppinfo appinfo, WxBatchOrder batchOrder) throws Exception{
WxPayOrder orderq = new WxPayOrder();
@@ -121,6 +169,12 @@ public class FmInsideOrderPushMsgServiceImpl implements MsgSendService {
throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "支付订单找到多个用户" + batchOrder.getId());
}

payServiceFactory.getPayAdapterService(EnumPayWay.PAY_WAY_TT.getCode()).payOrderPush(openIds.get(0),appinfo,batchOrder,payOrder);
PayAdapterResult payAdapterResult = payServiceFactory.getPayAdapterService(EnumPayWay.PAY_WAY_TT.getCode()).payOrderPush(openIds.get(0), appinfo, batchOrder, payOrder);

if(payAdapterResult.isSuccess()){
ttOrderPushErrorMapper.deleteById(batchOrder.getId());
}else{
throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(), payAdapterResult.getMsg() + batchOrder.getId());
}
}
}

+ 2
- 2
mallinkService/src/main/java/com/iformall/service/pay/service/pay/douyin/miniApp/TtMiniAppPayAdapterService.java View File

@@ -143,9 +143,9 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen
return new PayAdapterResult(false, err_msg, null, null);
}
} catch (WxErrorException e) {
return new PayAdapterResult(false, "订单同步异常", null, null);
return new PayAdapterResult(false, "订单同步异常"+e.getMessage(), null, null);
} catch (Exception e){
return new PayAdapterResult(false, "订单同步异常", null, null);
return new PayAdapterResult(false, "订单同步异常"+e.getMessage(), null, null);
}
}



+ 58
- 0
mallinkService/src/main/resources/mapper/TtOrderPushErrorMapper.xml View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.iformall.mapper.TtOrderPushErrorMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.TtOrderPushError">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>

<result column="err_msg" jdbcType="VARCHAR" property="errMsg"/>

<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>

</resultMap>
<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`err_msg`,
`create_date`,`update_date`
</sql>
<sql id="dynamicWhereConditions">
where 1=1

<if test=" null != id ">
and `id` = #{id}
</if>

<if test=" null != tenantId and '' != tenantId">
and `tenant_id` = #{tenantId}
</if>
<if test=" null != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
</if>

<if test=" null != ids ">
and `id` in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>

<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>

<select id="findList" parameterType="com.iformall.domain.po.TtOrderPushError" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from tt_order_push_error
<include refid="dynamicWhereConditions"/>
</select>
<select id="findIdList" parameterType="com.iformall.domain.po.TtOrderPushError" resultType="Long">
select id
from tt_order_push_error
<include refid="dynamicWhereConditions"/>
</select>

</mapper>

Loading…
Cancel
Save