Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile
# Conflicts:
# ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml
| | |
| | | public R<List<Site>> getSiteByIds(List<Integer> ids) { |
| | | return R.fail("根据id集合获取站点数据调用失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<Site>> getSiteAll() { |
| | | return R.fail("获取所有站点调用失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | */ |
| | | @PostMapping("/site/getSiteByIds") |
| | | R<List<Site>> getSiteByIds(@RequestBody List<Integer> ids); |
| | | |
| | | /** |
| | | * 获取所有站点 |
| | | * @return |
| | | */ |
| | | @PostMapping("/site/getSiteAll") |
| | | R<List<Site>> getSiteAll(); |
| | | } |
| | |
| | | private Integer underlyingSales; |
| | | |
| | | @ApiModelProperty(value = "商品描述") |
| | | @TableField("describe") |
| | | private String describe; |
| | | @TableField("describes") |
| | | private String describes; |
| | | |
| | | @ApiModelProperty(value = "商品介绍") |
| | | @TableField("introduce") |
| | |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "禁用账户备注") |
| | | @TableField("forbidden_remark") |
| | | private String forbiddenRemark; |
| | | |
| | | @ApiModelProperty(value = "充电站") |
| | | @TableField(exist = false) |
| | | private List<String> siteNames; |
| | |
| | | this.roleNames = roleNames; |
| | | } |
| | | |
| | | public String getForbiddenRemark() { |
| | | return forbiddenRemark; |
| | | } |
| | | |
| | | public void setForbiddenRemark(String forbiddenRemark) { |
| | | this.forbiddenRemark = forbiddenRemark; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | |
| | | |
| | | @Override |
| | | public R<Boolean> updateSysUser(SysUser sysUser) { |
| | | return R.fail("更新用户失败:" + cause.getMessage()); |
| | | throw new RuntimeException("更新用户失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-common-seata</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- SpringBoot Web --> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | |
| | | import com.ruoyi.system.api.domain.SysRole; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | public class TokenController |
| | | { |
| | | public class TokenController { |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | |
| | | private SysUserClient userClient; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @PostMapping("login") |
| | | @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 |
| | | public R<?> login(@RequestBody LoginBody form, HttpServletRequest request) { |
| | | // 用户登录 |
| | | LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword(), request); |
| | |
| | | @DeleteMapping("logout") |
| | | public R<?> logout(HttpServletRequest request) { |
| | | String token = SecurityUtils.getToken(request); |
| | | if (StringUtils.isNotEmpty(token)) |
| | | { |
| | | if (StringUtils.isNotEmpty(token)) { |
| | | String username = JwtUtils.getUserName(token); |
| | | // 删除用户缓存记录 |
| | | AuthUtil.logoutByToken(token); |
| | |
| | | |
| | | |
| | | @PostMapping("refresh") |
| | | public R<?> refresh(HttpServletRequest request) |
| | | { |
| | | public R<?> refresh(HttpServletRequest request) { |
| | | LoginUser loginUser = tokenService.getLoginUser(request); |
| | | if (StringUtils.isNotNull(loginUser)) |
| | | { |
| | | if (StringUtils.isNotNull(loginUser)) { |
| | | // 刷新令牌有效期 |
| | | tokenService.refreshToken(loginUser); |
| | | return R.ok(); |
| | |
| | | } |
| | | |
| | | @PostMapping("register") |
| | | public R<?> register(@RequestBody RegisterBody registerBody, HttpServletRequest request) |
| | | { |
| | | public R<?> register(@RequestBody RegisterBody registerBody, HttpServletRequest request) { |
| | | // 用户注册 |
| | | sysLoginService.register(registerBody.getUsername(), registerBody.getPassword(), request); |
| | | return R.ok(); |
| | |
| | | @RestController |
| | | @RequestMapping("/role") |
| | | @Api(tags = "角色模块") |
| | | public class SysRoleController extends BaseController |
| | | { |
| | | public class SysRoleController extends BaseController { |
| | | @Resource |
| | | private ISysRoleService roleService; |
| | | |
| | |
| | | private SiteClient siteClient; |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "获取角色列表", tags = {"管理后台-系统用户管理"}) |
| | | @GetMapping("/list") |
| | | public AjaxResult list() { |
| | | List<SysRole> list = roleService.list(new LambdaQueryWrapper<SysRole>().eq(SysRole::getDelFlag, 0).eq(SysRole::getStatus, 0)); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/roleAdd") |
| | | @ApiOperation(value = "添加角色", tags = {"管理后台-角色管理"}) |
| | | @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 |
| | | public AjaxResult roleAdd(@Validated @RequestBody RoleAddDto dto) |
| | | { |
| | | public AjaxResult roleAdd(@Validated @RequestBody RoleAddDto dto) { |
| | | SysRole role = new SysRole(); |
| | | role.setRoleName(dto.getRoleName()); |
| | | long count = roleService.count(Wrappers.lambdaQuery(SysRole.class) |
| | |
| | | roleInfoVo.setMenus(menusId); |
| | | roleInfoVo.setRemark(role.getRemark()); |
| | | List<Integer> siteIds = roleSiteClient.getSiteIds(role.getRoleId()).getData(); |
| | | if (null != siteIds && siteIds.size() > 0) { |
| | | List<Site> sites = siteClient.getSiteByIds(siteIds).getData(); |
| | | List<String> siteNames = sites.stream().map(Site::getName).collect(Collectors.toList()); |
| | | roleInfoVo.setSiteNames(siteNames); |
| | | roleInfoVo.setSiteIds(siteIds); |
| | | } |
| | | return AjaxResult.success(roleInfoVo); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/roleUpdate") |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 删除角色 |
| | | */ |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询已分配用户角色列表 |
| | | */ |
| | | @RequiresPermissions("system:role:list") |
| | | @GetMapping("/authUser/allocatedList") |
| | | public TableDataInfo allocatedList(SysUser user) |
| | | { |
| | | public TableDataInfo allocatedList(SysUser user) { |
| | | startPage(); |
| | | List<SysUser> list = userService.selectAllocatedList(user); |
| | | return getDataTable(list); |
| | |
| | | */ |
| | | @RequiresPermissions("system:role:list") |
| | | @GetMapping("/authUser/unallocatedList") |
| | | public TableDataInfo unallocatedList(SysUser user) |
| | | { |
| | | public TableDataInfo unallocatedList(SysUser user) { |
| | | startPage(); |
| | | List<SysUser> list = userService.selectUnallocatedList(user); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @RequiresPermissions("system:role:query") |
| | | @GetMapping(value = "/deptTree/{roleId}") |
| | | public AjaxResult deptTree(@PathVariable("roleId") Long roleId) |
| | | { |
| | | public AjaxResult deptTree(@PathVariable("roleId") Long roleId) { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); |
| | | ajax.put("depts", deptService.selectDeptTreeList(new SysDept())); |
| | |
| | | |
| | | /** |
| | | * 根据id集合获取数据 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | |
| | | package com.ruoyi.system.controller; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.chargingPile.api.feignClient.SiteClient; |
| | |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.system.api.query.ChangeUserQuery; |
| | | import com.ruoyi.system.domain.dto.IndexDto; |
| | | import com.ruoyi.system.domain.vo.UserRoleVO; |
| | | import com.ruoyi.system.api.model.*; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.domain.dto.AddCompanyUserDto; |
| | | import com.ruoyi.system.domain.vo.CompanyUserVo; |
| | | import com.ruoyi.system.domain.vo.TCompanyToUserVo; |
| | | import com.ruoyi.system.query.GetSysUserList; |
| | | import com.ruoyi.system.query.ShopUserStart; |
| | | import com.ruoyi.system.service.*; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import com.ruoyi.common.core.domain.R; |
| | | 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.log.annotation.Log; |
| | |
| | | SysUser sysUser = userService.selectUserById(shopUserStart.getUserId()); |
| | | if (sysUser.getStatus().equals("0")) { |
| | | sysUser.setStatus("1"); |
| | | sysUser.setRemark(shopUserStart.getRemark()); |
| | | sysUser.setForbiddenRemark(shopUserStart.getRemark()); |
| | | } else { |
| | | sysUser.setStatus("0"); |
| | | sysUser.setRemark(""); |
| | | sysUser.setForbiddenRemark(""); |
| | | } |
| | | return toAjax(userService.updateUser(sysUser)); |
| | | } |
| | |
| | | sysUser.setUpdateBy(SecurityUtils.getUsername()); |
| | | sysUser.setUpdateTime(new Date()); |
| | | userService.updateUser(sysUser); |
| | | if(null != sysUser.getRoleId()){ |
| | | userRoleService.deleteSysUserRoleByUserId(sysUser.getUserId()); |
| | | SysUserRole sysUserRole = new SysUserRole(); |
| | | sysUserRole.setRoleId(sysUser.getRoleId()); |
| | | sysUserRole.setUserId(sysUser.getUserId()); |
| | | userRoleService.insertSysUserRole(sysUserRole); |
| | | } |
| | | return R.ok(true); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/userRole") |
| | | public class SysUserRoleController extends BaseController |
| | | { |
| | | public class SysUserRoleController extends BaseController { |
| | | @Autowired |
| | | private ISysUserRoleService sysUserRoleService; |
| | | |
| | |
| | | */ |
| | | @RequiresPermissions("car:role:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysUserRole sysUserRole) |
| | | { |
| | | public TableDataInfo list(SysUserRole sysUserRole) { |
| | | startPage(); |
| | | List<SysUserRole> list = sysUserRoleService.selectSysUserRoleList(sysUserRole); |
| | | return getDataTable(list); |
| | |
| | | @RequiresPermissions("car:role:export") |
| | | @Log(title = "用户和角色关联", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, SysUserRole sysUserRole) |
| | | { |
| | | public void export(HttpServletResponse response, SysUserRole sysUserRole) { |
| | | List<SysUserRole> list = sysUserRoleService.selectSysUserRoleList(sysUserRole); |
| | | ExcelUtil<SysUserRole> util = new ExcelUtil<SysUserRole>(SysUserRole.class); |
| | | util.exportExcel(response, list, "用户和角色关联数据"); |
| | |
| | | */ |
| | | @RequiresPermissions("car:role:query") |
| | | @GetMapping(value = "/{userId}") |
| | | public AjaxResult getInfo(@PathVariable("userId") Long userId) |
| | | { |
| | | public AjaxResult getInfo(@PathVariable("userId") Long userId) { |
| | | return success(sysUserRoleService.selectSysUserRoleByUserId(userId)); |
| | | } |
| | | |
| | |
| | | @RequiresPermissions("car:role:add") |
| | | @Log(title = "用户和角色关联", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody SysUserRole sysUserRole) |
| | | { |
| | | public AjaxResult add(@RequestBody SysUserRole sysUserRole) { |
| | | return toAjax(sysUserRoleService.insertSysUserRole(sysUserRole)); |
| | | } |
| | | |
| | |
| | | @RequiresPermissions("car:role:edit") |
| | | @Log(title = "用户和角色关联", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody SysUserRole sysUserRole) |
| | | { |
| | | public AjaxResult edit(@RequestBody SysUserRole sysUserRole) { |
| | | return toAjax(sysUserRoleService.updateSysUserRole(sysUserRole)); |
| | | } |
| | | |
| | |
| | | @RequiresPermissions("car:role:remove") |
| | | @Log(title = "用户和角色关联", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{userIds}") |
| | | public AjaxResult remove(@PathVariable Long[] userIds) |
| | | { |
| | | public AjaxResult remove(@PathVariable Long[] userIds) { |
| | | return toAjax(sysUserRoleService.deleteSysUserRoleByUserIds(userIds)); |
| | | } |
| | | } |
| | |
| | | * @date 2023-06-12 |
| | | */ |
| | | @Service |
| | | public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements ISysUserRoleService |
| | | { |
| | | public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements ISysUserRoleService { |
| | | @Autowired |
| | | private SysUserRoleMapper sysUserRoleMapper; |
| | | |
| | |
| | | * @return 用户和角色关联 |
| | | */ |
| | | @Override |
| | | public SysUserRole selectSysUserRoleByUserId(Long userId) |
| | | { |
| | | public SysUserRole selectSysUserRoleByUserId(Long userId) { |
| | | return sysUserRoleMapper.selectSysUserRoleByUserId(userId); |
| | | } |
| | | |
| | |
| | | * @return 用户和角色关联 |
| | | */ |
| | | @Override |
| | | public List<SysUserRole> selectSysUserRoleList(SysUserRole sysUserRole) |
| | | { |
| | | public List<SysUserRole> selectSysUserRoleList(SysUserRole sysUserRole) { |
| | | return sysUserRoleMapper.selectSysUserRoleList(sysUserRole); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertSysUserRole(SysUserRole sysUserRole) |
| | | { |
| | | public int insertSysUserRole(SysUserRole sysUserRole) { |
| | | return sysUserRoleMapper.insertSysUserRole(sysUserRole); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateSysUserRole(SysUserRole sysUserRole) |
| | | { |
| | | public int updateSysUserRole(SysUserRole sysUserRole) { |
| | | return sysUserRoleMapper.updateSysUserRole(sysUserRole); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteSysUserRoleByUserIds(Long[] userIds) |
| | | { |
| | | public int deleteSysUserRoleByUserIds(Long[] userIds) { |
| | | return sysUserRoleMapper.deleteSysUserRoleByUserIds(userIds); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteSysUserRoleByUserId(Long userId) |
| | | { |
| | | public int deleteSysUserRoleByUserId(Long userId) { |
| | | return sysUserRoleMapper.deleteSysUserRoleByUserId(userId); |
| | | } |
| | | } |
| | |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="forbiddenRemark" column="forbidden_remark"/> |
| | | <result property="remark" column="remark" /> |
| | | <result property="roleType" column="roleType" /> |
| | | <result property="objectId" column="objectId" /> |
New file |
| | |
| | | package com.ruoyi.account.ali.pojo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "支付宝小程序登录") |
| | | public class AppletUserLogin implements Serializable { |
| | | |
| | | @ApiModelProperty(value = "auth_code") |
| | | @NotBlank(message = "auth_code不能为空") |
| | | private String code; |
| | | |
| | | @ApiModelProperty(value = "获取用户信息加密串") |
| | | @NotBlank(message = "获取用户信息加密串不能为空") |
| | | private String token; |
| | | |
| | | } |
| | |
| | | package com.ruoyi.account.ali.tools; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.alibaba.fastjson.parser.Feature; |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.AlipayConfig; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.internal.util.AlipayEncrypt; |
| | | import com.alipay.api.internal.util.AlipaySignature; |
| | | import com.alipay.api.request.AlipaySystemOauthTokenRequest; |
| | | import com.alipay.api.request.AlipayUserUserinfoShareRequest; |
| | | import com.alipay.api.request.AlipayUserInfoShareRequest; |
| | | import com.alipay.api.response.AlipaySystemOauthTokenResponse; |
| | | import com.alipay.api.response.AlipayUserUserinfoShareResponse; |
| | | import com.alipay.api.response.AlipayUserInfoShareResponse; |
| | | import com.ruoyi.account.ali.Constant.AliConstant; |
| | | import com.ruoyi.account.ali.model.AliProperties; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author xiaochen |
| | |
| | | * 支付宝小程序授权获取手机号 |
| | | * @return |
| | | */ |
| | | public AlipayUserUserinfoShareResponse getUserInfo(String accessToken) { |
| | | public AlipayUserInfoShareResponse getUserInfo(String accessToken) { |
| | | try { |
| | | // 初始化SDK |
| | | AlipayClient alipayClient = new DefaultAlipayClient(new AliAppletTools(aliProperties).getAlipayConfig(AliConstant.LOGIN_SERVER_URL)); |
| | | //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.user.userinfo.share |
| | | AlipayUserUserinfoShareRequest request = new AlipayUserUserinfoShareRequest(); |
| | | AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest(); |
| | | //授权类接口执行API调用时需要带上accessToken |
| | | return alipayClient.execute(request,accessToken); |
| | | } catch (AlipayApiException e) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取用户手机号 |
| | | * @param response |
| | | * @return |
| | | */ |
| | | public String getPhoneNumber(String response){ |
| | | //1. 获取验签和解密所需要的参数 |
| | | Map<String, String> openapiResult = JSON.parseObject(response,new TypeReference<Map<String, String>>() {}, Feature.OrderedField); |
| | | String signType = "RSA2"; |
| | | String charset = "UTF-8"; |
| | | String encryptType = "AES"; |
| | | String sign = openapiResult.get("sign"); |
| | | String content = openapiResult.get("response"); |
| | | //判断是否为加密内容 |
| | | boolean isDataEncrypted = !content.startsWith("{"); |
| | | boolean signCheckPass = false; |
| | | //2. 验签 |
| | | String signContent = content; |
| | | if (isDataEncrypted) { |
| | | signContent = "\"" + signContent + "\""; |
| | | } try { |
| | | signCheckPass = AlipaySignature.rsaCheck(signContent, sign, aliProperties.getAlipayPublicKey(), charset, signType); |
| | | } catch (AlipayApiException e) { |
| | | // 验签异常, 日志 |
| | | } if (!signCheckPass) { |
| | | //验签不通过(异常或者报文被篡改),终止流程(不需要做解密) |
| | | throw new ServiceException("验签失败"); |
| | | } |
| | | //3. 解密 |
| | | String plainData = null; |
| | | if (isDataEncrypted) { |
| | | try { |
| | | plainData = AlipayEncrypt.decryptContent(content, encryptType, "XABBSOeWDakvuG9TDez4Qg====", charset); |
| | | } catch (AlipayApiException e) { |
| | | //解密异常, 记录日志 |
| | | throw new ServiceException("解密异常"); |
| | | }} else { |
| | | plainData = content; |
| | | } |
| | | log.info("解密后的数据:{}", plainData); |
| | | String phoneNumber = ""; |
| | | if (plainData.contains("mobile")) { |
| | | phoneNumber = JSON.parseObject(plainData).getString("mobile"); |
| | | } |
| | | return phoneNumber; |
| | | } |
| | | |
| | | /** |
| | | * 初始化支付宝配置 |
| | | * @return |
| | | */ |
| | |
| | | import com.alipay.api.diagnosis.DiagnosisUtils; |
| | | import com.alipay.api.request.AlipaySystemOauthTokenRequest; |
| | | import com.alipay.api.response.AlipaySystemOauthTokenResponse; |
| | | import com.alipay.api.response.AlipayUserInfoShareResponse; |
| | | import com.alipay.api.response.AlipayUserUserinfoShareResponse; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.account.ali.Constant.AliConstant; |
| | | import com.ruoyi.account.ali.model.AliProperties; |
| | | import com.ruoyi.account.ali.pojo.AppletUserLogin; |
| | | import com.ruoyi.account.ali.tools.AliAppletTools; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.service.TAppUserService; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUserApplet; |
| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | |
| | | @Autowired |
| | | private TAppUserService appUserService; |
| | | @ApiOperation(value = "通过code获得openid",tags = {"支付宝小程序登录"}) |
| | | @GetMapping("/openIdByJsCode") |
| | | public AjaxResult<Map<String, Object>> openIdByJsCode(@RequestParam(name = "code")@ApiParam(value = "code", required = true) String code){ |
| | | log.info("<<<<<<<<换取openid开始<<<<<<<<:{}", code); |
| | | @PostMapping("/openIdByJsCode") |
| | | public AjaxResult<Map<String, Object>> openIdByJsCode(@RequestBody AppletUserLogin appletUserLogin){ |
| | | log.info("<<<<<<<<换取openid开始<<<<<<<<:{}", appletUserLogin.getCode()); |
| | | // 登录 |
| | | AlipaySystemOauthTokenResponse response = new AliAppletTools(aliProperties).login(code); |
| | | AlipaySystemOauthTokenResponse response = new AliAppletTools(aliProperties).login(appletUserLogin.getCode()); |
| | | if (response.isSuccess()) { |
| | | // 获取用户信息 |
| | | AlipayUserUserinfoShareResponse userInfo = new AliAppletTools(aliProperties).getUserInfo(response.getAccessToken()); |
| | | log.info("获取支付宝用户信息:{}", userInfo); |
| | | // AlipayUserInfoShareResponse userInfo = new AliAppletTools(aliProperties).getUserInfo(response.getAccessToken()); |
| | | if(StringUtils.isEmpty(appletUserLogin.getToken())){ |
| | | return AjaxResult.success("已拒绝授权"); |
| | | } |
| | | // 获取用户手机号 |
| | | String phoneNumber = new AliAppletTools(aliProperties).getPhoneNumber(appletUserLogin.getToken()); |
| | | log.info("获取支付宝用户信息:{}", phoneNumber); |
| | | // 用户信息封装 |
| | | return AjaxResult.ok(appUserService.aliLogin(response,userInfo)); |
| | | return AjaxResult.success(appUserService.aliLogin(response,phoneNumber)); |
| | | } else { |
| | | String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response); |
| | | log.warn("诊断结果:{}",diagnosisUrl); |
| | |
| | | if (userListQueryDto.getUserTagId() != null){ |
| | | String[] split = userListQueryDto.getUserTagId().split(","); |
| | | userIds = appUserTagService.lambdaQuery().in(TAppUserTag::getUserTagId, Arrays.asList(split)).list().stream().map(TAppUserTag::getAppUserId).collect(Collectors.toList()); |
| | | if (userIds.isEmpty()){ |
| | | userIds.add(-1L); |
| | | } |
| | | } |
| | | //列表查询 |
| | | Page<TAppUser> page = appUserService.lambdaQuery() |
| | |
| | | //拿到最新的tagId |
| | | TAppUserTag one = appUserTagService.lambdaQuery().eq(TAppUserTag::getAppUserId, appUser.getId()).orderByDesc(TAppUserTag::getCreateTime).last("limit 1").one(); |
| | | //设置最新的tagName |
| | | if (one!=null){ |
| | | R<TUserTag> byIdTag = otherClient.getByIdTag(one.getUserTagId()); |
| | | if (byIdTag.getData()!=null) { |
| | | appUser.setTagName(byIdTag.getData().getName()); |
| | | } |
| | | } |
| | | //匹配vipMap的值 |
| | | appUser.setVipName(vipMap.getData().get(appUser.getVipId())); |
| | | //累计充电次数 |
| | |
| | | import com.ruoyi.account.wx.tools.WxAppletTools; |
| | | import com.ruoyi.account.wx.tools.WxUtils; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.client.RestTemplate; |
| | |
| | | // if (StringUtils.isNotBlank(data.getSignature())) { |
| | | // WxUtils.verifySignature(data.getRawData(), sessionKey, data.getSignature()); |
| | | // } |
| | | if(StringUtils.isEmpty(data.getEncryptedData()) || StringUtils.isEmpty(data.getIv())){ |
| | | return AjaxResult.success("已拒绝授权"); |
| | | } |
| | | AppletUserDecodeData appletUserDecodeData = WxUtils.encryptedData(data.getEncryptedData(), sessionKey, data.getIv()); |
| | | appletUserDecodeData.setOpenId(openid); |
| | | return AjaxResult.ok(appUserService.wxLogin(appletUserDecodeData)); |
| | | return AjaxResult.success(appUserService.wxLogin(appletUserDecodeData)); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.account.service; |
| | | |
| | | import com.alipay.api.response.AlipaySystemOauthTokenResponse; |
| | | import com.alipay.api.response.AlipayUserInfoShareResponse; |
| | | import com.alipay.api.response.AlipayUserUserinfoShareResponse; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | |
| | | |
| | | /** |
| | | * 支付宝小程序登录用户封装 |
| | | * @param userInfo |
| | | * @param response |
| | | * @return |
| | | */ |
| | | Map<String, Object> aliLogin(AlipaySystemOauthTokenResponse response,AlipayUserUserinfoShareResponse userInfo); |
| | | // Map<String, Object> aliLogin(AlipaySystemOauthTokenResponse response, AlipayUserInfoShareResponse userInfo); |
| | | Map<String, Object> aliLogin(AlipaySystemOauthTokenResponse response,String phone); |
| | | |
| | | /** |
| | | * 封装用户信息和token |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.alipay.api.response.AlipaySystemOauthTokenResponse; |
| | | import com.alipay.api.response.AlipayUserInfoShareResponse; |
| | | import com.alipay.api.response.AlipayUserUserinfoShareResponse; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> aliLogin(AlipaySystemOauthTokenResponse response, AlipayUserUserinfoShareResponse userInfo) { |
| | | public Map<String, Object> aliLogin(AlipaySystemOauthTokenResponse response,String phone) { |
| | | // 通过手机号查询用户,是否已存在手动导入用户,包含微信用户 |
| | | TAppUser appUser = this.getOne(Wrappers.lambdaQuery(TAppUser.class) |
| | | .eq(TAppUser::getPhone, userInfo.getMobile()) |
| | | .eq(TAppUser::getPhone, phone) |
| | | .isNull(TAppUser::getAliOpenid) |
| | | .last("LIMIT 1")); |
| | | if(Objects.isNull(appUser)){ |
| | | // 先使用openId和当前手机号进行查询 |
| | | appUser = this.getOne(Wrappers.lambdaQuery(TAppUser.class) |
| | | .eq(TAppUser::getAliOpenid, response.getOpenId()) |
| | | .eq(TAppUser::getPhone, userInfo.getMobile()) |
| | | .eq(TAppUser::getPhone, phone) |
| | | .last("LIMIT 1")); |
| | | if(Objects.isNull(appUser)){ |
| | | appUser = new TAppUser(); |
| | | appUser.setPhone(userInfo.getMobile()); |
| | | appUser.setPhone(phone); |
| | | } |
| | | } |
| | | if(Objects.nonNull(appUser.getStatus())){ |
| | | throwInfo(appUser.getStatus()); |
| | | } |
| | | appUser.setAvatar(userInfo.getAvatar()); |
| | | appUser.setCity(userInfo.getCity()); |
| | | appUser.setName(userInfo.getNickName()); |
| | | appUser.setProvince(userInfo.getProvince()); |
| | | appUser.setAliOpenid(response.getOpenId()); |
| | | this.saveOrUpdate(appUser); |
| | | return this.getUserInfo(appUser); |
| | | } |
| | | // @Override |
| | | // public Map<String, Object> aliLogin(AlipaySystemOauthTokenResponse response, AlipayUserInfoShareResponse userInfo) { |
| | | // // 通过手机号查询用户,是否已存在手动导入用户,包含微信用户 |
| | | // TAppUser appUser = this.getOne(Wrappers.lambdaQuery(TAppUser.class) |
| | | // .eq(TAppUser::getPhone, userInfo.getMobile()) |
| | | // .isNull(TAppUser::getAliOpenid) |
| | | // .last("LIMIT 1")); |
| | | // if(Objects.isNull(appUser)){ |
| | | // // 先使用openId和当前手机号进行查询 |
| | | // appUser = this.getOne(Wrappers.lambdaQuery(TAppUser.class) |
| | | // .eq(TAppUser::getAliOpenid, response.getOpenId()) |
| | | // .eq(TAppUser::getPhone, userInfo.getMobile()) |
| | | // .last("LIMIT 1")); |
| | | // if(Objects.isNull(appUser)){ |
| | | // appUser = new TAppUser(); |
| | | // appUser.setPhone(userInfo.getMobile()); |
| | | // } |
| | | // } |
| | | // if(Objects.nonNull(appUser.getStatus())){ |
| | | // throwInfo(appUser.getStatus()); |
| | | // } |
| | | // appUser.setAvatar(userInfo.getAvatar()); |
| | | // appUser.setCity(userInfo.getCity()); |
| | | // appUser.setName(userInfo.getNickName()); |
| | | // appUser.setProvince(userInfo.getProvince()); |
| | | // appUser.setAliOpenid(response.getOpenId()); |
| | | // this.saveOrUpdate(appUser); |
| | | // return this.getUserInfo(appUser); |
| | | // } |
| | | |
| | | @Override |
| | | public Map<String, Object> getUserInfo(TAppUser appUser) { |
| | |
| | | List<Site> sites = siteService.listByIds(ids); |
| | | return R.ok(sites); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取所有站点数据 |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getSiteAll") |
| | | public R<List<Site>> getSiteAll(){ |
| | | List<Site> list = siteService.list(new LambdaQueryWrapper<Site>().eq(Site::getDelFlag, 0)); |
| | | return R.ok(list); |
| | | } |
| | | } |
| | |
| | | return R.fail("excel导出失败!"); |
| | | } |
| | | try { |
| | | List<TApplyChargingPile> list = applyChargingPileService.lambdaQuery().list(); |
| | | List<TApplyChargingPile> list = applyChargingPileService.lambdaQuery().last("limit 1").list(); |
| | | |
| | | List<TApplyChargingPileExportDto> exportDtos =new ArrayList<>(); |
| | | for (TApplyChargingPile tApplyChargingPile : list) { |
| | |
| | | <if test="null != req.code and req.code!=''"> |
| | | and t1.code LIKE CONCAT('%',#{req.code},'%') |
| | | </if> |
| | | <if test="req.type != null and ·req.type != '' and req.type == 1"> |
| | | and t1.coupon_discount_amount != null and t1.coupon_discount_amount != 0 |
| | | <if test="req.type != null and req.type != '' and req.type == 1"> |
| | | and t1.coupon_discount_amount IS NOT NULL and t1.coupon_discount_amount != 0 |
| | | </if> |
| | | <if test="req.type != null and req.type != '' and req.type == 2"> |
| | | and t1.vip_discount_amount != null and t1.vip_discount_amount != 0 |
| | | and t1.vip_discount_amount IS NOT NULL and t1.vip_discount_amount != 0 |
| | | </if> |
| | | <if test="null != req.userIds and req.userIds.size()>0" > |
| | | and t1.app_user_id in |
| | |
| | | and t2.code LIKE CONCAT('%',#{req.code},'%') |
| | | </if> |
| | | <if test="req.type != null and req.type != '' and req.type == 1"> |
| | | and t2.coupon_discount_amount != null and t1.coupon_discount_amount != 0 |
| | | and t2.coupon_discount_amount IS NOT NULL and t2.coupon_discount_amount != 0 |
| | | </if> |
| | | <if test="req.type != null and req.type != '' and req.type == 2"> |
| | | and t2.vip_discount_amount != null and t1.vip_discount_amount != 0 |
| | | and t2.vip_discount_amount IS NOT NULL and t2.vip_discount_amount != 0 |
| | | </if> |
| | | <if test="req.type == null "> |
| | | and t2.vip_discount_amount != null and t1.vip_discount_amount != 0 and t2.coupon_discount_amount != null and t1.coupon_discount_amount != 0 |
| | | and t2.vip_discount_amount IS NOT NULL and t2.vip_discount_amount != 0 and t2.coupon_discount_amount IS NOT NULL and t2.coupon_discount_amount != 0 |
| | | </if> |
| | | <if test="null != req.userIds and req.userIds.size()>0" > |
| | | and t2.app_user_id in |
| | |
| | | 3 as orderType |
| | | from t_vip_order t3 |
| | | where 1 = 1 |
| | | and t3.type ==1 |
| | | and t3.type =1 |
| | | <if test="null != req.code and req.code!=''"> |
| | | and t3.code LIKE CONCAT('%',#{req.code},'%') |
| | | </if> |
| | | <if test="req.type == null "> |
| | | and t3.discount_amount != null and t3.discount_amount != 0 |
| | | and t3.discount_amount IS NOT NULL and t3.discount_amount != 0 |
| | | </if> |
| | | <if test="null != req.userIds and req.userIds.size()>0" > |
| | | and t3.app_user_id in |
| | |
| | | and t4.code LIKE CONCAT('%',#{req.code},'%') |
| | | </if> |
| | | <if test="req.type == null "> |
| | | and t4.discount_amount != null and t4.discount_amount != 0 |
| | | and t4.discount_amount IS NOT NULL and t4.discount_amount != 0 |
| | | </if> |
| | | <if test="null != req.userIds and req.userIds.size()>0" > |
| | | and t4.app_user_id in |
| | |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-common-swagger</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-chargingPile</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- 引入Druid依赖,阿里巴巴所提供的数据源 --> |
| | | <dependency> |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.chargingPile.api.feignClient.SiteClient; |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TRoleSite; |
| | | import com.ruoyi.other.service.TRoleSiteService; |
| | |
| | | @Resource |
| | | private TRoleSiteService roleSiteService; |
| | | |
| | | @Resource |
| | | private SiteClient siteClient; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询角色站点数据 |
| | | * @param roleId |
| | |
| | | @PostMapping("/getSiteIds/{roleId}") |
| | | public R<List<Integer>> getSiteIds(@PathVariable Long roleId){ |
| | | List<TRoleSite> list = roleSiteService.list(new LambdaQueryWrapper<TRoleSite>().eq(TRoleSite::getRoleId, roleId)); |
| | | if(list.size() == 1){ |
| | | Integer siteId = list.get(0).getSiteId(); |
| | | if(0 == siteId){ |
| | | List<Site> data = siteClient.getSiteAll().getData(); |
| | | List<Integer> collect = data.stream().map(Site::getId).collect(Collectors.toList()); |
| | | return R.ok(collect); |
| | | } |
| | | } |
| | | List<Integer> collect = list.stream().map(TRoleSite::getSiteId).collect(Collectors.toList()); |
| | | return R.ok(collect); |
| | | } |