ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserCarClient.java
@@ -26,7 +26,7 @@ * @param carIds 车辆id集合 * @return */ @PostMapping(value = "/t-app-user-car/getCarByIds") @PostMapping(value = "/t-app-user-car/t-app-user-car/getCarByIds") public R<List<TAppUserCar>> getCarByIds(@RequestBody List<Long> carIds); ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/PartnerFallbackFactory.java
New file @@ -0,0 +1,32 @@ package com.ruoyi.chargingPile.api.factory; import com.ruoyi.chargingPile.api.feignClient.PartnerClient; import com.ruoyi.chargingPile.api.model.Partner; import com.ruoyi.common.core.domain.R; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; /** * 充电桩服务降级处理 * * @author ruoyi */ @Component public class PartnerFallbackFactory implements org.springframework.cloud.openfeign.FallbackFactory<PartnerClient> { private static final Logger log = LoggerFactory.getLogger(PartnerFallbackFactory.class); @Override public PartnerClient create(Throwable throwable) { log.error("调用失败:{}", throwable.getMessage()); return new PartnerClient() { @Override public R<Partner> getPartnerById(Integer id) { return R.fail("根据id获取合作商信息失败:" + throwable.getMessage()); } }; } } ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/PartnerClient.java
New file @@ -0,0 +1,27 @@ package com.ruoyi.chargingPile.api.feignClient; import com.ruoyi.chargingPile.api.factory.PartnerFallbackFactory; import com.ruoyi.chargingPile.api.model.Partner; import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.domain.AjaxResult; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; /** * @author zhibing.pu * @Date 2024/9/30 9:36 */ @FeignClient(contextId = "PartnerClient", value = ServiceNameConstants.CHARGINGPILE_SERVICE, fallbackFactory = PartnerFallbackFactory.class) public interface PartnerClient { /** * 根据id获取合作商信息 * @param id * @return */ @PostMapping("/partner/getPartnerById/{id}") R<Partner> getPartnerById(@PathVariable("id") Integer id); } ruoyi-api/ruoyi-api-chargingPile/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -6,3 +6,4 @@ com.ruoyi.chargingPile.api.factory.AccountingStrategyFallbackFactory com.ruoyi.chargingPile.api.factory.ParkingRecordFallbackFactory com.ruoyi.chargingPile.api.factory.FaultMessageFallbackFactory com.ruoyi.chargingPile.api.factory.PartnerFallbackFactory ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ShoppingOrderFallbackFactory.java
New file @@ -0,0 +1,31 @@ package com.ruoyi.order.api.factory; import com.ruoyi.order.api.feignClient.ShoppingOrderClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; /** * 充电订单服务降级处理 * * @author ruoyi */ @Component public class ShoppingOrderFallbackFactory implements org.springframework.cloud.openfeign.FallbackFactory<ShoppingOrderClient> { private static final Logger log = LoggerFactory.getLogger(ShoppingOrderFallbackFactory.class); @Override public ShoppingOrderClient create(Throwable cause) { log.error("调用失败:{}", cause.getMessage()); return new ShoppingOrderClient() { @Override public void cancelShoppingOrderWxRefund(String out_refund_no, String refund_id, String tradeState, String success_time) { log.error("商城订单去掉退款回调通知失败:" + cause.getMessage()); } }; } } ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ShoppingOrderClient.java
New file @@ -0,0 +1,29 @@ package com.ruoyi.order.api.feignClient; import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.order.api.factory.ShoppingOrderFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; /** * @author zhibing.pu * @Date 2024/9/29 16:23 */ @FeignClient(contextId = "ShoppingOrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = ShoppingOrderFallbackFactory.class) public interface ShoppingOrderClient { /** * 商城订单去掉退款回调通知 * @param out_refund_no * @param refund_id * @param tradeState * @param success_time */ @PostMapping("/t-shopping-order/cancelShoppingOrderWxRefund") void cancelShoppingOrderWxRefund(@RequestParam("out_refund_no") String out_refund_no, @RequestParam("refund_id") String refund_id, @RequestParam("tradeState") String tradeState, @RequestParam("success_time") String success_time); } ruoyi-api/ruoyi-api-order/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -4,3 +4,4 @@ com.ruoyi.order.api.factory.ChargingOrderAccountingStrategyFallbackFactory com.ruoyi.order.api.factory.AccountingStrategyDetailOrderFallbackFactory com.ruoyi.order.api.factory.AccountingStrategyOrderFallbackFactory com.ruoyi.order.api.factory.ShoppingOrderFallbackFactory ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysLoginLog.java
@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; @@ -66,6 +67,7 @@ @TableField("login_time") @ApiModelProperty(value = "登录时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime loginTime; /** * 登录状态(1=成功,2=失败) ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysLoginLogClient.java
@@ -21,6 +21,6 @@ * @param loginLog * @return */ @PostMapping("/saveLoginLog") @PostMapping("/sysLoginLog/saveLoginLog") R saveLoginLog(@RequestBody SysLoginLog loginLog); } ruoyi-auth/pom.xml
@@ -89,6 +89,10 @@ <artifactId>hutool-crypto</artifactId> <version>${hutool.version}</version> </dependency> <dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-api-chargingPile</artifactId> </dependency> </dependencies> ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java
@@ -3,6 +3,8 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import com.ruoyi.chargingPile.api.feignClient.PartnerClient; import com.ruoyi.chargingPile.api.model.Partner; import com.ruoyi.system.api.domain.SysRole; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.feignClient.SysUserClient; @@ -40,6 +42,12 @@ @Resource private SysUserClient userClient; @Resource private PartnerClient partnerClient; @PostMapping("login") @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 @@ -55,6 +63,10 @@ map.put("roleName",roles.get(0).getRoleName()); map.put("info", userInfo); if(userInfo.getSysUser().getRoleType() == 2){ Partner partner = partnerClient.getPartnerById(userInfo.getSysUser().getObjectId()).getData(); map.put("partnerName", partner.getName()); } // 修改用户最后登录时间 SysUser sysUser = new SysUser(); sysUser.setUserId(userInfo.getSysUser().getUserId()); ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java
@@ -60,12 +60,12 @@ /** * 登录成功状态 */ public static final String LOGIN_SUCCESS_STATUS = "0"; public static final String LOGIN_SUCCESS_STATUS = "1"; /** * 登录失败状态 */ public static final String LOGIN_FAIL_STATUS = "1"; public static final String LOGIN_FAIL_STATUS = "2"; /** * 登录成功 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
@@ -33,8 +33,7 @@ * @author ruoyi */ @Service public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService { public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService { @Autowired private SysRoleMapper roleMapper; @@ -55,8 +54,7 @@ */ @Override @DataScope(deptAlias = "d") public List<SysRole> selectRoleList(SysRole role) { public List<SysRole> selectRoleList(SysRole role) { return roleMapper.selectRoleList(role); } @@ -67,16 +65,12 @@ * @return 角色列表 */ @Override public List<SysRole> selectRolesByUserId(Long userId) { public List<SysRole> selectRolesByUserId(Long userId) { List<SysRole> userRoles = roleMapper.selectRolePermissionByUserId(userId); List<SysRole> roles = selectRoleAll(); for (SysRole role : roles) { for (SysRole userRole : userRoles) { if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) { for (SysRole role : roles) { for (SysRole userRole : userRoles) { if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) { role.setFlag(true); break; } @@ -92,14 +86,11 @@ * @return 权限列表 */ @Override public Set<String> selectRolePermissionByUserId(Long userId) { public Set<String> selectRolePermissionByUserId(Long userId) { List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId); Set<String> permsSet = new HashSet<>(); for (SysRole perm : perms) { if (StringUtils.isNotNull(perm)) { for (SysRole perm : perms) { if (StringUtils.isNotNull(perm)) { permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); } } @@ -112,8 +103,7 @@ * @return 角色列表 */ @Override public List<SysRole> selectRoleAll() { public List<SysRole> selectRoleAll() { return SpringUtils.getAopProxy(this).selectRoleList(new SysRole()); } @@ -124,8 +114,7 @@ * @return 选中角色ID列表 */ @Override public List<Long> selectRoleListByUserId(Long userId) { public List<Long> selectRoleListByUserId(Long userId) { return roleMapper.selectRoleListByUserId(userId); } @@ -136,8 +125,7 @@ * @return 角色对象信息 */ @Override public SysRole selectRoleById(Long roleId) { public SysRole selectRoleById(Long roleId) { return roleMapper.selectRoleById(roleId); } @@ -148,12 +136,10 @@ * @return 结果 */ @Override public boolean checkRoleNameUnique(SysRole role) { public boolean checkRoleNameUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -166,12 +152,10 @@ * @return 结果 */ @Override public boolean checkRoleKeyUnique(SysRole role) { public boolean checkRoleKeyUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey()); if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -183,10 +167,8 @@ * @param role 角色信息 */ @Override public void checkRoleAllowed(SysRole role) { if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) { public void checkRoleAllowed(SysRole role) { if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) { throw new ServiceException("不允许操作超级管理员角色"); } } @@ -197,15 +179,12 @@ * @param roleId 角色id */ @Override public void checkRoleDataScope(Long roleId) { if (!SysUser.isAdmin(SecurityUtils.getUserId())) { public void checkRoleDataScope(Long roleId) { if (!SysUser.isAdmin(SecurityUtils.getUserId())) { SysRole role = new SysRole(); role.setRoleId(roleId); List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role); if (StringUtils.isEmpty(roles)) { if (StringUtils.isEmpty(roles)) { throw new ServiceException("没有权限访问角色数据!"); } } @@ -218,8 +197,7 @@ * @return 结果 */ @Override public int countUserRoleByRoleId(Long roleId) { public int countUserRoleByRoleId(Long roleId) { return userRoleMapper.countUserRoleByRoleId(roleId); } @@ -231,8 +209,7 @@ */ @Override @Transactional(rollbackFor = Exception.class) public int insertRole(SysRole role) { public int insertRole(SysRole role) { // 新增角色信息 roleMapper.insertRole(role); return insertRoleMenu(role); @@ -246,8 +223,7 @@ */ @Override @Transactional(rollbackFor = Exception.class) public int updateRole(SysRole role) { public int updateRole(SysRole role) { // 修改角色信息 // roleMapper.updateRole(role); // 删除角色与菜单关联 @@ -262,8 +238,7 @@ * @return 结果 */ @Override public int updateRoleStatus(SysRole role) { public int updateRoleStatus(SysRole role) { return roleMapper.updateRole(role); } @@ -275,8 +250,7 @@ */ @Override @Transactional(rollbackFor = Exception.class) public int authDataScope(SysRole role) { public int authDataScope(SysRole role) { // 修改角色信息 roleMapper.updateRole(role); // 删除角色与部门关联 @@ -290,8 +264,7 @@ * * @param role 角色对象 */ public int insertRoleMenu(SysRole role) { public int insertRoleMenu(SysRole role) { int rows = 1; // 新增用户与角色管理 List<SysRoleMenu> list = new ArrayList<SysRoleMenu>(); @@ -310,15 +283,13 @@ longs.add(1203L); } for (Long menuId : longs) { for (Long menuId : longs) { SysRoleMenu rm = new SysRoleMenu(); rm.setRoleId(role.getRoleId()); rm.setMenuId(menuId); list.add(rm); } if (list.size() > 0) { if (list.size() > 0) { rows = roleMenuMapper.batchRoleMenu(list); } return rows; @@ -329,20 +300,17 @@ * * @param role 角色对象 */ public int insertRoleDept(SysRole role) { public int insertRoleDept(SysRole role) { int rows = 1; // 新增角色与部门(数据权限)管理 List<SysRoleDept> list = new ArrayList<SysRoleDept>(); for (Long deptId : role.getDeptIds()) { for (Long deptId : role.getDeptIds()) { SysRoleDept rd = new SysRoleDept(); rd.setRoleId(role.getRoleId()); rd.setDeptId(deptId); list.add(rd); } if (list.size() > 0) { if (list.size() > 0) { rows = roleDeptMapper.batchRoleDept(list); } return rows; @@ -356,8 +324,7 @@ */ @Override @Transactional(rollbackFor = Exception.class) public int deleteRoleById(Long roleId) { public int deleteRoleById(Long roleId) { // 删除角色与菜单关联 roleMenuMapper.deleteRoleMenuByRoleId(roleId); // 删除角色与部门关联 @@ -374,13 +341,11 @@ @Override @Transactional(rollbackFor = Exception.class) public int deleteRoleByIds(Long[] roleIds) { for (Long roleId : roleIds) { for (Long roleId : roleIds) { checkRoleAllowed(new SysRole(roleId)); checkRoleDataScope(roleId); SysRole role = selectRoleById(roleId); if (countUserRoleByRoleId(roleId) > 0) { if (countUserRoleByRoleId(roleId) > 0) { throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName())); } } @@ -398,8 +363,7 @@ * @return 结果 */ @Override public int deleteAuthUser(SysUserRole userRole) { public int deleteAuthUser(SysUserRole userRole) { return userRoleMapper.deleteUserRoleInfo(userRole); } @@ -411,8 +375,7 @@ * @return 结果 */ @Override public int deleteAuthUsers(Long roleId, Long[] userIds) { public int deleteAuthUsers(Long roleId, Long[] userIds) { return userRoleMapper.deleteUserRoleInfos(roleId, userIds); } @@ -424,12 +387,10 @@ * @return 结果 */ @Override public int insertAuthUsers(Long roleId, Long[] userIds) { public int insertAuthUsers(Long roleId, Long[] userIds) { // 新增用户与角色管理 List<SysUserRole> list = new ArrayList<SysUserRole>(); for (Long userId : userIds) { for (Long userId : userIds) { SysUserRole ur = new SysUserRole(); ur.setUserId(userId); ur.setRoleId(roleId); @@ -445,6 +406,7 @@ /** * 根据id获取数据 * * @param ids 数据id集合 * @return */ ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java
@@ -223,6 +223,7 @@ */ @PostMapping("/grantCoupon") public R grantCoupon(@RequestBody GrantCouponDto dto){ dto.setWaysToObtain(3); List<TAppCoupon> res = new ArrayList<>(); TCoupon coupon = otherClient.getCouponById(dto.getCouponId()).getData(); @@ -246,9 +247,20 @@ break; case 2: // 根据市codes 查询用户ids List<Long> collect1 = appUserService.list(new QueryWrapper<TAppUser>() List<Long> collect1 = new ArrayList<>(); // 根据市codes 查询用户ids if (StringUtils.hasLength(dto.getProvinceCode())){ List<Long> collect2 = appUserService.list(new QueryWrapper<TAppUser>() .in("province_code", Arrays.asList(dto.getProvinceCode().split(",")))) .stream().map(TAppUser::getId).collect(Collectors.toList()); collect1.addAll(collect2); } if (StringUtils.hasLength(dto.getCityCode())){ List<Long> collect2 = appUserService.list(new QueryWrapper<TAppUser>() .in("city_code", Arrays.asList(dto.getCityCode().split(",")))) .stream().map(TAppUser::getId).collect(Collectors.toList()); collect1.addAll(collect2); } for (Long l : collect1) { TAppCoupon tAppCoupon = new TAppCoupon(); tAppCoupon.setAppUserId(l); ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TInvoiceInformationController.java
@@ -39,7 +39,8 @@ @ApiOperation(value = "获取开票抬头数据列表", tags = {"小程序-充电发票"}) public AjaxResult<List<InvoiceInformationVo>> getInvoiceInformationList(){ Long userId = tokenService.getLoginUserApplet().getUserId(); List<TInvoiceInformation> list = invoiceInformationService.list(new LambdaQueryWrapper<TInvoiceInformation>().eq(TInvoiceInformation::getAppUserId, userId).eq(TInvoiceInformation::getDelFlag, 0)); List<TInvoiceInformation> list = invoiceInformationService.list(new LambdaQueryWrapper<TInvoiceInformation>() .eq(TInvoiceInformation::getAppUserId, userId).eq(TInvoiceInformation::getDelFlag, 0).orderByDesc(TInvoiceInformation::getIsDefault)); List<InvoiceInformationVo> lists = new ArrayList<>(); for (TInvoiceInformation tInvoiceInformation : list) { InvoiceInformationVo vo = new InvoiceInformationVo(); ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/PartnerController.java
@@ -148,4 +148,14 @@ } /** * 根据id获取合作商信息 * @param id * @return */ @PostMapping("/getPartnerById/{id}") public R<Partner> getPartnerById(@PathVariable("id") Integer id){ Partner partner = partnerService.getPartner(id); return R.ok(partner); } } ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
@@ -164,6 +164,8 @@ PageInfo<GetSiteListDTO> list = siteService.getSiteList(siteList); return AjaxResult.success(list); } @GetMapping("/getSiteList/byUserId") @ApiOperation(value = "获取站点列表", tags = {"管理后台-站点管理"}) public R<List<GetSiteListDTO>> getSiteListByUserId(@RequestParam("userId") Long userId){ @@ -424,7 +426,7 @@ @ResponseBody @PostMapping("/getSiteByIds") public R<List<Site>> getSiteByIds(@RequestBody List<Integer> ids){ List<Site> sites = siteService.listByIds(ids); List<Site> sites = siteService.list(new LambdaQueryWrapper<Site>().in(Site::getId, ids).eq(Site::getDelFlag, 0)); return R.ok(sites); } ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/PartnerServiceImpl.java
@@ -94,10 +94,10 @@ List<SysRole> data = r.getData(); for (PartnerListDTO partnerListDTO : list) { Integer roleId = partnerListDTO.getRoleId(); if(null != roleId){ if(null == roleId){ continue; } SysRole sysRole = data.stream().filter(s -> roleId.equals(s.getRoleId())).findFirst().get(); SysRole sysRole = data.stream().filter(s -> roleId.compareTo(s.getRoleId().intValue()) == 0).findFirst().get(); if(null != sysRole){ partnerListDTO.setRoleName(sysRole.getRoleName()); } @@ -286,12 +286,12 @@ //站点 long count = siteService.count(new LambdaQueryWrapper<Site>().in(Site::getPartnerId, Arrays.asList(ids)).eq(Site::getDelFlag, 0)); if(count > 0){ return AjaxResult.error("当前合作商有关联站点,删除失败!"); return AjaxResult.error("该合作商已关联站点不可删除!"); } //充电桩 long count1 = chargingPileService.count(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getPartnerId, Arrays.asList(ids)).eq(TChargingPile::getDelFlag, 0)); long count1 = chargingPileService.count(new LambdaQueryWrapper<TChargingPile>().in(TChargingPile::getPartnerId, Arrays.asList(ids)).eq(TChargingPile::getDelFlag, 0)); if(count1 > 0){ return AjaxResult.error("当前合作商有关联充电桩,删除失败!"); return AjaxResult.error("该合作商已关联充电桩不可删除!"); } for (Integer id : ids) { Partner partner = this.getById(id); ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingGunServiceImpl.java
@@ -111,7 +111,7 @@ return ajaxResult; } long count = this.count(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, dto.getCode()) .eq(TChargingGun::getDelFlag, 0)); .eq(TChargingGun::getDelFlag, 0).eq(TChargingGun::getChargingPileId, dto.getChargingPileId())); if(count > 0){ return AjaxResult.error("接口编码已存在"); } @@ -136,7 +136,7 @@ return ajaxResult; } TChargingGun one = this.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, dto.getCode()) .eq(TChargingGun::getDelFlag, 0)); .eq(TChargingGun::getDelFlag, 0).eq(TChargingGun::getChargingPileId, dto.getChargingPileId())); if(null != one && !dto.getId().equals(one.getId())){ return AjaxResult.error("接口编码已存在"); } ruoyi-service/ruoyi-chargingPile/src/main/resources/bootstrap.yml
@@ -46,7 +46,7 @@ enabled: true application-id: ${spring.application.name} tx-service-group: seata_tx_group #此处配置自定义的seata事务分组名称 enable-auto-data-source-proxy: true enable-auto-data-source-proxy: false service: vgroup-mapping: seata_tx_group: default ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/SiteMapper.xml
@@ -61,7 +61,7 @@ a.phone, a.service_phone as servicePhone, a.parking_space as parkingSpace, DATE_FORMAT('%Y-%m-%d %H:%i:%s', a.establishment_time) as establishmentTime, DATE_FORMAT(a.establishment_time, '%Y-%m-%d %H:%i:%s') as establishmentTime, c.num as chargingPileNumber, a.sort, a.accounting_strategy_id as accountingStrategyId, ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TExchangeOrderController.java
@@ -202,14 +202,16 @@ for (int i = 0; i < split1.length; i++) { Integer reduce = tShoppingOrderService.list(new QueryWrapper<TShoppingOrder>() .eq("order_type",1) .ne("refund_status", 2)) .eq("goods_id", split1[i]) .isNull("refund_status")) .stream().map(TShoppingOrder::getPurchaseQuantity).reduce(0, Integer::sum); res.add(reduce); } break; case 2: for (int i = 0; i < split1.length; i++) { Integer reduce = exchangeOrderService.list(new QueryWrapper<TExchangeOrder>().eq("order_type",1).ne("status",4).eq("goods_id", split1[i])) Integer reduce = exchangeOrderService.list(new QueryWrapper<TExchangeOrder>().eq("order_type",1) .ne("status",4).eq("goods_id", split1[i])) .stream().map(TExchangeOrder::getPurchaseQuantity).reduce(0, Integer::sum); res.add(reduce); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TShoppingOrderController.java
@@ -281,11 +281,11 @@ public AjaxResult<Map<String, Object>> getMyShoppingOrderListNum() { Long userId = tokenService.getLoginUserApplet().getUserId(); long dfh = shoppingOrderService.count(new LambdaQueryWrapper<TShoppingOrder>().eq(TShoppingOrder::getDelFlag, 0) .eq(TShoppingOrder::getStatus, 1).eq(TShoppingOrder::getAppUserId, userId)); .eq(TShoppingOrder::getStatus, 1).eq(TShoppingOrder::getAppUserId, userId).eq(TShoppingOrder::getPaymentStatus, 2)); long dsh = shoppingOrderService.count(new LambdaQueryWrapper<TShoppingOrder>().eq(TShoppingOrder::getDelFlag, 0) .eq(TShoppingOrder::getStatus, 2).eq(TShoppingOrder::getAppUserId, userId)); .eq(TShoppingOrder::getStatus, 2).eq(TShoppingOrder::getAppUserId, userId).eq(TShoppingOrder::getPaymentStatus, 2)); long ywc = shoppingOrderService.count(new LambdaQueryWrapper<TShoppingOrder>().eq(TShoppingOrder::getDelFlag, 0) .eq(TShoppingOrder::getStatus, 3).eq(TShoppingOrder::getAppUserId, userId)); .eq(TShoppingOrder::getStatus, 3).eq(TShoppingOrder::getAppUserId, userId).eq(TShoppingOrder::getPaymentStatus, 2)); Map<String, Object> map = new HashMap<>(); map.put("dfh", dfh); map.put("dsh", dsh); @@ -316,6 +316,7 @@ return AjaxResult.error("订单已取消,不允许操作。"); } shoppingOrder.setStatus(3); shoppingOrder.setReceivingTime(LocalDateTime.now()); shoppingOrderService.updateById(shoppingOrder); return AjaxResult.success(); } @@ -331,15 +332,11 @@ * 商城订单取消微信退款回调 */ @PostMapping("/cancelShoppingOrderWxRefund") public void cancelShoppingOrderWxRefund(HttpServletRequest request) { // WxRefundNotifyResp data = wxPaymentClient.refundNotify(request).getData(); // if (null != data) { // String out_refund_no = data.getOut_refund_no(); // String refund_id = data.getRefund_id(); // String tradeState = data.getTradeState(); // String success_time = data.getSuccess_time(); // shoppingOrderService.cancelShoppingOrderWxRefund(out_refund_no, refund_id, tradeState, success_time); // } public void cancelShoppingOrderWxRefund(@RequestParam("out_refund_no") String out_refund_no, @RequestParam("refund_id") String refund_id, @RequestParam("tradeState") String tradeState, @RequestParam("success_time") String success_time) { shoppingOrderService.cancelShoppingOrderWxRefund(out_refund_no, refund_id, tradeState, success_time); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderInvoiceServiceImpl.java
@@ -119,13 +119,17 @@ } SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); String code = Double.valueOf(Math.random() * 1000).intValue() + sdf.format(new Date()); //获取开票类型 TInvoiceType invoiceType = invoiceTypeClient.getInvoiceType(addOrderInvoice.getInvoiceTypeId()).getData(); addOrderInvoice.setInvoicingCompany(invoiceType.getInvoicingCompany()); addOrderInvoice.setInvoiceType(invoiceType.getName()); addOrderInvoice.setInvoiceMaterial(2); addOrderInvoice.setInvoicingMethod(invoiceType.getInvoicingMethod()); addOrderInvoice.setAppUserId(userId); addOrderInvoice.setCode(code); addOrderInvoice.setStatus(1); addOrderInvoice.setCreateTime(LocalDateTime.now()); this.save(addOrderInvoice); //获取开票类型 TInvoiceType invoiceType = invoiceTypeClient.getInvoiceType(addOrderInvoice.getInvoiceTypeId()).getData(); for (Long orderId : orderIds) { List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.list(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>() .eq(TChargingOrderAccountingStrategy::getChargingOrderId, orderId)); @@ -263,14 +267,14 @@ List<TOrderInvoiceVO> list = this.baseMapper.pageList(query,pageInfo); for (TOrderInvoiceVO tOrderInvoiceVO : list) { tOrderInvoiceVO.setUid(tOrderInvoiceVO.getId().toString()); List<Long> collect = orderInvoiceDetailService.lambdaQuery().eq(TOrderInvoiceDetail::getOrderInvoiceId, tOrderInvoiceVO.getId()) .eq(TOrderInvoiceDetail::getOrderType, 1).list().stream() List<Long> collect = orderInvoiceDetailService.lambdaQuery().eq(TOrderInvoiceDetail::getOrderInvoiceId, tOrderInvoiceVO.getId()).list().stream() .map(TOrderInvoiceDetail::getOrderId).collect(Collectors.toList()); // 将其全部转化为String tOrderInvoiceVO.setIds(collect.stream().map(String::valueOf).collect(Collectors.toList())); } // 查询这个开票的订单ids if (!list.isEmpty()){ List<Long> ids = list.stream().map(TOrderInvoiceVO::getId).collect(Collectors.toList()); List<TOrderInvoiceDetail> orderInvoiceDetailList = orderInvoiceDetailService.list(new LambdaQueryWrapper<TOrderInvoiceDetail>() @@ -278,16 +282,22 @@ List<TAppUser> finalTAppUsers = tAppUsers; list.forEach(e->{ if (e.getOrderType()!=null&&e.getOrderType()==1){ e.setServiceTariff(orderInvoiceDetailList.get(0).getServiceTariff()); }else{ e.setServiceTariff(new BigDecimal("0")); } e.setElectricityTariff(orderInvoiceDetailList.get(0).getElectricityTariff()); e.setAddedServiceTariff(orderInvoiceDetailList.get(0).getAddedServiceTariff()); e.setAddedService(orderInvoiceDetailList.stream().filter(t->t.getAddedService()!=null).map(TOrderInvoiceDetail::getAddedService).reduce(BigDecimal::add).get()); e.setElectrovalence(orderInvoiceDetailList.stream().filter(t->t.getElectrovalence()!=null).map(TOrderInvoiceDetail::getElectrovalence).reduce(BigDecimal::add).get()); e.setServiceCharge(orderInvoiceDetailList.stream().filter(t->t.getServiceCharge()!=null).map(TOrderInvoiceDetail::getServiceCharge).reduce(BigDecimal::add).get()); if (e.getBillingUserId()!=null){ e.setUserPhone(finalTAppUsers.stream().filter(t->t.getId()!=null).filter(m->m.getId().equals(Long.parseLong(e.getAppUserId().toString()))).findFirst().get().getPhone()); e.setUserPhone(finalTAppUsers.stream().filter(t->t.getId()!=null).filter(m->m.getId().equals(Long.parseLong(e.getBillingUserId().toString()))).findFirst().get().getPhone()); } }); } pageInfo.setRecords(list); return pageInfo; ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java
@@ -202,7 +202,7 @@ public Map<String, Object> getMyShoppingOrderList(GetMyShoppingOrderList query) { Long userId = tokenService.getLoginUserApplet().getUserId(); LambdaQueryWrapper<TShoppingOrder> wrapper = new LambdaQueryWrapper<TShoppingOrder>().eq(TShoppingOrder::getDelFlag, 0) .eq(TShoppingOrder::getAppUserId, userId); .eq(TShoppingOrder::getAppUserId, userId).eq(TShoppingOrder::getPaymentStatus, 2); if(query.getStatus() != 0){ wrapper.eq(TShoppingOrder::getStatus, query.getStatus()); } @@ -255,7 +255,7 @@ TAppUserAddress userAddress = appUserAddressClient.getAppUserAddressById(shoppingOrder.getAppUserAddressId()).getData(); info.setConsignee(userAddress.getName()); info.setPhone(userAddress.getPhone()); info.setAddress(userAddress.getAddress()); info.setAddress(userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getAddress()); info.setExpressCompany(shoppingOrder.getExpressCompany()); info.setExpressNumber(shoppingOrder.getExpressNumber()); String name = ""; @@ -364,6 +364,9 @@ shoppingOrderRefund.setRefundRemark("全额退款"); shoppingOrderRefund.setRefundTotalAmount(refundAmount.add(bigDecimal)); shoppingOrderRefund.setPayAmount(shoppingOrder.getPaymentAmount()); shoppingOrder.setCancellationTime(LocalDateTime.now()); shoppingOrder.setCancellationId(shoppingOrder.getAppUserId()); if(1 == paymentType){ WxPaymentRefundModel model = new WxPaymentRefundModel(); model.setOut_trade_no(shoppingOrder.getCode()); @@ -378,6 +381,7 @@ model.setAmount(amount); R<String> orderR = wxPaymentClient.refundOrderR(model); if(200 == orderR.getCode()){ this.updateById(shoppingOrder); shoppingOrderRefundService.save(shoppingOrderRefund); } } @@ -389,49 +393,9 @@ dto.setRefundReason("取消订单"); RefundResp resp = aliPaymentClient.refund(dto).getData(); if(null != resp){ this.updateById(shoppingOrder); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-DDTHH:mm:ss+TIMEZONE"); AjaxResult success = cancelShoppingOrderWxRefund(resp.getOutTradeNo(), resp.getTradeNo(), "SUCCESS", sdf1.format(new Date())); if(success.isSuccess()){ shoppingOrderRefundService.save(shoppingOrderRefund); //商品 if(shoppingOrder.getOrderType() == 1){ //redis锁 和支付使用同一个锁 RedisLock redisLock = new RedisLock(redisTemplate, "SHOPPING_GOODS_LOCK", 5, 30000); try { redisLock.lock(); TGoods goods = goodsClient.getGoodsById(shoppingOrder.getGoodsId()).getData(); Integer inventory = goods.getInventory(); if(-1 != inventory){ goods.setInventory(inventory + shoppingOrder.getPurchaseQuantity()); goodsClient.updateGoods(goods); } }catch (Exception e){ e.printStackTrace(); }finally { //解锁 redisLock.unlock(); } } //优惠券 if(shoppingOrder.getOrderType() == 2){ //redis锁 和支付使用同一个锁 RedisLock redisLock = new RedisLock(redisTemplate, "SHOPPING_COUPON_LOCK", 5, 30000); try { redisLock.lock(); TCoupon coupon = couponClient.getCouponById1(shoppingOrder.getCouponId()).getData(); Integer inventory = coupon.getInventoryQuantity(); if(-1 != inventory){ coupon.setInventoryQuantity(inventory + shoppingOrder.getPurchaseQuantity()); couponClient.updateCoupon(coupon); } }catch (Exception e){ e.printStackTrace(); }finally { //解锁 redisLock.unlock(); } } } } } return AjaxResult.success(); @@ -457,6 +421,13 @@ shoppingOrderRefundService.updateById(one); //判断是否需要回退库存 TShoppingOrder shoppingOrder = this.getById(one.getShoppingOrderId()); shoppingOrder.setStatus(4); shoppingOrder.setRefundCode(one.getRefundSerialNumber()); shoppingOrder.setRefundAmount(one.getRefundAmount()); shoppingOrder.setRefundStatus(2); shoppingOrder.setRefundTime(one.getRefundTime()); this.updateById(shoppingOrder); //商品 if(shoppingOrder.getOrderType() == 1){ //redis锁 和支付使用同一个锁 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -62,7 +62,7 @@ </if> </select> <select id="getNoInvoicedOrder" resultMap="BaseResultMap"> select * from t_charging_order where del_flag = 0 and app_user_id = #{appUserId} select * from t_charging_order where del_flag = 0 and status = 5 and recharge_payment_status = 2 and payment_amount is null and app_user_id = #{appUserId} <if test="null != month and '' != month"> and DATE_FORMAT(end_time, '%Y-%m') = #{month} </if> ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TExchangeOrderMapper.xml
@@ -37,23 +37,33 @@ <if test="null != req.code and req.code!=''"> and t1.code LIKE CONCAT('%',#{req.code},'%') </if> <if test="null != req.status"> and t1.status = #{req.status} </if> <if test="null != req.userIds and req.userIds.size()>0" > and t1.app_user_id in <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </if> <if test="null != req.couponIds and req.couponIds.size()>0 or null != req.couponIds and req.couponIds.size()>0" > and (t1.goods_id in <foreach collection="req.goodsIds" item="item" index="index" separator="," open="(" close=")"> <if test="null != req.userIds and req.userIds.size()>0" > and t1.app_user_id in <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> or </if> <if test="null != req.couponIds and req.couponIds.size()>0" > and t1.coupon_id in <foreach collection="req.couponIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> ) </if> <if test="null != req.goodsIds and req.goodsIds.size()>0" > and t1.goods_id in <foreach collection="req.goodsIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </if> <if test="startTime1 != null and startTime1!=''"> and (t1.create_time between #{startTime1} and #{startTime2}) ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml
@@ -214,7 +214,7 @@ <select id="getNoInvoicedOrder" resultMap="BaseResultMap"> select * from t_shopping_order where del_flag = 0 and app_user_id = #{appUserId} select * from t_shopping_order where del_flag = 0 and payment_status = 2 and status = 3 and app_user_id = #{appUserId} <if test="null != month and '' != month"> and DATE_FORMAT(create_time, '%Y-%m') = #{month} </if> @@ -231,6 +231,9 @@ <if test="null != req.code and req.code!=''"> and t1.code LIKE CONCAT('%',#{req.code},'%') </if> <if test="null != req.status"> and t1.status = #{req.status} </if> <if test="null != req.userIds and req.userIds.size()>0" > and t1.app_user_id in <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")"> @@ -238,17 +241,17 @@ </foreach> </if> <if test="null != req.couponIds and req.couponIds.size()>0 or null != req.couponIds and req.couponIds.size()>0" > and (t1.goods_id in <foreach collection="req.goodsIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> or <if test="null != req.couponIds and req.couponIds.size()>0" > and t1.coupon_id in <foreach collection="req.couponIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> ) </if> <if test="null != req.goodsIds and req.goodsIds.size()>0" > and t1.goods_id in <foreach collection="req.goodsIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </if> <if test="startTime1 != null and startTime1!=''"> and (t1.create_time between #{startTime1} and #{startTime2}) ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TVipOrderMapper.xml
@@ -42,7 +42,7 @@ and t1.vip_id = #{req.vipId} </if> <if test="startTime1 != null and startTime1!=''"> and (t1.create_time between #{startTime1} and #{startTime2} and t1.create_time between #{startTime1} and #{startTime2} </if> and t1.payment_status = 2 AND t1.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/controller/WxPayController.java
@@ -5,6 +5,7 @@ import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.order.api.feignClient.ChargingOrderClient; import com.ruoyi.order.api.feignClient.OrderClient; import com.ruoyi.order.api.feignClient.ShoppingOrderClient; import com.ruoyi.payment.api.vo.PaymentOrder; import com.ruoyi.payment.api.vo.WxRefundNotifyResp; import com.ruoyi.payment.wx.enums.RefundEnum; @@ -41,6 +42,9 @@ @Resource private ChargingOrderClient chargingOrderClient; @Resource private ShoppingOrderClient shoppingOrderClient; @@ -196,6 +200,10 @@ chargingOrderClient.chargingOrderStartupFailureWxRefund(out_refund_no, refund_id, tradeState, success_time); System.err.println("----充电启动失败退款回调通知"); break; case "GDF": shoppingOrderClient.cancelShoppingOrderWxRefund(out_refund_no, refund_id, tradeState, success_time); System.err.println("----商城订单取消退款回调通知"); break; //充电订单 case "GWF": chargingOrderClient.shoppingOrderWxRefund(out_refund_no, refund_id, tradeState, success_time);