/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & [email protected]).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jeequan.jeepay.service.impl;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.IsvInfo;
import com.jeequan.jeepay.core.entity.MchInfo;
import com.jeequan.jeepay.core.entity.PayOrder;
import com.jeequan.jeepay.core.entity.PayWay;
import com.jeequan.jeepay.service.mapper.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
/**
* <p>
* 支付订单表 服务实现类
* </p>
*
* @author [mybatis plus generator]
* @since 2021-04-27
*/
@Service
public class PayOrderService extends ServiceImpl<PayOrderMapper, PayOrder> {
@Autowired private PayOrderMapper payOrderMapper;
@Autowired private MchInfoMapper mchInfoMapper;
@Autowired private IsvInfoMapper isvInfoMapper;
@Autowired private PayWayMapper payWayMapper;
@Autowired private PayOrderDivisionRecordMapper payOrderDivisionRecordMapper;
/** 更新订单状态 【订单生成】 --》 【支付中】 **/
public boolean updateInit2Ing(String payOrderId, PayOrder payOrder){
PayOrder updateRecord = new PayOrder();
updateRecord.setState(PayOrder.STATE_ING);
//同时更新, 未确定 --》 已确定的其他信息。 如支付接口的确认、 费率的计算。
updateRecord.setIfCode(payOrder.getIfCode());
updateRecord.setWayCode(payOrder.getWayCode());
updateRecord.setMchFeeRate(payOrder.getMchFeeRate());
updateRecord.setMchFeeAmount(payOrder.getMchFeeAmount());
updateRecord.setChannelUser(payOrder.getChannelUser());
updateRecord.setChannelOrderNo(payOrder.getChannelOrderNo());
return update(updateRecord, new LambdaUpdateWrapper<PayOrder>()
.eq(PayOrder::getPayOrderId, payOrderId).eq(PayOrder::getState, PayOrder.STATE_INIT));
}
/** 更新订单状态 【支付中】 --》 【支付成功】 **/
public boolean updateIng2Success(String payOrderId, String channelOrderNo, String channelUserId){
PayOrder updateRecord = new PayOrder();
updateRecord.setState(PayOrder.STATE_SUCCESS);
updateRecord.setChannelOrderNo(channelOrderNo);
updateRecord.setChannelUser(channelUserId);
updateRecord.setSuccessTime(new Date());
return update(updateRecord, new LambdaUpdateWrapper<PayOrder>()
.eq(PayOrder::getPayOrderId, payOrderId).eq(PayOrder::getState, PayOrder.STATE_ING));
}
/** 更新订单状态 【支付中】 --》 【订单关闭】 **/
public boolean updateIng2Close(String payOrderId){
PayOrder updateRecord = new PayOrder();
updateRecord.setState(PayOrder.STATE_CLOSED);
return update(updateRecord, new LambdaUpdateWrapper<PayOrder>()
.eq(PayOrder::getPayOrderId, payOrderId).eq(PayOrder::getState, PayOrder.STATE_ING));
}
/** 更新订单状态 【订单生成】 --》 【订单关闭】 **/
public boolean updateInit2Close(String payOrderId){
PayOrder updateRecord = new PayOrder();
updateRecord.setState(PayOrder.STATE_CLOSED);
return update(updateRecord, new LambdaUpdateWrapper<PayOrder>()
.eq(PayOrder::getPayOrderId, payOrderId).eq(PayOrder::getState, PayOrder.STATE_INIT));
}
/** 更新订单状态 【支付中】 --》 【支付失败】 **/
public boolean updateIng2Fail(String payOrderId, String channelOrderNo, String channelUserId, String channelErrCode, String channelErrMsg){
PayOrder updateRecord = new PayOrder();
updateRecord.setState(PayOrder.STATE_FAIL);
updateRecord.setErrCode(channelErrCode);
updateRecord.setErrMsg(channelErrMsg);
updateRecord.setChannelOrderNo(channelOrderNo);
updateRecord.setChannelUser(channelUserId);
return update(updateRecord, new LambdaUpdateWrapper<PayOrder>()
.eq(PayOrder::getPayOrderId, payOrderId).eq(PayOrder::getState, PayOrder.STATE_ING));
}
/** 更新订单状态 【支付中】 --》 【支付成功/支付失败】 **/
public boolean updateIng2SuccessOrFail(String payOrderId, Byte updateState, String channelOrderNo, String channelUserId, String channelErrCode, String channelErrMsg){
if(updateState == PayOrder.STATE_ING){
return true;
}else if(updateState == PayOrder.STATE_SUCCESS){
return updateIng2Success(payOrderId, channelOrderNo, channelUserId);
}else if(updateState == PayOrder.STATE_FAIL){
return updateIng2Fail(payOrderId, channelOrderNo, channelUserId, channelErrCode, channelErrMsg);
}
return false;
}
/** 查询商户订单 **/
public PayOrder queryMchOrder(String mchNo, String payOrderId, String mchOrderNo){
if(StringUtils.isNotEmpty(payOrderId)){
return getOne(PayOrder.gw().eq(PayOrder::getMchNo, mchNo).eq(PayOrder::getPayOrderId, payOrderId));
}else if(StringUtils.isNotEmpty(mchOrderNo)){
return getOne(PayOrder.gw().eq(PayOrder::getMchNo, mchNo).eq(PayOrder::getMchOrderNo, mchOrderNo));
}else{
return null;
}
}
public Map payCount(String mchNo, Byte state, Byte refundState, String dayStart, String dayEnd) {
Map param = new HashMap<>();
if (state != null) {
param.put("state", state);
}
if (refundState != null) {
param.put("refundState", refundState);
}
if (StrUtil.isNotBlank(mchNo)) {
param.put("mchNo", mchNo);
}
if (StrUtil.isNotBlank(dayStart)) {
param.put("createTimeStart", dayStart);
}
if (StrUtil.isNotBlank(dayEnd)) {
param.put("createTimeEnd", dayEnd);
}
return payOrderMapper.payCount(param);
}
public List<Map> payTypeCount(String mchNo, Byte state, Byte refundState, String dayStart, String dayEnd) {
Map param = new HashMap<>();
if (state != null) {
param.put("state", state);
}
if (refundState != null) {
param.put("refundState", refundState);
}
if (StrUtil.isNotBlank(mchNo)) {
param.put("mchNo", mchNo);
}
if (StrUtil.isNotBlank(dayStart)) {
param.put("createTimeStart", dayStart);
}
if (StrUtil.isNotBlank(dayEnd)) {
param.put("createTimeEnd", dayEnd);
}
return payOrderMapper.payTypeCount(param);
}
/** 更新订单为 超时状态 **/
public Integer updateOrderExpired(){
PayOrder payOrder = new PayOrder();
payOrder.setState(PayOrder.STATE_CLOSED);
return baseMapper.update(payOrder,
PayOrder.gw()
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Jeepay是一套适合互联网企业使用的开源支付系统,已实现交易、退款、转账、分账等接口,支持服务商特约商户和普通商户接口。已对接微信,支付宝,云闪付官方接口,支持聚合码支付。Jeepay使用Spring Boot和Ant Design Vue开发,集成Spring Security实现权限管理功能,是一套非常实用的web开发框架。
资源推荐
资源详情
资源评论











格式:zip 资源大小:2.4MB











格式:zip 资源大小:246.4MB









收起资源包目录





































































































共 628 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论

- qq_224796632024-06-28资源和描述一致,质量不错,解决了我的问题,感谢资源主。

Java程序员-张凯
- 粉丝: 1w+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 电气工程及其自动化发展问题分析及应对措施解析.docx
- 浅析无线局域网通信安全机制.doc
- 对中小学计算机教学评价技术的研究.docx
- 造价员考试土石方工程造价基础知识.ppt
- 移动互联网产品推广运营方案.docx
- 景观绿化工程质量通病及防治指引手册(含图).doc
- matlab信号实验分析方案.doc
- 大数据背景下如何有效创新档案管理模式和提升服务能力.docx
- 微软校园招聘笔试笔经超完整版.doc
- 电力系统安全稳定导则.doc
- 《中国网址》项目管理方案(草案).doc
- 输配电系统安全管理研究.docx
- 《CADCAM应用》课程标准.doc
- 以Excel和SPSS为工具的管理统计.ppt
- 通信工程建设全过程管理及其有效措施探析.docx
- 谈计算机网络信息安全及防护对策.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
