202508151822

This commit is contained in:
张潘 2025-08-15 18:22:12 +08:00
parent bae71b2015
commit 9f3b9a55eb
27 changed files with 2007 additions and 1361 deletions

View File

@ -1,53 +0,0 @@
import request from '@/utils/request'
// 查询wechat_transfer列表
export function listTransfer(query) {
return request({
url: '/system/transfer/list',
method: 'get',
params: query
})
}
// 查询wechat_transfer详细
export function getTransfer(id) {
return request({
url: '/system/transfer/' + id,
method: 'get'
})
}
// 查询wechat_transfer详细
export function getUserDataList() {
return request({
url: '/system/transfer/getUsersDataList',
method: 'get'
})
}
// 新增wechat_transfer
export function addTransfer(data) {
return request({
url: '/system/transfer',
method: 'post',
data: data
})
}
// 修改wechat_transfer
export function updateTransfer(data) {
return request({
url: '/system/transfer',
method: 'put',
data: data
})
}
// 删除wechat_transfer
export function delTransfer(id) {
return request({
url: '/system/transfer/' + id,
method: 'delete'
})
}

View File

@ -1,51 +0,0 @@
import request from '@/utils/request'
// 查询wechat_transfer列表
export function listTransfer(query) {
return request({
url: '/system/transfer/list',
method: 'get',
params: query
})
}
// 查询wechat_transfer详细
export function getTransfer(id) {
return request({
url: '/system/transfer/' + id,
method: 'get'
})
}
getUserDataList () {
getUserDataList().then(response => {
this.userDataList = response.data
})
},
// 新增wechat_transfer
export function addTransfer(data) {
return request({
url: '/system/transfer',
method: 'post',
data: data
})
}
// 修改wechat_transfer
export function updateTransfer(data) {
return request({
url: '/system/transfer',
method: 'put',
data: data
})
}
// 删除wechat_transfer
export function delTransfer(id) {
return request({
url: '/system/transfer/' + id,
method: 'delete'
})
}

15
pom.xml
View File

@ -151,11 +151,26 @@
</dependency>
<!-- excel工具 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>3.1.0</version>
</dependency>
<!-- velocity代码生成使用模板 -->
<dependency>

View File

@ -60,18 +60,23 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>

View File

@ -4310,10 +4310,17 @@ public class AppleOrderController extends BaseController {
if (goodsOrder.getStatus() != 3L) {
return AppletControllerUtil.appletError("订单状态不正确,无法确认收货");
}
int updateResult=0;
GoodsOrder goodsOrder1=new GoodsOrder();
goodsOrder1.setMainOrderId(goodsOrder.getMainOrderId());
List<GoodsOrder> list=goodsOrderService.selectGoodsOrderList(goodsOrder1);
for (GoodsOrder goodsOrder2 : list) {
goodsOrder.setStatus(4L);
updateResult += goodsOrderService.updateGoodsOrder(goodsOrder);
}
// 6. 更新订单状态为已收货
goodsOrder.setStatus(4L);
int updateResult = goodsOrderService.updateGoodsOrder(goodsOrder);
// goodsOrder.setStatus(4L);
// int updateResult = goodsOrderService.updateGoodsOrder(goodsOrder);
if (updateResult > 0) {
// 7. 添加订单日志
@ -4752,37 +4759,52 @@ public class AppleOrderController extends BaseController {
// if (goodsOrder.getStatus() != 5L) {
// return AppletControllerUtil.appletError("订单状态不正确,无法申请退货");
// }
UsersPayBefor usersPayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(goodsOrder.getMainOrderId());
// 6. 验证退款金额不能超过支付金额
BigDecimal payPrice = goodsOrder.getPayPrice() != null ? goodsOrder.getPayPrice() : BigDecimal.ZERO;
BigDecimal payPrice = usersPayBefor.getAllmoney() != null ? usersPayBefor.getAllmoney() : BigDecimal.ZERO;
if (refundAmount.compareTo(payPrice) > 0) {
return AppletControllerUtil.appletError("退款金额不能超过支付金额");
}
//修改状态
int updateResult=0;
GoodsOrder goodsOrder1=new GoodsOrder();
goodsOrder1.setMainOrderId(usersPayBefor.getOrderid());
List<GoodsOrder> goodsOrders = goodsOrderService.selectGoodsOrderList(goodsOrder1);
for (GoodsOrder goodsOrder2 : goodsOrders) {
// 构建退货日志JSON数组
JSONArray returnJsonArray = new JSONArray();
JSONObject returnJsonObject = new JSONObject();
// returnJsonObject.put("title", refundType == 1 ? "申请仅退款" : "申请退货退款");
returnJsonObject.put("title", "申请退款");
returnJsonObject.put("time",dateFormat.format(new Date()));
returnJsonObject.put("desc", 1);
returnJsonArray.add(returnJsonObject);
JSONObject returnJsonObject2 = new JSONObject();
returnJsonObject2.put("title","退款中");
returnJsonObject2.put("content","平台将在72小时为您处理请耐心等待");
goodsOrder2.setReturntype(Long.valueOf(refundType));
goodsOrder2.setReturnreason(refundReason);
goodsOrder2.setReturnfiledata(voucher);
goodsOrder2.setStatus(20L); // 设置为退货状态
goodsOrder2.setReturntime(new Date());
goodsOrder2.setReturnstatus(1L);
goodsOrder2.setReturnmoney(refundAmount);
goodsOrder2.setReturnshow(returnJsonObject2.toJSONString());
goodsOrder2.setReturnjson(returnJsonArray.toJSONString());
// 8. 更新订单
updateResult += goodsOrderService.updateGoodsOrder(goodsOrder2);
}
// 7. 更新订单退货信息
goodsOrder.setReturntype(Long.valueOf(refundType));
goodsOrder.setReturnreason(refundReason);
goodsOrder.setReturnfiledata(voucher);
goodsOrder.setStatus(20L); // 设置为退货状态
goodsOrder.setReturntime(new Date());
goodsOrder.setReturnstatus(1L);
goodsOrder.setReturnmoney(refundAmount);
// 构建退货日志JSON数组
JSONArray returnJsonArray = new JSONArray();
JSONObject returnJsonObject = new JSONObject();
// returnJsonObject.put("title", refundType == 1 ? "申请仅退款" : "申请退货退款");
returnJsonObject.put("title", "申请退款");
returnJsonObject.put("time",dateFormat.format(new Date()));
returnJsonObject.put("desc", 1);
returnJsonArray.add(returnJsonObject);
JSONObject returnJsonObject2 = new JSONObject();
returnJsonObject2.put("title","退款中");
returnJsonObject2.put("content","平台将在72小时为您处理请耐心等待");
goodsOrder.setReturnshow(returnJsonObject2.toJSONString());
goodsOrder.setReturnjson(returnJsonArray.toJSONString());
// 8. 更新订单
int updateResult = goodsOrderService.updateGoodsOrder(goodsOrder);
if (updateResult > 0) {
// 9. 添加订单日志

View File

@ -1171,11 +1171,20 @@ public class ApplePayController extends BaseController {
// 微信支付
if (wxMoney.compareTo(BigDecimal.ZERO) <= 0) {
// 金额为0直接走后续逻辑
payBefor.setStatus(2L); // 已支付
payBefor.setPaytime(new Date());
usersPayBeforService.updateUsersPayBefor(payBefor);
// payBefor.setStatus(2L); // 已支付
// payBefor.setPaytime(new Date());
// usersPayBeforService.updateUsersPayBefor(payBefor);
//扣减消费金服务金
BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
if (flg==0){
UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo);
if (newpayBefor!=null){
// 创建订单
newpayBefor.setStatus(2L);
usersPayBeforService.updateUsersPayBefor(newpayBefor);
}
}
//BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
//回调方法用来处理订单相关数据
OrderUtil.prepayCallback(payBefor, user);
payResult.put("istowx", 1);
@ -1199,11 +1208,20 @@ public class ApplePayController extends BaseController {
// 余额支付
if (yeMoney.compareTo(BigDecimal.ZERO) <= 0) {
// 金额为0直接走后续逻辑
payBefor.setStatus(2L); // 已支付
payBefor.setPaytime(new Date());
usersPayBeforService.updateUsersPayBefor(payBefor);
// payBefor.setStatus(2L); // 已支付
// payBefor.setPaytime(new Date());
// usersPayBeforService.updateUsersPayBefor(payBefor);
//扣减消费金服务金
BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
// BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
if (flg==0){
UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo);
if (newpayBefor!=null){
// 创建订单
newpayBefor.setStatus(2L);
usersPayBeforService.updateUsersPayBefor(newpayBefor);
}
}
//回调方法用来处理订单相关数据
OrderUtil.prepayCallback(payBefor, user);
@ -1219,12 +1237,21 @@ public class ApplePayController extends BaseController {
);
if (balanceResult != null && Boolean.TRUE.equals(balanceResult.get("success"))) {
// 更新预支付记录状态
payBefor.setStatus(2L); // 已支付
payBefor.setPaytime(new Date());
usersPayBeforService.updateUsersPayBefor(payBefor);
// payBefor.setStatus(2L); // 已支付
// payBefor.setPaytime(new Date());
// usersPayBeforService.updateUsersPayBefor(payBefor);
OrderUtil.prepayCallback(payBefor, user);
//扣减消费金服务金
BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
if (flg==0){
UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo);
if (newpayBefor!=null){
// 创建订单
newpayBefor.setStatus(2L);
usersPayBeforService.updateUsersPayBefor(newpayBefor);
}
}
//BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
//IntegralAndBenefitUtil.processIntegralAndBenefit(payBefor.getAllmoney(), payBefor.getOrderid(), user.getId(), payBefor.getId());
// IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId());
payResult.put("istowx", 2);
@ -1242,8 +1269,17 @@ public class ApplePayController extends BaseController {
usersPayBeforService.updateUsersPayBefor(payBefor);
OrderUtil.prepayCallback(payBefor, user);
//扣减消费金服务金
BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
// BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
// IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId());
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
if (flg==0){
UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo);
if (newpayBefor!=null){
// 创建订单
newpayBefor.setStatus(2L);
usersPayBeforService.updateUsersPayBefor(newpayBefor);
}
}
payResult.put("istowx", 1);
return AppletControllerUtil.appletSuccess("支付成功");
}
@ -1276,7 +1312,16 @@ public class ApplePayController extends BaseController {
usersPayBeforService.updateUsersPayBefor(payBefor);
OrderUtil.prepayCallback(payBefor, user);
//扣减消费金服务金
BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
if (flg==0){
UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo);
if (newpayBefor!=null){
// 创建订单
newpayBefor.setStatus(2L);
usersPayBeforService.updateUsersPayBefor(newpayBefor);
}
}
//BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
// IntegralAndBenefitUtil.processIntegralAndBenefit(payBefor.getAllmoney(), payBefor.getOrderid(), user.getId(), payBefor.getId());
// IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId());
payResult.put("istowx", 2);
@ -1500,17 +1545,7 @@ public class ApplePayController extends BaseController {
if (useCard == null) {
return AppletControllerUtil.appletWarning("次卡使用记录不存在");
}
// // 4. 验证权限只能退款自己的次卡
// if (!useCard.getUid().equals(user.getId())) {
// return AppletControllerUtil.appletWarning("无权操作该次卡记录");
// }
// // 5. 验证退款状态
// if (useCard.getStatus() == null || useCard.getStatus() != 2L) {
// return AppletControllerUtil.appletWarning("该次卡记录状态不允许退款,只有已支付的次卡才能退款");
// }
// 6. 验证是否已有退款记录
if (useCard.getStatus() == 3L) {
return AppletControllerUtil.appletWarning("该次卡已申请退款,请勿重复操作");
@ -1521,43 +1556,17 @@ public class ApplePayController extends BaseController {
1,
1,
"次卡退款",
WechatPayUtil.PAY_FH + "/api/secondary/card/refund/notify"
WechatPayUtil.PAY_FH + "/api/worker/cika/notify"
);
// 7. 调用微信退款接口
// Map<String, Object> refundResult = wechatPayV3Util.refund(
// useCard.getOrderid(), // 原订单号
// useCard.getPaymoney(), // 退款金额
// "次卡退款" // 退款原因
// );
// 8. 处理退款结果
if (refundResult != null && Boolean.TRUE.equals(refundResult.get("success"))) {
// 9. 更新次卡使用记录状态为退款状态
useCard.setStatus(3L); // 3=退款状态
useCard.setRemark("退款成功,退款时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
int updateResult = userUseSecondaryCardService.updateUserUseSecondaryCard(useCard);
if (updateResult > 0) {
Map<String, Object> responseData = new HashMap<>();
responseData.put("orderid", useCard.getOrderid());
responseData.put("refundAmount", useCard.getPaymoney());
responseData.put("refundTime", new Date());
responseData.put("message", "退款申请成功");
logger.info("次卡退款成功 - 用户ID: {}, 次卡使用记录ID: {}, 退款金额: {}",
user.getId(), useCardId, useCard.getPaymoney());
return AppletControllerUtil.appletSuccess(responseData);
return AppletControllerUtil.appletSuccess("操作成功");
} else {
return AppletControllerUtil.appletWarning("退款状态更新失败");
}
} else {
String errorMsg = refundResult != null ? (String) refundResult.get("message") : "微信退款失败";
logger.error("次卡退款失败 - 用户ID: {}, 次卡使用记录ID: {}, 错误信息: {}",
user.getId(), useCardId, errorMsg);
return AppletControllerUtil.appletWarning("退款申请失败:" + errorMsg);
}
} catch (Exception e) {
logger.error("次卡退款异常 - 用户ID: {}, 参数: {}, 异常: {}",
request.getHeader("token"), params, e.getMessage());

View File

@ -4056,15 +4056,11 @@ public class AppletController extends BaseController {
}
}
// // 5. 验证订单状态是否可以取消
// if (order.getStatus() != 1L) {
// return AppletControllerUtil.appletWarning("当前订单状态不可取消");
// }
// 6. 更新订单状态为已取消(5)
Order updateOrder = new Order();
updateOrder.setId(orderId);
//设置订单支付的金额为0防止开票
updateOrder.setPayPrice(new BigDecimal(0));
updateOrder.setStatus(5L);
int result = orderService.updateOrder(updateOrder);
if (result > 0) {
@ -4088,14 +4084,20 @@ public class AppletController extends BaseController {
//如果有支付信息就要进行退款
System.out.println("=== 开始退款处理,订单号: " + order.getOrderId() + " ===");
if (usersPayBefor != null) {
//退回其他对应支付时产生的金额和积分
BenefitPointsUtil.refundServiceAndConsumption(order.getId(), user, usersPayBefor.getServicemoney(),usersPayBefor.getShopmoney());
System.out.println("=== 开始退款处理2222222222订单号: " + usersPayBefor.getStatus() + " ===");
// if (usersPayBefor.getStatus() == 2){
System.out.println("=== 开始退款处理2222222222订单号: " + order.getOrderId() + " ===");
refundUtil.refundOrder(order.getOrderId());
// }
int flg= BenefitPointsUtil.refundServerOrderData(usersPayBefor);
if(flg==0){
UsersPayBefor newusersPayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(order.getOrderId());
//退款里面金额退款结束就开始回滚订单状态添加日志
newusersPayBefor.setStatus(3L); // 设置为已退款状态
usersPayBeforService.updateUsersPayBefor(newusersPayBefor);
}
// BenefitPointsUtil.refundServiceAndConsumption(order.getId(), user, usersPayBefor.getServicemoney(),usersPayBefor.getShopmoney());
// System.out.println("=== 开始退款处理2222222222订单号: " + usersPayBefor.getStatus() + " ===");
// // if (usersPayBefor.getStatus() == 2){
// System.out.println("=== 开始退款处理2222222222订单号: " + order.getOrderId() + " ===");
// refundUtil.refundOrder(order.getOrderId());
// // }
}
return AppletControllerUtil.appletSuccess("取消成功");
@ -7527,7 +7529,7 @@ public class AppletController extends BaseController {
System.out.println("快速提现成功"+result);
WechatTransfer wechatTransfer = new WechatTransfer();
wechatTransfer.setUid(user.getId());
wechatTransfer.setMoney(moneyBigDecimal);
wechatTransfer.setMoney(moneyBigDecimal);//
wechatTransfer.setUname(user.getName());
wechatTransfer.setOrderId(orderId);
wechatTransfer.setStatus(1L);

View File

@ -31,36 +31,39 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 商品订单Controller
*
*
* @author ruoyi
* @date 2025-05-13
*/
@RestController
@RequestMapping("/system/GoodsOrder")
public class GoodsOrderController extends BaseController
{
public class GoodsOrderController extends BaseController {
private static final Logger log = LoggerFactory.getLogger(GoodsOrderController.class);
@Autowired
private IGoodsOrderService goodsOrderService;
@Autowired
private IServiceGoodsService serviceGoodsService;
@Autowired
private IUsersService usersService;
private IUsersService usersService;
@Autowired
private IUserAddressService userAddressService;
@Autowired
private ISiteDeliveryService siteDeliveryService;
@Autowired
private IUsersPayBeforService usersPayBeforService;
/**
@ -68,26 +71,30 @@ public class GoodsOrderController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:list')")
@GetMapping("/list")
public TableDataInfo list(GoodsOrder goodsOrder)
{
public TableDataInfo list(GoodsOrder goodsOrder) {
startPage();
List<GoodsOrder> list = goodsOrderService.selectGoodsOrdergrouBymAIDList(goodsOrder);
for(GoodsOrder goodsOrderdata:list){
for (GoodsOrder goodsOrderdata : list) {
goodsOrderdata.setOrderId(goodsOrderdata.getMainOrderId());
ServiceGoods serviceGoods=serviceGoodsService.selectServiceGoodsById(goodsOrderdata.getProductId());
if(serviceGoods!=null){
ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(goodsOrderdata.getProductId());
if (serviceGoods != null) {
goodsOrderdata.setProductName(serviceGoods.getTitle());
}
if(goodsOrderdata.getAddressId()!=null){
UserAddress userAddress=userAddressService.selectUserAddressById(goodsOrderdata.getAddressId());
if (userAddress != null){
goodsOrderdata.setLatitude(userAddress.getLatitude());
goodsOrderdata.setLongitude(userAddress.getLongitude());
goodsOrderdata.setAdressinfo(userAddress.getAddressInfo()+userAddress.getInfo());
}
}
Users users=usersService.selectUsersById(goodsOrderdata.getUid());
if(users !=null){
UsersPayBefor usersPayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(goodsOrderdata.getMainOrderId());
if (usersPayBefor != null) {
goodsOrderdata.setTotalPrice(usersPayBefor.getAllmoney());
goodsOrderdata.setPayPrice(usersPayBefor.getAllmoney().subtract(usersPayBefor.getReturnmoney()));
}
if (goodsOrderdata.getAddressId() != null) {
UserAddress userAddress = userAddressService.selectUserAddressById(goodsOrderdata.getAddressId());
if (userAddress != null) {
goodsOrderdata.setLatitude(userAddress.getLatitude());
goodsOrderdata.setLongitude(userAddress.getLongitude());
goodsOrderdata.setAdressinfo(userAddress.getAddressInfo() + userAddress.getInfo());
}
}
Users users = usersService.selectUsersById(goodsOrderdata.getUid());
if (users != null) {
goodsOrderdata.setUname(users.getName());
goodsOrderdata.setUphone(users.getPhone());
}
@ -96,13 +103,14 @@ public class GoodsOrderController extends BaseController
}
return getDataTable(list);
}
@GetMapping("/getByMainOrderId/{mainOrderId}")
public AjaxResult getGoodsOrderByMainOrderId(@PathVariable String mainOrderId) {
try {
GoodsOrder goodsOrderdata = new GoodsOrder();
goodsOrderdata.setMainOrderId(mainOrderId);
List<GoodsOrder> orders = goodsOrderService.selectGoodsOrderList(goodsOrderdata);
// 为每个订单补充商品详细信息
for (GoodsOrder order : orders) {
if (order.getProductId() != null) {
@ -122,14 +130,14 @@ public class GoodsOrderController extends BaseController
}
}
}
return AjaxResult.success(orders);
} catch (Exception e) {
log.error("获取主订单数据失败主订单ID: {}, 错误: {}", mainOrderId, e.getMessage());
return AjaxResult.error("获取主订单数据失败: " + e.getMessage());
}
}
/**
* 根据商品ID获取商品详细信息
*/
@ -139,19 +147,19 @@ public class GoodsOrderController extends BaseController
if (productId == null) {
return AjaxResult.error("商品ID不能为空");
}
ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(productId);
if (serviceGoods == null) {
return AjaxResult.error("未找到商品信息");
}
return AjaxResult.success(serviceGoods);
} catch (Exception e) {
log.error("获取商品信息失败商品ID: {}, 错误: {}", productId, e.getMessage());
return AjaxResult.error("获取商品信息失败: " + e.getMessage());
}
}
/**
* 批量获取商品信息
*/
@ -161,7 +169,7 @@ public class GoodsOrderController extends BaseController
if (productIds == null || productIds.isEmpty()) {
return AjaxResult.error("商品ID列表不能为空");
}
Map<Long, ServiceGoods> productMap = new HashMap<>();
for (Long productId : productIds) {
try {
@ -173,7 +181,7 @@ public class GoodsOrderController extends BaseController
log.warn("获取商品信息失败商品ID: {}, 错误: {}", productId, e.getMessage());
}
}
return AjaxResult.success(productMap);
} catch (Exception e) {
log.error("批量获取商品信息失败,错误: {}", e.getMessage());
@ -187,8 +195,7 @@ public class GoodsOrderController extends BaseController
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:export')")
@Log(title = "商品订单", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, GoodsOrder goodsOrder)
{
public void export(HttpServletResponse response, GoodsOrder goodsOrder) {
List<GoodsOrder> list = goodsOrderService.selectGoodsOrderList(goodsOrder);
ExcelUtil<GoodsOrder> util = new ExcelUtil<GoodsOrder>(GoodsOrder.class);
util.exportExcel(response, list, "商品订单数据");
@ -199,26 +206,25 @@ public class GoodsOrderController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
GoodsOrder goodsOrderdata =goodsOrderService.selectGoodsOrderById(id);
if(goodsOrderdata.getAddressId()!=null){
UserAddress userAddress=userAddressService.selectUserAddressById(goodsOrderdata.getAddressId());
if (userAddress != null){
public AjaxResult getInfo(@PathVariable("id") Long id) {
GoodsOrder goodsOrderdata = goodsOrderService.selectGoodsOrderById(id);
if (goodsOrderdata.getAddressId() != null) {
UserAddress userAddress = userAddressService.selectUserAddressById(goodsOrderdata.getAddressId());
if (userAddress != null) {
goodsOrderdata.setLatitude(userAddress.getLatitude());
goodsOrderdata.setLongitude(userAddress.getLongitude());
goodsOrderdata.setAdressinfo(userAddress.getAddressInfo()+userAddress.getInfo());
goodsOrderdata.setAdressinfo(userAddress.getAddressInfo() + userAddress.getInfo());
}
//ISiteDeliveryService siteDeliveryService;
if (goodsOrderdata.getDeliveryId()!=null){
SiteDelivery siteDelivery=siteDeliveryService.selectSiteDeliveryById(goodsOrderdata.getDeliveryId());
if(siteDelivery!=null){
if (goodsOrderdata.getDeliveryId() != null) {
SiteDelivery siteDelivery = siteDeliveryService.selectSiteDeliveryById(goodsOrderdata.getDeliveryId());
if (siteDelivery != null) {
goodsOrderdata.setDeliveryName(siteDelivery.getTitle());
}
}
Users users=usersService.selectUsersById(goodsOrderdata.getUid());
if(users !=null){
Users users = usersService.selectUsersById(goodsOrderdata.getUid());
if (users != null) {
goodsOrderdata.setUname(users.getName());
goodsOrderdata.setUphone(users.getPhone());
}
@ -233,11 +239,10 @@ public class GoodsOrderController extends BaseController
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:add')")
@Log(title = "商品订单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody GoodsOrder goodsOrder)
{
if (goodsOrder.getAddressId()!=null){
UserAddress userAddress=userAddressService.selectUserAddressById(goodsOrder.getAddressId());
if (userAddress!=null){
public AjaxResult add(@RequestBody GoodsOrder goodsOrder) {
if (goodsOrder.getAddressId() != null) {
UserAddress userAddress = userAddressService.selectUserAddressById(goodsOrder.getAddressId());
if (userAddress != null) {
goodsOrder.setName(userAddress.getName());
goodsOrder.setPhone(userAddress.getPhone());
@ -245,16 +250,16 @@ public class GoodsOrderController extends BaseController
}
}
if (goodsOrder.getProductId()!=null){
ServiceGoods serviceGoods=serviceGoodsService.selectServiceGoodsById(goodsOrder.getProductId());
if (serviceGoods!=null){
if (goodsOrder.getProductId() != null) {
ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(goodsOrder.getProductId());
if (serviceGoods != null) {
goodsOrder.setGoodPrice(serviceGoods.getPrice());
}
}
goodsOrder.setGoodPrice(serviceGoods.getPrice());
}
}
return toAjax(goodsOrderService.insertGoodsOrder(goodsOrder));
}
}
/**
* 修改商品订单
@ -262,16 +267,15 @@ public class GoodsOrderController extends BaseController
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:edit')")
@Log(title = "商品订单", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody GoodsOrder goodsOrder)
{
GoodsOrder goodsOrderdata=goodsOrderService.selectGoodsOrderById(goodsOrder.getId());
if (goodsOrderdata.getStatus()==2L&&goodsOrder.getStatus()==3L){
SiteDelivery siteDelivery=siteDeliveryService.selectSiteDeliveryById(goodsOrder.getDeliveryId());
if (siteDelivery!=null){
JSONObject jsonObject= new JSONObject();
jsonObject.put("wlgs",siteDelivery.getTitle());
jsonObject.put("wldh",goodsOrder.getDeliveryNum());
OrderUtil.addgoodsorderlog(goodsOrder.getId(),goodsOrder.getOrderId(),"订单已发货","2",jsonObject,2L);
public AjaxResult edit(@RequestBody GoodsOrder goodsOrder) {
GoodsOrder goodsOrderdata = goodsOrderService.selectGoodsOrderById(goodsOrder.getId());
if (goodsOrderdata.getStatus() == 2L && goodsOrder.getStatus() == 3L) {
SiteDelivery siteDelivery = siteDeliveryService.selectSiteDeliveryById(goodsOrder.getDeliveryId());
if (siteDelivery != null) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("wlgs", siteDelivery.getTitle());
jsonObject.put("wldh", goodsOrder.getDeliveryNum());
OrderUtil.addgoodsorderlog(goodsOrder.getId(), goodsOrder.getOrderId(), "订单已发货", "2", jsonObject, 2L);
}
}
@ -283,9 +287,8 @@ public class GoodsOrderController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:remove')")
@Log(title = "商品订单", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(goodsOrderService.deleteGoodsOrderByIds(ids));
}
@ -295,17 +298,16 @@ public class GoodsOrderController extends BaseController
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:edit')")
@Log(title = "售后申请处理", businessType = BusinessType.UPDATE)
@PostMapping("/processAfterSale")
public AjaxResult processAfterSale(@RequestBody JSONObject params)
{
public AjaxResult processAfterSale(@RequestBody JSONObject params) {
try {
java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Long id = params.getLong("id");
String action = params.getString("action");
if (id == null || action == null) {
return error("参数错误");
}
GoodsOrder goodsOrder = goodsOrderService.selectGoodsOrderById(id);
if (goodsOrder == null) {
return error("订单不存在");
@ -315,11 +317,11 @@ public class GoodsOrderController extends BaseController
reamk = "";
}
// 检查当前状态是否为申请状态或平台收货状态
if (goodsOrder.getReturnstatus() == null ||
(goodsOrder.getReturnstatus() != 1 && goodsOrder.getReturnstatus() != 4)) {
if (goodsOrder.getReturnstatus() == null ||
(goodsOrder.getReturnstatus() != 1 && goodsOrder.getReturnstatus() != 4)) {
return error("当前订单状态不允许此操作");
}
JSONArray returnLogistics = null;
if (goodsOrder.getReturnjson() != null && !goodsOrder.getReturnjson().isEmpty()) {
try {
@ -340,13 +342,13 @@ public class GoodsOrderController extends BaseController
String logMessage = "";
String content = "";
Long newStatus = null;
if ("reject".equals(action)) {
// 驳回申请
newStatus = 6L;
logMessage = "拒绝退款";
returnJsonObject2.put("title","拒绝退款");
returnJsonObject2.put("content","拒绝原因"+reamk);
returnJsonObject2.put("title", "拒绝退款");
returnJsonObject2.put("content", "拒绝原因" + reamk);
} else if ("approve".equals(action)) {
// 同意申请
if (goodsOrder.getReturntype() != null) {
@ -354,15 +356,15 @@ public class GoodsOrderController extends BaseController
// 仅退款
newStatus = 2L;
logMessage = "同意退款";
content="商家已同意申请,72小时内完成您的退款操作";
returnJsonObject2.put("title","退款成功");
returnJsonObject2.put("content","平台以退款"+reamk);
content = "商家已同意申请,72小时内完成您的退款操作";
returnJsonObject2.put("title", "退款成功");
returnJsonObject2.put("content", "平台以退款" + reamk);
} else if (goodsOrder.getReturntype() == 2) {
// 退货退款
newStatus = 3L;
logMessage = "商品寄回";
returnJsonObject2.put("title","请寄回物品");
returnJsonObject2.put("content","平台将在收到货物72小时为您处理请耐心等待");
returnJsonObject2.put("title", "请寄回物品");
returnJsonObject2.put("content", "平台将在收到货物72小时为您处理请耐心等待");
} else {
return error("售后类型错误");
}
@ -376,44 +378,44 @@ public class GoodsOrderController extends BaseController
}
newStatus = 6L;
logMessage = "驳回退款";
returnJsonObject2.put("title","拒绝退款");
returnJsonObject2.put("content","拒绝原因"+reamk);
returnJsonObject2.put("title", "拒绝退款");
returnJsonObject2.put("content", "拒绝原因" + reamk);
} else if ("approve_refund".equals(action)) {
// 同意退款平台收货后
if (goodsOrder.getReturnstatus() != 4) {
return error("当前状态不允许此操作");
}
// 获取退款金额和备注
String refundAmountStr = params.getString("returnrealmoney");
String refundRemark = params.getString("refundRemark");
if (refundAmountStr == null || refundAmountStr.trim().isEmpty()) {
return error("退款金额不能为空");
}
try {
BigDecimal refundAmount = new BigDecimal(refundAmountStr);
BigDecimal orderAmount = goodsOrder.getPayPrice();
if (refundAmount.compareTo(orderAmount) > 0) {
return error("退款金额不能超过订单金额");
}
// 设置退款金额
goodsOrder.setReturnmoney(refundAmount);
// 构建退款内容
String refundContent = "退款金额:¥" + refundAmount;
if (refundRemark != null && !refundRemark.trim().isEmpty()) {
refundContent += ",备注:" + refundRemark;
}
newStatus = 5L;
logMessage = "同意退款";
returnJsonObject2.put("title","退款成功");
returnJsonObject2.put("title", "退款成功");
returnJsonObject2.put("content", refundContent);
} catch (NumberFormatException e) {
return error("退款金额格式错误");
}
@ -423,7 +425,7 @@ public class GoodsOrderController extends BaseController
returnLogisticsData.put("title", logMessage);
returnLogistics.add(returnLogisticsData);
goodsOrder.setReturnjson(returnLogistics.toJSONString());
// 如果是同意退款设置退款完成时间
if ("approve_refund".equals(action)) {
goodsOrder.setReturnfinshtime(new Date());
@ -432,23 +434,23 @@ public class GoodsOrderController extends BaseController
// 更新订单状态
goodsOrder.setReturnstatus(newStatus);
int result = goodsOrderService.updateGoodsOrder(goodsOrder);
if (result > 0) {
// 添加操作日志
OrderUtil.addgoodsorderlog(
goodsOrder.getId(),
goodsOrder.getOrderId(),
logMessage,
"3",
new JSONObject(),
2L
goodsOrder.getId(),
goodsOrder.getOrderId(),
logMessage,
"3",
new JSONObject(),
2L
);
return success("操作成功");
} else {
return error("操作失败");
}
} catch (Exception e) {
log.error("处理售后申请失败", e);
return error("操作失败:" + e.getMessage());
@ -461,20 +463,19 @@ public class GoodsOrderController extends BaseController
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:edit')")
@Log(title = "订单发货", businessType = BusinessType.UPDATE)
@PostMapping("/shipOrder")
public AjaxResult shipOrder(@RequestBody GoodsOrder goodsOrder)
{
public AjaxResult shipOrder(@RequestBody GoodsOrder goodsOrder) {
try {
// 验证订单是否存在
GoodsOrder existingOrder = goodsOrderService.selectGoodsOrderById(goodsOrder.getId());
if (existingOrder == null) {
return error("订单不存在");
}
// 验证订单状态是否为已支付待发货
if (existingOrder.getStatus() != 2L) {
return error("只有已支付待发货的订单才能发货");
}
// 验证必填字段
if (goodsOrder.getDeliveryId() == null) {
return error("请选择快递公司");
@ -485,13 +486,13 @@ public class GoodsOrderController extends BaseController
if (goodsOrder.getSendTime() == null) {
return error("请选择发货时间");
}
// 获取快递公司信息
SiteDelivery siteDelivery = siteDeliveryService.selectSiteDeliveryById(goodsOrder.getDeliveryId());
if (siteDelivery == null) {
return error("快递公司不存在");
}
// // 更新订单信息
// existingOrder.setDeliveryId(goodsOrder.getDeliveryId());
// existingOrder.setDeliveryNum(goodsOrder.getDeliveryNum());
@ -510,30 +511,30 @@ public class GoodsOrderController extends BaseController
goodsOrderdata.setSendTime(goodsOrder.getSendTime());
goodsOrderdata.setMark(goodsOrder.getMark());
goodsOrderdata.setStatus(3L); // 设置为已发货状态
count+= goodsOrderService.updateGoodsOrder(goodsOrderdata);
count += goodsOrderService.updateGoodsOrder(goodsOrderdata);
}
// 更新订单
if (count > 0) {
// 添加发货日志
JSONObject logData = new JSONObject();
logData.put("wlgs", siteDelivery.getTitle());
logData.put("wldh", goodsOrder.getDeliveryNum());
OrderUtil.addgoodsorderlog(
existingOrder.getId(),
existingOrder.getMainOrderId(),
"订单已发货",
"2",
logData,
2L
existingOrder.getId(),
existingOrder.getMainOrderId(),
"订单已发货",
"2",
logData,
2L
);
return success("发货成功");
} else {
return error("发货失败");
}
} catch (Exception e) {
log.error("订单发货失败", e);
return error("发货失败:" + e.getMessage());
@ -546,48 +547,47 @@ public class GoodsOrderController extends BaseController
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:edit')")
@Log(title = "Excel导入批量发货", businessType = BusinessType.UPDATE)
@PostMapping("/batchShipByExcel")
public AjaxResult batchShipByExcel(@RequestParam("file") MultipartFile file)
{
public AjaxResult batchShipByExcel(@RequestParam("file") MultipartFile file) {
try {
if (file.isEmpty()) {
return error("请选择要上传的Excel文件");
}
String fileName = file.getOriginalFilename();
if (!fileName.endsWith(".xlsx") && !fileName.endsWith(".xls")) {
return error("请上传Excel格式的文件(.xlsx或.xls)");
}
// 读取Excel文件
List<Map<String, Object>> excelData = readExcelFile(file);
if (excelData == null || excelData.isEmpty()) {
return error("Excel文件内容为空或格式错误");
}
// 验证Excel数据格式
String validationResult = validateExcelData(excelData);
if (!"success".equals(validationResult)) {
return error("Excel数据格式错误" + validationResult);
}
// 执行批量发货
Map<String, Object> result = executeBatchShipping(excelData);
// 返回详细的结果信息
return AjaxResult.success("批量发货完成", result);
} catch (Exception e) {
log.error("Excel导入批量发货失败", e);
return error("批量发货失败:" + e.getMessage());
}
}
/**
* 读取Excel文件内容
*/
private List<Map<String, Object>> readExcelFile(MultipartFile file) throws Exception {
List<Map<String, Object>> dataList = new ArrayList<>();
try (InputStream is = file.getInputStream()) {
Workbook workbook;
if (file.getOriginalFilename().endsWith(".xlsx")) {
@ -595,55 +595,55 @@ public class GoodsOrderController extends BaseController
} else {
workbook = WorkbookFactory.create(is);
}
Sheet sheet = workbook.getSheetAt(0);
if (sheet == null) {
return dataList;
}
// 跳过标题行从第二行开始读取数据
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
Row row = sheet.getRow(i);
if (row == null) continue;
Map<String, Object> rowData = new HashMap<>();
// 读取订单号
Cell orderIdCell = row.getCell(0);
if (orderIdCell != null) {
rowData.put("orderId", getCellValue(orderIdCell));
}
// 读取快递公司
Cell deliveryCompanyCell = row.getCell(1);
if (deliveryCompanyCell != null) {
rowData.put("deliveryCompany", getCellValue(deliveryCompanyCell));
}
// 读取快递单号
Cell deliveryNumCell = row.getCell(2);
if (deliveryNumCell != null) {
rowData.put("deliveryNum", getCellValue(deliveryNumCell));
}
// 读取发货时间
Cell sendTimeCell = row.getCell(3);
if (sendTimeCell != null) {
rowData.put("sendTime", getCellValue(sendTimeCell));
}
// 只添加有订单号的行
if (rowData.get("orderId") != null && !rowData.get("orderId").toString().trim().isEmpty()) {
dataList.add(rowData);
}
}
workbook.close();
}
return dataList;
}
/**
* 获取单元格值
*/
@ -651,7 +651,7 @@ public class GoodsOrderController extends BaseController
if (cell == null) {
return "";
}
switch (cell.getCellType()) {
case STRING:
return cell.getStringCellValue();
@ -670,7 +670,7 @@ public class GoodsOrderController extends BaseController
return "";
}
}
/**
* 验证Excel数据格式
*/
@ -678,35 +678,35 @@ public class GoodsOrderController extends BaseController
if (excelData == null || excelData.isEmpty()) {
return "Excel数据为空";
}
for (int i = 0; i < excelData.size(); i++) {
Map<String, Object> row = excelData.get(i);
int rowNum = i + 2; // Excel行号从2开始因为第1行是标题
// 验证订单号
Object orderId = row.get("orderId");
if (orderId == null || orderId.toString().trim().isEmpty()) {
return "" + rowNum + "行:订单号不能为空";
}
// 验证快递公司
Object deliveryCompany = row.get("deliveryCompany");
if (deliveryCompany == null || deliveryCompany.toString().trim().isEmpty()) {
return "" + rowNum + "行:快递公司不能为空";
}
// 验证快递单号
Object deliveryNum = row.get("deliveryNum");
if (deliveryNum == null || deliveryNum.toString().trim().isEmpty()) {
return "" + rowNum + "行:快递单号不能为空";
}
// 验证发货时间
Object sendTime = row.get("sendTime");
if (sendTime == null || sendTime.toString().trim().isEmpty()) {
return "" + rowNum + "行:发货时间不能为空";
}
// 验证发货时间格式
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@ -715,10 +715,10 @@ public class GoodsOrderController extends BaseController
return "" + rowNum + "发货时间格式错误请使用yyyy-MM-dd格式";
}
}
return "success";
}
/**
* 执行批量发货
*/
@ -727,41 +727,41 @@ public class GoodsOrderController extends BaseController
List<String> successList = new ArrayList<>();
List<String> failList = new ArrayList<>();
List<String> skipList = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (Map<String, Object> row : excelData) {
String orderId = row.get("orderId").toString().trim();
String deliveryCompany = row.get("deliveryCompany").toString().trim();
String deliveryNum = row.get("deliveryNum").toString().trim();
String sendTimeStr = row.get("sendTime").toString().trim();
try {
// 根据订单号查询订单
GoodsOrder queryOrder = new GoodsOrder();
queryOrder.setOrderId(orderId);
List<GoodsOrder> orders = goodsOrderService.selectGoodsOrderList(queryOrder);
if (orders == null || orders.isEmpty()) {
failList.add(orderId + ":订单不存在");
continue;
}
GoodsOrder order = orders.get(0);
// 检查订单状态
if (order.getStatus() != 2L) {
skipList.add(orderId + ":订单状态不是待发货状态(当前状态:" + order.getStatus() + "");
continue;
}
// 根据快递公司名称查找快递公司ID
Long deliveryId = findDeliveryIdByName(deliveryCompany);
if (deliveryId == null) {
failList.add(orderId + ":快递公司'" + deliveryCompany + "'不存在");
continue;
}
// 解析发货时间
Date sendTime;
try {
@ -770,22 +770,22 @@ public class GoodsOrderController extends BaseController
failList.add(orderId + ":发货时间格式错误");
continue;
}
// 执行发货
boolean shipResult = shipSingleOrder(order, deliveryId, deliveryNum, sendTime);
if (shipResult) {
successList.add(orderId);
} else {
failList.add(orderId + ":发货失败");
}
} catch (Exception e) {
log.error("处理订单" + orderId + "发货失败", e);
failList.add(orderId + ":处理异常 - " + e.getMessage());
}
}
result.put("total", excelData.size());
result.put("success", successList.size());
result.put("fail", failList.size());
@ -793,10 +793,10 @@ public class GoodsOrderController extends BaseController
result.put("successList", successList);
result.put("failList", failList);
result.put("skipList", skipList);
return result;
}
/**
* 根据快递公司名称查找ID
*/
@ -814,7 +814,7 @@ public class GoodsOrderController extends BaseController
}
return null;
}
/**
* 发货单个订单
*/
@ -825,39 +825,39 @@ public class GoodsOrderController extends BaseController
order.setDeliveryNum(deliveryNum);
order.setSendTime(sendTime);
order.setStatus(3L); // 设置为已发货状态
// 更新订单
int result = goodsOrderService.updateGoodsOrder(order);
if (result > 0) {
// 获取快递公司信息
SiteDelivery siteDelivery = siteDeliveryService.selectSiteDeliveryById(deliveryId);
String deliveryTitle = siteDelivery != null ? siteDelivery.getTitle() : "未知快递";
// 添加发货日志
JSONObject logData = new JSONObject();
logData.put("wlgs", deliveryTitle);
logData.put("wldh", deliveryNum);
OrderUtil.addgoodsorderlog(
999L,
order.getMainOrderId(),
"Excel批量导入发货",
"2",
logData,
2L
999L,
order.getMainOrderId(),
"Excel批量导入发货",
"2",
logData,
2L
);
return true;
}
return false;
} catch (Exception e) {
log.error("发货订单" + order.getOrderId() + "失败", e);
return false;
}
}
/**
* 下载批量发货Excel模板
*/
@ -866,27 +866,27 @@ public class GoodsOrderController extends BaseController
try {
// 创建CSV内容
String csvContent = "订单号,快递公司,快递单号,发货时间\n" +
"B00001,顺丰,35434353,2025/8/11\n" +
"B00002,圆通,12345678,2025/8/11";
"B00001,顺丰,35434353,2025/8/11\n" +
"B00002,圆通,12345678,2025/8/11";
// 设置响应头
response.setContentType("text/csv;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
String fileName = "批量发货模板.csv";
response.setHeader("Content-Disposition", "attachment;filename=" +
java.net.URLEncoder.encode(fileName, "UTF-8"));
response.setHeader("Content-Disposition", "attachment;filename=" +
java.net.URLEncoder.encode(fileName, "UTF-8"));
// 写入CSV内容
response.getWriter().write(csvContent);
response.getWriter().flush();
} catch (Exception e) {
log.error("下载模板失败", e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.getWriter().write("下载模板失败:" + e.getMessage());
}
}
/**
* 测试模板文件是否正常
*/
@ -898,27 +898,27 @@ public class GoodsOrderController extends BaseController
if (resourceUrl == null) {
return error("模板文件不存在");
}
// 使用Files.readAllBytes来读取文件内容
java.nio.file.Path filePath = java.nio.file.Paths.get(resourceUrl.toURI());
byte[] fileContent = java.nio.file.Files.readAllBytes(filePath);
if (fileContent.length == 0) {
return error("模板文件为空");
}
// 检查文件头验证是否为有效的XLSX文件
if (fileContent.length < 4) {
return error("模板文件太小,可能已损坏");
}
// XLSX文件应该以PK开头ZIP格式
if (fileContent[0] != 0x50 || fileContent[1] != 0x4B) {
return error("模板文件不是有效的XLSX格式缺少ZIP文件头");
}
return success("模板文件正常,大小:" + fileContent.length + " 字节");
} catch (Exception e) {
log.error("测试模板文件失败", e);
return error("测试模板文件失败:" + e.getMessage());

View File

@ -46,6 +46,21 @@ public class OrderLogController extends BaseController
return getDataTable(list);
}
/**
* 查询订单服务记录列表
*/
@PreAuthorize("@ss.hasPermi('system:OrderLog:list')")
@GetMapping("/getAllList")
public AjaxResult getAllList(OrderLog orderLog)
{
List<OrderLog> list = orderLogService.selectOrderLogList(orderLog);
return success(list);
}
/**
* 导出订单服务记录列表
*/

View File

@ -444,29 +444,6 @@ public class UsersPayBeforController extends BaseController
if (paymentInfo == null) {
return error("未找到支付记录");
}
// 根据servicetype查询对应订单
Order order = null;
if (paymentInfo.getServicetype() != null) {
if (paymentInfo.getServicetype() == 1) {
// 服务类型为1调用orderService根据orderid查询订单
order = orderService.selectOrderByOrderId(orderId);
} else if (paymentInfo.getServicetype() == 2) {
// 服务类型为2调用goodsOrderService根据mainOrderId查询订单
GoodsOrder goodsOrder = new GoodsOrder();
goodsOrder.setMainOrderId(orderId);
List<GoodsOrder> goodsOrders = goodsOrderService.selectGoodsOrderList(goodsOrder);
if (goodsOrders != null && !goodsOrders.isEmpty()) {
// 使用第一个商品订单的orderId查询订单
//order = orderService.selectOrderByOrderId(goodsOrders.get(0).getOrderId());
}
}
}
// if (order == null) {
// return error("订单不存在");
// }
List<UsersPayBefor> payRecords = usersPayBeforService.selectPayDetailsByOrderId(orderId);
System.out.println("000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"+payRecords.size());
if (payRecords == null || payRecords.isEmpty()) {
@ -610,337 +587,53 @@ public class UsersPayBeforController extends BaseController
BigDecimal remainingServiceGoldRefund = serviceGoldRefund;
BigDecimal remainingCouponRefund = couponRefund;
// 修复确保BigDecimal转换正确处理可能的null值和类型问题
// BigDecimal wechatRefund = BigDecimal.ZERO;
// BigDecimal balanceRefund = BigDecimal.ZERO;
// BigDecimal shoppingGoldRefund = BigDecimal.ZERO;
// BigDecimal serviceGoldRefund = BigDecimal.ZERO;
// BigDecimal memberDiscountRefund = BigDecimal.ZERO;
// BigDecimal couponRefund = BigDecimal.ZERO;
// 修复正确计算各项支付方式的退款金额
for (UsersPayBefor record : payRecords) {
BigDecimal currentRefunded = record.getReturnmoney() != null ? record.getReturnmoney() : BigDecimal.ZERO;
// 计算本次退款中该记录应承担的退款金额
BigDecimal recordRefundAmount = BigDecimal.ZERO;
// 根据该记录的支付方式分配退款金额
if (record.getWxmoney() != null && record.getWxmoney().compareTo(BigDecimal.ZERO) > 0) {
// 修复计算该记录微信支付的剩余可退款金额
BigDecimal wxRemaining = record.getWxmoney().subtract(currentRefunded);
if (wxRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingWechatRefund.compareTo(BigDecimal.ZERO) > 0) {
record.setWxmoney(record.getWxmoney().subtract(currentRefunded));
if (remainingWechatRefund.compareTo(BigDecimal.ZERO) > 0) {
BenefitPointsUtil.theWXmoneyChangeResult(record, remainingWechatRefund, "微信支付退款成功");
}
// BigDecimal wxRemaining = record.getWxmoney().subtract(currentRefunded);
// if (wxRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingWechatRefund.compareTo(BigDecimal.ZERO) > 0) {
// record.setWxmoney(wxRemaining);
// BigDecimal wxRefund = remainingWechatRefund.min(wxRemaining);
// recordRefundAmount = recordRefundAmount.add(wxRefund);
// remainingWechatRefund = remainingWechatRefund.subtract(wxRefund);
// }
}
//余额
if (record.getYemoney() != null && record.getYemoney().compareTo(BigDecimal.ZERO) > 0) {
// 修复计算该记录余额支付的剩余可退款金额
BigDecimal yeRemaining = record.getYemoney().subtract(currentRefunded);
if (yeRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingBalanceRefund.compareTo(BigDecimal.ZERO) > 0) {
record.setYemoney(record.getYemoney().subtract(remainingBalanceRefund));
// System.out.println("=== 调用退款工具方法前的参数验证 yeRemaining======================================================"+yeRemaining);
// System.out.println("=== 调用退款工具方法前的参数验证 record.getYemoney()======================================================"+record.getYemoney());
// System.out.println("=== 调用退款工具方法前的参数验证 currentRefunded======================================================"+currentRefunded);
//
// record.setYemoney(yeRemaining);
// BigDecimal yeRefund = remainingBalanceRefund.min(yeRemaining);
// recordRefundAmount = recordRefundAmount.add(yeRefund);
// remainingBalanceRefund = remainingBalanceRefund.subtract(yeRefund);
if (remainingBalanceRefund.compareTo(BigDecimal.ZERO) > 0) {
BenefitPointsUtil.theYueChangeResult(record, remainingBalanceRefund, 1, "余额支付退款");
}
}
if (record.getShopmoney() != null && record.getShopmoney().compareTo(BigDecimal.ZERO) > 0) {
// 修复计算该记录购物金的剩余可退款金额
BigDecimal shopRemaining = record.getShopmoney().subtract(currentRefunded);
if (shopRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingShoppingGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
// record.setShopmoney(shopRemaining);
// BigDecimal shopRefund = remainingShoppingGoldRefund.min(shopRemaining);
// recordRefundAmount = recordRefundAmount.add(shopRefund);
// remainingShoppingGoldRefund = remainingShoppingGoldRefund.subtract(shopRefund);
if (remainingShoppingGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
BenefitPointsUtil.theBenefitPointsGoodsMoneyChangeResult(record, remainingShoppingGoldRefund, 1, "订单退款");
}
}
if (record.getServicemoney() != null && record.getServicemoney().compareTo(BigDecimal.ZERO) > 0) {
// 修复计算该记录服务金的剩余可退款金额
BigDecimal serviceRemaining = record.getServicemoney().subtract(currentRefunded);
if (serviceRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingServiceGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
if (remainingServiceGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
BenefitPointsUtil.theBenefitPointsServiceMoneyChangeResult(record,remainingServiceGoldRefund,1,"订单退款");
}
}
if (record.getCouponmoney() != null && record.getCouponmoney().compareTo(BigDecimal.ZERO) > 0) {
// 修复计算该记录优惠券的剩余可退款金额
BigDecimal couponRemaining = record.getCouponmoney().subtract(currentRefunded);
if (couponRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingCouponRefund.compareTo(BigDecimal.ZERO) > 0) {
BenefitPointsUtil.theBenefitPointsGoodsMoneyChangeResult(record,remainingShoppingGoldRefund,1,"订单退款");
if (remainingCouponRefund.compareTo(BigDecimal.ZERO) > 0) {
BenefitPointsUtil.theyouhuimoneyChangeResult(record,1);
}
}
// 如果该记录有退款金额则更新
if (recordRefundAmount.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal newTotalRefunded = currentRefunded.add(recordRefundAmount);
// 如果累计退款金额等于或超过支付金额设置为已退款状态
if (newTotalRefunded.compareTo(record.getAllmoney()) >= 0) {
record.setStatus(3L); // 完全退款
} else {
record.setStatus(2L); // 部分退款
}
record.setReturnmoney(newTotalRefunded);
usersPayBeforService.updateUsersPayBefor(record);
System.out.println("更新支付记录: ID=" + record.getId() +
", 原退款金额=" + currentRefunded +
", 本次退款=" + recordRefundAmount +
", 新总退款=" + newTotalRefunded +
", 状态=" + record.getStatus());
}
}
// 调用退款工具方法实现真实的业务退款与金额变动
// 使用原始参数而不是被修改的副本
System.out.println("=== 调用退款工具方法前的参数验证 ===");
System.out.println("原始退款参数:");
System.out.println(" orderId: " + orderId);
System.out.println(" wechatRefund: " + wechatRefund);
System.out.println(" balanceRefund: " + balanceRefund);
System.out.println(" shoppingGoldRefund: " + shoppingGoldRefund);
System.out.println(" serviceGoldRefund: " + serviceGoldRefund);
System.out.println(" memberDiscountRefund: " + memberDiscountRefund);
System.out.println(" couponRefund: " + couponRefund);
System.out.println(" refundRemark: " + refundRemark);
// 验证参数类型和值
System.out.println("参数类型检查:");
System.out.println(" balanceRefund类型: " + balanceRefund.getClass().getName());
System.out.println(" balanceRefund值: " + balanceRefund);
System.out.println(" balanceRefund比较0: " + balanceRefund.compareTo(BigDecimal.ZERO));
// Map<String, Object> refundResult = refundUtil.processUnifiedRefund(
// orderId, wechatRefund, balanceRefund, shoppingGoldRefund,
// serviceGoldRefund, memberDiscountRefund, couponRefund, refundRemark
// );
return success("退款成功");
// if (refundResult != null && (Boolean) refundResult.get("success")) {
// return success("退款成功");
// } else {
// String errorMsg = (String) refundResult.get("message");
// return error(errorMsg != null ? errorMsg : "退款处理失败");
// }
} catch (Exception e) {
return error("退款失败:" + e.getMessage());
}
}
// /**
// * 统一退款方法 - 核心逻辑直接修改预支付表金额
// */
// @Log(title = "统一退款", businessType = BusinessType.UPDATE)
// @PostMapping("/unifiedRefund")
// public AjaxResult unifiedRefund(@RequestBody Map<String, Object> params)
// {
// try {
// System.out.println("=== 开始统一退款 ===");
// System.out.println("接收到的参数: " + params);
//
// // 1. 获取订单ID
// String orderId = params.get("orderId") == null ? null : params.get("orderId").toString();
// if (orderId == null || orderId.trim().isEmpty()) {
// return error("订单ID不能为空");
// }
//
// // 2. 获取各项退款金额
// BigDecimal wechatRefund = parseBigDecimalSafely(params.get("wechatRefund"));
// BigDecimal balanceRefund = parseBigDecimalSafely(params.get("balanceRefund"));
// BigDecimal shoppingGoldRefund = parseBigDecimalSafely(params.get("shoppingGoldRefund"));
// BigDecimal serviceGoldRefund = parseBigDecimalSafely(params.get("serviceGoldRefund"));
// BigDecimal couponRefund = parseBigDecimalSafely(params.get("couponRefund"));
// String refundRemark = params.get("refundRemark") == null ? "" : params.get("refundRemark").toString();
//
// // 3. 计算总退款金额
// BigDecimal totalRefund = wechatRefund.add(balanceRefund).add(shoppingGoldRefund)
// .add(serviceGoldRefund).add(couponRefund);
//
// if (totalRefund.compareTo(BigDecimal.ZERO) <= 0) {
// return error("退款金额必须大于0");
// }
//
// System.out.println("=== 退款金额 ===");
// System.out.println("微信退款: " + wechatRefund + "");
// System.out.println("余额退款: " + balanceRefund + "");
// System.out.println("购物金退款: " + shoppingGoldRefund + "");
// System.out.println("服务金退款: " + serviceGoldRefund + "");
// System.out.println("优惠券退款: " + couponRefund + "");
// System.out.println("总退款金额: " + totalRefund + "");
//
// // 4. 核心逻辑调用IUsersPayBeforService查询orderid获取预支付数据
// UsersPayBefor paymentInfo = usersPayBeforService.selectUsersPayBeforByOrderId(orderId);
// if (paymentInfo == null) {
// return error("未找到支付记录");
// }
//
// // 5. 获取原始金额
// BigDecimal originalWxMoney = paymentInfo.getWxmoney() != null ? paymentInfo.getWxmoney() : BigDecimal.ZERO;
// BigDecimal originalYeMoney = paymentInfo.getYemoney() != null ? paymentInfo.getYemoney() : BigDecimal.ZERO;
// BigDecimal originalShopMoney = paymentInfo.getShopmoney() != null ? paymentInfo.getShopmoney() : BigDecimal.ZERO;
// BigDecimal originalServiceMoney = paymentInfo.getServicemoney() != null ? paymentInfo.getServicemoney() : BigDecimal.ZERO;
// BigDecimal originalCouponMoney = paymentInfo.getCouponmoney() != null ? paymentInfo.getCouponmoney() : BigDecimal.ZERO;
// BigDecimal originalMemberMoney = paymentInfo.getMembermoney() != null ? paymentInfo.getMembermoney() : BigDecimal.ZERO;
//
// System.out.println("=== 原始金额 ===");
// System.out.println("微信支付: " + originalWxMoney + "");
// System.out.println("余额支付: " + originalYeMoney + "");
// System.out.println("购物金: " + originalShopMoney + "");
// System.out.println("服务金: " + originalServiceMoney + "");
// System.out.println("优惠券: " + originalCouponMoney + "");
// System.out.println("会员优惠: " + originalMemberMoney + "");
//
// // 6. 验证退款金额不超过原始金额
// if (wechatRefund.compareTo(originalWxMoney) > 0) {
// return error("微信退款金额不能超过微信支付金额");
// }
// if (balanceRefund.compareTo(originalYeMoney) > 0) {
// return error("余额退款金额不能超过余额支付金额");
// }
// if (shoppingGoldRefund.compareTo(originalShopMoney) > 0) {
// return error("购物金退款金额不能超过购物金金额");
// }
// if (serviceGoldRefund.compareTo(originalServiceMoney) > 0) {
// return error("服务金退款金额不能超过服务金金额");
// }
// // 优惠券只能全额退要么退0要么等于原优惠券金额
// if (couponRefund.compareTo(BigDecimal.ZERO) > 0) {
// if (originalCouponMoney.compareTo(BigDecimal.ZERO) == 0) {
// return error("无可退的优惠券金额");
// }
// if (couponRefund.compareTo(originalCouponMoney) != 0) {
// return error("优惠券只能全额退,原金额:¥" + originalCouponMoney + ",本次退款:¥" + couponRefund);
// }
// }
//
// // 7. 核心逻辑根据各个项目的退款进行修改上面的金额
// BigDecimal newWxMoney = originalWxMoney.subtract(wechatRefund);
// BigDecimal newYeMoney = originalYeMoney.subtract(balanceRefund);
// BigDecimal newShopMoney = originalShopMoney.subtract(shoppingGoldRefund);
// BigDecimal newServiceMoney = originalServiceMoney.subtract(serviceGoldRefund);
// BigDecimal newCouponMoney = originalCouponMoney.subtract(couponRefund);
//
// // 确保金额不为负数
// if (newWxMoney.compareTo(BigDecimal.ZERO) < 0) newWxMoney = BigDecimal.ZERO;
// if (newYeMoney.compareTo(BigDecimal.ZERO) < 0) newYeMoney = BigDecimal.ZERO;
// if (newShopMoney.compareTo(BigDecimal.ZERO) < 0) newShopMoney = BigDecimal.ZERO;
// if (newServiceMoney.compareTo(BigDecimal.ZERO) < 0) newServiceMoney = BigDecimal.ZERO;
// if (newCouponMoney.compareTo(BigDecimal.ZERO) < 0) newCouponMoney = BigDecimal.ZERO;
//
// // 8. 计算新的总金额不包括会员优惠
// BigDecimal newTotalAmount = newWxMoney.add(newYeMoney).add(newShopMoney)
// .add(newServiceMoney).add(newCouponMoney);
//
// // 9. 获取当前已退款金额并计算新的总退款金额
// BigDecimal currentRefunded = paymentInfo.getReturnmoney() != null ? paymentInfo.getReturnmoney() : BigDecimal.ZERO;
// BigDecimal newTotalRefunded = currentRefunded.add(totalRefund);
//
// System.out.println("=== 修改后的金额 ===");
// System.out.println("微信支付: " + newWxMoney + "元 (原: " + originalWxMoney + " - 退: " + wechatRefund + ")");
// System.out.println("余额支付: " + newYeMoney + "元 (原: " + originalYeMoney + " - 退: " + balanceRefund + ")");
// System.out.println("购物金: " + newShopMoney + "元 (原: " + originalShopMoney + " - 退: " + shoppingGoldRefund + ")");
// System.out.println("服务金: " + newServiceMoney + "元 (原: " + originalServiceMoney + " - 退: " + serviceGoldRefund + ")");
// System.out.println("优惠券: " + newCouponMoney + "元 (原: " + originalCouponMoney + " - 退: " + couponRefund + ")");
// System.out.println("会员优惠: " + originalMemberMoney + "元 (不参与退款)");
// System.out.println("新总金额: " + newTotalAmount + "");
// System.out.println("累计退款: " + newTotalRefunded + "");
//
// // 10. 更新预支付表数据
// paymentInfo.setWxmoney(newWxMoney);
// paymentInfo.setYemoney(newYeMoney);
// paymentInfo.setShopmoney(newShopMoney);
// paymentInfo.setServicemoney(newServiceMoney);
// paymentInfo.setCouponmoney(newCouponMoney);
// paymentInfo.setAllmoney(newTotalAmount);
// paymentInfo.setReturnmoney(newTotalRefunded);
//
// // 设置状态
// if (newTotalRefunded.compareTo(newTotalAmount) >= 0) {
// paymentInfo.setStatus(3L); // 完全退款
// } else {
// paymentInfo.setStatus(2L); // 部分退款
// }
//
// // 11. 保存更新
// int updateResult = usersPayBeforService.updateUsersPayBefor(paymentInfo);
// if (updateResult <= 0) {
// return error("支付记录更新失败");
// }
//
// // 12. 记录退款日志
// OrderLog orderLog = new OrderLog();
// orderLog.setOrderId(orderId);
// orderLog.setOid(999L);
// orderLog.setTitle("退款");
// orderLog.setOrdertype(paymentInfo.getServicetype());
// orderLog.setType(new BigDecimal(11));
//
// // 构建退款说明
// StringBuilder refundDesc = new StringBuilder("统一退款:");
// if (wechatRefund.compareTo(BigDecimal.ZERO) > 0) {
// refundDesc.append("微信支付退款¥").append(wechatRefund).append("");
// }
// if (balanceRefund.compareTo(BigDecimal.ZERO) > 0) {
// refundDesc.append("余额退款¥").append(balanceRefund).append("");
// }
// if (shoppingGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
// refundDesc.append("购物金退款¥").append(shoppingGoldRefund).append("");
// }
// if (serviceGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
// refundDesc.append("服务金退款¥").append(serviceGoldRefund).append("");
// }
// if (couponRefund.compareTo(BigDecimal.ZERO) > 0) {
// refundDesc.append("优惠券退款¥").append(couponRefund).append("");
// }
//
// if (refundDesc.charAt(refundDesc.length() - 1) == '') {
// refundDesc.setLength(refundDesc.length() - 1);
// }
//
// refundDesc.append(",本次退款金额:¥").append(totalRefund);
// refundDesc.append(",累计已退款:¥").append(newTotalRefunded);
// refundDesc.append(",剩余可退款:¥").append(newTotalAmount);
// refundDesc.append("(会员优惠¥").append(originalMemberMoney).append("不参与退款)");
//
// orderLog.setContent(refundDesc.toString());
// orderLogService.insertOrderLog(orderLog);
//
// // 13. 调用退款工具方法处理业务逻辑
// System.out.println("=== 调用退款工具方法 ===");
// Map<String, Object> refundResult = refundUtil.processUnifiedRefund(
// orderId, wechatRefund, balanceRefund, shoppingGoldRefund,
// serviceGoldRefund, BigDecimal.ZERO, couponRefund, refundRemark
// );
//
// if (refundResult != null && (Boolean) refundResult.get("success")) {
// System.out.println("✅ 退款处理成功");
// return success("退款成功");
// } else {
// String errorMsg = (String) refundResult.get("message");
// return error(errorMsg != null ? errorMsg : "退款处理失败");
// }
//
// } catch (Exception e) {
// System.err.println("❌ 退款处理异常: " + e.getMessage());
// e.printStackTrace();
// return error("退款失败:" + e.getMessage());
// }
// }
}

View File

@ -75,6 +75,16 @@ public class WechatTransferController extends BaseController
}
return success(usersService.selectUsersList(users));
}
/**
* 统计汇总总申请金额已到账金额处理中金额不含状态3
*/
@PreAuthorize("@ss.hasPermi('system:transfer:list')")
@GetMapping("/summary")
public AjaxResult summary(WechatTransfer wechatTransfer)
{
return success(wechatTransferService.selectWechatTransferSummary(wechatTransfer));
}
/**
* 导出wechat_transfer列表
*/
@ -84,6 +94,32 @@ public class WechatTransferController extends BaseController
public void export(HttpServletResponse response, WechatTransfer wechatTransfer)
{
List<WechatTransfer> list = wechatTransferService.selectWechatTransferList(wechatTransfer);
for(WechatTransfer dd: list){
Users users=usersService.selectUsersById(dd.getUid());
if (users!=null){
dd.setUname(users.getName());
}
if (dd.getPaid()!=null){
if (dd.getPaid()==1){
dd.setPaname("已到账");
}else{
dd.setPaname("未到账");
}
}else{
dd.setPaname("未到账");
}
if (dd.getStatus()!=null){
if (dd.getStatus()==1){
dd.setStatusname("待处理");
}
if (dd.getStatus()==2){
dd.setStatusname("处理完成");
}
if (dd.getStatus()==3){
dd.setStatusname("驳回");
}
}
}
ExcelUtil<WechatTransfer> util = new ExcelUtil<WechatTransfer>(WechatTransfer.class);
util.exportExcel(response, list, "wechat_transfer数据");
}

View File

@ -40,7 +40,7 @@ public class BenefitPointsUtil {
private static final IUsersPayBeforService usersPayBeforService = SpringUtils.getBean(IUsersPayBeforService.class);
private static final IUserMemnerConsumptionLogService userMemnerConsumptionLogService = SpringUtils.getBean(IUserMemnerConsumptionLogService.class);
private static final IPayMoneyLogService payMoneyLogService = SpringUtils.getBean(IPayMoneyLogService.class);
private static final ICouponUserService couponUserService = SpringUtils.getBean(ICouponUserService.class);
// 配置常量
@ -102,6 +102,10 @@ public class BenefitPointsUtil {
log.error("【错误】订单不存在订单ID: {}", orderId);
return new BenefitPointsResult(false, "订单不存在", null);
}
UsersPayBefor payBefor = usersPayBeforService.selectUsersPayBeforByOrderId(order.getMainOrderId());
if (payBefor == null){
return new BenefitPointsResult(false, "订单不存在", null);
}
// 2. 获取用户信息
Users user = usersService.selectUsersById(order.getUid());
if (user == null) {
@ -115,7 +119,7 @@ public class BenefitPointsUtil {
return new BenefitPointsResult(false, "系统配置获取失败", null);
}
//处理积分
IntegralAndBenefitUtil.processIntegralAndBenefit(money, order.getOrderId(), order.getUid());
IntegralAndBenefitUtil.processIntegralAndBenefit(payBefor.getAllmoney(), payBefor.getOrderid(), payBefor.getUid());
// //处理库存及销量
// OrderUtil.updateInventoryAndSales(order.getOrderId(), 2);
@ -443,6 +447,10 @@ public class BenefitPointsUtil {
if (userDb != null && userDb.getServicefee() != null && userDb.getServicefee().compareTo(ZERO) > 0) {
BigDecimal serviceRate = serviceDeductionRatio.divide(new BigDecimal("100"), 4, ROUND_HALF_UP);
serviceMoney = userDb.getServicefee().multiply(serviceRate);
//判断一下如果服务抵扣金额大于总金额amount就表示服务金全部抵扣如果小于就抵扣一部分
if (serviceMoney.compareTo(amount) > 0) {
serviceMoney=amount;
}
log.info("【服务金抵扣】用户ID: {}, 服务金余额: {}, 抵扣比例: {}, 抵扣金额: {}",
user.getId(), userDb.getServicefee(), serviceDeductionRatio, serviceMoney);
}
@ -456,6 +464,9 @@ public class BenefitPointsUtil {
if (userDb != null && userDb.getConsumption() != null && userDb.getConsumption().compareTo(ZERO) > 0) {
BigDecimal consumptionRate = consumptionDeductionRatio.divide(new BigDecimal("100"), 4, ROUND_HALF_UP);
shopMoney = userDb.getConsumption().multiply(consumptionRate);
if (shopMoney.compareTo(amount) > 0) {
shopMoney=amount;
}
log.info("【消费金抵扣】用户ID: {}, 消费金余额: {}, 抵扣比例: {}, 抵扣金额: {}",
user.getId(), userDb.getConsumption(), consumptionDeductionRatio, shopMoney);
}
@ -1166,6 +1177,70 @@ public class BenefitPointsUtil {
public UserBenefitPoints getLog() { return log; }
public void setLog(UserBenefitPoints log) { this.log = log; }
}
//这是用户创建订单和退款的时候的调用 减少各类数据
public static int creatServerOrderData(UsersPayBefor usersPayBefor) {
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
if(usersPayBeforData!=null){
if (usersPayBeforData.getStatus()==1){
//微信支付比较特殊在回调里面直接处理就可以回调里面添加流水修改订单状态即可
// if (usersPayBeforData.getWxmoney()!=null&&usersPayBeforData.getWxmoney().compareTo(BigDecimal.ZERO)>0){
// theWXmoneyChangeResult(usersPayBeforData,usersPayBeforData.getWxmoney(),"");
// }
//余额退款
if (usersPayBeforData.getYemoney()!=null&&usersPayBeforData.getYemoney().compareTo(BigDecimal.ZERO)>0){
theYueChangeResult(usersPayBeforData,usersPayBeforData.getYemoney(),2,"创建订单消费");
}
//购物金退款
if (usersPayBeforData.getShopmoney()!=null&&usersPayBeforData.getShopmoney().compareTo(BigDecimal.ZERO)>0){
theBenefitPointsGoodsMoneyChangeResult(usersPayBeforData,usersPayBeforData.getShopmoney(),2,"创建订单消费");
}
//服务金退款
if (usersPayBeforData.getServicemoney()!=null&&usersPayBeforData.getServicemoney().compareTo(BigDecimal.ZERO)>0){
theBenefitPointsServiceMoneyChangeResult(usersPayBeforData,usersPayBeforData.getServicemoney(),2,"创建订单消费");
}
//优惠券退款
if (usersPayBeforData.getCouponmoney()!=null&&usersPayBeforData.getCouponmoney().compareTo(BigDecimal.ZERO)>0){
theyouhuimoneyChangeResult(usersPayBeforData,2);
}
}
}
return 0;
}
//这是用户取消订单和退款的时候的调用 添加各类数据
public static int refundServerOrderData(UsersPayBefor usersPayBefor) {
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
if(usersPayBeforData!=null) {
if (usersPayBeforData.getStatus()==2){
//微信退款
if (usersPayBeforData.getWxmoney()!=null&&usersPayBeforData.getWxmoney().compareTo(BigDecimal.ZERO)>0){
theWXmoneyChangeResult(usersPayBeforData,usersPayBeforData.getWxmoney(),"");
}
//余额退款
if (usersPayBeforData.getYemoney()!=null&&usersPayBeforData.getYemoney().compareTo(BigDecimal.ZERO)>0){
theYueChangeResult(usersPayBeforData,usersPayBeforData.getYemoney(),1,"用户取消订单退款");
}
//购物金退款
if (usersPayBeforData.getShopmoney()!=null&&usersPayBeforData.getShopmoney().compareTo(BigDecimal.ZERO)>0){
theBenefitPointsGoodsMoneyChangeResult(usersPayBeforData,usersPayBeforData.getShopmoney(),1,"用户取消订单退款");
}
//服务金退款
if (usersPayBeforData.getServicemoney()!=null&&usersPayBeforData.getServicemoney().compareTo(BigDecimal.ZERO)>0){
theBenefitPointsServiceMoneyChangeResult(usersPayBeforData,usersPayBeforData.getServicemoney(),1,"用户取消订单退款");
}
//优惠券退款
if (usersPayBeforData.getCouponmoney()!=null&&usersPayBeforData.getCouponmoney().compareTo(BigDecimal.ZERO)>0){
theyouhuimoneyChangeResult(usersPayBeforData,1);
}
}
}
return 0;
}
//------------------------------------------------------------------------------------------------------------------------------
//服务金变更
// private IUsersPayBeforService usersPayBeforService;
@ -1174,14 +1249,24 @@ public class BenefitPointsUtil {
Map<String, Object> remap=new HashMap<>();
Map<String, Object> config = getSystemConfig();
BigDecimal servicefeeRatio = getConfigValue(config, SERVICEFEE_KEY, new BigDecimal("0"));
BigDecimal amountService = servicemoney.multiply(servicefeeRatio).divide(new BigDecimal("100"));
// BigDecimal amountService = servicemoney.multiply(servicefeeRatio).divide(new BigDecimal("100"));
BigDecimal amountService = BigDecimal.ZERO;
if (servicefeeRatio.compareTo(BigDecimal.ZERO) > 0) {
// 将百分比转换为小数如10% -> 0.1
BigDecimal ratioDecimal = servicefeeRatio.divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
// 计算退回金额Goodsmoney / ratioDecimal
amountService = servicemoney.divide(ratioDecimal, 2, RoundingMode.HALF_UP);
}
Users user = usersService.selectUsersById(usersPayBefor.getUid());
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
if(usersPayBeforData.getReturnmoney()==null){
usersPayBeforData.setReturnmoney(BigDecimal.ZERO);
}
if (user==null){
remap.put("code",2);
return remap;
}
//type 1增加 0减少
//type 1增加(用户增加就是退款的时候用) 0减少
if(type==1){
user.setServicefee(user.getServicefee().add(amountService));
UserBenefitPoints benefitLog = new UserBenefitPoints();
@ -1198,8 +1283,11 @@ public class BenefitPointsUtil {
userBenefitPointsService.insertUserBenefitPoints(benefitLog);
usersService.updateUsers(user);
//增加用户服务金金就是减少预支付的服务金
usersPayBeforData.setReturnmoney(usersPayBeforData.getReturnmoney().add(servicemoney));
usersPayBeforData.setServicemoney(usersPayBeforData.getServicemoney().subtract(servicemoney));
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
//退款的时候就要添加退款金额累加的
remap.put("code",1);
return remap;
@ -1219,23 +1307,27 @@ public class BenefitPointsUtil {
userBenefitPointsService.insertUserBenefitPoints(benefitLog);
usersService.updateUsers(user);
//减少用户服务金金就是增加预支付的服务金
usersPayBeforData.setServicemoney(usersPayBeforData.getServicemoney().add(servicemoney));
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
// usersPayBeforData.setServicemoney(usersPayBeforData.getServicemoney().add(servicemoney));
// usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
remap.put("code",1);
return remap;
}
}
//余额变动
//余额变动//type 1增加(用户增加就是退款的时候用) 0减少
public static Map<String, Object> theYueChangeResult(UsersPayBefor usersPayBefor,BigDecimal money,int type,String reamk) {
Map<String, Object> remap=new HashMap<>();
System.out.println("余额变动-------"+money);
//余额变动
Users user = usersService.selectUsersById(usersPayBefor.getUid());
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
if(usersPayBeforData.getReturnmoney()==null){
usersPayBeforData.setReturnmoney(BigDecimal.ZERO);
}
if(type==1){
user.setBalance(user.getBalance().add(money));
usersPayBeforData.setYemoney(usersPayBeforData.getYemoney().subtract(money));
UserMemnerConsumptionLog userMemnerConsumptionLog=new UserMemnerConsumptionLog();
userMemnerConsumptionLog.setUid(Math.toIntExact(user.getId()));
userMemnerConsumptionLog.setConsumptiontype(2);
@ -1249,11 +1341,14 @@ public class BenefitPointsUtil {
userMemnerConsumptionLog.setOrderid(usersPayBefor.getOrderid());
userMemnerConsumptionLogService.insertUserMemnerConsumptionLog(userMemnerConsumptionLog);
usersService.updateUsers(user);
usersPayBeforData.setYemoney(usersPayBeforData.getYemoney().subtract(money));
usersPayBeforData.setReturnmoney(usersPayBeforData.getReturnmoney().add(money));
System.out.println("11余额变动-------"+usersPayBeforData.getYemoney());
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
remap.put("code",1);
}else{
user.setBalance(user.getBalance().subtract(money));
usersPayBeforData.setYemoney(usersPayBeforData.getYemoney().add(money));
// usersPayBeforData.setYemoney(money);
UserMemnerConsumptionLog userMemnerConsumptionLog=new UserMemnerConsumptionLog();
userMemnerConsumptionLog.setUid(Math.toIntExact(user.getId()));
userMemnerConsumptionLog.setConsumptiontype(2);
@ -1267,21 +1362,34 @@ public class BenefitPointsUtil {
userMemnerConsumptionLog.setOrderid(usersPayBefor.getOrderid());
userMemnerConsumptionLogService.insertUserMemnerConsumptionLog(userMemnerConsumptionLog);
usersService.updateUsers(user);
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
// usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
remap.put("code",1);
}
return remap;
}
//购物金变更
//购物金变更//type 1增加(用户增加就是退款的时候用) 0减少
public static Map<String, Object> theBenefitPointsGoodsMoneyChangeResult(UsersPayBefor usersPayBefor,BigDecimal Goodsmoney,int type,String reamk) {
//第一步获取系统维护的服务金比例
//第一步获取系统维护的购物金比例
Map<String, Object> remap=new HashMap<>();
Map<String, Object> config = getSystemConfig();
BigDecimal goodsfeeRatio = getConfigValue(config, CONSUMPTION_KEY, new BigDecimal("0"));
BigDecimal amountService = Goodsmoney.multiply(goodsfeeRatio).divide(new BigDecimal("100"));
System.out.println("换算比例-------"+goodsfeeRatio);
// 修改计算逻辑amountGoodsmoney = Goodsmoney / goodsfeeRatio
// 例如goodsfeeRatio=10表示10%Goodsmoney=5则amountGoodsmoney=5/0.1=50
BigDecimal amountGoodsmoney = BigDecimal.ZERO;
if (goodsfeeRatio.compareTo(BigDecimal.ZERO) > 0) {
// 将百分比转换为小数如10% -> 0.1
BigDecimal ratioDecimal = goodsfeeRatio.divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
// 计算退回金额Goodsmoney / ratioDecimal
amountGoodsmoney = Goodsmoney.divide(ratioDecimal, 2, RoundingMode.HALF_UP);
}
System.out.println("抵扣金额-------"+amountGoodsmoney);
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
if(usersPayBeforData.getReturnmoney()==null){
usersPayBeforData.setReturnmoney(BigDecimal.ZERO);
}
Users user = usersService.selectUsersById(usersPayBefor.getUid());
if (user==null){
remap.put("code",2);
@ -1289,42 +1397,46 @@ public class BenefitPointsUtil {
}
//type 1增加 0减少
if(type==1){
user.setConsumption(user.getConsumption().add(amountService));
user.setConsumption(user.getConsumption().add(amountGoodsmoney));
UserBenefitPoints benefitLog = new UserBenefitPoints();
benefitLog.setOrderid(usersPayBefor.getId());
benefitLog.setUid(usersPayBefor.getUid());
benefitLog.setType(2L);//类别 1服务金 2消费金
benefitLog.setOrdertype(1L); //数据类别 1收入 2支出
benefitLog.setOrdermoney(usersPayBefor.getAllmoney());
benefitLog.setMoney(amountService);
benefitLog.setBeformoney(user.getConsumption().subtract(amountService));
benefitLog.setMoney(amountGoodsmoney);
benefitLog.setBeformoney(user.getConsumption().subtract(amountGoodsmoney));
benefitLog.setAftremoney(user.getConsumption());
benefitLog.setReamk(reamk);
benefitLog.setDotime(new Date());
userBenefitPointsService.insertUserBenefitPoints(benefitLog);
usersService.updateUsers(user);
usersPayBeforData.setReturnmoney(usersPayBeforData.getReturnmoney().add(Goodsmoney));
usersPayBeforData.setShopmoney(usersPayBeforData.getShopmoney().subtract(Goodsmoney));
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
remap.put("code",1);
return remap;
}else{
user.setConsumption(user.getConsumption().subtract(amountService));
System.out.println("抵扣区间-------"+user.getConsumption().subtract(amountGoodsmoney));
user.setConsumption(user.getConsumption().subtract(amountGoodsmoney));
UserBenefitPoints benefitLog = new UserBenefitPoints();
benefitLog.setOrderid(usersPayBefor.getId());
benefitLog.setUid(usersPayBefor.getUid());
benefitLog.setType(2L);//类别 1服务金 2消费金
benefitLog.setOrdertype(2L); //数据类别 1收入 2支出
benefitLog.setOrdermoney(usersPayBefor.getAllmoney());
benefitLog.setMoney(amountService);
benefitLog.setBeformoney(user.getConsumption().add(amountService));
benefitLog.setMoney(amountGoodsmoney);
benefitLog.setBeformoney(user.getConsumption().add(amountGoodsmoney));
benefitLog.setAftremoney(user.getConsumption());
benefitLog.setReamk(reamk);
benefitLog.setDotime(new Date());
userBenefitPointsService.insertUserBenefitPoints(benefitLog);
usersService.updateUsers(user);
usersPayBeforData.setShopmoney(usersPayBeforData.getShopmoney().add(Goodsmoney));
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
System.out.println("抵扣完成-------"+benefitLog.getId());
// usersPayBeforData.setShopmoney(usersPayBeforData.getShopmoney().add(Goodsmoney));
// usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
remap.put("code",1);
return remap;
@ -1332,75 +1444,82 @@ public class BenefitPointsUtil {
}
//微信支付变动
public static Map<String, Object> theWXmoneyChangeResult(UsersPayBefor usersPayBefor,BigDecimal money,int type,String reamk) {
//微信支付变动只有退款
public static Map<String, Object> theWXmoneyChangeResult(UsersPayBefor usersPayBefor,BigDecimal money,String reamk) {
Map<String, Object> remap=new HashMap<>();
//余额变动
Users user = usersService.selectUsersById(usersPayBefor.getUid());
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
if(usersPayBeforData.getReturnmoney()==null){
usersPayBeforData.setReturnmoney(BigDecimal.ZERO);
}
int allmoney=usersPayBefor.getWxmoney().multiply(new BigDecimal(100)).intValue();
int tkmoney=money.multiply(new BigDecimal(100)).intValue();
WechatPayV3Util WW=new WechatPayV3Util();
// 7. 调用微信退款接口
Map<String, Object> refundResult = WW.refund(usersPayBeforData.getOrderid(),
Map<String, Object> refundResult = WW.refund(
usersPayBeforData.getOrderid(),
String.valueOf(usersPayBeforData.getId()),
allmoney,
tkmoney,
"订单退款",
WechatPayUtil.PAY_FH + "/api/secondary/card/refund/notify"
WechatPayUtil.PAY_FH + "/api/secondary/tuikuan/refund/notify"
);
PayMoneyLog payMoneyLog = new PayMoneyLog();
if (usersPayBefor != null) {
payMoneyLog.setOid(usersPayBefor.getId());
if (refundResult != null && Boolean.TRUE.equals(refundResult.get("success"))) {
remap.put("success", true);
return remap;
}
payMoneyLog.setOrderId(usersPayBefor.getOrderid());
payMoneyLog.setUid(usersPayBefor.getUid());
if (user != null) {
payMoneyLog.setUname(user.getName());
}
payMoneyLog.setPrice(money);
payMoneyLog.setMark("订单退款");
payMoneyLog.setPayTime(new Date());
payMoneyLogService.insertPayMoneyLog(payMoneyLog);
// if(type==1){
// user.setBalance(user.getBalance().add(money));
// usersPayBeforData.setYemoney(usersPayBeforData.getYemoney().subtract(money));
// UserMemnerConsumptionLog userMemnerConsumptionLog=new UserMemnerConsumptionLog();
// userMemnerConsumptionLog.setUid(Math.toIntExact(user.getId()));
// userMemnerConsumptionLog.setConsumptiontype(2);
// userMemnerConsumptionLog.setConsumptiontime(new Date());
// userMemnerConsumptionLog.setConsumptionmoney(money);
// userMemnerConsumptionLog.setReamk(reamk);
// userMemnerConsumptionLog.setBeformoney(user.getBalance().subtract(money));
// userMemnerConsumptionLog.setAftermoney(user.getBalance());
// userMemnerConsumptionLog.setNowmoney(user.getBalance());
// userMemnerConsumptionLog.setType(1);
// userMemnerConsumptionLog.setOrderid(usersPayBefor.getOrderid());
// userMemnerConsumptionLogService.insertUserMemnerConsumptionLog(userMemnerConsumptionLog);
// usersService.updateUsers(user);
// usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
// remap.put("code",1);
// }else{
// user.setBalance(user.getBalance().subtract(money));
// usersPayBeforData.setYemoney(usersPayBeforData.getYemoney().add(money));
// UserMemnerConsumptionLog userMemnerConsumptionLog=new UserMemnerConsumptionLog();
// userMemnerConsumptionLog.setUid(Math.toIntExact(user.getId()));
// userMemnerConsumptionLog.setConsumptiontype(2);
// userMemnerConsumptionLog.setConsumptiontime(new Date());
// userMemnerConsumptionLog.setConsumptionmoney(money);
// userMemnerConsumptionLog.setReamk(reamk);
// userMemnerConsumptionLog.setBeformoney(user.getBalance().add(money));
// userMemnerConsumptionLog.setAftermoney(user.getBalance());
// userMemnerConsumptionLog.setNowmoney(user.getBalance());
// userMemnerConsumptionLog.setType(2);
// userMemnerConsumptionLog.setOrderid(usersPayBefor.getOrderid());
// userMemnerConsumptionLogService.insertUserMemnerConsumptionLog(userMemnerConsumptionLog);
// usersService.updateUsers(user);
// usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
// remap.put("code",1);
// PayMoneyLog payMoneyLog = new PayMoneyLog();
// if (usersPayBefor != null) {
// payMoneyLog.setOid(usersPayBefor.getId());
// }
// payMoneyLog.setOrderId(usersPayBefor.getOrderid());
// payMoneyLog.setUid(usersPayBefor.getUid());
// if (user != null) {
// payMoneyLog.setUname(user.getName());
// }
// payMoneyLog.setPrice(money);
// payMoneyLog.setMark(reamk);
// payMoneyLog.setPayTime(new Date());
// payMoneyLogService.insertPayMoneyLog(payMoneyLog);
// usersPayBeforData.setReturnmoney(usersPayBeforData.getReturnmoney().add(money));
// usersPayBeforData.setWxmoney(usersPayBefor.getWxmoney().subtract(money));
// usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
return remap;
}
//优惠券回款直接退回优惠券就可以
public static Map<String, Object> theyouhuimoneyChangeResult(UsersPayBefor usersPayBefor,int type) {
Map<String, Object> remap=new HashMap<>();
//余额变动
Users user = usersService.selectUsersById(usersPayBefor.getUid());
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
if(usersPayBeforData.getReturnmoney()==null){
usersPayBeforData.setReturnmoney(BigDecimal.ZERO);
}
//1为退款的时候回滚优惠券
if (type==1){
CouponUser couponUser=couponUserService.selectCouponUserById(usersPayBefor.getCouponid());
if(couponUser!=null){
couponUser.setStatus(1L);
couponUserService.updateCouponUser(couponUser);
}
usersPayBeforData.setCouponid( null);
usersPayBeforData.setReturnmoney(usersPayBeforData.getReturnmoney().add(usersPayBeforData.getCouponmoney()));
usersPayBeforData.setCouponmoney(new BigDecimal("0"));
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
}else{
CouponUser couponUser=couponUserService.selectCouponUserById(usersPayBefor.getCouponid());
if(couponUser!=null){
couponUser.setStatus(2L);
couponUserService.updateCouponUser(couponUser);
}
}
return remap;
}

View File

@ -82,7 +82,7 @@ public class WechatPayUtil {
// public static final String PAY_FH = "https://www.huafurenjia.cn/";
public static final String PAY_FH = "https://api.huafurenjia.cn/";
public static final String PAY_FH = "https://552e105d.r3.cpolar.top/";
/**

View File

@ -41,7 +41,7 @@ public class WechatTransfer extends BaseEntity
private BigDecimal priceMax;
/** 状态 */
@Excel(name = "状态")
private Long status;
/** 订单号 */
@ -51,19 +51,28 @@ public class WechatTransfer extends BaseEntity
private String openid;
/** 0未到账 */
@Excel(name = "0未到账")
private Long paid;
/** 0未到账 */
@Excel(name = "是否到账")
private String paname;
/** 0未到账 */
@Excel(name = "申请状态")
private String statusname;
/** 到账时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "到账时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date payTime;
/** 操作时间 */
@Excel(name = "操作时间")
private Long time;
/** $column.columnComment */
/** 操作时间 */
@Excel(name = "操作时间",width = 30, dateFormat = "yyyy-MM-dd")
private Date createdAt;
/** $column.columnComment */
@ -213,6 +222,23 @@ public class WechatTransfer extends BaseEntity
this.priceMax = priceMax;
}
public String getStatusname() {
return statusname;
}
public void setStatusname(String statusname) {
this.statusname = statusname;
}
public String getPaname() {
return paname;
}
public void setPaname(String paname) {
this.paname = paname;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -58,4 +58,9 @@ public interface WechatTransferMapper
* @return 结果
*/
public int deleteWechatTransferByIds(Long[] ids);
/**
* 统计汇总总申请金额已到账金额处理中金额不计入状态3
*/
public java.util.Map<String, java.math.BigDecimal> selectWechatTransferSummary(WechatTransfer wechatTransfer);
}

View File

@ -58,4 +58,9 @@ public interface IWechatTransferService
* @return 结果
*/
public int deleteWechatTransferById(Long id);
/**
* 统计汇总总申请金额已到账金额处理中金额不含状态3
*/
public java.util.Map<String, java.math.BigDecimal> selectWechatTransferSummary(WechatTransfer wechatTransfer);
}

View File

@ -90,4 +90,13 @@ public class WechatTransferServiceImpl implements IWechatTransferService
{
return wechatTransferMapper.deleteWechatTransferById(id);
}
/**
* 统计汇总
*/
@Override
public java.util.Map<String, java.math.BigDecimal> selectWechatTransferSummary(WechatTransfer wechatTransfer)
{
return wechatTransferMapper.selectWechatTransferSummary(wechatTransfer);
}
}

View File

@ -100,4 +100,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<!-- 统计汇总总申请金额、已到账金额、处理中金额不含状态3 -->
<select id="selectWechatTransferSummary" parameterType="WechatTransfer" resultType="java.util.HashMap">
select
COALESCE(SUM(money),0) as totalApply,
COALESCE(SUM(CASE WHEN status = 2 THEN money ELSE 0 END),0) as totalPaid,
COALESCE(SUM(CASE WHEN status = 1 THEN money ELSE 0 END),0) as totalProcessing
from wechat_transfer
<where>
<if test="uid != null "> and uid = #{uid} </if>
<if test="batchId != null and batchId != ''"> and batch_id like concat('%', #{batchId}, '%')</if>
<if test="priceMin != null and priceMax != null">
and money BETWEEN #{priceMin} AND #{priceMax}
</if>
<if test="params.beginPayTime != null and params.beginPayTime != '' and params.endPayTime != null and params.endPayTime != ''"> and pay_time between #{params.beginPayTime} and #{params.endPayTime}</if>
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and time between #{params.beginTime} and #{params.endTime}</if>
</where>
</select>
</mapper>

View File

@ -52,7 +52,7 @@ export function delOrderLog(id) {
// 查询退款历史记录
export function getRefundHistory(orderId) {
return request({
url: '/system/OrderLog/list',
url: '/system/OrderLog/getAllList',
method: 'get',
params: {
orderId: orderId,

View File

@ -9,6 +9,15 @@ export function listTransfer(query) {
})
}
// 查询统计汇总
export function getTransferSummary(query) {
return request({
url: '/system/transfer/summary',
method: 'get',
params: query
})
}
// 查询wechat_transfer详细
export function getTransfer(id) {
return request({

View File

@ -89,12 +89,25 @@
</div>
</div>
<!-- 统一退款对话框 -->
<UnifiedRefundDialog
:visible.sync="unifiedRefundDialogVisible"
:orderId="currentAfterSaleOrder ? currentAfterSaleOrder.mainOrderId || currentAfterSaleOrder.orderId : ''"
:paymentData="currentRefundPaymentData"
@success="handleRefundSuccess"
/>
</el-dialog>
</template>
<script>
import UnifiedRefundDialog from './UnifiedRefundDialog.vue'
export default {
name: "AfterSaleDialog",
components: {
UnifiedRefundDialog
},
props: {
visible: {
type: Boolean,
@ -119,7 +132,9 @@ export default {
},
data() {
return {
localVisible: this.visible
localVisible: this.visible,
unifiedRefundDialogVisible: false,
currentRefundPaymentData: null
}
},
watch: {
@ -153,7 +168,22 @@ export default {
this.$emit('reject-refund');
},
handleApproveRefund() {
this.$emit('approve-refund');
// 退退
this.currentRefundPaymentData = {
wxmoney: this.currentAfterSaleOrder.payPrice || 0,
yemoney: 0,
shopmoney: 0,
servicemoney: 0,
membermoney: 0,
couponmoney: 0
};
this.unifiedRefundDialogVisible = true;
},
handleRefundSuccess() {
// 退退
this.unifiedRefundDialogVisible = false;
this.$emit('refund-success');
this.$emit('close');
}
}
};

View File

@ -33,6 +33,9 @@
<el-descriptions-item label="美团抵扣金额">
<span style="color: #67C23A;">{{ prePaymentData.mtmoney ? prePaymentData.mtmoney.toFixed(2) : '0.00' }}</span>
</el-descriptions-item>
<el-descriptions-item label="退款金额">
<span style="color: #67C23A;">{{ prePaymentData.returnmoney ? prePaymentData.returnmoney.toFixed(2) : '0.00' }}</span>
</el-descriptions-item>
</el-descriptions>
</div>
<div v-else>

View File

@ -44,11 +44,18 @@
</el-col>
</el-row>
<!-- 会员优惠单独显示仅当不为0时 -->
<div v-if="actualPaymentData.membermoney && parseFloat(actualPaymentData.membermoney) > 0" class="member-discount-row">
<div class="member-discount-item">
<span class="member-discount-label">会员优惠{{ formatAmount(actualPaymentData.membermoney) }}</span>
<span class="member-discount-note">平台承担不参与退款</span>
<!-- 会员优惠和邮费显示在同一行 -->
<div class="discount-postage-row">
<!-- 会员优惠仅当不为0时显示 -->
<div v-if="actualPaymentData.membermoney && parseFloat(actualPaymentData.membermoney) > 0" class="discount-postage-item">
<span class="discount-postage-label">会员优惠{{ formatAmount(actualPaymentData.membermoney) }}</span>
<span class="discount-postage-note">平台承担不参与退款</span>
</div>
<!-- 邮费仅当存在时显示 -->
<div v-if="actualPaymentData.postage && parseFloat(actualPaymentData.postage) > 0" class="discount-postage-item">
<span class="discount-postage-label">邮费{{ formatAmount(actualPaymentData.postage) }}</span>
<span class="discount-postage-note">此订单邮费{{ formatAmount(actualPaymentData.postage) }}元已计算在订单支付信息内</span>
</div>
</div>
<div class="total-amount">
@ -60,6 +67,7 @@
<div class="refund-summary" v-if="refundHistory.length > 0">
<el-row :gutter="20">
<el-col :span="12">
支付信息
<div class="summary-item">
<label>累计已退款</label>
<span class="amount refunded">{{ formatAmount(totalRefundedAmount) }}</span>
@ -72,24 +80,24 @@
</div>
</el-col>
</el-row>
<div class="summary-note">
<span class="note-text">💡 退款信息</span>
<div class="refund-details">
<div class="detail-row compact">
<span class="detail-label">订单总额</span>
<span class="detail-value">{{ formatAmount(actualPaymentData.allmoney) }}</span>
<span class="detail-separator">|</span>
<span class="detail-label">会员优惠</span>
<span class="detail-value">{{ formatAmount(actualPaymentData.membermoney || 0) }}</span>
<span class="detail-separator">|</span>
<span class="detail-label">累计退款</span>
<span class="detail-value">{{ formatAmount(totalRefundedAmount) }}</span>
<span class="detail-separator">|</span>
<span class="detail-label">剩余可退</span>
<span class="detail-value total-value">{{ formatAmount(remainingRefundableAmountComputed) }}</span>
</div>
</div>
</div>
<!-- <div class="summary-note">-->
<!-- <span class="note-text">💡 退款信息</span>-->
<!-- <div class="refund-details">-->
<!-- <div class="detail-row compact">-->
<!-- <span class="detail-label">订单总额</span>-->
<!-- <span class="detail-value">{{ formatAmount(actualPaymentData.allmoney) }}</span>-->
<!-- <span class="detail-separator">|</span>-->
<!-- <span class="detail-label">会员优惠</span>-->
<!-- <span class="detail-value">{{ formatAmount(actualPaymentData.membermoney || 0) }}</span>-->
<!-- <span class="detail-separator">|</span>-->
<!-- <span class="detail-label">累计退款</span>-->
<!-- <span class="detail-value">{{ formatAmount(totalRefundedAmount) }}</span>-->
<!-- <span class="detail-separator">|</span>-->
<!-- <span class="detail-label">剩余可退</span>-->
<!-- <span class="detail-value total-value">{{ formatAmount(remainingRefundableAmountComputed) }}</span>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</div>
</div>
@ -258,7 +266,11 @@
<div class="timeline-header">
<div class="header-title">
<span class="title-text">退款记录 #{{ index + 1 }}</span>
<span class="title-time">&nbsp;&nbsp;&nbsp;{{ formatTime(item.createTime) }}</span>
<!-- <span class="title-time">&nbsp;&nbsp;&nbsp;{{ formatTime(item.createdAt) }}</span>-->
</div>
<div class="header-date">
<span class="date-label">操作时间</span>
<span class="date-value">{{ formatDateTime(item.createdAt) }}</span>
</div>
<!-- <div class="header-actions">-->
<!-- <el-button-->
@ -586,9 +598,9 @@ export default {
const response = await getRefundHistory(this.orderId);
console.log('退款历史接口响应:', response);
if (response.code === 200 && response.rows) {
if (response.code === 200 && response.data) {
//
this.refundHistory = response.rows.sort((a, b) => {
this.refundHistory = response.data.sort((a, b) => {
const timeA = new Date(a.createTime || 0);
const timeB = new Date(b.createTime || 0);
return timeB - timeA;
@ -892,6 +904,13 @@ export default {
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`;
},
//
formatDateTime(timeStr) {
if (!timeStr) return '';
const date = new Date(timeStr);
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`;
},
//
formatAmount(amount) {
if (!amount || isNaN(amount)) return '0.00';
@ -927,12 +946,12 @@ export default {
try {
if (item.content) {
const content = JSON.parse(item.content);
// contentremainingRefundable使
if (content.remainingRefundable !== undefined) {
return content.name || content.description || content.remark || '退款记录';
}
//
if (content.name) {
return content.name;
@ -1074,12 +1093,12 @@ export default {
try {
if (item.content) {
const content = JSON.parse(item.content);
// contentremainingRefundable使
if (content.remainingRefundable !== undefined) {
return parseFloat(content.remainingRefundable);
}
// 使
return parseFloat(this.remainingRefundableAmountComputed);
}
@ -1139,9 +1158,19 @@ export default {
width: 100%;
}
/* 会员优惠单独行样式 */
.member-discount-row {
/* 会员优惠和邮费同行显示样式 */
.discount-postage-row {
margin-top: 10px;
display: flex;
gap: 20px;
justify-content: center;
flex-wrap: wrap;
}
.discount-postage-item {
flex: 1;
min-width: 200px;
max-width: 300px;
padding: 8px 12px;
background-color: #f0f9ff;
border: 1px solid #b3d8ff;
@ -1149,23 +1178,20 @@ export default {
text-align: center;
}
.member-discount-item {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
}
.member-discount-label {
.discount-postage-label {
font-size: 13px;
font-weight: 500;
color: #409EFF;
display: block;
margin-bottom: 4px;
}
.member-discount-note {
.discount-postage-note {
font-size: 11px;
color: #909399;
font-style: italic;
display: block;
line-height: 1.3;
}
.amount { font-weight: 600; color: #E6A23C; }
.amount.total { font-size: 18px; color: #409EFF; }
@ -1587,14 +1613,33 @@ export default {
}
.timeline-header {
margin-bottom: 10px;
padding-bottom: 10px;
border-bottom: 1px solid #ebeef5;
display: flex;
justify-content: space-between;
align-items: center;
.header-title{
display: flex;
justify-content: space-between;
}
.header-date {
text-align: right;
.date-label {
font-size: 12px;
color: #909399;
margin-right: 5px;
}
.date-value {
font-size: 12px;
color: #409EFF;
font-weight: 500;
}
}
}
.timeline-title {

View File

@ -279,7 +279,7 @@
<!-- v-if="scope.row.status >= 15"-->
<!-- 统一退款按钮 -->
<el-button
v-if="scope.row.status >= 15"
size="mini"
type="text"
icon="el-icon-money"
@ -336,7 +336,7 @@
@reject-after-sale="handleRejectAfterSale"
@approve-after-sale="handleApproveAfterSale"
@reject-refund="handleRejectRefund"
@approve-refund="handleApproveRefund"
@refund-success="handleRefundSuccess"
/>
<!-- 驳回理由输入对话框 -->
@ -886,21 +886,31 @@ export default {
/** 同意售后申请 */
handleApproveAfterSale() {
// 退
// 退
const { returntype, returnstatus } = this.currentAfterSaleOrder;
if (returntype === 1 && returnstatus === 1) {
// 退退
this.refundAmountForm.orderAmount = this.currentAfterSaleOrder.payPrice ? this.currentAfterSaleOrder.payPrice.toFixed(2) : '0.00';
this.refundAmountForm.returnrealmoney = '';
this.refundAmountForm.refundRemark = '';
this.refundAmountDialogVisible = true;
// 退退 - 退
this.currentRefundPaymentData = {
wxmoney: this.currentAfterSaleOrder.payPrice || 0,
yemoney: 0,
shopmoney: 0,
servicemoney: 0,
membermoney: 0,
couponmoney: 0
};
this.unifiedRefundDialogVisible = true;
} else if (returntype === 2 && returnstatus === 4) {
// 退退退
this.refundAmountForm.orderAmount = this.currentAfterSaleOrder.payPrice ? this.currentAfterSaleOrder.payPrice.toFixed(2) : '0.00';
this.refundAmountForm.returnrealmoney = '';
this.refundAmountForm.refundRemark = '';
this.refundAmountDialogVisible = true;
// 退退退 - 退
this.currentRefundPaymentData = {
wxmoney: this.currentAfterSaleOrder.payPrice || 0,
yemoney: 0,
shopmoney: 0,
servicemoney: 0,
membermoney: 0,
couponmoney: 0
};
this.unifiedRefundDialogVisible = true;
} else if (returntype === 2 && returnstatus === 1) {
// 退退退
this.$modal.confirm('确认同意该退货退款申请吗?客户需要先寄回商品。').then(() => {
@ -928,13 +938,11 @@ export default {
this.rejectReasonDialogVisible = true;
},
/** 同意退款 */
handleApproveRefund() {
// returnstatus === 4退
this.refundAmountForm.orderAmount = this.currentAfterSaleOrder.payPrice ? this.currentAfterSaleOrder.payPrice.toFixed(2) : '0.00';
this.refundAmountForm.returnrealmoney = '';
this.refundAmountForm.refundRemark = '';
this.refundAmountDialogVisible = true;
/** 处理退款成功 */
handleRefundSuccess() {
// 退
this.getList();
this.$modal.msgSuccess('退款成功');
},
/** 提交驳回理由 */

View File

@ -1146,9 +1146,9 @@
</el-dialog>
<!-- 订单详情查看对话框 -->
<el-dialog
<el-dialog
:title="`订单详情 - ${orderProcessForm.orderId}`"
:visible.sync="orderProcessOpen"
:visible.sync="orderProcessOpen"
width="90%"
:close-on-click-modal="true"
:close-on-press-escape="true"
@ -1163,7 +1163,7 @@
<div slot="header" class="clearfix">
<span>订单基本信息</span>
</div>
<!-- 第一行订单核心信息 -->
<el-row :gutter="16" class="info-row">
<el-col :span="6">
@ -1187,7 +1187,7 @@
</el-form-item>
</el-col>
</el-row>
<!-- 第二行金额和地址信息 -->
<el-row :gutter="16" class="info-row">
<el-col :span="6">
@ -1211,7 +1211,7 @@
</el-form-item>
</el-col>
</el-row>
<!-- 第三行时间信息 -->
<el-row :gutter="16" class="info-row">
<el-col :span="6">
@ -1235,7 +1235,7 @@
</el-form-item>
</el-col>
</el-row>
<!-- 附件信息 -->
<el-row :gutter="16" v-if="orderProcessForm.fileData || getFileList().length > 0" class="info-row">
<el-col :span="24">
@ -1261,7 +1261,7 @@
</el-form-item>
</el-col>
</el-row>
<!-- 备注信息 -->
<el-row :gutter="16" v-if="orderProcessForm.mark" class="info-row">
<el-col :span="24">
@ -1272,7 +1272,7 @@
</el-form-item>
</el-col>
</el-row>
<!-- 无附件和备注时的提示 -->
<el-row v-if="!orderProcessForm.fileData && !orderProcessForm.mark && getFileList().length === 0" class="info-row">
<el-col :span="24">
@ -1311,7 +1311,7 @@
</el-button>
</div>
</div>
<div v-if="orderProcessForm.receiveRecords && orderProcessForm.receiveRecords.length > 0" class="order-timeline">
<div class="timeline-container">
<div
@ -1332,7 +1332,7 @@
</div>
<div class="timeline-body">
<div class="timeline-description">{{ getContentDescription(record.content) }}</div>
<!-- 显示报价数据 -->
<div v-if="record.quote && isJsonString(record.quote)" class="timeline-quote">
<div class="quote-header">
@ -1343,7 +1343,7 @@
<pre>{{ formatJson(record.quote) }}</pre>
</div>
</div>
<!-- 显示图片 -->
<div v-if="record.contentImage && record.contentImage.length > 0" class="timeline-images">
<el-image
@ -1359,99 +1359,99 @@
</div>
</el-image>
</div>
<!-- 订单流程操作按钮 - 只在最后一条日志显示 -->
<div class="timeline-actions" v-if="index === orderProcessForm.receiveRecords.length - 1">
<!-- 根据最后一条日志的type显示不同操作 -->
<el-button
<el-button
v-if="record.type === 1"
type="primary"
size="small"
type="primary"
size="small"
@click="handleDispatchFromTimeline(record)"
:loading="dispatchLoading"
>
<i class="el-icon-s-promotion"></i>
派单
</el-button>
<!-- type为1.1时显示更换师傅和接单按钮 -->
<el-button
<el-button
v-if="record.type === 1.1"
type="warning"
size="small"
type="warning"
size="small"
@click="handleChangeWorker(record)"
style="margin-right: 8px;"
>
<i class="el-icon-refresh"></i>
更换师傅
</el-button>
<el-button
<el-button
v-if="record.type === 1.1"
type="success"
size="small"
type="success"
size="small"
@click="handleAcceptOrder(record)"
>
<i class="el-icon-check"></i>
接单
</el-button>
<el-button
<el-button
v-if="record.type === 2"
type="success"
size="small"
type="success"
size="small"
@click="handleDeparture(record)"
>
<i class="el-icon-location"></i>
出发上门
</el-button>
<el-button
<el-button
v-if="record.type === 3"
type="warning"
size="small"
type="warning"
size="small"
@click="handleConfirmArrival(record)"
>
<i class="el-icon-location-information"></i>
确认到达
</el-button>
<!-- type为4时显示三个按钮结束订单开始服务项目报价 -->
<div v-if="record.type === 4" class="timeline-actions-multiple">
<el-button
type="danger"
size="small"
<el-button
type="danger"
size="small"
@click="handleEndOrder(record)"
style="margin-right: 8px;"
>
<i class="el-icon-close"></i>
结束订单
</el-button>
<el-button
type="success"
size="small"
<el-button
type="success"
size="small"
@click="handleStartService(record)"
style="margin-right: 8px;"
>
<i class="el-icon-video-play"></i>
开始服务
</el-button>
<el-button
type="primary"
size="small"
<el-button
type="primary"
size="small"
@click="handleProjectQuote(record)"
>
<i class="el-icon-money"></i>
项目报价
</el-button>
</div>
<el-button
<el-button
v-if="record.type === 5"
type="success"
size="small"
type="success"
size="small"
@click="handleCompleteService(record)"
>
<i class="el-icon-circle-check"></i>
@ -1478,7 +1478,7 @@
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="orderProcessOpen = false" type="primary" size="medium"> </el-button>
</div>
@ -1792,13 +1792,14 @@
</el-tag>
</template>
</el-table-column>
<el-table-column label="退款金额" align="right" prop="returnmoney" width="100">
<template slot-scope="scope">
<span class="refund-amount">
{{ (scope.row.returnmoney || 0).toFixed(2) }}
</span>
</template>
</el-table-column>
<el-table-column label="退款金额" align="center" prop="returnmoney" width="100">
<template slot-scope="scope">
<span class="refund-amount">
{{ parseFloat(scope.row.returnmoney || 0).toFixed(2) }}
</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="80" fixed="right">
<template slot-scope="scope">
<el-button
@ -1806,7 +1807,7 @@
size="mini"
type="warning"
@click="handleRefund(scope.row)"
:disabled="scope.row.allmoney <= (scope.row.returnmoney || 0)"
:disabled="parseFloat(scope.row.allmoney || 0) <= parseFloat(scope.row.returnmoney || 0)"
>
退款
</el-button>
@ -1839,6 +1840,14 @@
</div>
</el-dialog>
<!-- 统一退款对话框 -->
<UnifiedRefundDialog
:visible.sync="unifiedRefundDialogVisible"
:orderId="currentRefundOrderId"
:paymentData="currentRefundPaymentData"
@success="handleUnifiedRefundSuccess"
/>
<!-- 退款弹窗 -->
<el-dialog
title="退款申请"
@ -2076,6 +2085,7 @@ import {
startService,
projectQuote
} from "@/api/system/Order"
import { getRefundHistory } from "@/api/system/OrderLog"
import CallRecord from './components/CallRecord'
import AudioRecord from './components/AudioRecord'
import ReceiveRecord from './components/ReceiveRecord'
@ -2083,6 +2093,7 @@ import NotifyRecord from './components/NotifyRecord'
import CommentRecord from './components/CommentRecord'
import EditInfo from './components/EditInfo'
import Pagination from '@/components/Pagination'
import UnifiedRefundDialog from '../GoodsOrder/UnifiedRefundDialog'
export default {
name: "Order",
@ -2094,7 +2105,8 @@ export default {
NotifyRecord,
CommentRecord,
EditInfo,
Pagination
Pagination,
UnifiedRefundDialog
},
data() {
return {
@ -2452,6 +2464,7 @@ export default {
paymentDetailsLoading: false, //
currentPaymentOrder: {}, //
paymentDetailsList: [], //
refundHistoryList: [], // 退
// 退
refundDialogVisible: false, // 退
@ -2466,6 +2479,11 @@ export default {
refundReason: '',
orderid: null // ID
},
// 退
unifiedRefundDialogVisible: false, // 退
currentRefundOrderId: '', // 退ID
currentRefundPaymentData: {}, // 退
refundRules: {
refundAmount: [
{ required: true, message: '请输入退款金额', trigger: 'blur' },
@ -2703,13 +2721,13 @@ export default {
loadReceiveRecords(orderId) {
console.log('开始加载接单记录,订单号:', orderId)
console.log('当前订单处理表单:', this.orderProcessForm)
//
if (!orderId) {
console.error('订单号为空,无法加载接单记录')
return
}
request.get(`/system/Order/receive-records/${orderId}`).then(response => {
console.log('接单记录API响应:', response)
console.log('响应状态码:', response.status)
@ -2834,12 +2852,12 @@ export default {
console.log('当前接单记录数组:', this.orderProcessForm.receiveRecords)
console.log('数组长度:', this.orderProcessForm.receiveRecords.length)
console.log('数组类型:', Array.isArray(this.orderProcessForm.receiveRecords))
if (this.orderProcessForm.receiveRecords.length > 0) {
console.log('第一条记录详情:', this.orderProcessForm.receiveRecords[0])
console.log('记录字段列表:', Object.keys(this.orderProcessForm.receiveRecords[0]))
}
//
const testData = [
{
@ -2855,7 +2873,7 @@ export default {
createdAt: new Date().toISOString()
}
]
console.log('设置测试数据:', testData)
this.orderProcessForm.receiveRecords = testData
},
@ -2866,10 +2884,10 @@ export default {
console.error('订单号为空无法测试API')
return
}
try {
console.log('开始调用API:', `/system/Order/receive-records/${orderId}`)
const response = await request.get(`/system/Order/receive-records/${orderId}`)
console.log('API响应成功:', response)
console.log('响应状态:', response.status)
@ -3057,7 +3075,7 @@ export default {
//
const status = this.orderProcessForm.status
const jsonStatus = this.orderProcessForm.jsonStatus
//
const updateData = {
id: this.orderProcessForm.id,
@ -3135,7 +3153,7 @@ export default {
/** 处理订单状态变化 */
handleStatusChange(status) {
const now = new Date()
switch (status) {
case 2: //
if (!this.orderProcessForm.workerId) {
@ -3175,7 +3193,7 @@ export default {
/** 处理服务进度变化 */
handleJsonStatusChange(jsonStatus) {
const now = new Date()
switch (jsonStatus) {
case 8: //
this.orderProcessForm.pauseTime = now
@ -4293,19 +4311,97 @@ export default {
},
//
getPaymentDetailsData(orderId) {
async getPaymentDetailsData(orderId) {
this.paymentDetailsLoading = true;
getPaymentDetails(orderId).then(response => {
this.paymentDetailsList = response.data || [];
try {
//
const paymentResponse = await getPaymentDetails(orderId);
this.paymentDetailsList = paymentResponse.data || [];
//
console.log('支付明细数据结构:', this.paymentDetailsList);
if (this.paymentDetailsList.length > 0) {
console.log('第一行支付明细数据:', this.paymentDetailsList[0]);
console.log('第一行数据的所有字段:', Object.keys(this.paymentDetailsList[0]));
}
// 退
const refundResponse = await getRefundHistory(orderId);
this.refundHistoryList = refundResponse.data || [];
// 退
console.log('退款历史数据结构:', this.refundHistoryList);
if (this.refundHistoryList.length > 0) {
console.log('第一条退款记录:', this.refundHistoryList[0]);
console.log('退款记录的所有字段:', Object.keys(this.refundHistoryList[0]));
}
// 退退
this.updateRefundAmounts();
// 退returnmoney
// if (!this.refundHistoryList || this.refundHistoryList.length === 0) {
// this.paymentDetailsList.forEach(item => {
// if (item.returnmoney === undefined || item.returnmoney === null) {
// this.$set(item, 'returnmoney', '0.00');
// }
// });
// }
this.paymentDetailsLoading = false;
}).catch(error => {
} catch (error) {
console.error('获取支付明细失败:', error);
this.$modal.msgError('获取支付明细失败');
this.paymentDetailsList = [];
this.refundHistoryList = [];
this.paymentDetailsLoading = false;
}
},
// 退退
updateRefundAmounts() {
if (!this.paymentDetailsList || !this.refundHistoryList) return;
console.log('开始更新退款金额,支付明细数量:', this.paymentDetailsList.length, '退款历史数量:', this.refundHistoryList.length);
// 退退
this.paymentDetailsList.forEach((item, index) => {
// 退
let totalRefundAmount = 0;
console.log(`处理第${index + 1}行支付记录:`, item);
// 退
this.refundHistoryList.forEach(refund => {
console.log('检查退款记录:', refund);
// ID
if (refund.orderid === item.orderid ||
refund.orderid === item.id ||
refund.orderid === item.paytime ||
(refund.amount && Math.abs(parseFloat(refund.amount) - parseFloat(item.allmoney)) < 0.01)) {
console.log('找到匹配的退款记录,金额:', refund.amount);
totalRefundAmount += parseFloat(refund.amount || 0);
}
});
console.log(`${index + 1}行总退款金额:`, totalRefundAmount);
// 退
// this.$set(item, 'returnmoney', totalRefundAmount.toFixed(2));
});
},
// 退
getTotalRefundedAmount() {
//
const total = this.paymentDetailsList.reduce((sum, item) => {
return sum + (parseFloat(item.returnmoney || 0));
}, 0);
return total;
},
//
getPayTypeTag(paytype) {
const typeMap = {
@ -4406,23 +4502,48 @@ export default {
// 退
handleRefund(row) {
this.refundForm = {
id: row.id,
paytime: row.paytime,
status: row.status,
//
console.log('退款行数据:', row);
console.log('退款行数据的所有字段:', Object.keys(row));
console.log('orderid字段值:', row.orderid);
console.log('orderId字段值:', row.orderId);
// 退
// 使orderid使
this.currentRefundOrderId = row.orderid || row.id || row.paytime || this.currentPaymentOrder.orderId;
this.currentRefundPaymentData = {
wxmoney: row.wxmoney || 0,
yemoney: row.yemoney || 0,
shopmoney: row.shopmoney || 0,
servicemoney: row.servicemoney || 0,
membermoney: row.membermoney || 0,
couponmoney: row.couponmoney || 0,
allmoney: row.allmoney || 0,
returnmoney: row.returnmoney || 0,
refundAmount: null,
refundReason: '',
orderid: this.currentPaymentOrder.orderId // ID
returnmoney: row.returnmoney || 0
};
this.refundDialogVisible = true;
this.$nextTick(() => {
this.$refs.refundForm.clearValidate();
});
console.log('设置的退款订单ID:', this.currentRefundOrderId);
console.log('设置的退款支付数据:', this.currentRefundPaymentData);
// 退
this.unifiedRefundDialogVisible = true;
},
// 退
// 退
handleUnifiedRefundSuccess() {
// 退
this.unifiedRefundDialogVisible = false;
// 退
if (this.currentPaymentOrder && this.currentPaymentOrder.orderId) {
this.getPaymentDetailsData(this.currentPaymentOrder.orderId);
}
//
this.$modal.msgSuccess('退款成功');
},
// 退使
submitRefund() {
this.$refs.refundForm.validate(valid => {
if (valid) {
@ -4524,7 +4645,7 @@ export default {
selectWorker(worker) {
this.dispatchForm.workerId = worker.id;
this.dispatchForm.workerName = worker.name;
//
this.processDispatch(worker);
},
@ -4767,7 +4888,7 @@ export default {
workerId: null,
workerName: ''
};
this.dispatchDialogVisible = true;
//
this.getWorkerList();
@ -4992,9 +5113,16 @@ export default {
// 退退
totalRefundedAmount() {
return this.paymentDetailsList.reduce((total, item) => {
return total + (parseFloat(item.returnmoney) || 0);
const total = this.paymentDetailsList.reduce((total, item) => {
// 使退
console.log(`计算汇总 - 行退款金额: ${item}, 累计: ${item}`);
const refundAmount = parseFloat(item.returnmoney) || 0;
console.log(`计算汇总 - 行退款金额: ${refundAmount}, 累计: ${total + refundAmount}`);
return total + refundAmount;
}, 0);
console.log(`已退金额汇总计算完成: ${total}`);
return total;
},
// -
@ -5625,15 +5753,15 @@ export default {
.order-process-dialog {
.el-card {
margin-bottom: 20px;
.el-card__header {
background-color: #f5f7fa;
border-bottom: 1px solid #e4e7ed;
.clearfix {
display: flex;
align-items: center;
span {
font-weight: 600;
color: #303133;
@ -5641,35 +5769,35 @@ export default {
}
}
}
.el-card__body {
padding: 20px;
}
}
.el-form-item {
margin-bottom: 18px;
}
.el-select {
width: 100%;
}
.el-date-picker {
width: 100%;
}
.el-textarea {
.el-textarea__inner {
resize: vertical;
}
}
.dialog-footer {
text-align: center;
padding-top: 20px;
border-top: 1px solid #e4e7ed;
.el-button {
margin: 0 10px;
min-width: 100px;
@ -5686,7 +5814,7 @@ export default {
border-radius: 4px;
color: #409eff;
font-size: 14px;
.el-icon-info {
margin-right: 8px;
}
@ -5997,7 +6125,7 @@ export default {
max-height: 80vh;
overflow-y: auto;
}
.el-dialog__footer {
padding: 15px 30px;
border-top: 1px solid #e4e7ed;
@ -6014,7 +6142,7 @@ export default {
/* 信息行样式 */
.info-row {
margin-bottom: 20px;
&:last-child {
margin-bottom: 0;
}
@ -6043,19 +6171,19 @@ export default {
border: 1px solid #e4e7ed;
border-radius: 6px;
margin-bottom: 10px;
&:last-child {
margin-bottom: 0;
}
}
.file-image {
width: 60px;
height: 60px;
border-radius: 4px;
border: 1px solid #e4e7ed;
}
.file-icon {
width: 60px;
height: 60px;
@ -6068,17 +6196,17 @@ export default {
border: 1px solid #e4e7ed;
color: #909399;
}
.file-info {
margin-top: 8px;
.file-name {
display: block;
font-weight: 600;
color: #303133;
margin-bottom: 4px;
}
.file-url {
display: block;
font-size: 12px;
@ -6108,7 +6236,7 @@ export default {
width: 95% !important;
}
}
.info-row {
.el-col {
margin-bottom: 15px;
@ -6121,20 +6249,20 @@ export default {
.el-dialog__body {
padding: 15px 20px;
}
.el-dialog__footer {
padding: 10px 20px;
}
}
.card-title {
font-size: 14px;
i {
font-size: 16px;
}
}
.order-info-text {
padding: 8px 12px;
font-size: 13px;
@ -6161,11 +6289,11 @@ export default {
display: flex;
flex-wrap: wrap;
gap: 12px;
.simple-file-item {
flex-shrink: 0;
}
.simple-file-image {
width: 60px;
height: 60px;
@ -6173,12 +6301,12 @@ export default {
border: 2px solid #e4e7ed;
cursor: pointer;
transition: border-color 0.2s ease;
&:hover {
border-color: #409eff;
}
}
.simple-file-icon {
width: 60px;
height: 60px;
@ -6299,7 +6427,7 @@ export default {
flex-direction: column;
gap: 6px;
}
.timeline-actions-multiple .el-button {
width: 100%;
margin-right: 0 !important;
@ -6352,11 +6480,11 @@ export default {
.timeline-quote {
padding: 8px;
}
.quote-content {
max-height: 150px;
}
.quote-content pre {
font-size: 11px;
}

View File

@ -49,39 +49,39 @@
</el-form-item>
</el-form>
<!-- <el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:transfer:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:transfer:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:transfer:remove']"
>删除</el-button>
</el-col>
<el-row :gutter="10" class="mb8">
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="primary"-->
<!-- plain-->
<!-- icon="el-icon-plus"-->
<!-- size="mini"-->
<!-- @click="handleAdd"-->
<!-- v-hasPermi="['system:transfer:add']"-->
<!-- >新增</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="success"-->
<!-- plain-->
<!-- icon="el-icon-edit"-->
<!-- size="mini"-->
<!-- :disabled="single"-->
<!-- @click="handleUpdate"-->
<!-- v-hasPermi="['system:transfer:edit']"-->
<!-- >修改</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="danger"-->
<!-- plain-->
<!-- icon="el-icon-delete"-->
<!-- size="mini"-->
<!-- :disabled="multiple"-->
<!-- @click="handleDelete"-->
<!-- v-hasPermi="['system:transfer:remove']"-->
<!-- >删除</el-button>-->
<!-- </el-col>-->
<el-col :span="1.5">
<el-button
type="warning"
@ -93,7 +93,25 @@
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> -->
</el-row>
<!-- 统计汇总 -->
<el-card shadow="never" style="margin-bottom: 10px;">
<div style="display:flex;gap:24px;flex-wrap:wrap;">
<div>
<span>总计申请</span>
<b style="color:#303133;">¥ {{ formatMoney(summary.totalApply) }}</b>
</div>
<div>
<span>提现到账</span>
<b style="color:#67C23A;">¥ {{ formatMoney(summary.totalPaid) }}</b>
</div>
<div>
<span>处理中</span>
<b style="color:#E6A23C;">¥ {{ formatMoney(summary.totalProcessing) }}</b>
</div>
</div>
</el-card>
<el-table v-loading="loading" :data="transferList" @selection-change="handleSelectionChange" border>
<el-table-column type="selection" width="55" align="center" />
@ -118,9 +136,9 @@
<span>{{ parseTime(scope.row.payTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="发起时间" align="center" prop="payTime" width="180">
<el-table-column label="发起时间" align="center" prop="createdAt" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.time, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.createdAt, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@ -221,7 +239,7 @@
</template>
<script>
import { listTransfer, getTransfer, delTransfer, addTransfer, updateTransfer} from "@/api/system/transfer"
import { listTransfer, getTransfer, delTransfer, addTransfer, updateTransfer, getTransferSummary} from "@/api/system/transfer"
export default {
name: "Transfer",
dicts: ['money_status'],
@ -241,6 +259,9 @@ export default {
total: 0,
//
summary: { totalApply: 0, totalPaid: 0, totalProcessing: 0 },
// wechat_transfer
transferList: [],
//
@ -302,6 +323,14 @@ export default {
this.transferList = response.rows
this.total = response.total
this.loading = false
//
this.loadSummary()
})
},
//
loadSummary() {
getTransferSummary(this.queryParams).then(res => {
this.summary = res.data || { totalApply: 0, totalPaid: 0, totalProcessing: 0 }
})
},
//