package com.gkhy.exam.pay.service.impl;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.gkhy.exam.pay.entity.CoalPayStudent;
|
import com.gkhy.exam.pay.entity.NonCoalPayStudent;
|
import com.gkhy.exam.pay.mapper.CoalPayStudentMapper;
|
import com.gkhy.exam.pay.mapper.NonCoalPayStudentMapper;
|
import com.gkhy.exam.pay.service.PaymentService;
|
import com.gkhy.exam.pay.utils.PayUtils;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
|
@Service
|
@Slf4j
|
public class PaymentServiceImpl implements PaymentService {
|
|
@Autowired
|
private PayUtils payUtils;
|
@Resource
|
private NonCoalPayStudentMapper nonCoalPayStudentMapper;
|
@Resource
|
private CoalPayStudentMapper coalPayStudentMapper;
|
|
@Override
|
public void notifyConfirm(String orderNo) {
|
try {
|
JSONObject result = payUtils.query(orderNo);
|
log.info("查询财政订单返回结果:" + result);
|
String respcode = result.getString("respcode");
|
if (CaiZhengConstans.CAI_ZHENG_SUCCESS.equals(respcode)) {
|
JSONObject respdata = result.getJSONObject("respdata");
|
if (respdata != null && "1".equals(respdata.getString("status"))) {
|
nonCoalPayStudentMapper.update(null, Wrappers.<NonCoalPayStudent>lambdaUpdate()
|
.set(NonCoalPayStudent::getPayStatus, 1)
|
.set(NonCoalPayStudent::getPayTime, respdata.getDate("payTime"))
|
.eq(NonCoalPayStudent::getOrderNo, orderNo).eq(NonCoalPayStudent::getDelFlag, 0)
|
.eq(NonCoalPayStudent::getPayStatus, 0));
|
payUtils.affirmPost(orderNo);
|
}else {
|
log.error("查询财政订单失败:" + result.getString("respmsg") + ",错误编码:" + result.getString("respcode"));
|
}
|
}
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
|
}
|
|
@Override
|
public void paySuccess(String orderNo, Date payTime) {
|
|
if (orderNo.startsWith("NC")) {
|
//非煤
|
nonCoalPayStudentMapper.update(null, Wrappers.<NonCoalPayStudent>lambdaUpdate()
|
.set(NonCoalPayStudent::getPayStatus, 1)
|
.set(NonCoalPayStudent::getPayTime, payTime)
|
.eq(NonCoalPayStudent::getOrderNo, orderNo).eq(NonCoalPayStudent::getDelFlag, 0)
|
.eq(NonCoalPayStudent::getPayStatus, 0));
|
} else {
|
coalPayStudentMapper.update(null, Wrappers.<CoalPayStudent>lambdaUpdate()
|
.set(CoalPayStudent::getPayStatus, 1)
|
.set(CoalPayStudent::getPayTime, payTime)
|
.eq(CoalPayStudent::getOrderNo, orderNo).eq(CoalPayStudent::getDelFlag, 0)
|
.eq(CoalPayStudent::getPayStatus, 0));
|
}
|
payUtils.asyncNotrify(orderNo);
|
|
}
|
|
|
}
|