shikeyin
2024-01-11 65da8373531677b1c37a98f53eaa30c892f35e5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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 = "";
}