Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile
| | |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-seata</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | import com.ruoyi.account.api.model.TAppUserAddress; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.dto.PointChangeDto; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | |
| | | @Override |
| | | public R<TAppUser> getUserById(Long id) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("根据id查询用户失败:"+throwable.getMessage()); |
| | | } |
| | | |
| | |
| | | return R.fail("修改用户失败:"+throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R change(PointChangeDto points) { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R changeDown(PointChangeDto points) { |
New file |
| | |
| | | package com.ruoyi.account.api.factory; |
| | | |
| | | import com.ruoyi.account.api.feignClient.AppUserTagClient; |
| | | import com.ruoyi.account.api.feignClient.InviteUserClient; |
| | | import com.ruoyi.account.api.model.TAppUserTag; |
| | | import com.ruoyi.account.api.model.TInviteUser; |
| | | import com.ruoyi.account.api.vo.GetInviteUser; |
| | | 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 AppUserTagFallbackFactory implements org.springframework.cloud.openfeign.FallbackFactory<AppUserTagClient> |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(AppUserTagFallbackFactory.class); |
| | | |
| | | @Override |
| | | public AppUserTagClient create(Throwable throwable) { |
| | | log.error("调用失败:{}", throwable.getMessage()); |
| | | return new AppUserTagClient() { |
| | | |
| | | |
| | | @Override |
| | | public R<TAppUserTag> getUserTag(TAppUserTag appUserTag) { |
| | | return R.fail("获取用户标签关系失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public void addUserTag(TAppUserTag appUserTag) { |
| | | |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.api.vo.GetAppUserVipDetail; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | |
| | | @Override |
| | | public R<TAppUserVipDetail> getAppUserVipDetail(GetAppUserVipDetail getAppUserVipDetail) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("获取用户当前有效的VIP明细调用失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public void updateAppUserVipDetail(TAppUserVipDetail appUserVipDetail) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | R.fail(throwable.getMessage()); |
| | | } |
| | | }; |
| | |
| | | @PostMapping("/t-app-user/user/updateAppUser") |
| | | R updateAppUser(@RequestBody TAppUser appUser); |
| | | |
| | | @PostMapping("/t-app-user/user/points/change") |
| | | R change(@RequestBody PointChangeDto points); |
| | | // @PostMapping("/t-app-user/user/points/change") |
| | | // R change(@RequestBody PointChangeDto points); |
| | | @PostMapping("/t-app-user/user/points/change/down") |
| | | R changeDown(@RequestBody PointChangeDto points); |
| | | |
New file |
| | |
| | | package com.ruoyi.account.api.feignClient; |
| | | |
| | | import com.ruoyi.account.api.factory.AppUserTagFallbackFactory; |
| | | import com.ruoyi.account.api.model.TAppUserTag; |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/9/25 16:17 |
| | | */ |
| | | @FeignClient(contextId = "AppUserTagClient", value = ServiceNameConstants.ACCOUNT_SERVICE, fallbackFactory = AppUserTagFallbackFactory.class) |
| | | public interface AppUserTagClient { |
| | | |
| | | /** |
| | | * 获取用户标签关系 |
| | | * @param appUserTag |
| | | * @return |
| | | */ |
| | | @PostMapping(value = "/t-app-user-tag/tags/getUserTag") |
| | | R<TAppUserTag> getUserTag(@RequestBody TAppUserTag appUserTag); |
| | | |
| | | /** |
| | | * 添加用户标签关系数据 |
| | | * @param appUserTag |
| | | */ |
| | | @PostMapping(value = "/t-app-user-tag/tags/addUserTag") |
| | | void addUserTag(@RequestBody TAppUserTag appUserTag); |
| | | } |
| | |
| | | @TableField("code") |
| | | private String code; |
| | | |
| | | @ApiModelProperty(value = "对应跳转订单号") |
| | | @TableField("order_code") |
| | | private String orderCode; |
| | | @ApiModelProperty(value = "用户id") |
| | | @TableField("app_user_id") |
| | | private Long appUserId; |
| | |
| | | com.ruoyi.account.api.factory.AppUserAddressFallbackFactory |
| | | com.ruoyi.account.api.factory.AppUserVipDetailFallbackFactory |
| | | com.ruoyi.account.api.factory.InviteUserFallbackFactory |
| | | com.ruoyi.account.api.factory.AppUserTagFallbackFactory |
| | |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-seata</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | import com.ruoyi.chargingPile.api.feignClient.AccountingStrategyDetailClient; |
| | | import com.ruoyi.chargingPile.api.model.TAccountingStrategyDetail; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | |
| | | @Override |
| | | public R<List<TAccountingStrategyDetail>> getListByAccountingStrategyId(Integer id) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("根据计费策略主表id策略明细失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.chargingPile.api.feignClient.AccountingStrategyClient; |
| | | import com.ruoyi.chargingPile.api.model.TAccountingStrategy; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | |
| | | @Override |
| | | public R<TAccountingStrategy> getAccountingStrategyById(Integer id) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("根据id查询计费策略失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | |
| | | import com.ruoyi.chargingPile.api.model.TFaultMessage; |
| | | import com.ruoyi.chargingPile.api.vo.SiteNameVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | |
| | | @Override |
| | | public R<TChargingGun> getChargingGunById(Integer id) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("根据id获取充电枪失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<SiteInfoVO> getSiteInfoByNumber1(String number) { |
| | | return R.fail("通过桩编号获取电站信息失败:"+throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<TChargingPile> getChargingPileById(Integer id) { |
| | | return R.fail(throwable.getMessage()); |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | |
| | | @PostMapping(value = "/t-accounting-strategy/getServiceMoney") |
| | | R<BigDecimal> getServiceMoney(@RequestParam("param") String param); |
| | | |
| | | @PostMapping("/site/getSiteInfoByNumber") |
| | | @ApiOperation(value = "扫一扫后通过桩编号获取电站信息", tags = {"小程序-扫一扫"}) |
| | | @GetMapping("/site/getSiteInfoByNumber") |
| | | R<SiteInfoVO> getSiteInfoByNumber(@RequestParam("number") String number); |
| | | |
| | | @PostMapping("/site/getSiteInfoByNumber1") |
| | | R<SiteInfoVO> getSiteInfoByNumber1(@RequestParam("number") String number); |
| | | |
| | | |
| | | @PostMapping("/t-charging-pile/getChargingPileById/{id}") |
| | | R<TChargingPile> getChargingPileById(@PathVariable("id") Integer id); |
| | |
| | | private String spaceChargeExplain; |
| | | @ApiModelProperty(value = "添加车辆最高可得积分 车辆信息为空 展示提示语") |
| | | private Integer integral; |
| | | @ApiModelProperty(value = "充电模式(1=超级快充,2=快充,3=慢充") |
| | | private Integer chargeMode; |
| | | |
| | | @ApiModelProperty(value = "上次选择车辆logo") |
| | | private String carLogo; |
| | |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-seata</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | public R<String> platformRemoteUpdate(PlatformRemoteUpdate platformRemoteUpdate) { |
| | | return R.fail("远程更新调用失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> setupBillingModel1(String deviceId) { |
| | | return R.fail("远程更新硬件:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.integration.api.model.ChargingHandshake; |
| | | import com.ruoyi.integration.api.model.PlatformStartCharging; |
| | | import com.ruoyi.integration.api.model.PlatformStopCharging; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | |
| | | @Override |
| | | public String platformStartCharging(PlatformStartCharging platformStartCharging) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return "远程启机失败"; |
| | | } |
| | | |
| | | @Override |
| | | public String platformStopCharging(PlatformStopCharging platformStopCharging) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return "远程停机失败"; |
| | | } |
| | | }; |
| | |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-other</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-seata</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | public R<AccountingStrategyDetailOrder> getNowAccountingStrategyDetailOrder(Long orderId) { |
| | | return R.fail("根据订单id获取当前有效的策略失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<AccountingStrategyDetailOrder>> getAllAccountingStrategyDetailOrder(Long orderId) { |
| | | return R.fail("获取订单对应的计费策略数据失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.order.api.factory; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.api.feignClient.AccountingStrategyDetailOrderClient; |
| | | import com.ruoyi.order.api.feignClient.AccountingStrategyOrderClient; |
| | | import com.ruoyi.order.api.model.AccountingStrategyDetailOrder; |
| | | import com.ruoyi.order.api.model.AccountingStrategyOrder; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 充电订单服务降级处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class AccountingStrategyOrderFallbackFactory implements org.springframework.cloud.openfeign.FallbackFactory<AccountingStrategyOrderClient> |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(AccountingStrategyOrderFallbackFactory.class); |
| | | |
| | | @Override |
| | | public AccountingStrategyOrderClient create(Throwable throwable) { |
| | | log.error("调用失败:{}", throwable.getMessage()); |
| | | return new AccountingStrategyOrderClient() { |
| | | |
| | | |
| | | @Override |
| | | public R<AccountingStrategyOrder> getAccountingStrategyOrderById(Integer id) { |
| | | return R.fail("根据id获取计费策略失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.order.api.factory; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.dto.ExchangeBackDto; |
| | | import com.ruoyi.common.core.dto.ExchangeDto; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | | import com.ruoyi.order.api.model.ChargingListQuery; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<Long> exchangeCreate(ExchangeDto exchangeDto) { |
| | | public R<ExchangeBackDto> exchangeCreate(ExchangeDto exchangeDto) { |
| | | return R.fail("创建订单" + cause.getMessage()); |
| | | } |
| | | |
| | |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/9/4 16:11 |
| | |
| | | */ |
| | | @PostMapping("/accountingStrategyDetailOrder/getNowAccountingStrategyDetailOrder") |
| | | R<AccountingStrategyDetailOrder> getNowAccountingStrategyDetailOrder(@RequestParam("orderId") Long orderId); |
| | | |
| | | /** |
| | | * 获取订单对应的计费策略数据 |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | @PostMapping("/accountingStrategyDetailOrder/getAllAccountingStrategyDetailOrder") |
| | | R<List<AccountingStrategyDetailOrder>> getAllAccountingStrategyDetailOrder(@RequestParam("orderId") Long orderId); |
| | | } |
New file |
| | |
| | | package com.ruoyi.order.api.feignClient; |
| | | |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.api.factory.AccountingStrategyOrderFallbackFactory; |
| | | import com.ruoyi.order.api.model.AccountingStrategyOrder; |
| | | 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/26 9:09 |
| | | */ |
| | | @FeignClient(contextId = "AccountingStrategyOrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = AccountingStrategyOrderFallbackFactory.class) |
| | | public interface AccountingStrategyOrderClient { |
| | | |
| | | |
| | | /** |
| | | * 根据id获取数据 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/accountingStrategyOrder/getAccountingStrategyOrderById") |
| | | R<AccountingStrategyOrder> getAccountingStrategyOrderById(@RequestParam("id") Integer id); |
| | | } |
| | |
| | | |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.dto.ExchangeBackDto; |
| | | import com.ruoyi.common.core.dto.ExchangeDto; |
| | | import com.ruoyi.order.api.factory.OrderFallbackFactory; |
| | | import com.ruoyi.order.api.model.ChargingListQuery; |
| | |
| | | public R<Long> getExchangeById(@RequestParam("goodId") Integer goodId,@RequestParam("userId") Long userId,@RequestParam("goodType") Integer goodType); |
| | | |
| | | @PostMapping("/t-exchange-order/create") |
| | | public R<Long> exchangeCreate(@RequestBody ExchangeDto exchangeDto); |
| | | public R<ExchangeBackDto> exchangeCreate(@RequestBody ExchangeDto exchangeDto); |
| | | @PostMapping("/t-vip-order//addVipOrder") |
| | | public R<Long> addVipOrder(@RequestBody TVipOrder vipOrder); |
| | | @PostMapping("/t-shopping-order/create") |
| | |
| | | package com.ruoyi.order.api.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableField(value = "id") |
| | | @TableId(type = IdType.INPUT, value = "id") |
| | | private Integer id; |
| | | @ApiModelProperty(value = "策略id") |
| | | @TableField("accounting_strategy_id") |
| | | private Integer accountingStrategyId; |
| | | @TableField("accounting_strategy_order_id") |
| | | private Integer accountingStrategyOrderId; |
| | | |
| | | @ApiModelProperty(value = "阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段)") |
| | | @TableField("type") |
| | |
| | | @TableName("t_accounting_strategy_order") |
| | | public class AccountingStrategyOrder extends BasePojo { |
| | | |
| | | @ApiModelProperty(value = "策略id") |
| | | @TableId(type = IdType.INPUT, value = "id") |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(value = "站点id") |
| | | @TableField("site_id") |
| | | private Integer siteId; |
| | |
| | | import java.time.LocalDateTime; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import java.io.Serializable; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | |
| | | @ApiModelProperty(value = "退款成功时间") |
| | | @TableField("refund_time") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime refundTime; |
| | | |
| | | @ApiModelProperty(value = "订单编号") |
| | |
| | | private BigDecimal paymentAmount; |
| | | @ApiModelProperty(value = "支付时间") |
| | | @TableField(exist = false) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime payTime; |
| | | |
| | | |
| | | @ApiModelProperty(value = "订单id") |
| | | @TableField(exist = false) |
| | | private String orderId; |
| | | @TableField(exist = false) |
| | | private String userId; |
| | | } |
| | |
| | | com.ruoyi.order.api.factory.ExchangeOrderFallbackFactory |
| | | com.ruoyi.order.api.factory.ChargingOrderAccountingStrategyFallbackFactory |
| | | com.ruoyi.order.api.factory.AccountingStrategyDetailOrderFallbackFactory |
| | | com.ruoyi.order.api.factory.AccountingStrategyOrderFallbackFactory |
| | |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-account</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-seata</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.other.api.feignClient.CouponClient; |
| | | import com.ruoyi.other.api.feignClient.GoodsClient; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | |
| | | @Override |
| | | public R updateCoupon(TCoupon coupon) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("修改优惠券失败"); |
| | | } |
| | | }; |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.other.api.feignClient.GoodsClient; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | |
| | | @Override |
| | | public R updateGoods(TGoods goods) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("修改商品异常"); |
| | | } |
| | | }; |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TInvoiceType; |
| | | import com.ruoyi.other.api.feignClient.InvoiceTypeClient; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | |
| | | @Override |
| | | public R<TInvoiceType> getInvoiceType(Integer id) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail(throwable.getMessage()); |
| | | } |
| | | }; |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TUserSite; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | |
| | | @Override |
| | | public R addUserSite(List<TUserSite> userSite) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("添加用户站点失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R delUserSite(Long userId) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("删除用户站点失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
New file |
| | |
| | | package com.ruoyi.other.api.factory; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TUserTag; |
| | | import com.ruoyi.other.api.feignClient.UserTagClient; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * 商品服务降级处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class UserTagFallbackFactory implements org.springframework.cloud.openfeign.FallbackFactory<UserTagClient> { |
| | | private static final Logger log = LoggerFactory.getLogger(UserTagFallbackFactory.class); |
| | | |
| | | @Override |
| | | public UserTagClient create(Throwable throwable) { |
| | | log.error("调用失败:{}", throwable.getMessage()); |
| | | return new UserTagClient() { |
| | | |
| | | @Override |
| | | public R<List<TUserTag>> getAllUserTag() { |
| | | return R.fail("获取所有用户标签数据失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.other.api.feignClient; |
| | | |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TUserTag; |
| | | import com.ruoyi.other.api.factory.UserTagFallbackFactory; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/9/25 15:53 |
| | | */ |
| | | @FeignClient(contextId = "UserTagClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = UserTagFallbackFactory.class) |
| | | public interface UserTagClient { |
| | | |
| | | /** |
| | | * 获取所有用户标签数据 |
| | | * @return |
| | | */ |
| | | @PostMapping(value = "/t-user-tag/getAllUserTag") |
| | | R<List<TUserTag>> getAllUserTag(); |
| | | } |
| | |
| | | com.ruoyi.other.api.factory.CouponFallbackFactory |
| | | com.ruoyi.other.api.factory.InvoiceTypeFallbackFactory |
| | | com.ruoyi.other.api.factory.WebSocketFallbackFactory |
| | | com.ruoyi.other.api.factory.UserTagFallbackFactory |
| | |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-seata</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | import com.ruoyi.payment.api.vo.AliPaymentReq; |
| | | import com.ruoyi.payment.api.vo.AliPaymentResp; |
| | | import com.ruoyi.payment.api.vo.AliQueryOrder; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | |
| | | @Override |
| | | public R<AliPaymentResp> payment(AliPaymentReq req) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("调起支付宝小程序支付失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<AliQueryOrder> query(String outTradeNo) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("查询支付订单失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public void close(String outTradeNo) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | R.fail("关闭支付订单失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<RefundResp> refund(RefundReq dto) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("支付宝退款失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | |
| | | import com.ruoyi.payment.api.vo.NotifyV3PayDecodeRespBody; |
| | | import com.ruoyi.payment.api.vo.PaymentOrder; |
| | | import com.ruoyi.payment.api.vo.WxRefundNotifyResp; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | |
| | | @Override |
| | | public R<NotifyV3PayDecodeRespBody> queryOrderInfo(String orderId) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("查询支付订单信息失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<Map<String, Object>> orderPay(PaymentOrder paymentOrder) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("调起微信支付失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void close(String outTradeNo) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | R.fail("关闭支付订单失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> refundOrderR(WxPaymentRefundModel model) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("微信退款失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-seata</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.model.*; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | |
| | | @Override |
| | | public R<Boolean> updateSysUser(SysUser sysUser) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("更新用户失败:" + cause.getMessage()); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public R resetPassword(SysUser user) { |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return R.fail("重置用户密码失败:" + cause.getMessage()); |
| | | } |
| | | }; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class SysLoginService |
| | | { |
| | | public class SysLoginService { |
| | | @Autowired |
| | | private RemoteUserService remoteUserService; |
| | | |
| | |
| | | * 登录 |
| | | */ |
| | | public LoginUser login(String username, String password, HttpServletRequest request) { |
| | | username = username.trim(); |
| | | // 查询用户信息 |
| | | R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER); |
| | | |
| | | if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) |
| | | { |
| | | if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) { |
| | | recordLogService.recordLogininfor(request, null, username, Constants.LOGIN_FAIL_STATUS, "登录用户不存在"); |
| | | throw new ServiceException("登录用户:" + username + " 不存在"); |
| | | } |
| | |
| | | SysUser user = userResult.getData().getSysUser(); |
| | | |
| | | // 用户名或密码为空 错误 |
| | | if (StringUtils.isAnyBlank(username, password)) |
| | | { |
| | | if (StringUtils.isAnyBlank(username, password)) { |
| | | recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "用户/密码必须填写"); |
| | | throw new ServiceException("用户/密码必须填写"); |
| | | } |
| | | // 密码如果不在指定范围内 错误 |
| | | if (password.length() < UserConstants.PASSWORD_MIN_LENGTH |
| | | || password.length() > UserConstants.PASSWORD_MAX_LENGTH) |
| | | { |
| | | || password.length() > UserConstants.PASSWORD_MAX_LENGTH) { |
| | | recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "用户密码不在指定范围"); |
| | | throw new ServiceException("用户密码不在指定范围"); |
| | | } |
| | | // 用户名不在指定范围内 错误 |
| | | if (username.length() < UserConstants.USERNAME_MIN_LENGTH |
| | | || username.length() > UserConstants.USERNAME_MAX_LENGTH) |
| | | { |
| | | || username.length() > UserConstants.USERNAME_MAX_LENGTH) { |
| | | recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "用户名不在指定范围"); |
| | | throw new ServiceException("用户名不在指定范围"); |
| | | } |
| | | // IP黑名单校验 |
| | | String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST)); |
| | | if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) |
| | | { |
| | | if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) { |
| | | recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "很遗憾,访问IP已被列入系统黑名单"); |
| | | throw new ServiceException("很遗憾,访问IP已被列入系统黑名单"); |
| | | } |
| | | |
| | | if (R.FAIL == userResult.getCode()) |
| | | { |
| | | if (R.FAIL == userResult.getCode()) { |
| | | throw new ServiceException(userResult.getMsg()); |
| | | } |
| | | |
| | | |
| | | if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) |
| | | { |
| | | if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { |
| | | recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "对不起,您的账号已被删除"); |
| | | throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(user.getStatus())) |
| | | { |
| | | if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { |
| | | recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, "用户已停用,请联系管理员"); |
| | | throw new ServiceException("对不起,您的账号:" + username + " 已停用"); |
| | | } |
| | |
| | | return userInfo; |
| | | } |
| | | |
| | | public void logout(String loginName, HttpServletRequest request) |
| | | { |
| | | public void logout(String loginName, HttpServletRequest request) { |
| | | recordLogService.recordLogininfor(request, null, loginName, Constants.LOGIN_SUCCESS_STATUS, "退出成功"); |
| | | } |
| | | |
| | | /** |
| | | * 注册 |
| | | */ |
| | | public void register(String username, String password, HttpServletRequest request) |
| | | { |
| | | public void register(String username, String password, HttpServletRequest request) { |
| | | // 用户名或密码为空 错误 |
| | | if (StringUtils.isAnyBlank(username, password)) |
| | | { |
| | | if (StringUtils.isAnyBlank(username, password)) { |
| | | throw new ServiceException("用户/密码必须填写"); |
| | | } |
| | | if (username.length() < UserConstants.USERNAME_MIN_LENGTH |
| | | || username.length() > UserConstants.USERNAME_MAX_LENGTH) |
| | | { |
| | | || username.length() > UserConstants.USERNAME_MAX_LENGTH) { |
| | | throw new ServiceException("账户长度必须在2到20个字符之间"); |
| | | } |
| | | if (password.length() < UserConstants.PASSWORD_MIN_LENGTH |
| | | || password.length() > UserConstants.PASSWORD_MAX_LENGTH) |
| | | { |
| | | || password.length() > UserConstants.PASSWORD_MAX_LENGTH) { |
| | | throw new ServiceException("密码长度必须在5到20个字符之间"); |
| | | } |
| | | |
| | |
| | | sysUser.setPassword(SecurityUtils.encryptPassword(password)); |
| | | R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER); |
| | | |
| | | if (R.FAIL == registerResult.getCode()) |
| | | { |
| | | if (R.FAIL == registerResult.getCode()) { |
| | | throw new ServiceException(registerResult.getMsg()); |
| | | } |
| | | recordLogService.recordLogininfor(request, sysUser.getUserId().intValue(), username, Constants.LOGIN_SUCCESS_STATUS, "注册成功"); |
New file |
| | |
| | | package com.ruoyi.common.core.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ExchangeBackDto { |
| | | private Long id; |
| | | private String code; |
| | | } |
| | |
| | | private Integer points; |
| | | private String remark; |
| | | private Integer type; |
| | | private String code; |
| | | } |
| | |
| | | */ |
| | | @Aspect |
| | | @Component |
| | | public class LogAspect |
| | | { |
| | | public class LogAspect { |
| | | private static final Logger log = LoggerFactory.getLogger(LogAspect.class); |
| | | |
| | | /** 排除敏感属性字段 */ |
| | | /** |
| | | * 排除敏感属性字段 |
| | | */ |
| | | public static final String[] EXCLUDE_PROPERTIES = { "password", "oldPassword", "newPassword", "confirmPassword" }; |
| | | |
| | | /** 计算操作消耗时间 */ |
| | | /** |
| | | * 计算操作消耗时间 |
| | | */ |
| | | private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<Long>("Cost Time"); |
| | | |
| | | @Autowired |
| | |
| | | * 处理请求前执行 |
| | | */ |
| | | @Before(value = "@annotation(controllerLog)") |
| | | public void boBefore(JoinPoint joinPoint, Log controllerLog) |
| | | { |
| | | public void boBefore(JoinPoint joinPoint, Log controllerLog) { |
| | | TIME_THREADLOCAL.set(System.currentTimeMillis()); |
| | | } |
| | | |
| | |
| | | * @param joinPoint 切点 |
| | | */ |
| | | @AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult") |
| | | public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult) |
| | | { |
| | | public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult) { |
| | | handleLog(joinPoint, controllerLog, null, jsonResult); |
| | | } |
| | | |
| | |
| | | * @param e 异常 |
| | | */ |
| | | @AfterThrowing(value = "@annotation(controllerLog)", throwing = "e") |
| | | public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e) |
| | | { |
| | | public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e) { |
| | | handleLog(joinPoint, controllerLog, e, null); |
| | | } |
| | | |
| | | protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) |
| | | { |
| | | try |
| | | { |
| | | protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) { |
| | | try { |
| | | // *========数据库日志=========*// |
| | | SysOperLog operLog = new SysOperLog(); |
| | | operLog.setStatus(BusinessStatus.SUCCESS.ordinal()); |
| | |
| | | operLog.setOperIp(ip); |
| | | operLog.setOperUrl(StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255)); |
| | | String username = SecurityUtils.getUsername(); |
| | | if (StringUtils.isNotBlank(username)) |
| | | { |
| | | if (StringUtils.isNotBlank(username)) { |
| | | operLog.setOperName(username); |
| | | } |
| | | |
| | | if (e != null) |
| | | { |
| | | if (e != null) { |
| | | operLog.setStatus(BusinessStatus.FAIL.ordinal()); |
| | | operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000)); |
| | | } |
| | |
| | | operLog.setCostTime(System.currentTimeMillis() - TIME_THREADLOCAL.get()); |
| | | // 保存数据库 |
| | | asyncLogService.saveSysLog(operLog); |
| | | } |
| | | catch (Exception exp) |
| | | { |
| | | } catch (Exception exp) { |
| | | // 记录本地异常日志 |
| | | log.error("异常信息:{}", exp.getMessage()); |
| | | exp.printStackTrace(); |
| | | } |
| | | finally |
| | | { |
| | | } finally { |
| | | TIME_THREADLOCAL.remove(); |
| | | } |
| | | } |
| | |
| | | * @param operLog 操作日志 |
| | | * @throws Exception |
| | | */ |
| | | public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception |
| | | { |
| | | public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception { |
| | | // 设置action动作 |
| | | operLog.setBusinessType(log.businessType().ordinal()); |
| | | // 设置标题 |
| | |
| | | // 设置操作人类别 |
| | | operLog.setOperatorType(log.operatorType().ordinal()); |
| | | // 是否需要保存request,参数和值 |
| | | if (log.isSaveRequestData()) |
| | | { |
| | | if (log.isSaveRequestData()) { |
| | | // 获取参数的信息,传入到数据库中。 |
| | | setRequestValue(joinPoint, operLog, log.excludeParamNames()); |
| | | } |
| | | // 是否需要保存response,参数和值 |
| | | if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) |
| | | { |
| | | if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) { |
| | | operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000)); |
| | | } |
| | | } |
| | |
| | | * @param operLog 操作日志 |
| | | * @throws Exception 异常 |
| | | */ |
| | | private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog, String[] excludeParamNames) throws Exception |
| | | { |
| | | private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog, String[] excludeParamNames) throws Exception { |
| | | String requestMethod = operLog.getRequestMethod(); |
| | | Map<?, ?> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest()); |
| | | if (StringUtils.isEmpty(paramsMap) |
| | | && (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod))) |
| | | { |
| | | && (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod))) { |
| | | String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames); |
| | | operLog.setOperParam(StringUtils.substring(params, 0, 2000)); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | operLog.setOperParam(StringUtils.substring(JSON.toJSONString(paramsMap, excludePropertyPreFilter(excludeParamNames)), 0, 2000)); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 参数拼装 |
| | | */ |
| | | private String argsArrayToString(Object[] paramsArray, String[] excludeParamNames) |
| | | { |
| | | private String argsArrayToString(Object[] paramsArray, String[] excludeParamNames) { |
| | | String params = ""; |
| | | if (paramsArray != null && paramsArray.length > 0) |
| | | { |
| | | for (Object o : paramsArray) |
| | | { |
| | | if (StringUtils.isNotNull(o) && !isFilterObject(o)) |
| | | { |
| | | try |
| | | { |
| | | if (paramsArray != null && paramsArray.length > 0) { |
| | | for (Object o : paramsArray) { |
| | | if (StringUtils.isNotNull(o) && !isFilterObject(o)) { |
| | | try { |
| | | String jsonObj = JSON.toJSONString(o, excludePropertyPreFilter(excludeParamNames)); |
| | | params += jsonObj.toString() + " "; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 忽略敏感属性 |
| | | */ |
| | | public PropertyPreExcludeFilter excludePropertyPreFilter(String[] excludeParamNames) |
| | | { |
| | | public PropertyPreExcludeFilter excludePropertyPreFilter(String[] excludeParamNames) { |
| | | return new PropertyPreExcludeFilter().addExcludes(ArrayUtils.addAll(EXCLUDE_PROPERTIES, excludeParamNames)); |
| | | } |
| | | |
| | |
| | | * @return 如果是需要过滤的对象,则返回true;否则返回false。 |
| | | */ |
| | | @SuppressWarnings("rawtypes") |
| | | public boolean isFilterObject(final Object o) |
| | | { |
| | | public boolean isFilterObject(final Object o) { |
| | | Class<?> clazz = o.getClass(); |
| | | if (clazz.isArray()) |
| | | { |
| | | if (clazz.isArray()) { |
| | | return clazz.getComponentType().isAssignableFrom(MultipartFile.class); |
| | | } |
| | | else if (Collection.class.isAssignableFrom(clazz)) |
| | | { |
| | | } else if (Collection.class.isAssignableFrom(clazz)) { |
| | | Collection collection = (Collection) o; |
| | | for (Object value : collection) |
| | | { |
| | | for (Object value : collection) { |
| | | return value instanceof MultipartFile; |
| | | } |
| | | } |
| | | else if (Map.class.isAssignableFrom(clazz)) |
| | | { |
| | | } else if (Map.class.isAssignableFrom(clazz)) { |
| | | Map map = (Map) o; |
| | | for (Object value : map.entrySet()) |
| | | { |
| | | for (Object value : map.entrySet()) { |
| | | Map.Entry entry = (Map.Entry) value; |
| | | return entry.getValue() instanceof MultipartFile; |
| | | } |
| | |
| | | public class GlobalExceptionHandler { |
| | | private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class); |
| | | |
| | | @Value("${spring.servlet.multipart.max-file-size:50MB}") |
| | | @Value("${spring.servlet.multipart.max-file-size}") |
| | | private String maxFileSize; |
| | | @Value("${spring.servlet.multipart.max-request-size:100MB}") |
| | | @Value("${spring.servlet.multipart.max-request-size}") |
| | | private String maxRequestSize; |
| | | |
| | | |
| | |
| | | public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请求地址'{}',发生未知异常.", requestURI, e); |
| | | throw new RuntimeException(e.getMessage()); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping("/addSysUser") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R addSysUser(@RequestBody SysUser user) { |
| | | System.err.println("事务ID:" + RootContext.getXID()); |
| | | if(StringUtils.isEmpty(user.getUserName())){ |
| | | user.setUserName(user.getPhonenumber()); |
| | | } |
| | |
| | | return; |
| | | } |
| | | } |
| | | filterChain.doFilter(request, response); |
| | | filterChain.doFilter(servletRequest, servletResponse); |
| | | } |
| | | |
| | | |
| | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | |
| | | private String title; |
| | | @ApiModelProperty(value = "状态(0=正常,1=异常)") |
| | | private Integer status; |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty(value = "操作开始时间", notes = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime startTime; |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty(value = "操作结束时间", notes = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime endTime; |
| | | |
| | | } |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService |
| | | { |
| | | public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService { |
| | | private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); |
| | | |
| | | @Resource |
| | |
| | | private ISysRoleService sysRoleService; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据条件分页查询用户列表 |
| | | * |
| | |
| | | */ |
| | | @Override |
| | | @DataScope(deptAlias = "d", userAlias = "u") |
| | | public List<SysUser> selectUserList(SysUser user) |
| | | { |
| | | public List<SysUser> selectUserList(SysUser user) { |
| | | return userMapper.selectUserList(user); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | @DataScope(deptAlias = "d", userAlias = "u") |
| | | public List<SysUser> selectAllocatedList(SysUser user) |
| | | { |
| | | public List<SysUser> selectAllocatedList(SysUser user) { |
| | | return userMapper.selectAllocatedList(user); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | @DataScope(deptAlias = "d", userAlias = "u") |
| | | public List<SysUser> selectUnallocatedList(SysUser user) |
| | | { |
| | | public List<SysUser> selectUnallocatedList(SysUser user) { |
| | | return userMapper.selectUnallocatedList(user); |
| | | } |
| | | |
| | |
| | | * @return 用户对象信息 |
| | | */ |
| | | @Override |
| | | public SysUser selectUserByUserName(String userName) |
| | | { |
| | | public SysUser selectUserByUserName(String userName) { |
| | | return userMapper.selectUserByUserName(userName); |
| | | } |
| | | |
| | |
| | | * @return 用户对象信息 |
| | | */ |
| | | @Override |
| | | public SysUser selectUserById(Long userId) |
| | | { |
| | | public SysUser selectUserById(Long userId) { |
| | | return userMapper.selectUserById(userId); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public String selectUserRoleGroup(String userName) |
| | | { |
| | | public String selectUserRoleGroup(String userName) { |
| | | List<SysRole> list = roleMapper.selectRolesByUserName(userName); |
| | | if (CollectionUtils.isEmpty(list)) |
| | | { |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return StringUtils.EMPTY; |
| | | } |
| | | return list.stream().map(SysRole::getRoleName).collect(Collectors.joining(",")); |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public String selectUserPostGroup(String userName) |
| | | { |
| | | public String selectUserPostGroup(String userName) { |
| | | List<SysPost> list = postMapper.selectPostsByUserName(userName); |
| | | if (CollectionUtils.isEmpty(list)) |
| | | { |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return StringUtils.EMPTY; |
| | | } |
| | | return list.stream().map(SysPost::getPostName).collect(Collectors.joining(",")); |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean checkUserNameUnique(SysUser user) |
| | | { |
| | | public boolean checkUserNameUnique(SysUser user) { |
| | | Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | SysUser info = userMapper.checkUserNameUnique(user.getUserName()); |
| | | if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) |
| | | { |
| | | if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean checkPhoneUnique(SysUser user) |
| | | { |
| | | public boolean checkPhoneUnique(SysUser user) { |
| | | Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); |
| | | if (StringUtils.isNotNull(info) ) |
| | | { |
| | | if (StringUtils.isNotNull(info)) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean checkEmailUnique(SysUser user) |
| | | { |
| | | public boolean checkEmailUnique(SysUser user) { |
| | | Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | SysUser info = userMapper.checkEmailUnique(user.getEmail()); |
| | | if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) |
| | | { |
| | | if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | |
| | | * @param user 用户信息 |
| | | */ |
| | | @Override |
| | | public void checkUserAllowed(SysUser user) |
| | | { |
| | | if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) |
| | | { |
| | | public void checkUserAllowed(SysUser user) { |
| | | if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) { |
| | | throw new ServiceException("不允许操作超级管理员用户"); |
| | | } |
| | | } |
| | |
| | | * @param userId 用户id |
| | | */ |
| | | @Override |
| | | public void checkUserDataScope(Long userId) |
| | | { |
| | | if (!SysUser.isAdmin(SecurityUtils.getUserId())) |
| | | { |
| | | public void checkUserDataScope(Long userId) { |
| | | if (!SysUser.isAdmin(SecurityUtils.getUserId())) { |
| | | SysUser user = new SysUser(); |
| | | user.setUserId(userId); |
| | | List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user); |
| | | if (StringUtils.isEmpty(users)) |
| | | { |
| | | if (StringUtils.isEmpty(users)) { |
| | | throw new ServiceException("没有权限访问用户数据!"); |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int insertUser(SysUser user) |
| | | { |
| | | public int insertUser(SysUser user) { |
| | | // 新增用户信息 |
| | | int rows = userMapper.insertUser(user); |
| | | // // 新增用户岗位关联 |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean registerUser(SysUser user) |
| | | { |
| | | public boolean registerUser(SysUser user) { |
| | | return userMapper.insertUser(user) > 0; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int updateUser(SysUser user) |
| | | { |
| | | public int updateUser(SysUser user) { |
| | | // Long userId = user.getUserId(); |
| | | // // 删除用户与角色关联 |
| | | // userRoleMapper.deleteUserRoleByUserId(userId); |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void insertUserAuth(Long userId, Long[] roleIds) |
| | | { |
| | | public void insertUserAuth(Long userId, Long[] roleIds) { |
| | | userRoleMapper.deleteUserRoleByUserId(userId); |
| | | insertUserRole(userId, roleIds); |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateUserStatus(SysUser user) |
| | | { |
| | | public int updateUserStatus(SysUser user) { |
| | | return userMapper.updateUser(user); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateUserProfile(SysUser user) |
| | | { |
| | | public int updateUserProfile(SysUser user) { |
| | | return userMapper.updateUser(user); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public boolean updateUserAvatar(String userName, String avatar) |
| | | { |
| | | public boolean updateUserAvatar(String userName, String avatar) { |
| | | return userMapper.updateUserAvatar(userName, avatar) > 0; |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int resetPwd(SysUser user) |
| | | { |
| | | public int resetPwd(SysUser user) { |
| | | return userMapper.updateUser(user); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int resetUserPwd(String userName, String password) |
| | | { |
| | | public int resetUserPwd(String userName, String password) { |
| | | return userMapper.resetUserPwd(userName, password); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param user 用户对象 |
| | | */ |
| | | public void insertUserRole(SysUser user) |
| | | { |
| | | public void insertUserRole(SysUser user) { |
| | | this.insertUserRole(user.getUserId(), user.getRoleIds()); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param user 用户对象 |
| | | */ |
| | | public void insertUserPost(SysUser user) |
| | | { |
| | | public void insertUserPost(SysUser user) { |
| | | Long[] posts = user.getPostIds(); |
| | | if (StringUtils.isNotEmpty(posts)) |
| | | { |
| | | if (StringUtils.isNotEmpty(posts)) { |
| | | // 新增用户与岗位管理 |
| | | List<SysUserPost> list = new ArrayList<SysUserPost>(); |
| | | for (Long postId : posts) |
| | | { |
| | | for (Long postId : posts) { |
| | | SysUserPost up = new SysUserPost(); |
| | | up.setUserId(user.getUserId()); |
| | | up.setPostId(postId); |
| | |
| | | * @param userId 用户ID |
| | | * @param roleIds 角色组 |
| | | */ |
| | | public void insertUserRole(Long userId, Long[] roleIds) |
| | | { |
| | | if (StringUtils.isNotEmpty(roleIds)) |
| | | { |
| | | public void insertUserRole(Long userId, Long[] roleIds) { |
| | | if (StringUtils.isNotEmpty(roleIds)) { |
| | | // 新增用户与角色管理 |
| | | List<SysUserRole> list = new ArrayList<SysUserRole>(); |
| | | for (Long roleId : roleIds) |
| | | { |
| | | for (Long roleId : roleIds) { |
| | | SysUserRole ur = new SysUserRole(); |
| | | ur.setUserId(userId); |
| | | ur.setRoleId(roleId); |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int deleteUserById(Long userId) |
| | | { |
| | | public int deleteUserById(Long userId) { |
| | | // 删除用户与角色关联 |
| | | userRoleMapper.deleteUserRoleByUserId(userId); |
| | | // 删除用户与岗位表 |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int deleteUserByIds(Long[] userIds) |
| | | { |
| | | for (Long userId : userIds) |
| | | { |
| | | public int deleteUserByIds(Long[] userIds) { |
| | | for (Long userId : userIds) { |
| | | checkUserAllowed(new SysUser(userId)); |
| | | // checkUserDataScope(userId); |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) |
| | | { |
| | | if (StringUtils.isNull(userList) || userList.size() == 0) |
| | | { |
| | | public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) { |
| | | if (StringUtils.isNull(userList) || userList.size() == 0) { |
| | | throw new ServiceException("导入用户数据不能为空!"); |
| | | } |
| | | int successNum = 0; |
| | |
| | | StringBuilder successMsg = new StringBuilder(); |
| | | StringBuilder failureMsg = new StringBuilder(); |
| | | String password = configService.selectConfigByKey("sys.user.initPassword"); |
| | | for (SysUser user : userList) |
| | | { |
| | | try |
| | | { |
| | | for (SysUser user : userList) { |
| | | try { |
| | | // 验证是否存在这个用户 |
| | | SysUser u = userMapper.selectUserByUserName(user.getUserName()); |
| | | if (StringUtils.isNull(u)) |
| | | { |
| | | 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.getUserName() + " 导入成功"); |
| | | } |
| | | else if (isUpdateSupport) |
| | | { |
| | | } else if (isUpdateSupport) { |
| | | BeanValidators.validateWithException(validator, user); |
| | | checkUserAllowed(u); |
| | | checkUserDataScope(u.getUserId()); |
| | |
| | | userMapper.updateUser(user); |
| | | successNum++; |
| | | successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功"); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | failureNum++; |
| | | failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在"); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | } catch (Exception e) { |
| | | failureNum++; |
| | | String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:"; |
| | | failureMsg.append(msg + e.getMessage()); |
| | | log.error(msg, e); |
| | | } |
| | | } |
| | | if (failureNum > 0) |
| | | { |
| | | if (failureNum > 0) { |
| | | failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); |
| | | throw new ServiceException(failureMsg.toString()); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); |
| | | } |
| | | return successMsg.toString(); |
| | |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "通过充电枪id和预付金额获取电站详情", tags = {"小程序-扫一扫"}) |
| | | @GetMapping(value = "/scan/siteInfo") |
| | | @PostMapping(value = "/scan/siteInfo") |
| | | public AjaxResult<SiteInfoVO> siteInfo(Integer id, BigDecimal money) { |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(id).getData(); |
| | | TChargingPile chargingPile = chargingPileClient.getChargingPileById(chargingGun.getChargingPileId()).getData(); |
| | | SiteInfoVO data = chargingPileClient.getSiteInfoByNumber(chargingPile.getNumber().toString()).getData(); |
| | | SiteInfoVO data = chargingPileClient.getSiteInfoByNumber1(chargingPile.getCode().toString()).getData(); |
| | | data.setChargingGunId(id); |
| | | data.setChargeMode(chargingGun.getChargeMode()); |
| | | List<TAppUserCar> cars = appUserCarService.list(new QueryWrapper<TAppUserCar>() |
| | | .eq("app_user_id",tokenService.getLoginUserApplet().getUserId()) |
| | | .orderByDesc("create_time")); |
| | |
| | | @DeleteMapping(value = "/unit/delete") |
| | | @Log(title = "【单位管理】删除单位", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | public R add(@RequestParam String ids) { |
| | | List<TAppUser> list = appUserService.lambdaQuery().in(TAppUser::getCompanyId, Arrays.asList(ids.split(","))).list(); |
| | | if (!list.isEmpty()){ |
| | | return R.fail("当前单位已存在用户,无法删除!"); |
| | | } |
| | | String[] split = ids.split(","); |
| | | for (String s : split) { |
| | | otherClient.unitDelete(Integer.valueOf(s)); |
| | |
| | | Page<TAppUser> page = appUserService.lambdaQuery() |
| | | .like(userListQueryDto.getUserPhone() != null && !"".equals(userListQueryDto.getUserPhone()), TAppUser::getPhone, userListQueryDto.getUserPhone()) |
| | | .eq(userListQueryDto.getCompanyId() != null, TAppUser::getCompanyId, userListQueryDto.getCompanyId()) |
| | | .like(userListQueryDto.getProvinceCode() != null && !"".equals(userListQueryDto.getProvinceCode()), TAppUser::getProvinceCode, userListQueryDto.getProvinceCode()) |
| | | .eq(userListQueryDto.getProvinceCode() != null && !"".equals(userListQueryDto.getProvinceCode()), TAppUser::getProvinceCode, userListQueryDto.getProvinceCode()) |
| | | .eq(userListQueryDto.getCityCode() != null && !"".equals(userListQueryDto.getCityCode()), TAppUser::getCityCode, userListQueryDto.getCityCode()) |
| | | .eq(userListQueryDto.getStatus() != null, TAppUser::getStatus, userListQueryDto.getStatus()) |
| | | .eq(userListQueryDto.getVipTypeId() != null, TAppUser::getVipId, userListQueryDto.getVipTypeId()) |
| | |
| | | if (userListQueryDto.getUserTagId() != null){ |
| | | userIds = appUserTagService.lambdaQuery().eq(TAppUserTag::getUserTagId, userListQueryDto.getUserTagId()).list().stream().map(TAppUserTag::getAppUserId).collect(Collectors.toList()); |
| | | } |
| | | LocalDateTime end1 = null; |
| | | LocalDateTime end2 = null ; |
| | | if (userListQueryDto.getVipEndTime1()!=null) { |
| | | end1 = LocalDateTime.now().plusDays(userListQueryDto.getVipEndTime1()); |
| | | } |
| | | if (userListQueryDto.getVipEndTime2()!=null){ |
| | | end2 = LocalDateTime.now().plusDays(userListQueryDto.getVipEndTime2()); |
| | | } |
| | | //列表查询 |
| | | Page<TAppUser> page = appUserService.lambdaQuery() |
| | | .ge(TAppUser::getVipEndTime, LocalDateTime.now()) |
| | | .like(userListQueryDto.getUserPhone() != null && !"".equals(userListQueryDto.getUserPhone()), TAppUser::getPhone, userListQueryDto.getUserPhone()) |
| | | .eq(userListQueryDto.getCompanyId() != null, TAppUser::getCompanyId, userListQueryDto.getCompanyId()) |
| | | .eq(userListQueryDto.getProvinceCode() != null && !"".equals(userListQueryDto.getProvinceCode()), TAppUser::getProvinceCode, userListQueryDto.getProvinceCode()) |
| | | .eq(userListQueryDto.getCityCode() != null && !"".equals(userListQueryDto.getCityCode()), TAppUser::getCityCode, userListQueryDto.getCityCode()) |
| | | .eq(userListQueryDto.getStatus() != null, TAppUser::getStatus, userListQueryDto.getStatus()) |
| | | .eq(userListQueryDto.getVipTypeId() != null, TAppUser::getVipId, userListQueryDto.getVipTypeId()) |
| | | .ge(userListQueryDto.getVipEndTime1() != null, TAppUser::getVipEndTime, userListQueryDto.getVipEndTime1() == null ? null : LocalDateTime.now().plusDays(userListQueryDto.getVipEndTime1())) |
| | | .le(userListQueryDto.getVipEndTime2() != null, TAppUser::getVipEndTime, userListQueryDto.getVipEndTime2() == null ? null : LocalDateTime.now().plusDays(userListQueryDto.getVipEndTime2())) |
| | | .ge(userListQueryDto.getVipEndTime1() != null, TAppUser::getVipEndTime, end1 ) |
| | | .le(userListQueryDto.getVipEndTime2() != null, TAppUser::getVipEndTime, end2) |
| | | .in(!userIds.isEmpty(), TAppUser::getId, userIds) |
| | | .page(Page.of(userListQueryDto.getPageCurr(), userListQueryDto.getPageSize())); |
| | | if (page.getRecords().isEmpty()){ |
| | |
| | | } |
| | | } |
| | | |
| | | }else { |
| | | List<TAppUser> list = appUserService.lambdaQuery().eq(TAppUser::getPhone, tAppUser.getPhone()).list(); |
| | | if (!list.isEmpty()){ |
| | | return R.fail("该手机号已注册"); |
| | | } |
| | | } |
| | | appUserService.saveOrUpdate(tAppUser); |
| | | return R.ok(); |
| | |
| | | @GetMapping(value = "/user/detail/{id}") |
| | | public R<UserDetailDto> userDetail(@PathVariable Long id) { |
| | | TAppUser user = appUserService.getById(id); |
| | | UserDetailDto userDetailDto = new UserDetailDto(); |
| | | BeanUtils.copyProperties(user,userDetailDto); |
| | | if (user.getVipId()!=null) { |
| | | R<Map<Integer, String>> vipMap = otherClient.getVipMap(Arrays.asList(user.getVipId())); |
| | | R<Map<Integer, String>> vipMap = otherClient.getVipMap(Collections.singletonList(user.getVipId())); |
| | | if (user.getVipEndTime()!=null&&user.getVipEndTime().isAfter(LocalDateTime.now())) { |
| | | //匹配vipMap的值 |
| | | user.setVipName(vipMap.getData().get(user.getVipId())); |
| | | } |
| | | |
| | | |
| | | UserDetailDto userDetailDto = new UserDetailDto(); |
| | | BeanUtils.copyProperties(user,userDetailDto); |
| | | |
| | | //获取累计充电数量 |
| | | R<Long> useOrderCount = chargingOrderClient.useOrderCount(user.getId()); |
| | | userDetailDto.setOrderCount(useOrderCount.getData()); |
| | |
| | | userDetailDto.setTagName(tagMap.getData().values() |
| | | .stream() |
| | | .collect(Collectors.joining(","))); |
| | | |
| | | |
| | | |
| | | return R.ok(userDetailDto); |
| | | } |
| | | |
| | |
| | | Long count = signService.lambdaQuery().eq(TAppUserSign::getAppUserId,userId).eq(TAppUserSign::getSignDay, LocalDate.now()).count(); |
| | | appUserInfoDto.setIsSign(count>0?1:0); |
| | | //获取当前拥有的优惠卷数量 |
| | | Long coupons = appCouponService.lambdaQuery().eq(TAppCoupon::getAppUserId, userId).eq(TAppCoupon::getStatus, 1).count(); |
| | | Long coupons = appCouponService.lambdaQuery().eq(TAppCoupon::getAppUserId, userId).ge(TAppCoupon::getEndTime, LocalDateTime.now()).eq(TAppCoupon::getStatus, 1).count(); |
| | | appUserInfoDto.setCouponNum(Math.toIntExact(coupons)); |
| | | //当前绑定的车辆 |
| | | List<TAppUserCar> list = carService.lambdaQuery().eq(TAppUserCar::getAppUserId, userId).list(); |
| | |
| | | signService.updateById(appUserSign); |
| | | } |
| | | } |
| | | pointDetailUtil.addDetail(byId.getPoints(),byId.getPoints()+points,1,userId,"每日签到","JF"); |
| | | pointDetailUtil.addDetail(byId.getPoints(),byId.getPoints()+points,1,userId,"每日签到","JF",""); |
| | | byId.setPoints(byId.getPoints()+points); |
| | | appUserService.updateById(byId); |
| | | return R.ok(); |
| | |
| | | |
| | | |
| | | //积分变化记录用 |
| | | @PostMapping(value = "/user/points/change") |
| | | public R change(@RequestBody PointChangeDto points) { |
| | | TAppUser byId = appUserService.getById(points.getUserId()); |
| | | pointDetailUtil.addDetail(byId.getPoints(),byId.getPoints()+points.getPoints(),points.getType(),points.getUserId(),points.getRemark(),"JF"); |
| | | byId.setPoints(byId.getPoints()+points.getPoints()); |
| | | appUserService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | // @PostMapping(value = "/user/points/change") |
| | | // public R change(@RequestBody PointChangeDto points) { |
| | | // TAppUser byId = appUserService.getById(points.getUserId()); |
| | | // pointDetailUtil.addDetail(byId.getPoints(),byId.getPoints()+points.getPoints(),points.getType(),points.getUserId(),points.getRemark(),"JF"); |
| | | // byId.setPoints(byId.getPoints()+points.getPoints()); |
| | | // appUserService.updateById(byId); |
| | | // return R.ok(); |
| | | // } |
| | | |
| | | @PostMapping(value = "/user/points/change/down") |
| | | public R changeDown(@RequestBody PointChangeDto points) { |
| | | TAppUser byId = appUserService.getById(points.getUserId()); |
| | | pointDetailUtil.addDetail(byId.getPoints(),byId.getPoints()-points.getPoints(),points.getType(),points.getUserId(),points.getRemark(),"JF"); |
| | | pointDetailUtil.addDetail(byId.getPoints(),byId.getPoints()-points.getPoints(),points.getType(),points.getUserId(),points.getRemark(),"JF",points.getCode()); |
| | | byId.setPoints(byId.getPoints()-points.getPoints()); |
| | | appUserService.updateById(byId); |
| | | return R.ok(); |
| | |
| | | } |
| | | |
| | | //增加积分记录 |
| | | pointDetailUtil.addDetail(byId.getPoints(),byId.getPoints()+point,5,userId,appUserCar.getLicensePlate(),""); |
| | | pointDetailUtil.addDetail(byId.getPoints(),byId.getPoints()+point,5,userId,appUserCar.getLicensePlate(),"",""); |
| | | byId.setPoints(byId.getPoints()+point); |
| | | byId.setFirstAdd(1); |
| | | |
| | |
| | | |
| | | return R.ok(jsonObject.getJSONObject("data")); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @PostMapping(value = "/user/editAppUserInfo") |
| | | @ApiOperation(value = "修改个人信息", tags = {"小程序-个人中心"}) |
| | | public AjaxResult editAppUserInfo(@RequestBody TAppUser appUser){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | appUser.setId(userId); |
| | | appUserService.updateById(appUser); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | |
| | | public R delete(String ids) { |
| | | //拿到单位列表 |
| | | String[] split = ids.split(","); |
| | | |
| | | List<TAppUserTag> list = appUserTagService.lambdaQuery().in(TAppUserTag::getUserTagId).list(); |
| | | if (!list.isEmpty()){ |
| | | return R.fail("当前标签已有用户获取,无法删除"); |
| | | } |
| | | for (String id : split) { |
| | | otherClient.deleteTag(Integer.valueOf(id)); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户标签关系 |
| | | * @param appUserTag |
| | | * @return |
| | | */ |
| | | @PostMapping(value = "/tags/getUserTag") |
| | | public R<TAppUserTag> getUserTag(@RequestBody TAppUserTag appUserTag){ |
| | | TAppUserTag one = appUserTagService.getOne(new LambdaQueryWrapper<TAppUserTag>().eq(TAppUserTag::getAppUserId, appUserTag.getAppUserId()) |
| | | .eq(TAppUserTag::getUserTagId, appUserTag.getUserTagId())); |
| | | return R.ok(one); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存用户标签关系数据 |
| | | * @param appUserTag |
| | | */ |
| | | @PostMapping(value = "/tags/addUserTag") |
| | | public void addUserTag(@RequestBody TAppUserTag appUserTag){ |
| | | appUserTagService.save(appUserTag); |
| | | } |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "生效会员列表", tags = {"小程序-个人中心"}) |
| | | public R<List<TAppUserVipDetail>> getVipUseDetail(){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | List<TAppUserVipDetail> list = appUserVipDetailService.lambdaQuery().eq(TAppUserVipDetail::getAppUserId, userId).last(" and now() between start_time and end_time order by start_time desc").list(); |
| | | List<TAppUserVipDetail> list = appUserVipDetailService.lambdaQuery().eq(TAppUserVipDetail::getAppUserId, userId).last(" and now() between start_time and end_time order by start_time asc").list(); |
| | | |
| | | for (TAppUserVipDetail tAppUserVipDetail : list) { |
| | | if(null != tAppUserVipDetail.getVipId()){ |
| | |
| | | public class PointDetailUtil { |
| | | @Resource |
| | | private TAppUserIntegralChangeService appUserIntegralChangeService; |
| | | public void addDetail(Integer old,Integer now,Integer type,Long userId,String extension,String code){ |
| | | public void addDetail(Integer old,Integer now,Integer type,Long userId,String extension,String code,String orderCode){ |
| | | |
| | | TAppUserIntegralChange tAppUserIntegralChange= new TAppUserIntegralChange(); |
| | | tAppUserIntegralChange.setCode(OrderCodeUtil.getOrderCode(code)); |
| | |
| | | tAppUserIntegralChange.setCurrentIntegral(now); |
| | | tAppUserIntegralChange.setCreateTime(LocalDateTime.now()); |
| | | tAppUserIntegralChange.setExtension(extension); |
| | | tAppUserIntegralChange.setOrderCode(orderCode); |
| | | appUserIntegralChangeService.save(tAppUserIntegralChange); |
| | | |
| | | |
| | |
| | | @ApiOperation(value = "扫一扫后通过桩编号获取电站信息", tags = {"小程序-扫一扫"}) |
| | | public R<SiteInfoVO> getSiteInfoByNumber(@RequestParam("number") String number){ |
| | | SiteInfoVO siteInfoVO = new SiteInfoVO(); |
| | | String chargingPileCode = number.substring(0, number.length() - 2); |
| | | String chargingGunCode = number.substring(number.length() - 2); |
| | | TChargingPile one = chargingPileService.lambdaQuery().eq(TChargingPile::getCode, chargingPileCode).one(); |
| | | TChargingGun chargingGun = chargingGunService.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, chargingGunCode).eq(TChargingGun::getChargingPileId, one.getId())); |
| | | Site byId = siteService.getById(one.getSiteId()); |
| | | TAccountingStrategy byId1 = accountingStrategyService.getById(byId.getAccountingStrategyId()); |
| | | List<TAccountingStrategyDetail> list = accountingStrategyDetailService.lambdaQuery().eq(TAccountingStrategyDetail::getAccountingStrategyId, byId1.getId()).list(); |
| | | for (TAccountingStrategyDetail tAccountingStrategyDetail : list) { |
| | | // 当前时间属于那个阶段 取哪个阶段的电价 |
| | | if(LocalTime.now().isAfter(LocalTime.parse(tAccountingStrategyDetail.getStartTime())) && LocalTime.now().isBefore(LocalTime.parse(tAccountingStrategyDetail.getEndTime()))){ |
| | | siteInfoVO.setElectrovalence(tAccountingStrategyDetail.getElectrovalence()); |
| | | siteInfoVO.setVipElectrovalence(tAccountingStrategyDetail.getElectrovalence().multiply(byId1.getDiscount()).setScale(4, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | } |
| | | siteInfoVO.setChargingGunId(chargingGun.getId()); |
| | | siteInfoVO.setChargingPileId(one.getId()); |
| | | siteInfoVO.setName(byId.getName()); |
| | | siteInfoVO.setNumber(one.getNumber().toString()); |
| | | siteInfoVO.setSpaceChargeExplain(byId.getSpaceChargeExplain()); |
| | | return R.ok(siteInfoVO); |
| | | } |
| | | /** |
| | | * 通过桩编号获取电站信息 遠程調用 |
| | | * @param number |
| | | * @return |
| | | */ |
| | | @PostMapping("/getSiteInfoByNumber1") |
| | | public R<SiteInfoVO> getSiteInfoByNumber1(@RequestParam("number") String number){ |
| | | SiteInfoVO siteInfoVO = new SiteInfoVO(); |
| | | TChargingPile one = chargingPileService.lambdaQuery().eq(TChargingPile::getCode, number).one(); |
| | | Site byId = siteService.getById(one.getSiteId()); |
| | | TAccountingStrategy byId1 = accountingStrategyService.getById(byId.getAccountingStrategyId()); |
| | |
| | | siteInfoVO.setSpaceChargeExplain(byId.getSpaceChargeExplain()); |
| | | return R.ok(siteInfoVO); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getSiteList") |
| | | @ApiOperation(value = "获取站点列表", tags = {"管理后台-站点管理"}) |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.chargingPile.api.dto.TAccountingStrategyDTO; |
| | | import com.ruoyi.chargingPile.api.model.*; |
| | | import com.ruoyi.chargingPile.api.query.BatchSetAccountingStrategy; |
| | | import com.ruoyi.chargingPile.api.query.TAccountingStrategyQuery; |
| | | import com.ruoyi.chargingPile.api.vo.TAccountingStrategyDetailVO; |
| | | import com.ruoyi.chargingPile.api.vo.TAccountingStrategyVO; |
| | |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.log.enums.OperatorType; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.integration.api.feignClient.IntegrationClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | private TChargingPileService chargingPileService; |
| | | @Autowired |
| | | private ISiteService siteService; |
| | | @Resource |
| | | @Autowired |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | @Autowired |
| | | public TAccountingStrategyController(TAccountingStrategyService accountingStrategyService, TAccountingStrategyDetailService accountingStrategyDetailService) { |
| | |
| | | |
| | | return AjaxResult.ok(accountingStrategyService.pageList(query)); |
| | | } |
| | | @Resource |
| | | private IntegrationClient integrationClient; |
| | | |
| | | @ApiOperation(tags = {"后台-申请表单-计费模板审核"},value = "审核") |
| | | @PostMapping(value = "/auth/pass") |
| | |
| | | } |
| | | |
| | | //硬件 |
| | | List<TChargingPile> list = chargingPileService.lambdaQuery().eq(TChargingPile::getSiteId, byId.getSiteId()).list(); |
| | | for (TChargingPile tChargingPile : list) { |
| | | integrationClient.setupBillingModel1(tChargingPile.getCode()); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.ruoyi.chargingPile.api.vo.GunStatusStatisticsVO; |
| | | import com.ruoyi.chargingPile.api.vo.SiteNameVO; |
| | | import com.ruoyi.chargingPile.api.vo.TChargingGunVO; |
| | | import com.ruoyi.chargingPile.config.FileUploadConfig; |
| | | import com.ruoyi.chargingPile.service.ISiteService; |
| | | import com.ruoyi.chargingPile.service.TChargingGunService; |
| | | import com.ruoyi.chargingPile.service.TChargingPileService; |
| | |
| | | |
| | | @Autowired |
| | | private TChargingGunService chargingGunService; |
| | | @Autowired |
| | | @Resource |
| | | private ChargingOrderClient chargingOrderClient; |
| | | |
| | | @Resource |
| | | private TChargingPileService chargingPileService; |
| | | @Resource |
| | | private ISiteService siteService; |
| | | |
| | | @Autowired |
| | | private FileUploadConfig fileUploadConfig; |
| | | |
| | | /** |
| | | * 查询充电枪列表 |
| | |
| | | public void downloadQRCode(@PathVariable Integer id, HttpServletResponse response){ |
| | | try { |
| | | TChargingGun chargingGun = chargingGunService.getById(id); |
| | | String fileName = URLEncoder.encode(chargingGun.getCode(), "UTF-8") + ".jpg"; |
| | | TChargingPile chargingPile = chargingPileService.getById(chargingGun.getId()); |
| | | String code = chargingPile.getCode() + chargingGun.getCode(); |
| | | String fileName = URLEncoder.encode(code, "UTF-8") + ".jpg"; |
| | | response.setContentType("application/force-download"); |
| | | response.addHeader("Content-Disposition", "attachment;fileName=" + fileName); |
| | | String url = "https://www.baidu.com?id=" + id; |
| | | String filePath = "D:/Program Files/nginx-1.20.2/html"; |
| | | String url = "https://mxcd.zhinenganguan.com?No=" + code; |
| | | String filePath = fileUploadConfig.getLocation(); |
| | | QRCodeUtils.encode(url, filePath); |
| | | FileInputStream inputStream = new FileInputStream(filePath); |
| | | ServletOutputStream out = response.getOutputStream(); |
| | |
| | | import io.seata.core.context.RootContext; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import io.seata.tm.api.GlobalTransaction; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Override |
| | | @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 |
| | | public AjaxResult addPartner(Partner partner) { |
| | | System.err.println("事务ID:" + RootContext.getXID()); |
| | | //校验参数和重复数据 |
| | | AjaxResult ajaxResult = addPartnerParameterCheck(partner); |
| | | if(ajaxResult.isError()){ |
| | |
| | | if(null != one){ |
| | | return AjaxResult.error("登录账号不能重复"); |
| | | } |
| | | //添加新数据 |
| | | this.save(partner); |
| | | //添加登录账户 |
| | | SysUser user = new SysUser(); |
| | | user.setPhonenumber(partner.getPhoneOne()); |
| | |
| | | user.setRoleType(2); |
| | | user.setObjectId(partner.getId()); |
| | | R r = sysUserClient.addSysUser(user); |
| | | if(r.getCode() != 200){ |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | if(200 != r.getCode()){ |
| | | throw new RuntimeException(r.getMsg()); |
| | | } |
| | | return AjaxResult.error(r.getMsg()); |
| | | } |
| | | //添加新数据 |
| | | this.save(partner); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | } |
| | | Partner oldPartner = this.getById(partner.getId()); |
| | | SysUser user = sysUserClient.queryUserByUserName(oldPartner.getAccount()).getData(); |
| | | |
| | | //修改数据 |
| | | this.updateById(partner); |
| | | //修改登录账户 |
| | | if(null == user){ |
| | | user = new SysUser(); |
| | |
| | | throw new RuntimeException(r.getMsg()); |
| | | } |
| | | } |
| | | |
| | | //修改数据 |
| | | this.updateById(partner); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | public AjaxResult delSite(Integer[] ids) { |
| | | //查询是否有关联数据 |
| | | //充电桩 |
| | | long count1 = chargingPileService.count(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getSiteId, Arrays.asList(ids)).eq(TChargingPile::getDelFlag, 0)); |
| | | long count1 = chargingPileService.count(new LambdaQueryWrapper<TChargingPile>().in(TChargingPile::getSiteId, Arrays.asList(ids)) |
| | | .eq(TChargingPile::getDelFlag, 0)); |
| | | if(count1 > 0){ |
| | | return AjaxResult.error("该站点有关联充电桩,删除失败!"); |
| | | return AjaxResult.error("该站点已添加充电桩,不可删除。"); |
| | | } |
| | | for (Integer id : ids) { |
| | | Site site = this.getById(id); |
| | |
| | | public AjaxResult delChargingPile(Integer[] ids) { |
| | | //检查是否有关联数据 |
| | | //接口 |
| | | long count = chargingGunService.count(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, Arrays.asList(ids)).eq(TChargingGun::getDelFlag, 0)); |
| | | long count = chargingGunService.count(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getChargingPileId, Arrays.asList(ids)) |
| | | .eq(TChargingGun::getDelFlag, 0)); |
| | | if(count > 0){ |
| | | return AjaxResult.error("该充电桩有关联的接口数据,删除失败!"); |
| | | return AjaxResult.error("该充电桩已添加接口,不可删除。"); |
| | | } |
| | | for (Integer id : ids) { |
| | | TChargingPile chargingPile = this.getById(id); |
| | |
| | | return R.ok(message); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "远程重启",tags = {"硬件接口"}) |
| | | @PostMapping(value = "/platformRestart") |
| | | public R platformRestart(String deviceId) { |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | .last(" and DATE_FORMAT(now(), '%H:%i') between start_time and end_time")); |
| | | return R.ok(one); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取订单对应的计费策略数据 |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | @PostMapping("/getAllAccountingStrategyDetailOrder") |
| | | public R<List<AccountingStrategyDetailOrder>> getAllAccountingStrategyDetailOrder(@RequestParam("orderId") Long orderId){ |
| | | List<AccountingStrategyDetailOrder> one = accountingStrategyDetailOrderService.list(new LambdaQueryWrapper<AccountingStrategyDetailOrder>() |
| | | .eq(AccountingStrategyDetailOrder::getChargingOrderId, orderId) |
| | | .orderByAsc(AccountingStrategyDetailOrder::getStartTime)); |
| | | return R.ok(one); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.order.controller; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.api.model.AccountingStrategyOrder; |
| | | import com.ruoyi.order.service.AccountingStrategyOrderService; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/9/25 18:33 |
| | | */ |
| | | @RequestMapping("/accountingStrategyOrder") |
| | | @RestController |
| | | public class AccountingStrategyOrderController { |
| | | |
| | | @Resource |
| | | private AccountingStrategyOrderService accountingStrategyOrderService; |
| | | |
| | | |
| | | /** |
| | | * 根据id获取数据 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping("/getAccountingStrategyOrderById") |
| | | public R<AccountingStrategyOrder> getAccountingStrategyOrderById(@RequestParam("id") Integer id){ |
| | | AccountingStrategyOrder accountingStrategyOrder = accountingStrategyOrderService.getById(id); |
| | | return R.ok(accountingStrategyOrder); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @GetMapping(value = "/work/shop") |
| | | @PostMapping(value = "/work/shop") |
| | | @ApiOperation(value = "购物收入", tags = {"后台-工作台"}) |
| | | public R workShop(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) { |
| | | //count近6个月的数据 |
| | |
| | | siteIds.add(statisticsQueryDto.getSiteId()); |
| | | } |
| | | if (statisticsQueryDto.getDayType()==1) { |
| | | List<Map<String,Object>> charMap = chargingOrderService.getHourType(siteIds,statisticsQueryDto); |
| | | List<Map<String,Object>> charMap1 = chargingOrderService.getHourType(siteIds,statisticsQueryDto); |
| | | List<Map<String, Object>> charMap = new ArrayList<>(); |
| | | // 生成从 "00:00" 到 "23:00" 的时间数据 |
| | | for (int hour = 0; hour < 24; hour++) { |
| | | String time = String.format("%02d:00", hour); |
| | | Map<String, Object> mapWithTimeValue = findMapWithTimeValue(charMap1, time); |
| | | if (mapWithTimeValue!=null){ |
| | | charMap.add(mapWithTimeValue); |
| | | }else { |
| | | Map<String, Object> timeMap = new HashMap<>(); |
| | | timeMap.put("time", time); // 初始化值为 null |
| | | timeMap.put("electrovalence", 0); |
| | | timeMap.put("orderCount", 0); |
| | | timeMap.put("servicecharge", 0); |
| | | timeMap.put("electricity", 0); |
| | | charMap.add(timeMap); |
| | | } |
| | | } |
| | | return R.ok(charMap); |
| | | }else if (statisticsQueryDto.getDayType()==2){ |
| | | List<Map<String,Object>> charMap = chargingOrderService.getDateType(siteIds,statisticsQueryDto); |
| | | return R.ok(charMap); |
| | | }else if (statisticsQueryDto.getDayType()==3){ |
| | | List<Map<String,Object>> charMap = chargingOrderService.getMonthType(siteIds,statisticsQueryDto); |
| | | } |
| | | return R.ok(charMap); |
| | | |
| | | } |
| | | return R.ok(); |
| | | |
| | | |
| | | } |
| | | |
| | | private static Map<String, Object> findMapWithTimeValue(List<Map<String, Object>> charMap1,String timeValue) { |
| | | for (Map<String, Object> map : charMap1) { |
| | | if (map.containsKey("time") && map.get("time").equals(timeValue)) { |
| | | return map; |
| | | } |
| | | } |
| | | return null; // 如果没有找到,返回 null |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping(value = "/work/use") |
| | |
| | | @Resource |
| | | private TOrderInvoiceService invoiceService; |
| | | @ResponseBody |
| | | @PostMapping(value = "/work/shopOrder") |
| | | @GetMapping(value = "/work/shopOrder") |
| | | @ApiOperation(value = "购物订单统计", tags = {"管理后台-工作台"}) |
| | | public R shopOrder(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) { |
| | | public R shopOrder() { |
| | | Long count = shoppingOrderService.lambdaQuery().eq(TShoppingOrder::getStatus, 1).count(); |
| | | Long count1 = shoppingOrderService.lambdaQuery().eq(TShoppingOrder::getStatus, 2).count(); |
| | | List<Long> counts = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping(value = "/work/invoice") |
| | | @GetMapping(value = "/work/invoice") |
| | | @ApiOperation(value = "开票统计", tags = {"管理后台-工作台"}) |
| | | public R invoice(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) { |
| | | public R invoice() { |
| | | Long count = invoiceService.lambdaQuery().eq(TOrderInvoice::getStatus, 1).count(); |
| | | Long count1 = invoiceService.lambdaQuery().eq(TOrderInvoice::getStatus, 3).count(); |
| | | List<Long> counts = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping(value = "/work/users/count") |
| | | @GetMapping(value = "/work/users/count") |
| | | @ApiOperation(value = "用户数量", tags = {"管理后台-工作台"}) |
| | | public R usersCount(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) { |
| | | public R usersCount() { |
| | | List<Map<String,Object>> userMap = chargingOrderService.countAllUserData(); |
| | | return R.ok(userMap); |
| | | |
| | |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; |
| | | import com.ruoyi.chargingPile.api.model.TChargingPile; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.dto.ExchangeBackDto; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | |
| | | } |
| | | |
| | | @PostMapping("/create") |
| | | public R<Long> exchangeCreate(@RequestBody ExchangeDto exchangeDto){ |
| | | public R<ExchangeBackDto> exchangeCreate(@RequestBody ExchangeDto exchangeDto){ |
| | | TExchangeOrder tExchangeOrder = new TExchangeOrder(); |
| | | tExchangeOrder.setCode(OrderCodeUtil.getOrderCode("DH")); |
| | | tExchangeOrder.setAppUserId(exchangeDto.getUserId()); |
| | |
| | | tExchangeOrder.setCreateTime(LocalDateTime.now()); |
| | | tExchangeOrder.setDelFlag(false); |
| | | exchangeOrderService.save(tExchangeOrder); |
| | | return R.ok(tExchangeOrder.getId()); |
| | | ExchangeBackDto exchangeBackDto = new ExchangeBackDto(); |
| | | exchangeBackDto.setId(tExchangeOrder.getId()); |
| | | exchangeBackDto.setCode(tExchangeOrder.getCode()); |
| | | return R.ok(exchangeBackDto); |
| | | |
| | | } |
| | | |
| | |
| | | package com.ruoyi.order.controller; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | |
| | | import com.ruoyi.order.api.query.ShoppingOrderQuery; |
| | | import com.ruoyi.order.dto.*; |
| | | import com.ruoyi.order.service.TShoppingOrderService; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.other.api.feignClient.CouponClient; |
| | | import com.ruoyi.other.api.feignClient.GoodsClient; |
| | | import com.ruoyi.payment.api.feignClient.AliPaymentClient; |
| | |
| | | private GoodsClient goodsClient; |
| | | @Resource |
| | | private CouponClient couponClient; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private AliPaymentClient aliPaymentClient; |
| | | @Resource |
| | | private WxPaymentClient wxPaymentClient; |
| | | @Resource |
| | | private AppCouponClient appCouponClient; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | @PostMapping("/getShoppingOrderList") |
| | |
| | | PageInfo<TShoppingOrder> res = shoppingOrderService.pageList(query); |
| | | return AjaxResult.success(res); |
| | | } |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @GetMapping("/getShoppingOrderInfoById") |
| | | @ApiOperation(value = "根据订单id查看订单详情", tags = {"管理后台-购物订单"}) |
| | | public AjaxResult<TShoppingOrder> getShoppingOrderList(String id) { |
| | |
| | | byId.setReceivingAddress(data.getAddress()); |
| | | } |
| | | } |
| | | if (byId.getOrderType()==1){ |
| | | TGoods data = goodsClient.getGoodsById(byId.getGoodsId()).getData(); |
| | | if (data!=null){ |
| | | byId.setName(data.getName()); |
| | | } |
| | | }else { |
| | | TCoupon data = couponClient.getCouponById1(byId.getCouponId()).getData(); |
| | | if (data!=null){ |
| | | byId.setName(data.getName()); |
| | | } |
| | | } |
| | | return AjaxResult.success(byId); |
| | | } |
| | | |
| | | @GetMapping("/deleteShoppingOrder") |
| | | @ApiOperation(value = "批量删除订单", tags = {"管理后台-购物订单"}) |
| | | public AjaxResult<TShoppingOrder> deleteShoppingOrder(String ids) { |
| | | shoppingOrderService.removeBatchByIds(Arrays.asList(ids.split(","))); |
| | | return AjaxResult.success(); |
| | | } |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private AliPaymentClient aliPaymentClient; |
| | | @Resource |
| | | private WxPaymentClient wxPaymentClient; |
| | | @Resource |
| | | private AppCouponClient appCouponClient; |
| | | |
| | | @GetMapping("/cancelShoppingOrder") |
| | | @ApiOperation(value = "取消订单", tags = {"管理后台-购物订单"}) |
| | | public AjaxResult cancelShoppingOrder(String id) { |
| | |
| | | shoppingOrderService.updateById(byId); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @GetMapping("/consignerShoppingOrder") |
| | | @ApiOperation(value = "发货", tags = {"管理后台-购物订单"}) |
| | | public AjaxResult consignerShoppingOrder(String id,String companyName,String code) { |
| | |
| | | shoppingOrderService.updateById(byId); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @GetMapping("/getMyShoppingOrderList") |
| | | @ApiOperation(value = "获取购买订单列表", tags = {"小程序-商城购买订单"}) |
| | | public AjaxResult<Map<String, Object>> getMyShoppingOrderList(GetMyShoppingOrderList query){ |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/getMyShoppingOrderInfo/{id}") |
| | | @ApiOperation(value = "获取购买订单详情", tags = {"小程序-商城购买订单","管理后台-支付订单-订单信息"}) |
| | | public AjaxResult<MyShoppingOrderInfo> getMyShoppingOrderInfo(@PathVariable String id){ |
| | | MyShoppingOrderInfo info = shoppingOrderService.getMyShoppingOrderInfo(id); |
| | | return AjaxResult.success(info); |
| | | } |
| | | |
| | | |
| | | |
| | | @PutMapping("/confirmReceipt/{id}") |
| | |
| | | shoppingOrderService.cancelShoppingOrderWxRefund(out_refund_no, refund_id, tradeState, success_time); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | package com.ruoyi.order.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.order.api.model.TExchangeOrder; |
| | | import com.ruoyi.order.api.query.ShoppingOrderQuery; |
| | | import com.ruoyi.order.dto.ExchangeOrderGoodsInfo; |
| | | import com.ruoyi.order.dto.GetMyExchangeOrder; |
| | | import com.ruoyi.order.dto.MyExchangeOrderList; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | import com.ruoyi.integration.api.vo.GetPlatformStopChargingReply; |
| | | import com.ruoyi.order.api.dto.SettlementConfirmAdd; |
| | | import com.ruoyi.order.api.feignClient.AccountingStrategyDetailOrderClient; |
| | | import com.ruoyi.order.api.feignClient.AccountingStrategyOrderClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient; |
| | | import com.ruoyi.order.api.model.*; |
| | | import com.ruoyi.order.api.query.ChargingOrderQuery; |
| | |
| | | import com.ruoyi.order.service.TChargingOrderService; |
| | | import com.ruoyi.order.service.TOrderEvaluateService; |
| | | import com.ruoyi.order.service.*; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.other.api.domain.*; |
| | | import com.ruoyi.order.vo.ChargingOrderListInfoVO; |
| | | import com.ruoyi.other.api.domain.TIntegralRule; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.feignClient.*; |
| | | import com.ruoyi.payment.api.feignClient.AliPaymentClient; |
| | | import com.ruoyi.payment.api.feignClient.WxPaymentClient; |
| | |
| | | private AccountingStrategyDetailOrderClient accountingStrategyDetailOrderClient; |
| | | |
| | | @Resource |
| | | private AccountingStrategyOrderClient accountingStrategyOrderClient; |
| | | |
| | | @Resource |
| | | private AccountingStrategyClient accountingStrategyClient; |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private VipClient vipClient; |
| | | |
| | | @Resource |
| | | private UserTagClient userTagClient; |
| | | |
| | | @Resource |
| | | private AppUserTagClient appUserTagClient; |
| | | |
| | | //计数器 |
| | | private Map<String, Integer> counter_map = new HashMap<>(); |
| | |
| | | chargingOrder.setRechargePaymentStatus(1); |
| | | chargingOrder.setRechargeAmount(addChargingOrder.getPaymentAmount()); |
| | | chargingOrder.setAppCouponId(addChargingOrder.getAppUserCouponId()); |
| | | if(null != appUser.getVipId()){ |
| | | chargingOrder.setVipDiscount(new BigDecimal(10)); |
| | | chargingOrder.setVipDiscountAmount(BigDecimal.ZERO); |
| | | |
| | | Site site = siteClient.getSiteByIds(Arrays.asList(tChargingGun.getSiteId())).getData().get(0); |
| | | Integer accountingStrategyId = tChargingGun.getAccountingStrategyId(); |
| | | if(null == accountingStrategyId){ |
| | | //查询站点上面的计费策略 |
| | | accountingStrategyId = site.getAccountingStrategyId(); |
| | | } |
| | | TAccountingStrategy accountingStrategy = accountingStrategyClient.getAccountingStrategyById(accountingStrategyId).getData(); |
| | | |
| | | //直营站点才可以享受会员折扣 |
| | | if(null != appUser.getVipId() && 1 == site.getBusinessCategory()){ |
| | | TVip vip = vipClient.getInfo(appUser.getVipId()).getData(); |
| | | BigDecimal discount = null; |
| | | if(1 == vip.getType()){ |
| | | //普通会员折扣使用积分策略上的折扣,且有最高优惠金额 |
| | | discount = accountingStrategy.getDiscount(); |
| | | }else{ |
| | | //内部会员使用会员信息设置的折扣,没有最高优惠金额 |
| | | discount = vip.getDiscount(); |
| | | } |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(appUser.getId()); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | |
| | | if(null != vipDetail){ |
| | | Integer chargeNum = vipDetail.getChargeNum(); |
| | | if(0 > chargeNum){ |
| | | chargingOrder.setVipDiscount(vipDetail.getDiscount()); |
| | | BigDecimal discountAmount = addChargingOrder.getPaymentAmount().multiply((new BigDecimal(10) |
| | | .subtract(vipDetail.getDiscount())).divide(new BigDecimal(10))).setScale(4, BigDecimal.ROUND_HALF_EVEN); |
| | | chargingOrder.setVipDiscountAmount(discountAmount); |
| | | chargingOrder.setVipDiscount(discount); |
| | | } |
| | | } |
| | | |
| | | } |
| | | this.save(chargingOrder); |
| | | |
| | | //添加订单的计费策略 |
| | | Integer accountingStrategyId = tChargingGun.getAccountingStrategyId(); |
| | | if(null == accountingStrategyId){ |
| | | //查询站点上面的计费策略 |
| | | Site site = siteClient.getSiteByIds(Arrays.asList(tChargingGun.getSiteId())).getData().get(0); |
| | | accountingStrategyId = site.getAccountingStrategyId(); |
| | | } |
| | | TAccountingStrategy accountingStrategy = accountingStrategyClient.getAccountingStrategyById(accountingStrategyId).getData(); |
| | | List<TAccountingStrategyDetail> strategyDetailList = accountingStrategyDetailClient.getListByAccountingStrategyId(accountingStrategyId).getData(); |
| | | AccountingStrategyOrder accountingStrategyOrder = new AccountingStrategyOrder(); |
| | | BeanUtils.copyProperties(accountingStrategy, accountingStrategyOrder); |
| | |
| | | |
| | | //根据当前充值的金额和计费模板算出充电的金额 |
| | | BigDecimal rechargeAmount = chargingOrder.getRechargeAmount(); |
| | | //计算充电金额,会员需要将折扣金额加入到充电总金额中 |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | AccountingStrategyDetailOrder strategyDetail = accountingStrategyDetailOrderClient.getNowAccountingStrategyDetailOrder(chargingOrder.getId()).getData(); |
| | | //总单价 |
| | | BigDecimal totalUnitPrice = strategyDetail.getServiceCharge().add(strategyDetail.getElectrovalence()); |
| | | //计算能充电的度数 |
| | | BigDecimal degrees = rechargeAmount.divide(totalUnitPrice); |
| | | BigDecimal rechargeAmount1 = new BigDecimal(rechargeAmount.toString()); |
| | | Long now = System.currentTimeMillis(); |
| | | //根据支付金额,获取出使用的计费策略明细 |
| | | //计算电费金额和服务费 |
| | | BigDecimal serviceCharge = strategyDetail.getServiceCharge().multiply(degrees); |
| | | BigDecimal electrovalence = strategyDetail.getElectrovalence().multiply(degrees); |
| | | BigDecimal serviceCharge = BigDecimal.ZERO; |
| | | BigDecimal electrovalence = BigDecimal.ZERO; |
| | | BigDecimal discountAmount = BigDecimal.ZERO; |
| | | BigDecimal discount = chargingOrder.getVipDiscount(); |
| | | //先根据额定功率计算出每秒充电度数,然后计算出支付金额能充多少度电 |
| | | TChargingGun tChargingGun = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | BigDecimal s_degrees = tChargingGun.getRatedPower().divide(new BigDecimal(3600)); |
| | | |
| | | //再处理会员折扣 |
| | | BigDecimal discount = BigDecimal.ZERO; |
| | | |
| | | TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | List<AccountingStrategyDetailOrder> list = accountingStrategyDetailOrderClient.getAllAccountingStrategyDetailOrder(chargingOrder.getId()).getData(); |
| | | for (AccountingStrategyDetailOrder accountingStrategyDetailOrder : list) { |
| | | AccountingStrategyOrder accountingStrategyOrder = accountingStrategyOrderClient.getAccountingStrategyOrderById(accountingStrategyDetailOrder.getAccountingStrategyOrderId()).getData(); |
| | | Integer start = Integer.valueOf(accountingStrategyDetailOrder.getStartTime().replaceAll(":", "")); |
| | | String[] split = accountingStrategyDetailOrder.getEndTime().split(":"); |
| | | if(now >= start){ |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); |
| | | calendar.set(Calendar.MINUTE, Integer.valueOf(split[1])); |
| | | //到此策略结束的秒数 |
| | | long m = (calendar.getTimeInMillis() - now) / 1000; |
| | | //每度电的单价 |
| | | BigDecimal total_unit = accountingStrategyDetailOrder.getElectrovalence().add(accountingStrategyDetailOrder.getServiceCharge()); |
| | | //每秒需要支付的金额 |
| | | BigDecimal multiply = s_degrees.multiply(total_unit); |
| | | //计算充值金额能充多长时间的电 |
| | | long times = rechargeAmount1.divide(multiply, 0, RoundingMode.DOWN).longValue(); |
| | | if(times > m){ |
| | | //充电时间跨度两个计费策略,需要继续对下一个策略进行计算 |
| | | electrovalence = accountingStrategyDetailOrder.getElectrovalence().multiply(s_degrees).multiply(new BigDecimal(m)); |
| | | serviceCharge = accountingStrategyDetailOrder.getServiceCharge().multiply(s_degrees).multiply(new BigDecimal(m)); |
| | | discountAmount = discountAmount.add(serviceCharge.multiply((new BigDecimal(10).subtract(discount)).divide(new BigDecimal(10)))); |
| | | rechargeAmount1 = rechargeAmount1.subtract(multiply.multiply(new BigDecimal(m))); |
| | | }else{ |
| | | electrovalence = accountingStrategyDetailOrder.getElectrovalence().multiply(s_degrees).multiply(new BigDecimal(times)); |
| | | serviceCharge = accountingStrategyDetailOrder.getServiceCharge().multiply(s_degrees).multiply(new BigDecimal(times)); |
| | | discountAmount = discountAmount.add(serviceCharge.multiply((new BigDecimal(10).subtract(discount)).divide(new BigDecimal(10)))); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if(discountAmount.compareTo(BigDecimal.ZERO) >= 0){ |
| | | //计算会员最大优惠金额 |
| | | if(null != appUser.getVipId()){ |
| | | TVip vip = vipClient.getInfo(appUser.getVipId()).getData(); |
| | | BigDecimal maximumDeduction = vip.getMaximumDeduction(); |
| | | //普通会员有最高优惠限制 |
| | | if(vip.getType() == 1 && discountAmount.compareTo(maximumDeduction) > 0){ |
| | | discountAmount = maximumDeduction; |
| | | } |
| | | |
| | | //判断会员是否还有充电优惠次数 |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(chargingOrder.getAppUserId()); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | TAppUserVipDetail data = appUserVipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData(); |
| | | if(data.getChargeNum() > 0){ |
| | | discount = serviceCharge.multiply(data.getDiscount().divide(new BigDecimal(10))); |
| | | data.setChargeNum(data.getChargeNum() - 1); |
| | | appUserVipDetailClient.updateAppUserVipDetail(data); |
| | | //会员有充电优惠次数,直接将优惠金额加入到充电费用中增加充电时长 |
| | | electrovalence = electrovalence.add(discountAmount); |
| | | } |
| | | } |
| | | electrovalence = electrovalence.add(discount); |
| | | } |
| | | chargingOrder.setChargeAmount(electrovalence); |
| | | chargingOrder.setVipDiscountAmount(discountAmount); |
| | | this.updateById(chargingOrder); |
| | | |
| | | |
| | | TChargingPile chargingPile = chargingPileClient.getChargingPileById(chargingGun.getChargingPileId()).getData(); |
| | | TChargingPile chargingPile = chargingPileClient.getChargingPileById(tChargingGun.getChargingPileId()).getData(); |
| | | //调用远程启动充电消息 |
| | | PlatformStartCharging platformStartCharging = new PlatformStartCharging(); |
| | | platformStartCharging.setTransaction_serial_number(chargingOrder.getCode()); |
| | | platformStartCharging.setCharging_pile_code(chargingPile.getCode()); |
| | | platformStartCharging.setCharging_gun_code(chargingGun.getCode()); |
| | | platformStartCharging.setCharging_gun_code(tChargingGun.getCode()); |
| | | //使用订单id作为逻辑卡号 |
| | | platformStartCharging.setCard_number(chargingOrder.getId().toString()); |
| | | platformStartCharging.setAccount_balance(electrovalence); |
| | |
| | | PreChargeCheck preChargeCheck1 = redisService.getCacheObject(key); |
| | | //状态为5的时候,硬件会间隔60秒后再次检测,依然未插枪,则不启动充电 |
| | | //因这里是间隔5秒执行检测,所以累计次数在30次以上 |
| | | if(failure_cause == 5 && null == counter || counter < 35){ |
| | | if(failure_cause == 5 && (null == counter || counter < 35)){ |
| | | counter++; |
| | | counter_map.put(code, counter); |
| | | //启动失败 |
| | |
| | | chargingOrder.setStatus(4); |
| | | chargingOrder.setEndMode(1); |
| | | this.updateById(chargingOrder); |
| | | |
| | | //处理用户标签数据 |
| | | List<TUserTag> data = userTagClient.getAllUserTag().getData(); |
| | | //累计充电次数 |
| | | long count1 = this.count(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, chargingOrder.getAppUserId()) |
| | | .eq(TChargingOrder::getRechargePaymentStatus, 2).isNotNull(TChargingOrder::getPaymentAmount).eq(TChargingOrder::getDelFlag, 0)); |
| | | List<TUserTag> userTagList1 = data.stream().filter(s -> s.getStandardCondition() == 1).collect(Collectors.toList()); |
| | | int old_times = 0; |
| | | Integer userTagId = null; |
| | | for (TUserTag tUserTag : userTagList1) { |
| | | Integer times = JSON.parseObject(tUserTag.getConditions()).getInteger("times"); |
| | | //加上本次充电 |
| | | //获取最大值标签 |
| | | if((count1 + 1) >= times && old_times < times){ |
| | | userTagId = tUserTag.getId(); |
| | | old_times = times; |
| | | } |
| | | } |
| | | if(null != userTagId){ |
| | | TAppUserTag appUserTag = new TAppUserTag(); |
| | | appUserTag.setAppUserId(chargingOrder.getAppUserId()); |
| | | appUserTag.setUserTagId(userTagId); |
| | | TAppUserTag data1 = appUserTagClient.getUserTag(appUserTag).getData(); |
| | | if(null == data1){ |
| | | data1 = new TAppUserTag(); |
| | | data1.setAppUserId(chargingOrder.getAppUserId()); |
| | | data1.setUserTagId(userTagId); |
| | | data1.setCreateTime(LocalDateTime.now()); |
| | | appUserTagClient.addUserTag(data1); |
| | | } |
| | | } |
| | | //充电评率 |
| | | List<TUserTag> userTagList2 = data.stream().filter(s -> s.getStandardCondition() == 2).collect(Collectors.toList()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | for (TUserTag tUserTag : userTagList2) { |
| | | TAppUserTag appUserTag = new TAppUserTag(); |
| | | appUserTag.setAppUserId(chargingOrder.getAppUserId()); |
| | | appUserTag.setUserTagId(tUserTag.getId()); |
| | | TAppUserTag data1 = appUserTagClient.getUserTag(appUserTag).getData(); |
| | | if(null == data1){ |
| | | Integer day = JSON.parseObject(tUserTag.getConditions()).getInteger("day"); |
| | | Integer times = JSON.parseObject(tUserTag.getConditions()).getInteger("times"); |
| | | Calendar start = Calendar.getInstance(); |
| | | start.set(Calendar.DAY_OF_YEAR, start.get(Calendar.DAY_OF_YEAR) + day); |
| | | count1 = this.count(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, chargingOrder.getAppUserId()) |
| | | .eq(TChargingOrder::getRechargePaymentStatus, 2).isNotNull(TChargingOrder::getPaymentAmount) |
| | | .between(TChargingOrder::getStartTime, sdf.format(start.getTime()), sdf.format(new Date())).eq(TChargingOrder::getDelFlag, 0)); |
| | | //加上本次充电 |
| | | if(count1 >= times){ |
| | | data1 = new TAppUserTag(); |
| | | data1.setAppUserId(chargingOrder.getAppUserId()); |
| | | data1.setUserTagId(tUserTag.getId()); |
| | | data1.setCreateTime(LocalDateTime.now()); |
| | | appUserTagClient.addUserTag(data1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //异步线程处理停机 |
| | | ExecutorService cachedThreadPool = Executors.newFixedThreadPool(1); |
| | |
| | | model.setOut_trade_no(chargingOrder.getCode()); |
| | | model.setOut_refund_no(chargingOrderRefund.getRefundCode()); |
| | | model.setReason("充电完成退款"); |
| | | model.setNotify_url("http://221.182.45.100:9000/order/t-charging-order/chargingOrderStartupFailureWxRefund"); |
| | | model.setNotify_url("/order/t-charging-order/chargingOrderStartupFailureWxRefund"); |
| | | WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount(); |
| | | amount.setRefund(refundAmount.multiply(new BigDecimal(100)).intValue()); |
| | | amount.setTotal(rechargeAmount.multiply(new BigDecimal(100)).intValue()); |
| | |
| | | model.setOut_refund_no(chargingOrderRefund.getRefundCode()); |
| | | model.setTransaction_id(tChargingOrder.getRechargeSerialNumber()); |
| | | model.setReason("取消订单"); |
| | | model.setNotify_url("http://221.182.45.100:9000/order/t-shopping-order/cancelShoppingOrderWxRefund"); |
| | | model.setNotify_url("/order/t-shopping-order/cancelShoppingOrderWxRefund"); |
| | | WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount(); |
| | | amount.setRefund(payOrderQueryDto.getRefundAmount().multiply(new BigDecimal(100)).intValue()); |
| | | amount.setTotal(tChargingOrder.getPaymentAmount().multiply(new BigDecimal(100)).intValue()); |
| | |
| | | model.setOut_refund_no(chargingOrderRefund.getRefundCode()); |
| | | model.setTransaction_id(tChargingOrder.getSerialNumber()); |
| | | model.setReason("取消订单"); |
| | | model.setNotify_url("http://221.182.45.100:9000/order/t-shopping-order/cancelShoppingOrderWxRefund"); |
| | | model.setNotify_url("/order/t-shopping-order/cancelShoppingOrderWxRefund"); |
| | | WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount(); |
| | | amount.setRefund(payOrderQueryDto.getRefundAmount().multiply(new BigDecimal(100)).intValue()); |
| | | amount.setTotal(tChargingOrder.getPaymentAmount().multiply(new BigDecimal(100)).intValue()); |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.feignClient.AppUserAddressClient; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.feignClient.AppUserIntegralChangeClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.api.model.TAppUserAddress; |
| | | import com.ruoyi.account.api.model.TAppUserIntegralChange; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.api.model.TExchangeOrder; |
| | |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Resource |
| | | private AppUserIntegralChangeClient appUserIntegralChangeClient; |
| | | |
| | | |
| | | |
| | |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ruoyi.order.mapper.TShoppingOrderMapper; |
| | | import com.ruoyi.order.service.TShoppingOrderRefundService; |
| | | import com.ruoyi.order.service.TShoppingOrderService; |
| | | import com.ruoyi.order.util.RedisLock; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.other.api.feignClient.CouponClient; |
| | |
| | | import com.ruoyi.payment.api.vo.AliQueryOrder; |
| | | import com.ruoyi.payment.api.vo.NotifyV3PayDecodeRespBody; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private TShoppingOrderRefundService shoppingOrderRefundService; |
| | | |
| | | @Autowired |
| | | public RedisTemplate redisTemplate; |
| | | |
| | | |
| | | |
| | |
| | | model.setTransaction_id(shoppingOrder.getSerialNumber()); |
| | | model.setOut_refund_no(shoppingOrderRefund.getRefundCode()); |
| | | model.setReason("取消订单"); |
| | | model.setNotify_url("http://221.182.45.100:9000/order/t-shopping-order/cancelShoppingOrderWxRefund"); |
| | | model.setNotify_url("/order/t-shopping-order/cancelShoppingOrderWxRefund"); |
| | | WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount(); |
| | | amount.setRefund(refundAmount.multiply(new BigDecimal(100)).intValue()); |
| | | amount.setTotal(shoppingOrder.getPaymentAmount().multiply(new BigDecimal(100)).intValue()); |
| | |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | TShoppingOrder shoppingOrder = this.getById(one.getShoppingOrderId()); |
| | | //商品 |
| | | if(shoppingOrder.getOrderType() == 1){ |
| | | // todo 需完善redis锁 |
| | | //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锁 |
| | | //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(); |
New file |
| | |
| | | package com.ruoyi.order.util; |
| | | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | |
| | | import java.util.UUID; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/9/26 18:43 |
| | | */ |
| | | public class RedisLock { |
| | | private RedisTemplate<String, String> redisTemplate; |
| | | private String lockKey; |
| | | private int expireTime; // 锁的超时时间 |
| | | private int timeout; // 获取锁的超时时间 |
| | | |
| | | |
| | | public RedisLock(RedisTemplate<String, String> redisTemplate, String lockKey, int expireTime, int timeout) { |
| | | this.redisTemplate = redisTemplate; |
| | | this.lockKey = lockKey; |
| | | this.expireTime = expireTime; |
| | | this.timeout = timeout; |
| | | } |
| | | |
| | | public boolean lock() { |
| | | String identifier = UUID.randomUUID().toString(); |
| | | long end = System.currentTimeMillis() + timeout; |
| | | while (System.currentTimeMillis() < end) { |
| | | if (redisTemplate.opsForValue().setIfAbsent(lockKey, identifier, expireTime, TimeUnit.SECONDS)) { |
| | | return true; |
| | | } |
| | | // 可以使用延时来减少CPU占用 |
| | | try { |
| | | Thread.sleep(100); |
| | | } catch (InterruptedException e) { |
| | | Thread.currentThread().interrupt(); |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public boolean unlock() { |
| | | String identifier = redisTemplate.opsForValue().get(lockKey); |
| | | if (identifier != null && identifier.equals(UUID.randomUUID().toString())) { |
| | | redisTemplate.delete(lockKey); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | |
| | | </if> |
| | | </select> |
| | | <select id="payOrderQuery" resultType="com.ruoyi.order.dto.PayOrderDto"> |
| | | SELECT * FROM (SELECT |
| | | SELECT o.*,i.phone FROM (SELECT |
| | | id, |
| | | `code`, |
| | | 1 as type, |
| | | title, |
| | | phone, |
| | | `status`, |
| | | order_amount, |
| | | payment_amount , |
| | |
| | | pay_time, |
| | | refund_status, |
| | | (payment_amount-refund_amount) as final_amount, |
| | | del_flag |
| | | del_flag, |
| | | app_user_id |
| | | FROM |
| | | charging_pile_order.t_charging_order |
| | | where recharge_payment_status = 2 |
| | |
| | | `code`, |
| | | 2 as type, |
| | | title, |
| | | phone, |
| | | `status`, |
| | | order_amount, |
| | | payment_amount , |
| | |
| | | pay_time, |
| | | refund_status, |
| | | (payment_amount-refund_amount) as final_amount, |
| | | del_flag |
| | | del_flag, |
| | | app_user_id |
| | | FROM |
| | | charging_pile_order.t_shopping_order |
| | | where payment_status = 2 |
| | |
| | | `code`, |
| | | 3 as type, |
| | | title, |
| | | phone, |
| | | payment_status AS `status`, |
| | | order_amount, |
| | | payment_amount , |
| | |
| | | pay_time, |
| | | refund_status, |
| | | (payment_amount-refund_amount) as final_amount, |
| | | del_flag |
| | | del_flag, |
| | | app_user_id |
| | | |
| | | FROM |
| | | charging_pile_order.t_vip_order |
| | |
| | | `code`, |
| | | 4 as type, |
| | | title, |
| | | phone, |
| | | `status`, |
| | | order_amount , |
| | | order_amount as payment_amount, |
| | |
| | | out_parking_time as pay_time, |
| | | null as refund_status, |
| | | 0 as final_amount, |
| | | 0 as del_flag |
| | | 0 as del_flag, |
| | | app_user_id |
| | | FROM |
| | | charging_pile_service.t_parking_record ) o |
| | | LEFT JOIN `charging_pile_account`.`t_app_user` i on o.app_user_id = i.id |
| | | <where> |
| | | o.del_flag = 0 |
| | | <if test="data.code != null and data.code != ''"> |
| | |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | <if test="data.isRefund == 1"> |
| | | AND o.refund_status is not null |
| | | </if> |
| | | <if test="data.isRefund == 1"> |
| | | AND o.refund_status is null |
| | | </if> |
| | | |
| | | </where> |
| | | ORDER BY o.create_time desc |
| | | |
| | |
| | | re.refund_remark, |
| | | co.recharge_serial_number as serail_number, |
| | | co.payment_amount, |
| | | co.pay_time |
| | | co.create_time as pay_time, |
| | | co.id as order_id, |
| | | co.app_user_id as user_id |
| | | FROM t_charging_order_refund re |
| | | LEFT JOIN t_charging_order co ON re.charging_order_id = co.id |
| | | UNION ALL |
| | |
| | | re.refund_remark, |
| | | so.serial_number, |
| | | so.payment_amount, |
| | | so.pay_time |
| | | so.create_time as pay_time, |
| | | so.id as order_id, |
| | | so.app_user_id as user_id |
| | | FROM t_shopping_order_refund re |
| | | LEFT JOIN t_shopping_order so on re.shopping_order_id = so.id |
| | | UNION ALL |
| | |
| | | vr.refund_remark, |
| | | vo.serial_number, |
| | | vo.payment_amount, |
| | | vo.pay_time |
| | | vo.create_time as pay_time, |
| | | vo.id as order_id, |
| | | vo.app_user_id as user_id |
| | | FROM t_vip_order_refund vr |
| | | LEFT JOIN t_vip_order vo on vr.vip_order_id = vo.id |
| | | |
| | |
| | | AND o.refund_code LIKE CONCAT('%',#{data.refundCode},'%') |
| | | </if> |
| | | </where> |
| | | |
| | | order by o.refund_time desc |
| | | |
| | | </select> |
| | | <select id="chargingOrderGroup" resultType="com.ruoyi.common.core.dto.ChargingOrderGroup"> |
| | |
| | | <if test="statisticsQueryDto.type == 2"> |
| | | end_time |
| | | </if> |
| | | , '%Y-%m-%d %H' ) as time, |
| | | , '%H:00' ) as time, |
| | | SUM(service_charge) as servicecharge, |
| | | SUM(electrovalence) as electrovalence, |
| | | SUM(electricity) as electricity, |
| | | count(1) as orderCount |
| | | FROM |
| | | t_charging_order |
| | |
| | | , '%Y-%m-%d' ) as time, |
| | | SUM(service_charge) as servicecharge, |
| | | SUM(electrovalence) as electrovalence, |
| | | count(1) as orderCount |
| | | count(1) as orderCount, |
| | | SUM(electricity) as electricity |
| | | FROM |
| | | t_charging_order |
| | | |
| | | WHERE del_flag = 0 and recharge_payment_status = 2 and DATE( |
| | | <if test="statisticsQueryDto.type == 1"> |
| | | start_time |
| | |
| | | , '%Y-%m' ) as time, |
| | | SUM(service_charge) as servicecharge, |
| | | SUM(electrovalence) as electrovalence, |
| | | count(1) as orderCount |
| | | count(1) as orderCount, |
| | | SUM(electricity) as electricity |
| | | FROM |
| | | t_charging_order |
| | | |
| | |
| | | payment_amount |
| | | FROM |
| | | t_shopping_order |
| | | <where> |
| | | WHERE del_flag = 0 and payment_status = 2 and ISNULL(refund_status) and status!=4 |
| | | WHERE del_flag = 0 and payment_status = 2 and ISNULL(refund_status) and status!=4 and |
| | | |
| | | DATE_FORMAT(create_time, '%Y-%m-%d') between #{statisticsQueryDto.startTime} and #{statisticsQueryDto.endTime} |
| | | |
| | | |
| | | </where> |
| | | |
| | | |
| | | ) AS subquery |
| | | GROUP BY |
| | | DATE_FORMAT( subquery.create_time, '%Y-%m-%d' ); |
| | | DATE_FORMAT( subquery.create_time, '%Y-%m-%d' ) |
| | | |
| | | |
| | | </select> |
| | |
| | | public R<Page<TCompany>> unitPage(@RequestBody UnitListQueryDto unitListQueryDto) { |
| | | Page<TCompany> page = companyService.lambdaQuery() |
| | | .orderByDesc(TCompany::getCreateTime) |
| | | .like(unitListQueryDto.getCompanyName() != null && unitListQueryDto.getCompanyName().isEmpty(), TCompany::getName, unitListQueryDto.getCompanyName()) |
| | | .like(unitListQueryDto.getCompanyName() != null && unitListQueryDto.getCompanyName()!="", TCompany::getName, unitListQueryDto.getCompanyName()) |
| | | .page(Page.of(unitListQueryDto.getPageCurr(), unitListQueryDto.getPageSize())); |
| | | return R.ok(page); |
| | | } |
| | |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.dto.AppGoodQuery; |
| | | import com.ruoyi.common.core.dto.ExchangeBackDto; |
| | | import com.ruoyi.common.core.dto.PointChangeDto; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | |
| | | return R.ok(); |
| | | |
| | | } |
| | | @ApiOperation(tags = {"小程序-" + |
| | | "兑换商城"},value = "积分兑换商品") |
| | | @ApiOperation(tags = {"小程序-兑换商城"},value = "积分兑换商品") |
| | | @PostMapping(value = "/app/shop") |
| | | public AjaxResult<PageInfo<TGoods>> shop(@RequestBody ExchangeDto exchangeDto) { |
| | | //检查当前用户积分是否够 |
| | |
| | | Long count = orderClient.getExchangeById(exchangeDto.getGoodId(), userId,exchangeDto.getGoodType()).getData(); |
| | | if (good.getLimitExchangeTimes() != -1 && count >= good.getLimitExchangeTimes()) { |
| | | return AjaxResult.error("当前用户已兑换"+count+"张"); |
| | | }else { |
| | | //减少库存 |
| | | good.setInventory(good.getInventory()-exchangeDto.getNum()); |
| | | } |
| | | if (user.getPoints()<good.getRedeemPoints()){ |
| | | return AjaxResult.error("当前用户积分不足"); |
| | |
| | | point = coupon.getRedeemPoints(); |
| | | |
| | | Long count = orderClient.getExchangeById(exchangeDto.getGoodId(), userId,exchangeDto.getGoodType()).getData(); |
| | | if (coupon.getInventoryQuantity() != -1 && count >= coupon.getInventoryQuantity()) { |
| | | return AjaxResult.error("当前用户已到达兑换"+coupon+"次"); |
| | | } |
| | | if (user.getPoints()<point){ |
| | | return AjaxResult.error("当前用户积分不足"); |
| | | } |
| | | if (coupon.getInventoryQuantity() != -1 && count >= coupon.getInventoryQuantity()) { |
| | | return AjaxResult.error("当前用户已到达兑换"+coupon+"次"); |
| | | }else { |
| | | coupon.setInventoryQuantity(coupon.getInventoryQuantity()-exchangeDto.getNum()); |
| | | } |
| | | |
| | | |
| | | } |
| | | exchangeDto.setPoint(point); |
| | | exchangeDto.setUserId(userId); |
| | | //生成积分兑换成功的订单 |
| | | R<Long> longR = orderClient.exchangeCreate(exchangeDto); |
| | | R<ExchangeBackDto> longR = orderClient.exchangeCreate(exchangeDto); |
| | | if (exchangeDto.getGoodType()==2) { |
| | | TCoupon coupon = couponService.getById(exchangeDto.getGoodId()); |
| | | |
| | |
| | | pointChangeDto.setPoints(point); |
| | | pointChangeDto.setRemark(longR.getData().toString()); |
| | | pointChangeDto.setType(6); |
| | | pointChangeDto.setCode(longR.getData().getCode()); |
| | | appUserClient.changeDown(pointChangeDto); |
| | | return AjaxResult.success(); |
| | | |
| | |
| | | package com.ruoyi.other.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.dto.TagListQueryDto; |
| | | import com.ruoyi.account.api.dto.UnitListQueryDto; |
| | |
| | | public R<Page<TUserTag>> page(@RequestBody TagListQueryDto tagListQueryDto) { |
| | | Page<TUserTag> page = tUserTagService.lambdaQuery() |
| | | .orderByDesc(TUserTag::getCreateTime) |
| | | .like(tagListQueryDto.getTagName()!=null&& tagListQueryDto.getTagName().isEmpty(), TUserTag::getName, tagListQueryDto.getTagName()) |
| | | .like(tagListQueryDto.getTagName()!=null&& tagListQueryDto.getTagName()!="", TUserTag::getName, tagListQueryDto.getTagName()) |
| | | .page(Page.of(tagListQueryDto.getPageCurr(), tagListQueryDto.getPageSize())); |
| | | return R.ok(page); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取所有有效数据 |
| | | * @return |
| | | */ |
| | | @PostMapping(value = "/getAllUserTag") |
| | | public R<List<TUserTag>> getAllUserTag(){ |
| | | List<TUserTag> list = tUserTagService.list(new LambdaQueryWrapper<TUserTag>().eq(TUserTag::getDelFlag, 0)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "购买会员", tags = {"小程序-个人中心"}) |
| | | @GetMapping("/vipInfo/pay") |
| | | public R vipInfoPay(@RequestParam("vipId")Integer vipId,@RequestParam("buyType") Integer buyType, |