From ddf3f19408fb311734218aaaa5edb49c5134b1eb Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期三, 08 一月 2025 21:14:36 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java             |   14 
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/BalancePaymentMapper.java                    |   11 
 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                                  |    2 
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java                         |   23 
 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        |   30 +
 ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysDeptMapper.xml                                  |    3 
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java                          |   13 
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java                      |   25 
 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                                 |    2 
 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                            |   14 
 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/service/impl/ShopServiceImpl.java                       |   36 +
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java                                  |    2 
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java               |  152 ++++--
 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                   |   67 ++
 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/OrderClientFallbackFactory.java                 |    8 
 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml                                       |   16 
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java                 |  165 ++++----
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java                     |   14 
 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/controller/OrderController.java                         |   34 +
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/BalancePaymentService.java                  |   11 
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java                         |    9 
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java                 |    1 
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java        |   16 
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsService.java                               |    2 
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java           |    4 
 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/OrderVO.java                                         |    3 
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysUserClient.java                    |    2 
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java                |   87 +++
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java        |    2 
 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OrderActivityInfoClient.java            |    4 
 ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml                                  |    1 
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java           |   13 
 /dev/null                                                                                                       |   29 -
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalancePaymentServiceImpl.java         |   15 
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java                               |    2 
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/SeckillActivityInfoService.java                 |    2 
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java                    |  121 +++++
 ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml                                 |   24 +
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java                |   52 ++
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java                         |    4 
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java                      |   27 +
 50 files changed, 837 insertions(+), 328 deletions(-)

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-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
index 684d7ac..c28dc25 100644
--- 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
@@ -4,6 +4,9 @@
 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
@@ -23,6 +26,11 @@
             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/feignClient/OrderClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/OrderClient.java
index b7a5490..a70a745 100644
--- 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
@@ -1,11 +1,15 @@
 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
@@ -18,6 +22,7 @@
     /**
      * 获取商品销售数量
      * @param goodsId
+     * @param type 购买类型(1=普通商品,2=秒杀商品)
      * @return
      */
     @PostMapping("/order/getGoodsSaleNum")
@@ -32,4 +37,13 @@
      */
     @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/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/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-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/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/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-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-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/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 4156427..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
@@ -148,6 +148,7 @@
 				)
 			</when>
 			<otherwise>
+				and role_type = 1
 				<if test="null != req.deptId">
 					and dept_id = #{req.deptId}
 				</if>
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 ccb48b3..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;
@@ -85,6 +88,10 @@
     private ShopClient shopClient;
     @Resource
     private RemoteOrderGoodsClient remoteOrderGoodsClient;
+    @Resource
+    private SysUserClient sysUserClient;
+    @Resource
+    private OrderClient orderClient;
 
 
     @ResponseBody
@@ -394,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());
@@ -623,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);
     }
 
@@ -633,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);
     }
 
@@ -643,19 +683,22 @@
      */
     @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);
             totalCommission = totalCommission.add(distributionAmount);
@@ -669,6 +712,9 @@
             }
         }
         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());
@@ -702,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/UserCouponController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java
index a08b7cf..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
@@ -119,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) {
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/impl/AppUserServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java
index c81fde8..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
@@ -11,6 +11,8 @@
 import com.ruoyi.account.mapper.AppUserMapper;
 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,15 +27,18 @@
 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;
@@ -50,6 +55,7 @@
  * @author luodangjia
  * @since 2024-11-21
  */
+@Slf4j
 @Service
 public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> implements AppUserService {
 	
@@ -100,6 +106,11 @@
 
 	@Resource
 	private UserCouponService userCouponService;
+
+	@Resource
+	private RedisTemplate redisTemplate;
+	@Resource
+	private BalancePaymentService balancePaymentService;
 
 
 	/**
@@ -350,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){
 				//构建积分流水记录
@@ -728,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 (UNIX_TIMESTAMP(create_time) + (" + vipCancelDay + " * 86400)) <= UNIX_TIMESTAMP()"));
-		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);
+
+		//解绑推广人
+		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::getDelFlag, 0).eq(AppUser::getChangePromoter, 0)
-				.eq(AppUser::getStatus, 1).last(" and (UNIX_TIMESTAMP(ifnull(last_shop_time, create_time)) + (" + vipChangeDay + " * 86400)) <= UNIX_TIMESTAMP()"));
-		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);
+			}
 		}
 	}
 	
@@ -801,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)){
@@ -811,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) {
@@ -924,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/util/TaskUtil.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/TaskUtil.java
index 8d2d276..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
@@ -28,6 +28,8 @@
     public void sendVipCoupon(){
         //解绑推广人
         appUserService.unbindThePromoter();
+        //关闭充值订单
+        appUserService.closeOrder();
     }
 
     /**
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 ee6149e..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
@@ -75,6 +75,12 @@
                     #{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>
         order by ta.is_danger desc
 
@@ -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-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 dfd365b..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
@@ -20,6 +20,8 @@
 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;
@@ -60,6 +62,8 @@
     private BaseSettingClient baseSettingClient;
     @Resource
     private OrderMapper orderMapper;
+    @Resource
+    private SysUserClient sysUserClient;
 
 
     /**
@@ -116,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();
     }
 
@@ -275,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"))));
 
 
@@ -308,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);
         }
@@ -390,5 +400,17 @@
         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/mapper/OrderMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java
index 67be37c..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,7 +35,7 @@
     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);
 
 
     /**
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 9233416..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
@@ -26,7 +26,7 @@
 
     boolean check(Order order, Integer shopId, Long userId);
 
-    void writeOff(String code,Integer shopId);
+    void writeOff(String id,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 8cb3aca..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());
@@ -464,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 35d4d3e..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
@@ -231,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("订单不存在");
@@ -303,8 +302,10 @@
         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);
         }
@@ -330,7 +331,7 @@
         if(!Arrays.asList(1, 2, 3).contains(order.getOrderStatus())){
             return R.fail("订单取消失败");
         }
-        if(LocalDateTime.now().isAfter(order.getAfterSaleTime())){
+        if(null != order.getAfterSaleTime() && LocalDateTime.now().isAfter(order.getAfterSaleTime())){
             return R.fail("订单取消失败");
         }
         order.setOrderStatus(5);
@@ -457,8 +458,10 @@
                     //余额退款
                     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();
@@ -733,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){
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 e7cfb50..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
@@ -155,6 +155,7 @@
 			return R.fail("不能重复操作");
 		}
 		refundPass.setPassStatus(status);
+		refundPass.setAuthTime(LocalDateTime.now());
 		//退货退款
 		if(refundPass.getRefundMethod() == 1 && 2 == status){
 			refundPass.setStatus(4);
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 d8b27db..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
@@ -240,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{
 			//构建价格数据
@@ -462,13 +478,22 @@
 		}
 
 		//查询当前是否有订单活动
-		OrderActivityInfo orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData();
+		List<OrderActivityInfo> orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData();
 		//满XX才打折,只有现金才能优惠
-		if(null != orderActivityInfo && confirmOrder.getPaymentType() == 1 && orderActivityInfo.getConditionAmount().compareTo(orderMoney) <= 0){
-			confirmOrderVo.setActivityName(orderActivityInfo.getActivityName());
-			BigDecimal multiply = orderActivityInfo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney);
-			BigDecimal bigDecimal = paymentMoney.subtract(multiply).setScale(2, RoundingMode.HALF_EVEN);
-			activityAmount = activityAmount.add(bigDecimal);
+		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();
@@ -819,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;
+				}
+			}
 		}
 
 		//可获得的消费积分
@@ -899,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();
@@ -1091,7 +1123,7 @@
 			if(expressFee.compareTo(BigDecimal.ZERO) > 0){
 				if(shoppingCartPayment.getFreightPaymentType() == 1){
 					//调起微信支付
-					UniPayResult uniPayResult = PaymentUtil.uniPay(order.getOrderNumber() + appUser.getId(), expressFee.doubleValue(), order.getOrderType() == 1 ? "购买服务商品快递费" : "购买单品商品快递费",
+					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());
@@ -1101,7 +1133,7 @@
 					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);
+					redisTemplate.opsForZSet().add("MaterialFlowPayment", "K" + order.getOrderNumber(), second);
 					return R.ok(jsonObject.toJSONString());
 				}
 			}
@@ -1318,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();
@@ -1377,39 +1409,43 @@
 		//订单支付数据
 		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){
-				redisTemplate.opsForZSet().remove("OrderPayment", code);
-				continue;
+		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());
 			}
-			//开始执行关闭订单操作
-			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));
-			}
-			redisTemplate.opsForZSet().remove("OrderPayment", code);
 		}
 		
 		//快递支付
 		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){
-				redisTemplate.opsForZSet().remove("MaterialFlowPayment", code);
-				continue;
+		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());
 			}
-			//开始执行关闭订单操作
-			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));
-			}
-			redisTemplate.opsForZSet().remove("MaterialFlowPayment", code);
 		}
 	}
 }
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 0922eb9..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,6 +99,9 @@
         <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>
 
 
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 f91120f..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,10 +46,9 @@
 	 */
 	@ResponseBody
 	@PostMapping("/getNowOrderActivityInfo")
-	public R<OrderActivityInfo> getNowOrderActivityInfo(@RequestParam("vip") Integer vip){
-		OrderActivityInfo one = orderActivityInfoService.getOne(new LambdaQueryWrapper<OrderActivityInfo>().eq(OrderActivityInfo::getDelFlag, 0)
-				.eq(OrderActivityInfo::getIsShelf, 1).eq(OrderActivityInfo::getStatus, 1)
-				.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);
 	}
 
@@ -97,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 aedad5c..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));
     }
     
     
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 ab82e73..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);
         }
     }
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 4a5dc06..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
@@ -182,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();
@@ -192,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();
     }
@@ -402,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);
     }
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/TechnicianSubscribeController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java
index c9fbf70..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);
     }
 
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/impl/GoodsServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
index 05f7de5..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
@@ -28,6 +28,7 @@
 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;
@@ -113,12 +114,14 @@
                 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不能为空");
         }
@@ -142,7 +145,7 @@
         BeanUtils.copyBeanProp(goodsVO, goods);
         goodsVO.setGoodsId(goods.getId());
         goodsVO.setGoodsName(goods.getName());
-        Price price = getPrice(vipId, goods.getId(), 1, null, provinceCode, cityCode, districtCode);
+        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);
@@ -170,6 +173,18 @@
                     .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;
@@ -200,6 +215,8 @@
                 good.setSellingPrice(price.getCash());
                 good.setIntegral(price.getPoint());
             }
+            Integer data = orderClient.getGoodsSaleNum(good.getId(), 1).getData();
+            good.setSaleNum(data);
         }
         return goods;
     }
@@ -270,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);
@@ -279,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);
             }
         }
     }
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 4a96d79..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
@@ -17,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;
@@ -24,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;
 
@@ -61,11 +64,25 @@
         AppUser appUser = appUserClient.getAppUserById(loginUserApplet.getUserid());
         goods.setVipId(appUser.getVipId());
         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) {
+    public SeckillActivityDetailVO detail(Integer seckillActivityId, String latitude, String longitude) {
         Integer vipId = 0;
         String token = SecurityUtils.getToken(ServletUtils.getRequest());
         if(StringUtils.isNotEmpty(token)){
@@ -88,6 +105,17 @@
         }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);
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 70aa04e..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
@@ -21,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>
@@ -89,9 +91,8 @@
         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));
     }
 
 
@@ -100,11 +101,12 @@
      */
     @Override
     public void taskEditStstus() {
-        List<TechnicianSubscribe> list = this.list(new LambdaQueryWrapper<TechnicianSubscribe>().eq(TechnicianSubscribe::getStatus, 0).eq(TechnicianSubscribe::getDelFlag, 0)
-                .lt(TechnicianSubscribe::getSubscribeTime, LocalDateTime.now()));
-        list.forEach(s->s.setStatus(3));
-        if(list.size() > 0){
+        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/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

--
Gitblit v1.7.1