huliguo
2025-04-17 19df67e19f23cd2a04d1c7f355e1e656f4140af4
后台:首页统计、系统管理、广告管理、用户管理、商品分类管理
53个文件已修改
3个文件已添加
1062 ■■■■■ 已修改文件
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/OrderClientFallbackFactory.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/OrderClient.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/Order.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/OrderDetailVO.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopWithdraw.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/ShopAnalysisDTO.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-auth/src/main/java/com/ruoyi/auth/form/LoginBody.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleAddDto.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleUpdateDto.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/dto/UpdatePassword.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysDeptMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java 122 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/dto/UserCancelQuery.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserPointVO.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserStatistics.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserStatisticsDetail.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserCancellationLogMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/ConfirmOrderDTO.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/vo/ShopAnalysisVO.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderStatisticsDetail.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/AgreementController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsShopController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PhoneController.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/AddGoodsDTO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/ShopService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/GoodsVO.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/NearbyShopVO.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/OrderClientFallbackFactory.java
@@ -7,6 +7,7 @@
import org.springframework.cloud.openfeign.FallbackFactory;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@@ -59,6 +60,11 @@
            public R<Long> getOrderCountByAppUserId(Long appUserId) {
                return R.fail("获取用户订单数量失败:" + cause.getMessage());
            }
            @Override
            public R<Map<String, Object>> getConsumeScoreAndPayAmount(Long userId) {
                return R.fail("获取总消费积分和总支付金额失败:" + cause.getMessage());
            }
        };
    }
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/OrderClient.java
@@ -12,6 +12,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@@ -87,4 +88,7 @@
     */
    @PostMapping("/order/getOrderCountByAppUserId")
    R<Long> getOrderCountByAppUserId(@RequestParam("id") Long appUserId);
    @GetMapping("/order/getOrderCountByAppUserId/")
    R<Map<String ,Object>> getConsumeScoreAndPayAmount(@RequestParam("userId") Long userId);
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/Order.java
@@ -37,11 +37,11 @@
    @ApiModelProperty(value = "3待使用4已完成5已取消6已退款7售后中8已评价")
    @ApiModelProperty(value = "3待使用4已完成5已取消8已评价")
    @TableField("order_status")
    private Integer orderStatus;
    
    @ApiModelProperty(value = "3待使用4已完成5已取消6已退款7售后中8已评价")
    @ApiModelProperty(value = "3待使用4已完成5已取消8已评价")
    @TableField("old_order_status")
    private Integer oldOrderStatus;
@@ -83,7 +83,7 @@
    @ApiModelProperty(value = "积分抵扣金额")
    @TableField("activity_amount")
    @TableField("point_deduction_amount")
    private BigDecimal pointDeductionAmount;
@@ -130,7 +130,7 @@
    @ApiModelProperty(value = "添加时间")
    @TableField("create_time")
    private LocalDateTime createTime;
    @ApiModelProperty(value = "预计提货时间")
    @TableField("expected_delivery_time")
    private String expectedDeliveryTime;
@@ -146,6 +146,6 @@
    @ApiModelProperty("退款时间")
    @TableField("refund_time")
    private LocalDateTime refundTime;
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/OrderDetailVO.java
@@ -1,5 +1,6 @@
package com.ruoyi.order.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -58,4 +59,8 @@
    @ApiModelProperty("核销码BASE64")
    private String writeOffCode;
    @ApiModelProperty(value = "核销时间")
    @TableField("end_time")
    private LocalDateTime endTime;
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopWithdraw.java
@@ -87,4 +87,24 @@
    private String shopName;
    @ApiModelProperty("报备商户号")
    @TableField("tradeMerchantNo")
    private String tradeMerchantNo;
    @ApiModelProperty("收款银行卡号")
    @TableField("receiverAccountNoEnc")
    private String receiverAccountNoEnc;
    @ApiModelProperty("收款银行卡持卡人名称")
    @TableField("receiverNameEnc")
    private String receiverNameEnc;
    @ApiModelProperty("账户类型(对私账户201,对公账户204)")
    @TableField("receiverAccountType")
    private Integer receiverAccountType;
    @ApiModelProperty("收款账户联行号")
    @TableField("receiverBankChannelNo")
    private String receiverBankChannelNo;
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/ShopAnalysisDTO.java
New file
@@ -0,0 +1,22 @@
package com.ruoyi.other.api.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Data
public class ShopAnalysisDTO {
    private Integer shopId;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate startTime;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate endTime;
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java
@@ -2,6 +2,7 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.other.api.domain.Shop;
import com.ruoyi.other.api.dto.ShopAnalysisDTO;
import com.ruoyi.other.api.feignClient.ShopClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
@@ -73,6 +74,11 @@
            public R<Shop> getSuperiorServiceProvider(Long appUserId) {
                return R.fail("获取高级服务商失败");
            }
            @Override
            public R<Map<String, Object>> getIncomeAnalysis(ShopAnalysisDTO shopAnalysisDTO) {
                return R.fail("获取店铺收益失败:" + cause.getMessage());
            }
        };
    }
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java
@@ -3,6 +3,7 @@
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.other.api.domain.Shop;
import com.ruoyi.other.api.dto.ShopAnalysisDTO;
import com.ruoyi.other.api.factory.ShopClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
@@ -82,5 +83,6 @@
    @GetMapping("/shop/getSuperiorServiceProvider")
    public R<Shop> getSuperiorServiceProvider(@RequestParam("appUserId") Long appUserId);
    @PostMapping("/shop/getIncomeAnalysis")
    R<Map<String, Object>> getIncomeAnalysis(@RequestBody ShopAnalysisDTO shopAnalysisDTO);
}
ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java
@@ -64,7 +64,7 @@
        userClient.updateSysUser(sysUser);
        return R.ok(map);
    }
    @PostMapping("loginShop")
    /*@PostMapping("loginShop")
    public R<?> loginShop(@RequestBody LoginBody form, HttpServletRequest request) {
        // 用户登录
        LoginUser userInfo = sysLoginService.loginShop(form.getUsername(), form.getPassword(), request);
@@ -85,7 +85,7 @@
        userClient.updateSysUser(sysUser);
        return R.ok(map);
    }
    */
    @DeleteMapping("logout")
    public R<?> logout(HttpServletRequest request) {
        String token = SecurityUtils.getToken(request);
ruoyi-auth/src/main/java/com/ruoyi/auth/form/LoginBody.java
@@ -16,10 +16,7 @@
     * 用户密码
     */
    private String password;
    /**
     * 登录平台类型(1=平台,2=门店)
     */
    private Integer roleType;
    public String getUsername()
    {
@@ -40,12 +37,5 @@
    {
        this.password = password;
    }
    public Integer getRoleType() {
        return roleType;
    }
    public void setRoleType(Integer roleType) {
        this.roleType = roleType;
    }
}
ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
@@ -93,7 +93,7 @@
        }
        if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
            recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "用户已停用,请联系管理员");
            throw new ServiceException("您所属门店已被冻结,请联系平台");
            throw new ServiceException("您的账号已被停用,请联系平台");
        }
        if (user.getRoleType()==2){
            Shop data = shopClient.getShopById(user.getObjectId()).getData();
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java
@@ -117,9 +117,10 @@
    
    
    public static void main(String[] args) {
        String s = encryptPassword("0192023a7bbd73250516f069df18b500");
        String s = encryptPassword("123456");
        System.err.println(s);
//        System.err.println(matchesPassword("c4ca4238a0b923820dcc509a6f75849b", "$2a$10$/7z/wiZ2ejTjD4GQuuyiSe1ptS8uoxrRAUlGCitiLEmpOO78cISeq"));
        System.err.println(matchesPassword("123456", "$2a$10$QTL3AZW2YMtRu/jMEOzYmeeAB7c3aIq/4VyuvqtyEAARVYfhXyFRi"));
        System.err.println(matchesPassword("123456", "$2a$10$Mg1l9OMJ/gFTQZmDql.21OVgGulPTQgze/cZWNe5plRpRDRjq79Ju"));
    }
}
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java
@@ -81,7 +81,7 @@
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SysDept dept) {
        Long deptId = dept.getDeptId();
        deptService.checkDeptDataScope(deptId);
        deptService.checkDeptDataScope(deptId);//检查是否有权限修改
        if (!deptService.checkDeptNameUnique(dept)) {
            return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
        }
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java
@@ -94,9 +94,9 @@
    }
    /**
     * 重置密码
     * 重置密码 后台-登录
     */
    @ApiOperation(value = "个人信息-修改密码")
    @ApiOperation(value = "修改密码",notes = "后台-登录")
    @Log(title = "个人信息", businessType = BusinessType.UPDATE)
    @PostMapping("/updatePwd")
    public AjaxResult updatePwd(@RequestBody UpdatePassword updatePassword)
@@ -108,11 +108,9 @@
        System.err.println(newPassword);
//        String username = SecurityUtils.getUsername();
        SysUser user =null;
        if (updatePassword.getType()==1){
            user = userService.selectUserByUserName(username);
        }else{
            user = userService.selectUserShopByUserName(username);
        }
        user = userService.selectUserByUserName(username);
        if (Objects.isNull(user))
        {
            return error("未查询到该账号");
@@ -126,7 +124,7 @@
        {
            return error("新密码不能与旧密码相同");
        }
        if (updatePassword.getType()==1&&userService.resetUserPwd(username, SecurityUtils.encryptPassword(newPassword)) > 0) {
        if (userService.resetUserPwd(username, SecurityUtils.encryptPassword(newPassword)) > 0) {
            // 更新缓存用户密码
//            LoginUser loginUser = SecurityUtils.getLoginUser();
//            SysUser sysUser = loginUser.getSysUser();
@@ -134,14 +132,7 @@
//            tokenService.setLoginUser(loginUser);
            return success();
        }
        if (updatePassword.getType()==2&&userService.resetUserShopPwd(username, SecurityUtils.encryptPassword(newPassword)) > 0) {
            // 更新缓存用户密码
//            LoginUser loginUser = SecurityUtils.getLoginUser();
//            SysUser sysUser = loginUser.getSysUser();
//            loginUser.getSysUser().setPassword(SecurityUtils.encryptPassword(newPassword));
//            tokenService.setLoginUser(loginUser);
            return success();
        }
        return error("修改密码异常,请联系管理员");
    }
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java
@@ -127,12 +127,8 @@
        role.setRoleName(dto.getRoleName());
        LambdaQueryWrapper<SysRole> wrapper = Wrappers.lambdaQuery(SysRole.class)
                .eq(SysRole::getRoleName, dto.getRoleName()).eq(SysRole::getDelFlag, 0);
        Long userid = tokenService.getLoginUser().getUserid();
        SysUser sysUser = sysUserService.getById(userid);
        if(sysUser.getRoleType() == 2){
            wrapper.eq(SysRole::getShopId, sysUser.getObjectId());
        }
        long count = roleService.count(wrapper);
        if (count > 0) {
            return AjaxResult.error("角色已存在,请重新输入");
@@ -146,10 +142,7 @@
        role.setRemark(dto.getRemark());
        role.setCreateBy(SecurityUtils.getUsername());
        role.setCreateTime(new Date());
        if(sysUser.getRoleType() == 2){
            role.setShopId(sysUser.getObjectId());
        }
        roleService.insertRole(role);
        return AjaxResult.success();
    }
@@ -208,20 +201,8 @@
        ArrayList<SysRoleMenu> sysRoleMenus = new ArrayList<>();
        List<Long> menuIds = dto.getMenuIds();
        // 移除原来的权限菜单
        if (menuIds.contains(1061L)) {
            sysRoleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>()
                    .eq(SysRoleMenu::getRoleId, dto.getRoleId()));
        } else {
            sysRoleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>()
                    .eq(SysRoleMenu::getRoleId, dto.getRoleId())
                    .ne(SysRoleMenu::getMenuId, 1061L)
                    .ne(SysRoleMenu::getMenuId, 1062L)
                    .ne(SysRoleMenu::getMenuId, 1065L)
                    .ne(SysRoleMenu::getMenuId, 1073L)
                    .ne(SysRoleMenu::getMenuId, 1161L)
                    .ne(SysRoleMenu::getMenuId, 1203L)
            );
        }
        sysRoleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, dto.getRoleId()));
        for (Long menuId : menuIds) {
            SysRoleMenu sysRoleMenu = new SysRoleMenu();
            sysRoleMenu.setMenuId(menuId);
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java
@@ -132,51 +132,7 @@
            return error("登录账号重复");
        }
        //门店员工添加数据,需要判断账号是否存在,共用同一个账号
        if(2 == sysUser1.getRoleType()){
            AppUser appUser = appUserClient.getAppUserByPhone1(user.getPhonenumber()).getData();
            if(null == appUser){
                return error("请先注册小程序账号");
            }
            SysUser one2 = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, user.getPhonenumber())
                    .eq(SysUser::getDelFlag, "0").eq(SysUser::getStatus, "0").eq(SysUser::getObjectId, sysUser1.getObjectId())
                    .eq(SysUser::getRoleType, 2));
            if(null != one2){
                return error("登录账号重复");
            }
            SysUser one = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, user.getPhonenumber())
                    .eq(SysUser::getDelFlag, "0").eq(SysUser::getStatus, "0").eq(SysUser::getRoleType, 2));
            if(null == one){
                user.setCreateBy(SecurityUtils.getUsername());
                user.setPassword(SecurityUtils.encryptPassword(MD5Generator.generateMD5("a123456")));
                user.setRoleType(sysUser1.getRoleType());
                user.setObjectId(sysUser1.getObjectId());
                if(null != appUser){
                    user.setAppUserId(appUser.getId());
                }
                userService.insertUser(user);
                one = user;
                SysUserRole sysUserRole = new SysUserRole();
                sysUserRole.setRoleId(user.getRoleId());
                sysUserRole.setUserId(user.getUserId());
                userRoleService.insertSysUserRole(sysUserRole);
            }
            //添加门店员工关系数据
            UserShop one1 = userShopService.getOne(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, one.getUserId()).eq(UserShop::getShopId, sysUser1.getObjectId()));
            if(null == one1){
                UserShop userShop = new UserShop();
                userShop.setUserId(one.getUserId());
                userShop.setShopId(sysUser1.getObjectId());
                userShop.setRoleType(2);
                userShop.setRoleId(user.getRoleId());
                userShop.setDeptId(user.getDeptId());
                userShop.setNickName(user.getNickName());
                userShop.setCreateTime(LocalDateTime.now());
                userShopService.save(userShop);
            }
        }else{
            user.setCreateBy(SecurityUtils.getUsername());
            user.setPassword(SecurityUtils.encryptPassword(MD5Generator.generateMD5("a123456")));
@@ -186,7 +142,7 @@
            sysUserRole.setRoleId(user.getRoleId());
            sysUserRole.setUserId(user.getUserId());
            userRoleService.insertSysUserRole(sysUserRole);
        }
        return AjaxResult.success();
    }
    
@@ -220,17 +176,6 @@
        ajax.put("posts", postService.selectPostAll());
        if (StringUtils.isNotNull(userId)) {
            SysUser sysUser = userService.selectUserById(userId);
            if(sysUser.getRoleType() == 2){
                Long userid = tokenService.getLoginUser().getUserid();
                SysUser sysUser1 = userService.selectUserById(userid);
                UserShop one = userShopService.getOne(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, sysUser.getUserId()).eq(UserShop::getShopId, sysUser1.getObjectId()));
                sysUser.setDeptId(one.getDeptId());
                sysUser.setNickName(one.getNickName());
                SysDept sysDept = deptService.selectDeptById(one.getDeptId());
                sysUser.setDept(sysDept);
                sysUser.setRoleId(one.getRoleId());
            }
            ajax.put("data", sysUser);
            ajax.put("postIds", postService.selectPostListByUserId(userId));
            ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
@@ -288,17 +233,6 @@
        user.setUpdateTime(new Date());
        userService.updateUser(user);
        user = userService.getById(user.getUserId());
        //添加门店员工关系数据
        if(2 == user.getRoleType()){
            UserShop one = userShopService.getOne(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId()).eq(UserShop::getShopId, user.getObjectId()));
            one.setUserId(user.getUserId());
            one.setShopId(user.getObjectId());
            one.setRoleType(one.getRoleType());
            one.setRoleId(user.getRoleId());
            one.setDeptId(user.getDeptId());
            one.setNickName(user.getNickName());
            userShopService.updateById(one);
        }
        return success();
    }
@@ -396,7 +330,7 @@
            return R.fail("用户名或密码错误");
        }
        // 角色集合
        Set<String> roles = permissionService.getRolePermission(sysUser);
        Set<String> roles = permissionService.getRolePermission(sysUser);//admin 或 其他权限
        // 权限集合getRolePermission
        Set<String> permissions = permissionService.getMenuPermission(sysUser);
        LoginUser sysUserVo = new LoginUser();
@@ -476,6 +410,7 @@
        userService.checkUserAllowed(user);
        userService.checkUserDataScope(user.getUserId());
        //todo 双重加密,在登录时校验 修改密码时校验
        user.setPassword(SecurityUtils.encryptPassword(MD5Generator.generateMD5("a123456")));
        user.setUpdateBy(SecurityUtils.getUsername());
        return toAjax(userService.resetPwd(user));
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleAddDto.java
@@ -12,8 +12,6 @@
    @ApiModelProperty(value = "角色名称", required = true)
    @NotBlank(message = "角色名称不能为空")
    private String roleName;
    @ApiModelProperty(value = "站点id", required = true)
    private List<Integer> siteIds;
    @ApiModelProperty(value = "备注")
    private String remark;
    @ApiModelProperty(value = "菜单id", required = true)
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/RoleUpdateDto.java
@@ -13,8 +13,6 @@
    @ApiModelProperty(value = "角色名称",required = true)
    @NotBlank(message = "角色名称不能为空")
    private String roleName;
    @ApiModelProperty(value = "站点id", required = true)
    private List<Integer> siteIds;
    @ApiModelProperty(value = "备注")
    private String remark;
    @ApiModelProperty(value = "菜单id", required = true)
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/dto/UpdatePassword.java
@@ -13,6 +13,5 @@
    private String newPassword;
    private String oldPassword;
    // 1平台 2门店
    private Integer type;
}
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
@@ -48,6 +48,8 @@
     * @return 用户对象信息
     */
    SysUser selectUserByUserName(String userName);
    SysUser selectUserShopByUserName(String userName);
    /**
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -57,11 +57,6 @@
    @Override
    @DataScope(deptAlias = "d")
    public List<SysDept> selectDeptList(SysDept dept) {
        Long userid = tokenService.getLoginUser().getUserid();
        SysUser sysUser = sysUserService.getById(userid);
        if(sysUser.getRoleType() == 2){
            dept.setShopId(sysUser.getObjectId());
        }
        return deptMapper.selectDeptList(dept);
    }
@@ -190,10 +185,10 @@
    @Override
    public boolean checkDeptNameUnique(SysDept dept)
    {
        Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
        SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
        Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();//部门id
        SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());//查询该父类部门下是否有相同名字的部门
        if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
        {
        {//有相同部门名称,且部门id不相同,返回不唯一
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
@@ -207,7 +202,7 @@
    @Override
    public void checkDeptDataScope(Long deptId)
    {
        if (!SysUser.isAdmin(SecurityUtils.getUserId()))
        if (!SysUser.isAdmin(SecurityUtils.getUserId()))//超级管理员跳过验证
        {
            SysDept dept = new SysDept();
            dept.setDeptId(deptId);
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java
@@ -65,15 +65,15 @@
    public Set<String> getMenuPermission(SysUser user)
    {
        Set<String> perms = new HashSet<String>();
        List<UserShop> userShop = userShopService.getUserShop(user.getUserId(), 1);
        List<UserShop> userShop = userShopService.getUserShop(user.getUserId(), 1);//获取门店
        // 管理员拥有所有权限
        if (user.isAdmin())
        {
            perms.add("*:*:*");
        }else if(user.getRoleType() == 2 && null != userShop && userShop.size() > 0){
        }/*else if(user.getRoleType() == 2 && null != userShop && userShop.size() > 0){//门店
            List<SysMenu> list = menuService.getAllMenu(2);
            return list.stream().map(SysMenu::getPath).collect(Collectors.toSet());
        }
        }*/
        else
        {
            List<SysRole> roles = user.getRoles();
@@ -88,13 +88,14 @@
                }
            }
            else
            {
                if(user.getRoleType() == 1){
            {//没有角色
                perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
                /*if(user.getRoleType() == 1){
                    perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
                }else{
                    UserShop one = userShopService.getOne(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId()).eq(UserShop::getShopId, user.getObjectId()));
                    perms.addAll(menuService.selectMenuPermsByRoleId(one.getRoleId()));
                }
                }*/
            }
        }
        return perms;
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
@@ -94,22 +94,13 @@
    @Override
    public Set<String> selectRolePermissionByUserId(SysUser user) {
        Set<String> permsSet = new HashSet<>();
        if(user.getRoleType() == 1){
            //平台
            List<SysRole> perms = roleMapper.selectRolePermissionByUserId(user.getUserId());
            for (SysRole perm : perms) {
                if (StringUtils.isNotNull(perm)) {
                    permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
                }
            }
        }/*else{
            List<UserShop> list = userShopService.list(new LambdaQueryWrapper<UserShop>().eq(UserShop::getUserId, user.getUserId())
                    .eq(UserShop::getShopId, user.getObjectId()));
            for (UserShop userShop : list) {
                if (StringUtils.isNotNull(userShop)) {
                    permsSet.add(userShop.getRoleId() + "");
                }
            }
        }*/
        return permsSet;
    }
    
ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysDeptMapper.xml
@@ -46,9 +46,6 @@
        <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
ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml
@@ -105,7 +105,6 @@
    <select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
        where u.user_name = #{userName} and u.del_flag = '0'
        and u.role_type = 1
    </select>
    <select id="selectUserShopByUserName" parameterType="String" resultMap="SysUserResult">
        <include refid="selectUserVo"/>
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -79,6 +79,8 @@
    private OrderClient orderClient;
    @Resource
    private SysConfigClient sysConfigClient;
    @Resource
    private AppUserShopService appUserShopService;
    
    @Resource
    private UserCancellationLogService userCancellationLogService;
@@ -310,24 +312,10 @@
    public R<IPage<AppUser>> getAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum,
                                               @ApiParam("每一页数据大小") Integer pageSize,
                                               AppUser 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();
        }
//        appUser.setExcludeStatus(3);
        IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId);
        for (AppUser record : appuserPage.getRecords()) {
            Shop shop1 = shopClient.getServiceProvider(record.getId()).getData();
            if(null != shop1){
                record.setShopName(shop1.getName());
                record.setShopId(shop1.getId());
            }
        }
        return R.ok(appuserPage);
    }
@@ -368,7 +356,7 @@
    @GetMapping("/shop/getAppuserPage")
    @ApiOperation(value = "用户列表", tags = {"门店后台"})
    @ApiOperation(value = "用户列表-在门店下过单的", tags = {"门店后台"})
    public R<IPage<AppUser>> shopGetAppuserPage(@ApiParam("页码") @RequestParam Integer pageCurr,
                                                @ApiParam("每一页数据大小") Integer pageSize,
                                                AppUser appUser) {
@@ -433,6 +421,7 @@
/*
    @GetMapping("/detail")
    @ApiOperation(value = "用户列表-详情", tags = {"管理后台"})
@@ -453,20 +442,13 @@
            }
            byId.setShopNames(shopName);
        }
        //推广人
        /*if (byId.getInviteUserId() != null) {
            AppUser appUser = appUserService.getById(byId.getInviteUserId());
            if(null != appUser){
                byId.setInviteUserName(appUser.getName());
            }
        }*/
        //最后下单时间
        R<Order> lastOrder = remoteOrderGoodsClient.getLastOrder(id);
        if (lastOrder.getData() != null) {
            byId.setLastOrderTime(lastOrder.getData().getCreateTime());
        }
        /*List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).list();
        byId.setBottomUsers(list);*/
        //消费总金额
        if(null == shopId || 1 == sysUser.getRoleType()){
            shopId = -1;
@@ -484,6 +466,7 @@
        }
        return R.ok(byId);
    }
*/
@@ -542,51 +525,76 @@
    /**
     * 用户统计
     * 工作台-顶部
     */
    @GetMapping("/statistics")
    @ApiOperation(value = "用户统计", tags = {"管理后台-首页统计-用户统计"})
    @GetMapping("/homeStatistics/statistics")
    @ApiOperation(value = "统计", tags = {"后台-工作台-顶部"})
    public R<UserStatistics> statistics() {
        Long userId = tokenService.getLoginUser().getUserid();
        SysUser data = sysUserClient.getSysUser(userId).getData();
        QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>();
        if (data.getRoleType() == 2) {
            Integer shopId = data.getObjectId();
            List<Order> orders = orderClient.getRedeemedOrdersByShop(shopId).getData();
            List<Long> userIds = orders.stream().map(Order::getAppUserId).collect(Collectors.toList());
            queryWrapper.in(!CollectionUtils.isEmpty(userIds), "id", userIds); // userIds 不为空时,查询 id 在 userIds 中
        }
        queryWrapper.eq("del_flag", 0);
        queryWrapper.ne("status", 3);
        List<AppUser> appUserList = appUserService.list(queryWrapper);
        queryWrapper.ne("status", 3);//没有注销的
        Map<Integer, Long> vipIdCountMap = appUserList.stream()
                .collect(Collectors.groupingBy(AppUser::getVipId, Collectors.counting()));
        List<AppUser> appUserList = appUserService.list(queryWrapper);
        long consumerUser = appUserList.stream()
                .filter(user -> user.getLastShopTime() != null)
                .count();//消费者总数
        UserStatistics userStatistics = new UserStatistics();
        userStatistics.setTotalUser(appUserList.size());
        userStatistics.setConsumerUser(vipIdCountMap.getOrDefault(0, 0L).intValue() +
                vipIdCountMap.getOrDefault(1, 0L).intValue() +
                vipIdCountMap.getOrDefault(2, 0L).intValue() +
                vipIdCountMap.getOrDefault(3, 0L).intValue());
        userStatistics.setCommonUser(vipIdCountMap.getOrDefault(1, 0L).intValue());
        userStatistics.setGoldUser(vipIdCountMap.getOrDefault(2, 0L).intValue());
        userStatistics.setDiamondUser(vipIdCountMap.getOrDefault(3, 0L).intValue());
        userStatistics.setEntrepreneurUser(vipIdCountMap.getOrDefault(4, 0L).intValue() +
                vipIdCountMap.getOrDefault(5, 0L).intValue() +
                vipIdCountMap.getOrDefault(6, 0L).intValue() +
                vipIdCountMap.getOrDefault(7, 0L).intValue());
        userStatistics.setProxyUser(vipIdCountMap.getOrDefault(4, 0L).intValue());
        userStatistics.setAgentUser(vipIdCountMap.getOrDefault(5, 0L).intValue());
        userStatistics.setTotalAgentUser(vipIdCountMap.getOrDefault(6, 0L).intValue());
        userStatistics.setPartnerUser(vipIdCountMap.getOrDefault(7, 0L).intValue());
        userStatistics.setTotalUser(appUserList.size());//总用户数
        userStatistics.setConsumerUser((int) consumerUser);//消费过的用户
        //用户类型统计门店
        long shopUserCount = appUserList.stream()
                .filter(appUser -> appUser.getUserType() == 2)
                .count();
        userStatistics.setShopUser((int) shopUserCount);
        //门店总数
        long shopNum = shopClient.getAllShop().getData().size();
        userStatistics.setShopNum((int) shopNum);
        return R.ok(userStatistics);
    }
    /**
     * 工作台-用户分析
     */
    @GetMapping("/homeStatistics/userAnalysis")
    @ApiOperation(value = "用户分析", tags = {"后台-工作台-用户分析"})
    public R<UserStatisticsDetail> userAnalysis(@ApiParam(value = "用户id") @RequestParam(value = "userId",required = false) Long userId) {
        UserStatisticsDetail userStatistics = new UserStatisticsDetail();
        QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>();
        // 条件构造  统计充值积分
        queryWrapper.select("SUM(recharge_point) as total_points");
        queryWrapper.eq("del_flag", 0);//未删除的
        queryWrapper.ne("status", 3);//未注销的
        if (userId != null) {
            queryWrapper.eq("user_id", userId);
        }
        //统计充值积分
        Map<String, Object> result = appUserService.getMap(queryWrapper);
        if (result == null || result.get("total_points") == null) {
            userStatistics.setTotalScore(0L);
        }else {
            userStatistics.setTotalScore((Long) result.get("total_points"));
        }
        //统计消费积分和现金支付数
        Map<String, Object> data = orderClient.getConsumeScoreAndPayAmount(userId).getData();
        if (data == null || data.get("total_points") == null) {
            userStatistics.setConsumeScore(0L);
        }else {
            userStatistics.setConsumeScore(Long.valueOf(data.get("total_points").toString()) );
        }
        if (data == null || data.get("payment_amounts") == null) {
            userStatistics.setShopAmount(BigDecimal.ZERO);
        }else {
            userStatistics.setShopAmount(new BigDecimal(data.get("payment_amounts").toString()));
        }
        return R.ok(userStatistics);
    }
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/dto/UserCancelQuery.java
@@ -14,8 +14,6 @@
    @ApiModelProperty("电话")
    private String userPhone;
    private Integer vipId;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate localDate1;
    @JsonFormat(pattern = "yyyy-MM-dd")
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java
@@ -520,10 +520,15 @@
        List<Shop> shopList = shopClient.getShopByUserId(userId).getData();
        user.setShopStatus(0);//未拥有门店
        if (shopList != null && !shopList.isEmpty()) {
            user.setShopStatus(2);//门店都被冻结
            for (Shop shop : shopList) {
                if (shop.getStatus()==1) {
                    user.setShopStatus(1);//门店状态
                }
                if(null==user.getShopIds()){
                    Set<Integer> integers = new HashSet<>();
                    user.setShopIds(integers);
                }
                    user.getShopIds().add(shop.getId());
                    user.setShopIds(user.getShopIds());
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java
@@ -10,11 +10,15 @@
import com.ruoyi.account.vo.UserPointDetailVO;
import com.ruoyi.account.vo.UserPointStatistics;
import com.ruoyi.account.vo.UserPointVO;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.PhoneNumberValidator;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.other.api.enums.PointChangeType;
import com.ruoyi.system.api.domain.SysConfig;
import com.ruoyi.system.api.feignClient.SysConfigClient;
import com.ruoyi.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -42,6 +46,8 @@
    private TokenService tokenService;
    @Resource
    private UserPointService userPointService;
    @Resource
    private SysConfigClient sysConfigClient;
    
@@ -58,6 +64,16 @@
        userPointVO.setExpendPoint(appUser.getExchangePoint());
        userPointVO.setTransferableInPoint(appUser.getTransferableInPoint());
        userPointVO.setTransferableOutPoint(appUser.getTransferableOutPoint());
        R<SysConfig> info = sysConfigClient.getInfo(9L);
        if (info == null || info.getData() == null) {
            throw new RuntimeException("获取积分兑换比例配置失败");
        }
        String configValue = info.getData().getConfigValue();
        if (StringUtils.isBlank(configValue)) {
            throw new RuntimeException("积分兑换比例配置值为空");
        }
        Boolean isTransferable = Boolean.valueOf(configValue.trim());
        userPointVO.setIsTransferable(isTransferable);
        return userPointVO;
    }
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserPointVO.java
@@ -28,4 +28,7 @@
    @ApiModelProperty(value = "转增(转出)")
    private Integer transferableOutPoint;
    @ApiModelProperty(value = "是否开启转增积分功能")
    private Boolean isTransferable;
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserStatistics.java
@@ -25,51 +25,14 @@
    @ApiModelProperty(value = "消费者用户数")
    private Integer consumerUser;
    /**
     * 普通会员数
     */
    @ApiModelProperty(value = "普通会员数")
    private Integer commonUser;
    /**
     * 黄金会员数
     * 店铺总数
     */
    @ApiModelProperty(value = "黄金会员数")
    private Integer goldUser;
    @ApiModelProperty(value = "店铺总数")
    private Integer shopNum;
    /**
     * 钻石会员数
     */
    @ApiModelProperty(value = "钻石会员数")
    private Integer diamondUser;
    /**
     * 创业者总数
     */
    @ApiModelProperty(value = "创业者总数")
    private Integer entrepreneurUser;
    /**
     * 准代理数
     */
    @ApiModelProperty(value = "准代理数")
    private Integer proxyUser;
    /**
     * 代理数
     */
    @ApiModelProperty(value = "代理数")
    private Integer agentUser;
    /**
     * 总代数
     */
    @ApiModelProperty(value = "总代数")
    private Integer totalAgentUser;
    /**
     * 合伙人数
     */
    @ApiModelProperty(value = "合伙人数")
    private Integer partnerUser;
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserStatisticsDetail.java
@@ -14,62 +14,14 @@
     * 用户获得总积分
     */
    @ApiModelProperty("用户获得总积分")
    private Integer totalScore;
    private Long totalScore;
    /**
     * 消费积分总数
     */
    @ApiModelProperty("消费积分总数")
    private Integer consumeScore;
    private Long consumeScore;
    /**
     * 返佣积分总数
     */
    @ApiModelProperty("返佣积分总数")
    private Integer rebateScore;
    /**
     * 拉新人积分总数
     */
    @ApiModelProperty("拉新人积分总数")
    private Integer inviteScore;
    /**
     * 注册积分总数
     */
    @ApiModelProperty("注册积分总数")
    private Integer registerScore;
    /**
     * 做工积分总数
     */
    @ApiModelProperty("做工积分总数")
    private Integer workScore;
    /**
     * 技师业绩积分总数
     */
    @ApiModelProperty("技师业绩积分总数")
    private Integer achievementScore;
    /**
     * 用户获得分佣总金额
     */
    @ApiModelProperty("用户获得分佣总金额")
    private BigDecimal totalRebate;
    /**
     * 充值金额
     */
    @ApiModelProperty("充值金额")
    private BigDecimal totalRecharge;
    /**
     * 已提现金额
     */
    @ApiModelProperty("已提现金额")
    private BigDecimal totalWithdraw;
    /**
     * 消费总金额
     */
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml
@@ -54,9 +54,6 @@
        FROM t_app_user ta
        <where>
            ta.del_flag = 0 and ta.status != 3
            <if test="appUser.excludeStatus != null">
                and ta.status != #{appUser.excludeStatus}
            </if>
            <if test="appUser.name != null and appUser.name != ''">
                and ta.`name` like CONCAT('%',#{appUser.name},'%')
            </if>
@@ -66,9 +63,7 @@
            <if test="null != appUser.status">
                and ta.status = #{appUser.status}
            </if>
            <if test="null != appUser.vipId">
                and ta.vip_id = #{appUser.vipId}
            </if>
            <if test="null != appUser.shopIds and appUser.shopIds.size() > 0">
                and ta.shop_id in
                <foreach collection="appUser.shopIds" item="shopId" open="(" separator="," close=")">
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserCancellationLogMapper.xml
@@ -26,9 +26,6 @@
            <if test="agentQuery.userPhone != null and agentQuery.userPhone != ''">
                and t2.phone like concat('%',#{agentQuery.userPhone},'%')
            </if>
            <if test="agentQuery.vipId != null">
                and t1.vip_id = #{agentQuery.vipId}
            </if>
            <if test="agentQuery.localDate1 != null">
                and DATE(t1.create_time) between #{agentQuery.localDate1} and #{agentQuery.localDate2}
            </if>
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -4,6 +4,7 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.AppUser;
@@ -15,6 +16,8 @@
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.order.dto.ConfirmOrderDTO;
import com.ruoyi.order.enums.OrderStatus;
import com.ruoyi.order.mapper.OrderMapper;
import com.ruoyi.order.model.Order;
@@ -22,10 +25,13 @@
import com.ruoyi.order.util.payment.model.RefundCallbackResult;
import com.ruoyi.order.util.payment.model.UniPayCallbackResult;
import com.ruoyi.order.util.vo.MapTrackKD100Vo;
import com.ruoyi.order.util.vo.ShopAnalysisVO;
import com.ruoyi.order.vo.*;
import com.ruoyi.other.api.domain.BaseSetting;
import com.ruoyi.other.api.domain.Goods;
import com.ruoyi.other.api.dto.ShopAnalysisDTO;
import com.ruoyi.other.api.feignClient.BaseSettingClient;
import com.ruoyi.other.api.feignClient.ShopClient;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import com.ruoyi.system.api.model.LoginUser;
@@ -40,7 +46,10 @@
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@@ -70,13 +79,16 @@
    @Resource
    private AppUserClient appUserClient;
    @Resource
    private ShopClient shopClient;
    @ResponseBody
    @GetMapping("/confirmOrder")
    @PostMapping("/confirmOrder")
    @ApiOperation(value = "确定订单", tags = {"商城-订单-小程序"})
    public R<ConfirmOrderVo> confirmOrder(@ApiParam("商品id") Integer goodId,@ApiParam("支付类型(1-现金,2-积分)")Integer type) {
        ConfirmOrderVo confirmOrderVo = orderService.confirmOrder(goodId,type);
    public R<ConfirmOrderVo> confirmOrder(@RequestBody ConfirmOrderDTO confirmOrderDTO) {
        ConfirmOrderVo confirmOrderVo = orderService.confirmOrder(confirmOrderDTO.getGoodId(),confirmOrderDTO.getType());
        return R.ok(confirmOrderVo);
    }
@@ -644,5 +656,101 @@
    }
    /**
     * 工作台统计
     */
    @PostMapping("/homeStatistics/getShopAnalysis")
    @ApiOperation(value = "店铺分析", tags = {"后台-工作台-店铺统计"})
    public R<ShopAnalysisVO> getShopAnalysis(@RequestBody ShopAnalysisDTO shopAnalysisDTO) {
        ShopAnalysisVO shopAnalysisVO = new ShopAnalysisVO();
        if (shopAnalysisDTO.getStartTime() == null || shopAnalysisDTO.getEndTime() == null) {
            LocalDate now = LocalDate.now();
            shopAnalysisDTO.setStartTime(now.minusDays(6)); // 7天前
            shopAnalysisDTO.setEndTime(now);
        }
        else if (shopAnalysisDTO.getStartTime().isAfter(shopAnalysisDTO.getEndTime())) {
            return R.fail("开始时间不能大于结束时间");
        }
       /* // 限制最大查询范围不超过3个月(可选)
        else if (Duration.between(shopAnalysisDTO.getStartTime(), shopAnalysisDTO.getEndTime()).toDays() > 90) {
            return R.fail("查询时间范围不能超过90天");
        }*/
        //订单统计
        QueryWrapper<Order> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("count(*) as total","SUM(total_amount) as total_money");
        queryWrapper.eq("del_flag", 0);
        queryWrapper.in("order_status", Arrays.asList(3,4,8));//待核销  已完成  已评价
        queryWrapper.eq("pay_status",2);
        queryWrapper.ge("create_time", shopAnalysisDTO.getStartTime().atStartOfDay());
        queryWrapper.le("create_time", shopAnalysisDTO.getEndTime().atTime(LocalTime.MAX));
        if (null!=shopAnalysisDTO.getShopId()){
            queryWrapper.eq("shop_id", shopAnalysisDTO.getShopId());
        }
        Map<String, Object> result = orderService.getMap(queryWrapper);
        if (result == null || result.get("total") == null) {
            shopAnalysisVO.setTotal(0);
        }else {
            shopAnalysisVO.setTotal(Integer.valueOf(result.get("total").toString()));
        }
        if (result == null || result.get("total_money") == null) {
            shopAnalysisVO.setTotalMoney(BigDecimal.ZERO);
        }else {
            shopAnalysisVO.setTotalMoney(new BigDecimal(result.get("total_money").toString()));
        }
        //收益分析
        Map<String, Object> shopResult =shopClient.getIncomeAnalysis(shopAnalysisDTO).getData();
        if (shopResult!=null){
            if (shopResult.get("balance")==null||shopResult.get("canWithdrawMoney")==null){
                shopAnalysisVO.setCanWithdrawMoney(BigDecimal.ZERO);
                shopAnalysisVO.setFreezeMoney(BigDecimal.ZERO);
            }else {
                shopAnalysisVO.setCanWithdrawMoney(new BigDecimal(shopResult.get("canWithdrawMoney").toString()));
                shopAnalysisVO.setFreezeMoney(new BigDecimal(shopResult.get("balance").toString()).subtract(shopAnalysisVO.getCanWithdrawMoney()));
            }
            if (shopResult.get("withdrawMoney")==null){
                shopAnalysisVO.setWithdrawMoney(BigDecimal.ZERO);
            }else {
                shopAnalysisVO.setWithdrawMoney(new BigDecimal(shopResult.get("withdrawMoney").toString()));
            }
            if (shopResult.get("withdrawAuditMoney")==null){
                shopAnalysisVO.setWithdrawAuditMoney(BigDecimal.ZERO);
            }else {
                shopAnalysisVO.setWithdrawAuditMoney(new BigDecimal(shopResult.get("withdrawAuditMoney").toString()));
            }
        }else {
            shopAnalysisVO.setCanWithdrawMoney(BigDecimal.ZERO);
            shopAnalysisVO.setFreezeMoney(BigDecimal.ZERO);
            shopAnalysisVO.setWithdrawMoney(BigDecimal.ZERO);
            shopAnalysisVO.setWithdrawAuditMoney(BigDecimal.ZERO);
        }
        //折线图
        List<OrderStatisticsDetail> orderStatisticsDetailList=orderService.getOrderListGroupByDate(shopAnalysisDTO.getStartTime(), shopAnalysisDTO.getEndTime());
        shopAnalysisVO.setOrderStatisticsDetailList(orderStatisticsDetailList);
        return R.ok(shopAnalysisVO);
    }
    /**
     * 统计用户总消费积分数和现金支付金额
     */
    @GetMapping("/getOrderCountByAppUserId/")
    R<Map<String ,Object>> getConsumeScoreAndPayAmount(@RequestParam(value = "userId",required = false) Long userId){
        QueryWrapper<Order> queryWrapper = new QueryWrapper<>();
        // 条件构造  统计充值积分
        queryWrapper.select("SUM(point) as total_points","SUM(payment_amount) as payment_amounts");
        queryWrapper.eq("del_flag", 0);
        queryWrapper.in("order_status", Arrays.asList(3,4,8));//待核销  已完成  已评价
        queryWrapper.eq("pay_status",2);
        if (userId != null) {
            queryWrapper.eq("user_id", userId);
        }
        return R.ok(orderService.getMap(queryWrapper));
    }
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/ConfirmOrderDTO.java
New file
@@ -0,0 +1,17 @@
package com.ruoyi.order.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
public class ConfirmOrderDTO {
    @ApiModelProperty("Integer goodId")
    @NotNull(message = "商品Id不能为空")
    private Integer goodId;
    @ApiModelProperty("支付类型(1-现金,2-积分)")
    @NotNull(message = "商品类型不能为空")
    private Integer type;
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java
@@ -5,9 +5,11 @@
import com.ruoyi.order.vo.*;
import com.ruoyi.order.model.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
/**
 * <p>
@@ -56,4 +58,8 @@
    Integer getShopSaleNumByShopIds(@Param("shopIds") List<Integer> shopIds, @Param("type") Integer type);
    List<OrderExport> getOrderExportList( @Param("item") OrderPageList order);
    List<OrderStatisticsDetail> getOrderListGroupByDate(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java
@@ -10,6 +10,8 @@
import com.ruoyi.order.vo.*;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
/**
@@ -128,4 +130,9 @@
    IPage<OrderPageListVo> getShopOrderList(String content, Integer status, Integer shopId, Integer pageNum, Integer pageSize);
    R shopCancelOrder(Long orderId);
    /**
     * 后台-工作台,订单折线图
     */
    List<OrderStatisticsDetail> getOrderListGroupByDate(LocalDate startTime, LocalDate endTime);
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -57,13 +57,12 @@
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.*;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -188,6 +187,10 @@
        } catch (Exception e) {
            e.printStackTrace();
            throw new ServiceException("生成核销码失败");
        }
        if(3!=order.getOrderStatus()){
            //不属于未使用的,应该有个核销\取消时间
            orderDetailVO.setEndTime(order.getEndTime());
        }
        //该商品是否被用户评论
        Long evaluateId = goodsEvaluateClient.getEvaluateIdByOrderId(order.getId()).getData();
@@ -419,6 +422,9 @@
        //退款成功再回退积分
        AppUser appUser = appUserClient.getAppUserById(order.getAppUserId());
        if (order.getPoint()>0) {
            if(null==appUser.getCancelPoint()){
                appUser.setCancelPoint(0);
            }
            //返回订单抵扣积分
            Integer historicalPoint = appUser.getAvailablePoint();
            Integer availablePoint = appUser.getAvailablePoint() + order.getPoint();//可用积分
@@ -684,11 +690,16 @@
        //判断是否是积分支付
        if (type == 1) {//现金
            confirmOrderVo.setOrderMoney(confirmOrderVo.getCash());
            Integer availablePoint = appUser.getAvailablePoint();//用户可用积分
            BigDecimal maxPointDeductionAmount = getCashByPoint(availablePoint);//最大可抵扣金额
            //计算积分抵扣的金额  将积分转为金额,去掉小数
            BigDecimal deduction=getCashByPoint(confirmOrderVo.getResidualPoint());
            //实际抵扣金额
            BigDecimal deduction= maxPointDeductionAmount.min(confirmOrderVo.getCash());
            confirmOrderVo.setDeduction(deduction);
        }else {//积分
            confirmOrderVo.setOrderPoint(good.getIntegral());
            confirmOrderVo.setOrderPoint(confirmOrderVo.getPoint());
        }
        //限购检查
        //判断当前数量是否已经超出限购数量(需要计算已经购买的数量)
@@ -844,6 +855,13 @@
        }
        //判断积分是否为零,积分支付
        if (0 != order.getPoint()){
            if (null==appUser.getAvailablePoint()){
                appUser.setAvailablePoint(0);
            }
            if (null==appUser.getExchangePoint()){
                appUser.setExchangePoint(0);
            }
            //积分支付
            Integer historicalPoint = appUser.getAvailablePoint();//历史积分
            Integer availablePoint = historicalPoint - orderPoint;//可用积分
@@ -896,6 +914,10 @@
        //门店增加冻结资金 即增加余额, 冻结资金=余额-可用资金
        Shop shop = shopClient.getShopById(order.getShopId()).getData();
        if (null==shop.getBalance()){
            shop.setBalance(BigDecimal.ZERO);
        }
        BigDecimal historicalBalance=shop.getBalance();//历史余额
        BigDecimal variableAmount=goods.getSellingPrice();//变动金额
        BigDecimal balance=shop.getBalance().add(goods.getSellingPrice());//变动后余额
@@ -1048,8 +1070,11 @@
            queryWrapper.eq("shop_id", shopId);
        }
        // 添加订单状态条件
        if (status != null) {
            queryWrapper.eq("order_status", status);
        if (status != null&&status==4) { //4-已完成 8-已评价
            queryWrapper.in("order_status",Arrays.asList(4,8));
        }
        if (status != null&&status!=4) {//3-待核销 5-已取消
            queryWrapper.eq("order_status",status);
        }
        // 模糊查询条件
        if (StringUtils.isNotBlank(content)) {
@@ -1079,12 +1104,47 @@
            return R.fail("订单取消失败");
        }
        order.setOrderStatus(5);
        order.setEndTime(LocalDateTime.now());
        R r = refundPayMoney(order);
        if (200 == r.getCode()) {
            this.updateById(order);
        }
        return r;
    }
    /**
     * 后台-工作台-折线图
     * @param startTime
     * @param endTime
     * @return
     */
    @Override
    public List<OrderStatisticsDetail> getOrderListGroupByDate(LocalDate startTime, LocalDate endTime) {
        // 查询数据库获取原始数据
        List<OrderStatisticsDetail> rawData = orderMapper.getOrderListGroupByDate(
                startTime.atTime(0,0, 0),
                endTime.atTime(23,59,59)
        );
        // 创建完整日期范围的映射
        Map<LocalDate, OrderStatisticsDetail> dateMap = rawData.stream()
                .collect(Collectors.toMap(
                        OrderStatisticsDetail::getDateTime,
                        Function.identity()
                ));
        // 生成完整日期序列并填充缺失数据
        List<OrderStatisticsDetail> completeList = new ArrayList<>();
        for (LocalDate date = startTime; !date.isAfter(endTime); date = date.plusDays(1)) {
            if (dateMap.containsKey(date)) {
                completeList.add(dateMap.get(date));
            } else {
                completeList.add(new OrderStatisticsDetail(date, 0, BigDecimal.ZERO));
            }
        }
        return completeList;
    }
    private OrderPageListVo convertToOrderListVo(Order order) {
        OrderPageListVo vo = new OrderPageListVo();
@@ -1095,6 +1155,7 @@
        if (user != null) {
            vo.setPhone(user.getPhone());
        }
        vo.setIdStr(order.getId().toString());
        return vo;
    }
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/vo/ShopAnalysisVO.java
New file
@@ -0,0 +1,38 @@
package com.ruoyi.order.util.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.order.vo.OrderStatisticsDetail;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class ShopAnalysisVO {
    /**
     * 订单总数
     */
    @ApiModelProperty(value = "订单总数")
    private Integer total;
    /**
     * 收益
     */
    @ApiModelProperty(value = "总收益")
    private BigDecimal totalMoney;
    @ApiModelProperty(value = "可提现金额")
    private BigDecimal canWithdrawMoney;
    @ApiModelProperty(value = "已提现金额")
    private BigDecimal withdrawMoney;
    @ApiModelProperty(value = "提现中金额")
    private BigDecimal withdrawAuditMoney;
    @ApiModelProperty(value = "冻结中金额")
    private BigDecimal freezeMoney;
    private List<OrderStatisticsDetail> orderStatisticsDetailList;
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java
@@ -18,6 +18,8 @@
public class OrderPageListVo {
    @ApiModelProperty("订单id")
    private Long id;
    @ApiModelProperty("订单idStr")
    private String idStr;
    @ApiModelProperty("订单编号")
    @Excel(name = "订单编号")
    private String orderNumber;
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderStatisticsDetail.java
@@ -1,39 +1,30 @@
package com.ruoyi.order.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class OrderStatisticsDetail {
    private String date;
    /**
     * 服务订单数量
     */
    private Integer serviceTotal;
    /**
     * 单品订单数量
     */
    private Integer singleTotal;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate dateTime;
    /**
     * 订单总数量
     */
    private Integer total;
    /**
     * 订单总金额
     */
    private BigDecimal totalMoney;
    /**
     * 服务订单金额
     */
    private BigDecimal serviceTotalMoney;
    /**
     * 单品订单金额
     */
    private BigDecimal singleTotalMoney;
}
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -226,4 +226,12 @@
        </if>
        order by o.create_time desc
    </select>
    <select id="getOrderListGroupByDate" resultType="com.ruoyi.order.vo.OrderStatisticsDetail">
        SELECT DATE_FORMAT(create_time, '%Y-%m-%d') AS `date_time`, COUNT(id) AS total, SUM(total_amount) AS total_money
        FROM t_order WHERE del_flag = 0 AND order_status IN (3, 4, 8) AND pay_status = 2
            AND create_time BETWEEN #{startTime} AND #{endTime}
        GROUP BY `date_time` ORDER BY `date_time` ASC
    </select>
</mapper>
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/AgreementController.java
@@ -43,7 +43,7 @@
    
    @ResponseBody
    @GetMapping("/getAgreementByType/{type}")
    @ApiOperation(value = "协议管理-详情", tags = {"管理后台"})
    @ApiOperation(value = "协议管理-详情", tags = {"后台"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "类型(1=用户协议,2=隐私协议,4=注销协议,5门店提现免责声明)", name = "type", required = true, dataType = "int"),
    })
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsShopController.java
@@ -38,6 +38,8 @@
    @Resource
    private ShopService shopService;
    @Resource
    private GoodsService goodsService;
    
@@ -53,8 +55,10 @@
        if (shop == null || shop.getStatus() ==2 || shop.getDelFlag()==1) {
            return R.ok();
        }
        one.setShopName(shop.getName());
        one.setPhone(shop.getPhone());
        one.setAddress(shop.getAddress());
        return R.ok(one);
    }
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PhoneController.java
@@ -57,16 +57,10 @@
    
    
    @GetMapping("/getSysPhone")
    @ApiOperation(value = "获取客服电话", tags = {"管理后台-客服电话", "门店后台-客服电话"})
    @ApiOperation(value = "获取客服电话", tags = {"后台-客服电话"})
    public R<Phone> getSysPhone(){
        Long userId = tokenService.getLoginUser().getSysUser().getUserId();
        SysUser sysUser = sysUserClient.getSysUser(userId).getData();
        LambdaQueryWrapper<Phone> wrapper = new LambdaQueryWrapper<>();
        if(sysUser.getRoleType() == 1){
            wrapper.eq(Phone::getType, 1);
        }else{
            wrapper.eq(Phone::getType, 2).eq(Phone::getShopId, sysUser.getObjectId());
        }
        wrapper.eq(Phone::getType, 1);
        Phone one = phoneService.getOne(wrapper);
        return R.ok(one);
    }
@@ -74,12 +68,9 @@
    
    
    @PostMapping("/savePhone")
    @ApiOperation(value = "保存客服电话", tags = {"管理后台-客服电话", "门店后台-客服电话"})
    @ApiOperation(value = "保存客服电话", tags = {"管理后台-客服电话"})
    public R savePhone(@RequestBody Phone phone){
        Long userId = tokenService.getLoginUser().getSysUser().getUserId();
        SysUser sysUser = sysUserClient.getSysUser(userId).getData();
        //平台配置
        if(sysUser.getRoleType() == 1){
            Phone one = phoneService.getOne(new LambdaQueryWrapper<Phone>().eq(Phone::getType, 1));
            if(null != one){
                one.setPhoneOne(phone.getPhoneOne());
@@ -89,19 +80,7 @@
                phone.setType(1);
                phoneService.save(phone);
            }
        }else{
            //门店配置
            Phone one = phoneService.getOne(new LambdaQueryWrapper<Phone>().eq(Phone::getType, 2).eq(Phone::getShopId, sysUser.getObjectId()));
            if(null != one){
                one.setPhoneOne(phone.getPhoneOne());
                one.setPhoneTwo(phone.getPhoneTwo());
                phoneService.updateById(one);
            }else{
                phone.setType(2);
                phone.setShopId(sysUser.getObjectId());
                phoneService.save(phone);
            }
        }
        return R.ok();
    }
    
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -22,6 +23,7 @@
import com.ruoyi.order.vo.OrderSaleNum;
import com.ruoyi.order.vo.VerifiableShopVo;
import com.ruoyi.other.api.domain.*;
import com.ruoyi.other.api.dto.ShopAnalysisDTO;
import com.ruoyi.other.dto.AddGoodsDTO;
import com.ruoyi.other.enums.PhoneType;
import com.ruoyi.other.mapper.ShopMapper;
@@ -773,6 +775,16 @@
    }
    /**
     * 编辑商品
     */
    @PostMapping("/editGoods")
    @ApiOperation(value = "编辑商品", tags = {"门店后台-商品管理"})
    public R<Integer> editGoods(@RequestBody AddGoodsDTO addGoodsDTO) {
        return R.ok( shopService.editGoodsByShop(addGoodsDTO));
    }
    /**
     * 上、下架商品
     */
    @PostMapping("/status/{goodsId}")
@@ -807,11 +819,10 @@
    /**
     * 获取所有门店
     * @return
     */
    @PostMapping("/getAllShop")
    public R<List<Shop>> getAllShop(){
        List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1));
        List<Shop> list = shopService.list(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0));
        return R.ok(list);
    }
@@ -855,6 +866,7 @@
    }
/*
    @GetMapping("/getShopStatistics")
    public R<Map<String, BigDecimal> > getShopStatistics(@RequestParam("shopId") Integer shopId){
        LambdaQueryWrapper<Shop> queryWrapper = new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1);
@@ -864,16 +876,34 @@
        List<Shop> shopList = shopService.list(queryWrapper);
        BigDecimal serverGiveawayMoney = BigDecimal.ZERO;
        BigDecimal giveawayMoney = BigDecimal.ZERO;
       /* for (Shop shop : shopList) {
       */
/* for (Shop shop : shopList) {
            serverGiveawayMoney = serverGiveawayMoney.add(shop.getServerGiveawayMoney());
            giveawayMoney = giveawayMoney.add(shop.getGiveawayMoney().add(shop.getLowerLevelGiveawayMoney()));
        }*/
        }*//*
        Map<String, BigDecimal> map = new HashMap<>();
        map.put("serverGiveawayMoney", serverGiveawayMoney);
        map.put("giveawayMoney", giveawayMoney);
        return R.ok(map);
    }
*/
    /**
     * 获取店铺收益 后天-工作台-收益分析
     */
    @PostMapping("/getIncomeAnalysis")
    R<Map<String, Object>> getIncomeAnalysis(@RequestBody ShopAnalysisDTO shopAnalysisDTO){
        QueryWrapper<Shop> queryWrapper=new QueryWrapper<>();
        //余额  已提现 提现中 可提现
        queryWrapper.select("sum(balance) as balance","sum(withdraw_money) as withdrawMoney"
                ,"sum(withdraw_audit_money) as withdrawAuditMoney","sum(can_withdraw_money) as canWithdrawMoney");
        queryWrapper.eq("del_flag",0);
        if (shopAnalysisDTO.getShopId() != null) {
            queryWrapper.eq("id", shopAnalysisDTO.getShopId());
        }
        return R.ok(shopService.getMap(queryWrapper));
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java
@@ -120,9 +120,15 @@
                        .eq(auditStatus!=null,ShopWithdraw::getAuditStatus,auditStatus)
                        .orderByDesc(ShopWithdraw::getCreateTime)
                );
        //添加转账的银行卡号和账户姓名
        List<ShopWithdraw> records = page.getRecords();
        for (ShopWithdraw record : records) {
        }
        return R.ok(page);
    }
/*
    @GetMapping("/shop/info")
    @ApiOperation(value = "提现申请列表上方数据", notes = "提现申请列表", tags = {"门店后台"})
    public R<Shop> shopCommissionStatisticsinfo(){
@@ -154,6 +160,7 @@
        }
        return R.ok(byId);
    }
*/
    @GetMapping("/shop/with")
    @ApiOperation(value = "提现申请", notes = "提现申请列表", tags = {"门店后台"})
@@ -196,6 +203,13 @@
        shopWithdraw.setAuditStatus(0);//待审核
        shopWithdraw.setStatus(1);//申请中
        shopWithdraw.setCreateTime(LocalDateTime.now());
        shopWithdraw.setTradeMerchantNo(shop.getTradeMerchantNo());
        shopWithdraw.setReceiverAccountNoEnc(shop.getReceiverAccountNoEnc());
        shopWithdraw.setReceiverNameEnc(shop.getReceiverNameEnc());
        shopWithdraw.setReceiverBankChannelNo(shop.getReceiverBankChannelNo());
        shopWithdraw.setReceiverAccountType(shop.getReceiverAccountType());
        shopWithdrawService.save(shopWithdraw);
        //扣除账户余额及添加变动明细
        BigDecimal balance = shop.getBalance();//余额
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/dto/AddGoodsDTO.java
@@ -13,6 +13,10 @@
@Data
public class AddGoodsDTO {
    @ApiModelProperty(value = "商品id")
    private Integer goodId;
    @ApiModelProperty(value = "门店id")
    private Integer shopId;
    @ApiModelProperty(value = "名称")
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/ShopService.java
@@ -58,4 +58,6 @@
    GoodsVO goodsDetail(Long goodsId);
    Integer addGoodsByShop(AddGoodsDTO addGoodsDTO);
    Integer editGoodsByShop(AddGoodsDTO addGoodsDTO);
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -39,6 +39,7 @@
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -232,6 +233,7 @@
        //已售数量
        Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 1).getData();
        goodsVO.setSaleNum(integer);
        return goodsVO;
    }
@@ -241,6 +243,9 @@
    public List<GoodsVO> getGoodsListByShopId(PageInfo<GoodsVO> pageInfo, Integer shopId) {
        //查询该门店商品
        List<GoodsVO> goods = goodsMapper.selectListByShopId(pageInfo, shopId);
        if (goods == null) {
            return null;
        }
        for (GoodsVO good : goods) {
            //价格
            Price price = getPrice( good.getGoodsId());
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java
@@ -32,6 +32,7 @@
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -247,7 +248,13 @@
        if(null == goods){
            return null;
        }
        for (GoodsVO good : goods) {
        // 根据id去重
        List<GoodsVO> distinctGoods = goods.stream()
                .collect(Collectors.collectingAndThen(
                        Collectors.toMap(GoodsVO::getGoodsId, Function.identity(), (existing, replacement) -> existing),
                        map -> new ArrayList<>(map.values())
                ));
        for (GoodsVO good : distinctGoods) {
            //价格
            Price price = getPrice( good.getGoodsId());
            if(null != price){
@@ -261,7 +268,7 @@
            Integer data = orderClient.getGoodsSaleNum(good.getGoodsId(), 1).getData();
            good.setSaleNum(data);
        }
        return goods;
        return distinctGoods;
    }
    @Override
@@ -280,10 +287,15 @@
        goodsVO.setGoodsId(goods.getId());
        goodsVO.setGoodsName(goods.getName());
        //商品活动前售价(编辑商品回显)
        goodsVO.setEditPrice(goods.getSellingPrice());
        //限购数量(编辑商品回显)
        goodsVO.setEditNum(goods.getPurchaseLimit());
        //计算所需价格和积分
        Price price = getPrice( goods.getId());
        if(null != price){
            //秒杀活动
            //在秒杀活动时间段内
            goodsVO.setSellingPrice(price.getCash());
            goodsVO.setIntegral(price.getPoint());
            goodsVO.setStartTime(price.getStartTime());
@@ -301,9 +313,28 @@
        //已售数量
        Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 1).getData();
        goodsVO.setSaleNum(integer);
        //分类id
        goodsVO.setGoodsCategoryId(goods.getGoodsCategoryId());
        //一个商品只有一个秒杀活动
        SeckillActivityInfo seckillActivityInfo = seckillActivityInfoService.getOne(new LambdaQueryWrapper<SeckillActivityInfo>()
                .eq(SeckillActivityInfo::getGoodId, goodsId)
                .eq(SeckillActivityInfo::getDelFlag, 0));
        //商品是否开启秒杀活动
        goodsVO.setIsSkillActivity(0);
        if (seckillActivityInfo != null) {
            goodsVO.setIsSkillActivity(1);
            //活动限购数量
            goodsVO.setEditActivityNum(seckillActivityInfo.getMaxNum());
            GoodsSeckill one = goodsSeckillService.getOne(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId()));
            //有秒杀活动,查看秒杀价格
            goodsVO.setEditActivityPrice(one.getSellingPrice());
        }
        return goodsVO;
    }
    /**
     * 发布商品 门店后台-商品管理
@@ -353,6 +384,76 @@
        return goods.getId();
    }
    /**
     * 编辑商品
     * @param addGoodsDTO
     * @return
     */
    @Override
    public Integer editGoodsByShop(AddGoodsDTO addGoodsDTO) {
        if(addGoodsDTO.getPurchaseLimit()==null){
            addGoodsDTO.setPurchaseLimit(-1);
        }
        //先修改商品
        Goods goods = new Goods();
        BeanUtils.copyProperties(addGoodsDTO, goods);
        goods.setStatus(GoodsStatus.DOWN.getCode());//下架状态
        goods.setId(addGoodsDTO.getGoodId());
        goods.setIntegral(getPoint(addGoodsDTO.getSellingPrice()));//积分
        goods.setDelFlag(0);
        goods.setCreateTime(LocalDateTime.now());
        goodsService.updateById(goods);//添加商品
        //门店关系不变
        //判断是否参加秒杀活动
        if (addGoodsDTO.getIsActivity()==1){//参加
            //一个商品只有一个秒杀活动
            SeckillActivityInfo seckillActivityInfo = seckillActivityInfoService.getOne(new LambdaQueryWrapper<SeckillActivityInfo>()
                    .eq(SeckillActivityInfo::getGoodId, addGoodsDTO.getGoodId())
                    .eq(SeckillActivityInfo::getDelFlag, 0));
            if (seckillActivityInfo != null) {
                //删除原本活动
                goodsSeckillService.remove(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId()));
                //删除主表
                seckillActivityInfoService.removeById(seckillActivityInfo.getId());
            }
            //新增
            //秒杀活动
            SeckillActivityInfo seckillActivityInfo1 = new SeckillActivityInfo();
            seckillActivityInfo1.setDelFlag(0);
            seckillActivityInfo1.setCreateTime(LocalDateTime.now());
            seckillActivityInfo1.setGoodId(goods.getId());
            seckillActivityInfo1.setMaxNum(addGoodsDTO.getMaxNum());
            seckillActivityInfo1.setStartTime(addGoodsDTO.getStartTime());
            seckillActivityInfo1.setEndTime(addGoodsDTO.getEndTime());
            seckillActivityInfo1.setIsShelves(1);//默认上架
            seckillActivityInfoService.save(seckillActivityInfo1);
            //秒杀活动价格
            GoodsSeckill goodsSeckill = new GoodsSeckill();
            goodsSeckill.setSellingPrice(addGoodsDTO.getActivityPrice());
            goodsSeckill.setIntegral(getPoint(addGoodsDTO.getActivityPrice()));
            goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo1.getId());
            goodsSeckillService.save(goodsSeckill);
        }else{
            //不参加秒杀活动,删除之前的活动
            //一个商品只有一个秒杀活动
            SeckillActivityInfo seckillActivityInfo = seckillActivityInfoService.getOne(new LambdaQueryWrapper<SeckillActivityInfo>()
                    .eq(SeckillActivityInfo::getGoodId, addGoodsDTO.getGoodId())
                    .eq(SeckillActivityInfo::getDelFlag, 0));
            if (seckillActivityInfo != null) {
                //删除原本活动
                goodsSeckillService.remove(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId()));
                //删除主表
                seckillActivityInfoService.removeById(seckillActivityInfo.getId());
            }
        }
        return goods.getId();
    }
    /**
     * 获取商品当前的价格,就是看当前商品是否在秒杀活动中
     */
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/GoodsVO.java
@@ -1,5 +1,6 @@
package com.ruoyi.other.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.other.api.domain.Shop;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -35,6 +36,8 @@
    private String detailPicture;
    @ApiModelProperty(value = "详情图,多个逗号分隔")
    private Integer goodsCategoryId;
    @ApiModelProperty(value = "基础积分")
    private Integer integral;
@@ -51,16 +54,34 @@
    @ApiModelProperty(value = "门店id")
    private Integer shopId;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "活动开始时间")
    private LocalDateTime startTime;
    @ApiModelProperty(value = "活动结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;
    @ApiModelProperty(value = "状态(1=下架,2=上架)")
    private Integer status;
    @ApiModelProperty(value = "商品售价(编辑商品)")
    private BigDecimal editPrice;
    @ApiModelProperty(value = "限购数量(编辑商品)")
    private Integer editNum;
    @ApiModelProperty(value = "是否秒杀活动,0-否,1-是")
    private Integer isSkillActivity;
    @ApiModelProperty(value = "活动限购数量(编辑商品)")
    private Integer editActivityNum;
    @ApiModelProperty(value = "活动价格(编辑商品)")
    private BigDecimal editActivityPrice;
    @ApiModelProperty(value = "门店")
    private Shop shop;
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/NearbyShopVO.java
@@ -16,8 +16,10 @@
    @ApiModelProperty(value = "门店名称")
    private String name;
    @ApiModelProperty(value = "详细地址")
    @ApiModelProperty(value = "商家地址")
    private String address;
    @ApiModelProperty(value = "详细地址")
    private String detailAddress;
    @ApiModelProperty(value = "距离")
    private Double distance;
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml
@@ -3,7 +3,7 @@
<mapper namespace="com.ruoyi.other.mapper.GoodsMapper">
    <select id="selectListByShopId" resultType="com.ruoyi.other.vo.GoodsVO">
        SELECT
        SELECT distinct
        tg.id as goodsId,
        tg.`name` as goodsName,
        tg.purchase_limit as purchaseLimit,
@@ -16,7 +16,6 @@
        tg.sort
        FROM t_goods tg
        where tg.del_flag = 0 and tg.status = 2 and tg.id in (select goods_id from t_goods_shop where shop_id = #{shopId})
        and tg.type = 2
        ORDER BY ifnull(tg.sort, -1) DESC
    </select>
    <select id="selectManageGoodsList" resultType="com.ruoyi.other.api.domain.Goods">
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml
@@ -32,9 +32,6 @@
            ts.latitude,
            ts.status,
            ts.phone,
            ts.province,
            ts.city,
            ts.district,
            (select ROUND(AVG(score), 1) from t_shop_score where shop_id = ts.id) as score
        FROM
            t_shop ts