提交修改
This commit is contained in:
parent
b028183f4f
commit
e5e967c7f4
@ -10,7 +10,7 @@ import java.util.Date;import java.util.Date;
|
||||
/**
|
||||
*逆向表
|
||||
* @author quyixiao
|
||||
* @since 2025-10-16
|
||||
* @since 2025-11-09
|
||||
*/
|
||||
|
||||
@Data
|
||||
@ -44,6 +44,14 @@ private static final long serialVersionUID = 1L;
|
||||
public final static String modify_timestamp = CLASS_NAME + "modify_timestamp"; // 修改时间撮
|
||||
public final static String refund_count = CLASS_NAME + "refund_count"; // 退款子单数量
|
||||
public final static String refund_reason = CLASS_NAME + "refund_reason"; // 退款原因
|
||||
public final static String weixin_funds_account = CLASS_NAME + "weixin_funds_account"; // 退款账户
|
||||
public final static String weixin_refund_id = CLASS_NAME + "weixin_refund_id"; // 退款id
|
||||
public final static String weixin_status = CLASS_NAME + "weixin_status"; // 退款状态
|
||||
public final static String weixin_transaction_id = CLASS_NAME + "weixin_transaction_id"; // 退款事务id
|
||||
public final static String user_eceived_account = CLASS_NAME + "user_eceived_account"; // 退款接收事务id
|
||||
public final static String pre_refund_info = CLASS_NAME + "pre_refund_info"; // 提交退款返回的参数
|
||||
public final static String gmt_pre_refund = CLASS_NAME + "gmt_pre_refund"; // 日期
|
||||
public final static String gmt_refund_notify = CLASS_NAME + "gmt_refund_notify"; // 回调的时间
|
||||
//
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
@ -91,6 +99,22 @@ private static final long serialVersionUID = 1L;
|
||||
private Integer refundCount;
|
||||
//退款原因
|
||||
private String refundReason;
|
||||
//退款账户
|
||||
private String weixinFundsAccount;
|
||||
//退款id
|
||||
private String weixinRefundId;
|
||||
//退款状态
|
||||
private String weixinStatus;
|
||||
//退款事务id
|
||||
private String weixinTransactionId;
|
||||
//退款接收事务id
|
||||
private String userEceivedAccount;
|
||||
//提交退款返回的参数
|
||||
private String preRefundInfo;
|
||||
//日期
|
||||
private Date gmtPreRefund;
|
||||
//回调的时间
|
||||
private Date gmtRefundNotify;
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
@ -436,6 +460,126 @@ private static final long serialVersionUID = 1L;
|
||||
this.refundReason = refundReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款账户
|
||||
* @return
|
||||
*/
|
||||
public String getWeixinFundsAccount() {
|
||||
return weixinFundsAccount;
|
||||
}
|
||||
/**
|
||||
* 退款账户
|
||||
* @param weixinFundsAccount
|
||||
*/
|
||||
public void setWeixinFundsAccount(String weixinFundsAccount) {
|
||||
this.weixinFundsAccount = weixinFundsAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款id
|
||||
* @return
|
||||
*/
|
||||
public String getWeixinRefundId() {
|
||||
return weixinRefundId;
|
||||
}
|
||||
/**
|
||||
* 退款id
|
||||
* @param weixinRefundId
|
||||
*/
|
||||
public void setWeixinRefundId(String weixinRefundId) {
|
||||
this.weixinRefundId = weixinRefundId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款状态
|
||||
* @return
|
||||
*/
|
||||
public String getWeixinStatus() {
|
||||
return weixinStatus;
|
||||
}
|
||||
/**
|
||||
* 退款状态
|
||||
* @param weixinStatus
|
||||
*/
|
||||
public void setWeixinStatus(String weixinStatus) {
|
||||
this.weixinStatus = weixinStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款事务id
|
||||
* @return
|
||||
*/
|
||||
public String getWeixinTransactionId() {
|
||||
return weixinTransactionId;
|
||||
}
|
||||
/**
|
||||
* 退款事务id
|
||||
* @param weixinTransactionId
|
||||
*/
|
||||
public void setWeixinTransactionId(String weixinTransactionId) {
|
||||
this.weixinTransactionId = weixinTransactionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款接收事务id
|
||||
* @return
|
||||
*/
|
||||
public String getUserEceivedAccount() {
|
||||
return userEceivedAccount;
|
||||
}
|
||||
/**
|
||||
* 退款接收事务id
|
||||
* @param userEceivedAccount
|
||||
*/
|
||||
public void setUserEceivedAccount(String userEceivedAccount) {
|
||||
this.userEceivedAccount = userEceivedAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交退款返回的参数
|
||||
* @return
|
||||
*/
|
||||
public String getPreRefundInfo() {
|
||||
return preRefundInfo;
|
||||
}
|
||||
/**
|
||||
* 提交退款返回的参数
|
||||
* @param preRefundInfo
|
||||
*/
|
||||
public void setPreRefundInfo(String preRefundInfo) {
|
||||
this.preRefundInfo = preRefundInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期
|
||||
* @return
|
||||
*/
|
||||
public Date getGmtPreRefund() {
|
||||
return gmtPreRefund;
|
||||
}
|
||||
/**
|
||||
* 日期
|
||||
* @param gmtPreRefund
|
||||
*/
|
||||
public void setGmtPreRefund(Date gmtPreRefund) {
|
||||
this.gmtPreRefund = gmtPreRefund;
|
||||
}
|
||||
|
||||
/**
|
||||
* 回调的时间
|
||||
* @return
|
||||
*/
|
||||
public Date getGmtRefundNotify() {
|
||||
return gmtRefundNotify;
|
||||
}
|
||||
/**
|
||||
* 回调的时间
|
||||
* @param gmtRefundNotify
|
||||
*/
|
||||
public void setGmtRefundNotify(Date gmtRefundNotify) {
|
||||
this.gmtRefundNotify = gmtRefundNotify;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VvReverseOrderEntity{" +
|
||||
@ -462,6 +606,14 @@ private static final long serialVersionUID = 1L;
|
||||
",modifyTimestamp=" + modifyTimestamp +
|
||||
",refundCount=" + refundCount +
|
||||
",refundReason=" + refundReason +
|
||||
",weixinFundsAccount=" + weixinFundsAccount +
|
||||
",weixinRefundId=" + weixinRefundId +
|
||||
",weixinStatus=" + weixinStatus +
|
||||
",weixinTransactionId=" + weixinTransactionId +
|
||||
",userEceivedAccount=" + userEceivedAccount +
|
||||
",preRefundInfo=" + preRefundInfo +
|
||||
",gmtPreRefund=" + gmtPreRefund +
|
||||
",gmtRefundNotify=" + gmtRefundNotify +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ public class MysqlMain_update {
|
||||
}
|
||||
List<TablesBean> list = new ArrayList<TablesBean>();
|
||||
|
||||
list.add(new TablesBean("vv_trade_order_line"));
|
||||
list.add(new TablesBean("vv_reverse_order"));
|
||||
|
||||
//list.add(new TablesBean("vv_trade_order"));
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package com.heyu.api.jsapi;
|
||||
|
||||
// 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/merchant/4014931831
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.heyu.api.data.dao.vv.VvReverseOrderDao;
|
||||
import com.heyu.api.data.dao.vv.VvTradeOrderDao;
|
||||
import com.heyu.api.data.entity.vv.VvReverseOrderEntity;
|
||||
@ -9,7 +10,10 @@ import com.heyu.api.data.entity.vv.VvTradeOrderEntity;
|
||||
import com.heyu.api.data.utils.BigDecimalUtil;
|
||||
import com.heyu.api.jsapi.dto.close.CloseOrderRequest;
|
||||
import com.heyu.api.jsapi.dto.pay.*;
|
||||
import com.heyu.api.jsapi.dto.refund.*;
|
||||
import com.heyu.api.jsapi.dto.refund.AmountReq;
|
||||
import com.heyu.api.jsapi.dto.refund.CreateRequest;
|
||||
import com.heyu.api.jsapi.dto.refund.Refund;
|
||||
import com.heyu.api.jsapi.dto.refund.ReqFundsAccount;
|
||||
import com.heyu.api.jsapi.dto.refund.query.QueryByOutRefundNoRequest;
|
||||
import com.heyu.api.jsapi.utils.PemUtil;
|
||||
import lombok.SneakyThrows;
|
||||
@ -27,7 +31,6 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.security.Signature;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -235,23 +238,12 @@ public class JsapiPrepay {
|
||||
|
||||
request.amount.refund =refundAmount; // 【退款金额】 退款金额,币种的最小单位,只能为整数,不能超过原订单支付金额。
|
||||
|
||||
// 【退款出资账户及金额】退款需从指定账户出资时,可传递该参数以指定出资金额(币种最小单位,仅限整数)。
|
||||
// 多账户出资退款需满足:1、未开通退款支出分离功能;2、订单为待分账或分账中的分账订单。
|
||||
// 传递参数需确保:1、基本账户可用与不可用余额之和等于退款金额;2、账户类型不重复。不符条件将返回错误。
|
||||
request.amount.from = new ArrayList<>();
|
||||
|
||||
{
|
||||
FundsFromItem fromItem = new FundsFromItem();
|
||||
fromItem.account = Account.AVAILABLE; // 【出资账户类型】 退款出资的账户类型。
|
||||
fromItem.amount = refundAmount; // AVAILABLE : 可用余额
|
||||
request.amount.from.add(fromItem); // 【出资金额】对应账户出资金额
|
||||
};
|
||||
|
||||
request.amount.total = tradeOrderAmount; // 必填 【原订单金额】 原支付交易的订单总金额,币种的最小单位,只能为整数
|
||||
request.amount.currency = "CNY"; // 必填 【退款币种】 符合ISO 4217标准的三位字母代码,固定传:CNY,代表人民币。
|
||||
String HOST = refundNotifyUrl;
|
||||
String HOST = "https://api.mch.weixin.qq.com";
|
||||
String METHOD = "POST";
|
||||
String uri = "/v3/refund/domestic/refunds";
|
||||
log.info("RefundServiceImpl refund params :{}", JSON.toJSONString(request));
|
||||
String reqBody = WXPayUtility.toJson(request);
|
||||
Request.Builder reqBuilder = new Request.Builder().url(HOST + uri);
|
||||
reqBuilder.addHeader("Accept", "application/json");
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package com.heyu.api.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.heyu.api.alibaba.request.mm.enums.ReverseStatusEnums;
|
||||
import com.heyu.api.alibaba.request.mm.enums.ReverseUploadSceneEnums;
|
||||
import com.heyu.api.alibaba.request.mm.order.ResourceDTO;
|
||||
import com.heyu.api.alibaba.request.mm.reverse.AppliyReverseRequest;
|
||||
@ -11,8 +9,6 @@ import com.heyu.api.data.entity.vv.*;
|
||||
import com.heyu.api.data.utils.BigDecimalUtil;
|
||||
import com.heyu.api.data.utils.R;
|
||||
import com.heyu.api.data.utils.SanUtils;
|
||||
import com.heyu.api.jsapi.JsapiPrepay;
|
||||
import com.heyu.api.jsapi.dto.refund.Refund;
|
||||
import com.heyu.api.service.ReverseOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
@ -44,9 +40,6 @@ public class ReverseOrderServiceImpl implements ReverseOrderService {
|
||||
@Autowired
|
||||
private VvReverseOrderProveDao vvReverseOrderProveDao;
|
||||
|
||||
@Autowired
|
||||
private JsapiPrepay jsapiPrepay;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@ -66,7 +59,8 @@ public class ReverseOrderServiceImpl implements ReverseOrderService {
|
||||
vvReverseOrderEntity.setRefundAmount(realRefundAmount);
|
||||
BigDecimal originRefundAmount = SanUtils.sum(vvTradeOrderLineEntityList, VvTradeOrderLineEntity::getPromotionPrice); // 本来应该退款金额
|
||||
if (realRefundAmount.compareTo(originRefundAmount) > 0) {
|
||||
return R.error("退款金额不能超过商品总额度");
|
||||
log.info("createReverseOrder realRefundAmount not 大于 originRefundAmount,realRefundAmount:{},originRefundAmount:{}",realRefundAmount,originRefundAmount);
|
||||
return R.error("退款金额不能大于原来金额");
|
||||
}
|
||||
|
||||
vvReverseOrderEntity.setRefundTradeOrderLineCount(tradeOrderLineIds.size());
|
||||
@ -77,8 +71,8 @@ public class ReverseOrderServiceImpl implements ReverseOrderService {
|
||||
vvReverseOrderEntity.setRefundCount(tradeOrderLineIds.size());
|
||||
vvReverseOrderEntity.setGmtBuyerApplyRefund(new Date());
|
||||
vvReverseOrderEntity.setRefundReason(appliyReverseRequest.getRefundReason());
|
||||
vvReverseOrderEntity.setGmtCancel(new Date());
|
||||
vvReverseOrderDao.insertOrUpdateVvReverseOrder(vvReverseOrderEntity);
|
||||
|
||||
BigDecimal preSum = BigDecimal.ZERO;
|
||||
|
||||
for (int i = 0; i < tradeOrderLineIds.size(); i++) {
|
||||
@ -113,7 +107,7 @@ public class ReverseOrderServiceImpl implements ReverseOrderService {
|
||||
vvTradeOrderLineEntity.setRefundCount(1);
|
||||
vvTradeOrderLineEntity.setRefundAmount(vvReverseOrderLineEntity.getRefundAmount());
|
||||
// 更新子单的逆向状态
|
||||
vvTradeOrderLineEntity.setReverseStatus(ReverseStatusEnums.buyer_apply_reverse_wait_seller_agree.getStatus());
|
||||
vvTradeOrderLineEntity.setReverseStatus(appliyReverseRequest.getStatus());
|
||||
vvTradeOrderLineDao.updateVvTradeOrderLineById(vvTradeOrderLineEntity);
|
||||
}
|
||||
|
||||
@ -127,8 +121,6 @@ public class ReverseOrderServiceImpl implements ReverseOrderService {
|
||||
vvReverseOrderProveDao.insertOrUpdateVvReverseOrderProve(vvReverseOrderProveEntity);
|
||||
}
|
||||
}
|
||||
Refund refund = jsapiPrepay.refund(tradeOrderId, vvReverseOrderEntity.getId());
|
||||
log.info("ReverseOrderServiceImpl refund:{}", JSON.toJSONString(refund));
|
||||
return R.ok().setData(vvReverseOrderEntity);
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,8 @@ import com.heyu.api.data.utils.BigDecimalUtil;
|
||||
import com.heyu.api.data.utils.DateUtils;
|
||||
import com.heyu.api.data.utils.R;
|
||||
import com.heyu.api.data.utils.SanUtils;
|
||||
import com.heyu.api.jsapi.JsapiPrepay;
|
||||
import com.heyu.api.jsapi.dto.refund.Refund;
|
||||
import com.heyu.api.service.ReverseOrderService;
|
||||
import com.heyu.api.service.VvTradeOrderConvertService;
|
||||
import com.heyu.api.utils.ISelect;
|
||||
@ -90,6 +92,11 @@ public class AdminOrderController {
|
||||
@Autowired
|
||||
private ReverseOrderService reverseOrderService;
|
||||
|
||||
@Autowired
|
||||
private JsapiPrepay jsapiPrepay;
|
||||
|
||||
@Autowired
|
||||
private VvReverseOrderDao vvReverseOrderDao;
|
||||
|
||||
|
||||
/***
|
||||
@ -290,6 +297,7 @@ public class AdminOrderController {
|
||||
|
||||
/***
|
||||
* 订单妥投
|
||||
* http://localhost:8888/mm/order/delivered
|
||||
*/
|
||||
@RequestMapping("/delivered")
|
||||
public R delivered(@RequestBody VvDeliveredDTO vvDeliveredDTO) {
|
||||
@ -311,6 +319,7 @@ public class AdminOrderController {
|
||||
|
||||
/***
|
||||
* 订单取消
|
||||
* http://localhost:8888/mm/order/cancel
|
||||
*/
|
||||
@RequestMapping("/cancel")
|
||||
public R delivered(@RequestBody VvCancelDTO vvCancelDTO) {
|
||||
@ -326,11 +335,27 @@ public class AdminOrderController {
|
||||
vvTradeOrderLineEntity.setCancelUser(vvCancelDTO.getUserName());
|
||||
vvTradeOrderLineDao.updateVvTradeOrderLineById(vvTradeOrderLineEntity);
|
||||
}
|
||||
|
||||
AppliyReverseRequest appliyReverseRequest = new AppliyReverseRequest();
|
||||
appliyReverseRequest.setRefundType(RefundTypeEnums.only_refund.getCode());
|
||||
appliyReverseRequest.setRefundReason("订单取消:" + vvCancelDTO.getCancelReason());
|
||||
appliyReverseRequest.setStatus(ReverseStatusEnums.cancel.getStatus());
|
||||
return reverseOrderService.createReverseOrder(vvTradeOrderLineEntityList, appliyReverseRequest);
|
||||
R r = reverseOrderService.createReverseOrder(vvTradeOrderLineEntityList, appliyReverseRequest);
|
||||
|
||||
if (r.ifSuccessful()) {
|
||||
VvReverseOrderEntity reverseOrderEntity = (VvReverseOrderEntity)r.getData();
|
||||
Refund refund = jsapiPrepay.refund(reverseOrderEntity.getTradeOrderId(), reverseOrderEntity.getId());
|
||||
log.info("ReverseOrderServiceImpl reverseOrderEntity id:{} refund:{}",reverseOrderEntity.getId(), JSON.toJSONString(refund));
|
||||
|
||||
reverseOrderEntity.setWeixinFundsAccount(JSON.toJSONString(refund.getFundsAccount()));
|
||||
reverseOrderEntity.setWeixinStatus(JSON.toJSONString(refund.getStatus()));
|
||||
reverseOrderEntity.setWeixinRefundId(refund.getRefundId());
|
||||
reverseOrderEntity.setWeixinTransactionId(refund.getTransactionId());
|
||||
reverseOrderEntity.setUserEceivedAccount(refund.getUserReceivedAccount());
|
||||
reverseOrderEntity.setPreRefundInfo(JSON.toJSONString(refund));
|
||||
vvReverseOrderDao.updateVvReverseOrderById(reverseOrderEntity);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/***
|
||||
|
||||
@ -68,7 +68,10 @@ public class AppReverseController {
|
||||
|
||||
List<VvTradeOrderLineEntity> vvTradeOrderLineEntityList = vvTradeOrderLineDao.selectVvTradeOrderLineByTrackNumber(appliyReverseRequest.getTrackNumber());
|
||||
|
||||
return reverseOrderService.createReverseOrder(vvTradeOrderLineEntityList, appliyReverseRequest);
|
||||
VvReverseOrderEntity vvReverseOrderEntity = reverseOrderService.createReverseOrder(vvTradeOrderLineEntityList, appliyReverseRequest);
|
||||
|
||||
|
||||
return R.ok().setData(vvReverseOrderEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user