解决合单退货逻辑,增加一些字段。兼容非合单退货
This commit is contained in:
parent
4f4aff603d
commit
0acf149eb2
@ -39,9 +39,15 @@ public class PayConsumeDeposit implements Serializable {
|
||||
@ApiModelProperty(value = "商户网站唯一订单号(DOT):合并支付则为多个订单号, 没有创建联合支付交易号")
|
||||
private String order_id;
|
||||
|
||||
@ApiModelProperty(value = "交易号:支付宝etc")
|
||||
@ApiModelProperty(value = "重要:一般是微信支付宝等的(非合单)主交易流水号")
|
||||
private String deposit_trade_no;
|
||||
|
||||
@ApiModelProperty(value = "(合单)商品子交易流水号")
|
||||
private String ord_sub_trade_no;
|
||||
|
||||
@ApiModelProperty(value = "(合单)运费子交易流水号")
|
||||
private String df_sub_trade_no;
|
||||
|
||||
@ApiModelProperty(value = "支付渠道")
|
||||
private Integer payment_channel_id;
|
||||
|
||||
|
||||
@ -64,9 +64,11 @@ public interface LakalaPayService {
|
||||
* @param originTradeNo 原拉卡拉交易流水号
|
||||
* @param refundAmount 退款金额(单位:分)
|
||||
* @param refundReason 退款原因
|
||||
* @param lklMerchantNo 拉卡拉商户号(可选参数),不填默认选择店铺的商户号
|
||||
* @param lklTermNo 拉卡拉终端号(可选参数),不填默认选择店铺的终端号
|
||||
* @return Pair<Boolean, String>,包含退款是否成功以及消息
|
||||
*/
|
||||
Pair<Boolean, String> innerLklRefund(Integer storeId, String outTradeNo, String originTradeNo, String refundAmount, String refundReason);
|
||||
Pair<Boolean, String> innerLklRefund(Integer storeId, String outTradeNo, String originTradeNo, String refundAmount, String refundReason, String lklMerchantNo, String lklTermNo);
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
|
||||
@ -51,13 +51,13 @@ public interface PayUserPayService extends IBaseService<PayUserPay> {
|
||||
*/
|
||||
ShopOrderReturn wxPayRefund(ShopOrderReturn orderReturn);
|
||||
|
||||
/**
|
||||
* 拉卡拉 退款接口
|
||||
*
|
||||
* @param orderReturn
|
||||
* @return
|
||||
*/
|
||||
ShopOrderReturn lklPayRefund(ShopOrderReturn orderReturn);
|
||||
// /**
|
||||
// * 拉卡拉 退款接口
|
||||
// *
|
||||
// * @param orderReturn
|
||||
// * @return
|
||||
// */
|
||||
// ShopOrderReturn lklPayRefund(ShopOrderReturn orderReturn);
|
||||
|
||||
void wxRefundNotify(HttpServletRequest request);
|
||||
|
||||
|
||||
@ -341,10 +341,12 @@ public class LakalaPayServiceImpl implements LakalaPayService {
|
||||
* @param originTradeNo 原拉卡拉交易流水号
|
||||
* @param refundAmount 退款金额(单位:分)
|
||||
* @param refundReason 退款原因
|
||||
* @param lklMerchantNo 拉卡拉商户号(可选参数),不填默认选择店铺的商户号
|
||||
* @param lklTermNo 拉卡拉终端号(可选参数),不填默认选择店铺的终端号
|
||||
* @return Pair<Boolean, String>,包含退款是否成功以及消息
|
||||
*/
|
||||
@Override
|
||||
public Pair<Boolean, String> innerLklRefund(Integer storeId, String outTradeNo, String originTradeNo, String refundAmount, String refundReason) {
|
||||
public Pair<Boolean, String> innerLklRefund(Integer storeId, String outTradeNo, String originTradeNo, String refundAmount, String refundReason, String lklMerchantNo, String lklTermNo) {
|
||||
try {
|
||||
log.info("开始执行拉卡拉内部退款,参数: storeId={}, outTradeNo={}, originTradeNo={}, refundAmount={}, refundReason={}",
|
||||
storeId, outTradeNo, originTradeNo, refundAmount, refundReason);
|
||||
@ -382,8 +384,10 @@ public class LakalaPayServiceImpl implements LakalaPayService {
|
||||
V3LabsRelationRefundRequest refundRequest = new V3LabsRelationRefundRequest();
|
||||
refundRequest.setOutTradeNo(outTradeNo);
|
||||
refundRequest.setOriginTradeNo(originTradeNo);
|
||||
refundRequest.setMerchantNo(shopStoreBase.getLkl_merchant_no());
|
||||
refundRequest.setTermNo(shopStoreBase.getLkl_term_no());
|
||||
lklMerchantNo = StrUtil.isBlank(lklMerchantNo) ? shopStoreBase.getLkl_merchant_no() : lklMerchantNo;
|
||||
lklTermNo = StrUtil.isBlank(lklTermNo) ? shopStoreBase.getLkl_term_no() : lklTermNo;
|
||||
refundRequest.setMerchantNo(lklMerchantNo);
|
||||
refundRequest.setTermNo(lklTermNo);
|
||||
refundRequest.setRefundAmount(refundAmount);
|
||||
refundRequest.setRefundReason(refundReason);
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -6,6 +6,7 @@ import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.*;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -1426,7 +1427,14 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
|
||||
|
||||
// 拉卡拉订单合单信息
|
||||
if (StrUtil.isNotBlank(outSplitRspInfos)) {
|
||||
// [{"sub_trade_no":"20250830110113130266250034401288","merchant_no":"822584059990FYP","amount":"1","settle_type":"0","sub_log_no":"66250034401288","out_sub_trade_no":"DF-DD-20250830-21","term_no":"N5811590"},{"sub_trade_no":"20250830110113130266250034401289","merchant_no":"8226330541100GU","amount":"1","settle_type":"0","sub_log_no":"66250034401289","out_sub_trade_no":"ORD-DD-20250830-21","term_no":"N5817779"}]
|
||||
payConsumeDeposit.setLkl_combine_params(outSplitRspInfos);
|
||||
|
||||
Pair<String, String> subTradeNos = getLklSubTradeNo(outSplitRspInfos);
|
||||
if (subTradeNos != null) {
|
||||
payConsumeDeposit.setOrd_sub_trade_no(subTradeNos.getFirst());
|
||||
payConsumeDeposit.setDf_sub_trade_no(subTradeNos.getSecond());
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否联合支付
|
||||
@ -1752,51 +1760,51 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
|
||||
return shopOrderReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉卡拉退款
|
||||
*
|
||||
* @param orderReturn
|
||||
* @return ShopOrderReturn 退款结果信息
|
||||
*/
|
||||
@Override
|
||||
public ShopOrderReturn lklPayRefund(ShopOrderReturn orderReturn) {
|
||||
// 获取并处理交易号
|
||||
String deposit_trade_no = CheckUtil.isEmpty(orderReturn.getDeposit_trade_no()) ? "" : orderReturn.getDeposit_trade_no();
|
||||
|
||||
// 调用拉卡拉退款接口
|
||||
Pair<Boolean, String> resp = lakalaPayService.innerLklRefund(
|
||||
orderReturn.getStore_id(),
|
||||
orderReturn.getReturn_id(),
|
||||
deposit_trade_no,
|
||||
Integer.toString(NumberUtil.mul(orderReturn.getTrade_payment_amount(), 100).intValue()),
|
||||
orderReturn.getReturn_buyer_message()
|
||||
);
|
||||
|
||||
if (!resp.getFirst()) {
|
||||
LogUtil.error("拉卡拉退款异常: " + resp.getSecond());
|
||||
return null;
|
||||
}
|
||||
|
||||
// 解析响应并获取退单号
|
||||
String lklTradeNo = "";
|
||||
try {
|
||||
JSONObject respData = StrUtil.isNotBlank(resp.getSecond()) ? JSONObject.parseObject(resp.getSecond()) : null;
|
||||
lklTradeNo = respData != null ? respData.getString("trade_no") : "";
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("解析拉卡拉退款响应数据失败: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
// 构造并返回结果
|
||||
String finalLklTradeNo = lklTradeNo;
|
||||
return new ShopOrderReturn() {{
|
||||
setReturn_channel_flag(1);
|
||||
setDeposit_trade_no(deposit_trade_no);
|
||||
setOrder_id(orderReturn.getOrder_id());
|
||||
setReturn_channel_trans_id(finalLklTradeNo);
|
||||
setReturn_channel_time(new Date());
|
||||
}};
|
||||
}
|
||||
// /**
|
||||
// * 拉卡拉退款
|
||||
// *
|
||||
// * @param orderReturn
|
||||
// * @return ShopOrderReturn 退款结果信息
|
||||
// */
|
||||
// @Override
|
||||
// public ShopOrderReturn lklPayRefund(ShopOrderReturn orderReturn) {
|
||||
// // 获取并处理交易号
|
||||
// String deposit_trade_no = CheckUtil.isEmpty(orderReturn.getDeposit_trade_no()) ? "" : orderReturn.getDeposit_trade_no();
|
||||
//
|
||||
// // 调用拉卡拉退款接口
|
||||
// Pair<Boolean, String> resp = lakalaPayService.innerLklRefund(
|
||||
// orderReturn.getStore_id(),
|
||||
// orderReturn.getReturn_id(),
|
||||
// deposit_trade_no,
|
||||
// Integer.toString(NumberUtil.mul(orderReturn.getTrade_payment_amount(), 100).intValue()),
|
||||
// orderReturn.getReturn_buyer_message()
|
||||
// );
|
||||
//
|
||||
// if (!resp.getFirst()) {
|
||||
// LogUtil.error("拉卡拉退款异常: " + resp.getSecond());
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// // 解析响应并获取退单号
|
||||
// String lklTradeNo = "";
|
||||
// try {
|
||||
// JSONObject respData = StrUtil.isNotBlank(resp.getSecond()) ? JSONObject.parseObject(resp.getSecond()) : null;
|
||||
// lklTradeNo = respData != null ? respData.getString("trade_no") : "";
|
||||
// } catch (Exception e) {
|
||||
// LogUtil.error("解析拉卡拉退款响应数据失败: " + e.getMessage());
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// // 构造并返回结果
|
||||
// String finalLklTradeNo = lklTradeNo;
|
||||
// return new ShopOrderReturn() {{
|
||||
// setReturn_channel_flag(1);
|
||||
// setDeposit_trade_no(deposit_trade_no);
|
||||
// setOrder_id(orderReturn.getOrder_id());
|
||||
// setReturn_channel_trans_id(finalLklTradeNo);
|
||||
// setReturn_channel_time(new Date());
|
||||
// }};
|
||||
// }
|
||||
|
||||
/**
|
||||
* 微信退款成功回调
|
||||
@ -1823,7 +1831,7 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
|
||||
|
||||
ShopOrderReturn shopOrderReturn = new ShopOrderReturn();
|
||||
shopOrderReturn.setReturn_channel_flag(1);
|
||||
shopOrderReturn.setDeposit_trade_no(out_refund_no);
|
||||
shopOrderReturn.setDeposit_trade_no(out_refund_no); // 退款单号
|
||||
shopOrderReturn.setOrder_id(out_trade_no);
|
||||
shopOrderReturn.setReturn_channel_time(success_time);
|
||||
|
||||
@ -1848,4 +1856,75 @@ public class PayUserPayServiceImpl extends BaseServiceImpl<PayUserPayMapper, Pay
|
||||
return new ThirdApiRes().fail(250, "批量保存失败");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据JSON数组解析商品订单子流水号和运费子流水号
|
||||
*
|
||||
* @param outSplitRspInfos 拉卡拉分账响应信息,格式为JSON数组字符串:[{"sub_trade_no":"20250830110113130266250034401288","merchant_no":"822584059990FYP","amount":"1","settle_type":"0","sub_log_no":"66250034401288","out_sub_trade_no":"DF-DD-20250830-21","term_no":"N5811590"},{"sub_trade_no":"20250830110113130266250034401289","merchant_no":"8226330541100GU","amount":"1","settle_type":"0","sub_log_no":"66250034401289","out_sub_trade_no":"ORD-DD-20250830-21","term_no":"N5817779"}]
|
||||
* @return Pair<String, String> 返回包含商品订单子流水号和运费子流水号的二元组
|
||||
* 若没有找到对应类型,返回的两个元素可能为null
|
||||
* 若出现异常或输入无效,返回null
|
||||
*/
|
||||
protected Pair<String, String> getLklSubTradeNo(String outSplitRspInfos) {
|
||||
// 1. 输入参数校验
|
||||
if (StrUtil.isBlank(outSplitRspInfos)) {
|
||||
logger.warn("获取子流水号失败:输入的分账信息为空");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 2. 解析JSON数组
|
||||
JSONArray outSplitRspInfoArray;
|
||||
try {
|
||||
outSplitRspInfoArray = JSONUtil.parseArray(outSplitRspInfos);
|
||||
} catch (Exception e) {
|
||||
logger.error("JSON解析失败:{}", outSplitRspInfos, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (outSplitRspInfoArray.isEmpty()) {
|
||||
logger.warn("获取子流水号失败:分账信息数组为空");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 3. 初始化结果变量
|
||||
String productSubTradeNo = null; // 商品订单子流水号
|
||||
String shippingSubTradeNo = null; // 运费子流水号
|
||||
|
||||
// 4. 遍历JSON数组
|
||||
for (cn.hutool.json.JSONObject item : outSplitRspInfoArray.jsonIter()) {
|
||||
// 5. 获取out_sub_trade_no字段
|
||||
String outSubTradeNo = item.getStr("out_sub_trade_no");
|
||||
if (StrUtil.isBlank(outSubTradeNo)) {
|
||||
logger.warn("分账信息缺少out_sub_trade_no字段:{}", item);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 6. 根据前缀分类处理
|
||||
if (outSubTradeNo.startsWith("ORD-")) {
|
||||
// 处理商品订单
|
||||
if (productSubTradeNo != null) {
|
||||
logger.warn("检测到重复的商品订单子流水号:{}", outSubTradeNo);
|
||||
}
|
||||
productSubTradeNo = item.getStr("sub_trade_no");
|
||||
} else if (outSubTradeNo.startsWith("DF-")) {
|
||||
// 处理运费订单
|
||||
if (shippingSubTradeNo != null) {
|
||||
logger.warn("检测到重复的运费子流水号:{}", outSubTradeNo);
|
||||
}
|
||||
shippingSubTradeNo = item.getStr("sub_trade_no");
|
||||
} else {
|
||||
logger.warn("未知前缀的out_sub_trade_no:{}", outSubTradeNo);
|
||||
}
|
||||
}
|
||||
|
||||
// 7. 严格校验:必须同时存在商品和运费子流水号
|
||||
if (StrUtil.isNotBlank(productSubTradeNo) && StrUtil.isNotBlank(shippingSubTradeNo)) {
|
||||
return Pair.of(productSubTradeNo, shippingSubTradeNo);
|
||||
} else {
|
||||
logger.warn("必须同时存在商品订单和运费子流水号,当前结果:商品={}, 运费={}",
|
||||
productSubTradeNo, shippingSubTradeNo);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
deposit_id
|
||||
, order_id, deposit_trade_no, payment_channel_id, app_id, server_id, deposit_app_id_channel, deposit_subject, deposit_payment_type, deposit_trade_status, deposit_seller_id, deposit_seller_email, deposit_buyer_id, deposit_buyer_email, currency_id, currency_symbol_left, deposit_total_fee, deposit_quantity, deposit_price, deposit_body, deposit_gmt_create, deposit_gmt_payment, deposit_gmt_close, deposit_is_total_fee_adjust, deposit_use_coupon, deposit_discount, deposit_notify_time, deposit_notify_type, deposit_notify_id, deposit_sign_type, deposit_sign, deposit_extra_param, lkl_combine_params, deposit_service, deposit_state, deposit_async, deposit_review, deposit_enable, store_id, user_id, chain_id
|
||||
, order_id, deposit_trade_no, ord_sub_trade_no, df_sub_trade_no, payment_channel_id, app_id, server_id, deposit_app_id_channel, deposit_subject, deposit_payment_type, deposit_trade_status, deposit_seller_id, deposit_seller_email, deposit_buyer_id, deposit_buyer_email, currency_id, currency_symbol_left, deposit_total_fee, deposit_quantity, deposit_price, deposit_body, deposit_gmt_create, deposit_gmt_payment, deposit_gmt_close, deposit_is_total_fee_adjust, deposit_use_coupon, deposit_discount, deposit_notify_time, deposit_notify_type, deposit_notify_id, deposit_sign_type, deposit_sign, deposit_extra_param, lkl_combine_params, deposit_service, deposit_state, deposit_async, deposit_review, deposit_enable, store_id, user_id, chain_id
|
||||
</sql>
|
||||
<select id="getConsumeDepositSumOne" resultType="java.math.BigDecimal">
|
||||
SELECT
|
||||
|
||||
@ -1395,7 +1395,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
*/
|
||||
@GlobalTransactional
|
||||
private boolean editNextState(List<String> return_ids, Integer store_id, Integer return_state_id, List<ShopOrderReturn> return_rows, Integer return_next_state_id) {
|
||||
// 获取订单的下一条状态
|
||||
// 获取订单下一条状态
|
||||
if (CheckUtil.isEmpty(return_next_state_id)) {
|
||||
return_next_state_id = shopStoreConfigService.getNextReturnProcess(store_id, return_state_id);
|
||||
}
|
||||
@ -1452,6 +1452,9 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
//修改退货订单及其相关商品为下一个待处理状态
|
||||
editShopOrderReturnAndItemNextState(return_ids, return_state_id, shopOrderReturn);
|
||||
|
||||
// 运费退款
|
||||
ShopOrderReturn return_order_shipping_fee_row = null;
|
||||
|
||||
// return_state_id 是当前状态(旧状态)
|
||||
if (ObjectUtil.equal(return_state_id, StateCode.RETURN_PROCESS_CHECK)) {
|
||||
// 同意退款退货,判断是否全部都退款退货,修改订单状态
|
||||
@ -1479,18 +1482,19 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
List<ShopOrderReturnItem> returnItemList = orderReturnItemService.find(returnItemQueryWrapper);
|
||||
BigDecimal return_item_subtotal = returnItemList.stream().map(s -> s.getReturn_item_subtotal()).reduce(BigDecimal::add).get();
|
||||
|
||||
// 全部退款的情况
|
||||
// 订单所有商品退款的情况
|
||||
if (ObjectUtil.compare(order_item_payment_amount, return_item_subtotal) == 0) {
|
||||
|
||||
ShopOrderData shopOrderData = new ShopOrderData();
|
||||
shopOrderData.setOrder_id(order_id);
|
||||
shopOrderData.setOrder_refund_status(2);
|
||||
shopOrderData.setOrder_refund_status(2); //退款状态:0-是无退款;1-是部分退款;2-是全部退款
|
||||
if (!shopOrderDataService.edit(shopOrderData)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
// 取消订单
|
||||
ShopOrderInfo info_row = shopOrderInfoService.get(order_id);
|
||||
// 当前订单状态
|
||||
Integer order_state_id = info_row.getOrder_state_id();
|
||||
|
||||
// 没有发货没有完成订单之前,允许取消订单和退运费
|
||||
@ -1500,13 +1504,23 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
shopOrderBaseService.cancel(order_id, info_row, false);
|
||||
// logger.info("全部退款完成,取消订单:{}", order_id);
|
||||
|
||||
// todo 未发货,退运费 - 判断运费是否存在
|
||||
// 未发货,退运费 - 判断运费是否存在
|
||||
ShopOrderData order_data_row = shopOrderDataService.get(order_id);
|
||||
|
||||
// 如果有打包费,最后的退款订单的退款金额加上 打包费
|
||||
if (order_data_row != null && order_data_row.getPacking_fee().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 退款金额+打包费
|
||||
BigDecimal order_refund_amount_add_fee = NumberUtil.add(order_data_row.getOrder_refund_amount(), order_data_row.getPacking_fee());
|
||||
// 最后一个退款订单如果有打包费,加上打包费
|
||||
return_row.setReturn_refund_amount(order_refund_amount_add_fee);
|
||||
}
|
||||
|
||||
// 有运费的订单
|
||||
if (order_data_row != null && order_data_row.getOrder_shipping_fee().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 运费大于0的, 执行退运费操作, 有两种方案,1、生成退运费售后服务单; 2、直接执行退款
|
||||
// 1、生成退运费售后服务单
|
||||
// 1、生成独立退运费售后服务单,需注意运费是退给运费代理商的,需要获取代理商的交易单号
|
||||
|
||||
ShopOrderReturn return_order_shipping_fee_row = new ShopOrderReturn();
|
||||
return_order_shipping_fee_row = new ShopOrderReturn();
|
||||
|
||||
Integer buyer_user_id = info_row.getBuyer_user_id();
|
||||
Integer storeId = info_row.getStore_id();
|
||||
@ -1520,11 +1534,10 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
return_order_shipping_fee_row.setBuyer_user_id(buyer_user_id);
|
||||
return_order_shipping_fee_row.setReturn_is_shipping_fee(1); //退货类型(BOOL): 0-退款单;1-退运费单
|
||||
return_order_shipping_fee_row.setReturn_reason_id(0);
|
||||
return_order_shipping_fee_row.setReturn_buyer_message(I18nUtil._("全部退款退运费"));
|
||||
return_order_shipping_fee_row.setReturn_buyer_message(I18nUtil._("退运费"));
|
||||
return_order_shipping_fee_row.setStore_id(storeId);
|
||||
return_order_shipping_fee_row.setReturn_refund_amount(order_shipping_fee);
|
||||
return_order_shipping_fee_row.setReturn_refund_point(NumberUtil.min(return_refund_point, order_shipping_fee));
|
||||
// return_order_shipping_fee_row.setReturn_state_id(StateCode.RETURN_PROCESS_CHECK);
|
||||
return_order_shipping_fee_row.setReturn_add_time(now); // 添加时间
|
||||
return_order_shipping_fee_row.setReturn_tel("");
|
||||
// 店铺审核操作员
|
||||
@ -1533,45 +1546,47 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
return_order_shipping_fee_row.setReturn_telephone("");
|
||||
return_order_shipping_fee_row.setSubsite_id(info_row.getSubsite_id());
|
||||
|
||||
String type_code = stateCodeService.getCode(StateCode.ORDER_TYPE_FX, "state_code_code");
|
||||
String return_id = shopNumberSeqService.createNextSeq(type_code);
|
||||
|
||||
// update 2025-07-24
|
||||
return_order_shipping_fee_row.setReturn_flag(0); // 退货标识(BOOL): 0-正常退货;1-退货换货
|
||||
return_order_shipping_fee_row.setReturn_store_message(I18nUtil._("全部退款退运费"));
|
||||
return_order_shipping_fee_row.setReturn_store_message(I18nUtil._("退运费"));
|
||||
return_order_shipping_fee_row.setReturn_finish_time(now);
|
||||
return_order_shipping_fee_row.setReturn_state_id(StateCode.RETURN_PROCESS_FINISH);
|
||||
return_order_shipping_fee_row.setReturn_is_paid(1);// 退款完成
|
||||
return_order_shipping_fee_row.setReturn_is_paid(0);// 退款完成
|
||||
return_order_shipping_fee_row.setReturn_channel_code("lakala");
|
||||
return_order_shipping_fee_row.setPayment_channel_id(1416);
|
||||
|
||||
return_order_shipping_fee_row.setReturn_year(DateUtil.year(now)); // 退单年份-索引查询
|
||||
return_order_shipping_fee_row.setReturn_month(DateUtil.month(now) + 1); // 退单月份-索引查询
|
||||
return_order_shipping_fee_row.setReturn_day(DateUtil.dayOfMonth(now)); // 退单日-索引查询
|
||||
|
||||
// 生成退货单
|
||||
String type_code = stateCodeService.getCode(StateCode.ORDER_TYPE_FX, "state_code_code");
|
||||
String return_id = shopNumberSeqService.createNextSeq(type_code);
|
||||
return_order_shipping_fee_row.setReturn_id(return_id);
|
||||
// 运费独立加一条退单记录
|
||||
if (!add(return_order_shipping_fee_row)) {
|
||||
// 1、生成退运费售后服务单;
|
||||
throw new ApiException(I18nUtil._("生成退运费订单失败!"));
|
||||
}
|
||||
|
||||
// 修正退款总额 为 加上运费
|
||||
ShopOrderData orderData = shopOrderDataService.get(order_id);
|
||||
BigDecimal order_refund_amount = orderData.getOrder_refund_amount();
|
||||
// 退款金额+运费
|
||||
BigDecimal order_refund_amount_add_fee = NumberUtil.add(order_refund_amount, order_shipping_fee);
|
||||
orderData.setOrder_refund_amount(order_refund_amount_add_fee);
|
||||
if (!shopOrderDataService.edit(orderData)) {
|
||||
throw new ApiException(I18nUtil._("修改订单退款总额(加运费)失败!"));
|
||||
}
|
||||
// 重要:加上单条运费退货单
|
||||
// return_rows.add(return_order_shipping_fee_row);
|
||||
|
||||
// 最后一个退款订单如果有运费,加上运费
|
||||
return_row.setReturn_refund_amount(order_refund_amount_add_fee);
|
||||
// // 修正退款总额 为 加上运费
|
||||
// ShopOrderData orderData = shopOrderDataService.get(order_id);
|
||||
// BigDecimal order_refund_amount = orderData.getOrder_refund_amount();
|
||||
// // 退款金额+运费
|
||||
// BigDecimal order_refund_amount_add_fee = NumberUtil.add(order_refund_amount, order_shipping_fee);
|
||||
// orderData.setOrder_refund_amount(order_refund_amount_add_fee);
|
||||
// if (!shopOrderDataService.edit(orderData)) {
|
||||
// throw new ApiException(I18nUtil._("修改订单退款总额(加运费)失败!"));
|
||||
// }
|
||||
//
|
||||
// // 最后一个退款订单如果有运费,加上运费
|
||||
// return_row.setReturn_refund_amount(order_refund_amount_add_fee);
|
||||
}
|
||||
|
||||
// 如果有打包费,退款金额加上 打包费
|
||||
if (order_data_row != null && order_data_row.getPacking_fee().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 退款金额+打包费
|
||||
BigDecimal order_refund_amount_add_fee = NumberUtil.add(order_data_row.getOrder_refund_amount(), order_data_row.getPacking_fee());
|
||||
// 最后一个退款订单如果有打包费,加上打包费
|
||||
return_row.setReturn_refund_amount(order_refund_amount_add_fee);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1604,8 +1619,13 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
shopOrderReturn.setReturn_is_paid(1); // 0-退货未完成;1-退货完成
|
||||
shopOrderReturn.setReturn_finish_time(now);
|
||||
|
||||
// 执行退款操作
|
||||
if (!payService.doRefund(return_rows)) {
|
||||
List<ShopOrderReturn> returnOrder = new ArrayList<>();
|
||||
returnOrder.addAll(return_rows);
|
||||
if (return_order_shipping_fee_row != null) {
|
||||
returnOrder.add(return_order_shipping_fee_row);
|
||||
}
|
||||
// 重要:执行退款操作
|
||||
if (!payService.doRefund(returnOrder)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,104 +89,72 @@ import java.util.stream.Collectors;
|
||||
@RequestMapping("/admin/shop/shopController")
|
||||
public class ShopController {
|
||||
|
||||
@Autowired
|
||||
private ShopDistributionPlantformUserService shopDistributionPlantformUserService;
|
||||
|
||||
@Autowired
|
||||
private ShopDistributionPlantformUserGeneratedCommissionService plantformUserGeneratedCommissionService;
|
||||
|
||||
@Autowired
|
||||
private ShopBaseStateCodeService shopBaseStateCodeService;
|
||||
|
||||
@Autowired
|
||||
private ShopOrderReturnService shopOrderReturnService;
|
||||
|
||||
@Autowired
|
||||
private ShopDistributionUserCommissionService commissionService;
|
||||
|
||||
@Autowired
|
||||
private ShopBaseProductCategoryService shopBaseProductCategoryService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductBaseService shopProductBaseService;
|
||||
|
||||
@Autowired
|
||||
private ShopUserPointsHistoryService userPointsHistoryService;
|
||||
|
||||
@Autowired
|
||||
private ShopBaseDistrictService shopBaseDistrictService;
|
||||
|
||||
@Autowired
|
||||
private ShopPlantformSubsiteService shopPlantformSubsiteService;
|
||||
|
||||
@Autowired
|
||||
private ShopDistributionUserService shopDistributionUserService;
|
||||
|
||||
@Autowired
|
||||
private ShopUserPointsHistoryService shopUserPointsHistoryService;
|
||||
|
||||
@Autowired
|
||||
private ShopPlantformSubsiteUserService shopPlantformSubsiteUserService;
|
||||
|
||||
@Autowired
|
||||
private ShopOrderInfoService shopOrderInfoService;
|
||||
|
||||
@Autowired
|
||||
private ShopOrderBaseService shopOrderBaseService;
|
||||
|
||||
@Autowired
|
||||
private ShopOrderCbService shopOrderCbService;
|
||||
|
||||
@Autowired
|
||||
private ShopOrderDataService shopOrderDataService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreBaseService shopStoreBaseService;
|
||||
|
||||
@Autowired
|
||||
private ShopOrderReturnItemService shopOrderReturnItemService;
|
||||
|
||||
@Autowired
|
||||
private ShopOrderItemService shopOrderItemService;
|
||||
|
||||
@Autowired
|
||||
private ShopNumberSeqService shopNumberSeqService;
|
||||
|
||||
@Autowired
|
||||
private ShopUserFavoritesStoreService shopUserFavoritesStoreService;
|
||||
|
||||
@Autowired
|
||||
private ShopUserFavoritesItemService shopUserFavoritesItemService;
|
||||
|
||||
@Autowired
|
||||
private ShopUserVoucherService shopUserVoucherService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductItemService shopProductItemService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreEmployeeService shopStoreEmployeeService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ShopController.class);
|
||||
@Autowired
|
||||
ShopStoreEmployeeRightsGroupService findStoreEmployeeRightsGroupService;
|
||||
|
||||
@Autowired
|
||||
ShopChainUserRightsGroupService findChainUserRightsGroupService;
|
||||
|
||||
@Autowired
|
||||
ShopChainUserService shopChainUserService;
|
||||
|
||||
@Autowired
|
||||
private ShopDistributionPlantformUserService shopDistributionPlantformUserService;
|
||||
@Autowired
|
||||
private ShopDistributionPlantformUserGeneratedCommissionService plantformUserGeneratedCommissionService;
|
||||
@Autowired
|
||||
private ShopBaseStateCodeService shopBaseStateCodeService;
|
||||
@Autowired
|
||||
private ShopOrderReturnService shopOrderReturnService;
|
||||
@Autowired
|
||||
private ShopDistributionUserCommissionService commissionService;
|
||||
@Autowired
|
||||
private ShopBaseProductCategoryService shopBaseProductCategoryService;
|
||||
@Autowired
|
||||
private ShopProductBaseService shopProductBaseService;
|
||||
@Autowired
|
||||
private ShopUserPointsHistoryService userPointsHistoryService;
|
||||
@Autowired
|
||||
private ShopBaseDistrictService shopBaseDistrictService;
|
||||
@Autowired
|
||||
private ShopPlantformSubsiteService shopPlantformSubsiteService;
|
||||
@Autowired
|
||||
private ShopDistributionUserService shopDistributionUserService;
|
||||
@Autowired
|
||||
private ShopUserPointsHistoryService shopUserPointsHistoryService;
|
||||
@Autowired
|
||||
private ShopPlantformSubsiteUserService shopPlantformSubsiteUserService;
|
||||
@Autowired
|
||||
private ShopOrderInfoService shopOrderInfoService;
|
||||
@Autowired
|
||||
private ShopOrderBaseService shopOrderBaseService;
|
||||
@Autowired
|
||||
private ShopOrderCbService shopOrderCbService;
|
||||
@Autowired
|
||||
private ShopOrderDataService shopOrderDataService;
|
||||
@Autowired
|
||||
private ShopStoreBaseService shopStoreBaseService;
|
||||
@Autowired
|
||||
private ShopOrderReturnItemService shopOrderReturnItemService;
|
||||
@Autowired
|
||||
private ShopOrderItemService shopOrderItemService;
|
||||
@Autowired
|
||||
private ShopNumberSeqService shopNumberSeqService;
|
||||
@Autowired
|
||||
private ShopUserFavoritesStoreService shopUserFavoritesStoreService;
|
||||
@Autowired
|
||||
private ShopUserFavoritesItemService shopUserFavoritesItemService;
|
||||
@Autowired
|
||||
private ShopUserVoucherService shopUserVoucherService;
|
||||
@Autowired
|
||||
private ShopProductItemService shopProductItemService;
|
||||
@Autowired
|
||||
private ShopStoreEmployeeService shopStoreEmployeeService;
|
||||
@Autowired
|
||||
private ShopStoreEmployeeKefuService shopStoreEmployeeKefuService;
|
||||
|
||||
@Autowired
|
||||
private ShopProductIndexService shopProductIndexService;
|
||||
|
||||
@Autowired
|
||||
private EduService eduService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ShopController.class);
|
||||
|
||||
@ApiOperation(value = "根据user_id 删除门店顾客关系数据", notes = "根据user_id 删除门店顾客关系数据")
|
||||
@RequestMapping(value = "/deletePlantformUserByUid", method = RequestMethod.POST)
|
||||
public boolean deletePlantformUserByUid(@RequestBody List<Integer> user_ids) {
|
||||
@ -523,10 +491,11 @@ public class ShopController {
|
||||
|
||||
@RequestMapping(value = "/editShopOrderData", method = RequestMethod.POST)
|
||||
public boolean editShopOrderData(@RequestBody ShopOrderData shopOrderData) {
|
||||
boolean flag = false;
|
||||
boolean flag;
|
||||
try {
|
||||
flag = shopOrderDataService.edit(shopOrderData);
|
||||
} catch (Exception e) {
|
||||
logger.error("修改订单数据,失败原因:", e);
|
||||
return false;
|
||||
}
|
||||
return flag;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user