Authored by Lixiaodi

Merge branch 'hotfix-0527' into test6.9.5

# Conflicts:
#	order/src/main/java/com/yohoufo/order/service/impl/PaymentServiceImpl.java
... ... @@ -25,7 +25,8 @@ public interface TradeBillsMapper {
//List<Map<String, Object>> selectSpendAmountByUid(@Param("uid") Integer uid);
int updateSelectiveByPrimaryKey(TradeBills record);
int updateSelectiveByPrimaryKeyNoCondition(TradeBills record);
int updateToFailByPrimaryKey(TradeBills record);
TradeBills selectByDealRelateId(Integer dealRelateId);
... ...
... ... @@ -131,6 +131,58 @@
</set>
where id = #{id,jdbcType=INTEGER} and deal_status != 1
</update>
<update id="updateSelectiveByPrimaryKeyNoCondition" parameterType="com.yohoufo.dal.order.model.TradeBills" >
update trade_bills
<set >
<if test="uid != null" >
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
order_code = #{orderCode,jdbcType=BIGINT},
</if>
<if test="userType != null" >
user_type = #{userType,jdbcType=INTEGER},
</if>
<if test="payType != null" >
pay_type = #{payType,jdbcType=INTEGER},
</if>
<if test="tradeType != null" >
trade_type = #{tradeType,jdbcType=INTEGER},
</if>
<if test="incomeOutcome != null" >
income_outcome = #{incomeOutcome,jdbcType=INTEGER},
</if>
<if test="amount != null" >
amount = #{amount,jdbcType=DECIMAL},
</if>
<if test="systemAmount != null" >
system_amount = #{systemAmount,jdbcType=DECIMAL},
</if>
<if test="tradeStatus != null" >
trade_status = #{tradeStatus,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="dealUid != null" >
deal_uid = #{dealUid,jdbcType=INTEGER},
</if>
<if test="dealUserName != null" >
deal_user_name = #{dealUserName,jdbcType=VARCHAR},
</if>
<if test="dealStatus != null" >
deal_status = #{dealStatus,jdbcType=INTEGER},
</if>
<if test="dealTime != null" >
deal_time = #{dealTime,jdbcType=INTEGER},
</if>
<if test="dealRelateId != null" >
deal_relate_id = #{dealRelateId,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateToFailByPrimaryKey" parameterType="com.yohoufo.dal.order.model.TradeBills" >
update trade_bills set deal_status = #{dealStatus,jdbcType=INTEGER}
... ...
... ... @@ -350,24 +350,25 @@ public class PaymentServiceImpl implements IPaymentService {
public void transferSuccess(TransferData transferData) {
int now = (int) (System.currentTimeMillis()/1000);
Integer tradeBillsId = transferData.getTradeBillsId();
Integer transferId = transferData.getTransferId();
String orderCode = transferData.getOrderCode();
TradeBills tradeBills = tradeBillsMapper.selectByPrimaryKey(tradeBillsId);
if (tradeBills == null) {
throw new ServiceException(400, "transferSuccess:流水不存在");
}
if (tradeBills.getTradeStatus() != BillTradeStatus.TRANSFER_WAITING.getCode()) {
throw new ServiceException(400, "transferSuccess:该流水不是异步转账的");
}
OrdersPayTransfer transfer = ordersPayTransferMapper.selectByPrimaryKey(transferId);
if (transfer == null) {
throw new ServiceException(400, "transferSuccess:转账记录不存在");
}
if (transfer.getStatus() == 1) {
throw new ServiceException(400, "transferSuccess:转账记录已经成功");
}
logger.info("transferSuccess 参数 tradeBillsId={}, tradeBillsId={}, orderCode={}", tradeBillsId, tradeBillsId, orderCode);
Integer transferId = transferData.getTransferId();
String orderCode = transferData.getOrderCode();
logger.info("transferSuccess 参数 transferId={}, tradeBillsId={}, orderCode={}", transferId, tradeBillsId, orderCode);
TradeBills tradeBills = tradeBillsMapper.selectByPrimaryKey(tradeBillsId);
logger.info("tradeBills is : {}", tradeBills);
if (tradeBills == null) {
throw new ServiceException(400, "transferSuccess:流水不存在");
}
if (tradeBills.getTradeStatus() != TradeBills.Status.TRANSFER_WAITING.getCode()) {
throw new ServiceException(400, "transferSuccess:该流水不是异步转账的");
}
OrdersPayTransfer transfer = ordersPayTransferMapper.selectByPrimaryKey(transferId);
if (transfer == null) {
throw new ServiceException(400, "transferSuccess:转账记录不存在");
}
if (transfer.getStatus() == 1) {
throw new ServiceException(400, "transferSuccess:转账记录已经成功");
}
if(StringUtils.equals("S", transferData.getStatus())) {
// 更新成OK
TradeBills success = new TradeBills();
... ... @@ -1114,8 +1115,14 @@ public class PaymentServiceImpl implements IPaymentService {
logger.info("manualDeal orderCode={}, tradeBillId={}, 转账接口类型为 {}", orderCode, tradeBillsId, interfaceType);
if (interfaceType != null && interfaceType == 2) {
logger.info("manualDeal orderCode={}, tradeBillId={}, 转账接口类型为 超过100万的接口", orderCode, tradeBillsId);
transferWhenExceedMillion(transfer.getId(), preSuccess, orderCode, account, amount, now);
return;
Map<String, String> mapResult = transferWhenExceedMillion(transfer.getId(), preSuccess, orderCode, account, amount, now);
String resultStr = JSON.toJSONString(mapResult);
jsonObject = JSON.parseObject(resultStr);
if(!StringUtils.equals("T", mapResult.get("is_success"))) {
throw new ServiceException(500, "转账失败:返回={}" + resultStr);
} else {
return;
}
}
logger.info("manualDeal orderCode={}, tradeBillId={}, 转账接口类型为 小于100万的接口", orderCode, tradeBillsId);
... ... @@ -1152,9 +1159,9 @@ public class PaymentServiceImpl implements IPaymentService {
throw new ServiceException(500, "转账失败:返回code="+code+",order_id="+orderId);
}
} catch (Exception e) {
if (interfaceType != null && interfaceType == 2) {
/*if (interfaceType != null && interfaceType == 2) {
return;
}
}*/
logger.warn("manualDealErr 转账失败 , orderCode is {}, msg is {}", orderCode, e.getMessage());
String alarmMsg = "订单号:" + orderCode + ",操作类型(转账),流水id=" + tradeBillsId + ",msg=" + e.getMessage();
if (jsonObject != null) {
... ... @@ -1180,14 +1187,15 @@ public class PaymentServiceImpl implements IPaymentService {
Map<String, String> mapResult = alipayService.transferMoneyWhenExceedMillion(Long.toString(orderCode),
transferId + "_" + tradeBills.getId(), account.getAlipayId(), account.getAlipayAccount(),
account.getCertName(), amount);
logger.info("transferWhenExceedMillion 转账阿里接口(总金额超过100万)返回 {}", mapResult);
// success to wait
logger.info("transferWhenExceedMillion 转账阿里接口(总金额超过100万)返回 {}, orderCode is {}, transferId is {}, tradeBillsId is {}, alibillId is {}", mapResult, orderCode, transferId, tradeBills.getId(), transferId + "_" + tradeBills.getId());
// success to wait
if (StringUtils.equals("T", mapResult.get("is_success"))) {
tradeBills.setDealStatus(0);
tradeBills.setTradeStatus(BillTradeStatus.TRANSFER_WAITING.getCode());
// wait
tradeBillsMapper.updateSelectiveByPrimaryKey(tradeBills);
}
tradeBillsMapper.updateSelectiveByPrimaryKeyNoCondition(tradeBills);
logger.info("transferWhenExceedMillion 转账阿里接口(总金额超过100万)更新之后的tradeBill: {}", tradeBillsMapper.selectByPrimaryKey(tradeBills.getId()));
}
return mapResult;
}
... ...