From b22df417e0bc423c788b013feaad686531d69eed Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期三, 08 一月 2025 09:51:37 +0800
Subject: [PATCH] 修改bug
---
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 74 ++++++++++++++++++++++++++++++++++++-
1 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
index 3a68b76..35d4d3e 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -4,6 +4,7 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.feignClient.BalanceChangeRecordClient;
@@ -304,11 +305,42 @@
AppUser appUser = appUserClient.getAppUserById(appUserId);
orderPageListVo.setUserName(appUser.getName());
orderPageListVo.setPhone(appUser.getPhone());
+ RefundPass one = refundPassService.getOne(new LambdaQueryWrapper<RefundPass>().eq(RefundPass::getOrderId, orderPageListVo.getId()).eq(RefundPass::getDelFlag, 0).last(" order by create_time desc limit 0, 1"));
+ orderPageListVo.setRefundPassId(null != one ? one.getId().toString() : null);
}
return pageInfo.setRecords(list);
}
-
-
+
+
+ /**
+ * 小程序取消订单
+ * @param orderId
+ * @return
+ */
+ @Override
+ public R cancel(Long orderId) {
+ Order order = this.getById(orderId);
+ if(null == order){
+ return R.fail("取消失败");
+ }
+ Long userid = tokenService.getLoginUserApplet().getUserid();
+ if(!order.getAppUserId().equals(userid)){
+ return R.fail("取消失败");
+ }
+ if(!Arrays.asList(1, 2, 3).contains(order.getOrderStatus())){
+ return R.fail("订单取消失败");
+ }
+ if(LocalDateTime.now().isAfter(order.getAfterSaleTime())){
+ return R.fail("订单取消失败");
+ }
+ order.setOrderStatus(5);
+ R r = refundPayMoney(order);
+ if(200 == r.getCode()){
+ this.updateById(order);
+ }
+ return r;
+ }
+
/**
* 确认发货操作
* @param orderId
@@ -345,6 +377,9 @@
Order order = this.getById(orderId);
if(Arrays.asList(5, 6, 7).contains(order.getOrderStatus())){
return R.fail("无效的操作");
+ }
+ if(LocalDateTime.now().isAfter(order.getAfterSaleTime())){
+ return R.fail("订单取消失败");
}
order.setOrderStatus(5);
R r = refundPayMoney(order);
@@ -667,6 +702,18 @@
return R.fail("无效的操作");
}
order.setOrderStatus(4);
+ R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(5);
+ if (R.isError(baseSettingR)) {
+ return R.fail("售后设置获取失败");
+ }
+ BaseSetting baseSetting = baseSettingR.getData();
+ if (baseSetting == null) {
+ return R.fail("售后设置获取失败");
+ }
+ String content = baseSetting.getContent();
+ JSONObject jsonObject = JSONObject.parseObject(content);
+ Long days = jsonObject.getLong("days");
+ order.setAfterSaleTime(LocalDateTime.now().plusDays(days));
this.updateById(order);
return R.ok();
}
@@ -730,4 +777,27 @@
orderInfo.setGoodsJson(JSON.toJSONString(goodsJson));
return orderInfo;
}
+
+
+ /**
+ * 获取商品销售数量
+ * @param goodsId
+ * @return
+ */
+ @Override
+ public Integer getGoodsSaleNum(Integer goodsId, Integer type) {
+ return this.baseMapper.getGoodsSaleNum(goodsId, type);
+ }
+
+
+ /**
+ * 获取店铺订单数量
+ * @param shopId
+ * @param type
+ * @return
+ */
+ @Override
+ public Integer getShopSaleNum(Integer shopId, Integer type) {
+ return this.baseMapper.getShopSaleNum(shopId, type);
+ }
}
--
Gitblit v1.7.1