package com.iplatform.pay.service;
|
|
import com.iplatform.model.po.S_pay_notify;
|
import com.iplatform.model.po.S_pay_order;
|
import com.walker.infrastructure.utils.DateUtils;
|
import com.walker.infrastructure.utils.StringUtils;
|
import com.walker.jdbc.service.BaseServiceImpl;
|
import com.walker.pay.PayStatus;
|
import org.springframework.stereotype.Service;
|
|
/**
|
* 订单相关数据操作。
|
* @author 时克英
|
* @date 2023-02-28
|
*/
|
@Service
|
public class PlatformOrderServiceImpl extends BaseServiceImpl {
|
|
/**
|
* 接收订单通知,更新订单状态。
|
* <pre>
|
* 1) 订单通知可能已存在,但未成功,需要更新
|
* 2) 订单信息,支付状态需要更新
|
* </pre>
|
* @param s_pay_notify
|
* @date 2023-02-28
|
* @date 2023-03-05 notify通知记录为更新,而不是写入
|
*/
|
public void execInsertOrderNotify(S_pay_notify s_pay_notify, boolean insertNotify){
|
S_pay_order s_pay_order = new S_pay_order(s_pay_notify.getOrder_id());
|
s_pay_order.setThird_notify_id(s_pay_notify.getNotify_id());
|
|
if(s_pay_notify.getTrade_no() != null){
|
// 更新第三方订单号
|
s_pay_order.setTrade_no(s_pay_notify.getTrade_no());
|
}
|
if(StringUtils.isNotEmpty(s_pay_notify.getNotify_acct())){
|
// 更新第三方付款人标识,如:微信openId,银行卡号等
|
s_pay_order.setThird_pay_acct(s_pay_notify.getNotify_acct());
|
}
|
if(s_pay_notify.getPay_status().equals(PayStatus.Success.getIndex())){
|
// 如果通知成功,则更新'成功'以及'成功时间'
|
s_pay_order.setPay_status(PayStatus.Success.getIndex());
|
s_pay_order.setPay_success_time(DateUtils.getDateTimeNumber(System.currentTimeMillis()));
|
} else {
|
s_pay_order.setPay_status(PayStatus.Error.getIndex());
|
s_pay_order.setPay_status_msg(s_pay_notify.getNotify_status());
|
}
|
if(insertNotify){
|
// 写入新订单通知
|
this.insert(s_pay_notify);
|
} else {
|
// 重复通知,如果存在记录需要更新,2023-03-05
|
this.save(s_pay_notify);
|
}
|
// 更新订单
|
this.save(s_pay_order);
|
}
|
|
// private static final String SQL_NOTIFY_ORDER = "";
|
}
|