| | |
| | | * @param phone 手机号 |
| | | * @return 订单信息 |
| | | */ |
| | | @GetMapping(value = "/admin/order/queryList") |
| | | @GetMapping(value = "/order/queryList") |
| | | R<List<Order>> queryList(@RequestParam("phone") String phone); |
| | | |
| | | /** |
| | |
| | | * @param type 查询类型 |
| | | * @return 详细数据 |
| | | */ |
| | | @GetMapping(value = "/admin/agreement/dataInfo") |
| | | @GetMapping(value = "/agreement/dataInfo") |
| | | R<Agreement> dataInfo(@RequestParam("type") Integer type); |
| | | |
| | | /** |
| | |
| | | * @param changeDispatch 改派信息 |
| | | * @return 详细数据 |
| | | */ |
| | | @PostMapping(value = "/admin/changeDispatch/save") |
| | | @PostMapping(value = "/changeDispatch/save") |
| | | R<Boolean> changeDispatchSave(@RequestBody ExchangeDispatch changeDispatch); |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return 通知公告列表 |
| | | */ |
| | | @GetMapping(value = "/admin/notices/list") |
| | | @GetMapping(value = "/notices/list") |
| | | R<List<Notices>> noticesList(); |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return 轮播图列表 |
| | | */ |
| | | @GetMapping(value = "/admin/rotate/bannerList") |
| | | @GetMapping(value = "/rotate/bannerList") |
| | | R<List<Rotate>> bannerList(); |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return 服务优势列表 |
| | | */ |
| | | @GetMapping(value = "/admin/advantage/advantageList") |
| | | @GetMapping(value = "/advantage/advantageList") |
| | | R<List<ServeAdvantage>> advantageList(); |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return 列表 |
| | | */ |
| | | @GetMapping(value = "/admin/problem/problemList") |
| | | @GetMapping(value = "/problem/problemList") |
| | | R<List<Problem>> problemList(); |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return 奖品列表 |
| | | */ |
| | | @GetMapping(value = "/admin/prize/list") |
| | | @GetMapping(value = "/prize/prizeList") |
| | | R<List<Prize>> prizeList(); |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return 操作结果 |
| | | */ |
| | | @GetMapping(value = "/withdrawProcess") |
| | | @GetMapping(value = "/userManage/withdrawProcess") |
| | | R<WithdrawalSetting> withdrawProcess(); |
| | | |
| | | } |
| | |
| | | public static final String CAPTCHA_CODE_KEY = "captcha_codes:"; |
| | | |
| | | /** |
| | | * 参数管理 cache key |
| | | */ |
| | | public static final String SYS_CONFIG_KEY = "sys_config:"; |
| | | |
| | | /** |
| | | * 字典管理 cache key |
| | | */ |
| | | public static final String SYS_DICT_KEY = "sys_dict:"; |
| | | |
| | | /** |
| | | * 登录账户密码错误次数 redis key |
| | | */ |
| | | public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:"; |
| | | |
| | | /** |
| | | * 登录IP黑名单 cache key |
| | | */ |
| | | public static final String SYS_LOGIN_BLACKIPLIST = SYS_CONFIG_KEY + "sys.login.blackIPList"; |
| | | } |
| | |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.springframework.context.annotation.EnableAspectJAutoProxy; |
| | | import org.springframework.context.annotation.Import; |
| | |
| | | @EnableAsync |
| | | // 自动加载类 |
| | | @Import({ ApplicationConfig.class, FeignAutoConfiguration.class }) |
| | | public @interface EnableCustomConfig |
| | | { |
| | | public @interface EnableCustomConfig { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.common.security.annotation; |
| | | |
| | | import org.springframework.cloud.openfeign.EnableFeignClients; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | /** |
| | |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | @EnableFeignClients |
| | | public @interface EnableRyFeignClients |
| | | { |
| | | public @interface EnableRyFeignClients { |
| | | String[] value() default {}; |
| | | |
| | | String[] basePackages() default { "com.ruoyi" }; |
| | |
| | | * |
| | | * @return 用户信息 |
| | | */ |
| | | public LoginUser getLoginUserByUser() { |
| | | public LoginUserInfo getLoginUserByUser() { |
| | | return getLoginUserByUser(ServletUtils.getRequest()); |
| | | } |
| | | |
| | |
| | | * |
| | | * @return 用户信息 |
| | | */ |
| | | public LoginUser getLoginUserByUser(HttpServletRequest request) { |
| | | public LoginUserInfo getLoginUserByUser(HttpServletRequest request) { |
| | | // 获取请求携带的令牌 |
| | | String token = SecurityUtils.getToken(request); |
| | | return getLoginUserByUser(token); |
| | |
| | | * |
| | | * @return 用户信息 |
| | | */ |
| | | public LoginUser getLoginUserByUser(String token) { |
| | | LoginUser user = null; |
| | | public LoginUserInfo getLoginUserByUser(String token) { |
| | | LoginUserInfo user = null; |
| | | try { |
| | | if (StringUtils.isNotEmpty(token)) { |
| | | String userkey = JwtUtils.getUserKeyByUser(token); |
| | |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | import org.springframework.context.annotation.Import; |
| | | import com.ruoyi.common.swagger.config.SwaggerAutoConfiguration; |
| | | |
| | |
| | | @Documented |
| | | @Inherited |
| | | @Import({ SwaggerAutoConfiguration.class }) |
| | | public @interface EnableCustomSwagger2 |
| | | { |
| | | public @interface EnableCustomSwagger2 { |
| | | |
| | | } |
| | |
| | | |
| | | import com.ruoyi.common.core.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | |
| | | util.exportExcel(response, list, "参数数据"); |
| | | } |
| | | |
| | | /** |
| | | * 根据参数编号获取详细信息 |
| | | */ |
| | | @GetMapping(value = "/{configId}") |
| | | public AjaxResult getInfo(@PathVariable Long configId) { |
| | | return success(configService.selectConfigById(configId)); |
| | | } |
| | | |
| | | /** |
| | | * 根据参数键名查询参数值 |
| | | */ |
| | | @GetMapping(value = "/configKey/{configKey}") |
| | | public AjaxResult getConfigKey(@PathVariable String configKey) { |
| | | return success(configService.selectConfigByKey(configKey)); |
| | | } |
| | | |
| | | /** |
| | | * 新增参数配置 |
| | | */ |
| | | @RequiresPermissions("system:config:add") |
| | | @Log(title = "参数管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysConfig config) { |
| | | if (!configService.checkConfigKeyUnique(config)) { |
| | | return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); |
| | | } |
| | | config.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(configService.insertConfig(config)); |
| | | } |
| | | |
| | | /** |
| | | * 修改参数配置 |
| | | */ |
| | | @RequiresPermissions("system:config:edit") |
| | | @Log(title = "参数管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysConfig config) { |
| | | if (!configService.checkConfigKeyUnique(config)) { |
| | | return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); |
| | | } |
| | | config.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(configService.updateConfig(config)); |
| | | } |
| | | |
| | | /** |
| | | * 删除参数配置 |
| | | */ |
| | | @RequiresPermissions("system:config:remove") |
| | | @Log(title = "参数管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{configIds}") |
| | | public AjaxResult remove(@PathVariable Long[] configIds) { |
| | | configService.deleteConfigByIds(configIds); |
| | | return success(); |
| | | } |
| | | |
| | | /** |
| | | * 刷新参数缓存 |
| | | */ |
| | | @RequiresPermissions("system:config:remove") |
| | | @Log(title = "参数管理", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public AjaxResult refreshCache() { |
| | | configService.resetConfigCache(); |
| | | return success(); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.domain.SysDictData; |
| | | import com.ruoyi.system.service.ISysDictDataService; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | public AjaxResult dictType(@PathVariable String dictType) { |
| | | List<SysDictData> data = dictTypeService.selectDictDataByType(dictType); |
| | | if (StringUtils.isNull(data)) { |
| | | data = new ArrayList<SysDictData>(); |
| | | data = new ArrayList<>(); |
| | | } |
| | | return success(data); |
| | | } |
| | | |
| | | /** |
| | | * 新增字典类型 |
| | | */ |
| | | @RequiresPermissions("system:dict:add") |
| | | @Log(title = "字典数据", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDictData dict) { |
| | | dict.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(dictDataService.insertDictData(dict)); |
| | | } |
| | | |
| | | /** |
| | | * 修改保存字典类型 |
| | | */ |
| | | @RequiresPermissions("system:dict:edit") |
| | | @Log(title = "字典数据", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDictData dict) { |
| | | dict.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(dictDataService.updateDictData(dict)); |
| | | } |
| | | |
| | | /** |
| | | * 删除字典类型 |
| | | */ |
| | | @RequiresPermissions("system:dict:remove") |
| | | @Log(title = "字典类型", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictCodes}") |
| | | public AjaxResult remove(@PathVariable Long[] dictCodes) { |
| | | dictDataService.deleteDictDataByIds(dictCodes); |
| | | return success(); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.domain.SysDictType; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | return success(dictTypeService.selectDictTypeById(dictId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增字典类型 |
| | | */ |
| | | @RequiresPermissions("system:dict:add") |
| | | @Log(title = "字典类型", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDictType dict) { |
| | | if (!dictTypeService.checkDictTypeUnique(dict)) { |
| | | return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); |
| | | } |
| | | dict.setCreateBy(SecurityUtils.getUsername()); |
| | | return toAjax(dictTypeService.insertDictType(dict)); |
| | | } |
| | | |
| | | /** |
| | | * 修改字典类型 |
| | | */ |
| | | @RequiresPermissions("system:dict:edit") |
| | | @Log(title = "字典类型", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDictType dict) { |
| | | if (!dictTypeService.checkDictTypeUnique(dict)) { |
| | | return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); |
| | | } |
| | | dict.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(dictTypeService.updateDictType(dict)); |
| | | } |
| | | |
| | | /** |
| | | * 删除字典类型 |
| | | */ |
| | | @RequiresPermissions("system:dict:remove") |
| | | @Log(title = "字典类型", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictIds}") |
| | | public AjaxResult remove(@PathVariable Long[] dictIds) { |
| | | dictTypeService.deleteDictTypeByIds(dictIds); |
| | | return success(); |
| | | } |
| | | |
| | | /** |
| | | * 刷新字典缓存 |
| | | */ |
| | | @RequiresPermissions("system:dict:remove") |
| | | @Log(title = "字典类型", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public AjaxResult refreshCache() { |
| | | dictTypeService.resetDictCache(); |
| | | return success(); |
| | | } |
| | | |
| | | /** |
| | | * 获取字典选择框列表 |
| | | */ |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult optionselect() { |
| | | List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll(); |
| | | return success(dictTypes); |
| | | } |
| | | } |
| | |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | |
| | | util.exportExcel(response, list, "用户数据"); |
| | | } |
| | | |
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT) |
| | | @RequiresPermissions("system:user:import") |
| | | @PostMapping("/importData") |
| | | public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { |
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | List<SysUser> userList = util.importExcel(file.getInputStream()); |
| | | String operName = SecurityUtils.getUsername(); |
| | | String message = userService.importUser(userList, updateSupport, operName); |
| | | return success(message); |
| | | } |
| | | |
| | | @PostMapping("/importTemplate") |
| | | public void importTemplate(HttpServletResponse response) { |
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | |
| | | sysUserVo.setRole(roles); |
| | | sysUserVo.setPermissions(permissions); |
| | | return R.ok(sysUserVo); |
| | | } |
| | | |
| | | /** |
| | | * 注册用户信息 |
| | | */ |
| | | @InnerAuth |
| | | @PostMapping("/register") |
| | | public R<Boolean> register(@RequestBody SysUser sysUser) { |
| | | String username = sysUser.getNickName(); |
| | | if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) { |
| | | return R.fail("当前系统没有开启注册功能!"); |
| | | } |
| | | if (!userService.checkUserNameUnique(sysUser)) { |
| | | return R.fail("保存用户'" + username + "'失败,注册账号已存在"); |
| | | } |
| | | return R.ok(userService.registerUser(sysUser)); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.ruoyi.system.api.domain.SysDictData; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典表 数据层 |
| | |
| | | * @return 字典数据集合信息 |
| | | */ |
| | | public List<SysDictData> selectDictDataList(SysDictData dictData); |
| | | |
| | | /** |
| | | * 根据字典类型查询字典数据 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 字典数据集合信息 |
| | | */ |
| | | public List<SysDictData> selectDictDataByType(String dictType); |
| | | |
| | | /** |
| | | * 根据字典类型和字典键值查询字典数据信息 |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 参数配置 服务层 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysConfigService |
| | | { |
| | | /** |
| | | * 查询参数配置信息 |
| | | * |
| | | * @param configId 参数配置ID |
| | | * @return 参数配置信息 |
| | | */ |
| | | public SysConfig selectConfigById(Long configId); |
| | | |
| | | /** |
| | | * 根据键名查询参数配置信息 |
| | | * |
| | | * @param configKey 参数键名 |
| | | * @return 参数键值 |
| | | */ |
| | | public String selectConfigByKey(String configKey); |
| | | |
| | | public interface ISysConfigService { |
| | | /** |
| | | * 查询参数配置列表 |
| | | * |
| | |
| | | */ |
| | | public List<SysConfig> selectConfigList(SysConfig config); |
| | | |
| | | /** |
| | | * 新增参数配置 |
| | | * |
| | | * @param config 参数配置信息 |
| | | * @return 结果 |
| | | */ |
| | | public int insertConfig(SysConfig config); |
| | | |
| | | /** |
| | | * 修改参数配置 |
| | | * |
| | | * @param config 参数配置信息 |
| | | * @return 结果 |
| | | */ |
| | | public int updateConfig(SysConfig config); |
| | | |
| | | /** |
| | | * 批量删除参数信息 |
| | | * |
| | | * @param configIds 需要删除的参数ID |
| | | */ |
| | | public void deleteConfigByIds(Long[] configIds); |
| | | |
| | | /** |
| | | * 加载参数缓存数据 |
| | | */ |
| | | public void loadingConfigCache(); |
| | | |
| | | /** |
| | | * 清空参数缓存数据 |
| | | */ |
| | | public void clearConfigCache(); |
| | | |
| | | /** |
| | | * 重置参数缓存数据 |
| | | */ |
| | | public void resetConfigCache(); |
| | | |
| | | /** |
| | | * 校验参数键名是否唯一 |
| | | * |
| | | * @param config 参数信息 |
| | | * @return 结果 |
| | | */ |
| | | public boolean checkConfigKeyUnique(SysConfig config); |
| | | } |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.api.domain.SysDictData; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典 业务层 |
| | |
| | | public List<SysDictData> selectDictDataList(SysDictData dictData); |
| | | |
| | | /** |
| | | * 根据字典类型和字典键值查询字典数据信息 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @param dictValue 字典键值 |
| | | * @return 字典标签 |
| | | */ |
| | | public String selectDictLabel(String dictType, String dictValue); |
| | | |
| | | /** |
| | | * 根据字典数据ID查询信息 |
| | | * |
| | | * @param dictCode 字典数据ID |
| | |
| | | */ |
| | | public SysDictData selectDictDataById(Long dictCode); |
| | | |
| | | /** |
| | | * 批量删除字典数据信息 |
| | | * |
| | | * @param dictCodes 需要删除的字典数据ID |
| | | */ |
| | | public void deleteDictDataByIds(Long[] dictCodes); |
| | | |
| | | /** |
| | | * 新增保存字典数据信息 |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.api.domain.SysDictData; |
| | | import com.ruoyi.system.api.domain.SysDictType; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典 业务层 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysDictTypeService |
| | | { |
| | | public interface ISysDictTypeService { |
| | | /** |
| | | * 根据条件分页查询字典类型 |
| | | * |
| | |
| | | * @return 字典类型集合信息 |
| | | */ |
| | | public List<SysDictType> selectDictTypeList(SysDictType dictType); |
| | | |
| | | /** |
| | | * 根据所有字典类型 |
| | | * |
| | | * @return 字典类型集合信息 |
| | | */ |
| | | public List<SysDictType> selectDictTypeAll(); |
| | | |
| | | /** |
| | | * 根据字典类型查询字典数据 |
| | |
| | | */ |
| | | public SysDictType selectDictTypeById(Long dictId); |
| | | |
| | | /** |
| | | * 根据字典类型查询信息 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 字典类型 |
| | | */ |
| | | public SysDictType selectDictTypeByType(String dictType); |
| | | |
| | | /** |
| | | * 批量删除字典信息 |
| | | * |
| | | * @param dictIds 需要删除的字典ID |
| | | */ |
| | | public void deleteDictTypeByIds(Long[] dictIds); |
| | | |
| | | /** |
| | | * 加载字典缓存数据 |
| | | */ |
| | | public void loadingDictCache(); |
| | | |
| | | /** |
| | | * 清空字典缓存数据 |
| | | */ |
| | | public void clearDictCache(); |
| | | |
| | | /** |
| | | * 重置字典缓存数据 |
| | | */ |
| | | public void resetDictCache(); |
| | | |
| | | /** |
| | | * 新增保存字典类型信息 |
| | | * |
| | | * @param dictType 字典类型信息 |
| | | * @return 结果 |
| | | */ |
| | | public int insertDictType(SysDictType dictType); |
| | | |
| | | /** |
| | | * 修改保存字典类型信息 |
| | | * |
| | | * @param dictType 字典类型信息 |
| | | * @return 结果 |
| | | */ |
| | | public int updateDictType(SysDictType dictType); |
| | | |
| | | /** |
| | | * 校验字典类型称是否唯一 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 结果 |
| | | */ |
| | | public boolean checkDictTypeUnique(SysDictType dictType); |
| | | } |
| | |
| | | public int deleteUserByIds(Long[] userIds); |
| | | |
| | | /** |
| | | * 导入用户数据 |
| | | * |
| | | * @param userList 用户数据列表 |
| | | * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 |
| | | * @param operName 操作用户 |
| | | * @return 结果 |
| | | */ |
| | | public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName); |
| | | |
| | | /** |
| | | * 后台账号管理分页查询 |
| | | * |
| | | * @param nickName 账号名称 |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private SysConfigMapper configMapper; |
| | | |
| | | @Autowired |
| | | private RedisService redisService; |
| | | |
| | | /** |
| | | * 项目启动时,初始化参数到缓存 |
| | | */ |
| | | @PostConstruct |
| | | public void init() { |
| | | loadingConfigCache(); |
| | | } |
| | | |
| | | /** |
| | | * 查询参数配置信息 |
| | | * |
| | | * @param configId 参数配置ID |
| | | * @return 参数配置信息 |
| | | */ |
| | | @Override |
| | | public SysConfig selectConfigById(Long configId) { |
| | | SysConfig config = new SysConfig(); |
| | | config.setConfigId(configId); |
| | | return configMapper.selectConfig(config); |
| | | } |
| | | |
| | | /** |
| | | * 根据键名查询参数配置信息 |
| | | * |
| | | * @param configKey 参数key |
| | | * @return 参数键值 |
| | | */ |
| | | @Override |
| | | public String selectConfigByKey(String configKey) { |
| | | String configValue = Convert.toStr(redisService.getCacheObject(getCacheKey(configKey))); |
| | | if (StringUtils.isNotEmpty(configValue)) { |
| | | return configValue; |
| | | } |
| | | SysConfig config = new SysConfig(); |
| | | config.setConfigKey(configKey); |
| | | SysConfig retConfig = configMapper.selectConfig(config); |
| | | if (StringUtils.isNotNull(retConfig)) { |
| | | redisService.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); |
| | | return retConfig.getConfigValue(); |
| | | } |
| | | return StringUtils.EMPTY; |
| | | } |
| | | |
| | | /** |
| | | * 查询参数配置列表 |
| | | * |
| | |
| | | return configMapper.selectConfigList(config); |
| | | } |
| | | |
| | | /** |
| | | * 新增参数配置 |
| | | * |
| | | * @param config 参数配置信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertConfig(SysConfig config) { |
| | | int row = configMapper.insertConfig(config); |
| | | if (row > 0) { |
| | | redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | /** |
| | | * 修改参数配置 |
| | | * |
| | | * @param config 参数配置信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateConfig(SysConfig config) { |
| | | SysConfig temp = configMapper.selectConfigById(config.getConfigId()); |
| | | if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey())) { |
| | | redisService.deleteObject(getCacheKey(temp.getConfigKey())); |
| | | } |
| | | |
| | | int row = configMapper.updateConfig(config); |
| | | if (row > 0) { |
| | | redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | /** |
| | | * 批量删除参数信息 |
| | | * |
| | | * @param configIds 需要删除的参数ID |
| | | */ |
| | | @Override |
| | | public void deleteConfigByIds(Long[] configIds) { |
| | | for (Long configId : configIds) { |
| | | SysConfig config = selectConfigById(configId); |
| | | if (StringUtils.equals(UserConstants.YES, config.getConfigType())) { |
| | | throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey())); |
| | | } |
| | | configMapper.deleteConfigById(configId); |
| | | redisService.deleteObject(getCacheKey(config.getConfigKey())); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 加载参数缓存数据 |
| | | */ |
| | | @Override |
| | | public void loadingConfigCache() { |
| | | List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig()); |
| | | for (SysConfig config : configsList) { |
| | | redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 清空参数缓存数据 |
| | | */ |
| | | @Override |
| | | public void clearConfigCache() { |
| | | Collection<String> keys = redisService.keys(CacheConstants.SYS_CONFIG_KEY + "*"); |
| | | redisService.deleteObject(keys); |
| | | } |
| | | |
| | | /** |
| | | * 重置参数缓存数据 |
| | | */ |
| | | @Override |
| | | public void resetConfigCache() { |
| | | clearConfigCache(); |
| | | loadingConfigCache(); |
| | | } |
| | | |
| | | /** |
| | | * 校验参数键名是否唯一 |
| | | * |
| | | * @param config 参数配置信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean checkConfigKeyUnique(SysConfig config) { |
| | | Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId(); |
| | | SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey()); |
| | | if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | | } |
| | | |
| | | /** |
| | | * 设置cache key |
| | | * |
| | | * @param configKey 参数键 |
| | | * @return 缓存键key |
| | | */ |
| | | private String getCacheKey(String configKey) { |
| | | return CacheConstants.SYS_CONFIG_KEY + configKey; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.common.security.utils.DictUtils; |
| | | import com.ruoyi.system.api.domain.SysDictData; |
| | | import com.ruoyi.system.mapper.SysDictDataMapper; |
| | | import com.ruoyi.system.service.ISysDictDataService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 字典 业务层处理 |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysDictDataServiceImpl implements ISysDictDataService |
| | | { |
| | | public class SysDictDataServiceImpl implements ISysDictDataService { |
| | | @Autowired |
| | | private SysDictDataMapper dictDataMapper; |
| | | |
| | |
| | | * @return 字典数据集合信息 |
| | | */ |
| | | @Override |
| | | public List<SysDictData> selectDictDataList(SysDictData dictData) |
| | | { |
| | | public List<SysDictData> selectDictDataList(SysDictData dictData) { |
| | | return dictDataMapper.selectDictDataList(dictData); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型和字典键值查询字典数据信息 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @param dictValue 字典键值 |
| | | * @return 字典标签 |
| | | */ |
| | | @Override |
| | | public String selectDictLabel(String dictType, String dictValue) |
| | | { |
| | | return dictDataMapper.selectDictLabel(dictType, dictValue); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return 字典数据 |
| | | */ |
| | | @Override |
| | | public SysDictData selectDictDataById(Long dictCode) |
| | | { |
| | | public SysDictData selectDictDataById(Long dictCode) { |
| | | return dictDataMapper.selectDictDataById(dictCode); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除字典数据信息 |
| | | * |
| | | * @param dictCodes 需要删除的字典数据ID |
| | | */ |
| | | @Override |
| | | public void deleteDictDataByIds(Long[] dictCodes) |
| | | { |
| | | for (Long dictCode : dictCodes) |
| | | { |
| | | SysDictData data = selectDictDataById(dictCode); |
| | | dictDataMapper.deleteDictDataById(dictCode); |
| | | List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); |
| | | DictUtils.setDictCache(data.getDictType(), dictDatas); |
| | | } |
| | | public int insertDictData(SysDictData dictData) { |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * 新增保存字典数据信息 |
| | | * |
| | | * @param data 字典数据信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertDictData(SysDictData data) |
| | | { |
| | | int row = dictDataMapper.insertDictData(data); |
| | | if (row > 0) |
| | | { |
| | | List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); |
| | | DictUtils.setDictCache(data.getDictType(), dictDatas); |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | /** |
| | | * 修改保存字典数据信息 |
| | | * |
| | | * @param data 字典数据信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateDictData(SysDictData data) |
| | | { |
| | | int row = dictDataMapper.updateDictData(data); |
| | | if (row > 0) |
| | | { |
| | | List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); |
| | | DictUtils.setDictCache(data.getDictType(), dictDatas); |
| | | } |
| | | return row; |
| | | public int updateDictData(SysDictData dictData) { |
| | | return 0; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.security.utils.DictUtils; |
| | | import com.ruoyi.system.api.domain.SysDictData; |
| | | import com.ruoyi.system.api.domain.SysDictType; |
| | | import com.ruoyi.system.mapper.SysDictDataMapper; |
| | | import com.ruoyi.system.mapper.SysDictTypeMapper; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 字典 业务层处理 |
| | |
| | | public class SysDictTypeServiceImpl implements ISysDictTypeService { |
| | | @Autowired |
| | | private SysDictTypeMapper dictTypeMapper; |
| | | |
| | | @Autowired |
| | | private SysDictDataMapper dictDataMapper; |
| | | |
| | | /** |
| | | * 项目启动时,初始化字典到缓存 |
| | |
| | | return dictTypeMapper.selectDictTypeList(dictType); |
| | | } |
| | | |
| | | /** |
| | | * 根据所有字典类型 |
| | | * |
| | | * @return 字典类型集合信息 |
| | | */ |
| | | @Override |
| | | public List<SysDictType> selectDictTypeAll() { |
| | | return dictTypeMapper.selectDictTypeAll(); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型查询字典数据 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 字典数据集合信息 |
| | | */ |
| | | @Override |
| | | public List<SysDictData> selectDictDataByType(String dictType) { |
| | | List<SysDictData> dictDatas = DictUtils.getDictCache(dictType); |
| | | if (StringUtils.isNotEmpty(dictDatas)) { |
| | | return dictDatas; |
| | | } |
| | | dictDatas = dictDataMapper.selectDictDataByType(dictType); |
| | | if (StringUtils.isNotEmpty(dictDatas)) { |
| | | DictUtils.setDictCache(dictType, dictDatas); |
| | | return dictDatas; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据字典类型ID查询信息 |
| | |
| | | return dictTypeMapper.selectDictTypeById(dictId); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型查询信息 |
| | | * |
| | | * @param dictType 字典类型 |
| | | * @return 字典类型 |
| | | */ |
| | | @Override |
| | | public SysDictType selectDictTypeByType(String dictType) { |
| | | return dictTypeMapper.selectDictTypeByType(dictType); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除字典类型信息 |
| | | * |
| | | * @param dictIds 需要删除的字典ID |
| | | */ |
| | | @Override |
| | | public void deleteDictTypeByIds(Long[] dictIds) { |
| | | for (Long dictId : dictIds) { |
| | | SysDictType dictType = selectDictTypeById(dictId); |
| | | if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) { |
| | | throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName())); |
| | | } |
| | | dictTypeMapper.deleteDictTypeById(dictId); |
| | | DictUtils.removeDictCache(dictType.getDictType()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 加载字典缓存数据 |
| | | */ |
| | | @Override |
| | | public void loadingDictCache() { |
| | | SysDictData dictData = new SysDictData(); |
| | | dictData.setStatus("0"); |
| | | Map<String, List<SysDictData>> dictDataMap = dictDataMapper.selectDictDataList(dictData).stream().collect(Collectors.groupingBy(SysDictData::getDictType)); |
| | | for (Map.Entry<String, List<SysDictData>> entry : dictDataMap.entrySet()) { |
| | | DictUtils.setDictCache(entry.getKey(), entry.getValue().stream().sorted(Comparator.comparing(SysDictData::getDictSort)).collect(Collectors.toList())); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 清空字典缓存数据 |
| | | */ |
| | | @Override |
| | | public void clearDictCache() { |
| | | DictUtils.clearDictCache(); |
| | | } |
| | | |
| | | /** |
| | | * 重置字典缓存数据 |
| | | */ |
| | | @Override |
| | | public void resetDictCache() { |
| | | clearDictCache(); |
| | | loadingDictCache(); |
| | | } |
| | | |
| | | /** |
| | | * 新增保存字典类型信息 |
| | | * |
| | | * @param dict 字典类型信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertDictType(SysDictType dict) { |
| | | int row = dictTypeMapper.insertDictType(dict); |
| | | if (row > 0) { |
| | | DictUtils.setDictCache(dict.getDictType(), null); |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | /** |
| | | * 修改保存字典类型信息 |
| | | * |
| | | * @param dict 字典类型信息 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int updateDictType(SysDictType dict) { |
| | | SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId()); |
| | | dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType()); |
| | | int row = dictTypeMapper.updateDictType(dict); |
| | | if (row > 0) { |
| | | List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType()); |
| | | DictUtils.setDictCache(dict.getDictType(), dictDatas); |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | /** |
| | | * 校验字典类型称是否唯一 |
| | | * |
| | | * @param dict 字典类型 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean checkDictTypeUnique(SysDictType dict) { |
| | | Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); |
| | | SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType()); |
| | | if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.SpringUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.bean.BeanValidators; |
| | | import com.ruoyi.common.datascope.annotation.DataScope; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.domain.SysRole; |
| | |
| | | // 删除用户与岗位关联 |
| | | userPostMapper.deleteUserPost(userIds); |
| | | return userMapper.deleteUserByIds(userIds); |
| | | } |
| | | |
| | | /** |
| | | * 导入用户数据 |
| | | * |
| | | * @param userList 用户数据列表 |
| | | * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 |
| | | * @param operName 操作用户 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) { |
| | | if (StringUtils.isNull(userList) || userList.size() == 0) { |
| | | throw new ServiceException("导入用户数据不能为空!"); |
| | | } |
| | | int successNum = 0; |
| | | int failureNum = 0; |
| | | StringBuilder successMsg = new StringBuilder(); |
| | | StringBuilder failureMsg = new StringBuilder(); |
| | | String password = configService.selectConfigByKey("sys.user.initPassword"); |
| | | for (SysUser user : userList) { |
| | | try { |
| | | // 验证是否存在这个用户 |
| | | SysUser u = userMapper.selectUserByUserName(user.getNickName()); |
| | | if (StringUtils.isNull(u)) { |
| | | BeanValidators.validateWithException(validator, user); |
| | | user.setPassword(SecurityUtils.encryptPassword(password)); |
| | | user.setCreateBy(operName); |
| | | userMapper.insertUser(user); |
| | | successNum++; |
| | | successMsg.append("<br/>" + successNum + "、账号 " + user.getNickName() + " 导入成功"); |
| | | } else if (isUpdateSupport) { |
| | | BeanValidators.validateWithException(validator, user); |
| | | checkUserAllowed(u); |
| | | checkUserDataScope(u.getUserId()); |
| | | user.setUserId(u.getUserId()); |
| | | user.setUpdateBy(operName); |
| | | userMapper.updateUser(user); |
| | | successNum++; |
| | | successMsg.append("<br/>" + successNum + "、账号 " + user.getNickName() + " 更新成功"); |
| | | } else { |
| | | failureNum++; |
| | | failureMsg.append("<br/>" + failureNum + "、账号 " + user.getNickName() + " 已存在"); |
| | | } |
| | | } catch (Exception e) { |
| | | failureNum++; |
| | | String msg = "<br/>" + failureNum + "、账号 " + user.getNickName() + " 导入失败:"; |
| | | failureMsg.append(msg + e.getMessage()); |
| | | log.error(msg, e); |
| | | } |
| | | } |
| | | if (failureNum > 0) { |
| | | failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); |
| | | throw new ServiceException(failureMsg.toString()); |
| | | } else { |
| | | successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); |
| | | } |
| | | return successMsg.toString(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | order by dict_sort asc |
| | | </select> |
| | | |
| | | <select id="selectDictDataByType" parameterType="com.ruoyi.system.api.domain.SysDictData" resultMap="SysDictDataResult"> |
| | | <include refid="selectDictDataVo"/> |
| | | where status = '0' and dict_type = #{dictType} order by dict_sort asc |
| | | </select> |
| | | |
| | | <select id="selectDictLabel" resultType="String"> |
| | | select dict_label from sys_dict_data |
| | | where dict_type = #{dictType} and dict_value = #{dictValue} |
| | |
| | | @TableField("complete_time") |
| | | private Date completeTime; |
| | | |
| | | @ApiModelProperty("订单补贴金额") |
| | | @TableField("subsidy") |
| | | private BigDecimal subsidy; |
| | | |
| | | @ApiModelProperty("是否已提现(0:未提现,1:已提现)") |
| | | @TableField("is_withdrawal") |
| | | private Integer isWithdrawal; |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.api.model.LoginUserInfo; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void insertFill(MetaObject metaObject) { |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | String userName = null == loginUser ? "" : loginUser.getUsername(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | String userName = null == loginUser ? "" : loginUser.getName(); |
| | | // 创建时间 |
| | | this.setFieldValByName("createTime", new Date(), metaObject); |
| | | // 更新时间 |
| | |
| | | |
| | | @Override |
| | | public void updateFill(MetaObject metaObject) { |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | String userName = null == loginUser ? "" : loginUser.getUsername(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | String userName = null == loginUser ? "" : loginUser.getName(); |
| | | // 修改时间为当前时间 |
| | | this.setFieldValByName("updateTime", new Date(), metaObject); |
| | | this.setFieldValByName("updateBy", userName, metaObject); |
| | |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.api.model.LoginUserInfo; |
| | | import com.ruoyi.user.entity.Evaluate; |
| | | import com.ruoyi.user.entity.Order; |
| | | import com.ruoyi.user.request.OrderEvaluateRequest; |
| | |
| | | @GetMapping("/orderEvaluate") |
| | | @ApiOperation(value = "订单评价列表", tags = {"用户端-个人中心"}) |
| | | public R<List<OrderEvaluateVO>> orderEvaluate() { |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | |
| | | String content = orderEvaluate.getContent(); |
| | | BigDecimal starRating = orderEvaluate.getStarRating(); |
| | | String serveNo = orderEvaluate.getServeNo(); |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | |
| | | throw new GlobalException("订单异常!"); |
| | | } |
| | | Evaluate evaluate = new Evaluate(); |
| | | evaluate.setUserId(loginUser.getUserid().intValue()); |
| | | evaluate.setUserId(loginUser.getUserid()); |
| | | evaluate.setOrderId(orderId); |
| | | evaluate.setContent(content); |
| | | evaluate.setWorkerId(order.getServerId()); |
| | |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.api.model.LoginUserInfo; |
| | | import com.ruoyi.user.entity.Order; |
| | | import com.ruoyi.user.entity.ServeRecord; |
| | | import com.ruoyi.user.request.OrderRequest; |
| | |
| | | private ServeRecordService serveRecordService; |
| | | @Resource |
| | | private AdminClient adminClient; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | @GetMapping("/detail") |
| | | @ApiOperation(value = "订单详情", tags = {"用户端-订单"}) |
| | |
| | | } |
| | | |
| | | @PostMapping("/placeOrder") |
| | | @ApiOperation(value = "下单", tags = {"用户端-订单"}) |
| | | @ApiOperation(value = "用户下单", tags = {"用户端-订单"}) |
| | | public R<String> placeOrder(@RequestBody OrderRequest orderRequest) { |
| | | return R.ok(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | Boolean result = orderService.placeOrder(orderRequest, loginUser.getUserid()); |
| | | return result ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | }) |
| | | public R<RecoveryServe> serveDetail(@RequestParam Integer serveId) { |
| | | return R.ok(recoveryServeService.lambdaQuery().eq(RecoveryServe::getId, serveId) |
| | | .eq(RecoveryServe::getIsDelete, 0).orderByAsc(RecoveryServe::getOrder).one()); |
| | | .eq(RecoveryServe::getIsDelete, 0).orderByAsc(RecoveryServe::getSort).one()); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.api.model.LoginUserInfo; |
| | | import com.ruoyi.user.entity.UserCollect; |
| | | import com.ruoyi.user.service.UserCollectService; |
| | | import com.ruoyi.user.vo.UserCollectVO; |
| | |
| | | @ApiImplicitParam(value = "服务id", name = "serveId", dataType = "Integer", required = true) |
| | | }) |
| | | public R<Boolean> serveDetail(@RequestParam Integer serveId) { |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | UserCollect userCollect = new UserCollect(loginUser.getUserid().intValue(), serveId); |
| | | UserCollect userCollect = new UserCollect(loginUser.getUserid(), serveId); |
| | | return R.ok(userCollectService.save(userCollect)); |
| | | } |
| | | |
| | |
| | | @ApiImplicitParam(value = "收藏记录id", name = "collectId", dataType = "Integer", required = true) |
| | | }) |
| | | public R<Boolean> cancelCollect(@RequestParam Integer collectId) { |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | |
| | | @GetMapping(value = "/collectList") |
| | | @ApiOperation(value = "服务收藏列表", tags = {"用户端-收藏"}) |
| | | public R<List<UserCollectVO>> collectList() { |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.api.model.LoginUserInfo; |
| | | import com.ruoyi.user.entity.RecoveryClassify; |
| | | import com.ruoyi.user.entity.RecoveryServe; |
| | |
| | | public R<Object> phoneCodeLogin(@RequestBody @Validated LoginPhoneRequest loginPhoneRequest) { |
| | | String phone = loginPhoneRequest.getPhone(); |
| | | String phoneCode = loginPhoneRequest.getPhoneCode(); |
| | | // 默认验证码 123456 |
| | | if (!"123456".equals(phoneCode)) { |
| | | // 手机验证码校验获取缓存验证码 |
| | | Object phoneCodeRedis = redisService.getCacheObject(RedisConstants.USER_LOGIN_PHONE_CODE + phone); |
| | | if (null == phoneCodeRedis) { |
| | |
| | | String rCode = rCodeAndTime.split(":")[0]; |
| | | if (!rCode.equalsIgnoreCase(phoneCode)) { |
| | | return R.errorCode("登录失败,验证码无效!"); |
| | | } |
| | | } |
| | | } |
| | | // 用户账号校验 |
| | |
| | | // 随机编号 |
| | | user.setUserNo(String.format(Constants.USER_NO_PRE, RandomUtil.randomNumbers(Constants.EIGHT))); |
| | | user.setState(Constants.ONE); |
| | | user.setNickname(phone); |
| | | user.setPhone(phone); |
| | | user.setCity(loginPhoneRequest.getCity()); |
| | | user.setOpenId(loginPhoneRequest.getOpenId()); |
| | |
| | | } |
| | | // 校验通过,生成token及过期时间 |
| | | LoginUserInfo loginUserInfo = new LoginUserInfo(); |
| | | loginUserInfo.setName(user.getNickname()); |
| | | loginUserInfo.setName(user.getPhone()); |
| | | loginUserInfo.setUserid(user.getId()); |
| | | loginUserInfo.setPhone(user.getPhone()); |
| | | loginUserInfo.setLoginTime(System.currentTimeMillis()); |
| | |
| | | public R<List<RecoveryServe>> recoverySearch(@RequestParam String keyword) { |
| | | LambdaQueryChainWrapper<RecoveryServe> wrapper = recoveryServeService.lambdaQuery() |
| | | .eq(RecoveryServe::getIsDelete, 0) |
| | | .orderByAsc(RecoveryServe::getOrder); |
| | | .orderByAsc(RecoveryServe::getSort); |
| | | wrapper = StringUtils.isNotBlank(keyword) ? wrapper.like(RecoveryServe::getServeName, keyword) : wrapper; |
| | | return R.ok(wrapper.list()); |
| | | } |
| | |
| | | @ApiOperation(value = "个人中心用户信息", tags = {"用户端-个人中心"}) |
| | | @GetMapping(value = "/userInfo") |
| | | public R<User> userInfo() { |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.api.model.LoginUserInfo; |
| | | import com.ruoyi.user.entity.UserRecipient; |
| | | import com.ruoyi.user.service.UserRecipientService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | @GetMapping(value = "/list") |
| | | @ApiOperation(value = "收货地址列表", tags = {"用户端-收货地址管理"}) |
| | | public R<List<UserRecipient>> list() { |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | |
| | | @ApiOperation(value = "新增收货地址", tags = {"用户端-收货地址管理"}) |
| | | @PostMapping(value = "/save") |
| | | public R<String> save(@RequestBody UserRecipient userRecipient) { |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | userRecipient.setUserId(loginUser.getUserid().intValue()); |
| | | return recipientService.save(userRecipient) ? R.ok() : R.fail(); |
| | | userRecipient.setUserId(loginUser.getUserid()); |
| | | // 当前新增收货地址为默认地址时 |
| | | boolean result = recipientService.updateBatchAddress(userRecipient, loginUser.getUserid()); |
| | | return result && recipientService.save(userRecipient) ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation(value = "修改收货地址", tags = {"用户端-收货地址管理"}) |
| | | @PostMapping(value = "/update") |
| | | public R<String> update(@RequestBody UserRecipient userRecipient) { |
| | | return recipientService.updateById(userRecipient) ? R.ok() : R.fail(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | // 当前修改收货地址为默认地址时 |
| | | boolean result = recipientService.updateBatchAddress(userRecipient, loginUser.getUserid()); |
| | | return result && recipientService.updateById(userRecipient) ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParam(value = "收货地址id", name = "id", dataType = "String", required = true) |
| | | }) |
| | | public R<String> batchDelete(@RequestParam Integer id) { |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | return recipientService.lambdaUpdate().set(UserRecipient::getIsDelete, Constants.ONE) |
| | | .eq(UserRecipient::getId, id).update() ? R.ok() : R.fail(); |
| | | } |
| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.api.model.LoginUserInfo; |
| | | import com.ruoyi.user.entity.Withdraw; |
| | | import com.ruoyi.user.service.WithdrawService; |
| | | import com.ruoyi.user.vo.WithdrawListVO; |
| | |
| | | @GetMapping("/withdrawList") |
| | | @ApiOperation(value = "提现列表", tags = {"用户端-个人中心"}) |
| | | public R<WithdrawListVO> withdrawList() { |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "Integer", required = true) |
| | | }) |
| | | public R<Boolean> confirmWithdraw(@RequestParam Integer orderId) { |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | |
| | | @GetMapping("/withdrawRecord") |
| | | @ApiOperation(value = "提现记录", tags = {"用户端-个人中心"}) |
| | | public R<List<Withdraw>> withdrawRecord() { |
| | | LoginUser loginUser = tokenService.getLoginUserByUser(); |
| | | LoginUserInfo loginUser = tokenService.getLoginUserByUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | |
| | | private BigDecimal defaultPrice; |
| | | |
| | | @ApiModelProperty("排序权重") |
| | | @TableField("order") |
| | | private Integer order; |
| | | @TableField("sort") |
| | | private Integer sort; |
| | | |
| | | @ApiModelProperty("封面图片") |
| | | @TableField("cover") |
| | |
| | | * @param userId 用户id |
| | | * @return 列表数据 |
| | | */ |
| | | List<OrderEvaluateVO> orderEvaluate(Long userId); |
| | | List<OrderEvaluateVO> orderEvaluate(Integer userId); |
| | | } |
| | |
| | | * @param userid 用户id |
| | | * @return 服务列表 |
| | | */ |
| | | List<UserCollectVO> collectList(Long userid); |
| | | List<UserCollectVO> collectList(Integer userid); |
| | | } |
| | |
| | | @ApiModelProperty("回收服务id") |
| | | private Integer serveId; |
| | | |
| | | @ApiModelProperty("下单用户id") |
| | | private Integer userId; |
| | | |
| | | @ApiModelProperty("预约姓名") |
| | | private String reservationName; |
| | | |
| | | @ApiModelProperty("预约手机号") |
| | | private String reservationPhone; |
| | | |
| | | @ApiModelProperty("预约地址") |
| | | @ApiModelProperty("预约地址(收货地址id)") |
| | | private Integer addressId; |
| | | |
| | | @ApiModelProperty("上门时间") |
| | |
| | | @ApiModelProperty("下单用户纬度") |
| | | private Double latitude; |
| | | |
| | | @ApiModelProperty("订单补贴金额") |
| | | @ApiModelProperty("订单津贴金额") |
| | | private BigDecimal subsidy; |
| | | |
| | | @ApiModelProperty("详细地址") |
| | | private String address; |
| | | |
| | | } |
| | |
| | | * @param userId 用户id |
| | | * @return 列表数据 |
| | | */ |
| | | List<OrderEvaluateVO> orderEvaluate(Long userId); |
| | | List<OrderEvaluateVO> orderEvaluate(Integer userId); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.admin.api.entity.Prize; |
| | | import com.ruoyi.user.entity.Order; |
| | | import com.ruoyi.user.request.OrderRequest; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * @return 奖品列表 |
| | | */ |
| | | Object obtainAllowance(List<Prize> prizeList); |
| | | |
| | | /** |
| | | * 用户下单 |
| | | * |
| | | * @param orderRequest 下单信息 |
| | | * @param userId 用户id |
| | | * @return 下单结果 |
| | | */ |
| | | Boolean placeOrder(OrderRequest orderRequest, Integer userId); |
| | | } |
| | |
| | | * @param userid 用户id |
| | | * @return 服务列表 |
| | | */ |
| | | List<UserCollectVO> collectList(Long userid); |
| | | List<UserCollectVO> collectList(Integer userid); |
| | | } |
| | |
| | | */ |
| | | public interface UserRecipientService extends IService<UserRecipient> { |
| | | |
| | | /** |
| | | * 收货地址更改 |
| | | * |
| | | * @param userRecipient 收货地址 |
| | | * @param userid 用户id |
| | | * @return 操作结果 |
| | | */ |
| | | boolean updateBatchAddress(UserRecipient userRecipient, Integer userid); |
| | | } |
| | |
| | | * @param userid 用户id |
| | | * @return 提现列表 |
| | | */ |
| | | WithdrawListVO withdrawList(Long userid); |
| | | WithdrawListVO withdrawList(Integer userid); |
| | | |
| | | /** |
| | | * 确认提现 |
| | |
| | | * @param orderId 订单id |
| | | * @return 操作结果 |
| | | */ |
| | | Boolean confirmWithdraw(Integer orderId, Long userid); |
| | | Boolean confirmWithdraw(Integer orderId, Integer userid); |
| | | } |
| | |
| | | public class EvaluateServiceImpl extends ServiceImpl<EvaluateMapper, Evaluate> implements EvaluateService { |
| | | |
| | | @Override |
| | | public List<OrderEvaluateVO> orderEvaluate(Long userId) { |
| | | public List<OrderEvaluateVO> orderEvaluate(Integer userId) { |
| | | return baseMapper.orderEvaluate(userId); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.admin.api.entity.Prize; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.user.entity.Order; |
| | | import com.ruoyi.user.entity.RecoveryServe; |
| | | import com.ruoyi.user.entity.UserRecipient; |
| | | import com.ruoyi.user.mapper.OrderMapper; |
| | | import com.ruoyi.user.request.OrderRequest; |
| | | import com.ruoyi.user.service.OrderService; |
| | | import com.ruoyi.user.service.RecoveryServeService; |
| | | import com.ruoyi.user.service.UserRecipientService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | import java.util.stream.Collectors; |
| | |
| | | @Service |
| | | public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService { |
| | | |
| | | @Resource |
| | | private UserRecipientService userRecipientService; |
| | | @Resource |
| | | private RecoveryServeService recoveryServeService; |
| | | |
| | | @Override |
| | | public Object obtainAllowance(List<Prize> prizeList) { |
| | | // 过滤中奖概率为空的奖品 |
| | |
| | | // 转盘逻辑 |
| | | double sum = prizes.stream().map(Prize::getProbability).mapToDouble(Double::doubleValue).sum(); |
| | | Prize result = null; |
| | | boolean v = true; |
| | | while (v) { |
| | | for (Prize prize : prizes) { |
| | | double item = prize.getProbability() / sum; |
| | | // 随机数对象 |
| | | Random random = new Random(); |
| | | // 生成一个介于0到1之间的随机小数 |
| | | double randomDouble = random.nextDouble(); |
| | | if (item <= randomDouble) { |
| | | if (item >= randomDouble) { |
| | | result = prize; |
| | | break; |
| | | } |
| | | } |
| | | if (null != result) { |
| | | v = false; |
| | | } |
| | | } |
| | | // 抽中的商品 |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean placeOrder(OrderRequest orderRequest, Integer userId) { |
| | | String orderNumber = orderRequest.getOrderNumber(); |
| | | Integer serveId = orderRequest.getServeId(); |
| | | String reservationName = orderRequest.getReservationName(); |
| | | String reservationPhone = orderRequest.getReservationPhone(); |
| | | Integer addressId = orderRequest.getAddressId(); |
| | | Date time = orderRequest.getTime(); |
| | | String reservationRemark = orderRequest.getReservationRemark(); |
| | | Double longitude = orderRequest.getLongitude(); |
| | | Double latitude = orderRequest.getLatitude(); |
| | | BigDecimal subsidy = orderRequest.getSubsidy(); |
| | | // 下单相关信息 |
| | | RecoveryServe recoveryServe = recoveryServeService.lambdaQuery().eq(RecoveryServe::getId, serveId) |
| | | .eq(RecoveryServe::getIsDelete, 0).one(); |
| | | UserRecipient userRecipient = userRecipientService.lambdaQuery().eq(UserRecipient::getId, addressId) |
| | | .eq(UserRecipient::getIsDelete, 0).one(); |
| | | if (null == recoveryServe || null == userRecipient) { |
| | | throw new GlobalException("下单失败,预约服务信息或收货地址信息异常!"); |
| | | } |
| | | // 订单信息 |
| | | Order order = new Order(); |
| | | order.setOrderNumber(orderNumber); |
| | | order.setServeId(serveId); |
| | | order.setServeName(recoveryServe.getServeName()); |
| | | order.setServePrice(recoveryServe.getDefaultPrice()); |
| | | order.setUserId(userId); |
| | | order.setReservationName(reservationName); |
| | | order.setReservationPhone(reservationPhone); |
| | | order.setReservationAddress(userRecipient.getAddress()); |
| | | order.setTime(time); |
| | | order.setReservationRemark(reservationRemark); |
| | | order.setOrderMoney(recoveryServe.getDefaultPrice().add(new BigDecimal(String.valueOf(subsidy)))); |
| | | order.setState(Constants.ZERO); |
| | | order.setType(Constants.ZERO); |
| | | order.setLongitude(longitude); |
| | | order.setLatitude(latitude); |
| | | order.setIsWithdrawal(Constants.ZERO); |
| | | order.setSubsidy(subsidy); |
| | | order.setAddress(userRecipient.getAddressDetail()); |
| | | return this.save(order); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | public class UserCollectServiceImpl extends ServiceImpl<UserCollectMapper, UserCollect> implements UserCollectService { |
| | | |
| | | @Override |
| | | public List<UserCollectVO> collectList(Long userid) { |
| | | public List<UserCollectVO> collectList(Integer userid) { |
| | | return baseMapper.collectList(userid); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.user.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.user.entity.UserRecipient; |
| | | import com.ruoyi.user.mapper.UserRecipientMapper; |
| | | import com.ruoyi.user.service.UserRecipientService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class UserRecipientServiceImpl extends ServiceImpl<UserRecipientMapper, UserRecipient> implements UserRecipientService { |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateBatchAddress(UserRecipient userRecipient, Integer userid) { |
| | | boolean result = true; |
| | | if (Constants.ONE.equals(userRecipient.getIsDefault())) { |
| | | List<UserRecipient> list = lambdaQuery().eq(UserRecipient::getUserId, userid) |
| | | .eq(UserRecipient::getIsDelete, 0).list(); |
| | | List<UserRecipient> updateList = new ArrayList<>(); |
| | | for (UserRecipient recipient : list) { |
| | | if (Constants.ONE.equals(recipient.getIsDefault())) { |
| | | recipient.setIsDefault(0); |
| | | updateList.add(recipient); |
| | | } |
| | | } |
| | | if (!updateList.isEmpty()) { |
| | | result = this.updateBatchById(updateList); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.user.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.admin.api.entity.WithdrawalSetting; |
| | | import com.ruoyi.admin.api.feignClient.AdminClient; |
| | |
| | | private AdminClient adminClient; |
| | | |
| | | @Override |
| | | public WithdrawListVO withdrawList(Long userid) { |
| | | public WithdrawListVO withdrawList(Integer userid) { |
| | | WithdrawListVO withdrawList = new WithdrawListVO(); |
| | | List<Order> orderList = orderService.lambdaQuery().eq(Order::getUserId, userid) |
| | | .eq(Order::getState, 3).eq(Order::getIsDelete, 0).list(); |
| | | // 总金额 |
| | | BigDecimal totalMoney = orderList.stream().map(Order::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal totalMoney = BigDecimal.ZERO; |
| | | // 未提现金额 |
| | | BigDecimal undelivered = orderList.stream().filter(data -> Constants.ZERO.equals(data.getIsWithdrawal())) |
| | | BigDecimal undelivered = BigDecimal.ZERO; |
| | | // 已提现金额 |
| | | BigDecimal withdrawn = BigDecimal.ZERO; |
| | | if (!orderList.isEmpty()) { |
| | | // 总金额 |
| | | totalMoney = orderList.stream().map(Order::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 未提现金额 |
| | | undelivered = orderList.stream().filter(data -> Constants.ZERO.equals(data.getIsWithdrawal())) |
| | | .map(Order::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 已提现金额 |
| | | BigDecimal withdrawn = orderList.stream().filter(data -> Constants.ONE.equals(data.getIsWithdrawal())) |
| | | withdrawn = orderList.stream().filter(data -> Constants.ONE.equals(data.getIsWithdrawal())) |
| | | .map(Order::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | } |
| | | withdrawList.setMoneyCount(new WithdrawMoneyVO(totalMoney, undelivered, withdrawn)); |
| | | // 回收服务列表 |
| | | List<RecoveryServe> serveList = recoveryServeService.lambdaQuery().eq(RecoveryServe::getIsDelete, 0) |
| | | .in(RecoveryServe::getId, orderList.stream().map(Order::getServeId).collect(Collectors.toList())).list(); |
| | | List<Integer> serveIds = orderList.stream().map(Order::getServeId).collect(Collectors.toList()); |
| | | LambdaQueryChainWrapper<RecoveryServe> wrapper = recoveryServeService.lambdaQuery() |
| | | .eq(RecoveryServe::getIsDelete, 0); |
| | | wrapper = serveIds.isEmpty() ? wrapper : wrapper.in(RecoveryServe::getId, serveIds); |
| | | List<RecoveryServe> serveList = wrapper.list(); |
| | | Map<Integer, RecoveryServe> serveMap = serveList.stream().collect(Collectors.toMap(RecoveryServe::getId, serve -> serve)); |
| | | // 订单列表 |
| | | List<WithdrawOrderVO> list = new ArrayList<>(); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean confirmWithdraw(Integer orderId, Long userid) { |
| | | public Boolean confirmWithdraw(Integer orderId, Integer userid) { |
| | | Order order = orderService.lambdaQuery().eq(Order::getId, orderId).eq(Order::getIsDelete, 0).one(); |
| | | if (null == order) { |
| | | throw new GlobalException("订单信息异常!"); |
| | |
| | | @Data |
| | | public class UserCollectVO { |
| | | |
| | | @ApiModelProperty("服务id") |
| | | private Integer serveId; |
| | | |
| | | @ApiModelProperty("服务名称") |
| | | private String serveName; |
| | | |
| | |
| | | <result column="serve_describe" property="serveDescribe"/> |
| | | <result column="estimate_price" property="estimatePrice"/> |
| | | <result column="default_price" property="defaultPrice"/> |
| | | <result column="order" property="order"/> |
| | | <result column="sort" property="sort"/> |
| | | <result column="cover" property="cover"/> |
| | | <result column="rotate" property="rotate"/> |
| | | <result column="createBy" property="createBy"/> |
| | |
| | | </resultMap> |
| | | |
| | | <select id="collectList" resultType="com.ruoyi.user.vo.UserCollectVO"> |
| | | select s.serve_name, s.serve_describe, s.cover |
| | | select s.serve_name as serveName, |
| | | s.serve_describe as serveDescribe, |
| | | s.cover, |
| | | s.id as serveId |
| | | from t_user_collect c |
| | | left join sys_recovery_serve s on c.serve_id = s.id |
| | | where c.user_id = #{userid} |
| | |
| | | @TableField("complete_time") |
| | | private Date completeTime; |
| | | |
| | | @ApiModelProperty("是否已提现(0:未提现,1:已提现)") |
| | | @TableField("is_withdrawal") |
| | | private Integer isWithdrawal; |
| | | |
| | | @ApiModelProperty("订单补贴金额") |
| | | @TableField("subsidy") |
| | | private BigDecimal subsidy; |
| | | |
| | | @ApiModelProperty("详细地址") |
| | | @TableField("address") |
| | | private String address; |
| | | |
| | | } |