From 74b2581c8a9be309ca6454da3ff2c56501368771 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 09 一月 2025 09:30:21 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java | 8
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserCancellationLogMapper.xml | 8
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalancePayment.java | 59 +
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/TaskUtil.java | 13
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java | 2
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java | 64
ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysDeptMapper.xml | 3
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java | 4
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java | 10
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 331 +++++
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/VipSettingServiceImpl.java | 22
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java | 4
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java | 2
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserAddressController.java | 6
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/GetSysUserList.java | 12
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/CouponInfoClientFallbackFactory.java | 5
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/RefundPass.java | 4
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java | 7
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/OrderClient.java | 49
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/UserShopService.java | 11
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java | 36
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/payment/PaymentUtil.java | 7
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java | 2
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java | 14
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipSettingServiceImpl.java | 73 -
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/OrderGood.java | 3
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/VipSettingService.java | 1
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/TransferPoint.java | 19
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml | 8
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserClickLogMapper.xml | 1
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java | 270 ++--
ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java | 2
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java | 14
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserShopServiceImpl.java | 8
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/IndexConfigSetDto.java | 2
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/ShoppingCartService.java | 2
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/Order.java | 12
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java | 27
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml | 32
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/BalancePaymentService.java | 11
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java | 28
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java | 30
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsService.java | 2
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java | 2
ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysUserClient.java | 2
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java | 11
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java | 137 +
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java | 6
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java | 2
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java | 3
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml | 56
ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml | 45
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java | 14
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/payment/PaymentUtil.java | 9
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java | 121 +
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java | 72 +
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java | 4
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/CouponInfoClient.java | 9
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java | 61
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java | 13
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java | 14
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/BalancePaymentMapper.java | 11
ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/UserShop.java | 15
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java | 25
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ShoppingCartPayment.java | 2
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java | 59
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java | 2
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/GoodsVO.java | 5
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml | 20
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OrderActivityInfoClientFallbackFactory.java | 4
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java | 19
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ConfirmOrder.java | 4
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/payment/PaymentUtil.java | 7
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderRefundPassList.java | 2
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AgentApplicationMapper.xml | 1
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/WithdrawalRequestsMapper.xml | 2
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserPointClient.java | 10
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Shop.java | 3
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianController.java | 32
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/VipSettingService.java | 1
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/ShoppingCart.java | 4
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java | 10
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java | 5
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserPointFallbackFactory.java | 7
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java | 427 +++++--
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopScore.java | 2
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 119 +
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/RefundPassMapper.xml | 3
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/OrderClientFallbackFactory.java | 36
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml | 42
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/TaskUtil.java | 21
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java | 34
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java | 3
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/SeckillActivityInfoClient.java | 11
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java | 124 +
ruoyi-api/ruoyi-api-order/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports | 3
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java | 9
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java | 16
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AgentApplication.java | 2
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/OrderVO.java | 3
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SeckillActivityInfoClientFallbackFactory.java | 6
ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java | 3
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OrderActivityInfoClient.java | 4
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsMapper.java | 3
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/SeckillActivityVO.java | 3
/dev/null | 29
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalancePaymentServiceImpl.java | 15
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java | 75
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java | 47
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/SeckillActivityInfoService.java | 2
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java | 2
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml | 5
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml | 26
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java | 41
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java | 251 +++
115 files changed, 2,527 insertions(+), 899 deletions(-)
diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserPointFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserPointFallbackFactory.java
index 96ac46e..e282ec1 100644
--- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserPointFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserPointFallbackFactory.java
@@ -5,6 +5,8 @@
import com.ruoyi.common.core.domain.R;
import org.springframework.cloud.openfeign.FallbackFactory;
+import java.util.List;
+
/**
* @author zhibing.pu
* @Date 2024/12/2 15:04
@@ -17,6 +19,11 @@
public R saveUserPoint(UserPoint userPoint) {
return R.fail("保存积分流水记录失败:" + cause.getMessage());
}
+
+ @Override
+ public R<List<UserPoint>> getUserPointList(UserPoint userPoint) {
+ return R.fail("获取积分变动明细失败:" + cause.getMessage());
+ }
};
}
}
diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserPointClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserPointClient.java
index c7af699..478b03f 100644
--- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserPointClient.java
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserPointClient.java
@@ -8,6 +8,8 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
+import java.util.List;
+
/**
* @author zhibing.pu
* @Date 2024/12/2 15:04
@@ -23,4 +25,12 @@
@PostMapping("/user-point/saveUserPoint")
R saveUserPoint(@RequestBody UserPoint userPoint);
+
+ /**
+ * 获取积分变动明细
+ * @param userPoint
+ * @return
+ */
+ @PostMapping("/user-point/getUserPointList")
+ R<List<UserPoint>> getUserPointList(@RequestBody UserPoint userPoint);
}
diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AgentApplication.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AgentApplication.java
index 77c293d..2fafda8 100644
--- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AgentApplication.java
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AgentApplication.java
@@ -94,6 +94,8 @@
@TableField(exist = false)
private String idStr;
+ @TableField(exist = false)
+ private Integer vipId;
}
diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalancePayment.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalancePayment.java
new file mode 100644
index 0000000..d738f89
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalancePayment.java
@@ -0,0 +1,59 @@
+package com.ruoyi.account.api.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * @author zhibing.pu
+ * @date 2025/1/8 17:25
+ */
+@Data
+@TableName("t_balance_payment")
+public class BalancePayment {
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.NONE)
+ private Long id;
+ /**
+ * 用户id
+ */
+ @TableField("app_user_id")
+ private Long appUserId;
+ /**
+ * 支付金额
+ */
+ @TableField("money")
+ private BigDecimal money;
+ /**
+ * 微信支付流水
+ */
+ @TableField("serial_number")
+ private String serialNumber;
+ /**
+ * 微信支付状态(1=待支付,2=已支付)
+ */
+ @TableField("status")
+ private Integer status;
+ /**
+ * 完成支付时间
+ */
+ @TableField("payment_time")
+ private LocalDateTime paymentTime;
+ /**
+ * 余额变更记录id
+ */
+ @TableField("balance_change_record_id")
+ private Long balanceChangeRecordId;
+ /**
+ * 添加时间
+ */
+ @TableField("create_time")
+ private LocalDateTime createTime;
+}
diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java
index 91ef39a..c0a2a59 100644
--- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java
@@ -1,6 +1,7 @@
package com.ruoyi.account.api.model;
import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -38,6 +39,7 @@
@ApiModelProperty(value = "添加时间")
@TableField("create_time")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@ApiModelProperty(value = "用户id")
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/OrderClientFallbackFactory.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/OrderClientFallbackFactory.java
new file mode 100644
index 0000000..c28dc25
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/OrderClientFallbackFactory.java
@@ -0,0 +1,36 @@
+package com.ruoyi.order.factory;
+
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.order.feignClient.OrderClient;
+import org.springframework.cloud.openfeign.FallbackFactory;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author zhibing.pu
+ * @date 2025/1/7 14:38
+ */
+public class OrderClientFallbackFactory implements FallbackFactory<OrderClient> {
+ @Override
+ public OrderClient create(Throwable cause) {
+ return new OrderClient(){
+
+ @Override
+ public R<Integer> getGoodsSaleNum(Integer goodsId, Integer type) {
+ return R.fail("获取商品销售数量失败:" + cause.getMessage());
+ }
+
+
+ @Override
+ public R<Integer> getShopSaleNum(Integer shopId, Integer type) {
+ return R.fail("获取门店销售订单数量失败:" + cause.getMessage());
+ }
+
+ @Override
+ public R<Set<Long>> getAppUserByShoppingShop(Integer shopId) {
+ return R.fail("获取所有在指定门店消费的用户id失败:" + cause);
+ }
+ };
+ }
+}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderFallbackFactory.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderFallbackFactory.java
deleted file mode 100644
index d62e606..0000000
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderFallbackFactory.java
+++ /dev/null
@@ -1,19 +0,0 @@
-//package factory;
-//
-//import feignClient.RemoteOrderClient;
-//import org.springframework.cloud.openfeign.FallbackFactory;
-//import org.springframework.stereotype.Component;
-//
-///**
-// * 订单服务降级处理
-// * @author luofl
-// */
-//@Component
-//public class RemoteOrderFallbackFactory implements FallbackFactory<RemoteOrderClient> {
-//
-// @Override
-// public RemoteOrderClient create(Throwable cause) {
-// return new RemoteOrderClient() {
-// };
-// }
-//}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/OrderClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/OrderClient.java
new file mode 100644
index 0000000..a70a745
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/OrderClient.java
@@ -0,0 +1,49 @@
+package com.ruoyi.order.feignClient;
+
+import com.ruoyi.account.api.model.AppUser;
+import com.ruoyi.common.core.constant.ServiceNameConstants;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.order.factory.OrderClientFallbackFactory;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author zhibing.pu
+ * @date 2025/1/7 14:37
+ */
+@FeignClient(contextId = "OrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = OrderClientFallbackFactory.class)
+public interface OrderClient {
+
+
+ /**
+ * 获取商品销售数量
+ * @param goodsId
+ * @param type 购买类型(1=普通商品,2=秒杀商品)
+ * @return
+ */
+ @PostMapping("/order/getGoodsSaleNum")
+ R<Integer> getGoodsSaleNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("type") Integer type);
+
+
+ /**
+ * 获取门店销售订单数量
+ * @param shopId 门店id
+ * @param type 1:服务订单,2:单品订单
+ * @return
+ */
+ @PostMapping("/order/getShopSaleNum")
+ R<Integer> getShopSaleNum(@RequestParam("shopId") Integer shopId, @RequestParam("type") Integer type);
+
+
+ /**
+ * 获取所有在指定门店消费的用户id
+ * @param shopId
+ * @return
+ */
+ @PostMapping("/order/getAppUserByShoppingShop")
+ R<Set<Long>> getAppUserByShoppingShop(@RequestParam("shopId") Integer shopId);
+}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderClient.java
deleted file mode 100644
index 1bfdb19..0000000
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderClient.java
+++ /dev/null
@@ -1,24 +0,0 @@
-//package feignClient;
-//
-//import com.ruoyi.common.core.constant.ServiceNameConstants;
-//import com.ruoyi.common.core.domain.R;
-//import factory.RemoteOrderFallbackFactory;
-//import model.Order;
-//import model.OrderGood;
-//import org.springframework.cloud.openfeign.FeignClient;
-//import org.springframework.web.bind.annotation.GetMapping;
-//import org.springframework.web.bind.annotation.PostMapping;
-//import org.springframework.web.bind.annotation.RequestBody;
-//import org.springframework.web.bind.annotation.RequestParam;
-//
-//import java.util.List;
-//
-///**
-// * 订单远程调用接口
-// * @author luofl
-// */
-//@FeignClient(contextId = "RemoteOrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = RemoteOrderFallbackFactory.class)
-//public interface RemoteOrderClient {
-//
-//
-//}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/Order.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/Order.java
index 7b9b5a2..5537061 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/Order.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/Order.java
@@ -170,6 +170,18 @@
@ApiModelProperty(value = "预计提货时间")
@TableField("expected_delivery_time")
private String expectedDeliveryTime;
+
+ @ApiModelProperty("退款状态(1=退款中,2=已退款)")
+ @TableField("refund_status")
+ private Integer refundStatus;
+
+ @ApiModelProperty("退款流水号")
+ @TableField("refund_code")
+ private String refundCode;
+
+ @ApiModelProperty("退款时间")
+ @TableField("refund_time")
+ private LocalDateTime refundTime;
}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/OrderGood.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/OrderGood.java
index 0eb2ab8..7443f90 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/OrderGood.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/OrderGood.java
@@ -108,6 +108,9 @@
@ApiModelProperty(value = "绑定门店上级门店可获得返佣积分")
@TableField("bound_shop_superiors_points")
private Integer boundShopSuperiorsPoints;
+ @ApiModelProperty("购买类型(1=普通商品,2=秒杀商品)")
+ @TableField("type")
+ private Integer type;
}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/RefundPass.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/RefundPass.java
index 16ea67a..f51d012 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/RefundPass.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/RefundPass.java
@@ -59,6 +59,10 @@
@TableField("pass_status")
private Integer passStatus;
+ @ApiModelProperty(value = "审核时间")
+ @TableField("auth_time")
+ private LocalDateTime authTime;
+
@ApiModelProperty(value = "后台审核备注")
@TableField("pass_remark")
private String passRemark;
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/ShoppingCart.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/ShoppingCart.java
index 11b064f..1a7e25e 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/ShoppingCart.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/ShoppingCart.java
@@ -27,4 +27,8 @@
private Integer goodsId;
@ApiModelProperty("数量")
private Integer number;
+ @ApiModelProperty("购买类型(1=普通商品,2=秒杀商品)")
+ private Integer type;
+ @ApiModelProperty("状态(0=临时数据,1=购物车数据)")
+ private Integer status;
}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ConfirmOrder.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ConfirmOrder.java
index 4983fe5..ef0ee12 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ConfirmOrder.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ConfirmOrder.java
@@ -13,7 +13,7 @@
public class ConfirmOrder {
@ApiModelProperty(value = "购买方式(1=购物车,2=商品详情)", required = true)
private Integer position;
- @ApiModelProperty(value = "购物车数据id,数量 JSON[{id:1212,num:2}]", required = true)
+ @ApiModelProperty(value = "购物车数据id,数量 JSON[{id:1212,num:2,type:1}]", required = true, notes = "type值取值范围(1=普通商品,2=秒杀商品)")
private String goodsJson;
@ApiModelProperty(value = "支付方式(1=现金,2=积分)", required = true)
private Integer paymentType;
@@ -21,4 +21,6 @@
private Integer shopId;
@ApiModelProperty(value = "商品类型(1=服务商品,2=单品商品)", required = true)
private Integer type;
+ @ApiModelProperty("优惠券id")
+ private Long couponId;
}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java
index 922e250..bbb1c05 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java
@@ -15,6 +15,8 @@
public class MyShoppingCartVo {
@ApiModelProperty("数据id")
private String id;
+ @ApiModelProperty("购买类型(1=普通商品,2=秒杀商品)")
+ private Integer type;
@ApiModelProperty("商品id")
private Integer goodsId;
@ApiModelProperty("封面图")
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/OrderVO.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/OrderVO.java
index ed34770..71bacf4 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/OrderVO.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/OrderVO.java
@@ -31,5 +31,8 @@
@ApiModelProperty(value = "实际支付价格")
private BigDecimal paymentAmount;
+ @ApiModelProperty(value = "快递费")
+ private BigDecimal expressAmount;
+
}
diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ShoppingCartPayment.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ShoppingCartPayment.java
index 056104b..772b6ad 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ShoppingCartPayment.java
+++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ShoppingCartPayment.java
@@ -11,7 +11,7 @@
@Data
@ApiModel
public class ShoppingCartPayment {
- @ApiModelProperty(value = "购物车数据id,数量 JSON[{id:1212,num:2}]", required = true)
+ @ApiModelProperty(value = "购物车数据id,数量 JSON[{id:1212,num:2,type:1}]", required = true)
private String goodsJson;
@ApiModelProperty(value = "支付方式(1=微信,2=账户余额,3=积分)", required = true)
private Integer paymentType;
diff --git a/ruoyi-api/ruoyi-api-order/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-api/ruoyi-api-order/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index fa4f530..1e5d10a 100644
--- a/ruoyi-api/ruoyi-api-order/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ b/ruoyi-api/ruoyi-api-order/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -1 +1,2 @@
-com.ruoyi.order.factory.RemoteOrderGoodsFallbackFactory
\ No newline at end of file
+com.ruoyi.order.factory.RemoteOrderGoodsFallbackFactory
+com.ruoyi.order.factory.OrderClientFallbackFactory
\ No newline at end of file
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java
index df0aada..f81f0e7 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java
@@ -149,6 +149,10 @@
@TableField(exist = false)
private Integer showStatus;
+ @TableField(exist = false)
+ private String payMethod;
+
+
public String getIdStr() {
return String.valueOf(id);
}
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Shop.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Shop.java
index e323fe5..8027bea 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Shop.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Shop.java
@@ -214,5 +214,6 @@
@TableField("district_code")
private String districtCode;
-
+ @TableField(exist = false)
+ private Double distance;
}
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopScore.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopScore.java
index 0a551f7..80d071a 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopScore.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopScore.java
@@ -23,7 +23,7 @@
@ApiModelProperty(value = "主键")
@TableId("id")
- private Integer id;
+ private Long id;
@ApiModelProperty(value = "用户id")
@TableField("app_user_id")
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/IndexConfigSetDto.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/IndexConfigSetDto.java
index 43238d6..1e9164d 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/IndexConfigSetDto.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/IndexConfigSetDto.java
@@ -18,7 +18,7 @@
@ApiModelProperty("跳转内容2")
private String content2;
@ApiModelProperty("跳转类型2 - 1无2外部链接3商品详情4秒杀商品详情5领卷中心")
- private String direct2;
+ private Integer direct2;
@ApiModelProperty("公司简介")
private String companyInfo;
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/CouponInfoClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/CouponInfoClientFallbackFactory.java
index b587851..fc091d0 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/CouponInfoClientFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/CouponInfoClientFallbackFactory.java
@@ -19,6 +19,11 @@
public R<List<CouponInfo>> getCouponInfoList(List<Integer> ids) {
return R.fail("根据id集合获取优惠券数据失败:" + cause.getMessage());
}
+
+ @Override
+ public R<List<CouponInfo>> getCouponInfoByPersonType(Integer personType) {
+ return R.fail("根据类型获取有效优惠券列表失败:" + cause.getMessage());
+ }
};
}
}
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OrderActivityInfoClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OrderActivityInfoClientFallbackFactory.java
index 99214e9..9a289e8 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OrderActivityInfoClientFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OrderActivityInfoClientFallbackFactory.java
@@ -6,13 +6,15 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
+import java.util.List;
+
@Slf4j
public class OrderActivityInfoClientFallbackFactory implements FallbackFactory<OrderActivityInfoClient> {
@Override
public OrderActivityInfoClient create(Throwable cause) {
return new OrderActivityInfoClient(){
@Override
- public R<OrderActivityInfo> getNowOrderActivityInfo(Integer vip) {
+ public R<List<OrderActivityInfo>> getNowOrderActivityInfo(Integer vip) {
return R.fail("获取当前生效的活动失败:" + cause.getMessage());
}
};
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SeckillActivityInfoClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SeckillActivityInfoClientFallbackFactory.java
index e54d7a6..09fa1fa 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SeckillActivityInfoClientFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SeckillActivityInfoClientFallbackFactory.java
@@ -2,6 +2,7 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.other.api.domain.GoodsSeckill;
+import com.ruoyi.other.api.domain.SeckillActivityInfo;
import com.ruoyi.other.api.feignClient.SeckillActivityInfoClient;
import com.ruoyi.other.api.vo.GetSeckillActivityInfo;
import lombok.extern.slf4j.Slf4j;
@@ -16,6 +17,11 @@
public R<GoodsSeckill> getSeckillActivityInfo(GetSeckillActivityInfo info) {
return R.fail("根据商品id和会员等级获取对应的秒杀活动失败:" + cause.getMessage());
}
+
+ @Override
+ public R<SeckillActivityInfo> getSeckillActivityInfoById(Integer id) {
+ return R.fail("根据id获取秒杀活动失败:" + cause.getMessage());
+ }
};
}
}
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java
index 45446cc..00ab5fb 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java
@@ -49,6 +49,11 @@
public void updateShop(Shop shop) {
R.fail("编辑门店失败:" + cause.getMessage());
}
+
+ @Override
+ public R<List<Shop>> getAllShop() {
+ return R.fail("获取所有门店失败:" + cause.getMessage());
+ }
};
}
}
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/CouponInfoClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/CouponInfoClient.java
index 1b447e5..6d36de0 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/CouponInfoClient.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/CouponInfoClient.java
@@ -25,4 +25,13 @@
*/
@PostMapping("/coupon-info/getCouponInfoList")
R<List<CouponInfo>> getCouponInfoList(@RequestParam("ids") List<Integer> ids);
+
+
+ /**
+ * 根据类型获取有效优惠券列表
+ * @param personType
+ * @return
+ */
+ @PostMapping("/coupon-info/getCouponInfoByPersonType")
+ R<List<CouponInfo>> getCouponInfoByPersonType(@RequestParam("personType") Integer personType);
}
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OrderActivityInfoClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OrderActivityInfoClient.java
index bc0817a..7ba374f 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OrderActivityInfoClient.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OrderActivityInfoClient.java
@@ -8,6 +8,8 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
+import java.util.List;
+
/**
* @author zhibing.pu
* @Date 2024/11/29 10:55
@@ -22,5 +24,5 @@
* @return
*/
@PostMapping("/order-activity-info/getNowOrderActivityInfo")
- R<OrderActivityInfo> getNowOrderActivityInfo(@RequestParam("vip") Integer vip);
+ R<List<OrderActivityInfo>> getNowOrderActivityInfo(@RequestParam("vip") Integer vip);
}
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/SeckillActivityInfoClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/SeckillActivityInfoClient.java
index d84674e..0b3ba2c 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/SeckillActivityInfoClient.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/SeckillActivityInfoClient.java
@@ -3,11 +3,13 @@
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.other.api.domain.GoodsSeckill;
+import com.ruoyi.other.api.domain.SeckillActivityInfo;
import com.ruoyi.other.api.factory.SeckillActivityInfoClientFallbackFactory;
import com.ruoyi.other.api.vo.GetSeckillActivityInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
/**
* @author zhibing.pu
@@ -24,4 +26,13 @@
*/
@PostMapping("/seckill-activity-info/getSeckillActivityInfo")
R<GoodsSeckill> getSeckillActivityInfo(@RequestBody GetSeckillActivityInfo info);
+
+
+ /**
+ * 根据id获取秒杀活动
+ * @param id
+ * @return
+ */
+ @PostMapping("/seckill-activity-info/getSeckillActivityInfoById")
+ R<SeckillActivityInfo> getSeckillActivityInfoById(@RequestParam("id") Integer id);
}
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java
index e86f791..b7841e6 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java
@@ -57,4 +57,12 @@
*/
@PostMapping("/shop/updateShop")
void updateShop(Shop shop);
+
+
+ /**
+ * 获取所有门店
+ * @return
+ */
+ @PostMapping("/shop/getAllShop")
+ R<List<Shop>> getAllShop();
}
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java
index 798c117..d1f6378 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java
@@ -113,7 +113,7 @@
private Long roleId;
/**
- * 角色类型 1=平台 2=公司 3=门店 4=修理厂
+ * 角色类型 1=平台 2=门店
*/
@ApiModelProperty(value = "角色类型 1=平台 2=门店")
@TableField("role_type")
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysUserClient.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysUserClient.java
index 7f566d9..5211136 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysUserClient.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysUserClient.java
@@ -104,7 +104,7 @@
* @param roleType
* @return
*/
- @PostMapping("/user/delShopUser")
+ @PostMapping("/user/user/delShopUser")
R delShopUser(@RequestParam("objectId") Integer objectId, @RequestParam("roleType") Integer roleType);
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/UserShop.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/UserShop.java
index 83ab4cc..0f5133c 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/UserShop.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/UserShop.java
@@ -4,7 +4,11 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.annotation.Excel;
import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.time.LocalDateTime;
/**
* @author zhibing.pu
@@ -38,4 +42,15 @@
*/
@TableField("role_id")
private Long roleId;
+
+ /** 部门ID */
+ @TableField("dept_id")
+ private Long deptId;
+
+ /** 用户昵称 */
+ @TableField("nick_name")
+ private String nickName;
+
+ @TableField("create_time")
+ private LocalDateTime createTime;
}
diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
index 3c1c904..3b82526 100644
--- a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
+++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
@@ -90,7 +90,8 @@
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "用户已停用,请联系管理员");
- throw new ServiceException("对不起,您的账号:" + username + " 已停用");
+// throw new ServiceException("对不起,您的账号:" + username + " 已停用");
+ throw new ServiceException("您的账号已被禁用,请联系平台");
}
passwordService.validate(user, password, request);
recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_SUCCESS_STATUS, "登录成功");
diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java
index 5cc6b28..da432b3 100644
--- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java
+++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java
@@ -118,7 +118,7 @@
public static void main(String[] args) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
- String encode = passwordEncoder.encode("49a15811ea47e8e9c6d8f3ef4d7bbc54");
+ String encode = passwordEncoder.encode("31dc4a464b71db3ddaea244410af4833");
System.err.println(encode);
}
}
diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/TechnicianSubscribe.java b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/TechnicianSubscribe.java
deleted file mode 100644
index 9f3daa2..0000000
--- a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/TechnicianSubscribe.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.ruoyi.job.task;
-
-import com.ruoyi.other.api.feignClient.TechnicianClient;
-import lombok.extern.log4j.Log4j2;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import javax.annotation.Resource;
-import java.util.Set;
-
-@Component("technicianSubscribe")
-@Log4j2
-public class TechnicianSubscribe {
- @Resource
- private TechnicianClient technicianClient;
- @Resource
- private RedisTemplate<String, String> redisTemplate;
-
- public void updateStatus() {
- long now = System.currentTimeMillis() / 1000; // 获取当前时间戳(秒)
- Set<String> subscribeIds = redisTemplate.opsForZSet().rangeByScore("delay_queue:subscribe", 0, now);
- if (!CollectionUtils.isEmpty(subscribeIds)) {
- subscribeIds.forEach(subscribeId -> {
- technicianClient.updateStatus(3, Long.valueOf(subscribeId));
- });
- }
- }
-}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java
index b841724..d138b72 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java
@@ -103,6 +103,8 @@
SysUser sysUser = sysUserService.getById(userid);
if(sysUser.getRoleType() == 2){
wrapper.eq(SysRole::getShopId, sysUser.getObjectId());
+ }else{
+ wrapper.isNull(SysRole::getShopId);
}
PageInfo<SysRole> page = roleService.page(pageInfo, wrapper.orderByDesc(SysRole::getCreateTime));
for (SysRole record : page.getRecords()) {
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java
index aa126fd..f801929 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java
@@ -33,6 +33,7 @@
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
+import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@@ -112,9 +113,6 @@
user.setUserName(user.getPhonenumber());
Long userid = tokenService.getLoginUser().getUserid();
SysUser sysUser1 = userService.getById(userid);
- if(sysUser1.getRoleType() == 2){
- user.setObjectId(sysUser1.getObjectId());
- }
if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){
user.setNickName(user.getPhonenumber());
}
@@ -124,22 +122,41 @@
if (StringUtils.isNotEmpty(user.getUserName()) && !userService.checkUserNameUnique(user)) {
return error("登录账号重复");
}
- user.setCreateBy(SecurityUtils.getUsername());
- user.setPassword(SecurityUtils.encryptPassword("a123456"));
- user.setRoleType(sysUser1.getRoleType());
- userService.insertUser(user);
- SysUserRole sysUserRole = new SysUserRole();
- sysUserRole.setRoleId(user.getRoleId());
- sysUserRole.setUserId(user.getUserId());
- userRoleService.insertSysUserRole(sysUserRole);
- //添加门店员工关系数据
- if(2 == user.getRoleType()){
+ //门店员工添加数据,需要判断账号是否存在,共用同一个账号
+ if(2 == sysUser1.getRoleType()){
+ SysUser one = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, user.getPhonenumber())
+ .eq(SysUser::getDelFlag, "0").eq(SysUser::getStatus, "0").eq(SysUser::getRoleType, 2));
+ if(null == one){
+ user.setCreateBy(SecurityUtils.getUsername());
+ user.setPassword(SecurityUtils.encryptPassword("a123456"));
+ user.setRoleType(sysUser1.getRoleType());
+ user.setObjectId(sysUser1.getObjectId());
+ userService.insertUser(user);
+ one = user;
+ SysUserRole sysUserRole = new SysUserRole();
+ sysUserRole.setRoleId(user.getRoleId());
+ sysUserRole.setUserId(user.getUserId());
+ userRoleService.insertSysUserRole(sysUserRole);
+ }
+ //添加门店员工关系数据
UserShop userShop = new UserShop();
- userShop.setUserId(user.getUserId());
- userShop.setShopId(user.getObjectId());
+ userShop.setUserId(one.getUserId());
+ userShop.setShopId(sysUser1.getObjectId());
userShop.setRoleType(2);
userShop.setRoleId(user.getRoleId());
+ userShop.setDeptId(user.getDeptId());
+ userShop.setNickName(user.getNickName());
+ userShop.setCreateTime(LocalDateTime.now());
userShopService.save(userShop);
+ }else{
+ user.setCreateBy(SecurityUtils.getUsername());
+ user.setPassword(SecurityUtils.encryptPassword("a123456"));
+ user.setRoleType(sysUser1.getRoleType());
+ userService.insertUser(user);
+ SysUserRole sysUserRole = new SysUserRole();
+ sysUserRole.setRoleId(user.getRoleId());
+ sysUserRole.setUserId(user.getUserId());
+ userRoleService.insertSysUserRole(sysUserRole);
}
return AjaxResult.success();
}
@@ -174,6 +191,17 @@
ajax.put("posts", postService.selectPostAll());
if (StringUtils.isNotNull(userId)) {
SysUser sysUser = userService.selectUserById(userId);
+ if(sysUser.getRoleType() == 2){
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser sysUser1 = userService.selectUserById(userid);
+ UserShop one = userShopService.getOne(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, sysUser.getUserId()).eq(UserShop::getShopId, sysUser1.getObjectId()));
+ sysUser.setDeptId(one.getDeptId());
+ sysUser.setNickName(one.getNickName());
+ SysDept sysDept = deptService.selectDeptById(one.getDeptId());
+ sysUser.setDept(sysDept);
+ sysUser.setRoleId(one.getRoleId());
+ }
+
ajax.put("data", sysUser);
ajax.put("postIds", postService.selectPostListByUserId(userId));
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
@@ -231,13 +259,14 @@
//添加门店员工关系数据
if(2 == user.getRoleType()){
- userShopService.remove(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId()).eq(UserShop::getShopId, user.getObjectId()));
- UserShop userShop = new UserShop();
- userShop.setUserId(user.getUserId());
- userShop.setShopId(user.getObjectId());
- userShop.setRoleType(2);
- userShop.setRoleId(user.getRoleId());
- userShopService.save(userShop);
+ UserShop one = userShopService.getOne(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId()).eq(UserShop::getShopId, user.getObjectId()));
+ one.setUserId(user.getUserId());
+ one.setShopId(user.getObjectId());
+ one.setRoleType(one.getRoleType());
+ one.setRoleId(user.getRoleId());
+ one.setDeptId(user.getDeptId());
+ one.setNickName(user.getNickName());
+ userShopService.updateById(one);
}
return success();
}
@@ -614,7 +643,7 @@
@ResponseBody
- @GetMapping("/switchShop")
+ @PutMapping("/switchShop/{shopId}")
@ApiOperation(value = "切换门店", tags = {"门店后台-首页"})
public R<Set<String>> switchShop(@PathVariable("shopId") Integer shopId){
Long userid = tokenService.getLoginUser().getUserid();
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/GetSysUserList.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/GetSysUserList.java
index 58f136f..0297d79 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/GetSysUserList.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/GetSysUserList.java
@@ -14,13 +14,11 @@
@Data
@ApiModel
public class GetSysUserList extends BasePage {
- @ApiModelProperty(value = "人员搜索")
+ @ApiModelProperty(value = "账号名称")
private String search;
- @ApiModelProperty(value = "充电站id")
- private Integer siteId;
- @ApiModelProperty(value = "角色id")
- private List<Integer> roleIds;
- @ApiModelProperty(value = "账户状态(0=正常,1=禁用)")
- private Integer status;
+ @ApiModelProperty(value = "联系电话")
+ private String phonenumber;
+ @ApiModelProperty(value = "所属部门")
+ private Integer deptId;
private Integer objectId;
}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java
index 7114d60..00152ac 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java
@@ -22,7 +22,7 @@
* @param userId 用户ID
* @return 菜单列表
*/
- public List<SysMenu> selectMenuList(Long userId);
+ List<SysMenu> selectMenuList(Long userId);
/**
* 根据用户查询系统菜单列表
@@ -31,7 +31,7 @@
* @param userId 用户ID
* @return 菜单列表
*/
- public List<SysMenu> selectMenuList(SysMenu menu, Long userId);
+ List<SysMenu> selectMenuList(SysMenu menu, Long userId);
/**
* 根据用户ID查询权限
@@ -39,7 +39,7 @@
* @param userId 用户ID
* @return 权限列表
*/
- public Set<String> selectMenuPermsByUserId(Long userId);
+ Set<String> selectMenuPermsByUserId(Long userId);
/**
* 根据角色ID查询权限
@@ -47,7 +47,7 @@
* @param roleId 角色ID
* @return 权限列表
*/
- public Set<String> selectMenuPermsByRoleId(Long roleId);
+ Set<String> selectMenuPermsByRoleId(Long roleId);
/**
* 根据用户ID查询菜单树信息
@@ -55,7 +55,7 @@
* @param userId 用户ID
* @return 菜单列表
*/
- public List<SysMenu> selectMenuTreeByUserId(Long userId);
+ List<SysMenu> selectMenuTreeByUserId(Long userId);
/**
* 根据角色ID查询菜单树信息
@@ -63,7 +63,7 @@
* @param roleId 角色ID
* @return 选中菜单列表
*/
- public List<Long> selectMenuListByRoleId(Long roleId);
+ List<Long> selectMenuListByRoleId(Long roleId);
/**
* 构建前端路由所需要的菜单
@@ -71,7 +71,7 @@
* @param menus 菜单列表
* @return 路由列表
*/
- public List<RouterVo> buildMenus(List<SysMenu> menus);
+ List<RouterVo> buildMenus(List<SysMenu> menus);
/**
* 构建前端所需要树结构
@@ -79,7 +79,7 @@
* @param menus 菜单列表
* @return 树结构列表
*/
- public List<SysMenu> buildMenuTree(List<SysMenu> menus);
+ List<SysMenu> buildMenuTree(List<SysMenu> menus);
/**
* 构建前端所需要下拉树结构
@@ -87,7 +87,7 @@
* @param menus 菜单列表
* @return 下拉树结构列表
*/
- public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus);
+ List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus);
/**
* 根据菜单ID查询信息
@@ -95,7 +95,7 @@
* @param menuId 菜单ID
* @return 菜单信息
*/
- public SysMenu selectMenuById(Long menuId);
+ SysMenu selectMenuById(Long menuId);
/**
* 是否存在菜单子节点
@@ -103,7 +103,7 @@
* @param menuId 菜单ID
* @return 结果 true 存在 false 不存在
*/
- public boolean hasChildByMenuId(Long menuId);
+ boolean hasChildByMenuId(Long menuId);
/**
* 查询菜单是否存在角色
@@ -111,7 +111,7 @@
* @param menuId 菜单ID
* @return 结果 true 存在 false 不存在
*/
- public boolean checkMenuExistRole(Long menuId);
+ boolean checkMenuExistRole(Long menuId);
/**
* 新增保存菜单信息
@@ -119,7 +119,7 @@
* @param menu 菜单信息
* @return 结果
*/
- public int insertMenu(SysMenu menu);
+ int insertMenu(SysMenu menu);
/**
* 修改保存菜单信息
@@ -127,7 +127,7 @@
* @param menu 菜单信息
* @return 结果
*/
- public int updateMenu(SysMenu menu);
+ int updateMenu(SysMenu menu);
/**
* 删除菜单管理信息
@@ -135,7 +135,7 @@
* @param menuId 菜单ID
* @return 结果
*/
- public int deleteMenuById(Long menuId);
+ int deleteMenuById(Long menuId);
/**
* 校验菜单名称是否唯一
@@ -143,11 +143,11 @@
* @param menu 菜单信息
* @return 结果
*/
- public boolean checkMenuNameUnique(SysMenu menu);
+ boolean checkMenuNameUnique(SysMenu menu);
List<SysMenus> getAllMenu();
-
+ List<SysMenu> getAllMenu(Integer roleType);
}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/UserShopService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/UserShopService.java
index 27b2dff..1109f81 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/UserShopService.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/UserShopService.java
@@ -3,9 +3,20 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.system.api.model.UserShop;
+import java.util.List;
+
/**
* @author zhibing.pu
* @Date 2024/12/2 9:39
*/
public interface UserShopService extends IService<UserShop> {
+
+
+ /**
+ * 获取关系数据
+ * @param userId
+ * @param roleType
+ * @return
+ */
+ List<UserShop> getUserShop(Long userId, Integer roleType);
}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
index b9d09a4..5701160 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
@@ -1,5 +1,6 @@
package com.ruoyi.system.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.constant.UserConstants;
@@ -231,7 +232,7 @@
List<Long> tempList = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList());
for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext();)
{
- SysMenu menu = (SysMenu) iterator.next();
+ SysMenu menu = iterator.next();
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(menu.getParentId()))
{
@@ -506,7 +507,7 @@
List<SysMenu> returnList = new ArrayList<SysMenu>();
for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext();)
{
- SysMenu t = (SysMenu) iterator.next();
+ SysMenu t = iterator.next();
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
if (t.getParentId() == parentId)
{
@@ -546,7 +547,7 @@
Iterator<SysMenu> it = list.iterator();
while (it.hasNext())
{
- SysMenu n = (SysMenu) it.next();
+ SysMenu n = it.next();
if (n.getParentId().longValue() == t.getMenuId().longValue())
{
tlist.add(n);
@@ -573,4 +574,11 @@
return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, "." },
new String[] { "", "", "", "/" });
}
+
+
+ @Override
+ public List<SysMenu> getAllMenu(Integer roleType) {
+ return this.list(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getRoleType, roleType).eq(SysMenu::getVisible, 0)
+ .eq(SysMenu::getStatus, 0));
+ }
}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java
index 569182e..0a926ba 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java
@@ -1,9 +1,11 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ruoyi.system.api.domain.SysRole;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.UserShop;
+import com.ruoyi.system.domain.SysMenu;
import com.ruoyi.system.service.ISysMenuService;
import com.ruoyi.system.service.ISysPermissionService;
import com.ruoyi.system.service.ISysRoleService;
@@ -15,6 +17,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.stream.Collectors;
/**
* 用户权限处理
@@ -22,21 +25,19 @@
* @author ruoyi
*/
@Service
-public class SysPermissionServiceImpl implements ISysPermissionService
-{
+public class SysPermissionServiceImpl implements ISysPermissionService {
@Autowired
private ISysRoleService roleService;
@Autowired
private ISysMenuService menuService;
- @Resource
+ @Autowired
private UserShopService userShopService;
/**
* 获取角色数据权限
*
- * @param userId 用户Id
* @return 角色权限信息
*/
@Override
@@ -58,17 +59,20 @@
/**
* 获取菜单数据权限
*
- * @param userId 用户Id
* @return 菜单权限信息
*/
@Override
public Set<String> getMenuPermission(SysUser user)
{
Set<String> perms = new HashSet<String>();
+ List<UserShop> userShop = userShopService.getUserShop(user.getUserId(), 1);
// 管理员拥有所有权限
if (user.isAdmin())
{
perms.add("*:*:*");
+ }else if(user.getRoleType() == 2 && null != userShop && userShop.size() > 0){
+ List<SysMenu> list = menuService.getAllMenu(2);
+ return list.stream().map(SysMenu::getPath).collect(Collectors.toSet());
}
else
{
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
index 291ae90..9bde5e4 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
@@ -455,12 +455,6 @@
for (SysUser user : sysUsers) {
if(2 == user.getRoleType()){
userShopService.remove(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId()).eq(UserShop::getShopId, user.getObjectId()));
- UserShop userShop = new UserShop();
- userShop.setUserId(user.getUserId());
- userShop.setShopId(user.getObjectId());
- userShop.setRoleType(2);
- userShop.setRoleId(user.getRoleId());
- userShopService.save(userShop);
}
}
return i;
@@ -533,20 +527,31 @@
}
List<SysUser> list = this.baseMapper.getList(pageInfo, getSysUserList);
for (SysUser sysUser : list) {
- List<SysUserRole> list1 = sysUserRoleService.list(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, sysUser.getUserId()));
- List<String> roleNames = new ArrayList<>();
- for (SysUserRole sysUserRole : list1) {
- SysRole sysRole = sysRoleService.selectRoleById(sysUserRole.getRoleId());
- if(null == sysRole){
- continue;
+ if(sysUser.getRoleType() == 2){
+ UserShop userShop = userShopService.getOne(new LambdaQueryWrapper<UserShop>().eq(UserShop::getShopId, sysUser1.getObjectId()).eq(UserShop::getUserId, sysUser.getUserId()));
+ SysRole sysRole = roleMapper.selectRoleById(userShop.getRoleId());
+ Long[] roleIds = new Long[]{userShop.getRoleId()};
+ sysUser.setNickName(userShop.getNickName());
+ sysUser.setRoleIds(roleIds);
+ sysUser.setRoleNames(Arrays.asList(sysRole.getRoleName()));
+ SysDept sysDept = deptService.selectDeptById(userShop.getDeptId());
+ sysUser.setDept(sysDept);
+ }else{
+ List<SysUserRole> list1 = sysUserRoleService.list(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, sysUser.getUserId()));
+ List<String> roleNames = new ArrayList<>();
+ for (SysUserRole sysUserRole : list1) {
+ SysRole sysRole = sysRoleService.selectRoleById(sysUserRole.getRoleId());
+ if(null == sysRole){
+ continue;
+ }
+ roleNames.add(sysRole.getRoleName());
}
- roleNames.add(sysRole.getRoleName());
+ Long[] roleIds = new Long[]{};
+ sysUser.setRoleIds(list1.stream().map(SysUserRole::getRoleId).collect(Collectors.toList()).toArray(roleIds));
+ sysUser.setRoleNames(roleNames);
+ SysDept sysDept = deptService.selectDeptById(sysUser.getDeptId());
+ sysUser.setDept(sysDept);
}
- Long[] roleIds = new Long[]{};
- sysUser.setRoleIds(list1.stream().map(SysUserRole::getRoleId).collect(Collectors.toList()).toArray(roleIds));
- sysUser.setRoleNames(roleNames);
- SysDept sysDept = deptService.selectDeptById(sysUser.getDeptId());
- sysUser.setDept(sysDept);
}
return pageInfo.setRecords(list);
}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserShopServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserShopServiceImpl.java
index 95cc931..5267a1e 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserShopServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserShopServiceImpl.java
@@ -1,10 +1,13 @@
package com.ruoyi.system.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.api.model.UserShop;
import com.ruoyi.system.mapper.UserShopMapper;
import com.ruoyi.system.service.UserShopService;
import org.springframework.stereotype.Service;
+
+import java.util.List;
/**
* @author zhibing.pu
@@ -13,4 +16,9 @@
@Service
public class UserShopServiceImpl extends ServiceImpl<UserShopMapper, UserShop> implements UserShopService {
+
+ @Override
+ public List<UserShop> getUserShop(Long userId, Integer roleType) {
+ return this.list(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, userId).eq(UserShop::getRoleType, roleType));
+ }
}
diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysDeptMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysDeptMapper.xml
index 186c0ba..aeeaa31 100644
--- a/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysDeptMapper.xml
+++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysDeptMapper.xml
@@ -46,6 +46,9 @@
<if test="shopId != null">
AND shop_id = #{shopId}
</if>
+ <if test="shopId == null">
+ AND shop_id is null
+ </if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by d.parent_id, d.order_num
diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml
index 6830f59..61c2be5 100644
--- a/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml
+++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml
@@ -132,28 +132,31 @@
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
</select>
<select id="getList" resultMap="SysUserResult">
- select * from sys_user where 1=1
- <if test="req.search !=null and req.search !=''">
- and (phonenumber like concat("%", #{req.search},"%") or nick_name like concat("%", #{req.search},"%"))
+ select * from sys_user where del_flag = '0' and status = '0'
+ <if test="null != req.phonenumber and '' != req.phonenumber">
+ and phonenumber like CONCAT('%', #{req.phonenumber}, '%')
</if>
- <if test="null != req.siteId">
- and user_id in (select user_id from t_user_site where site_id = #{req.siteId})
- and user_id in (select user_id from sys_user_role where role_id in (select role_id from t_role_site where site_id = #{req.siteId}))
- </if>
- <if test="null != req.roleIds and req.roleIds.size() > 0">
- and user_id in (select user_id from sys_user_role where role_id in
- <foreach collection="req.roleIds" item="item" index="index" open="(" separator="," close=")">
- #{item}
- </foreach>
- )
- </if>
- <if test="null != req.status">
- and status = #{req.status}
- </if>
- <if test="null != req.objectId">
- and objectId = #{req.objectId}
- </if>
- and del_flag = '0'
+ <choose>
+ <when test="null != req.objectId">
+ and user_id in (select user_id from t_user_shop where shop_id = #{req.objectId}
+ <if test="null != req.deptId">
+ and dept_id = #{req.deptId}
+ </if>
+ <if test="req.search !=null and req.search !=''">
+ and nick_name like concat("%", #{req.search},"%")
+ </if>
+ )
+ </when>
+ <otherwise>
+ and role_type = 1
+ <if test="null != req.deptId">
+ and dept_id = #{req.deptId}
+ </if>
+ <if test="req.search !=null and req.search !=''">
+ and nick_name like concat("%", #{req.search},"%")
+ </if>
+ </otherwise>
+ </choose>
order by create_time desc
</select>
<select id="getAllList" resultType="com.ruoyi.system.api.domain.SysUser">
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java
index 7f02b6b..8958c81 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java
@@ -48,8 +48,14 @@
@PostMapping("/page")
@ApiOperation(value = "会员申请列表", tags = {"后台"})
public R<IPage<AgentApplication>> page(@RequestBody AgentQuery agentQuery) {
-
- return R.ok(agentApplicationService.pageList(agentQuery));
+ IPage<AgentApplication> agentApplicationIPage = agentApplicationService.pageList(agentQuery);
+ for (AgentApplication record : agentApplicationIPage.getRecords()) {
+ AppUser byId = appUserService.getById(record.getAppUserId());
+ if (byId!=null){
+ record.setVipId(byId.getVipId());
+ }
+ }
+ return R.ok(agentApplicationIPage);
}
@Resource
private VipSettingClient vipSettingClient;
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
index af03a28..981af18 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -20,6 +20,7 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.bean.BeanUtils;
import com.ruoyi.common.security.service.TokenService;
+import com.ruoyi.order.feignClient.OrderClient;
import com.ruoyi.order.feignClient.RemoteOrderGoodsClient;
import com.ruoyi.order.model.Order;
import com.ruoyi.other.api.domain.Shop;
@@ -27,6 +28,8 @@
import com.ruoyi.other.api.feignClient.ShopClient;
import com.ruoyi.other.api.feignClient.StoreClient;
import com.ruoyi.other.api.feignClient.VipSettingClient;
+import com.ruoyi.system.api.domain.SysUser;
+import com.ruoyi.system.api.feignClient.SysUserClient;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -81,6 +84,14 @@
private VipSettingService vipSettingService;
@Resource
private AppUserMapper appUserMapper;
+ @Resource
+ private ShopClient shopClient;
+ @Resource
+ private RemoteOrderGoodsClient remoteOrderGoodsClient;
+ @Resource
+ private SysUserClient sysUserClient;
+ @Resource
+ private OrderClient orderClient;
@ResponseBody
@@ -99,7 +110,6 @@
}
- @ResponseBody
@PostMapping("/getAppUserById")
public AppUser getAppUserById(@RequestParam("id") Long id) {
return appUserService.getById(id);
@@ -204,8 +214,8 @@
userCancellationLog.setAppUserId(user.getId());
userCancellationLog.setVipId(user.getVipId());
userCancellationLogService.save(userCancellationLog);
-
-
+ user.setStatus(3);
+ appUserService.updateById(user);
return R.ok();
}
@@ -289,13 +299,13 @@
user.setShopName(storeById.getData().getName());
}
}
- Long count1 = appUserService.lambdaQuery().eq(AppUser::getVipId, 1).eq(AppUser::getInviteUserId, userId).count();
- Long count2 = appUserService.lambdaQuery().eq(AppUser::getVipId, 2).eq(AppUser::getInviteUserId, userId).count();
- Long count3 = appUserService.lambdaQuery().eq(AppUser::getVipId, 3).eq(AppUser::getInviteUserId, userId).count();
- Long count4 = appUserService.lambdaQuery().eq(AppUser::getVipId, 4).eq(AppUser::getInviteUserId, userId).count();
- Long count5 = appUserService.lambdaQuery().eq(AppUser::getVipId, 5).eq(AppUser::getInviteUserId, userId).count();
- Long count6 = appUserService.lambdaQuery().eq(AppUser::getVipId, 6).eq(AppUser::getInviteUserId, userId).count();
- Long count7 = appUserService.lambdaQuery().eq(AppUser::getVipId, 7).eq(AppUser::getInviteUserId, userId).count();
+ Long count1 = appUserService.lambdaQuery().eq(AppUser::getVipId, 1).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count();
+ Long count2 = appUserService.lambdaQuery().eq(AppUser::getVipId, 2).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count();
+ Long count3 = appUserService.lambdaQuery().eq(AppUser::getVipId, 3).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count();
+ Long count4 = appUserService.lambdaQuery().eq(AppUser::getVipId, 4).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count();
+ Long count5 = appUserService.lambdaQuery().eq(AppUser::getVipId, 5).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count();
+ Long count6 = appUserService.lambdaQuery().eq(AppUser::getVipId, 6).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count();
+ Long count7 = appUserService.lambdaQuery().eq(AppUser::getVipId, 7).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count();
user.setCount1(count1);
user.setCount2(count2);
user.setCount3(count3);
@@ -391,7 +401,15 @@
public R<IPage<AppUser>> getAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum,
@ApiParam("每一页数据大小") Integer pageSize,
AppUser appUser) {
- IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser);
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser sysUser = sysUserClient.getSysUser(userid).getData();
+ Integer shopId = null;
+ Set<Long> userId = null;
+ if(sysUser.getRoleType() == 2){
+ shopId = sysUser.getObjectId();
+ userId = orderClient.getAppUserByShoppingShop(shopId).getData();
+ }
+ IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId);
for (AppUser record : appuserPage.getRecords()) {
if (record.getInviteUserId() != null) {
AppUser byId1 = appUserService.getById(record.getInviteUserId());
@@ -465,16 +483,6 @@
AppUser byId = appUserService.getById(id);
byId.setVipId(byId.getVipId() - 1);
appUserService.updateById(byId);
- //执行降级标记代码
- new Thread(new Runnable() {
- @Override
- public void run() {
- {
- vipSettingService.downUsers();
- }
- }
- }
- ).start();
return R.ok();
}
@@ -527,10 +535,8 @@
}
- @Resource
- private ShopClient shopClient;
- @Resource
- private RemoteOrderGoodsClient remoteOrderGoodsClient;
+
+
@GetMapping("/detail")
@ApiOperation(value = "用户列表-详情", tags = {"管理后台"})
@@ -621,7 +627,7 @@
@PostMapping("/getAppUserByPhone1")
public R<AppUser> getAppUserByPhone1(@RequestParam("phone") String phone) {
- AppUser appUser = appUserService.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1)
+ AppUser appUser = appUserService.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).ne(AppUser::getStatus, 3)
.eq(AppUser::getPhone, phone));
return R.ok(appUser);
}
@@ -632,7 +638,15 @@
@GetMapping("/statistics")
@ApiOperation(value = "用户统计", tags = {"管理后台-首页统计-用户统计"})
public R<UserStatistics> statistics() {
- UserStatistics userStatistics = appUserMapper.getUserStatistics();
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser data = sysUserClient.getSysUser(userid).getData();
+ Integer shopId = null;
+ Set<Long> userId = null;
+ if(data.getRoleType() == 2){
+ shopId = data.getObjectId();
+ userId = orderClient.getAppUserByShoppingShop(shopId).getData();
+ }
+ UserStatistics userStatistics = appUserMapper.getUserStatistics(shopId, userId);
return R.ok(userStatistics);
}
@@ -642,7 +656,24 @@
@GetMapping("/statistics/detail")
@ApiOperation(value = "用户统计详情", tags = {"管理后台-首页统计-用户统计详情"})
public R<UserStatisticsDetail> statisticsDetail(@ApiParam(value = "用户id") Long userId) {
- UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(userId);
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser data = sysUserClient.getSysUser(userid).getData();
+ Integer shopId = null;
+ Set<Long> userIds = null;
+ if(null != userId){
+ userIds = new HashSet<>();
+ userIds.add(userId);
+ }
+ if(data.getRoleType() == 2){
+ shopId = data.getObjectId();
+ if(null == userId){
+ userIds = orderClient.getAppUserByShoppingShop(shopId).getData();
+ }else{
+ userIds = new HashSet<>();
+ userIds.add(userId);
+ }
+ }
+ UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(shopId, userIds);
return R.ok(userStatisticsDetail);
}
@@ -652,28 +683,25 @@
*/
@GetMapping("/commissionDetail")
@ApiOperation(value = "分佣统计", tags = "管理后台-首页统计")
- public R<CommissionDetail> commissionDetail(BalanceChangeRecord balanceChangeRecord) {
- List<AppUser> appUserList = Optional.ofNullable(appUserService.list()).orElse(Collections.emptyList());
-
+ public R<CommissionDetail> commissionDetail() {
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser sysUser = sysUserClient.getSysUser(userid).getData();
+ LambdaQueryWrapper<AppUser> queryWrapper = new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0);
+ if(sysUser.getRoleType() == 2){
+ queryWrapper.eq(AppUser::getShopId, sysUser.getObjectId());
+ }
+ List<AppUser> appUserList = appUserService.list(queryWrapper);
if (appUserList.isEmpty()) {
return R.ok(new CommissionDetail());
}
-
BigDecimal totalCommission = BigDecimal.ZERO;
BigDecimal totalServiceFee = BigDecimal.ZERO;
BigDecimal totalUserCommission = BigDecimal.ZERO;
Map<Integer, BigDecimal> vipCommissions = new HashMap<>();
Map<String, Map<Integer, BigDecimal>> dailyVipCommissions = new HashMap<>();
-
for (AppUser appUser : appUserList) {
BigDecimal distributionAmount = Optional.ofNullable(appUser.getTotalDistributionAmount()).orElse(BigDecimal.ZERO);
- BigDecimal serviceFee = Optional.ofNullable(appUser.getShopServiceFee()).orElse(BigDecimal.ZERO);
- BigDecimal userCommission = Optional.ofNullable(appUser.getShopCommission()).orElse(BigDecimal.ZERO);
-
totalCommission = totalCommission.add(distributionAmount);
- totalServiceFee = totalServiceFee.add(serviceFee);
- totalUserCommission = totalUserCommission.add(userCommission);
-
Integer vipId = appUser.getVipId();
if (vipId != null && vipId >= 1 && vipId <= 7) {
vipCommissions.merge(vipId, distributionAmount, BigDecimal::add);
@@ -682,6 +710,14 @@
dailyVipCommissions.computeIfAbsent(dateKey, k -> new HashMap<>())
.merge(vipId, distributionAmount, BigDecimal::add);
}
+ }
+ List<Shop> data = shopClient.getAllShop().getData();
+ if(sysUser.getRoleType() == 2){
+ data = Arrays.asList(shopClient.getShopById(sysUser.getObjectId()).getData());
+ }
+ for (Shop shop : data) {
+ totalServiceFee = totalServiceFee.add(shop.getServerGiveawayMoney());
+ totalUserCommission = totalUserCommission.add(shop.getGiveawayMoney());
}
CommissionDetail commissionDetail = new CommissionDetail();
@@ -712,16 +748,11 @@
BigDecimal add = commissionDate.getNormalCommission().add(commissionDate.getGoldCommission()).add(commissionDate.getDiamondCommission()).add(commissionDate.getAgentCommission())
.add(commissionDate.getSuperAgentCommission()).add(commissionDate.getTopAgentCommission()).add(commissionDate.getPartnerCommission());
commissionDate.setTotalCommission(add);
-
-// commissionDate.setServiceChargeCommission();
-// commissionDate.setAssociatedUserCommission();
-// commissionDate.setBindLowerLevelStoresCommission();
return commissionDate;
})
.collect(Collectors.toList());
commissionDetail.setCommissionDateList(commissionDateList);
-
return R.ok(commissionDetail);
}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserAddressController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserAddressController.java
index c8b2c71..67e2f25 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserAddressController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserAddressController.java
@@ -62,9 +62,8 @@
@ResponseBody
@PostMapping("/add")
@ApiOperation(value = "添加", tags = {"小程序-个人中心首页-我的地址"})
- public R add(@RequestBody UserAddress userAddress){
+ public R<String> add(@RequestBody UserAddress userAddress){
Long userId = tokenService.getLoginUserApplet().getUserid();
-
if (userAddress.getIsDefault()==1){
List<UserAddress> list = userAddressService.lambdaQuery().eq(UserAddress::getAppUserId, userId).list();
for (UserAddress userAddress1 : list) {
@@ -72,10 +71,9 @@
}
userAddressService.updateBatchById(list);
}
-
userAddress.setAppUserId(userId);
userAddressService.save(userAddress);
- return R.ok();
+ return R.ok(userAddress.getId().toString());
}
@ResponseBody
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java
index 8608eff..00de185 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java
@@ -1,6 +1,7 @@
package com.ruoyi.account.controller;
+import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.api.model.AppUser;
@@ -12,6 +13,7 @@
import com.ruoyi.account.service.UserCouponService;
import com.ruoyi.account.service.UserPointService;
import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.bean.BeanUtils;
import com.ruoyi.account.api.vo.PaymentUserCoupon;
import com.ruoyi.other.api.domain.Goods;
@@ -117,6 +119,58 @@
}
+ @GetMapping("/mine/list1")
+ @ApiOperation(value = "已领取列表", tags = {"管理后台-优惠劵"})
+ public R<Page<UserCoupon>> list1(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @ApiParam("1未使用2已使用3已过期") Integer status, Integer id) {
+ Page<UserCoupon> page = userCouponService.lambdaQuery()
+ .isNull(status!=null&&(status==1||status==3),UserCoupon::getUseTime)
+ .isNotNull(status!=null&&status==2,UserCoupon::getUseTime)
+ .eq(UserCoupon::getCouponId, id)
+ .lt(status!=null&&status==3,UserCoupon::getEndTime, LocalDateTime.now()).page(Page.of(pageNum-1, pageSize));
+ for (UserCoupon record : page.getRecords()) {
+ record.setIdStr(record.getId().toString());
+ CouponInfo data = couponClient.detail(record.getCouponId()).getData();
+ CouponInfoVo vo = new CouponInfoVo();
+ BeanUtils.copyProperties(data,vo);
+ //如果是商品券,将商品名称返回
+ if (vo.getCouponType()==4){
+ List<String> goodNames = new ArrayList<>();
+ if (vo.getForGoodIds().equals("-1")){
+ goodNames.add("全部商品");
+ }else{
+ String[] split = vo.getForGoodIds().split(",");
+ R<List<Goods>> goodsById = goodsClient.getGoodsById(split);
+ if (goodsById.getData()!=null){
+ for (Goods datum : goodsById.getData()) {
+ goodNames.add(datum.getName());
+ }
+ }
+ vo.setGoodNames(goodNames);
+ }
+ }
+
+
+
+ record.setCouponInfoVo(vo);
+ if (record.getUseTime()==null){
+ record.setStatus(1);
+ if (record.getEndTime().isBefore(LocalDateTime.now())){
+ record.setStatus(3);
+ }
+ }else {
+ record.setStatus(2);
+ }
+
+
+ AppUser appUser = appUserService.getById(record.getAppUserId());
+ record.setUserName(appUser.getName());
+ record.setPhone(appUser.getPhone());
+ }
+ return R.ok(page);
+ }
+
+
+
@GetMapping("/get")
@ApiOperation(value = "领取或者兑换优惠券", tags = {"小程序-个人中心-优惠劵"})
public R<Page<UserCoupon>> get(@RequestParam Integer couponId) {
@@ -153,6 +207,7 @@
userPoint.setBalance(byId.getLavePoint());
userPoint.setAppUserId(userid);
userPoint.setObjectId(Long.valueOf(data.getId()));
+ userPoint.setCreateTime(LocalDateTime.now());
userPointService.save(userPoint);
}
//增加优惠券记录,根据时间类型设置开始结束时间
@@ -219,15 +274,22 @@
public R<UserCoupon> getCouponInfoInfo(String id){
UserCoupon userCoupon = userCouponService.getById(id);
CouponInfo couponInfo = couponClient.detail(userCoupon.getCouponId()).getData();
- List<Goods> goods = null;
- if("-1".equals(couponInfo.getForGoodIds())){
- goods = goodsClient.getGoodsByType(2).getData();
+ List<String> goodNames = new ArrayList<>();
+ if(!"null".equals(couponInfo.getGoodsNameJson()) && StringUtils.isNotEmpty(couponInfo.getGoodsNameJson())){
+ goodNames = JSON.parseArray(couponInfo.getGoodsNameJson(), String.class);
}else{
- goods = goodsClient.getGoodsById(couponInfo.getForGoodIds().split(",")).getData();
+ List<Goods> goods = null;
+ if("-1".equals(couponInfo.getForGoodIds())){
+ goods = goodsClient.getGoodsByType(2).getData();
+ }else{
+ goods = goodsClient.getGoodsById(couponInfo.getForGoodIds().split(",")).getData();
+ }
+ goodNames = goods.stream().map(Goods::getName).collect(Collectors.toList());
}
+
CouponInfoVo couponInfoVo = new CouponInfoVo();
BeanUtils.copyProperties(couponInfo, couponInfoVo);
- couponInfoVo.setGoodNames(goods.stream().map(Goods::getName).collect(Collectors.toList()));
+ couponInfoVo.setGoodNames(goodNames);
userCoupon.setCouponInfoVo(couponInfoVo);
if (userCoupon.getUseTime()==null){
userCoupon.setStatus(1);
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java
index 9afbe26..dc5612c 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java
@@ -1,11 +1,13 @@
package com.ruoyi.account.controller;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.api.model.UserPoint;
import com.ruoyi.account.service.AppUserService;
import com.ruoyi.account.service.UserPointService;
+import com.ruoyi.account.vo.TransferPoint;
import com.ruoyi.account.vo.UserPointDetailVO;
import com.ruoyi.account.vo.UserPointStatistics;
import com.ruoyi.account.vo.UserPointVO;
@@ -92,9 +94,8 @@
*/
@PostMapping("/transferPoint")
@ApiOperation("转赠积分")
- public R<Void> transferPoint(@ApiParam("积分") @RequestParam BigDecimal point, @ApiParam("手机号") @RequestParam String phone) {
- userPointService.transferPoint(point, phone);
- return R.ok();
+ public R<Void> transferPoint(@RequestBody TransferPoint transferPoint) {
+ return userPointService.transferPoint(transferPoint.getPoint(), transferPoint.getPhone());
}
@@ -152,5 +153,25 @@
}
+ /**
+ * 获取积分变动记录
+ * @param userPoint
+ * @return
+ */
+ @PostMapping("/getUserPointList")
+ public R<List<UserPoint>> getUserPointList(@RequestBody UserPoint userPoint){
+ LambdaQueryWrapper<UserPoint> queryWrapper = new LambdaQueryWrapper<>();
+ if(null != userPoint.getType()){
+ queryWrapper.eq(UserPoint::getType, userPoint.getType());
+ }
+ if(null != userPoint.getObjectId()){
+ queryWrapper.eq(UserPoint::getObjectId, userPoint.getObjectId());
+ }
+ if(null != userPoint.getAppUserId()){
+ queryWrapper.eq(UserPoint::getAppUserId, userPoint.getAppUserId());
+ }
+ List<UserPoint> list = userPointService.list(queryWrapper);
+ return R.ok(list);
+ }
}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java
index d8f9645..0d19dcd 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java
@@ -1,13 +1,16 @@
package com.ruoyi.account.controller;
import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.account.api.model.BalanceChangeRecord;
-import com.ruoyi.account.service.AppUserService;
-import com.ruoyi.account.service.BalanceChangeRecordService;
-import com.ruoyi.account.service.VipSettingService;
-import com.ruoyi.account.service.WalletService;
+import com.ruoyi.account.api.model.BalancePayment;
+import com.ruoyi.account.service.*;
+import com.ruoyi.account.util.payment.PaymentUtil;
+import com.ruoyi.account.util.payment.model.UniPayCallbackResult;
+import com.ruoyi.account.util.payment.model.UniPayResult;
import com.ruoyi.account.vo.WalletVO;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
@@ -20,18 +23,16 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
+import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.format.annotation.DateTimeFormat;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.math.BigDecimal;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.YearMonth;
+import java.time.*;
import java.util.List;
import java.util.stream.Collectors;
@@ -51,6 +52,12 @@
private AppUserService appUserService;
@Resource
private VipSettingService vipSettingService;
+ @Resource
+ private BalancePaymentService balancePaymentService;
+ @Resource
+ private RedisTemplate redisTemplate;
+
+
/**
* 钱包详情
@@ -121,14 +128,92 @@
*/
@GetMapping("recharge")
@ApiOperation(value = "充值", notes = "钱包充值")
- public R<Void> recharge(@ApiParam(value = "充值金额", required = true) @RequestParam BigDecimal amount) {
+ public R<String> recharge(@ApiParam(value = "充值金额", required = true) @RequestParam BigDecimal amount) {
LoginUser loginUserApplet = tokenService.getLoginUserApplet();
AppUser appUser = appUserService.getById(loginUserApplet.getUserid());
- String wxOpenid = appUser.getWxOpenid();
- // 商户号
- String partnerTradeNo;
- // TODO 充值
- return R.ok();
+ BalancePayment balancePayment = new BalancePayment();
+ balancePayment.setAppUserId(appUser.getId());
+ balancePayment.setMoney(amount);
+ balancePayment.setStatus(1);
+ balancePayment.setCreateTime(LocalDateTime.now());
+ balancePaymentService.save(balancePayment);
+ //调起支付
+ UniPayResult uniPayResult = PaymentUtil.uniPay(balancePayment.getId().toString(), amount.doubleValue(), "余额充值", "余额充值", "",
+ "/account/wallet/rechargeCallback", appUser.getWxOpenid(), null);
+ if(null == uniPayResult || !"100".equals(uniPayResult.getRa_Code())){
+ return R.fail(null == uniPayResult ? "支付失败" : uniPayResult.getRb_CodeMsg());
+ }
+ String rc_result = uniPayResult.getRc_Result();
+ JSONObject jsonObject = JSON.parseObject(rc_result);
+ //将支付数据添加到redis队列中,便于定时任务去校验是否完成支付,没有完成支付支付,15分钟后关闭订单。
+ long second = LocalDateTime.now().plusMinutes(15).toEpochSecond(ZoneOffset.UTC);
+ redisTemplate.opsForZSet().add("BalanceRecharge", balancePayment.getId(), second);
+ return R.ok(jsonObject.toJSONString());
}
+
+ /**
+ * 充值支付回调
+ * @param callback
+ * @param response
+ */
+ @ResponseBody
+ @GetMapping("/rechargeCallback")
+ public void rechargeCallback(UniPayCallbackResult callback, HttpServletResponse response){
+ String r2_orderNo = callback.getR2_OrderNo();
+ BalancePayment balancePayment = balancePaymentService.getById(r2_orderNo);
+ if(null == balancePayment || balancePayment.getStatus() != 1){
+ response.setStatus(200);
+ PrintWriter out = null;
+ try {
+ out = response.getWriter();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ out.println("success");
+ out.flush();
+ out.close();
+ return;
+ }
+ if("100".equals(callback.getR6_Status())){
+ //添加账户变动流水
+ BigDecimal money = balancePayment.getMoney();
+ AppUser appUser = appUserService.getById(balancePayment.getAppUserId());
+ BigDecimal balance = appUser.getBalance();
+ appUser.setBalance(appUser.getBalance().add(money));
+ appUser.setWithdrawableAmount(appUser.getWithdrawableAmount().add(money));
+ appUser.setTotalRechargeAmount(appUser.getTotalRechargeAmount().add(money));
+ appUserService.updateById(appUser);
+ //流水
+ BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord();
+ balanceChangeRecord.setAppUserId(appUser.getId());
+ balanceChangeRecord.setOrderId(balanceChangeRecord.getId());
+ balanceChangeRecord.setChangeType(1);
+ balanceChangeRecord.setBeforeAmount(balance);
+ balanceChangeRecord.setChangeAmount(money);
+ balanceChangeRecord.setAfterAmount(appUser.getBalance());
+ balanceChangeRecord.setDelFlag(0);
+ balanceChangeRecord.setCreateTime(LocalDateTime.now());
+ balanceChangeRecordService.save(balanceChangeRecord);
+
+ balancePayment.setStatus(2);
+ balancePayment.setPaymentTime(LocalDateTime.now());
+ balancePayment.setSerialNumber(callback.getR8_BankOrderNo());
+ balancePayment.setBalanceChangeRecordId(balanceChangeRecord.getId());
+ balancePaymentService.updateById(balancePayment);
+
+ response.setStatus(200);
+ PrintWriter out = null;
+ try {
+ out = response.getWriter();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ out.println("success");
+ out.flush();
+ out.close();
+ }
+
+
+ }
}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java
index 3e95d1a..7522ff0 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java
@@ -78,7 +78,7 @@
@PostMapping("/auth")
@ApiOperation(value = "提现申请审批", tags = {"后台"})
- public R auth(@RequestParam Long id,@ApiParam("2'审核通过',3'审核拒绝'") Integer auditStatus){
+ public R auth(@RequestParam("id") Long id,@ApiParam("2'审核通过',3'审核拒绝'") @RequestParam("auditStatus") Integer auditStatus){
WithdrawalRequests withdrawal = withdrawalRequestsService.getById(id);
BigDecimal withdrawalAmount = withdrawal.getWithdrawalAmount();
if(withdrawal.getAuditStatus() != 1){
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java
index 97be34d..e3642dc 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java
@@ -10,6 +10,7 @@
import org.apache.ibatis.annotations.Param;
import java.util.List;
+import java.util.Set;
/**
* <p>
@@ -29,12 +30,12 @@
*/
List<NearbyReferrerVo> getNearbyReferrer(@Param("cityCode") String cityCode, @Param("nearbyReferrer") NearbyReferrer nearbyReferrer);
- IPage<AppUser> getAppuserPage(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser);
+ IPage<AppUser> getAppuserPage(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser, @Param("shopId") Integer shopId, @Param("userId") Set<Long> userIds);
IPage<AppUser> getAppuserPage1(@Param("page") IPage<AppUser> page, @Param("appUser") AppUser appUser,@Param("objectId")Integer objectId,@Param("userIds")List<Long> userIds);
- UserStatistics getUserStatistics();
+ UserStatistics getUserStatistics(@Param("shopId") Integer shopId, @Param("userId") Set<Long> userId);
- UserStatisticsDetail getUserStatisticsDetail(Long userId);
+ UserStatisticsDetail getUserStatisticsDetail(@Param("shopId") Integer shopId, @Param("userId") Set<Long> userIds);
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/BalancePaymentMapper.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/BalancePaymentMapper.java
new file mode 100644
index 0000000..69f77ee
--- /dev/null
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/BalancePaymentMapper.java
@@ -0,0 +1,11 @@
+package com.ruoyi.account.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.account.api.model.BalancePayment;
+
+/**
+ * @author zhibing.pu
+ * @date 2025/1/8 17:47
+ */
+public interface BalancePaymentMapper extends BaseMapper<BalancePayment> {
+}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java
index c7817fe..05a32bd 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java
@@ -8,6 +8,7 @@
import com.ruoyi.common.core.web.domain.AjaxResult;
import java.util.List;
+import java.util.Set;
/**
* <p>
@@ -81,7 +82,7 @@
*/
void onlineRecord();
- IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser);
+ IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser, Integer shopId, Set<Long> userId);
IPage<AppUser> getAppuserPage1(Integer pageNum, Integer pageSize, AppUser appUser,Integer objectId,List<Long> userIds);
/**
@@ -95,4 +96,10 @@
* 降级检测
*/
void demotionDetection();
+
+
+ /**
+ * 定时任务关闭订单
+ */
+ void closeOrder();
}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/BalancePaymentService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/BalancePaymentService.java
new file mode 100644
index 0000000..e6e6579
--- /dev/null
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/BalancePaymentService.java
@@ -0,0 +1,11 @@
+package com.ruoyi.account.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.account.api.model.BalancePayment;
+
+/**
+ * @author zhibing.pu
+ * @date 2025/1/8 17:47
+ */
+public interface BalancePaymentService extends IService<BalancePayment> {
+}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java
index 149ea11..de8d44b 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java
@@ -9,6 +9,7 @@
import com.ruoyi.account.vo.UserPointDetailVO;
import com.ruoyi.account.vo.UserPointStatistics;
import com.ruoyi.account.vo.UserPointVO;
+import com.ruoyi.common.core.domain.R;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
@@ -30,7 +31,7 @@
List<UserPointDetailVO> getUserPointDetail(Long userId, LocalDateTime startTime, LocalDateTime endTime, Integer type);
- void transferPoint(BigDecimal point, String phone);
+ R transferPoint(Integer point, String phone);
UserPointStatistics getStatistics(UserPoint userPoint);
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/VipSettingService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/VipSettingService.java
index d6831ce..c937b2f 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/VipSettingService.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/VipSettingService.java
@@ -8,5 +8,4 @@
VipSetting getVipSettingByUserId(Long appUserId);
- void downUsers();
}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java
index 9d47a7a..ed32161 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java
@@ -3,19 +3,16 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.account.api.model.AppUserShop;
-import com.ruoyi.account.api.model.UserChangeLog;
-import com.ruoyi.account.api.model.UserPoint;
+import com.ruoyi.account.api.model.*;
import com.ruoyi.account.mapper.AppUserMapper;
-import com.ruoyi.account.api.model.AppUser;
-import com.ruoyi.account.service.AppUserService;
-import com.ruoyi.account.service.AppUserShopService;
-import com.ruoyi.account.service.UserChangeLogService;
-import com.ruoyi.account.service.UserPointService;
+import com.ruoyi.account.service.*;
import com.ruoyi.account.util.SMSUtil;
+import com.ruoyi.account.util.payment.PaymentUtil;
+import com.ruoyi.account.util.payment.model.CloseOrderResult;
import com.ruoyi.account.util.tencentMap.TencentMapUtil;
import com.ruoyi.account.util.weChat.EnvVersion;
import com.ruoyi.account.util.weChat.WXCore;
@@ -25,26 +22,23 @@
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
-import com.ruoyi.other.api.domain.PointSetting;
-import com.ruoyi.other.api.domain.Region;
-import com.ruoyi.other.api.domain.Shop;
-import com.ruoyi.other.api.domain.VipSetting;
-import com.ruoyi.other.api.feignClient.PointSettingClient;
-import com.ruoyi.other.api.feignClient.RegionClient;
-import com.ruoyi.other.api.feignClient.ShopClient;
-import com.ruoyi.other.api.feignClient.VipSettingClient;
+import com.ruoyi.other.api.domain.*;
+import com.ruoyi.other.api.feignClient.*;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import com.ruoyi.system.api.model.LoginUser;
+import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.core.util.UuidUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
+import java.time.ZoneOffset;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -61,6 +55,7 @@
* @author luodangjia
* @since 2024-11-21
*/
+@Slf4j
@Service
public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> implements AppUserService {
@@ -105,6 +100,17 @@
@Resource
private RegionClient regionClient;
+
+ @Resource
+ private CouponInfoClient couponInfoClient;
+
+ @Resource
+ private UserCouponService userCouponService;
+
+ @Resource
+ private RedisTemplate redisTemplate;
+ @Resource
+ private BalancePaymentService balancePaymentService;
/**
@@ -355,6 +361,15 @@
appUser.setProvinceCode(region.getCode());
}
this.save(appUser);
+ //添加定时任务队列
+ VipSetting vipSetting = vipSettingClient.getVipSetting(1).getData();
+ Integer vipCancelDay = vipSetting.getVipCancelDay();
+ Integer vipChangeDay = vipSetting.getVipChangeDay();
+ //解绑推广人
+ redisTemplate.opsForZSet().add("unbind_promoter", appUser.getId().toString(), LocalDateTime.now().plusDays(vipCancelDay).toEpochSecond(ZoneOffset.UTC));
+ //可更换推广人
+ redisTemplate.opsForZSet().add("replaceable", appUser.getId().toString(), LocalDateTime.now().plusDays(vipChangeDay).toEpochSecond(ZoneOffset.UTC));
+
//增加积分变动记录
if(0 == old && regisPoint > 0){
//构建积分流水记录
@@ -366,6 +381,26 @@
userPoint.setCreateTime(LocalDateTime.now());
userPoint.setAppUserId(appUser.getId());
userPointService.save(userPoint);
+ }
+ //获取优惠券
+ if(0 == old){
+ List<CouponInfo> list = couponInfoClient.getCouponInfoByPersonType(4).getData();
+ for (CouponInfo couponInfo : list) {
+ UserCoupon userCoupon = new UserCoupon();
+ userCoupon.setDelFlag(0);
+ userCoupon.setCreateTime(LocalDateTime.now());
+ userCoupon.setAppUserId(appUser.getId());
+ userCoupon.setCouponId(couponInfo.getId());
+ LocalDateTime start = couponInfo.getPeriodStartTime().atTime(0, 0, 0);
+ LocalDateTime end = couponInfo.getPeriodEndTime().atTime(23, 59, 59);
+ if(couponInfo.getPeriodType() == 2){
+ start = LocalDateTime.now();
+ end = start.plusDays(couponInfo.getPeriodDays());
+ }
+ userCoupon.setStartTime(start);
+ userCoupon.setEndTime(end);
+ userCouponService.save(userCoupon);
+ }
}
//变更等级
vipUpgrade(appUser.getId());
@@ -647,6 +682,9 @@
public List<NearbyReferrerVo> getNearbyReferrer(NearbyReferrer nearbyReferrer) {
//使用地图获取省市区数据
String citycode = TencentMapUtil.inverseGeographicalAnalysis(nearbyReferrer.getLongitude(), nearbyReferrer.getLatitude(), false);
+ if(StringUtils.isEmpty(citycode)){
+ citycode = "510100";
+ }
if(null != citycode){
String cityCode = citycode.substring(0, 4) + "00";
List<NearbyReferrerVo> list = this.baseMapper.getNearbyReferrer(cityCode, nearbyReferrer);
@@ -710,23 +748,27 @@
@Override
public void unbindThePromoter() {
//注册X天后没有升级成黄金会员则自动解绑推广人
- VipSetting vipSetting = vipSettingClient.getVipSetting(1).getData();
- Integer vipCancelDay = vipSetting.getVipCancelDay();
- Integer vipChangeDay = vipSetting.getVipChangeDay();
- List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 1).eq(AppUser::getDelFlag, 0).isNotNull(AppUser::getInviteUserId)
- .eq(AppUser::getStatus, 1).last(" and ADDDATE(create_time,INTERVAL " + vipCancelDay + " DAY) <= now()"));
- for (AppUser appUser : list) {
- appUser.setInviteUserId(null);
- appUser.setShopId(null);
- this.updateById(appUser);
+
+ //解绑推广人
+ Set<Long> unbind_promoter = redisTemplate.opsForZSet().range("unbind_promoter", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC));
+ if(unbind_promoter.size() > 0){
+ List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 1).eq(AppUser::getDelFlag, 0).isNotNull(AppUser::getInviteUserId)
+ .eq(AppUser::getStatus, 1).in(AppUser::getId, unbind_promoter));
+ for (AppUser appUser : list) {
+ UpdateWrapper<AppUser> updateWrapper = new UpdateWrapper<>();
+ updateWrapper.set("invite_user_id", null).set("shop_id", null).eq("id", appUser.getId());
+ this.update(updateWrapper);
+ }
}
-
//可更换推广人
- list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 1).eq(AppUser::getDelFlag, 0).eq(AppUser::getChangePromoter, 0)
- .isNull(AppUser::getLastShopTime).eq(AppUser::getStatus, 1).last(" and ADDDATE(create_time,INTERVAL " + vipChangeDay + " DAY) <= now()"));
- for (AppUser appUser : list) {
- appUser.setChangePromoter(1);
- this.updateById(appUser);
+ Set<Long> replaceable = redisTemplate.opsForZSet().range("replaceable", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC));
+ if(replaceable.size() > 0){
+ List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getChangePromoter, 0)
+ .eq(AppUser::getStatus, 1).in(AppUser::getId, unbind_promoter));
+ for (AppUser appUser : list) {
+ appUser.setChangePromoter(1);
+ this.updateById(appUser);
+ }
}
}
@@ -783,7 +825,7 @@
}
@Override
- public IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser) {
+ public IPage<AppUser> getAppuserPage(Integer pageNum, Integer pageSize, AppUser appUser, Integer shopId, Set<Long> userId) {
if (StringUtils.isNotEmpty(appUser.getShopName())){
R<Set<Integer>> shopR = shopClient.getShopIdByName(appUser.getShopName());
if (R.isSuccess(shopR)){
@@ -793,7 +835,7 @@
}
}
}
- return appUserMapper.getAppuserPage(new Page<>(pageNum, pageSize), appUser);
+ return appUserMapper.getAppuserPage(new Page<>(pageNum, pageSize), appUser, shopId, userId);
}
@Override
public IPage<AppUser> getAppuserPage1(Integer pageNum, Integer pageSize, AppUser appUser,Integer objectId,List<Long> userIds) {
@@ -906,4 +948,33 @@
this.updateBatchById(appUserList);
}
}
+
+
+
+ /**
+ * 定时任务关闭订单
+ */
+ @Override
+ public void closeOrder() {
+ //订单支付数据
+ long second = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC);
+ Set<String> orderPayment = redisTemplate.opsForZSet().range("BalanceRecharge", 0, second);
+ if(orderPayment.size() > 0){
+ List<BalancePayment> list = balancePaymentService.list(new LambdaQueryWrapper<BalancePayment>().in(BalancePayment::getId, orderPayment));
+ for (BalancePayment order : list) {
+ if(null == order || order.getStatus() != 1){
+ redisTemplate.opsForZSet().remove("BalanceRecharge", order.getId());
+ continue;
+ }
+ //开始执行关闭订单操作
+ CloseOrderResult closeOrderResult = PaymentUtil.closeOrder(order.getId().toString());
+ if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) &&
+ Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){
+ redisTemplate.opsForZSet().add("BalanceRecharge", order.getId(), 0);
+ log.error("关闭订单失败:{}---->{}", order.getId(), com.alibaba.fastjson2.JSON.toJSONString(closeOrderResult));
+ }
+ redisTemplate.opsForZSet().remove("BalanceRecharge", order.getId());
+ }
+ }
+ }
}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalancePaymentServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalancePaymentServiceImpl.java
new file mode 100644
index 0000000..59b10aa
--- /dev/null
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalancePaymentServiceImpl.java
@@ -0,0 +1,15 @@
+package com.ruoyi.account.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.account.api.model.BalancePayment;
+import com.ruoyi.account.mapper.BalancePaymentMapper;
+import com.ruoyi.account.service.BalancePaymentService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author zhibing.pu
+ * @date 2025/1/8 17:47
+ */
+@Service
+public class BalancePaymentServiceImpl extends ServiceImpl<BalancePaymentMapper, BalancePayment> implements BalancePaymentService {
+}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java
index 15e3ad8..8223d51 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java
@@ -15,6 +15,7 @@
import com.ruoyi.account.vo.UserPointDetailVO;
import com.ruoyi.account.vo.UserPointStatistics;
import com.ruoyi.account.vo.UserPointVO;
+import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.PhoneNumberValidator;
import com.ruoyi.common.security.service.TokenService;
@@ -54,6 +55,11 @@
private VipSettingService vipSettingService;
@Resource
private PointSettingService pointSettingService;
+ @Resource
+ private UserPointService userPointService;
+
+
+
@Override
public UserPointVO getUserPoint(Long userId) {
@@ -94,9 +100,9 @@
@Override
@Transactional
- public void transferPoint(BigDecimal point, String phone) {
+ public R transferPoint(Integer point, String phone) {
if (!PhoneNumberValidator.isValidChinaPhoneNumber(phone)) {
- throw new ServiceException("无效的电话号码");
+ return R.fail("无效的电话号码");
}
LoginUser loginUserApplet = tokenService.getLoginUserApplet();
@@ -104,44 +110,65 @@
VipSetting vipSetting = vipSettingService.getVipSettingByUserId(userid);
if (vipSetting == null) {
- throw new ServiceException("VIP 设置未找到");
+ return R.fail("VIP 设置未找到");
}
if (vipSetting.getId() == 0 && vipSetting.getVipGiftRole() == 0) {
- throw new ServiceException("转赠积分权限未开启");
+ return R.fail("转赠积分权限未开启");
}
AppUser appUser = appUserService.getById(userid);
if (appUser == null) {
- throw new ServiceException("用户未找到");
+ return R.fail("用户未找到");
}
PointSetting pointSetting = pointSettingService.getPointSettingByAppUserId(userid);
if (pointSetting == null) {
- throw new ServiceException("积分设置未找到");
+ return R.fail("积分设置未找到");
}
// 可转赠积分总数
- long adjustedPoint = appUser.getAvailablePoint();
-
- if (point.compareTo(new BigDecimal(adjustedPoint)) > 0) {
- throw new ServiceException("转赠积分不足");
+ Integer transferablePoint = appUser.getTransferablePoint();
+ if (point > transferablePoint) {
+ return R.fail("转赠积分不足");
}
AppUser appUserForPhoe = appUserService.getOne(new LambdaQueryWrapper<AppUser>()
.eq(AppUser::getPhone, phone));
if (appUserForPhoe == null) {
- throw new ServiceException("目标用户未找到");
+ return R.fail("目标用户未找到");
}
-
- appUserForPhoe.setLavePoint(appUserForPhoe.getLavePoint() + point.intValue());
- appUserForPhoe.setTotalPoint(appUserForPhoe.getTotalPoint() + point.intValue());
+ Integer lavePoint1 = appUserForPhoe.getLavePoint();
+ appUserForPhoe.setLavePoint(appUserForPhoe.getLavePoint() + point);
+ appUserForPhoe.setTotalPoint(appUserForPhoe.getTotalPoint() + point);
+ appUserForPhoe.setTransferablePoint(transferablePoint + point);
+ appUserForPhoe.setAvailablePoint(appUserForPhoe.getAvailablePoint() + point);
appUserService.updateById(appUserForPhoe);
+ //构建积分流水记录
+ UserPoint userPoint = new UserPoint();
+ userPoint.setType(12);
+ userPoint.setHistoricalPoint(lavePoint1);
+ userPoint.setVariablePoint(point);
+ userPoint.setBalance(appUserForPhoe.getLavePoint());
+ userPoint.setCreateTime(LocalDateTime.now());
+ userPoint.setAppUserId(appUserForPhoe.getId());
+ userPointService.save(userPoint);
Integer lavePoint = appUser.getLavePoint();
- appUser.setLavePoint(lavePoint - point.intValue());
+ appUser.setLavePoint(lavePoint - point);
Integer totalPoint = appUser.getTotalPoint();
- appUser.setTotalPoint(totalPoint - point.intValue());
+ appUser.setTotalPoint(totalPoint - point);
+ appUser.setTransferablePoint(appUser.getTransferablePoint() - point);
+ appUser.setAvailablePoint(appUser.getAvailablePoint() - point);
appUserService.updateById(appUser);
- log.info("积分转赠完成,用户ID: {}, 新积分: {}", appUserForPhoe.getId(), appUserForPhoe.getLavePoint());
+ //构建积分流水记录
+ userPoint = new UserPoint();
+ userPoint.setType(13);
+ userPoint.setHistoricalPoint(lavePoint);
+ userPoint.setVariablePoint(point);
+ userPoint.setBalance(appUser.getLavePoint());
+ userPoint.setCreateTime(LocalDateTime.now());
+ userPoint.setAppUserId(appUser.getId());
+ userPointService.save(userPoint);
+ return R.ok();
}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipSettingServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipSettingServiceImpl.java
index cd509c3..0ed0de8 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipSettingServiceImpl.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipSettingServiceImpl.java
@@ -54,78 +54,5 @@
return getVipSettingById(appUser.getVipId());
}
- @Override
- public void downUsers() {
- //查出可能需要降级的人员
- List<Integer> vipIds = new ArrayList<>();
- vipIds.add(5);
- vipIds.add(6);
- vipIds.add(7);
- List<AppUser> list = appUserService.lambdaQuery().in(AppUser::getVipId, vipIds).list();
- VipSetting vipSetting5 = vipSettingClient.getVipSetting(5).getData();
- VipSetting vipSetting6 = vipSettingClient.getVipSetting(6).getData();
- VipSetting vipSetting7 = vipSettingClient.getVipSetting(7).getData();
- LocalDate now = LocalDate.now();
- //循环判断是否要展示
- if (list.size()>0){
- for (AppUser appUser : list){
- boolean danger = false;
- if (appUser.getVipId()==5){
- extracted(vipSetting5, now,danger);
- }
- if (appUser.getVipId()==6){
- extracted(vipSetting6, now,danger);
- }
- if (appUser.getVipId()==7){
- extracted(vipSetting7, now,danger);
- }
- if (danger){
- appUser.setIsDanger(1);
- }else {
- appUser.setIsDanger(0);
- }
- }
- appUserService.updateBatchById(list);
- }
- }
- private void extracted(VipSetting vipSetting5, LocalDate now,boolean danger) {
-
- if (vipSetting5.getKeepBuyPoint()!=null){
- //如果消费不为空,查找对应天数的消费积分
- List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getType,1).ge(UserPoint::getCreateTime, now.minusDays(vipSetting5.getKeepBuyDay())).list();
- //如果消费积分小于保级积分,设置用户降级标志并将降级信息
- Integer point = 0;
- for (UserPoint userPoint : list1) {
- point = point+userPoint.getVariablePoint();
- }
- if (point<= vipSetting5.getKeepBuyPoint()){
- danger = true;
- }
- }
- if (vipSetting5.getKeepSharePoint()!=null){
- //如果消费不为空,查找对应天数的消费积分
- List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getType,2).ge(UserPoint::getCreateTime, now.minusDays(vipSetting5.getKeepBuyDay())).list();
- //如果消费积分小于保级积分,设置用户降级标志并将降级信息
- Integer point = 0;
- for (UserPoint userPoint : list1) {
- point = point+userPoint.getVariablePoint();
- }
- if (point<= vipSetting5.getKeepBuyPoint()){
- danger = true;
- }
- }
- if (vipSetting5.getKeepShopPoint()!=null){
- //如果消费不为空,查找对应天数的消费积分
- List<UserPoint> list1 = userPointService.lambdaQuery().eq(UserPoint::getType,5).ge(UserPoint::getCreateTime, now.minusDays(vipSetting5.getKeepBuyDay())).list();
- //如果消费积分小于保级积分,设置用户降级标志并将降级信息
- Integer point = 0;
- for (UserPoint userPoint : list1) {
- point = point+userPoint.getVariablePoint();
- }
- if (point<= vipSetting5.getKeepBuyPoint()){
- danger = true;
- }
- }
- }
}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/TaskUtil.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/TaskUtil.java
index 80ab125..ecbbfcc 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/TaskUtil.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/TaskUtil.java
@@ -17,9 +17,7 @@
@Resource
private AppUserService appUserService;
- @Resource
- private VipSettingService vipSettingService;
-
+
@@ -30,8 +28,8 @@
public void sendVipCoupon(){
//解绑推广人
appUserService.unbindThePromoter();
- //降级检测
- appUserService.demotionDetection();
+ //关闭充值订单
+ appUserService.closeOrder();
}
/**
@@ -40,9 +38,8 @@
@Scheduled(cron = "0 0 0 * * *")
public void taskDay(){
try {
-
-
- vipSettingService.downUsers();
+ //降级检测
+ appUserService.demotionDetection();
}catch (Exception e){
e.printStackTrace();
}
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/payment/PaymentUtil.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/payment/PaymentUtil.java
index 88ae4d1..3a31f48 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/payment/PaymentUtil.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/payment/PaymentUtil.java
@@ -7,6 +7,7 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.account.util.payment.model.*;
+import com.ruoyi.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import java.util.*;
@@ -77,7 +78,7 @@
//APPID
body.put("q7_AppId", appId);
//报备商户号
- body.put("qa_TradeMerchantNo", tradeMerchantNo);
+ body.put("qa_TradeMerchantNo", StringUtils.isNotEmpty(tradeMerchantNo) ? tradeMerchantNo : "777168500885852");
String sign = null;
try {
sign = sign(body);
@@ -252,13 +253,13 @@
- public static String sign(JSONObject body) throws Exception{
+ public static String sign(JSONObject body) {
Set<Map.Entry<String, Object>> entries = body.entrySet();
List<Map.Entry<String, Object>> infoIds = new ArrayList<Map.Entry<String, Object>>(entries);
// 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序)
Collections.sort(infoIds, new Comparator<Map.Entry<String, Object>>() {
public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) {
- return (o1.getKey()).toString().compareTo(o2.getKey());
+ return (o1.getKey()).compareTo(o2.getKey());
}
});
// 构造签名键值对的格式
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/TransferPoint.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/TransferPoint.java
new file mode 100644
index 0000000..1c2c58c
--- /dev/null
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/TransferPoint.java
@@ -0,0 +1,19 @@
+package com.ruoyi.account.vo;
+
+import lombok.Data;
+
+/**
+ * @author zhibing.pu
+ * @date 2025/1/6 15:35
+ */
+@Data
+public class TransferPoint {
+ /**
+ * 转增积分
+ */
+ private Integer point;
+ /**
+ * 手机号
+ */
+ private String phone;
+}
diff --git a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AgentApplicationMapper.xml b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AgentApplicationMapper.xml
index e408dac..a681db5 100644
--- a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AgentApplicationMapper.xml
+++ b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AgentApplicationMapper.xml
@@ -45,6 +45,7 @@
and t1.status = #{agentQuery.status}
</if>
</where>
+ order by t1.status asc
</select>
</mapper>
diff --git a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml
index 4827216..c37f93e 100644
--- a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml
+++ b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml
@@ -56,7 +56,7 @@
SELECT *
FROM t_app_user ta
<where>
- ta.del_flag = 0
+ ta.del_flag = 0 and ta.status != 3
<if test="null != appUser.name and '' != appUser.name">
and ta.`name` like CONCAT('%',#{appUser.name},'%')
</if>
@@ -73,6 +73,12 @@
and ta.shop_id in
<foreach collection="appUser.shopIds" item="shopId" open="(" separator="," close=")">
#{shopId}
+ </foreach>
+ </if>
+ <if test="null != shopId">
+ and ta.shop_id = #{shopId} or ta.id in
+ <foreach collection="userId" item="item" index="index" open="(" separator="," close=")">
+ #{item}
</foreach>
</if>
</where>
@@ -126,6 +132,14 @@
SUM(CASE WHEN tau.vip_id = 7 THEN 1 ELSE 0 END) AS partnerUser
FROM
t_app_user tau
+ <where>
+ <if test="null != shopId">
+ tau.shop_id = #{shopId} or tau.id in
+ <foreach collection="userId" item="item" index="index" open="(" separator="," close=")">
+ #{item}
+ </foreach>
+ </if>
+ </where>
</select>
<select id="getUserStatisticsDetail" resultType="com.ruoyi.account.vo.UserStatisticsDetail">
SELECT
@@ -142,8 +156,14 @@
FROM
t_app_user tau
<where>
- <if test="null != userName and '' != userName">
- and tau.id = #{userId}
+ <if test="null != shopId">
+ tau.shop_id = #{shopId} or
+ </if>
+ <if test="null != userId and userId.size() > 0">
+ tau.id in
+ <foreach collection="userId" item="item" index="index" open="(" separator="," close=")">
+ #{item}
+ </foreach>
</if>
</where>
</select>
diff --git a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserCancellationLogMapper.xml b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserCancellationLogMapper.xml
index 9f83d27..5ed212a 100644
--- a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserCancellationLogMapper.xml
+++ b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserCancellationLogMapper.xml
@@ -20,11 +20,11 @@
from t_user_cancellation_log t1
left join t_app_user t2 on t1.app_user_id = t2.id
<where>
- <if test="agentQuery.name != null and agentQuery.name != ''">
- and t2.name like concat('%',#{agentQuery.name},'%')
+ <if test="agentQuery.userName != null and agentQuery.userName != ''">
+ and t2.name like concat('%',#{agentQuery.userName},'%')
</if>
- <if test="agentQuery.phone != null and agentQuery.phone != ''">
- and t2.phone like concat('%',#{agentQuery.phone},'%')
+ <if test="agentQuery.userPhone != null and agentQuery.userPhone != ''">
+ and t2.phone like concat('%',#{agentQuery.userPhone},'%')
</if>
<if test="agentQuery.vipId != null">
and t1.vip_id = #{agentQuery.vipId}
diff --git a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserClickLogMapper.xml b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserClickLogMapper.xml
index 0fcc57d..5f8608f 100644
--- a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserClickLogMapper.xml
+++ b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserClickLogMapper.xml
@@ -37,6 +37,7 @@
and DATE(t1.create_time) between #{agentQuery.localDate1} and #{agentQuery.localDate2}
</if>
</where>
+ order by t1.create_time desc
</select>
</mapper>
diff --git a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/WithdrawalRequestsMapper.xml b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/WithdrawalRequestsMapper.xml
index ddfb739..d5943b6 100644
--- a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/WithdrawalRequestsMapper.xml
+++ b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/WithdrawalRequestsMapper.xml
@@ -23,7 +23,7 @@
select t1.*,t2.name as userName,t2.phone as userPhone
from t_withdrawal_requests t1
left join t_app_user t2 on t1.app_user_id = t2.id
-
+ order by t1.create_time desc
</select>
</mapper>
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
index 25fc793..bd94f8a 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -16,23 +16,26 @@
import com.ruoyi.order.model.Order;
import com.ruoyi.order.service.CommissionService;
import com.ruoyi.order.service.OrderService;
+import com.ruoyi.order.util.payment.model.RefundCallbackResult;
import com.ruoyi.order.vo.*;
import com.ruoyi.other.api.domain.BaseSetting;
import com.ruoyi.other.api.feignClient.BaseSettingClient;
+import com.ruoyi.system.api.domain.SysUser;
+import com.ruoyi.system.api.feignClient.SysUserClient;
import com.ruoyi.system.api.model.LoginUser;
import io.swagger.annotations.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -59,6 +62,8 @@
private BaseSettingClient baseSettingClient;
@Resource
private OrderMapper orderMapper;
+ @Resource
+ private SysUserClient sysUserClient;
/**
@@ -115,11 +120,11 @@
*/
@ApiOperation(value = "订单核销", tags = {"小程序-个人中心-门店管理"})
@ApiImplicitParams({
- @ApiImplicitParam(value = "订单号", name = "code", required = true, dataType = "String"),
+ @ApiImplicitParam(value = "订单id", name = "id", required = true, dataType = "String"),
})
- @GetMapping("/writeOff/{code}/{shopId}")
- public R<Void> writeOff(@PathVariable("code") String code, @PathVariable("shopId") Integer shopId){
- orderService.writeOff(code, shopId);
+ @GetMapping("/writeOff/{id}/{shopId}")
+ public R<Void> writeOff(@PathVariable("id") String id, @PathVariable("shopId") Integer shopId){
+ orderService.writeOff(id, shopId);
return R.ok();
}
@@ -131,11 +136,8 @@
@ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
})
@GetMapping("/cancel/{orderId}")
- public R<Void> cancel(@PathVariable("orderId") Long orderId){
- orderService.update(new LambdaUpdateWrapper<Order>()
- .eq(Order::getId, orderId)
- .set(Order::getOrderStatus, OrderStatus.CANCELLED.getCode()));
- return R.ok();
+ public R cancel(@PathVariable("orderId") Long orderId){
+ return orderService.cancel(orderId);
}
/**
@@ -277,7 +279,9 @@
public R<OrderStatistics> getOrderStatistics(@RequestParam("startTime") String startTime,
@RequestParam("endTime") String endTime){
- List<Order> orderList = orderService.list(new LambdaQueryWrapper<Order>()
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser sysUser = sysUserClient.getSysUser(userid).getData();
+ List<Order> orderList = orderService.list(new LambdaQueryWrapper<Order>().eq(sysUser.getRoleType() == 2, Order::getShopId, sysUser.getObjectId())
.between(Order::getCreateTime, LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))));
@@ -310,7 +314,11 @@
orderStatisticsDetail.setTotal(total);
orderStatisticsDetails.add(orderStatisticsDetail);
});
- OrderStatistics orderStatistics = orderMapper.getOrderStatistics(startTime, endTime);
+ Integer shopId = null;
+ if(sysUser.getRoleType() == 2){
+ shopId = sysUser.getObjectId();
+ }
+ OrderStatistics orderStatistics = orderMapper.getOrderStatistics(startTime, endTime, shopId);
if(null != orderStatistics){
orderStatistics.setOrderStatisticsDetailList(orderStatisticsDetails);
}
@@ -318,5 +326,91 @@
}
+ /**
+ * 订单取消支付回退
+ * @param refundCallbackResult
+ * @param response
+ * @return
+ */
+ @ResponseBody
+ @GetMapping("/refundPayMoneyCallback")
+ public void refundPayMoneyCallback(RefundCallbackResult refundCallbackResult, HttpServletResponse response){
+ R callback = orderService.refundPayMoneyCallback(refundCallbackResult);
+ if(callback.getCode() == 200){
+ response.setStatus(200);
+ PrintWriter out = null;
+ try {
+ out = response.getWriter();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ out.println("success");
+ out.flush();
+ out.close();
+ }
+ }
+
+
+ /**
+ * 取消订单快递费回退
+ * @param refundCallbackResult
+ * @param response
+ */
+ @ResponseBody
+ @GetMapping("/refundExpressPayMoneyCallback")
+ public void refundExpressPayMoneyCallback(RefundCallbackResult refundCallbackResult, HttpServletResponse response){
+ R callback = orderService.refundExpressPayMoneyCallback(refundCallbackResult);
+ if(callback.getCode() == 200){
+ response.setStatus(200);
+ PrintWriter out = null;
+ try {
+ out = response.getWriter();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ out.println("success");
+ out.flush();
+ out.close();
+ }
+ }
+
+
+ /**
+ * 获取商品销售数量
+ * @param goodsId
+ * @return
+ */
+ @PostMapping("/getGoodsSaleNum")
+ public R<Integer> getGoodsSaleNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("type") Integer type){
+ Integer goodsSaleNum = orderService.getGoodsSaleNum(goodsId, type);
+ return R.ok(goodsSaleNum);
+ }
+
+
+
+ /**
+ * 获取门店销售订单数量
+ * @param shopId 门店id
+ * @param type 1:服务订单,2:单品订单
+ * @return
+ */
+ @PostMapping("/getShopSaleNum")
+ public R<Integer> getShopSaleNum(@RequestParam("shopId") Integer shopId, @RequestParam("type") Integer type){
+ Integer shopSaleNum = orderService.getShopSaleNum(shopId, type);
+ return R.ok(shopSaleNum);
+ }
+
+
+ /**
+ * 获取所有在指定门店消费的用户id
+ * @param shopId
+ * @return
+ */
+ @PostMapping("/getAppUserByShoppingShop")
+ public R<Set<Long>> getAppUserByShoppingShop(@RequestParam("shopId") Integer shopId){
+ List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getShopId, shopId).eq(Order::getDelFlag, 0).eq(Order::getPayStatus, 2).in(Order::getOrderStatus, Arrays.asList(1, 2, 3, 4, 7, 8)));
+ Set<Long> collect = list.stream().map(Order::getAppUserId).collect(Collectors.toSet());
+ return R.ok(collect);
+ }
}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java
index da51645..8083049 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java
@@ -169,7 +169,7 @@
@GetMapping("/getGoodsPrice")
public R<Price> getGoodsPrice(Long appUserId, Integer goodsId, Integer shopId){
AppUser appUser = appUserClient.getAppUserById(appUserId);
- Price price = shoppingCartService.getPrice(appUser, goodsId, shopId);
+ Price price = shoppingCartService.getPrice(appUser, goodsId, 1, shopId);
return R.ok(price);
}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java
index 6b07b2a..47f8d47 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java
@@ -35,5 +35,22 @@
List<OrderPageListVo> getOrderPageList(PageInfo<OrderPageListVo> pageInfo, @Param("item") OrderPageList orderPageList);
OrderStatistics getOrderStatistics(@Param("startTime")String startTime,
- @Param("endTime") String endTime);
+ @Param("endTime") String endTime, @Param("shopId") Integer shopId);
+
+
+ /**
+ * 获取商品销售数量
+ * @param goodsId
+ * @return
+ */
+ Integer getGoodsSaleNum(@Param("goodsId") Integer goodsId, @Param("type") Integer type);
+
+
+ /**
+ * 获取店铺订单数量
+ * @param shopId
+ * @param type
+ * @return
+ */
+ Integer getShopSaleNum(@Param("shopId") Integer shopId, @Param("type") Integer type);
}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java
index 0d0cb47..b13d923 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java
@@ -4,7 +4,9 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.order.model.Order;
+import com.ruoyi.order.util.payment.model.RefundCallbackResult;
import com.ruoyi.order.vo.*;
+import org.omg.CORBA.INTERNAL;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.List;
@@ -24,7 +26,7 @@
boolean check(Order order, Integer shopId, Long userId);
- void writeOff(String code,Integer shopId);
+ void writeOff(String id,Integer shopId);
/**
@@ -33,7 +35,13 @@
* @return
*/
PageInfo<OrderPageListVo> getOrderPageList(OrderPageList orderPageList);
-
+
+ /**
+ * 小程序取消订单
+ * @param orderId
+ * @return
+ */
+ R cancel(Long orderId);
/**
* 确认发货操作
@@ -56,9 +64,22 @@
* 返回订单支付金额和回退积分和会员等级
* @param order
*/
- void refundPayMoney(Order order);
-
-
+ R refundPayMoney(Order order);
+
+ /**
+ * 取消订单后回调处理
+ * @return
+ */
+ R refundPayMoneyCallback(RefundCallbackResult refundCallbackResult);
+
+
+ /**
+ * 取消订单快递费回退
+ * @return
+ */
+ R refundExpressPayMoneyCallback(RefundCallbackResult refundCallbackResult);
+
+
/**
* 收货操作
* @param orderId
@@ -73,4 +94,20 @@
* @return
*/
OrderInfoVo getOrderInfo(Long orderId);
+
+ /**
+ * 获取商品销售数量
+ * @param goodsId
+ * @return
+ */
+ Integer getGoodsSaleNum(Integer goodsId, Integer type);
+
+
+ /**
+ * 获取店铺订单数量
+ * @param shopId
+ * @param type
+ * @return
+ */
+ Integer getShopSaleNum(Integer shopId, Integer type);
}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/ShoppingCartService.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/ShoppingCartService.java
index 716921a..5fdd626 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/ShoppingCartService.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/ShoppingCartService.java
@@ -66,7 +66,7 @@
R shoppingCartMaterialFlowPaymentCallback(UniPayCallbackResult uniPayCallbackResult);
- Price getPrice(AppUser appUser, Integer goodsId, Integer shopId);
+ Price getPrice(AppUser appUser, Integer goodsId, Integer type, Integer shopId);
/**
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java
index 3926014..bad6bc9 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java
@@ -58,16 +58,13 @@
@Transactional(rollbackFor = Exception.class)
public void calculationCommission() {
List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getIsCommission, 0).isNotNull(Order::getAfterSaleTime)
- .eq(Order::getDelFlag, 0).last(" and after_sale_time <= now()"));
+ .eq(Order::getDelFlag, 0).ne(Order::getPayMethod, 3).last(" and after_sale_time <= now()"));
List<Long> collect = list.stream().map(Order::getId).collect(Collectors.toList());
if(collect.size() == 0){
return;
}
for (Order order : list) {
- if(order.getPayMethod() == 3){
- continue;
- }
List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>()
.eq(OrderGood::getOrderId, order.getId()));
AppUser appUser = appUserClient.getAppUserById(order.getAppUserId());
@@ -143,61 +140,64 @@
bdmdsj_point += orderGood.getBoundShopSuperiorsPoints();
}
//直推上级
- AppUser inviteUser = appUserClient.getAppUserById(appUser.getInviteUserId());
- if(null != inviteUser){
- BigDecimal balance = inviteUser.getBalance();
- Integer lavePoint = inviteUser.getLavePoint();
- if(ztsj_price.compareTo(BigDecimal.ZERO) > 0){
- inviteUser.setTotalDistributionAmount(inviteUser.getTotalDistributionAmount().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
- inviteUser.setBalance(inviteUser.getBalance().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
- inviteUser.setWithdrawableAmount(inviteUser.getWithdrawableAmount().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
- }
- if(ztsj_point > 0){
- PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
- int earnPoint1 = 0;
- //计算可用积分比例
- if(null != pointSetting && 1 == pointSetting.getSharePointOpen()){
- earnPoint1 = new BigDecimal(ztsj_point).multiply(pointSetting.getSharePoint().divide(new BigDecimal(100))).intValue();
+ if(null != appUser.getInviteUserId()){
+ AppUser inviteUser = appUserClient.getAppUserById(appUser.getInviteUserId());
+ if(null != inviteUser){
+ BigDecimal balance = inviteUser.getBalance();
+ Integer lavePoint = inviteUser.getLavePoint();
+ if(ztsj_price.compareTo(BigDecimal.ZERO) > 0){
+ inviteUser.setTotalDistributionAmount(inviteUser.getTotalDistributionAmount().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
+ inviteUser.setBalance(inviteUser.getBalance().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
+ inviteUser.setWithdrawableAmount(inviteUser.getWithdrawableAmount().add(ztsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
}
- inviteUser.setSharePoint(inviteUser.getSharePoint() + ztsj_point);
- inviteUser.setLavePoint(inviteUser.getLavePoint() + ztsj_point);
- inviteUser.setAvailablePoint(inviteUser.getAvailablePoint() + earnPoint1);
- inviteUser.setTotalAvailablePoint(inviteUser.getTotalAvailablePoint() + earnPoint1);
- if(null != pointSetting && 1 == pointSetting.getSharePointGift()){
- inviteUser.setTransferablePoint(inviteUser.getTransferablePoint() + earnPoint1);
+ if(ztsj_point > 0){
+ PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
+ int earnPoint1 = 0;
+ //计算可用积分比例
+ if(null != pointSetting && 1 == pointSetting.getSharePointOpen()){
+ earnPoint1 = new BigDecimal(ztsj_point).multiply(pointSetting.getSharePoint().divide(new BigDecimal(100))).intValue();
+ }
+ inviteUser.setSharePoint(inviteUser.getSharePoint() + ztsj_point);
+ inviteUser.setLavePoint(inviteUser.getLavePoint() + ztsj_point);
+ inviteUser.setAvailablePoint(inviteUser.getAvailablePoint() + earnPoint1);
+ inviteUser.setTotalAvailablePoint(inviteUser.getTotalAvailablePoint() + earnPoint1);
+ if(null != pointSetting && 1 == pointSetting.getSharePointGift()){
+ inviteUser.setTransferablePoint(inviteUser.getTransferablePoint() + earnPoint1);
+ }
+ inviteUser.setTotalPoint(inviteUser.getTotalPoint() + ztsj_point);
}
- inviteUser.setTotalPoint(inviteUser.getTotalPoint() + ztsj_point);
- }
- appUserClient.editAppUserById(inviteUser);
- //添加明细记录
- if(!inviteUser.getBalance().equals(balance)){
- BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord();
- balanceChangeRecord.setAppUserId(inviteUser.getId());
- balanceChangeRecord.setOrderId(order.getId());
- balanceChangeRecord.setChangeType(4);
- balanceChangeRecord.setBeforeAmount(balance);
- balanceChangeRecord.setChangeAmount(ztsj_price);
- balanceChangeRecord.setAfterAmount(inviteUser.getBalance());
- balanceChangeRecord.setDelFlag(0);
- balanceChangeRecord.setCreateTime(LocalDateTime.now());
- balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord);
- }
- //添加积分明细
- if(!inviteUser.getLavePoint().equals(lavePoint)){
- UserPoint userPoint = new UserPoint();
- userPoint.setType(2);
- userPoint.setHistoricalPoint(lavePoint);
- userPoint.setVariablePoint(ztsj_point);
- userPoint.setBalance(inviteUser.getLavePoint());
- userPoint.setCreateTime(LocalDateTime.now());
- userPoint.setAppUserId(inviteUser.getId());
- userPoint.setObjectId(order.getId());
- userPoint.setExtention(order.getOrderNumber());
- userPointClient.saveUserPoint(userPoint);
- //变更等级
- appUserClient.vipUpgrade(inviteUser.getId());
+ appUserClient.editAppUserById(inviteUser);
+ //添加明细记录
+ if(!inviteUser.getBalance().equals(balance)){
+ BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord();
+ balanceChangeRecord.setAppUserId(inviteUser.getId());
+ balanceChangeRecord.setOrderId(order.getId());
+ balanceChangeRecord.setChangeType(4);
+ balanceChangeRecord.setBeforeAmount(balance);
+ balanceChangeRecord.setChangeAmount(ztsj_price);
+ balanceChangeRecord.setAfterAmount(inviteUser.getBalance());
+ balanceChangeRecord.setDelFlag(0);
+ balanceChangeRecord.setCreateTime(LocalDateTime.now());
+ balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord);
+ }
+ //添加积分明细
+ if(!inviteUser.getLavePoint().equals(lavePoint)){
+ UserPoint userPoint = new UserPoint();
+ userPoint.setType(2);
+ userPoint.setHistoricalPoint(lavePoint);
+ userPoint.setVariablePoint(ztsj_point);
+ userPoint.setBalance(inviteUser.getLavePoint());
+ userPoint.setCreateTime(LocalDateTime.now());
+ userPoint.setAppUserId(inviteUser.getId());
+ userPoint.setObjectId(order.getId());
+ userPoint.setExtention(order.getOrderNumber());
+ userPointClient.saveUserPoint(userPoint);
+ //变更等级
+ appUserClient.vipUpgrade(inviteUser.getId());
+ }
}
}
+
//直帮上级
AppUser superiorLeader = appUserClient.getSuperiorLeader(appUser.getId()).getData();
if(null != superiorLeader){
@@ -461,93 +461,93 @@
}
//上级门店分佣
- Integer pid = shop1.getPid();
- Shop shop2 = shopClient.getShopById(pid).getData();
- if(null != shop2){
- AppUser sjShopAppUser = appUserClient.getAppUserById(shop2.getAppUserId());
- if(null != sjShopAppUser){
- BigDecimal shopBalance = shop2.getBalance();
- Integer lavePoint = sjShopAppUser.getLavePoint();
- Integer shopLavePoint = shop2.getLavePoint();
- if(bdmdsj_price.compareTo(BigDecimal.ZERO) > 0){
- //门店返佣
- shop2.setGiveawayAllMoney(shop2.getGiveawayAllMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
- shop2.setLowerLevelGiveawayMoney(shop2.getLowerLevelGiveawayMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
- shop2.setCanWithdrawMoney(shop2.getCanWithdrawMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
- shop2.setBalance(shop2.getBalance().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
- }
- if(bdmdsj_point > 0){
- PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
- int earnPoint1 = 0;
- //计算可用积分比例
- if(null != pointSetting && 1 == pointSetting.getShopSharePointOpen()){
- earnPoint1 = new BigDecimal(bdmdsj_point).multiply(pointSetting.getShopSharePoint().divide(new BigDecimal(100))).intValue();
+ if(null != shop1){
+ Integer pid = shop1.getPid();
+ Shop shop2 = shopClient.getShopById(pid).getData();
+ if(null != shop2){
+ AppUser sjShopAppUser = appUserClient.getAppUserById(shop2.getAppUserId());
+ if(null != sjShopAppUser){
+ BigDecimal shopBalance = shop2.getBalance();
+ Integer lavePoint = sjShopAppUser.getLavePoint();
+ Integer shopLavePoint = shop2.getLavePoint();
+ if(bdmdsj_price.compareTo(BigDecimal.ZERO) > 0){
+ //门店返佣
+ shop2.setGiveawayAllMoney(shop2.getGiveawayAllMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
+ shop2.setLowerLevelGiveawayMoney(shop2.getLowerLevelGiveawayMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
+ shop2.setCanWithdrawMoney(shop2.getCanWithdrawMoney().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
+ shop2.setBalance(shop2.getBalance().add(bdmdsj_price).setScale(2, BigDecimal.ROUND_HALF_EVEN));
}
- sjShopAppUser.setLavePoint(sjShopAppUser.getLavePoint() + bdmdsj_point);
- sjShopAppUser.setAvailablePoint(sjShopAppUser.getAvailablePoint() + earnPoint1);
- sjShopAppUser.setTotalAvailablePoint(sjShopAppUser.getTotalAvailablePoint() + earnPoint1);
- if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){
- sjShopAppUser.setTransferablePoint(sjShopAppUser.getTransferablePoint() + earnPoint1);
+ if(bdmdsj_point > 0){
+ PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
+ int earnPoint1 = 0;
+ //计算可用积分比例
+ if(null != pointSetting && 1 == pointSetting.getShopSharePointOpen()){
+ earnPoint1 = new BigDecimal(bdmdsj_point).multiply(pointSetting.getShopSharePoint().divide(new BigDecimal(100))).intValue();
+ }
+ sjShopAppUser.setLavePoint(sjShopAppUser.getLavePoint() + bdmdsj_point);
+ sjShopAppUser.setAvailablePoint(sjShopAppUser.getAvailablePoint() + earnPoint1);
+ sjShopAppUser.setTotalAvailablePoint(sjShopAppUser.getTotalAvailablePoint() + earnPoint1);
+ if(null != pointSetting && 1 == pointSetting.getShopSharePointGift()){
+ sjShopAppUser.setTransferablePoint(sjShopAppUser.getTransferablePoint() + earnPoint1);
+ }
+ sjShopAppUser.setTotalPoint(sjShopAppUser.getTotalPoint() + bdmdsj_point);
+ sjShopAppUser.setLowerLevelSharePoint(sjShopAppUser.getLowerLevelSharePoint() + bdmdsj_point);
+ //门店返佣
+ shop2.setShopAllPoint(shop2.getShopAllPoint() + bdmdsj_point);
+ shop2.setLowerLevelSharePoint(shop2.getLowerLevelSharePoint() + bdmdsj_point);
+ shop2.setLavePoint(shop2.getLavePoint() + bdmdsj_point);
}
- sjShopAppUser.setTotalPoint(sjShopAppUser.getTotalPoint() + bdmdsj_point);
- sjShopAppUser.setLowerLevelSharePoint(sjShopAppUser.getLowerLevelSharePoint() + bdmdsj_point);
- //门店返佣
- shop2.setShopAllPoint(shop2.getShopAllPoint() + bdmdsj_point);
- shop2.setLowerLevelSharePoint(shop2.getLowerLevelSharePoint() + bdmdsj_point);
- shop2.setLavePoint(shop2.getLavePoint() + bdmdsj_point);
- }
- appUserClient.editAppUserById(sjShopAppUser);
- shopClient.updateShop(shop2);
- //添加明细记录
- if(!shop2.getBalance().equals(shopBalance)){
- ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement();
- shopBalanceStatement.setShopId(shop2.getId());
- shopBalanceStatement.setType(2);
- shopBalanceStatement.setHistoricalBalance(shopBalance);
- shopBalanceStatement.setVariableAmount(bdmdsj_price);
- shopBalanceStatement.setBalance(shop2.getBalance());
- shopBalanceStatement.setCreateTime(LocalDateTime.now());
- shopBalanceStatement.setCreateUserId(order.getAppUserId());
- shopBalanceStatement.setObjectId(order.getId());
- shopBalanceStatement.setExtension(order.getOrderNumber());
- shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement);
- }
- //添加积分明细
- if(!sjShopAppUser.getLavePoint().equals(lavePoint)){
- UserPoint userPoint = new UserPoint();
- userPoint.setType(14);
- userPoint.setHistoricalPoint(lavePoint);
- userPoint.setVariablePoint(bdmdsj_point);
- userPoint.setBalance(sjShopAppUser.getLavePoint());
- userPoint.setCreateTime(LocalDateTime.now());
- userPoint.setAppUserId(sjShopAppUser.getId());
- userPoint.setObjectId(order.getId());
- userPoint.setExtention(order.getOrderNumber());
- userPointClient.saveUserPoint(userPoint);
- //变更等级
- appUserClient.vipUpgrade(sjShopAppUser.getId());
- }
-
- if(!shop2.getLavePoint().equals(shopLavePoint)){
- ShopPoint shopPoint = new ShopPoint();
- shopPoint.setShopId(shop2.getId());
- shopPoint.setType(3);
- shopPoint.setHistoricalPoint(shopLavePoint);
- shopPoint.setVariablePoint(bdmdsj_point);
- shopPoint.setBalance(shop2.getLavePoint());
- shopPoint.setCreateTime(LocalDateTime.now());
- shopPoint.setCreateUserId(order.getAppUserId());
- shopPoint.setObjectId(order.getId());
- shopPoint.setOrderNum(order.getOrderNumber());
- shopPointClient.saveShopPoint(shopPoint);
+ appUserClient.editAppUserById(sjShopAppUser);
+ shopClient.updateShop(shop2);
+ //添加明细记录
+ if(!shop2.getBalance().equals(shopBalance)){
+ ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement();
+ shopBalanceStatement.setShopId(shop2.getId());
+ shopBalanceStatement.setType(2);
+ shopBalanceStatement.setHistoricalBalance(shopBalance);
+ shopBalanceStatement.setVariableAmount(bdmdsj_price);
+ shopBalanceStatement.setBalance(shop2.getBalance());
+ shopBalanceStatement.setCreateTime(LocalDateTime.now());
+ shopBalanceStatement.setCreateUserId(order.getAppUserId());
+ shopBalanceStatement.setObjectId(order.getId());
+ shopBalanceStatement.setExtension(order.getOrderNumber());
+ shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement);
+ }
+ //添加积分明细
+ if(!sjShopAppUser.getLavePoint().equals(lavePoint)){
+ UserPoint userPoint = new UserPoint();
+ userPoint.setType(14);
+ userPoint.setHistoricalPoint(lavePoint);
+ userPoint.setVariablePoint(bdmdsj_point);
+ userPoint.setBalance(sjShopAppUser.getLavePoint());
+ userPoint.setCreateTime(LocalDateTime.now());
+ userPoint.setAppUserId(sjShopAppUser.getId());
+ userPoint.setObjectId(order.getId());
+ userPoint.setExtention(order.getOrderNumber());
+ userPointClient.saveUserPoint(userPoint);
+ //变更等级
+ appUserClient.vipUpgrade(sjShopAppUser.getId());
+ }
+
+ if(!shop2.getLavePoint().equals(shopLavePoint)){
+ ShopPoint shopPoint = new ShopPoint();
+ shopPoint.setShopId(shop2.getId());
+ shopPoint.setType(3);
+ shopPoint.setHistoricalPoint(shopLavePoint);
+ shopPoint.setVariablePoint(bdmdsj_point);
+ shopPoint.setBalance(shop2.getLavePoint());
+ shopPoint.setCreateTime(LocalDateTime.now());
+ shopPoint.setCreateUserId(order.getAppUserId());
+ shopPoint.setObjectId(order.getId());
+ shopPoint.setOrderNum(order.getOrderNumber());
+ shopPointClient.saveShopPoint(shopPoint);
+ }
}
}
}
+
order.setIsCommission(1);
orderService.updateById(order);
}
-
-
-
}
}
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 e3bc81d..7265e26 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;
@@ -20,10 +21,15 @@
import com.ruoyi.order.model.Order;
import com.ruoyi.order.model.OrderBalancePayment;
import com.ruoyi.order.model.OrderGood;
+import com.ruoyi.order.model.RefundPass;
import com.ruoyi.order.service.CommissionService;
import com.ruoyi.order.service.OrderBalancePaymentService;
import com.ruoyi.order.service.OrderService;
+import com.ruoyi.order.service.RefundPassService;
import com.ruoyi.order.util.ExpressDeliveryUtil;
+import com.ruoyi.order.util.payment.PaymentUtil;
+import com.ruoyi.order.util.payment.model.RefundCallbackResult;
+import com.ruoyi.order.util.payment.model.RefundResult;
import com.ruoyi.order.util.vo.QueryKD100Vo;
import com.ruoyi.order.vo.*;
import com.ruoyi.other.api.domain.*;
@@ -89,6 +95,9 @@
@Resource
private GoodsClient goodsClient;
+
+ @Resource
+ private RefundPassService refundPassService;
@@ -222,10 +231,9 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public void writeOff(String code,Integer shopId) {
+ public void writeOff(String id,Integer shopId) {
LoginUser loginUserApplet = tokenService.getLoginUserApplet();
- Order order = orderMapper.selectOne(new LambdaQueryWrapper<Order>()
- .eq(Order::getId, code));
+ Order order = orderMapper.selectById(id);
boolean check = check(order, shopId, loginUserApplet.getUserid());
if (!check){
throw new ServiceException("订单不存在");
@@ -294,13 +302,46 @@
for (OrderPageListVo orderPageListVo : list) {
Long appUserId = orderPageListVo.getAppUserId();
AppUser appUser = appUserClient.getAppUserById(appUserId);
- orderPageListVo.setUserName(appUser.getName());
- orderPageListVo.setPhone(appUser.getPhone());
+ if(null != appUser){
+ 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(null != order.getAfterSaleTime() && 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
@@ -338,10 +379,15 @@
if(Arrays.asList(5, 6, 7).contains(order.getOrderStatus())){
return R.fail("无效的操作");
}
+ if(LocalDateTime.now().isAfter(order.getAfterSaleTime())){
+ return R.fail("订单取消失败");
+ }
order.setOrderStatus(5);
- this.updateById(order);
- refundPayMoney(order);
- return R.ok();
+ R r = refundPayMoney(order);
+ if(200 == r.getCode()){
+ this.updateById(order);
+ }
+ return r;
}
@@ -349,13 +395,20 @@
* 返回订单支付金额和回退积分和会员等级
* @param order
*/
- public void refundPayMoney(Order order){
+ public R refundPayMoney(Order order){
//开始退款
Integer payMethod = order.getPayMethod();
BigDecimal paymentAmount = order.getPaymentAmount();
AppUser appUser = appUserClient.getAppUserById(order.getAppUserId());
if(1 == payMethod){
//微信退款
+ RefundResult refund = PaymentUtil.refund(order.getOrderNumber(), "R" + order.getOrderNumber(), paymentAmount.doubleValue(), "/order/order/refundPayMoneyCallback");
+ if("100".equals(refund.getRa_Status())){
+ order.setRefundStatus(1);
+ return R.ok();
+ }else{
+ return R.fail(refund.getRc_CodeMsg());
+ }
}
if(2 == payMethod){
//余额退款
@@ -367,6 +420,13 @@
}
appUser.setBalance(balance.add(paymentAmount).setScale(2, RoundingMode.HALF_EVEN));
appUser.setShopAmount(appUser.getShopAmount().subtract(paymentAmount).setScale(2, RoundingMode.HALF_EVEN));
+ //查询最后一次的消费订单
+ Order order1 = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getAppUserId, order.getAppUserId()).eq(Order::getPayStatus, 2).eq(Order::getDelFlag, 0).in(Order::getOrderStatus, Arrays.asList(2, 3, 4, 8)).ne(Order::getId, order.getId()).last(" order by create_time desc limit 0, 1"));
+ if(null != order1){
+ appUser.setLastShopTime(order1.getCreateTime());
+ }else{
+ appUser.setLastShopTime(LocalDateTime.MIN);
+ }
//构建账户余额流水明细
BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord();
@@ -380,23 +440,28 @@
balanceChangeRecord.setCreateTime(LocalDateTime.now());
balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord);
}
- Integer lavePoint = appUser.getLavePoint();
if(3 == payMethod){
- //积分退款
- appUser.setLavePoint(appUser.getLavePoint() + order.getPoint());
-
//开始运费退款,积分支付,运费是单独进行支付的,所以需要单独退款
if(null != order.getExpressAmount() && BigDecimal.ZERO.compareTo(order.getExpressAmount()) < 0){
BigDecimal expressAmount = order.getExpressAmount();
if(1 == order.getExpressPayMethod()){
//微信退款
+ RefundResult refund = PaymentUtil.refund(order.getOrderNumber(), "R" + order.getOrderNumber(), expressAmount.doubleValue(), "/order/order/refundExpressPayMoneyCallback");
+ if("100".equals(refund.getRa_Status())){
+ order.setRefundStatus(1);
+ return R.ok();
+ }else{
+ return R.fail(refund.getRc_CodeMsg());
+ }
}
if(2 == order.getExpressPayMethod()){
//余额退款
OrderBalancePayment orderBalancePayment = orderBalancePaymentService.getOne(new LambdaQueryWrapper<OrderBalancePayment>().eq(OrderBalancePayment::getOrderId, order.getId()));
BigDecimal balance = appUser.getBalance();
- appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN));
- appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN));
+ if(null != orderBalancePayment){
+ appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN));
+ appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN));
+ }
appUser.setBalance(balance.add(expressAmount).setScale(2, RoundingMode.HALF_EVEN));
//构建账户余额流水明细
BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord();
@@ -411,38 +476,209 @@
balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord);
}
}
+
+ Integer lavePoint = appUser.getLavePoint();
+ //积分退款
+ appUser.setLavePoint(appUser.getLavePoint() + order.getPoint());
+ appUser.setAvailablePoint(appUser.getAvailablePoint() + order.getPoint());
+ UserPoint userPoint1 = new UserPoint();
+ userPoint1.setType(11);
+ userPoint1.setObjectId(order.getId());
+ List<UserPoint> data = userPointClient.getUserPointList(userPoint1).getData();
+ Integer transferablePoint = order.getPoint();
+ if(data.size() > 0){
+ UserPoint userPoint = data.get(0);
+ transferablePoint = Integer.valueOf(userPoint.getExtention());
+ }
+ appUser.setTransferablePoint(appUser.getTransferablePoint() + transferablePoint);
+
+ //构建积分流水明细
+ UserPoint userPoint = new UserPoint();
+ userPoint.setType(11);
+ userPoint.setHistoricalPoint(lavePoint);
+ userPoint.setVariablePoint(order.getPoint());
+ userPoint.setBalance(appUser.getLavePoint());
+ userPoint.setCreateTime(LocalDateTime.now());
+ userPoint.setAppUserId(order.getAppUserId());
+ userPoint.setObjectId(order.getId());
+ userPointClient.saveUserPoint(userPoint);
}
//退回获得的消费积分
//需要先检查会员等级时候回回退,使用回退后的会员等级查询配置
+ Integer lavePoint = appUser.getLavePoint();
Integer getPoint = order.getGetPoint();
boolean vipDemotion = vipDemotion(appUser.getShopPoint() - getPoint, appUser.getVipId());
PointSetting pointSetting = pointSettingClient.getPointSetting(vipDemotion ? appUser.getVipId() - 1 : appUser.getVipId()).getData();
- int earnPoint1 = getPoint;
+ int earnPoint1 = 0;
if(null != pointSetting && 1 == pointSetting.getBuyPointOpen()){
earnPoint1 = new BigDecimal(getPoint).divide(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue();
}
- appUser.setLavePoint(lavePoint - getPoint);
- appUser.setShopPoint(appUser.getShopPoint() - earnPoint1);
- appUser.setTotalPoint(appUser.getTotalPoint() - earnPoint1);
+ appUser.setShopPoint(appUser.getShopPoint() - getPoint);
+ appUser.setLavePoint(appUser.getLavePoint() - getPoint);
+ appUser.setAvailablePoint(appUser.getAvailablePoint() - earnPoint1);
+ appUser.setTotalAvailablePoint(appUser.getTotalAvailablePoint() - earnPoint1);
+ if(null != pointSetting && 1 == pointSetting.getBuyPointGift()){
+ appUser.setTransferablePoint(appUser.getTransferablePoint() - earnPoint1);
+ }
+ appUser.setTotalPoint(appUser.getTotalPoint() - getPoint);
if(vipDemotion){
appUser.setVipId(appUser.getVipId() - 1);
}
+
//构建积分流水明细
UserPoint userPoint = new UserPoint();
- userPoint.setType(11);
+ userPoint.setType(1);
userPoint.setHistoricalPoint(lavePoint);
- Integer point = appUser.getLavePoint() - lavePoint;
- userPoint.setVariablePoint(point >= 0 ? point : point * -1);
+ userPoint.setVariablePoint(getPoint);
userPoint.setBalance(appUser.getLavePoint());
userPoint.setCreateTime(LocalDateTime.now());
userPoint.setAppUserId(order.getAppUserId());
userPoint.setObjectId(order.getId());
userPointClient.saveUserPoint(userPoint);
appUserClient.editAppUserById(appUser);
+
+ order.setRefundStatus(2);
+ order.setRefundTime(LocalDateTime.now());
+ return R.ok();
}
-
-
-
+
+
+ /**
+ * 取消订单后回调处理
+ * @return
+ */
+ @Override
+ public R refundPayMoneyCallback(RefundCallbackResult refundCallbackResult) {
+ String code = refundCallbackResult.getR3_RefundOrderNo().substring(1);
+ Order order = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, code));
+ if(null == order || order.getPayStatus() == 1 || order.getOrderStatus() == 6){
+ return R.ok();
+ }
+ order.setRefundCode(refundCallbackResult.getR5_RefundTrxNo());
+ order.setRefundStatus(2);
+ order.setRefundTime(LocalDateTime.now());
+ this.updateById(order);
+
+ //退回获得的消费积分
+ //需要先检查会员等级时候回回退,使用回退后的会员等级查询配置
+ AppUser appUser = appUserClient.getAppUserById(order.getAppUserId());
+ Integer lavePoint = appUser.getLavePoint();
+ Integer getPoint = order.getGetPoint();
+ boolean vipDemotion = vipDemotion(appUser.getShopPoint() - getPoint, appUser.getVipId());
+ PointSetting pointSetting = pointSettingClient.getPointSetting(vipDemotion ? appUser.getVipId() - 1 : appUser.getVipId()).getData();
+ int earnPoint1 = 0;
+ if(null != pointSetting && 1 == pointSetting.getBuyPointOpen()){
+ earnPoint1 = new BigDecimal(getPoint).divide(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue();
+ }
+ appUser.setShopPoint(appUser.getShopPoint() - getPoint);
+ appUser.setLavePoint(appUser.getLavePoint() - getPoint);
+ appUser.setAvailablePoint(appUser.getAvailablePoint() - earnPoint1);
+ appUser.setTotalAvailablePoint(appUser.getTotalAvailablePoint() - earnPoint1);
+ if(null != pointSetting && 1 == pointSetting.getBuyPointGift()){
+ appUser.setTransferablePoint(appUser.getTransferablePoint() - earnPoint1);
+ }
+ appUser.setTotalPoint(appUser.getTotalPoint() - getPoint);
+ if(vipDemotion){
+ appUser.setVipId(appUser.getVipId() - 1);
+ }
+
+ //构建积分流水明细
+ UserPoint userPoint = new UserPoint();
+ userPoint.setType(1);
+ userPoint.setHistoricalPoint(lavePoint);
+ userPoint.setVariablePoint(getPoint);
+ userPoint.setBalance(appUser.getLavePoint());
+ userPoint.setCreateTime(LocalDateTime.now());
+ userPoint.setAppUserId(order.getAppUserId());
+ userPoint.setObjectId(order.getId());
+ userPointClient.saveUserPoint(userPoint);
+ appUserClient.editAppUserById(appUser);
+ return R.ok();
+ }
+
+
+ /**
+ * 取消订单快递费回退
+ * @return
+ */
+ @Override
+ public R refundExpressPayMoneyCallback(RefundCallbackResult refundCallbackResult) {
+ String code = refundCallbackResult.getR3_RefundOrderNo().substring(1);
+ Order order = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, code));
+ if(null == order || order.getPayStatus() == 1 || order.getOrderStatus() == 6){
+ return R.ok();
+ }
+ order.setRefundCode(refundCallbackResult.getR5_RefundTrxNo());
+ order.setRefundStatus(2);
+ order.setRefundTime(LocalDateTime.now());
+ this.updateById(order);
+
+ AppUser appUser = appUserClient.getAppUserById(order.getAppUserId());
+ Integer lavePoint = appUser.getLavePoint();
+ //积分退款
+ appUser.setLavePoint(appUser.getLavePoint() + order.getPoint());
+ appUser.setAvailablePoint(appUser.getAvailablePoint() + order.getPoint());
+ UserPoint userPoint1 = new UserPoint();
+ userPoint1.setType(11);
+ userPoint1.setObjectId(order.getId());
+ List<UserPoint> data = userPointClient.getUserPointList(userPoint1).getData();
+ Integer transferablePoint = order.getPoint();
+ if(data.size() > 0){
+ UserPoint userPoint = data.get(0);
+ transferablePoint = Integer.valueOf(userPoint.getExtention());
+ }
+ appUser.setTransferablePoint(appUser.getTransferablePoint() + transferablePoint);
+
+ //构建积分流水明细
+ UserPoint userPoint = new UserPoint();
+ userPoint.setType(11);
+ userPoint.setHistoricalPoint(lavePoint);
+ userPoint.setVariablePoint(order.getPoint());
+ userPoint.setBalance(appUser.getLavePoint());
+ userPoint.setCreateTime(LocalDateTime.now());
+ userPoint.setAppUserId(order.getAppUserId());
+ userPoint.setObjectId(order.getId());
+ userPointClient.saveUserPoint(userPoint);
+
+ //退回获得的消费积分
+ //需要先检查会员等级时候回回退,使用回退后的会员等级查询配置
+ lavePoint = appUser.getLavePoint();
+ Integer getPoint = order.getGetPoint();
+ boolean vipDemotion = vipDemotion(appUser.getShopPoint() - getPoint, appUser.getVipId());
+ PointSetting pointSetting = pointSettingClient.getPointSetting(vipDemotion ? appUser.getVipId() - 1 : appUser.getVipId()).getData();
+ int earnPoint1 = 0;
+ if(null != pointSetting && 1 == pointSetting.getBuyPointOpen()){
+ earnPoint1 = new BigDecimal(getPoint).divide(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue();
+ }
+ appUser.setShopPoint(appUser.getShopPoint() - getPoint);
+ appUser.setLavePoint(appUser.getLavePoint() - getPoint);
+ appUser.setAvailablePoint(appUser.getAvailablePoint() - earnPoint1);
+ appUser.setTotalAvailablePoint(appUser.getTotalAvailablePoint() - earnPoint1);
+ if(null != pointSetting && 1 == pointSetting.getBuyPointGift()){
+ appUser.setTransferablePoint(appUser.getTransferablePoint() - earnPoint1);
+ }
+ appUser.setTotalPoint(appUser.getTotalPoint() - getPoint);
+ if(vipDemotion){
+ appUser.setVipId(appUser.getVipId() - 1);
+ }
+
+ //构建积分流水明细
+ userPoint = new UserPoint();
+ userPoint.setType(1);
+ userPoint.setHistoricalPoint(lavePoint);
+ userPoint.setVariablePoint(getPoint);
+ userPoint.setBalance(appUser.getLavePoint());
+ userPoint.setCreateTime(LocalDateTime.now());
+ userPoint.setAppUserId(order.getAppUserId());
+ userPoint.setObjectId(order.getId());
+ userPointClient.saveUserPoint(userPoint);
+ appUserClient.editAppUserById(appUser);
+
+ order.setRefundStatus(2);
+ order.setRefundTime(LocalDateTime.now());
+ return null;
+ }
+
/**
* 会员降级检测
*/
@@ -469,6 +705,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();
}
@@ -488,8 +736,10 @@
orderInfo.setOrderStatus(order.getOrderStatus());
orderInfo.setCreateTime(order.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
AppUser appUser = appUserClient.getAppUserById(order.getAppUserId());
- orderInfo.setUserName(appUser.getName());
- orderInfo.setPhone(appUser.getPhone());
+ if(null != appUser){
+ orderInfo.setUserName(appUser.getName());
+ orderInfo.setPhone(appUser.getPhone());
+ }
orderInfo.setOrderType(order.getOrderType() == 1 ? "服务" : (StringUtils.isNotEmpty(order.getExpressJson()) ? "单品-快递配送" : "单品-自提"));
Shop shop = shopClient.getShopById(order.getShopId()).getData();
if(null != shop){
@@ -532,4 +782,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);
+ }
}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java
index 199eaf5..0805525 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java
@@ -132,8 +132,10 @@
List<OrderRefundPassList> orderRefundPassList = this.baseMapper.getOrderRefundPassList(pageInfo, refundPassListVo.getCode(), appUserIds, shopId, refundPassListVo.getRefundMethod(), refundPassListVo.getStatus());
for (OrderRefundPassList refundPassList : orderRefundPassList) {
AppUser appUser = appUserClient.getAppUserById(refundPassList.getAppUserId());
- refundPassList.setUserName(appUser.getName());
- refundPassList.setPhone(appUser.getPhone());
+ if(null != appUser){
+ refundPassList.setUserName(appUser.getName());
+ refundPassList.setPhone(appUser.getPhone());
+ }
}
return pageInfo.setRecords(orderRefundPassList);
}
@@ -153,6 +155,7 @@
return R.fail("不能重复操作");
}
refundPass.setPassStatus(status);
+ refundPass.setAuthTime(LocalDateTime.now());
//退货退款
if(refundPass.getRefundMethod() == 1 && 2 == status){
refundPass.setStatus(4);
@@ -160,16 +163,22 @@
if(refundPass.getRefundMethod() == 2 && 2 == status){
refundPass.setStatus(2);
}
+ if(3 == status){
+ refundPass.setStatus(3);
+ }
refundPass.setPassRemark(passRemark);
- this.updateById(refundPass);
//仅退款的售后需要将支付金额原路返回,然后再扣减支付获得的积分
if(refundPass.getRefundMethod() == 2 && 2 == status){
Order order = orderService.getById(refundPass.getOrderId());
order.setOrderStatus(6);
- orderService.updateById(order);
//返回订单支付金额和回退积分和会员等级
- orderService.refundPayMoney(order);
+ R r = orderService.refundPayMoney(order);
+ if(200 != r.getCode()){
+ return r;
+ }
+ orderService.updateById(order);
}
+ this.updateById(refundPass);
return R.ok();
}
@@ -189,13 +198,16 @@
return R.fail("操作失败");
}
refundPass.setStatus(2);
- this.updateById(refundPass);
//仅退款的售后需要将支付金额原路返回,然后再扣减支付获得的积分
Order order = orderService.getById(refundPass.getOrderId());
order.setOrderStatus(6);
- orderService.updateById(order);
//返回订单支付金额和回退积分和会员等级
- orderService.refundPayMoney(order);
+ R r = orderService.refundPayMoney(order);
+ if(200 != r.getCode()){
+ return r;
+ }
+ this.updateById(refundPass);
+ orderService.updateById(order);
return R.ok();
}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
index 3c5614f..36d8d92 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
@@ -142,7 +142,8 @@
}
List<Integer> goodsIds = data.stream().map(Goods::getId).collect(Collectors.toList());
//查询符合商品类型的商品数据
- List<ShoppingCart> list = this.list(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid).in(ShoppingCart::getGoodsId, goodsIds));
+ List<ShoppingCart> list = this.list(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid)
+ .in(ShoppingCart::getGoodsId, goodsIds).eq(ShoppingCart::getStatus, 1));
//构建返回数据
List<MyShoppingCartVo> page = buildDetail(appUser, shopId, list, null);
return page;
@@ -156,7 +157,7 @@
* @param shopId
* @return
*/
- public Price getPrice(AppUser appUser, Integer goodsId, Integer shopId){
+ public Price getPrice(AppUser appUser, Integer goodsId, Integer type, Integer shopId){
//获取支付价格
//秒杀活动>门店特价>地区价格>会员价格
//判断是否有秒杀活动
@@ -165,7 +166,8 @@
info.setGoodsId(goodsId);
info.setVip(appUser.getVipId());
GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData();
- if(null == goodsSeckill){
+ //没有秒杀活动或者添加的普通商品则不使用秒杀活动价格
+ if(null == goodsSeckill || type == 1){
//没有秒杀价,则判断门店特价
GetGoodsBargainPrice goodsBargainPrice = new GetGoodsBargainPrice();
goodsBargainPrice.setGoodsId(goodsId);
@@ -238,18 +240,34 @@
area.setProvinceCode(appUser.getProvinceCode());
area.setVip(appUser.getVipId());
GoodsArea goodsArea = goodsAreaClient.getGoodsArea(area).getData();
- price.setEarnSpendingPoints(goodsArea.getEarnSpendingPoints());
- price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission());
- price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints());
- price.setSuperiorType(goodsArea.getSuperiorType());
- price.setSuperiorPriceType(goodsArea.getSuperiorPriceType());
- price.setServuceShopCharges(goodsArea.getServuceShopCharges());
- price.setServuceShopPoints(goodsArea.getServuceShopPoints());
- price.setTechnicianPoints(goodsArea.getTechnicianPoints());
- price.setBoundShopCharges(goodsArea.getBoundShopCharges());
- price.setBoundShopPoints(goodsArea.getBoundShopPoints());
- price.setBoundShopSuperiorsCharges(goodsArea.getBoundShopSuperiorsCharges());
- price.setBoundShopSuperiorsPoints(goodsArea.getBoundShopSuperiorsPoints());
+ if(null != goodsArea){
+ price.setEarnSpendingPoints(goodsArea.getEarnSpendingPoints());
+ price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission());
+ price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints());
+ price.setSuperiorType(goodsArea.getSuperiorType());
+ price.setSuperiorPriceType(goodsArea.getSuperiorPriceType());
+ price.setServuceShopCharges(goodsArea.getServuceShopCharges());
+ price.setServuceShopPoints(goodsArea.getServuceShopPoints());
+ price.setTechnicianPoints(goodsArea.getTechnicianPoints());
+ price.setBoundShopCharges(goodsArea.getBoundShopCharges());
+ price.setBoundShopPoints(goodsArea.getBoundShopPoints());
+ price.setBoundShopSuperiorsCharges(goodsArea.getBoundShopSuperiorsCharges());
+ price.setBoundShopSuperiorsPoints(goodsArea.getBoundShopSuperiorsPoints());
+ }else{
+ GoodsVip goodsVip = goodsVipClient.getGoodsVip(goodsId, appUser.getVipId()).getData();
+ price.setEarnSpendingPoints(goodsVip.getEarnSpendingPoints());
+ price.setSuperiorSubcommission(goodsVip.getSuperiorSubcommission());
+ price.setSuperiorRebatePoints(goodsVip.getSuperiorRebatePoints());
+ price.setSuperiorType(goodsVip.getSuperiorType());
+ price.setSuperiorPriceType(goodsVip.getSuperiorPriceType());
+ price.setServuceShopCharges(goodsVip.getServuceShopCharges());
+ price.setServuceShopPoints(goodsVip.getServuceShopPoints());
+ price.setTechnicianPoints(goodsVip.getTechnicianPoints());
+ price.setBoundShopCharges(goodsVip.getBoundShopCharges());
+ price.setBoundShopPoints(goodsVip.getBoundShopPoints());
+ price.setBoundShopSuperiorsCharges(goodsVip.getBoundShopSuperiorsCharges());
+ price.setBoundShopSuperiorsPoints(goodsVip.getBoundShopSuperiorsPoints());
+ }
}
}else{
//构建价格数据
@@ -288,9 +306,18 @@
@Override
public Long addGoods(ShoppingCart shoppingCart) {
Long userid = tokenService.getLoginUserApplet().getUserid();
- shoppingCart.setAppUserId(userid);
- this.save(shoppingCart);
- return shoppingCart.getId();
+ ShoppingCart one = this.getOne(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid)
+ .eq(ShoppingCart::getGoodsId, shoppingCart.getGoodsId()).eq(ShoppingCart::getType, shoppingCart.getType()).eq(ShoppingCart::getStatus, 1));
+ if(null != one){
+ one.setNumber(one.getNumber() + shoppingCart.getNumber());
+ this.updateById(one);
+ return one.getId();
+ }else{
+ shoppingCart.setAppUserId(userid);
+ shoppingCart.setStatus(1);
+ this.save(shoppingCart);
+ return shoppingCart.getId();
+ }
}
@@ -336,12 +363,15 @@
JSONArray objects = JSON.parseArray(goodsJson);
Long id = objects.getJSONObject(0).getLong("id");
Integer num1 = objects.getJSONObject(0).getInteger("num");
+ Integer type = objects.getJSONObject(0).getInteger("type");
ShoppingCart shoppingCart = new ShoppingCart();
shoppingCart.setAppUserId(userid);
shoppingCart.setGoodsId(id.intValue());
shoppingCart.setNumber(num1);
- Long shoppingCarId = addGoods(shoppingCart);
- confirmOrder.setGoodsJson("[{\"id\": " + shoppingCarId + ", \"num\": " + num1 + "}]");
+ shoppingCart.setType(type);
+ shoppingCart.setStatus(0);
+ this.save(shoppingCart);
+ confirmOrder.setGoodsJson("[{\"id\": " + shoppingCart.getId() + ", \"num\": " + num1 + ",\"type\":" + type + "}]");
}
AppUser appUser = appUserClient.getAppUserById(userid);
Integer shopId = confirmOrder.getShopId();
@@ -362,22 +392,110 @@
confirmOrderVo.setShopName(shop.getName());
//现金支付
if(confirmOrder.getPaymentType() == 1){
- BigDecimal bigDecimal = goodsList.stream().map(MyShoppingCartVo::getCash).reduce(BigDecimal::add).get();
+ BigDecimal bigDecimal = BigDecimal.ZERO;
+ for (MyShoppingCartVo myShoppingCartVo : goodsList) {
+ bigDecimal = bigDecimal.add(myShoppingCartVo.getCash().multiply(new BigDecimal(myShoppingCartVo.getNumber())));
+ }
confirmOrderVo.setOrderMoney(bigDecimal);
}else{
- int sum = goodsList.stream().mapToInt(MyShoppingCartVo::getPoint).sum();
+ int sum = 0;
+ for (MyShoppingCartVo myShoppingCartVo : goodsList) {
+ sum += (myShoppingCartVo.getPoint() * myShoppingCartVo.getNumber());
+ }
confirmOrderVo.setOrderPoint(sum);
}
- //查询当前是否有订单活动
- OrderActivityInfo orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData();
+
BigDecimal orderMoney = confirmOrderVo.getOrderMoney();
BigDecimal paymentMoney = orderMoney;
- //满XX才打折,只有现金才能优惠
- if(null != orderActivityInfo && confirmOrder.getPaymentType() == 1 && orderActivityInfo.getConditionAmount().compareTo(orderMoney) <= 0){
- confirmOrderVo.setActivityName(orderActivityInfo.getActivityName());
- paymentMoney = orderActivityInfo.getDiscount().divide(new BigDecimal(10)).multiply(orderMoney);
- confirmOrderVo.setDiscountAmount(orderMoney.subtract(paymentMoney).setScale(2, RoundingMode.HALF_EVEN));
+ //总优惠金额
+ BigDecimal activityAmount = BigDecimal.ZERO;
+
+ //减去优惠券优惠金额
+ CouponInfoVo couponInfoVo = null;
+ if(null != confirmOrder.getCouponId() && 2 != confirmOrder.getPaymentType()){
+ couponInfoVo = userCouponClient.getCouponInfo(confirmOrder.getCouponId()).getData();
+ String forGoodIds = couponInfoVo.getForGoodIds();
+ String[] split = forGoodIds.split(",");
+ List<String> parseArray = Arrays.asList(split);
+ //全部商品
+ if("-1".equals(forGoodIds)){
+ //满减
+ if(1 == couponInfoVo.getCouponType() && couponInfoVo.getConditionAmount().compareTo(paymentMoney) <= 0){
+ paymentMoney = paymentMoney.subtract(couponInfoVo.getDiscountAmount());
+ activityAmount = activityAmount.add(couponInfoVo.getDiscountAmount());
+ }
+ //代金券
+ if(2 == couponInfoVo.getCouponType()){
+ paymentMoney = paymentMoney.subtract(couponInfoVo.getMoneyAmount());
+ activityAmount = activityAmount.add(couponInfoVo.getMoneyAmount());
+ if(paymentMoney.compareTo(BigDecimal.ZERO) < 0){
+ paymentMoney = BigDecimal.ZERO;
+ }
+ }
+ //折扣券
+ if(3 == couponInfoVo.getCouponType()){
+ BigDecimal paymentMoney1 = couponInfoVo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney);
+ BigDecimal bigDecimal = paymentMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN);
+ paymentMoney = paymentMoney1;
+ activityAmount = activityAmount.add(bigDecimal);
+ }
+ }else{
+ //部分商品,需要计算参与优惠商品的支付金额,然后再对商品进行优惠券处理
+ paymentMoney = BigDecimal.ZERO;
+ BigDecimal goodsMoney = BigDecimal.ZERO;
+ for (MyShoppingCartVo myShoppingCartVo : goodsList) {
+ String goodsId = myShoppingCartVo.getGoodsId().toString();
+ BigDecimal cash = myShoppingCartVo.getCash();
+ if(parseArray.contains(goodsId)){
+ goodsMoney = goodsMoney.add(cash);
+ }else{
+ paymentMoney = paymentMoney.add(cash);
+ }
+ }
+
+ //满减
+ if(1 == couponInfoVo.getCouponType() && couponInfoVo.getConditionAmount().compareTo(goodsMoney) <= 0){
+ goodsMoney = goodsMoney.subtract(couponInfoVo.getDiscountAmount());
+ activityAmount = activityAmount.add(couponInfoVo.getDiscountAmount());
+ }
+ //代金券
+ if(2 == couponInfoVo.getCouponType()){
+ goodsMoney = goodsMoney.subtract(couponInfoVo.getMoneyAmount());
+ activityAmount = activityAmount.add(couponInfoVo.getMoneyAmount());
+ if(goodsMoney.compareTo(BigDecimal.ZERO) < 0){
+ goodsMoney = BigDecimal.ZERO;
+ }
+ }
+ //折扣券
+ if(3 == couponInfoVo.getCouponType()){
+ BigDecimal paymentMoney1 = couponInfoVo.getDiscount().divide(new BigDecimal(10)).multiply(goodsMoney);
+ BigDecimal bigDecimal = goodsMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN);
+ goodsMoney = paymentMoney1;
+ activityAmount = activityAmount.add(bigDecimal);
+ }
+ paymentMoney = paymentMoney.add(goodsMoney);
+ }
}
+
+ //查询当前是否有订单活动
+ List<OrderActivityInfo> orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData();
+ //满XX才打折,只有现金才能优惠
+ if(null != orderActivityInfo && confirmOrder.getPaymentType() == 1){
+ for (OrderActivityInfo activityInfo : orderActivityInfo) {
+ if(activityInfo.getConditionAmount().compareTo(paymentMoney) <= 0){
+ confirmOrderVo.setActivityName(activityInfo.getActivityName());
+ //优惠后的支付金额
+ BigDecimal multiply = activityInfo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney);
+ //优惠金额
+ BigDecimal bigDecimal = paymentMoney.subtract(multiply).setScale(2, RoundingMode.HALF_EVEN);
+ paymentMoney = multiply;
+ activityAmount = activityAmount.add(bigDecimal);
+ break;
+ }
+ }
+
+ }
+ confirmOrderVo.setDiscountAmount(activityAmount);
BaseSetting baseSetting = baseSettingClient.getBaseSetting(4).getData();
confirmOrderVo.setUseSimultaneously(JSON.parseObject(baseSetting.getContent()).getInteger("status") == 1);
int earnPoint = goodsList.stream().mapToInt(MyShoppingCartVo::getEarnSpendingPoints).sum();
@@ -474,6 +592,7 @@
Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData();
MyShoppingCartVo vo = new MyShoppingCartVo();
vo.setId(shoppingCart.getId().toString());
+ vo.setType(shoppingCart.getType());
vo.setGoodsId(goods.getId());
vo.setHomePicture(goods.getHomePagePicture());
vo.setName(goods.getName());
@@ -488,7 +607,7 @@
}
}
//获取支付价格
- Price price = getPrice(appUser, shoppingCart.getGoodsId(), shopId);
+ Price price = getPrice(appUser, shoppingCart.getGoodsId(), shoppingCart.getType(), shopId);
if(null == price){
price = new Price();
//使用商品的基础价格
@@ -512,6 +631,7 @@
//判断当前数量是否已经超出限购数量(需要计算已经购买的数量)
if(null == goods.getPurchaseLimit() || -1 == goods.getPurchaseLimit()){
vo.setPurchaseLimit(false);
+ vo.setPurchaseLimitNum(-1);
}else{
List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getAppUserId, appUser.getId()).eq(Order::getDelFlag, 0).in(Order::getOrderStatus, Arrays.asList(4, 8)));
List<Long> orderIds = orders.stream().map(Order::getId).collect(Collectors.toList());
@@ -560,21 +680,26 @@
for (int i = 0; i < objects.size(); i++) {
Long id = objects.getJSONObject(i).getLong("id");
Integer num1 = objects.getJSONObject(i).getInteger("num");
+ Integer type = objects.getJSONObject(i).getInteger("type");
num += num1;
ShoppingCart shoppingCart = this.getById(id);
//判断当前数量是否已经超出限购数量(需要计算已经购买的数量)
+ Integer goodsSaleNum = orderService.getGoodsSaleNum(shoppingCart.getGoodsId(), type);
Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData();
- if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit()){
- List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getAppUserId, appUser.getId()).eq(Order::getDelFlag, 0).in(Order::getOrderStatus, Arrays.asList(4, 8)));
- List<Long> orderIds = orders.stream().map(Order::getId).collect(Collectors.toList());
- int sum = 0;
- if(orderIds.size() > 0){
- List<OrderGood> orderGoodList = orderGoodService.list(new LambdaQueryWrapper<OrderGood>().in(OrderGood::getOrderId, orderIds)
- .eq(OrderGood::getGoodsId, shoppingCart.getGoodsId()).eq(OrderGood::getDelFlag, 0));
- sum = orderGoodList.stream().mapToInt(OrderGood::getNum).sum();
- }
- if((num1 + sum) > goods.getPurchaseLimit()){
+ if(1 == type){
+ if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && (goodsSaleNum + num1) > goods.getPurchaseLimit()){
return R.fail(goods.getName() + "已超出购买上限");
+ }
+ }else{
+ GetSeckillActivityInfo info = new GetSeckillActivityInfo();
+ info.setGoodsId(shoppingCart.getGoodsId());
+ info.setVip(appUser.getVipId());
+ GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData();
+ if(null != goodsSeckill ){
+ SeckillActivityInfo activityInfo = seckillActivityInfoClient.getSeckillActivityInfoById(goodsSeckill.getSeckillActivityInfoId()).getData();
+ if(null != activityInfo.getMaxNum() && -1 != activityInfo.getMaxNum() && (goodsSaleNum + num1) > activityInfo.getMaxNum()){
+ return R.fail(goods.getName() + "已超出秒杀活动购买上限");
+ }
}
}
ids.add(id);
@@ -719,20 +844,27 @@
}
//查询当前是否有订单活动
- OrderActivityInfo orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData();
+ List<OrderActivityInfo> orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData();
BaseSetting baseSetting = baseSettingClient.getBaseSetting(4).getData();
//系统活动设置(优惠券和活动能否同时使用)
- boolean useSimultaneously = baseSetting.getContent().equals("1");
+ Integer status = JSON.parseObject(baseSetting.getContent()).getInteger("status");
//满XX才打折,只有现金才能优惠
//如果使用优惠券,则需要判断是否可以和同时使用,且活动满足使用条件。
//没有使用优惠券,只需要判断是都满足使用条件
- if((useSimultaneously || null == shoppingCartPayment.getUserCouponId()) &&
- null != orderActivityInfo && shoppingCartPayment.getPaymentType() != 3 && orderActivityInfo.getConditionAmount().compareTo(paymentMoney) <= 0){
- BigDecimal paymentMoney1 = orderActivityInfo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney);
- BigDecimal bigDecimal = paymentMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN);
- discount = orderActivityInfo.getDiscount();
- paymentMoney = paymentMoney1;
- activityAmount = activityAmount.add(bigDecimal);
+ OrderActivityInfo orderActivityInfo1 = null;
+ if((1 == status || null == shoppingCartPayment.getUserCouponId()) &&
+ null != orderActivityInfo && shoppingCartPayment.getPaymentType() != 3){
+ for (OrderActivityInfo activityInfo : orderActivityInfo) {
+ if(activityInfo.getConditionAmount().compareTo(paymentMoney) <= 0){
+ BigDecimal paymentMoney1 = activityInfo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney);
+ BigDecimal bigDecimal = paymentMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN);
+ discount = activityInfo.getDiscount();
+ paymentMoney = paymentMoney1;
+ activityAmount = activityAmount.add(bigDecimal);
+ orderActivityInfo1 = activityInfo;
+ break;
+ }
+ }
}
//可获得的消费积分
@@ -799,7 +931,7 @@
order.setCouponJson(JSON.toJSONString(couponInfoVo));
}
if(activityAmount.compareTo(BigDecimal.ZERO) > 0){
- order.setActivityJson(JSON.toJSONString(orderActivityInfo));
+ order.setActivityJson(JSON.toJSONString(orderActivityInfo1));
}
if(null != shoppingCartPayment.getUserAddressId()){
UserAddress address = userAddressClient.getUserAddressById(shoppingCartPayment.getUserAddressId()).getData();
@@ -839,19 +971,23 @@
OrderGood orderGood = new OrderGood();
orderGood.setGoodsId(myShoppingCartVo.getGoodsId());
orderGood.setOrderId(order.getId());
- GetSeckillActivityInfo info = new GetSeckillActivityInfo();
- info.setGoodsId(myShoppingCartVo.getGoodsId());
- info.setVip(appUser.getVipId());
- GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData();
- if(null != goodsSeckill){
- orderGood.setSeckillJson(JSON.toJSONString(goodsSeckill));
- }
for (int i = 0; i < objects.size(); i++) {
Long id = objects.getJSONObject(i).getLong("id");
if(myShoppingCartVo.getId().equals(id.toString())){
ShoppingCart shoppingCart = this.getById(id);
Integer num1 = objects.getJSONObject(i).getInteger("num");
+ Integer type = objects.getJSONObject(i).getInteger("type");
orderGood.setNum(num1);
+ orderGood.setType(type);
+ if(2 == type){
+ GetSeckillActivityInfo info = new GetSeckillActivityInfo();
+ info.setGoodsId(myShoppingCartVo.getGoodsId());
+ info.setVip(appUser.getVipId());
+ GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData();
+ if(null != goodsSeckill){
+ orderGood.setSeckillJson(JSON.toJSONString(goodsSeckill));
+ }
+ }
Goods goods1 = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData();
orderGood.setGoodJson(JSON.toJSONString(goods1));
break;
@@ -881,15 +1017,17 @@
//调起微信支付
String goodsNames = goodsList.stream().map(MyShoppingCartVo::getName).collect(Collectors.joining("\n"));
UniPayResult uniPayResult = PaymentUtil.uniPay(order.getOrderNumber(), paymentMoney.doubleValue(), order.getOrderType() == 1 ? "购买服务商品" : "购买单品商品",
- goodsNames, "", "/order/shopping-cart/shoppingCartPaymentCallback", appUser.getWxOpenid(), "");
+ goodsNames, "", "/order/shopping-cart/shoppingCartPaymentCallback", appUser.getWxOpenid(), null);
if(null == uniPayResult || !"100".equals(uniPayResult.getRa_Code())){
return R.fail(null == uniPayResult ? "支付失败" : uniPayResult.getRb_CodeMsg());
}
String rc_result = uniPayResult.getRc_Result();
+ JSONObject jsonObject = JSON.parseObject(rc_result);
+ jsonObject.put("orderId", order.getId().toString());
//将支付数据添加到redis队列中,便于定时任务去校验是否完成支付,没有完成支付支付,15分钟后关闭订单。
long second = LocalDateTime.now().plusMinutes(15).toEpochSecond(ZoneOffset.UTC);
redisTemplate.opsForZSet().add("OrderPayment", order.getOrderNumber(), second);
- return R.ok(rc_result);
+ return R.ok(jsonObject.toJSONString());
}
//账户余额
BigDecimal redPacketAmount = BigDecimal.ZERO;
@@ -942,15 +1080,17 @@
appUser.setTransferablePoint(appUser.getTransferablePoint() + earnPoint1);
}
- UserPoint userPoint = new UserPoint();
- userPoint.setType(1);
- userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint);
- userPoint.setVariablePoint(earnPoint);
- userPoint.setBalance(appUser.getLavePoint());
- userPoint.setCreateTime(LocalDateTime.now());
- userPoint.setAppUserId(appUser.getId());
- userPoint.setObjectId(order.getId());
- userPointClient.saveUserPoint(userPoint);
+ if(earnPoint > 0){
+ UserPoint userPoint = new UserPoint();
+ userPoint.setType(1);
+ userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint);
+ userPoint.setVariablePoint(earnPoint);
+ userPoint.setBalance(appUser.getLavePoint());
+ userPoint.setCreateTime(LocalDateTime.now());
+ userPoint.setAppUserId(appUser.getId());
+ userPoint.setObjectId(order.getId());
+ userPointClient.saveUserPoint(userPoint);
+ }
}
appUser.setShopAmount(appUser.getShopAmount().add(paymentMoney).setScale(2, RoundingMode.HALF_EVEN));
appUser.setLastShopTime(LocalDateTime.now());
@@ -983,30 +1123,53 @@
if(expressFee.compareTo(BigDecimal.ZERO) > 0){
if(shoppingCartPayment.getFreightPaymentType() == 1){
//调起微信支付
- UniPayResult uniPayResult = PaymentUtil.uniPay(order.getOrderNumber() + appUser.getId(), expressFee.doubleValue(), order.getOrderType() == 1 ? "购买服务商品快递费" : "购买单品商品快递费",
- "快递费", "", "/order/shopping-cart/shoppingCartMaterialFlowPaymentCallback", appUser.getWxOpenid(), "");
+ UniPayResult uniPayResult = PaymentUtil.uniPay("K" + order.getOrderNumber(), expressFee.doubleValue(), order.getOrderType() == 1 ? "购买服务商品快递费" : "购买单品商品快递费",
+ "快递费", "", "/order/shopping-cart/shoppingCartMaterialFlowPaymentCallback", appUser.getWxOpenid(), null);
if(null == uniPayResult || !"100".equals(uniPayResult.getRa_Code())){
return R.fail(null == uniPayResult ? "支付失败" : uniPayResult.getRb_CodeMsg());
}
String rc_result = uniPayResult.getRc_Result();
+ JSONObject jsonObject = JSON.parseObject(rc_result);
+ jsonObject.put("orderId", order.getId().toString());
//将支付数据添加到redis队列中,便于定时任务去校验是否完成支付,没有完成支付支付,15分钟后关闭订单。
long second = LocalDateTime.now().plusMinutes(15).toEpochSecond(ZoneOffset.UTC);
- redisTemplate.opsForZSet().add("MaterialFlowPayment", order.getOrderNumber() + appUser.getId(), second);
- return R.ok(rc_result);
+ redisTemplate.opsForZSet().add("MaterialFlowPayment", "K" + order.getOrderNumber(), second);
+ return R.ok(jsonObject.toJSONString());
}
}
-
+
Integer lavePoint = appUser.getLavePoint();
+ //扣减订单支付积分
+ appUser.setLavePoint(appUser.getLavePoint() - orderPoint);
+ appUser.setAvailablePoint(appUser.getAvailablePoint() - orderPoint);
+ //可转增积分
+ Integer transferablePoint = appUser.getTransferablePoint();
+ Integer tra = 0;
+ if(transferablePoint > 0){
+ tra = transferablePoint - orderPoint;
+ appUser.setTransferablePoint(tra >= 0 ? tra : 0);
+ }
+ appUser.setTransferablePoint(appUser.getTransferablePoint() - orderPoint);
+
+ //构建积分流水记录
+ UserPoint userPoint = new UserPoint();
+ userPoint.setType(11);
+ userPoint.setHistoricalPoint(lavePoint);
+ userPoint.setVariablePoint(orderPoint);
+ userPoint.setBalance(appUser.getLavePoint());
+ userPoint.setCreateTime(LocalDateTime.now());
+ userPoint.setAppUserId(appUser.getId());
+ userPoint.setObjectId(order.getId());
+ userPoint.setExtention((tra >= 0 ? orderPoint : transferablePoint) + "");
+ userPointClient.saveUserPoint(userPoint);
+
+ lavePoint = appUser.getLavePoint();
PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
int earnPoint1 = 0;
//计算可用积分比例
if(null != pointSetting && 1 == pointSetting.getBuyPointOpen()){
earnPoint1 = new BigDecimal(earnPoint).multiply(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue();
}
- //扣减订单支付积分
- appUser.setLavePoint(appUser.getLavePoint() - orderPoint);
- appUser.setAvailablePoint(appUser.getAvailablePoint() - orderPoint);
-
appUser.setShopPoint(appUser.getShopPoint() + earnPoint);
appUser.setLavePoint(appUser.getLavePoint() + earnPoint);
appUser.setAvailablePoint(appUser.getAvailablePoint() + earnPoint1);
@@ -1021,16 +1184,17 @@
appUserClient.vipUpgrade(appUser.getId());
//构建积分流水记录
- UserPoint userPoint = new UserPoint();
- userPoint.setType(1);
- userPoint.setHistoricalPoint(lavePoint);
- Integer point = appUser.getLavePoint() - lavePoint;
- userPoint.setVariablePoint(point >= 0 ? point : point * -1);
- userPoint.setBalance(appUser.getLavePoint());
- userPoint.setCreateTime(LocalDateTime.now());
- userPoint.setAppUserId(appUser.getId());
- userPoint.setObjectId(order.getId());
- userPointClient.saveUserPoint(userPoint);
+ if(earnPoint > 0){
+ userPoint = new UserPoint();
+ userPoint.setType(1);
+ userPoint.setHistoricalPoint(lavePoint);
+ userPoint.setVariablePoint(earnPoint);
+ userPoint.setBalance(appUser.getLavePoint());
+ userPoint.setCreateTime(LocalDateTime.now());
+ userPoint.setAppUserId(appUser.getId());
+ userPoint.setObjectId(order.getId());
+ userPointClient.saveUserPoint(userPoint);
+ }
//如果有运费,需要先扣除账户积分,再进行支付。支付成功后修改订单状态,未支付成功则回退积分,删除的订单
if(expressFee.compareTo(BigDecimal.ZERO) > 0){
if(shoppingCartPayment.getFreightPaymentType() == 2){
@@ -1145,15 +1309,17 @@
appUser.setAvailablePoint(appUser.getAvailablePoint() + earnPoint1);
appUser.setTotalAvailablePoint(appUser.getTotalAvailablePoint() + earnPoint1);
- UserPoint userPoint = new UserPoint();
- userPoint.setType(1);
- userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint);
- userPoint.setVariablePoint(earnPoint);
- userPoint.setBalance(appUser.getLavePoint());
- userPoint.setCreateTime(LocalDateTime.now());
- userPoint.setAppUserId(appUser.getId());
- userPoint.setObjectId(order.getId());
- userPointClient.saveUserPoint(userPoint);
+ if(earnPoint > 0){
+ UserPoint userPoint = new UserPoint();
+ userPoint.setType(1);
+ userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint);
+ userPoint.setVariablePoint(earnPoint);
+ userPoint.setBalance(appUser.getLavePoint());
+ userPoint.setCreateTime(LocalDateTime.now());
+ userPoint.setAppUserId(appUser.getId());
+ userPoint.setObjectId(order.getId());
+ userPointClient.saveUserPoint(userPoint);
+ }
}
appUser.setShopAmount(appUser.getShopAmount().add(paymentMoney).setScale(2, RoundingMode.HALF_EVEN));
appUser.setLastShopTime(LocalDateTime.now());
@@ -1184,7 +1350,7 @@
@Override
public R shoppingCartMaterialFlowPaymentCallback(UniPayCallbackResult uniPayCallbackResult) {
String r2_orderNo = uniPayCallbackResult.getR2_OrderNo();
- r2_orderNo = r2_orderNo.substring(0, 23);
+ r2_orderNo = r2_orderNo.substring(1);
Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, r2_orderNo));
if(null == order || order.getPayStatus() == 2){
return R.ok();
@@ -1192,17 +1358,12 @@
Integer earnPoint = order.getGetPoint();
AppUser appUser = appUserClient.getAppUserById(order.getAppUserId());
Integer lavePoint = appUser.getLavePoint();
- Integer orderPoint = order.getPoint();
PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData();
- int earnPoint1 = earnPoint;
+ int earnPoint1 = 0;
//计算可用积分比例
if(null != pointSetting && 1 == pointSetting.getBuyPointOpen()){
- earnPoint1 = new BigDecimal(earnPoint1).multiply(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue();
+ earnPoint1 = new BigDecimal(earnPoint).multiply(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue();
}
- //扣减订单支付积分
- appUser.setLavePoint(appUser.getLavePoint() - orderPoint);
- appUser.setAvailablePoint(appUser.getAvailablePoint() - orderPoint);
-
appUser.setShopPoint(appUser.getShopPoint() + earnPoint);
appUser.setLavePoint(appUser.getLavePoint() + earnPoint);
appUser.setAvailablePoint(appUser.getAvailablePoint() + earnPoint1);
@@ -1217,13 +1378,13 @@
UserPoint userPoint = new UserPoint();
userPoint.setType(1);
userPoint.setHistoricalPoint(lavePoint);
- Integer point = appUser.getLavePoint() - lavePoint;
- userPoint.setVariablePoint(point >= 0 ? point : point * -1);
+ userPoint.setVariablePoint(earnPoint);
userPoint.setBalance(appUser.getLavePoint());
userPoint.setCreateTime(LocalDateTime.now());
userPoint.setAppUserId(appUser.getId());
userPoint.setObjectId(order.getId());
userPointClient.saveUserPoint(userPoint);
+
//修改订支付状态
order.setPayStatus(2);
//自提
@@ -1248,34 +1409,42 @@
//订单支付数据
long second = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC);
Set<String> orderPayment = redisTemplate.opsForZSet().range("OrderPayment", 0, second);
- for (String code : orderPayment) {
- Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, code));
- if(null == order || order.getPayStatus() != 1){
- continue;
- }
- //开始执行关闭订单操作
- CloseOrderResult closeOrderResult = PaymentUtil.closeOrder(code);
- if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) &&
- Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){
- redisTemplate.opsForZSet().add("OrderPayment", code, 0);
- log.error("关闭订单失败:{}---->{}", code, JSON.toJSONString(closeOrderResult));
+ if(orderPayment.size() > 0){
+ List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getOrderNumber, orderPayment));
+ for (Order order : list) {
+ if(null == order || order.getPayStatus() != 1){
+ redisTemplate.opsForZSet().remove("OrderPayment", order.getOrderNumber());
+ continue;
+ }
+ //开始执行关闭订单操作
+ CloseOrderResult closeOrderResult = PaymentUtil.closeOrder(order.getOrderNumber());
+ if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) &&
+ Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){
+ redisTemplate.opsForZSet().add("OrderPayment", order.getOrderNumber(), 0);
+ log.error("关闭订单失败:{}---->{}", order.getOrderNumber(), JSON.toJSONString(closeOrderResult));
+ }
+ redisTemplate.opsForZSet().remove("OrderPayment", order.getOrderNumber());
}
}
//快递支付
Set<String> materialFlowPayment = redisTemplate.opsForZSet().range("MaterialFlowPayment", 0, second);
- for (String code : materialFlowPayment) {
- code = code.substring(0, 23);
- Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, code));
- if(null == order || order.getPayStatus() != 1){
- continue;
- }
- //开始执行关闭订单操作
- CloseOrderResult closeOrderResult = PaymentUtil.closeOrder(code);
- if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) &&
- Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){
- redisTemplate.opsForZSet().add("MaterialFlowPayment", code, 0);
- log.error("关闭订单失败:{}---->{}", code, JSON.toJSONString(closeOrderResult));
+ if(materialFlowPayment.size() > 0){
+ materialFlowPayment.forEach(s->s.substring(1));
+ List<Order> list = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getOrderNumber, materialFlowPayment));
+ for (Order order : list) {
+ if(null == order || order.getPayStatus() != 1){
+ redisTemplate.opsForZSet().remove("MaterialFlowPayment", order.getOrderNumber());
+ continue;
+ }
+ //开始执行关闭订单操作
+ CloseOrderResult closeOrderResult = PaymentUtil.closeOrder("K" + order.getOrderNumber());
+ if((null == closeOrderResult || !closeOrderResult.getRa_Status().equals("100")) &&
+ Arrays.asList("0", "4", "101", "10080000", "10080002", "10083004", "10083005").contains(closeOrderResult.getRb_Code())){
+ redisTemplate.opsForZSet().add("MaterialFlowPayment", order.getOrderNumber(), 0);
+ log.error("关闭订单失败:{}---->{}", order.getOrderNumber(), JSON.toJSONString(closeOrderResult));
+ }
+ redisTemplate.opsForZSet().remove("MaterialFlowPayment", order.getOrderNumber());
}
}
}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/payment/PaymentUtil.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/payment/PaymentUtil.java
index 4914a27..9da6f50 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/payment/PaymentUtil.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/payment/PaymentUtil.java
@@ -3,6 +3,7 @@
import cn.hutool.http.*;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
+import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.order.util.payment.model.*;
import lombok.extern.slf4j.Slf4j;
@@ -74,7 +75,7 @@
//APPID
body.put("q7_AppId", appId);
//报备商户号
- body.put("qa_TradeMerchantNo", tradeMerchantNo);
+ body.put("qa_TradeMerchantNo", StringUtils.isNotEmpty(tradeMerchantNo) ? tradeMerchantNo : "777168500885852");
String sign = null;
try {
sign = sign(body);
@@ -155,7 +156,7 @@
//退款金额
body.put("p4_RefundAmount", refundAmount);
//服务器异步通知地址
- body.put("p6_NotifyUrl", notifyUrl);
+ body.put("p6_NotifyUrl", callbackUrl + notifyUrl);
String sign = null;
try {
sign = sign(body);
@@ -249,13 +250,13 @@
- public static String sign(JSONObject body) throws Exception{
+ public static String sign(JSONObject body) {
Set<Map.Entry<String, Object>> entries = body.entrySet();
List<Map.Entry<String, Object>> infoIds = new ArrayList<Map.Entry<String, Object>>(entries);
// 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序)
Collections.sort(infoIds, new Comparator<Map.Entry<String, Object>>() {
public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) {
- return (o1.getKey()).toString().compareTo(o2.getKey());
+ return (o1.getKey()).compareTo(o2.getKey());
}
});
// 构造签名键值对的格式
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java
index 7c97847..b6cdfb0 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java
@@ -31,9 +31,10 @@
private BigDecimal orderMoney;
@ApiModelProperty("订单状态(1待发货2待收货3待使用4已完成5已取消6已退款7售后中8已评价)")
private Integer status;
-
/**
* 用户id
*/
private Long appUserId;
+ @ApiModelProperty("售后订单id")
+ private String refundPassId;
}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderRefundPassList.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderRefundPassList.java
index 9d4a048..b909179 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderRefundPassList.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderRefundPassList.java
@@ -25,6 +25,8 @@
private Integer refundMethod;
@ApiModelProperty("申请原因")
private String refundReason;
+ @ApiModelProperty("1待审核2已完成3已拒绝4待退货5待平台收货")
+ private Integer status;
@ApiModelProperty("状态(1待审核2同意3拒绝)")
private Integer passStatus;
/**
diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
index 52f52fb..0be4871 100644
--- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
+++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -13,12 +13,20 @@
o.num,
o.point,
o.payment_amount,
+ o.express_amount,
COUNT(o.id) AS order_count
FROM
t_order o
<where>
<if test="status != null">
- o.order_status = #{status}
+ <choose>
+ <when test="status == 4">
+ o.order_status in (4, 8)
+ </when>
+ <otherwise>
+ o.order_status = #{status}
+ </otherwise>
+ </choose>
</if>
<if test="userId != null">
AND o.app_user_id = #{userId}
@@ -33,7 +41,8 @@
o.num,
o.point,
o.payment_amount,
- o.create_time
+ o.create_time,
+ o.express_amount
ORDER BY
o.create_time DESC
</select>
@@ -90,5 +99,34 @@
<if test="startTime != null and '' != startTime and endTime != null and '' != endTime">
and tor.create_time between #{startTime} and #{endTime}
</if>
+ <if test="null != shopId">
+ and tor.shop_id = #{shopId}
+ </if>
+ </select>
+
+
+ <select id="getGoodsSaleNum" resultType="int">
+ select
+ ifnull(sum(a.num), 0)
+ from t_order_good a
+ left join t_order b on (a.order_id = b.id)
+ where b.del_flag = 0 and b.pay_status = 2 and b.order_status in (1, 2, 3, 4, 7, 8) and a.goods_id = #{goodsId}
+ <if test="null != type">
+ and a.type = #{type}
+ </if>
+ </select>
+
+
+ <select id="getShopSaleNum" resultType="int">
+ select
+ ifnull(count(1), 0)
+ from t_order a
+ where del_flag = 0 and pay_status = 2 and order_status in (1, 2, 3, 4, 7, 8)
+ <if test="null != shopId and 0 != shopId">
+ and shop_id = #{shopId}
+ </if>
+ <if test="null != type">
+ and order_type = #{type}
+ </if>
</select>
</mapper>
diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/RefundPassMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/RefundPassMapper.xml
index 270358b..28f8142 100644
--- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/RefundPassMapper.xml
+++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/RefundPassMapper.xml
@@ -11,7 +11,8 @@
DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%m:%s') as createTime,
a.refund_method as refundMethod,
a.refund_reason as refundReason,
- a.pass_status as passStatus
+ a.pass_status as passStatus,
+ a.status
from t_refund_pass a
left join t_order b on (a.order_id = b.id)
where a.del_flag = 0
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java
index 6cc0e7b..2aee854 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java
@@ -56,6 +56,15 @@
@ApiOperation(value = "获取基础配置", tags = {"管理后台-基础配置"})
public R<BaseSetting> getBaseSetting(@RequestParam("id") Integer id){
BaseSetting baseSetting = baseSettingService.getById(id);
+ return R.ok(baseSetting);
+ }
+
+
+ @ResponseBody
+ @GetMapping("/getBaseSetting1")
+ @ApiOperation(value = "获取基础配置", tags = {"小程序-基础配置"})
+ public R<BaseSetting> getBaseSetting1(@RequestParam("id") Integer id){
+ BaseSetting baseSetting = baseSettingService.getById(id);
Long userid = tokenService.getLoginUserApplet().getUserid();
AppUser appUser = appUserClient.getAppUserById(userid);
VipSetting vipSetting = vipSettingService.getById(appUser.getVipId());
@@ -64,6 +73,7 @@
return R.ok(baseSetting);
}
+
/**
* 保存设置
*/
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java
index f7de2e1..45f16c3 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java
@@ -205,9 +205,14 @@
}
-
-
-
+ /**
+ * 根据类型获取有效优惠券列表
+ */
+ @PostMapping("/getCouponInfoByPersonType")
+ public R<List<CouponInfo>> getCouponInfoByPersonType(@RequestParam("personType") Integer personType){
+ List<CouponInfo> list = couponInfoService.list(new LambdaUpdateWrapper<CouponInfo>().eq(CouponInfo::getPersonType, personType).eq(CouponInfo::getDelFlag, 0).eq(CouponInfo::getShelfStatus, 1).last(" and now() between period_start_time and period_end_time"));
+ return R.ok(list);
+ }
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
index 3cc2ec4..099cb27 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
@@ -154,8 +154,8 @@
*/
@GetMapping("/goodsDetail/{goodsId}")
@ApiOperation(value = "商品详情", tags = {"小程序-商城-首页"})
- public R<GoodsVO> goodsDetail(@PathVariable("goodsId") Long goodsId){
- return R.ok(goodsService.goodsDetail(goodsId));
+ public R<GoodsVO> goodsDetail(@PathVariable("goodsId") Long goodsId, String longitude, String latitude){
+ return R.ok(goodsService.goodsDetail(goodsId, longitude, latitude));
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java
index 11a35a9..3779fe3 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java
@@ -46,9 +46,9 @@
*/
@ResponseBody
@PostMapping("/getNowOrderActivityInfo")
- public R<OrderActivityInfo> getNowOrderActivityInfo(@RequestParam("vip") Integer vip){
- OrderActivityInfo one = orderActivityInfoService.getOne(new LambdaQueryWrapper<OrderActivityInfo>().eq(OrderActivityInfo::getDelFlag, 0)
- .last(" and now() between start_time and end_time and FIND_IN_SET(" + vip + ", vip_ids) limit 0, 1"));
+ public R<List<OrderActivityInfo>> getNowOrderActivityInfo(@RequestParam("vip") Integer vip){
+ List<OrderActivityInfo> one = orderActivityInfoService.list(new LambdaQueryWrapper<OrderActivityInfo>().eq(OrderActivityInfo::getDelFlag, 0)
+ .eq(OrderActivityInfo::getIsShelf, 1).last(" and now() between start_time and end_time and FIND_IN_SET(" + vip + ", vip_ids)"));
return R.ok(one);
}
@@ -96,9 +96,10 @@
Page<OrderActivityInfo> page = orderActivityInfoService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<OrderActivityInfo>()
.eq(orderActivityInfo.getId() != null, OrderActivityInfo::getId, orderActivityInfo.getId())
.eq(StringUtils.isNotEmpty(orderActivityInfo.getActivityName()), OrderActivityInfo::getActivityName, orderActivityInfo.getActivityName())
- .lt(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 0, OrderActivityInfo::getStartTime, orderActivityInfo.getStartTime())
- .ge(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 1, OrderActivityInfo::getEndTime, orderActivityInfo.getStartTime())
- .eq(orderActivityInfo.getIsShelf() != null, OrderActivityInfo::getIsShelf, orderActivityInfo.getIsShelf()));
+ .gt(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 0, OrderActivityInfo::getStartTime, LocalDateTime.now())
+ .ge(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 1, OrderActivityInfo::getEndTime, LocalDateTime.now())
+ .lt(orderActivityInfo.getStatus() != null && orderActivityInfo.getStatus() == 1, OrderActivityInfo::getStartTime, LocalDateTime.now())
+ .eq(orderActivityInfo.getIsShelf() != null, OrderActivityInfo::getIsShelf, orderActivityInfo.getIsShelf()).orderByDesc(OrderActivityInfo::getCreateTime));
page.getRecords().forEach(item -> {
LocalDateTime startTime = item.getStartTime();
LocalDateTime now = LocalDateTime.now();
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java
index 50b09d0..1a8fb82 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java
@@ -72,9 +72,9 @@
*/
@GetMapping("/detail/{id}")
@ApiOperation(value = "秒杀活动详情", tags = {"小程序-商城-首页"})
- public R<SeckillActivityDetailVO> detail(@PathVariable("id") Integer id)
+ public R<SeckillActivityDetailVO> detail(@PathVariable("id") Integer id, String latitude, String longitude)
{
- return R.ok(seckillActivityInfoService.detail(id));
+ return R.ok(seckillActivityInfoService.detail(id, latitude, longitude));
}
@@ -97,6 +97,18 @@
/**
+ * 获取商品秒杀活动
+ * @param id
+ * @return
+ */
+ @PostMapping("/getSeckillActivityInfoById")
+ public R<SeckillActivityInfo> getSeckillActivityInfoById(@RequestParam("id") Integer id){
+ SeckillActivityInfo one = seckillActivityInfoService.getById(id);
+ return R.ok(one);
+ }
+
+
+ /**
* 秒杀活动列表
*/
@GetMapping("/manageList")
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java
index 7fa27cd..113022a 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java
@@ -15,6 +15,8 @@
import com.ruoyi.other.enums.ShareAddType;
import com.ruoyi.other.enums.ShareAuditStatus;
import com.ruoyi.other.service.ShareService;
+import com.ruoyi.system.api.domain.SysUser;
+import com.ruoyi.system.api.feignClient.SysUserClient;
import com.ruoyi.system.api.model.LoginUser;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;
@@ -42,6 +44,8 @@
private AppUserClient appUserClient;
@Resource
private ShopClient shopClient;
+ @Resource
+ private SysUserClient sysUserClient;
@@ -64,7 +68,7 @@
public R<List<Share>> recommandlist() {
Long userid = tokenService.getLoginUserApplet().getUserid();
return R.ok(shareService.list(new LambdaQueryWrapper<Share>().eq(Share::getAddType, 2)
- .eq(Share::getObjectId, userid)));
+ .eq(Share::getObjectId, userid).or().eq(Share::getAddType, 1).eq(Share::getAuditStatus, 1).eq(Share::getDelFlag, 0)));
}
@@ -123,10 +127,13 @@
public R<Void> manage(@RequestBody Share share) {
LoginUser loginUser = SecurityUtils.getLoginUser();
Long userid = loginUser.getSysUser().getUserId();
- share.setAddType(1);
+ SysUser sysUser = sysUserClient.getSysUser(userid).getData();
+ share.setAddType(sysUser.getRoleType() == 1 ? 1 : 3);
share.setAppletShare(0);
share.setAuditStatus(ShareAuditStatus.SUCCESS.getCode());
- share.setObjectId(userid.toString());
+ if(sysUser.getRoleType() == 2){
+ share.setObjectId(sysUser.getObjectId().toString());
+ }
share.setDelFlag(0);
shareService.save(share);
return R.ok();
@@ -135,7 +142,6 @@
@ApiOperation(value = "广告管理-分享管理-编辑", tags = {"管理后台"})
@PostMapping("/manage/edit")
public R<Void> manageedit(@RequestBody Share share) {
-
shareService.updateById(share);
return R.ok();
}
@@ -143,7 +149,6 @@
@ApiOperation(value = "广告管理-分享管理-删除", tags = {"管理后台"})
@GetMapping("/manage/delete")
public R<Void> managedelete(@RequestParam Integer id) {
-
shareService.removeById(id);
return R.ok();
}
@@ -153,10 +158,14 @@
public R<Page<Share>> managelist(String name, Integer addType, @RequestParam Integer pageNum, Integer pageSize) {
//判断当前登陆人是平台还是门店
if (tokenService.getLoginUser().getSysUser().getRoleType()==1) {
- Page<Share> page = shareService.lambdaQuery().eq(Share::getAuditStatus, 1).like(name != null, Share::getName, name).eq(addType != null, Share::getAddType, addType).page(Page.of(pageNum, pageSize));
+ Page<Share> page = shareService.lambdaQuery().eq(Share::getAuditStatus, 1).like(name != null, Share::getName, name)
+ .eq(Share::getAddType, 1).page(Page.of(pageNum, pageSize));
return R.ok(page);
}else {
- Page<Share> page = shareService.lambdaQuery().eq(Share::getAddType,3).eq(Share::getObjectId, tokenService.getLoginUser().getSysUser().getObjectId()).like(name != null, Share::getName, name).eq(addType != null, Share::getAddType, addType).page(Page.of(pageNum, pageSize));
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser sysUser = sysUserClient.getSysUser(userid).getData();
+ Page<Share> page = shareService.lambdaQuery().eq(Share::getAddType,3).eq(Share::getObjectId, sysUser.getObjectId())
+ .like(name != null, Share::getName, name).page(Page.of(pageNum, pageSize));
return R.ok(page);
}
}
@@ -183,7 +192,7 @@
@ApiOperation(value = "广告管理-分享管理-审核列表", tags = {"管理后台"})
@GetMapping("/manage/auth/list")
public R<Page<Share>> authmanagelist(String name, Integer addType, @RequestParam Integer pageNum, Integer pageSize) {
- Page<Share> page = shareService.lambdaQuery().ne(Share::getAuditStatus, 1).like(name != null, Share::getName, name).eq(addType != null, Share::getAddType, addType).page(Page.of(pageNum, pageSize));
+ Page<Share> page = shareService.lambdaQuery().ne(Share::getAuditStatus, 1).like(name != null, Share::getName, name).eq(addType != null, Share::getAddType, addType).orderByAsc(Share::getAuditStatus).page(Page.of(pageNum, pageSize));
for (Share record : page.getRecords()) {
if (record.getAddType() == 2) {
AppUser appUserById = appUserClient.getAppUserById(Long.valueOf(record.getObjectId()));
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
index d1bac18..ee35476 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -11,6 +11,7 @@
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.security.utils.SecurityUtils;
+import com.ruoyi.order.feignClient.OrderClient;
import com.ruoyi.order.vo.VerifiableShopVo;
import com.ruoyi.other.api.domain.Goods;
import com.ruoyi.other.api.domain.GoodsShop;
@@ -77,6 +78,8 @@
private GoodsService goodsService;
@Resource
private GoodsShopService goodsShopService;
+ @Resource
+ private OrderClient orderClient;
@@ -179,7 +182,6 @@
Shop shop = shopService.getById(id);
shop.setDelFlag(1);
shopService.updateById(shop);
- //获取门店的员工数据
UserShop userShop = new UserShop();
userShop.setShopId(shop.getId());
List<UserShop> data = userShopClient.getUserShop(userShop).getData();
@@ -189,16 +191,19 @@
sysUserClient.delShopUser(shop.getId(), 2);
//修改小程序用户类型和门店数据
for (SysUser sysUser : sysUserList) {
- String userName = sysUser.getUserName();
//通过电话号码查询小程序用户和门店关系数据
- AppUser appUser = appUserClient.getAppUserByPhone1(userName).getData();
+ AppUser appUser = appUserClient.getAppUserByPhone1(sysUser.getUserName()).getData();
//需要先判断用户是否没有关联任何门店
List<AppUserShop> userShops = appUserShopClient.getAppUserShop(appUser.getId()).getData();
if(userShops.size() == 1 && userShops.get(0).getShopId().equals(shop.getId())){
appUser.setUserType(1);
appUserClient.editAppUserById(appUser);
}
-
+ //删除用户门店关系表数据
+ AppUserShop appUserShop = new AppUserShop();
+ appUserShop.setAppUserId(appUser.getId());
+ appUserShop.setShopId(shop.getId());
+ appUserShopClient.delAppUserShop(appUserShop);
}
return R.ok();
}
@@ -282,6 +287,22 @@
}
return R.ok();
}
+
+
+ @PutMapping("/freezingOrThawing")
+ @ApiOperation(value = "门店管理-冻结/解冻门店", tags = {"管理后台-门店管理"})
+ public R freezingOrThawing(@RequestParam("id") Integer id, @RequestParam("status") Integer status){
+ Shop shop = shopService.getById(id);
+ if(shop.getStatus().equals(status)){
+ return R.fail("不能重复操作");
+ }
+ shop.setStatus(status);
+ shopService.updateById(shop);
+ return R.ok();
+ }
+
+
+
@GetMapping("/list")
@ApiOperation(value = "门店列表", tags = {"管理后台-门店管理"})
@@ -383,6 +404,9 @@
@ApiOperation(value = "绑定门店", tags = {"小程序-个人中心"})
public R<Void> bindShop(@ApiParam("门店id") @RequestParam Integer shopId) {
AppUser appUser = appUserClient.getAppUserById(SecurityUtils.getUserId());
+ if(null != appUser.getShopId()){
+ return R.fail("不能重复绑定门店");
+ }
appUser.setShopId(shopId);
return appUserClient.editAppUserById(appUser);
}
@@ -418,7 +442,7 @@
@ResponseBody
@PostMapping("/getShopByUserId")
public R<List<Shop>> getShopByUserId(@RequestParam("id") Long id){
- List<Shop> list = shopService.lambdaQuery().eq(Shop::getAppUserId, id).list();
+ List<Shop> list = shopService.lambdaQuery().eq(Shop::getAppUserId, id).eq(Shop::getDelFlag,0).list();
return R.ok(list);
}
@@ -455,6 +479,14 @@
@ApiOperation(value = "门店统计", tags = {"管理后台-首页统计"})
public R<ShopStatistics> shopStatistics(@ApiParam("门店id") Integer shopId) {
ShopStatistics shopStatistics = shopMapper.getShopStatistics(shopId);
+ if(null == shopId){
+ shopId = 0;
+ }
+ Integer serviceOrder = orderClient.getShopSaleNum(shopId, 1).getData();
+ Integer goodsOrder = orderClient.getShopSaleNum(shopId, 2).getData();
+ shopStatistics.setTotalOrder(serviceOrder + goodsOrder);
+ shopStatistics.setServiceOrder(serviceOrder);
+ shopStatistics.setGoodsOrder(goodsOrder);
return R.ok(shopStatistics);
}
@@ -476,12 +508,16 @@
@ApiOperation(value = "获取可核销门店列表", tags = {"购物车-小程序"})
public R<List<VerifiableShopVo>> getVerifiableShop(String longitude, String latitude, Integer goodsId){
String city = TencentMapUtil.inverseGeographicalAnalysis(longitude, latitude, false);
+ if(null == city){
+ city = "510100";
+ }
city = city.substring(0, 4) + "00";
LambdaQueryWrapper<Shop> wrapper = new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getCityCode, city);
if(null != goodsId){
Goods goods = goodsService.getById(goodsId);
if(1 == goods.getType() && 1 == goods.getAppointStore()){
- List<Integer> collect = goodsShopService.list(new LambdaQueryWrapper<GoodsShop>().eq(GoodsShop::getGoodsId, goods)).stream().map(GoodsShop::getShopId).collect(Collectors.toList());
+ List<Integer> collect = goodsShopService.list(new LambdaQueryWrapper<GoodsShop>().eq(GoodsShop::getGoodsId, goods.getId()))
+ .stream().map(GoodsShop::getShopId).collect(Collectors.toList());
if(collect.size() > 0){
wrapper.in(Shop::getId, collect);
}
@@ -538,5 +574,16 @@
shopService.saveWithdrawalAccount(saveWithdrawalAccount);
return R.ok();
}
+
+
+ /**
+ * 获取所有门店
+ * @return
+ */
+ @PostMapping("/getAllShop")
+ public R<List<Shop>> getAllShop(){
+ List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1));
+ return R.ok(list);
+ }
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java
index 7c58751..50fc680 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java
@@ -9,6 +9,8 @@
import com.ruoyi.other.api.domain.ShopPoint;
import com.ruoyi.other.service.ShopPointService;
import com.ruoyi.other.vo.ShopPointStatistics;
+import com.ruoyi.system.api.domain.SysUser;
+import com.ruoyi.system.api.feignClient.SysUserClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
@@ -32,6 +34,8 @@
private ShopPointService shopPointService;
@Resource
private TokenService tokenService;
+ @Resource
+ private SysUserClient sysUserClient;
/**
@@ -47,16 +51,18 @@
@GetMapping("/shop/statistics")
@ApiOperation(value = "门店积分统计", notes = "门店积分统计", tags = {"门店后台"})
public R<ShopPointStatistics> shopstatistics(ShopPoint shopPoint) {
- Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId();
- shopPoint.setShopId(objectId);
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser sysUser = sysUserClient.getSysUser(userid).getData();
+ shopPoint.setShopId(sysUser.getObjectId());
ShopPointStatistics statistics = shopPointService.statistics(Page.of(shopPoint.getPageNum(), shopPoint.getPageSize()), shopPoint);
return R.ok(statistics);
}
@GetMapping("/shop/statistics/list")
@ApiOperation(value = "门店积分统计列表", notes = "门店积分统计", tags = {"门店后台"})
public R<Page<ShopPoint>> shopstatisticslist(ShopPoint shopPoint,Integer pageNum,Integer pageSize) {
- Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId();
- Page<ShopPoint> page = shopPointService.lambdaQuery().eq(ShopPoint::getShopId, objectId).eq(shopPoint.getType()!=null,ShopPoint::getType, shopPoint.getType())
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser sysUser = sysUserClient.getSysUser(userid).getData();
+ Page<ShopPoint> page = shopPointService.lambdaQuery().eq(ShopPoint::getShopId, sysUser.getObjectId()).eq(shopPoint.getType()!=null,ShopPoint::getType, shopPoint.getType())
.like(shopPoint.getOrderNum()!=null,ShopPoint::getOrderNum, shopPoint.getOrderNum())
.orderByDesc(ShopPoint::getCreateTime)
.page(Page.of(pageNum, pageSize));
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianController.java
index bd8b676..931bc30 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianController.java
@@ -3,6 +3,8 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.account.api.feignClient.AppUserClient;
+import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.TableDataInfo;
@@ -119,11 +121,41 @@
.page(Page.of(pageNum, pageSize));
return R.ok(page);
}
+
+ @Resource
+ private AppUserClient appUserClient;
@PostMapping("/manage/addorupdate")
@ApiOperation(value = "添加编辑", tags = {"门店-技师列表"})
public R<Page<Technician>> add(@RequestBody Technician technician) {
Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId();
+ if (technician.getId()==null) {
+ technician.setSubscribeStatus(2);
+ List<Technician> list = technicianService.lambdaQuery().eq(Technician::getPhone, technician.getPhone()).list();
+ if (!list.isEmpty()) {
+ return R.fail("当前号码已经添加");
+ }
+ R<AppUser> appUserByPhone1 = appUserClient.getAppUserByPhone1(technician.getPhone());
+ if (appUserByPhone1.getData()==null){
+ return R.fail("当前号码暂无注册用户");
+ }
+ }else {
+ Technician byId = technicianService.getById(technician.getId());
+ if (byId.getPhone()!=technician.getPhone()){
+ List<Technician> list = technicianService.lambdaQuery().eq(Technician::getPhone, technician.getPhone()).list();
+ if (!list.isEmpty()) {
+ return R.fail("当前号码已经添加");
+ }
+ R<AppUser> appUserByPhone1 = appUserClient.getAppUserByPhone1(technician.getPhone());
+ if (appUserByPhone1.getData()==null){
+ return R.fail("当前号码暂无注册用户");
+ }
+ }
+ }
technician.setShopId(objectId);
+ R<AppUser> appUserByPhone1 = appUserClient.getAppUserByPhone1(technician.getPhone());
+ if (appUserByPhone1.getData()!=null){
+ technician.setAppUserId(appUserByPhone1.getData().getId());
+ }
technicianService.saveOrUpdate(technician);
return R.ok();
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java
index af7a01b..740990f 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java
@@ -14,6 +14,8 @@
import com.ruoyi.other.api.domain.TechnicianSubscribe;
import com.ruoyi.other.service.TechnicianSubscribeService;
import com.ruoyi.other.vo.TechnicianSubscribeVO;
+import com.ruoyi.system.api.domain.SysUser;
+import com.ruoyi.system.api.feignClient.SysUserClient;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;
@@ -36,6 +38,12 @@
private TechnicianSubscribeService technicianSubscribeService;
@Resource
private TokenService tokenService;
+ @Resource
+ private SysUserClient sysUserClient;
+
+
+
+
@GetMapping("/shop/list")
@@ -44,8 +52,9 @@
@ApiParam("电话")String phone,
@ApiParam("姓名")String name,
@ApiParam("服务方式:1=上门服务,2=到店服务")Integer serviceMode, Integer pageCurr, Integer pageSize) {
- Integer objectId = tokenService.getLoginUser().getSysUser().getObjectId();
- PageInfo<TechnicianSubscribeVO> pageInfo = technicianSubscribeService.getTechnicianSubscribeByUserAndShop1(Long.valueOf(objectId), status, phone, name, serviceMode, pageCurr, pageSize);
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser sysUser = sysUserClient.getSysUser(userid).getData();
+ PageInfo<TechnicianSubscribeVO> pageInfo = technicianSubscribeService.getTechnicianSubscribeByUserAndShop1(Long.valueOf(sysUser.getObjectId()), status, phone, name, serviceMode, pageCurr, pageSize);
return R.ok(pageInfo);
}
@@ -76,7 +85,6 @@
@GetMapping("/cancel")
@ApiOperation(value = "取消服务", notes = "取消服务", tags = {"小程序-个人中心-门店管理,小程序-个人中心-我的预约","门店-预约管理"})
public R<Void> cancel(@ApiParam(value = "预约id") @RequestParam Long id) {
-
TechnicianSubscribe subscribe = technicianSubscribeService.getOne(new LambdaQueryWrapper<TechnicianSubscribe>()
.eq(TechnicianSubscribe::getId, id)
.eq(TechnicianSubscribe::getStatus, 0));
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsMapper.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsMapper.java
index 2a308cd..f1017a1 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsMapper.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsMapper.java
@@ -18,6 +18,7 @@
* @since 2024-11-20
*/
public interface GoodsMapper extends BaseMapper<Goods> {
+
List<Goods> selectListByShopId(PageInfo<Goods> pageInfo, @Param("shopId") Integer shopId,@Param("vip") Integer vip);
IPage<Goods> selectManageGoodsList(@Param("page") IPage<Goods> page, @Param("goods") Goods goods);
@@ -30,5 +31,5 @@
* @param name
* @return
*/
- List<GoodsVO> goodsList(PageInfo<GoodsVO> pageInfo, @Param("goodsCategoryId") Integer goodsCategoryId, @Param("name") String name);
+ List<GoodsVO> goodsList(PageInfo<GoodsVO> pageInfo, @Param("goodsCategoryId") Integer goodsCategoryId, @Param("name") String name, @Param("vip") Integer vip);
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java
index df25f9d..f4ff1c0 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java
@@ -26,7 +26,7 @@
List<NearbyShopVO> selectNearbyShopList(@Param("longitude") BigDecimal longitude,@Param("latitude") BigDecimal latitude);
- ShopDetailVO selectShopDetail(Integer shopId);
+ ShopDetailVO selectShopDetail(@Param("shopId") Integer shopId);
ShopStatistics getShopStatistics(@Param("shopId") Integer shopId);
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsService.java
index 4d7accd..3d2b3e2 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsService.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsService.java
@@ -21,7 +21,7 @@
PageInfo<GoodsVO> goodsList(Goods goods);
- GoodsVO goodsDetail(Long goodsId);
+ GoodsVO goodsDetail(Long goodsId, String longitude, String latitude);
List<Goods> getGoodsListByShopId(PageInfo<Goods> pageInfo, Integer shopId);
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/SeckillActivityInfoService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/SeckillActivityInfoService.java
index 2f4023b..e99a6fa 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/SeckillActivityInfoService.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/SeckillActivityInfoService.java
@@ -20,7 +20,7 @@
List<SeckillActivityVO> listSeckillActivity(Goods goods);
- SeckillActivityDetailVO detail(Integer seckillActivityId);
+ SeckillActivityDetailVO detail(Integer seckillActivityId, String latitude, String longitude);
void saveSeckillActivityInfo(SeckillActivityInfo seckillActivityInfo);
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java
index 9d5d3d4..27f5bd2 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java
@@ -31,4 +31,10 @@
IPage<TechnicianSubscribeVO> getTechnicianSubscribeByUser(Page<TechnicianSubscribe> page, Long userId, Integer status);
void subscribe(TechnicianSubscribe technicianSubscribe);
+
+
+ /**
+ * 定时修改到期状态
+ */
+ void taskEditStstus();
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/VipSettingService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/VipSettingService.java
index 2302088..aef5579 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/VipSettingService.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/VipSettingService.java
@@ -15,5 +15,4 @@
VipSetting getVipSettingByUserId(Long userId);
- void downUsers();
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
index d647b1d..80dc58a 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -15,15 +16,19 @@
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.security.utils.SecurityUtils;
+import com.ruoyi.order.feignClient.OrderClient;
import com.ruoyi.order.feignClient.RemoteOrderGoodsClient;
import com.ruoyi.order.vo.Price;
import com.ruoyi.other.api.domain.*;
+import com.ruoyi.other.api.vo.GetGoodsBargainPrice;
+import com.ruoyi.other.api.vo.GetSeckillActivityInfo;
import com.ruoyi.other.enums.GoodsStatus;
import com.ruoyi.other.mapper.GoodsAreaMapper;
import com.ruoyi.other.mapper.GoodsMapper;
import com.ruoyi.other.mapper.GoodsShopMapper;
import com.ruoyi.other.mapper.ShopMapper;
import com.ruoyi.other.service.*;
+import com.ruoyi.other.util.GeodesyUtil;
import com.ruoyi.other.vo.GoodsVO;
import com.ruoyi.system.api.model.LoginUser;
import org.jetbrains.annotations.NotNull;
@@ -71,60 +76,68 @@
private GoodsAreaService goodsAreaService;
@Resource
private RemoteOrderGoodsClient remoteOrderGoodsClient;
+ @Resource
+ private SeckillActivityInfoService seckillActivityInfoService;
+ @Resource
+ private GoodsSeckillService goodsSeckillService;
+ @Resource
+ private GoodsBargainPriceService goodsBargainPriceService;
+ @Resource
+ private GoodsBargainPriceDetailService goodsBargainPriceDetailService;
+ @Resource
+ private OrderClient orderClient;
+
+
@Override
public PageInfo<GoodsVO> goodsList(Goods search) {
PageInfo<GoodsVO> pageInfo = new PageInfo(search.getPageCurr(), search.getPageSize());
- List<GoodsVO> list = this.baseMapper.goodsList(pageInfo, search.getGoodsCategoryId(), search.getName());
- Long userId = null;
+ Integer vipId = 0;
+ String provinceCode = null;
+ String cityCode = null;
+ String districtCode = null;
String token = SecurityUtils.getToken(ServletUtils.getRequest());
if(StringUtils.isNotEmpty(token)){
- userId = tokenService.getLoginUserApplet().getUserid();
+ Long userid = tokenService.getLoginUserApplet().getUserid();
+ AppUser appUser = appUserClient.getAppUserById(userid);
+ vipId = appUser.getVipId();
+ provinceCode = appUser.getProvinceCode();
+ cityCode = appUser.getCityCode();
+ districtCode = appUser.getDistrictCode();
}
+ List<GoodsVO> list = this.baseMapper.goodsList(pageInfo, search.getGoodsCategoryId(), search.getName(), vipId);
for (GoodsVO goods : list) {
- //游客展示基础售价
- if(null != userId){
- R<Price> r = remoteOrderGoodsClient.getGoodsPrice(userId, goods.getGoodsId(), null);
- if (null != r.getData()){
- Price price = r.getData();
- goods.setSellingPrice(price.getCash());
- goods.setIntegral(price.getPoint());
- }
+ Price price = getPrice(vipId, goods.getGoodsId(), null, 1, provinceCode, cityCode, districtCode);
+ if(null != price){
+ goods.setCashPayment(price.getCashPayment() ? 1 : 0);
+ goods.setPointPayment(price.getPointPayment() ? 1 : 0);
+ goods.setSellingPrice(price.getCash());
+ goods.setIntegral(price.getPoint());
}
+ Integer data = orderClient.getGoodsSaleNum(goods.getGoodsId(), 1).getData();
+ goods.setSaleNum(data);
}
return pageInfo.setRecords(list);
}
@Override
- public GoodsVO goodsDetail(Long goodsId) {
+ public GoodsVO goodsDetail(Long goodsId, String longitude, String latitude) {
if (goodsId == null || goodsId <= 0) {
throw new NullPointerException("商品ID不能为空");
}
- LoginUser loginUserApplet = tokenService.getLoginUserApplet();
- AppUser appUser = appUserClient.getAppUserById(loginUserApplet.getUserid());
- BigDecimal sellingPrice = BigDecimal.ZERO;
- Integer integral = 0;
-
- GoodsArea goodsArea = goodsAreaMapper.selectOne(new LambdaQueryWrapper<GoodsArea>()
- .eq(GoodsArea::getGoodsId, goodsId)
- .eq(GoodsArea::getVip, appUser.getVipId())
- .eq(GoodsArea::getProvinceCode, appUser.getProvinceCode())
- .eq(StringUtils.isNotEmpty(appUser.getCityCode()), GoodsArea::getCityCode, appUser.getCityCode())
- .eq(StringUtils.isNotEmpty(appUser.getDistrictCode()), GoodsArea::getDistrictsCode, appUser.getDistrictCode()));
-
- if (Objects.nonNull(goodsArea)){
- sellingPrice = goodsArea.getSellingPrice();
- integral = goodsArea.getIntegral();
- }else {
- VipSetting vipSetting = vipSettingService.getVipSettingByUserId(loginUserApplet.getUserid());
- GoodsVip goodsVip = goodsVipService.getOne(new LambdaQueryWrapper<GoodsVip>()
- .eq(GoodsVip::getVip, vipSetting.getId())
- .eq(GoodsVip::getGoodsId, goodsId));
- if(null != goodsVip){
- sellingPrice = goodsVip.getSellingPrice();
- integral = goodsVip.getIntegral();
- }
+ Integer vipId = 0;
+ String provinceCode = null;
+ String cityCode = null;
+ String districtCode = null;
+ String token = SecurityUtils.getToken(ServletUtils.getRequest());
+ if(StringUtils.isNotEmpty(token)){
+ Long userid = tokenService.getLoginUserApplet().getUserid();
+ AppUser appUser = appUserClient.getAppUserById(userid);
+ vipId = appUser.getVipId();
+ provinceCode = appUser.getProvinceCode();
+ cityCode = appUser.getCityCode();
+ districtCode = appUser.getDistrictCode();
}
Goods goods = this.getById(goodsId);
@@ -132,8 +145,13 @@
BeanUtils.copyBeanProp(goodsVO, goods);
goodsVO.setGoodsId(goods.getId());
goodsVO.setGoodsName(goods.getName());
- goodsVO.setSellingPrice(sellingPrice);
- goodsVO.setIntegral(integral);
+ Price price = getPrice(vipId, goods.getId(), null, 1, provinceCode, cityCode, districtCode);
+ if(null != price){
+ goodsVO.setPointPayment(price.getPointPayment() ? 1 : 0);
+ goodsVO.setCashPayment(price.getCashPayment() ? 1 : 0);
+ goodsVO.setSellingPrice(price.getCash());
+ goodsVO.setIntegral(price.getPoint());
+ }
if(goods.getType() == 1){
if(goods.getAppointStore() == 2){
@@ -155,15 +173,52 @@
.in(Shop::getDelFlag, 0));
goodsVO.setShopList(shopList);
}
+ List<Shop> shopList = goodsVO.getShopList();
+ for (Shop shop : shopList) {
+ Double wgs84 = GeodesyUtil.getDistance(longitude + "," + latitude, shop.getLongitude() + "," + shop.getLatitude()).get("WGS84");
+ shop.setDistance(wgs84);
+ }
+ shopList.sort(new Comparator<Shop>() {
+ @Override
+ public int compare(Shop o1, Shop o2) {
+ return o1.getDistance().compareTo(o2.getDistance());
+ }
+ });
+ goodsVO.setShopList(shopList);
+ Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 1).getData();
+ goodsVO.setSaleNum(integer);
return goodsVO;
}
@Override
public List<Goods> getGoodsListByShopId(PageInfo<Goods> pageInfo, Integer shopId) {
- LoginUser loginUserApplet = tokenService.getLoginUserApplet();
- VipSetting vipSetting = vipSettingService.getVipSettingByUserId(loginUserApplet.getUserid());
- return goodsMapper.selectListByShopId(pageInfo, shopId, vipSetting.getId());
+ Integer vipId = 0;
+ String provinceCode = null;
+ String cityCode = null;
+ String districtCode = null;
+ String token = SecurityUtils.getToken(ServletUtils.getRequest());
+ if(StringUtils.isNotEmpty(token)){
+ Long userid = tokenService.getLoginUserApplet().getUserid();
+ AppUser appUser = appUserClient.getAppUserById(userid);
+ vipId = appUser.getVipId();
+ provinceCode = appUser.getProvinceCode();
+ cityCode = appUser.getCityCode();
+ districtCode = appUser.getDistrictCode();
+ }
+ List<Goods> goods = goodsMapper.selectListByShopId(pageInfo, shopId, vipId);
+ for (Goods good : goods) {
+ Price price = getPrice(vipId, good.getId(), shopId, 1, provinceCode, cityCode, districtCode);
+ if(null != price){
+ good.setCashPayment(price.getCashPayment() ? 1 : 0);
+ good.setPointPayment(price.getPointPayment() ? 1 : 0);
+ good.setSellingPrice(price.getCash());
+ good.setIntegral(price.getPoint());
+ }
+ Integer data = orderClient.getGoodsSaleNum(good.getId(), 1).getData();
+ good.setSaleNum(data);
+ }
+ return goods;
}
@Override
@@ -232,6 +287,7 @@
if (!CollectionUtils.isEmpty(goodsAreaList)){
for (GoodsArea goodsArea : goodsAreaList) {
List<GoodsArea> goodsAreaList1 = goodsArea.getGoodsAreaList();
+ List<GoodsArea> goodsAreaList2 = new ArrayList<>();
for (GoodsArea area : goodsAreaList1) {
area.setId(null);
area.setGoodsId(id);
@@ -241,8 +297,11 @@
area.setProvinceCode(goodsArea.getProvinceCode());
area.setCityCode(goodsArea.getCityCode());
area.setDistrictsCode(goodsArea.getDistrictsCode());
+ if(null != area.getSellingPrice() && null != area.getIntegral()){
+ goodsAreaList2.add(area);
+ }
}
- goodsAreaService.saveBatch(goodsAreaList1);
+ goodsAreaService.saveBatch(goodsAreaList2);
}
}
}
@@ -376,4 +435,112 @@
goodsArea1.setGoodsAreaList(goodsAreas);
return goodsArea1;
}
+
+
+ /**
+ * 根据商品的价格配置体系获取商品当前的价格
+ * @param vip
+ * @param goodsId
+ * @param type 1普通商品,2秒杀商品
+ * @param shopId
+ * @param provinceCode
+ * @param cityCode
+ * @param districtCode
+ * @return
+ */
+ public Price getPrice(Integer vip, Integer goodsId, Integer shopId, Integer type, String provinceCode, String cityCode, String districtCode){
+ //获取支付价格
+ //秒杀活动>门店特价>地区价格>会员价格
+ //判断是否有秒杀活动
+ Price price = new Price();
+ SeckillActivityInfo one = seckillActivityInfoService.getOne(new LambdaQueryWrapper<SeckillActivityInfo>().eq(SeckillActivityInfo::getGoodId, goodsId)
+ .eq(SeckillActivityInfo::getIsShelves, 1).eq(SeckillActivityInfo::getDelFlag, 0)
+ .last(" and now() between start_time and end_time and FIND_IN_SET(" + vip + ", vip_ids) order by create_time desc limit 0, 1"));
+ GoodsSeckill goodsSeckill = null;
+ if(null != one){
+ goodsSeckill = goodsSeckillService.getOne(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, one.getId()).eq(GoodsSeckill::getVip, vip));
+ }
+ //没有秒杀活动或者添加的普通商品则不使用秒杀活动价格
+ if(null == goodsSeckill || type == 1){
+ //没有秒杀价,则判断门店特价
+ GoodsBargainPriceDetail bargainPriceDetail = null;
+ if (shopId != null){
+ GoodsBargainPrice priceServiceOne = goodsBargainPriceService.getOne(new LambdaQueryWrapper<GoodsBargainPrice>().eq(GoodsBargainPrice::getGoodsId, goodsId).eq(GoodsBargainPrice::getShopId, shopId)
+ .eq(GoodsBargainPrice::getDelFlag, 0).eq(GoodsBargainPrice::getAuditStatus, 1).last(" order by create_time desc limit 0, 1"));
+ if(null != priceServiceOne){
+ bargainPriceDetail = goodsBargainPriceDetailService.getOne(new LambdaQueryWrapper<GoodsBargainPriceDetail>().eq(GoodsBargainPriceDetail::getGoodsBargainPriceId, priceServiceOne.getId()).eq(GoodsBargainPriceDetail::getVip, vip));
+ }
+ }
+ if(null == bargainPriceDetail){
+ //没有门店特价,判断地区价格配置
+ LambdaQueryWrapper<GoodsArea> queryWrapper = new LambdaQueryWrapper<GoodsArea>().eq(GoodsArea::getGoodsId, goodsId).eq(GoodsArea::getVip, vip);
+ if(StringUtils.isNotEmpty(districtCode)){
+ queryWrapper.eq(GoodsArea::getDistrictsCode, districtCode);
+ }
+ if(StringUtils.isNotEmpty(cityCode)){
+ queryWrapper.eq(GoodsArea::getCityCode, cityCode);
+ }
+ if(StringUtils.isNotEmpty(provinceCode)){
+ queryWrapper.eq(GoodsArea::getProvinceCode, provinceCode);
+ }
+ GoodsArea goodsArea = goodsAreaService.getOne(queryWrapper);
+ if(null == goodsArea){
+ //没有地区价格,则使用会员价格
+ GoodsVip goodsVip = goodsVipService.getOne(new LambdaQueryWrapper<GoodsVip>().eq(GoodsVip::getGoodsId, goodsId).eq(GoodsVip::getVip, vip));
+ if(null == goodsVip){
+ //没有配置价格,直接使用原始基础价格
+ return null;
+ }else{
+ //构建价格数据
+ if(goodsVip.getCashPayment() == 1 && goodsVip.getPointPayment() == 1){
+ price.setCash(goodsVip.getSellingPrice());
+ price.setPoint(goodsVip.getIntegral());
+ }
+ if(goodsVip.getCashPayment() == 1 && goodsVip.getPointPayment() == 0){
+ price.setCash(goodsVip.getSellingPrice());
+ }
+ if(goodsVip.getCashPayment() == 0 && goodsVip.getPointPayment() == 1){
+ price.setPoint(goodsVip.getIntegral());
+ }
+ price.setCashPayment(goodsVip.getCashPayment() == 1);
+ price.setPointPayment(goodsVip.getPointPayment() == 1);
+ }
+ }else{
+ //构建价格数据
+ if(goodsArea.getCashPayment() == 1 && goodsArea.getPointPayment() == 1){
+ price.setCash(goodsArea.getSellingPrice());
+ price.setPoint(goodsArea.getIntegral());
+ }
+ if(goodsArea.getCashPayment() == 1 && goodsArea.getPointPayment() == 0){
+ price.setCash(goodsArea.getSellingPrice());
+ }
+ if(goodsArea.getCashPayment() == 0 && goodsArea.getPointPayment() == 1){
+ price.setPoint(goodsArea.getIntegral());
+ }
+ price.setCashPayment(goodsArea.getCashPayment() == 1);
+ price.setPointPayment(goodsArea.getPointPayment() == 1);
+ }
+ }else{
+ price.setCash(bargainPriceDetail.getSellingPrice());
+ price.setPoint(bargainPriceDetail.getIntegral());
+ price.setCashPayment(bargainPriceDetail.getSellingPrice() != null);
+ price.setPointPayment(bargainPriceDetail.getIntegral() != null);
+ }
+ }else{
+ //构建价格数据
+ if(goodsSeckill.getCashPayment() == 1 && goodsSeckill.getPointPayment() == 1){
+ price.setCash(goodsSeckill.getSellingPrice());
+ price.setPoint(goodsSeckill.getIntegral());
+ }
+ if(goodsSeckill.getCashPayment() == 1 && goodsSeckill.getPointPayment() == 0){
+ price.setCash(goodsSeckill.getSellingPrice());
+ }
+ if(goodsSeckill.getCashPayment() == 0 && goodsSeckill.getPointPayment() == 1){
+ price.setPoint(goodsSeckill.getIntegral());
+ }
+ price.setCashPayment(goodsSeckill.getCashPayment() == 1);
+ price.setPointPayment(goodsSeckill.getPointPayment() == 1);
+ }
+ return price;
+ }
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java
index 7e23225..cea68dd 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java
@@ -5,7 +5,11 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.AppUser;
+import com.ruoyi.common.core.utils.ServletUtils;
+import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.service.TokenService;
+import com.ruoyi.common.security.utils.SecurityUtils;
+import com.ruoyi.order.feignClient.OrderClient;
import com.ruoyi.other.api.domain.*;
import com.ruoyi.other.mapper.GoodsShopMapper;
import com.ruoyi.other.mapper.SeckillActivityInfoMapper;
@@ -13,6 +17,7 @@
import com.ruoyi.other.service.GoodsSeckillService;
import com.ruoyi.other.service.GoodsService;
import com.ruoyi.other.service.SeckillActivityInfoService;
+import com.ruoyi.other.util.GeodesyUtil;
import com.ruoyi.other.vo.SeckillActivityDetailVO;
import com.ruoyi.other.vo.SeckillActivityVO;
import com.ruoyi.system.api.model.LoginUser;
@@ -20,7 +25,9 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
+import java.time.LocalDateTime;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@@ -48,20 +55,42 @@
private GoodsSeckillService goodsSeckillService;
@Resource
private GoodsService goodsService;
+ @Resource
+ private OrderClient orderClient;
@Override
public List<SeckillActivityVO> listSeckillActivity(Goods goods) {
LoginUser loginUserApplet = tokenService.getLoginUserApplet();
AppUser appUser = appUserClient.getAppUserById(loginUserApplet.getUserid());
goods.setVipId(appUser.getVipId());
- return seckillActivityInfoMapper.listSeckillActivity(goods);
+ List<SeckillActivityVO> seckillActivityVOS = seckillActivityInfoMapper.listSeckillActivity(goods);
+ for (SeckillActivityVO seckillActivityVO : seckillActivityVOS) {
+ Integer data = orderClient.getGoodsSaleNum(seckillActivityVO.getGoodsId(), 2).getData();
+ seckillActivityVO.setSaleNum(data);
+ LocalDateTime startTime = seckillActivityVO.getStartTime();
+ LocalDateTime now = LocalDateTime.now();
+ LocalDateTime endTime = seckillActivityVO.getEndTime();
+ if (endTime.isBefore(now)){
+ seckillActivityVO.setStatus(3); //已结束
+ }else if (startTime.isBefore(now)){
+ seckillActivityVO.setStatus(2); // 已开始
+ }else {
+ seckillActivityVO.setStatus(1); // 未开始
+ }
+ }
+ return seckillActivityVOS;
}
@Override
- public SeckillActivityDetailVO detail(Integer seckillActivityId) {
- Long userid = tokenService.getLoginUserApplet().getUserid();
- AppUser appUser = appUserClient.getAppUserById(userid);
- SeckillActivityDetailVO seckillActivityDetailVO = seckillActivityInfoMapper.selectDetail(seckillActivityId, appUser.getVipId());
+ public SeckillActivityDetailVO detail(Integer seckillActivityId, String latitude, String longitude) {
+ Integer vipId = 0;
+ String token = SecurityUtils.getToken(ServletUtils.getRequest());
+ if(StringUtils.isNotEmpty(token)){
+ Long userid = tokenService.getLoginUserApplet().getUserid();
+ AppUser appUser = appUserClient.getAppUserById(userid);
+ vipId = appUser.getVipId();
+ }
+ SeckillActivityDetailVO seckillActivityDetailVO = seckillActivityInfoMapper.selectDetail(seckillActivityId, vipId);
Integer goodsId = seckillActivityDetailVO.getGoodsId();
Goods goods = goodsService.getById(goodsId);
@@ -76,7 +105,20 @@
}else{
shops = shopMapper.selectList(new LambdaUpdateWrapper<Shop>().eq(Shop::getDelFlag, 0));
}
+
+ for (Shop shop : shops) {
+ Double wgs84 = GeodesyUtil.getDistance(longitude + "," + latitude, shop.getLongitude() + "," + shop.getLatitude()).get("WGS84");
+ shop.setDistance(wgs84);
+ }
+ shops.sort(new Comparator<Shop>() {
+ @Override
+ public int compare(Shop o1, Shop o2) {
+ return o1.getDistance().compareTo(o2.getDistance());
+ }
+ });
seckillActivityDetailVO.setShopList(shops);
+ Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 2).getData();
+ seckillActivityDetailVO.setSaleNum(integer);
return seckillActivityDetailVO;
}
@@ -85,7 +127,11 @@
public void saveSeckillActivityInfo(SeckillActivityInfo seckillActivityInfo) {
this.baseMapper.insert(seckillActivityInfo);
List<GoodsSeckill> goodsSeckills = seckillActivityInfo.getGoodsSeckills();
- goodsSeckills.forEach(goodsSeckill -> goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo.getId()));
+ for (GoodsSeckill goodsSeckill : goodsSeckills) {
+ goodsSeckill.setCashPayment(null == goodsSeckill.getSellingPrice() ? 0 : 1);
+ goodsSeckill.setPointPayment(null == goodsSeckill.getIntegral() ? 0 : 1);
+ goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo.getId());
+ }
goodsSeckillService.saveBatch(goodsSeckills);
}
@@ -95,7 +141,11 @@
this.baseMapper.updateById(seckillActivityInfo);
goodsSeckillService.remove(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId()));
List<GoodsSeckill> goodsSeckills = seckillActivityInfo.getGoodsSeckills();
- goodsSeckills.forEach(goodsSeckill -> goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo.getId()));
+ for (GoodsSeckill goodsSeckill : goodsSeckills) {
+ goodsSeckill.setCashPayment(null == goodsSeckill.getSellingPrice() ? 0 : 1);
+ goodsSeckill.setPointPayment(null == goodsSeckill.getIntegral() ? 0 : 1);
+ goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo.getId());
+ }
goodsSeckillService.saveBatch(goodsSeckills);
}
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java
index a7e233b..c483fe4 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java
@@ -28,10 +28,7 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -76,20 +73,25 @@
List<NearbyShopVO> nearbyShopVOS = shopMapper.selectNearbyShopList(longitude, longitude);
if(null != appUser && null != appUser.getShopId()){
AppUser finalAppUser = appUser;
- NearbyShopVO nearbyShopVO = nearbyShopVOS.stream().filter(s -> s.getId().equals(finalAppUser.getShopId().longValue())).findFirst().get();
- if(null != nearbyShopVO){
- nearbyShopVOS.remove(nearbyShopVO);
+ Optional<NearbyShopVO> first = nearbyShopVOS.stream().filter(s -> s.getId().equals(finalAppUser.getShopId().longValue())).findFirst();
+ if(first.isPresent()){
+ NearbyShopVO nearbyShopVO = first.get();
+ if(null != nearbyShopVO){
+ nearbyShopVOS.remove(nearbyShopVO);
+ }
}
Shop shop = shopMapper.selectById(appUser.getShopId());
- NearbyShopVO vo = new NearbyShopVO();
- vo.setId(appUser.getShopId().longValue());
- vo.setName(shop.getName());
- vo.setAddress(shop.getAddress());
- vo.setHomePicture(shop.getHomePicture());
- Double wgs84 = GeodesyUtil.getDistance(longitude.toString() + "," + latitude.toString(), shop.getLongitude() + "," + shop.getLatitude()).get("WGS84");
- vo.setDistance(wgs84.toString());
- nearbyShopVOS.add(0, vo);
+ if(null != shop){
+ NearbyShopVO vo = new NearbyShopVO();
+ vo.setId(appUser.getShopId().longValue());
+ vo.setName(shop.getName());
+ vo.setAddress(shop.getAddress());
+ vo.setHomePicture(shop.getHomePicture());
+ Double wgs84 = GeodesyUtil.getDistance(longitude.toString() + "," + latitude.toString(), shop.getLongitude() + "," + shop.getLatitude()).get("WGS84");
+ vo.setDistance(wgs84.toString());
+ nearbyShopVOS.add(0, vo);
+ }
}
if (nearbyShopVOS == null || nearbyShopVOS.isEmpty()) {
return Collections.emptyList();
@@ -117,12 +119,14 @@
@Override
public ShopDetailVO getShopDetail(Integer shopId, BigDecimal longitude, BigDecimal latitude) {
+ Long userid = tokenService.getLoginUserApplet().getUserid();
// 查询店铺详情
ShopDetailVO shopDetailVO = shopMapper.selectShopDetail(shopId);
if (shopDetailVO == null) {
throw new ServiceException("查询店铺不存在");
}
-
+ ShopScore one = shopScoreService.getOne(new LambdaQueryWrapper<ShopScore>().eq(ShopScore::getAppUserId, userid).eq(ShopScore::getShopId, shopId).last(" order by create_time desc limit 0, 1"));
+ shopDetailVO.setScore(null == one ? BigDecimal.ZERO : one.getScore());
// 计算距离
if (shopDetailVO.getLongitude() != null && shopDetailVO.getLatitude() != null){
String shopLocation = String.format("%s,%s", shopDetailVO.getLongitude(), shopDetailVO.getLatitude());
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java
index d4e7951..68f47f6 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java
@@ -1,5 +1,6 @@
package com.ruoyi.other.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -20,7 +21,9 @@
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneId;
+import java.time.ZoneOffset;
import java.util.List;
+import java.util.Set;
/**
* <p>
@@ -51,7 +54,7 @@
PageInfo<TechnicianSubscribeVO> pageInfo = new PageInfo(pageCurr, pageSize);
List<TechnicianSubscribeVO> list = technicianSubscribeMapper.getTechnicianSubscribeByUserAndShop(pageInfo, shopId, status);
for (TechnicianSubscribeVO technicianSubscribeVO : list) {
- Long id = technicianSubscribeVO.getId();
+ String id = technicianSubscribeVO.getId();
TechnicianSubscribe technicianSubscribe = this.getById(id);
AppUser appUser = appUserClient.getAppUserById(technicianSubscribe.getAppUserId());
technicianSubscribeVO.setUserName(appUser.getName());
@@ -65,6 +68,11 @@
Integer serviceMode, Integer pageCurr, Integer pageSize) {
PageInfo<TechnicianSubscribeVO> pageInfo = new PageInfo(pageCurr, pageSize);
List<TechnicianSubscribeVO> technicianSubscribeByUserAndShop1 = technicianSubscribeMapper.getTechnicianSubscribeByUserAndShop1(pageInfo, shopId, status, phone, name, serviceMode);
+ for (TechnicianSubscribeVO technicianSubscribeVO : technicianSubscribeByUserAndShop1) {
+ AppUser appUser = appUserClient.getAppUserById(technicianSubscribeVO.getAppUserId());
+ technicianSubscribeVO.setUserName(appUser.getName());
+ technicianSubscribeVO.setPhone(appUser.getPhone());
+ }
return pageInfo.setRecords(technicianSubscribeByUserAndShop1);
}
@Override
@@ -83,8 +91,22 @@
if (subscribe.getOrderId() != null){
orderGoodsClient.subscribe(subscribe.getOrderId(), subscribe.getTechnicianId());
}
- LocalDateTime subscribeTime = subscribe.getSubscribeTime();
- long deadlineTimestamp = subscribeTime.atZone(ZoneId.systemDefault()).toEpochSecond();
- redisTemplate.opsForZSet().add("delay_queue:subscribe", subscribe.getId().toString(), deadlineTimestamp);
+ //添加到redis有序队列中用于定时处理状态
+ redisTemplate.opsForZSet().add("technician_subscribe", subscribe.getId().toString(), subscribe.getSubscribeTime().toEpochSecond(ZoneOffset.UTC));
+ }
+
+
+ /**
+ * 定时修改到期状态
+ */
+ @Override
+ public void taskEditStstus() {
+ Set<String> technician_subscribe = redisTemplate.opsForZSet().range("technician_subscribe", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC));
+ if(technician_subscribe.size() > 0){
+ List<TechnicianSubscribe> list = this.listByIds(technician_subscribe);
+ list.forEach(s->s.setStatus(3));
+ this.updateBatchById(list);
+ redisTemplate.opsForZSet().remove("technician_subscribe", technician_subscribe.toArray());
+ }
}
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/VipSettingServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/VipSettingServiceImpl.java
index 99b5c83..b803d76 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/VipSettingServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/VipSettingServiceImpl.java
@@ -35,26 +35,4 @@
return this.getById(appUser.getVipId());
}
- @Override
- public void downUsers() {
-// //查出可能需要降级的人员
-// R<List<AppUser>> topUsers = appUserClient.getTopUsers();
-// //循环判断是否要展示
-// if (topUsers.getData()!=null && topUsers.getData().size()>0){
-// for (AppUser appUser : topUsers.getData()){
-// if (appUser.getVipId()==5){
-// VipSetting vipSetting = this.baseMapper.selectById(5);
-// if (vipSetting.getKeepBuyPoint()!=null){
-// //如果消费不为空,查找对应天数的消费积分
-//
-// //如果消费积分小于保级积分,设置用户降级标志并将降级信息
-// }
-//
-// }
-// }
-// }
-
- //然后设置降级提示
-
- }
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/TaskUtil.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/TaskUtil.java
index 6a67a19..1a165f3 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/TaskUtil.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/TaskUtil.java
@@ -1,16 +1,12 @@
package com.ruoyi.other.task;
-import com.ruoyi.other.service.VipSettingService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
+import com.ruoyi.other.service.TechnicianSubscribeService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
-import java.util.Date;
-import java.util.List;
/**
@@ -19,9 +15,17 @@
@Component
public class TaskUtil {
- @Resource
- private VipSettingService vipSettingService;
+ @Resource
+ private TechnicianSubscribeService technicianSubscribeService;
+
+ /**
+ * 每分钟定时
+ */
+ @Scheduled(fixedRate = 60000)
+ public void taskMonth() {
+ technicianSubscribeService.taskEditStstus();
+ }
/**
* 每天的凌晨执行的任务
@@ -29,9 +33,6 @@
@Scheduled(cron = "0 0 0 * * *")
public void taskDay(){
try {
-
-
- vipSettingService.downUsers();
}catch (Exception e){
e.printStackTrace();
}
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/payment/PaymentUtil.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/payment/PaymentUtil.java
index b7d8486..c78db82 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/payment/PaymentUtil.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/util/payment/PaymentUtil.java
@@ -6,6 +6,7 @@
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
+import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.other.util.payment.model.*;
import lombok.extern.slf4j.Slf4j;
@@ -77,7 +78,7 @@
//APPID
body.put("q7_AppId", appId);
//报备商户号
- body.put("qa_TradeMerchantNo", tradeMerchantNo);
+ body.put("qa_TradeMerchantNo", StringUtils.isNotEmpty(tradeMerchantNo) ? tradeMerchantNo : "777168500885852");
String sign = null;
try {
sign = sign(body);
@@ -252,13 +253,13 @@
- public static String sign(JSONObject body) throws Exception{
+ public static String sign(JSONObject body) {
Set<Map.Entry<String, Object>> entries = body.entrySet();
List<Map.Entry<String, Object>> infoIds = new ArrayList<Map.Entry<String, Object>>(entries);
// 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序)
Collections.sort(infoIds, new Comparator<Map.Entry<String, Object>>() {
public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) {
- return (o1.getKey()).toString().compareTo(o2.getKey());
+ return (o1.getKey()).compareTo(o2.getKey());
}
});
// 构造签名键值对的格式
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/GoodsVO.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/GoodsVO.java
index 6569362..78e55a9 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/GoodsVO.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/GoodsVO.java
@@ -1,5 +1,6 @@
package com.ruoyi.other.vo;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.other.api.domain.Shop;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -36,6 +37,10 @@
@ApiModelProperty(value = "详情图,多个逗号分隔")
private String detailPicture;
+
+ @ApiModelProperty(value = "现金支付(0=否,1=是)")
+ private Integer cashPayment;
+
@ApiModelProperty(value = "积分支付(0=否,1=是)")
private Integer pointPayment;
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/SeckillActivityVO.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/SeckillActivityVO.java
index 5ff9b25..072d806 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/SeckillActivityVO.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/SeckillActivityVO.java
@@ -50,6 +50,9 @@
@ApiModelProperty(value = "基础售价")
private BigDecimal sellingPrice;
+ @ApiModelProperty(value = "基础积分")
+ private Integer integral;
+
@ApiModelProperty(value = "开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java
index 8260e32..8fa55b7 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java
@@ -11,7 +11,7 @@
public class TechnicianSubscribeVO {
@ApiModelProperty(value = "预约id")
- private Long id;
+ private String id;
/**
* 门店名称
@@ -67,5 +67,7 @@
@ApiModelProperty(value = "联系电话")
private String phone;
+ private Long appUserId;
+
}
diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml
index 5ca5a61..26274d2 100644
--- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml
+++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml
@@ -4,38 +4,26 @@
<select id="selectListByShopId" resultType="com.ruoyi.other.api.domain.Goods">
SELECT
- tg.id,
- tg.`name`,
- tg.type,
- tg.introduction,
- tg.selling_price,
- tg.original_price,
- tg.sale_num,
- tg.home_page_picture
- FROM
- t_shop ts
- LEFT JOIN t_goods_shop tgs ON ts.id = tgs.shop_id
- LEFT JOIN t_goods tg ON tg.id = tgs.goods_id
- where ts.id = #{shopId} and ts.del_flag = 0
+ tg.id,
+ tg.`name`,
+ tg.type,
+ tg.introduction,
+ tg.selling_price as sellingPrice,
+ tg.original_price as originalPrice,
+ tg.integral as integral,
+ tg.sale_num as saleNum,
+ tg.home_page_picture as homePagePicture
+ FROM t_goods tg
+ where tg.del_flag = 0 and tg.status = 2 and (tg.appoint_store = 2 or (tg.appoint_store = 1 and tg.id in (select goods_id from t_goods_shop where shop_id = #{shopId})))
+ and tg.type = 1
<if test="vip != null">
- and FIND_IN_SET(#{vip}, tg.commodity_authority) > 0
+ and (tg.commodity_authority like '%-1%' or tg.commodity_authority like CONCAT('%', #{vip}, '%'))
</if>
ORDER BY tg.sale_num DESC
</select>
<select id="selectManageGoodsList" resultType="com.ruoyi.other.api.domain.Goods">
SELECT
- tg.id,
- tg.`name`,
- tg.type,
- tg.goods_category_id,
- tgc.`name`,
- tg.operating_cost,
- tg.shop_cost,
- tg.`status`,
- tg.purchase_limit,
- tg.sale_num,
- tg.cash_payment,
- tg.point_payment
+ tg.*
FROM
t_goods tg
LEFT JOIN t_goods_category tgc ON tg.goods_category_id = tgc.id
@@ -56,18 +44,32 @@
<if test="goods.status != null">
and tg.`status` = #{goods.status}
</if>
+
+ <if test="goods.payMethod != null and goods.payMethod == 1 ">
+ and tg.`cashPayment` = 1
+ </if>
+ <if test="goods.payMethod != null and goods.payMethod == 2 ">
+ and tg.`point_payment` = 1
+ </if>
+ <if test="goods.payMethod != null and goods.payMethod == 3 ">
+ and (tg.`point_payment` = 1 or tg.`cashPayment` = 1 )
+ </if>
+
</where>
order by tg.sort desc
</select>
<select id="goodsList" resultType="com.ruoyi.other.vo.GoodsVO">
- select *, id as goodsId, name as goodsName from t_goods where status = 2 and del_flag = 0
+ select *, id as goodsId, name as goodsName from t_goods where status = 2 and del_flag = 0 and `type` = 2
<if test="null != goodsCategoryId">
and goods_category_id = #{goodsCategoryId}
</if>
<if test="null != name and '' != name">
and name like CONCAT('%', #{name}, '%')
</if>
+ <if test="null != vip">
+ and (FIND_IN_SET(#{vip}, commodity_authority) or commodity_authority like '%-1%')
+ </if>
</select>
</mapper>
\ No newline at end of file
diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml
index cbbd719..53e8d84 100644
--- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml
+++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml
@@ -6,20 +6,22 @@
SELECT
tsai.id,
tg.id as goodsId,
- tg.`name`,
+ tg.`name` as goodsName,
tg.introduction,
- tg.home_page_picture,
- tg.original_price,
- tgs.selling_price,
- tg.sale_num,
- tsai.start_time
+ tg.home_page_picture as homePagePicture,
+ tg.original_price as originalPrice,
+ tgs.selling_price as sellingPrice,
+ tgs.integral as integral,
+ tg.sale_num as saleNum,
+ tsai.start_time as startTime,
+ tsai.end_time as endTime
FROM
t_seckill_activity_info tsai
LEFT JOIN t_goods tg ON tsai.good_id = tg.id
LEFT JOIN t_goods_seckill tgs ON tgs.seckill_activity_info_id = tsai.id and tgs.vip = #{vipId}
WHERE tsai.is_shelves = 1 AND tsai.del_flag = 0
<if test="name != null and name != ''">
- AND tg.`name` LIKE concat('%',#{goodsName},'%')
+ AND tg.`name` LIKE concat('%',#{name},'%')
</if>
<if test="goodsCategoryId != null">
AND tg.goods_category_id = #{goodsCategoryId}
@@ -37,13 +39,15 @@
tsai.good_id as goodsId,
tg.`name`,
tg.introduction,
- tg.home_page_picture,
- tg.original_price,
- tgs.selling_price,
- tg.sale_num,
- tsai.start_time,
- tg.detail_picture,
- tsai.end_time,
+ tg.home_page_picture as homePagePicture,
+ tg.original_price as originalPrice,
+ tgs.selling_price as sellingPrice,
+ tgs.integral,
+ tg.sale_num as saleNum,
+ tsai.start_time as startTime,
+ tg.detail_picture as detailPicture,
+ tsai.end_time as endTime,
+ tsai.max_num as maxNum,
tg.detail
FROM
t_seckill_activity_info tsai
diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml
index 80526d4..6dc9224 100644
--- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml
+++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml
@@ -32,26 +32,10 @@
ts.start_time,
ts.end_time,
ts.longitude,
- ts.latitude,
- AVG( tss.score ) score
+ ts.latitude
FROM
t_shop ts
- LEFT JOIN t_shop_score tss ON ts.id = tss.shop_id
- WHERE
- ts.del_flag = 0
- AND ts.`status` = 1
- AND ts.id = #{id}
- GROUP BY
- ts.id,
- ts.details_picture,
- ts.certification,
- ts.`name`,
- ts.address,
- ts.business_date,
- ts.start_time,
- ts.end_time,
- ts.longitude,
- ts.latitude
+ WHERE ts.del_flag = 0 AND ts.`status` = 1 AND ts.id = #{shopId}
</select>
<select id="selectShopList" resultType="com.ruoyi.other.api.domain.Shop">
SELECT
diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml
index 937b56a..f95ef42 100644
--- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml
+++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopPointMapper.xml
@@ -9,7 +9,8 @@
ts.phone,
tsp.type,
tsp.create_time,
- tsp.variable_point
+ tsp.variable_point,
+ tsp.order_num
FROM
t_shop_point tsp
LEFT JOIN t_shop ts ON tsp.shop_id = ts.id
@@ -29,8 +30,11 @@
<if test="shopPoint.startTime !=null and shopPoint.endTime !=null">
AND tsp.create_time BETWEEN #{shopPoint.startTime} AND #{shopPoint.endTime}
</if>
-
+ <if test="shopPoint.shopId !=null">
+ AND tsp.shop_id = #{shopPoint.shopId}
+ </if>
</where>
+ order by tsp.create_time desc
</sql>
<select id="selectShopPointList" resultType="com.ruoyi.other.api.domain.ShopPoint">
diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml
index 91afdb6..934c86b 100644
--- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml
+++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml
@@ -28,7 +28,7 @@
</select>
<select id="getTechnicianSubscribeByUserAndShop1" resultType="com.ruoyi.other.vo.TechnicianSubscribeVO">
SELECT
- CAST(tts.id AS CHAR) id,
+ tts.id,
tts.user_address,
ts.`name` shopName,
ts.address shopAddress,
@@ -37,7 +37,8 @@
ts.latitude,
tts.subscribe_time,
tts.service_mode,
- tts.status
+ tts.status,
+ tts.app_user_id as appUserId
FROM
t_technician_subscribe tts
LEFT JOIN t_technician tt ON tts.technician_id = tt.id AND tt.del_flag = 0
--
Gitblit v1.7.1