Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile
| | |
| | | <artifactId>ruoyi-api-system</artifactId> |
| | | <version>${ruoyi.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- 账户接口 --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-account</artifactId> |
| | | <version>${ruoyi.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- 充电桩接口 --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-chargingPile</artifactId> |
| | | <version>${ruoyi.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- 充电桩硬件交互接口 --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-integration</artifactId> |
| | | <version>${ruoyi.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- 订单接口 --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-order</artifactId> |
| | | <version>${ruoyi.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- 系统其他接口 --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-other</artifactId> |
| | | <version>${ruoyi.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- 支付接口 --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-payment</artifactId> |
| | | <version>${ruoyi.version}</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | </dependencyManagement> |
| | | |
New file |
| | |
| | | package com.ruoyi.account.api.dto; |
| | | |
| | | import com.ruoyi.common.core.web.domain.BasePojo; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class EnterpriseQuery extends BasePage { |
| | | private String phone; |
| | | } |
| | |
| | | Integer vipTypeId; |
| | | @ApiModelProperty(value = "单位id") |
| | | Integer companyId; |
| | | |
| | | @ApiModelProperty(value = "到期天数1") |
| | | Integer vipEndTime1; |
| | | @ApiModelProperty(value = "到期天数2") |
| | | Integer vipEndTime2; |
| | | |
| | | } |
| | |
| | | @TableField(exist = false) |
| | | private Long orderCount; |
| | | |
| | | @ApiModelProperty("剩余天数") |
| | | @TableField(exist = false) |
| | | private Long lastDays; |
| | | |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "备注") |
| | | private String permissionRemarks; |
| | | @ApiModelProperty(value = "权限菜单") |
| | | private Map<String, Object> menu; |
| | | private List<Map<String, Object>> menu; |
| | | } |
| | |
| | | private String code; |
| | | @ApiModelProperty(value = "站点名称") |
| | | private String name; |
| | | @ApiModelProperty(value = "合作商id") |
| | | private Integer partnerId; |
| | | @ApiModelProperty(value = "合作商名称") |
| | | private String partnerName; |
| | | @ApiModelProperty(value = "站点类型(0=其他,1=公共,2=个人,3=公交(专业),4=环卫(专用),5=物流(专用),6=出租车(专用))") |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | @TableField("establishment_time") |
| | | @ApiModelProperty(value = "建站时间", notes = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDate establishmentTime; |
| | | private LocalDateTime establishmentTime; |
| | | /** |
| | | * 排序 |
| | | */ |
| | |
| | | @TableField("site_id") |
| | | private Integer siteId; |
| | | |
| | | @ApiModelProperty(value = "申请人id") |
| | | @TableField("user_id") |
| | | private Long userId; |
| | | |
| | | @ApiModelProperty(value = "策略名称") |
| | | @TableField("name") |
| | | private String name; |
| | |
| | | |
| | | @ApiModelProperty(value = "站点名称") |
| | | @TableField(exist = false) |
| | | private Integer siteName; |
| | | private String siteName; |
| | | |
| | | @ApiModelProperty(value = "合作商id", required = true) |
| | | @TableField("partner_id") |
| | |
| | | |
| | | @ApiModelProperty(value = "合作商名称") |
| | | @TableField(exist = false) |
| | | private Integer partnerName; |
| | | private String partnerName; |
| | | |
| | | @ApiModelProperty(value = "生产商机构代码") |
| | | @TableField("manufacturer_code") |
| | |
| | | |
| | | @ApiModelProperty(value = "计费策略名称") |
| | | private String name; |
| | | @ApiModelProperty(value = "1=待审核一级,2=待审核二级,3=审核通过,4=驳回") |
| | | private Integer auditStatus; |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "二級审核人员") |
| | | private String twoUserName; |
| | | @ApiModelProperty(value = "申请人名字") |
| | | private String userName; |
| | | |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "查看费率权限") |
| | | private boolean authViewRates = true; |
| | | |
| | | @ApiModelProperty(value = "编辑权限") |
| | | @ApiModelProperty(value = "下载二维码权限") |
| | | private boolean authDownloadQRCode = true; |
| | | |
| | | @ApiModelProperty(value = "编辑权限") |
| | | @ApiModelProperty(value = "查看详情权限") |
| | | private boolean authQueryInfo = true; |
| | | |
| | | @ApiModelProperty(value = "编辑权限") |
| | | @ApiModelProperty(value = "结束充电权限") |
| | | private boolean authEndCharge = true; |
| | | |
| | | } |
| | |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.TExchangeOrder; |
| | | import com.ruoyi.order.api.query.TActivityStatisticsQuery; |
| | | import com.ruoyi.order.api.vo.TActivityVO; |
| | | import com.ruoyi.order.api.vo.ExchangeDto; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<Long> getExchangeById(Integer goodsIds, Long userId) { |
| | | return R.fail("根据订单数" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<Long> exchangeCreate(ExchangeDto exchangeDto) { |
| | | return R.fail("创建订单" + cause.getMessage()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R<TActivityVO> activityStatistics(TActivityStatisticsQuery dto) { |
| | | return R.fail("查询活动费用统计失败:" + cause.getMessage()); |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.api.factory.ChargingOrderFallbackFactory; |
| | | import com.ruoyi.order.api.factory.OrderFallbackFactory; |
| | | import com.ruoyi.order.api.model.TExchangeOrder; |
| | | import com.ruoyi.order.api.vo.ExchangeDto; |
| | | import com.ruoyi.order.api.query.TActivityStatisticsQuery; |
| | | import com.ruoyi.order.api.vo.TActivityVO; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | */ |
| | | @PostMapping("/t-exchange-order/getCodeByOrderId") |
| | | public R<List<String>> getCodeByOrderId(String goodsIds); |
| | | //查询已兑换的订单数 |
| | | @PostMapping("/t-exchange-order/getById") |
| | | public R<Long> getExchangeById(@RequestParam("goodId") Integer goodId,@RequestParam("userId") Long userId); |
| | | @PostMapping("/t-exchange-order/create") |
| | | public R<Long> exchangeCreate(@RequestBody ExchangeDto exchangeDto); |
| | | |
| | | /** |
| | | * 管理后台 活动费用统计 |
| | | * @param |
New file |
| | |
| | | package com.ruoyi.order.api.vo; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ExchangeDto { |
| | | @ApiModelProperty("商品id") |
| | | Integer goodId; |
| | | @ApiModelProperty("地址id") |
| | | Integer addressId; |
| | | @ApiModelProperty("备注") |
| | | String remark; |
| | | @ApiModelProperty(hidden = true) |
| | | Long userId; |
| | | |
| | | |
| | | } |
| | |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-account</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | </project> |
New file |
| | |
| | | package com.ruoyi.other.api.dto; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ExchangeDto { |
| | | @ApiModelProperty("商品id") |
| | | Integer goodId; |
| | | @ApiModelProperty("地址id") |
| | | Integer addressId; |
| | | @ApiModelProperty("备注") |
| | | String remark; |
| | | @ApiModelProperty(hidden = true) |
| | | Long userId; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.other.api.dto; |
| | | |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class TagListQueryDto extends BasePage { |
| | | private String tagName; |
| | | } |
New file |
| | |
| | | package com.ruoyi.other.api.dto; |
| | | |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class UnitListQueryDto extends BasePage { |
| | | private String companyName; |
| | | } |
| | |
| | | package com.ruoyi.other.api.factory; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.dto.TagListQueryDto; |
| | | import com.ruoyi.account.api.dto.UnitListQueryDto; |
| | | import com.ruoyi.account.api.vo.CouponListVOVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TCompany; |
| | | import com.ruoyi.other.api.domain.TIntegralRule; |
| | | import com.ruoyi.other.api.domain.TUserTag; |
| | | import com.ruoyi.other.api.feignClient.IntegralRuleClient; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 商品服务降级处理 |
| | |
| | | package com.ruoyi.other.api.factory; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.dto.TagListQueryDto; |
| | | import com.ruoyi.account.api.dto.UnitListQueryDto; |
| | | import com.ruoyi.account.api.vo.CouponListVOVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TCompany; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TUserTag; |
| | | import com.ruoyi.other.api.dto.TagListQueryDto; |
| | | import com.ruoyi.other.api.dto.UnitListQueryDto; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.vo.CouponListVOVO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | package com.ruoyi.other.api.feignClient; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.dto.TagListQueryDto; |
| | | import com.ruoyi.account.api.dto.UnitListQueryDto; |
| | | import com.ruoyi.account.api.vo.CouponListVOVO; |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TCompany; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TUserTag; |
| | | import com.ruoyi.other.api.dto.TagListQueryDto; |
| | | import com.ruoyi.other.api.dto.UnitListQueryDto; |
| | | import com.ruoyi.other.api.factory.OtherFallbackFactory; |
| | | import com.ruoyi.other.api.vo.CouponListVOVO; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.other.api.vo; |
| | | |
| | | import com.ruoyi.common.core.web.domain.BasePojo; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | @ApiModel("管理后台 优惠券兑换记录列表返回VO") |
| | | public class CouponListVOVO extends BasePojo { |
| | | @ApiModelProperty(value = "优惠券名称") |
| | | private String couponName; |
| | | @ApiModelProperty(value = "优惠方式 1满减 2折扣") |
| | | private Integer preferentialMode; |
| | | @ApiModelProperty(value = "满减--优惠金额") |
| | | private BigDecimal discountAmount; |
| | | @ApiModelProperty(value = "满减--使用门槛 满减条件") |
| | | private BigDecimal meetTheConditions; |
| | | @ApiModelProperty(value = "折扣--折扣") |
| | | private BigDecimal discount; |
| | | @ApiModelProperty(value = "折扣--最高折扣金额") |
| | | private BigDecimal maximumDiscountAmount; |
| | | @ApiModelProperty(value = "优惠券数量") |
| | | private Integer couponCount; |
| | | @ApiModelProperty(value = "有效期") |
| | | private String validityTime; |
| | | @ApiModelProperty(value = "结束时间 前端忽略") |
| | | private LocalDateTime endTime; |
| | | @ApiModelProperty(value = "是否可用") |
| | | private Integer isUse; |
| | | @ApiModelProperty(value = "优惠券id") |
| | | private Long couponId; |
| | | @ApiModelProperty(value = "使用了优惠券后的服务费 用于判断哪一张优惠券优惠力度最大 前端忽略") |
| | | private BigDecimal money; |
| | | @ApiModelProperty(value = "当前用户是否为会员0否1是 前端忽略") |
| | | private Integer isVip; |
| | | } |
| | |
| | | |
| | | import java.util.Date; |
| | | |
| | | 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 com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.core.annotation.Excel; |
| | | import com.ruoyi.common.core.annotation.Excel.ColumnType; |
| | | import com.ruoyi.common.core.web.domain.BaseEntity; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 操作日志记录表 oper_log |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | @TableName("") |
| | | public class SysOperLog extends BaseEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | |
| | | * 日志主键 |
| | | */ |
| | | @Excel(name = "操作序号", cellType = ColumnType.NUMERIC) |
| | | @ApiModelProperty("数据id") |
| | | @TableId(value = "oper_id", type = IdType.AUTO) |
| | | private Long operId; |
| | | |
| | | /** |
| | | * 操作模块 |
| | | */ |
| | | @Excel(name = "操作模块") |
| | | @ApiModelProperty("操作模块") |
| | | private String title; |
| | | |
| | | /** |
| | | * 业务类型(0其它 1新增 2修改 3删除) |
| | | */ |
| | | @Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") |
| | | @ApiModelProperty("0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") |
| | | @TableField("business_type") |
| | | private Integer businessType; |
| | | |
| | | /** |
| | |
| | | * 请求方法 |
| | | */ |
| | | @Excel(name = "请求方法") |
| | | @ApiModelProperty("请求方法") |
| | | private String method; |
| | | |
| | | /** |
| | | * 请求方式 |
| | | */ |
| | | @Excel(name = "请求方式") |
| | | @ApiModelProperty("请求方式") |
| | | @TableField("request_method") |
| | | private String requestMethod; |
| | | |
| | | /** |
| | | * 操作类别(0其它 1后台用户 2手机端用户) |
| | | */ |
| | | @Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户") |
| | | @ApiModelProperty("0=其它,1=后台用户,2=手机端用户") |
| | | @TableField("operator_type") |
| | | private Integer operatorType; |
| | | |
| | | /** |
| | | * 操作人员 |
| | | */ |
| | | @Excel(name = "操作人员") |
| | | @ApiModelProperty("操作人员") |
| | | @TableField("operator_type") |
| | | private String operName; |
| | | |
| | | /** |
| | | * 部门名称 |
| | | */ |
| | | @Excel(name = "部门名称") |
| | | @ApiModelProperty("部门名称") |
| | | private String deptName; |
| | | |
| | | /** |
| | | * 请求url |
| | | */ |
| | | @Excel(name = "请求地址") |
| | | @ApiModelProperty("请求地址") |
| | | private String operUrl; |
| | | |
| | | /** |
| | | * 操作地址 |
| | | */ |
| | | @Excel(name = "操作地址") |
| | | @ApiModelProperty("操作地址") |
| | | private String operIp; |
| | | |
| | | /** |
| | | * 请求参数 |
| | | */ |
| | | @Excel(name = "请求参数") |
| | | @ApiModelProperty("请求参数") |
| | | private String operParam; |
| | | |
| | | /** |
| | | * 返回参数 |
| | | */ |
| | | @Excel(name = "返回参数") |
| | | @ApiModelProperty("返回参数") |
| | | private String jsonResult; |
| | | |
| | | /** |
| | | * 操作状态(0正常 1异常) |
| | | */ |
| | | @Excel(name = "状态", readConverterExp = "0=正常,1=异常") |
| | | @ApiModelProperty("0=正常,1=异常") |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 错误消息 |
| | | */ |
| | | @Excel(name = "错误消息") |
| | | @ApiModelProperty("错误消息") |
| | | private String errorMsg; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty("操作时间") |
| | | private Date operTime; |
| | | |
| | | /** |
| | | * 消耗时间 |
| | | */ |
| | | @Excel(name = "消耗时间", suffix = "毫秒") |
| | | @ApiModelProperty("消耗时间") |
| | | private Long costTime; |
| | | |
| | | public Long getOperId() { |
| | |
| | | <version>${hutool.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-account</artifactId> |
| | | <version>3.6.2</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.constant.MsgConstants; |
| | | import com.ruoyi.common.core.utils.HttpUtils; |
| | | import com.ruoyi.common.core.utils.MsgUtil; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.system.api.domain.SysRole; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.ruoyi.auth.form.LoginBody; |
| | | import com.ruoyi.auth.form.RegisterBody; |
| | |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * token 控制 |
New file |
| | |
| | | package com.ruoyi.common.core.dto; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class SteategyPassDto { |
| | | @ApiModelProperty("备注") |
| | | private String remark; |
| | | @ApiModelProperty("1通过2拒绝") |
| | | private Integer pass; |
| | | @ApiModelProperty("ID") |
| | | private Integer id; |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.utils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | |
| | | /** |
| | | * @Description 活动订单操作 |
| | | * @Author xiaochen |
| | | * @Date 2021/7/28 10:26 |
| | | */ |
| | | public class CodeGenerateUtils { |
| | | |
| | | /** |
| | | * @return |
| | | * @Description 获取商品编码 |
| | | * 商品编码规则:nanoTime(后5位)*5位随机数(10000~99999) |
| | | * @Author xiaochen |
| | | */ |
| | | public static String generateProductCode() { |
| | | long nanoPart = System.nanoTime() % 100000L; |
| | | if (nanoPart < 10000L) { |
| | | nanoPart += 10000L; |
| | | } |
| | | long randomPart = (long) (Math.random() * (90000) + 10000); |
| | | String code = "0" + String.valueOf((new BigDecimal(nanoPart).multiply(new BigDecimal(randomPart)))); |
| | | return code.substring(code.length() - 10); |
| | | } |
| | | |
| | | /** |
| | | * @param id: 用户id |
| | | * @return |
| | | * @Description 生成订单编号 |
| | | * 订单编号规则:(10位):(年末尾*月,取后2位)+(用户ID%3.33*日取整后2位)+(timestamp*10000以内随机数,取后6位) |
| | | * @Author xiaochen |
| | | */ |
| | | public static String generateOrderSn(long id) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | int year = calendar.get(Calendar.YEAR); |
| | | year = year % 10; |
| | | if (year == 0) year = 10; |
| | | int month = calendar.get(Calendar.MONTH) + 1; |
| | | int yearMonth = year * month; |
| | | String yearMonthPart = "0" + yearMonth; |
| | | yearMonthPart = yearMonthPart.substring(yearMonthPart.length() - 2); |
| | | |
| | | int day = calendar.get(Calendar.DAY_OF_MONTH); |
| | | int dayNum = (int) ((id % 3.33) * day); |
| | | String dayPart = "0" + dayNum; |
| | | dayPart = dayPart.substring(dayPart.length() - 2); |
| | | |
| | | String timestampPart = "" + (Math.random() * 10000) * (System.currentTimeMillis() / 10000); |
| | | timestampPart = timestampPart.replace(".", "").replace("E", ""); |
| | | timestampPart = timestampPart.substring(0, 6); |
| | | return yearMonthPart + dayPart + timestampPart; |
| | | } |
| | | |
| | | /** |
| | | * @return |
| | | * @Description 生成统一支付单号 规则:年(2)月(2)日(2)时(2)分(2)+timestamp*5位随机整数取后5位 |
| | | * @Author xiaochen |
| | | */ |
| | | public static String generateVolumeSn() { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmmss"); |
| | | String dateTime = dateFormat.format(calendar.getTime()); |
| | | dateTime = dateTime.substring(2); |
| | | String timestampPart = "" + (Math.random() * 10000) * (System.currentTimeMillis() / 10000); |
| | | timestampPart = timestampPart.replace(".", "").replace("E", ""); |
| | | timestampPart = timestampPart.substring(0, 5); |
| | | return dateTime + timestampPart; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | for (long i = 0; i < 20; i++) { |
| | | //String timestampPart = ""+(Math.random() * 10000) * (System.currentTimeMillis()/10000); |
| | | //System.out.println(timestampPart); |
| | | //System.out.println(generateOrderSn(i)); |
| | | long l = System.currentTimeMillis() * Long.valueOf(CodeGenerateUtils.generateProductCode().substring(0, 5)); |
| | | System.out.println(String.valueOf(l).substring(0,10)); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @description id补0生成编号 |
| | | * @author jqs |
| | | * @date 2024/4/17 14:19 |
| | | * @param totalLength |
| | | * @param id |
| | | * @return String |
| | | */ |
| | | public static String toFillZeroCode(int totalLength, Long id) { |
| | | String idStr = id.toString(); |
| | | int length = idStr.length(); |
| | | if(totalLength <= length){ |
| | | return idStr; |
| | | } |
| | | int fillLength = totalLength - length; |
| | | StringBuilder idsbs = new StringBuilder(); |
| | | for (int i = 0; i < fillLength; i++) { |
| | | idsbs.append("0"); |
| | | } |
| | | return idsbs.append(idStr).toString(); |
| | | } |
| | | } |
| | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-account</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-system</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | |
| | | @Autowired |
| | | private RedisService redisService; |
| | | |
| | | @Lazy |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Lazy |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | |
| | | return chain.filter(exchange); |
| | | } |
| | | //防抖校验 |
| | | try { |
| | | antiShake(request); |
| | | }catch (Exception e){ |
| | | log.error("[重复提交]请求路径:{}", exchange.getRequest().getPath()); |
| | | return ServletUtils.webFluxResponseWriter(exchange.getResponse(), e.getMessage(), HttpStatus.SUCCESS); |
| | | } |
| | | // try { |
| | | // antiShake(request); |
| | | // }catch (Exception e){ |
| | | // log.error("[重复提交]请求路径:{}", exchange.getRequest().getPath()); |
| | | // return ServletUtils.webFluxResponseWriter(exchange.getResponse(), e.getMessage(), HttpStatus.SUCCESS); |
| | | // } |
| | | |
| | | //校验账户是否有效 |
| | | try { |
| | | verifyToken(request); |
| | | verifyAccount(request); |
| | | }catch (Exception e){ |
| | | return unauthorizedResponse(exchange, e.getMessage()); |
| | | } |
| | | // try { |
| | | // verifyToken(request); |
| | | // verifyAccount(request); |
| | | // }catch (Exception e){ |
| | | // return unauthorizedResponse(exchange, e.getMessage()); |
| | | // } |
| | | String token = getToken(request); |
| | | Claims claims = JwtUtils.parseToken(token); |
| | | String userkey = JwtUtils.getUserKey(claims); |
| | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-system</artifactId> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | |
| | | <!-- SpringCloud Alibaba Nacos --> |
| | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-order</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-chargingPile</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <!-- SpringCloud Alibaba Nacos --> |
| | | <dependency> |
| | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-account</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-other</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-lang</groupId> |
| | | <artifactId>commons-lang</artifactId> |
| | | <version>2.6</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-order</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | |
| | |
| | | import com.ruoyi.account.api.model.TAppCoupon; |
| | | import com.ruoyi.account.api.model.TAppUserCar; |
| | | import com.ruoyi.account.api.query.ExchangeRecordGoodsQuery; |
| | | import com.ruoyi.account.api.vo.CarListVO; |
| | | import com.ruoyi.account.api.vo.CouponListVOVO; |
| | | import com.ruoyi.other.api.vo.CouponListVOVO; |
| | | import com.ruoyi.account.api.vo.ExchangeRecordVO; |
| | | import com.ruoyi.account.service.TAppCouponService; |
| | | import com.ruoyi.account.service.TAppUserCarService; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; |
| | | import com.ruoyi.chargingPile.api.vo.SiteInfoVO; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | |
| | | return AjaxResult.ok(appUserAddressService.list(Wrappers.<TAppUserAddress>lambdaQuery().eq(TAppUserAddress::getAppUserId, userId))); |
| | | } |
| | | |
| | | /** |
| | | * 查询用户默认地址列表 |
| | | */ |
| | | @ApiOperation(tags = {"小程序-用户地址"},value = "查询用户默认地址列表") |
| | | @GetMapping(value = "/queryDefaultAddress") |
| | | public AjaxResult<TAppUserAddress> queryDefaultAddress() { |
| | | // 用户id |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | return AjaxResult.ok(appUserAddressService.getOne(Wrappers.<TAppUserAddress>lambdaQuery().eq(TAppUserAddress::getAppUserId, userId) |
| | | .eq(TAppUserAddress::getDefaultAddress,1))); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加用户地址管理 |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.dto.*; |
| | | import com.ruoyi.account.api.model.*; |
| | | import com.ruoyi.account.api.vo.CouponListVOVO; |
| | | import com.ruoyi.account.service.*; |
| | | import com.ruoyi.account.util.PointDetailUtil; |
| | | import com.ruoyi.account.util.SignDayUtil; |
| | | import com.ruoyi.account.wx.body.resp.Code2SessionRespBody; |
| | | import com.ruoyi.account.wx.body.resq.Code2SessionResqBody; |
| | | import com.ruoyi.account.wx.model.WeixinProperties; |
| | | import com.ruoyi.account.wx.tools.WxAppletTools; |
| | | import com.ruoyi.account.util.GiveVipUtil; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.domain.R; |
| | |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.domain.BasePojo; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.common.security.auth.AuthUtil; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | |
| | | import com.ruoyi.order.api.feignClient.ExchangeOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.TExchangeOrder; |
| | | import com.ruoyi.other.api.dto.UnitListQueryDto; |
| | | import com.ruoyi.other.api.domain.TCompany; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TIntegralRule; |
| | | import com.ruoyi.other.api.domain.TUserTag; |
| | | import com.ruoyi.other.api.feignClient.IntegralRuleClient; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.system.api.domain.SysRole; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.api.model.LoginUserApplet; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.aspectj.weaver.loadtime.Aj; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | } |
| | | //列表查询 |
| | | 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.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())) |
| | | .in(!userIds.isEmpty(),TAppUser::getId,userIds) |
| | | .page(Page.of(userListQueryDto.getPageCurr(), userListQueryDto.getPageSize())); |
| | | if (page.getRecords().isEmpty()){ |
| | |
| | | //拿到最新的tagId |
| | | TAppUserTag one = appUserTagService.lambdaQuery().eq(TAppUserTag::getAppUserId, appUser.getId()).orderByDesc(TAppUserTag::getCreateTime).last("limit 1").one(); |
| | | //设置最新的tagName |
| | | if (one!=null) { |
| | | R<TUserTag> byIdTag = otherClient.getByIdTag(one.getUserTagId()); |
| | | if (byIdTag.getData()!=null) { |
| | | appUser.setTagName(byIdTag.getData().getName()); |
| | | } |
| | | } |
| | | //匹配vipMap的值 |
| | | appUser.setVipName(vipMap.getData().get(appUser.getVipId())); |
| | | //累计充电次数 |
| | | R<Long> useOrderCount = chargingOrderClient.useOrderCount(appUser.getId()); |
| | | appUser.setOrderCount(useOrderCount.getData()); |
| | | appUser.setLastDays( Duration.between(LocalDateTime.now(), appUser.getVipEndTime()).toDays()); |
| | | appUser.setUid(appUser.getId().toString()); |
| | | |
| | | } |
| | | return R.ok(page); |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.dto.TagListQueryDto; |
| | | import com.ruoyi.account.api.dto.UnitListQueryDto; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.other.api.dto.TagListQueryDto; |
| | | import com.ruoyi.account.api.model.TAppUserTag; |
| | | import com.ruoyi.account.service.TAppUserTagService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TCompany; |
| | | import com.ruoyi.other.api.domain.TUserTag; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.account.api.model.TAppCoupon; |
| | | import com.ruoyi.account.api.query.ExchangeRecordGoodsQuery; |
| | | import com.ruoyi.account.api.vo.CouponListVOVO; |
| | | import com.ruoyi.other.api.vo.CouponListVOVO; |
| | | import com.ruoyi.account.api.vo.ExchangeRecordVO; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import org.apache.ibatis.annotations.Param; |
| | |
| | | import com.ruoyi.account.api.dto.CouponListDto; |
| | | import com.ruoyi.account.api.model.TAppCoupon; |
| | | import com.ruoyi.account.api.query.ExchangeRecordGoodsQuery; |
| | | import com.ruoyi.account.api.vo.CouponListVOVO; |
| | | import com.ruoyi.other.api.vo.CouponListVOVO; |
| | | import com.ruoyi.account.api.vo.ExchangeRecordVO; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.api.query.ExchangeRecordGoodsQuery; |
| | | import com.ruoyi.account.api.vo.CouponListVOVO; |
| | | import com.ruoyi.other.api.vo.CouponListVOVO; |
| | | import com.ruoyi.account.api.vo.ExchangeRecordVO; |
| | | import com.ruoyi.account.mapper.TAppCouponMapper; |
| | | import com.ruoyi.account.mapper.TAppUserMapper; |
| | |
| | | private ChargingOrderClient chargingOrderClient; |
| | | @Autowired |
| | | private TAppUserVipDetailService tAppUserVipDetailService; |
| | | @Autowired |
| | | private TAppUserMapper tAppUserMapper; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Override |
| | | public PageInfo<ExchangeRecordVO> pagelist(ExchangeRecordGoodsQuery dto) { |
| | |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private TAppUserMapper tAppUserMapper; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @Override |
| | | public PageInfo<CouponListVOVO> couponList(CouponListDto dto) { |
| | | // todo token获取用户id |
| | |
| | | </where> |
| | | ORDER BY create_time DESC |
| | | </select> |
| | | <select id="couponList" resultType="com.ruoyi.account.api.vo.CouponListVOVO"> |
| | | <select id="couponList" resultType="com.ruoyi.other.api.vo.CouponListVOVO"> |
| | | SELECT |
| | | t1.app_user_id AS appUserId, |
| | | t1.coupon_id AS couponId, |
| | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-account</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <!-- ruoyi-modules-chargingPile-api --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-chargingPile</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | |
| | | <!-- SpringCloud Alibaba Nacos --> |
| | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-other</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-order</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | |
| | | </dependencies> |
New file |
| | |
| | | package com.ruoyi.chargingPile.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * <p>文件上传配置</p> |
| | | * |
| | | * @author mouseyCat |
| | | * @date 2020/10/13 16:10 |
| | | */ |
| | | @Data |
| | | @Component |
| | | @ConfigurationProperties(prefix = "file.upload") |
| | | public class FileUploadConfig { |
| | | private String accessPath; |
| | | private String allowExt; |
| | | private String location; |
| | | private String qrLocation; |
| | | } |
New file |
| | |
| | | package com.ruoyi.chargingPile.controller; |
| | | |
| | | import com.ruoyi.chargingPile.config.FileUploadConfig; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 文件上传控制类 |
| | | * |
| | | * @author junelee |
| | | * @date 2020/3/20 20:21 |
| | | */ |
| | | @Api(tags = "服务器文件上传") |
| | | @RestController |
| | | @CrossOrigin |
| | | @RequestMapping("/file/") |
| | | public class FileController { |
| | | |
| | | @Autowired |
| | | private FileUploadConfig fileUploadConfig; |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "单文件上传", notes = "单文件上传,rename 默认不重命名") |
| | | @PostMapping(value = "upload", headers = "content-type=multipart/form-data") |
| | | public AjaxResult uploadImageMany(@RequestParam(value = "file") MultipartFile mf) throws IOException { |
| | | if (mf.isEmpty()) { |
| | | return AjaxResult.error("请传入文件!"); |
| | | } |
| | | String TimeDir =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| | | String realPath = fileUploadConfig.getLocation() + TimeDir; |
| | | // String realPath = "D:\\file\\" + TimeDir; |
| | | File file = new File(realPath); |
| | | // 没有目录就创建 |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | // 获取文件名称 |
| | | String filename = mf.getOriginalFilename(); |
| | | // 获取文件后缀 |
| | | String ext = filename.substring(filename.lastIndexOf("."), filename.length()); |
| | | // 检查文件类型 |
| | | if (!fileUploadConfig.getAllowExt().contains(ext)) { |
| | | return AjaxResult.error("上传文件格式不正确,仅支持" + fileUploadConfig.getAllowExt()); |
| | | } |
| | | File targetFile = new File(realPath, filename);//目标文件 |
| | | //开始从源文件拷贝到目标文件 |
| | | //传图片一步到位 |
| | | mf.transferTo(targetFile); |
| | | //拼接数据 |
| | | String imgstr = fileUploadConfig.getAccessPath() + TimeDir +"/"+ filename; |
| | | // String imgstr = TimeDir +"/"+ filename; |
| | | return AjaxResult.success(imgstr); |
| | | } |
| | | |
| | | |
| | | // @ApiOperation(value = "单文件上传", notes = "单文件上传,rename 默认不重命名") |
| | | // @PostMapping(value = "strUpload", headers = "content-type=multipart/form-data") |
| | | // public String strUpload(@RequestParam(value = "file") MultipartFile mf,@RequestParam(value = "fileName")String fileName) throws IOException { |
| | | // if (mf.isEmpty()) { |
| | | // return "请传入文件!"; |
| | | // } |
| | | // String TimeDir =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| | | // String realPath = fileUploadConfig.getQrLocation() + TimeDir; |
| | | // File file = new File(realPath); |
| | | // // 没有目录就创建 |
| | | // if (!file.exists()) { |
| | | // file.mkdirs(); |
| | | // } |
| | | // File targetFile = new File(realPath, fileName);//目标文件 |
| | | // //开始从源文件拷贝到目标文件 |
| | | // //传图片一步到位 |
| | | // mf.transferTo(targetFile); |
| | | // //拼接数据 |
| | | // return fileUploadConfig.getQrLocation() + TimeDir +"\\"+ fileName; |
| | | // } |
| | | |
| | | @ApiOperation(value = "单文件上传", notes = "单文件上传,rename 默认不重命名") |
| | | @PostMapping(value = "strUpload", headers = "content-type=multipart/form-data") |
| | | public String strUpload(@RequestParam(value = "file") MultipartFile mf,@RequestParam(value = "fileName")String fileName) throws IOException { |
| | | if (mf.isEmpty()) { |
| | | return "请传入文件!"; |
| | | } |
| | | String TimeDir =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| | | // String realPath = "D:\\file\\" + TimeDir; |
| | | String realPath = fileUploadConfig.getLocation() + TimeDir; |
| | | File file = new File(realPath); |
| | | // 没有目录就创建 |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | File targetFile = new File(realPath, fileName);//目标文件 |
| | | //开始从源文件拷贝到目标文件 |
| | | //传图片一步到位 |
| | | mf.transferTo(targetFile); |
| | | String imgstr = fileUploadConfig.getAccessPath() + TimeDir +"/"+ fileName; |
| | | //拼接数据 |
| | | // return TimeDir +"/"+ fileName; |
| | | return imgstr; |
| | | } |
| | | |
| | | @ApiOperation(value = "单文件上传(覆盖服务器原文件)", notes = "单文件上传,rename 默认不重命名") |
| | | @PostMapping(value = "test/upload", headers = "content-type=multipart/form-data") |
| | | public AjaxResult uploadTest(@RequestParam(value = "file") MultipartFile mf) throws IOException { |
| | | if (mf.isEmpty()) { |
| | | return AjaxResult.error("请传入文件!"); |
| | | } |
| | | String TimeDir = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| | | String realPath = fileUploadConfig.getLocation() + "2021-11-17"; |
| | | File file = new File(realPath); |
| | | // 没有目录就创建 |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | // 判断文件大小 |
| | | String filename = "6u2mGlqHkeE75e2ab51b4a03c6982ff7d68f4c024d43.jpg"; |
| | | // 获取文件后缀 |
| | | String ext = filename.substring(filename.lastIndexOf("."), filename.length()); |
| | | // 检查文件类型 |
| | | if (!fileUploadConfig.getAllowExt().contains(ext)) { |
| | | return AjaxResult.error("上传文件格式不正确,仅支持" + fileUploadConfig.getAllowExt()); |
| | | } |
| | | File targetFile = new File(realPath, filename);//目标文件 |
| | | //开始从源文件拷贝到目标文件 |
| | | //传图片一步到位 |
| | | mf.transferTo(targetFile); |
| | | //拼接数据 |
| | | String imgstr = fileUploadConfig.getAccessPath() + "2021-11-17" + "/" + filename; |
| | | return AjaxResult.success(imgstr); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | return siteService.addSite(site); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/getSiteInfo/{id}") |
| | | @ApiOperation(value = "获取站点详情", tags = {"管理后台-站点管理"}) |
| | | public AjaxResult<Site> getSiteInfo(@PathVariable Integer id){ |
| | | Site site = siteService.getById(id); |
| | | return AjaxResult.success(site); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/editSite") |
| | | @ApiOperation(value = "编辑站点", tags = {"管理后台-站点管理"}) |
| | |
| | | import com.ruoyi.chargingPile.service.TAccountingStrategyService; |
| | | import com.ruoyi.chargingPile.service.TChargingPileService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.dto.SteategyPassDto; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.domain.BaseDelete; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | |
| | | * @author xiaochen |
| | | * @since 2024-08-06 |
| | | */ |
| | | @Api(tags = "计费策略") |
| | | |
| | | @RestController |
| | | @RequestMapping("/t-accounting-strategy") |
| | | public class TAccountingStrategyController { |
| | |
| | | |
| | | @ApiOperation(tags = {"后台-申请表单-计费模板审核"},value = "查询计费审核分页列表") |
| | | @PostMapping(value = "/auth/pageList") |
| | | public AjaxResult authPageList(@RequestBody TAccountingStrategyQuery query) { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | Page<TAccountingStrategy> page = accountingStrategyService.lambdaQuery() |
| | | .in(TAccountingStrategy::getFirstUserId, userid) |
| | | .or().in(TAccountingStrategy::getTwoUserId, userid) |
| | | .page(Page.of(query.getPageCurr(), query.getPageSize())); |
| | | public AjaxResult<PageInfo<TAccountingStrategyVO>> authPageList(@RequestBody TAccountingStrategyQuery query) { |
| | | |
| | | List<TAccountingStrategy> records = page.getRecords(); |
| | | for (TAccountingStrategy record : records) { |
| | | if (record.getAuditStatus()==2){ |
| | | if (record.getFirstUserId().equals(userid)){ |
| | | record.setAuditStatus(3); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | return AjaxResult.ok(accountingStrategyService.pageList(query)); |
| | | } |
| | | |
| | | // @ApiOperation(tags = {"后台-申请表单-计费模板审核"},value = "审核") |
| | | // @PostMapping(value = "/auth/pass") |
| | | // public AjaxResult<PageInfo<TAccountingStrategyVO>> authPass(@RequestBody SteategyPassDto steategyPassDto) { |
| | | // TAccountingStrategy byId = accountingStrategyService.getById(steategyPassDto.getId()); |
| | | // Long userId = tokenService.getLoginUser().getSysUser().getUserId(); |
| | | // if (byId.getAuditStatus()==1&&byId.getFirstUserId()!=userId){ |
| | | // return AjaxResult.error("您不是一级审核人员,无法审核"); |
| | | // } |
| | | // if (byId.getAuditStatus()==2&&byId.getTwoUserId()!=userId){ |
| | | // return AjaxResult.error("您不是二级审核人员,无法审核"); |
| | | // } |
| | | // if (steategyPassDto.getPass()==1){ |
| | | // if (byId.getAuditStatus()==1){ |
| | | // |
| | | // byId.setAuditStatus(2); |
| | | // byId.setFirstRemark(steategyPassDto.getRemark()); |
| | | // |
| | | // }else if (byId.getAuditStatus()==2){ |
| | | // byId.setAuditStatus(3); |
| | | // byId.setTwoRemark(steategyPassDto.getRemark()); |
| | | // |
| | | // } |
| | | // }else { |
| | | // byId.setAuditStatus(4); |
| | | // } |
| | | // |
| | | // |
| | | // |
| | | // |
| | | // |
| | | // |
| | | // } |
| | | |
| | | /** |
| | | * 小程序远程调用 根据会员折扣、预付金额 计算服务费 |
| | | * @return |
| | |
| | | * 建桩申请 |
| | | */ |
| | | @Log(title = "建桩申请", businessType = BusinessType.INSERT,operatorType = OperatorType.MOBILE) |
| | | @ApiOperation(tags = {"小程序-建桩申请"},value = "建桩申请") |
| | | @ApiOperation(tags = {"小程序-建桩申请","后台-申请表单-申请建桩"},value = "建桩申请") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@RequestBody TApplyChargingPile dto) { |
| | | // 用户id |
| | |
| | | applyChargingPileService.updateById(byId); |
| | | return AjaxResult.success(); |
| | | } |
| | | @ApiOperation(tags = {"后台-申请表单-申请建桩"},value = "删除") |
| | | @DeleteMapping(value = "/remark") |
| | | public AjaxResult remark(String ids) { |
| | | |
| | | String[] split = ids.split(","); |
| | | for (String s : split) { |
| | | applyChargingPileService.removeById(s); |
| | | |
| | | } |
| | | return AjaxResult.success(); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | @ResponseBody |
| | | @GetMapping("/pageChargingPileList") |
| | | @ApiOperation(value = "获取充电桩列表数据", tags = {"管理后台-充电桩信息"}) |
| | | public AjaxResult<PageInfo<PageChargingPileListDTO>> pageChargingPileList(@RequestBody PageChargingPileList page){ |
| | | public AjaxResult<PageInfo<PageChargingPileListDTO>> pageChargingPileList(PageChargingPileList page){ |
| | | PageInfo<PageChargingPileListDTO> list = chargingPileService.pageChargingPileList(page); |
| | | return AjaxResult.success(list); |
| | | } |
| | |
| | | @ApiOperation(value = "删除系统通知", tags = {"管理后台-系统通知"}) |
| | | public AjaxResult delChargingPileNotification(@RequestParam("id") Long id){ |
| | | TChargingPileNotification chargingPileNotification = chargingPileNotificationService.getById(id); |
| | | chargingPileNotification.setDelFlag(1); |
| | | chargingPileNotificationService.updateById(chargingPileNotification); |
| | | chargingPileNotificationService.removeById(chargingPileNotification); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | |
| | | import com.ruoyi.chargingPile.api.model.TVehicleRamp; |
| | | import com.ruoyi.chargingPile.service.TVehicleRampService; |
| | | import com.ruoyi.common.core.utils.CodeGenerateUtils; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.domain.BaseDelete; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | |
| | | @ApiOperation(tags = {"后台-车道"},value = "添加车道") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@RequestBody TVehicleRamp dto) { |
| | | dto.setCarportNum(CodeGenerateUtils.generateVolumeSn()); |
| | | return AjaxResult.ok(vehicleRampService.save(dto)); |
| | | } |
| | | |
| | |
| | | * @param id |
| | | * @return |
| | | */ |
| | | TChargingPile getChargingPile(Integer id); |
| | | TChargingPile getChargingPile(@Param("id") Integer id); |
| | | |
| | | /** |
| | | * 获取站点下充电桩及充电枪列表 |
| | |
| | | Partner partner = this.getById(partnerId); |
| | | GetPermissionConfigurationDTO dto = new GetPermissionConfigurationDTO(); |
| | | dto.setPermissionRemarks(partner.getPermissionRemarks()); |
| | | Map<String, Object> menu = new HashMap<>(); |
| | | List<TPartnerSite> list = partnerSiteService.list(new LambdaQueryWrapper<TPartnerSite>() |
| | | .eq(TPartnerSite::getPartnerId, partnerId) |
| | | .eq(TPartnerSite::getSiteId, siteId)); |
| | |
| | | .eq(TSiteMenu::getParentId, 0) |
| | | .eq(TSiteMenu::getVisible, 0) |
| | | .eq(TSiteMenu::getStatus, 0).orderByAsc(TSiteMenu::getOrderNum)); |
| | | List<Map<String, Object>> list1 = new ArrayList<>(); |
| | | for (TSiteMenu tSiteMenu : tSiteMenus) { |
| | | Map<String, Object> menu = new HashMap<>(); |
| | | menu.put("id", tSiteMenu.getMenuId()); |
| | | menu.put("name", tSiteMenu.getMenuName()); |
| | | menu.put("path", tSiteMenu.getPath()); |
| | |
| | | .eq(TSiteMenu::getParentId, tSiteMenu.getMenuId()) |
| | | .eq(TSiteMenu::getVisible, 0) |
| | | .eq(TSiteMenu::getStatus, 0).orderByAsc(TSiteMenu::getOrderNum)); |
| | | Map<String, Object> child = new HashMap<>(); |
| | | List<Map<String, Object>> list2 = new ArrayList<>(); |
| | | for (TSiteMenu siteMenu : tSiteMenus1) { |
| | | Map<String, Object> child = new HashMap<>(); |
| | | child.put("id", siteMenu.getMenuId()); |
| | | child.put("name", siteMenu.getMenuName()); |
| | | child.put("path", siteMenu.getPath()); |
| | | child.put("type", siteMenu.getMenuType()); |
| | | child.put("selected", collect.contains(siteMenu.getMenuId())); |
| | | list2.add(child); |
| | | } |
| | | menu.put("selected", child.keySet().size() > 0 ? true : false); |
| | | menu.put("child", child); |
| | | menu.put("selected", list2.size() > 0 ? true : false); |
| | | menu.put("child", list2); |
| | | list1.add(menu); |
| | | } |
| | | dto.setMenu(menu); |
| | | dto.setMenu(list1); |
| | | return dto; |
| | | } |
| | | |
| | |
| | | import com.ruoyi.chargingPile.mapper.TAccountingStrategyMapper; |
| | | import com.ruoyi.chargingPile.service.TAccountingStrategyService; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Service |
| | | public class TAccountingStrategyServiceImpl extends ServiceImpl<TAccountingStrategyMapper, TAccountingStrategy> implements TAccountingStrategyService { |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | @Override |
| | | public PageInfo<TAccountingStrategyVO> pageList(TAccountingStrategyQuery query) { |
| | | PageInfo<TAccountingStrategyVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize()); |
| | | List<TAccountingStrategyVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | for (TAccountingStrategyVO tAccountingStrategyVO : list) { |
| | | SysUser data = sysUserClient.getSysUser(tAccountingStrategyVO.getUserId()).getData(); |
| | | tAccountingStrategyVO.setUserName(data.getNickName()); |
| | | if (tAccountingStrategyVO.getFirstUserId()!=null){ |
| | | SysUser first = sysUserClient.getSysUser(tAccountingStrategyVO.getUserId()).getData(); |
| | | tAccountingStrategyVO.setFirstUserName(first==null?null:first.getNickName()); |
| | | } |
| | | if (tAccountingStrategyVO.getTwoUserId()!=null){ |
| | | SysUser two = sysUserClient.getSysUser(tAccountingStrategyVO.getUserId()).getData(); |
| | | tAccountingStrategyVO.setTwoUserName(two==null?null:two.getNickName()); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | |
| | | </appender> |
| | | |
| | | <!-- 系统模块日志级别控制 --> |
| | | <logger name="com.ruoyi" level="info" /> |
| | | <logger name="com.ruoyi" level="debug" /> |
| | | <!-- Spring日志级别控制 --> |
| | | <logger name="org.springframework" level="warn" /> |
| | | <logger name="org.springframework" level="debug" /> |
| | | |
| | | <root level="info"> |
| | | <root level="debug"> |
| | | <appender-ref ref="console" /> |
| | | </root> |
| | | |
| | |
| | | a.id, |
| | | a.code, |
| | | a.name, |
| | | a.partner_id as partnerId, |
| | | b.name as partnerName, |
| | | a.site_type as siteType, |
| | | a.business_category as businessCategory, |
| | |
| | | </sql> |
| | | <select id="pageList" resultType="com.ruoyi.chargingPile.api.vo.TAccountingStrategyVO"> |
| | | SELECT |
| | | id, site_id, `name`, description, discount,first_user_id,two_user_id,first_remark,two_remark,audit_status,first_audit_time,two_audit_time, create_time, del_flag |
| | | id, site_id, `name`, description, discount,first_user_id,two_user_id,first_remark,two_remark,audit_status,first_audit_time,two_audit_time, create_time, del_flag,user_id |
| | | FROM t_accounting_strategy |
| | | <where> |
| | | <if test="query.name != null and query.name != ''"> |
| | | AND `name` LIKE concat('%',#{query.name}, '%') |
| | | </if> |
| | | <if test="query.auditStatus != null"> |
| | | AND audit_status = #{query.auditStatus} |
| | | </if> |
| | | AND site_id IS NULL |
| | | AND del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} |
| | | </where> |
| | |
| | | </sql> |
| | | <select id="pageList" resultType="com.ruoyi.chargingPile.api.vo.TChargingGunVO"> |
| | | SELECT |
| | | tas.id, tas.code, tas.site_id, tas.partner_id, tas.charging_pile_id, tas.`name`, tas.`type`, tas.status, tas.charge_mode, tas.accounting_strategy_id, |
| | | tas.upper_rated_voltage, tas.lower_limit_of_rated_voltage, tas.rated_current, tas.rated_power, tas.parking_number, tas.parking_status, |
| | | tas.parking_lock_state, tas.national_standard, tas.remark, tas.create_time, tas.del_flag,tcg.name AS strategyName |
| | | tcg.id, tcg.code, tcg.site_id, tcg.partner_id, tcg.charging_pile_id, tcg.`name`, tcg.`type`, tcg.status, tcg.charge_mode, tcg.accounting_strategy_id, |
| | | tcg.upper_rated_voltage, tcg.lower_limit_of_rated_voltage, tcg.rated_current, tcg.rated_power, tcg.parking_number, tcg.parking_status, |
| | | tcg.parking_lock_state, tcg.national_standard, tcg.remark, tcg.create_time, tcg.del_flag,tas.name AS strategyName |
| | | FROM t_charging_gun tcg |
| | | LEFT JOIN t_accounting_strategy tas ON tas.id = tcg.accounting_strategy_id |
| | | <where> |
| | | <if test="query.siteId != null"> |
| | | AND tas.site_id = #{query.siteId} |
| | | AND tcg.site_id = #{query.siteId} |
| | | </if> |
| | | <if test="query.chargingPileId != null"> |
| | | AND tas.charging_pile_id = #{query.chargingPileId} |
| | | AND tcg.charging_pile_id = #{query.chargingPileId} |
| | | </if> |
| | | <if test="query.name != null and query.name != ''"> |
| | | AND tas.`name` LIKE concat('%',#{query.name},'%') |
| | | AND tcg.`name` LIKE concat('%',#{query.name},'%') |
| | | </if> |
| | | <if test="query.type != null"> |
| | | AND tas.`type` = #{query.type} |
| | | AND tcg.`type` = #{query.type} |
| | | </if> |
| | | <if test="query.status != null"> |
| | | AND tas.status = #{query.status} |
| | | AND tcg.status = #{query.status} |
| | | </if> |
| | | <if test="query.chargeMode != null"> |
| | | AND tas.chargeMode = #{query.chargeMode} |
| | | AND tcg.chargeMode = #{query.chargeMode} |
| | | </if> |
| | | <if test="null != siteIds"> |
| | | and tcg.site_id in |
| | |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | AND tas.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} |
| | | AND tcg.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} |
| | | </where> |
| | | ORDER BY tas.create_time DESC |
| | | ORDER BY tcg.create_time DESC |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | |
| | | <select id="pageChargingPileList" resultType="com.ruoyi.chargingPile.api.dto.PageChargingPileListDTO"> |
| | | select |
| | | id, |
| | | code, |
| | | name, |
| | | number, |
| | | type, |
| | | a.id, |
| | | a.code, |
| | | a.name, |
| | | a.number, |
| | | a.type, |
| | | a.site_id as siteId, |
| | | b.name as siteName, |
| | | a.partner_id as partnerId, |
| | | c.name as partnerName, |
| | | a.manufacturer, |
| | | a.equipment_type as equipmentType, |
| | | a.ratedPower |
| | | a.rated_power as ratedPower |
| | | from t_charging_pile a |
| | | left join t_site b on (a.site_id = b.id) |
| | | left join t_partner c on (a.partner_id = c.id) |
| | | where del_flag = 0 |
| | | where a.del_flag = 0 |
| | | <if test="null != item.siteId"> |
| | | and a.site_id = #{item.siteId} |
| | | </if> |
| | |
| | | from t_charging_pile a |
| | | left join t_site b on (a.site_id = b.id) |
| | | left join t_partner c on (a.partner_id = c.id) |
| | | where a.id = #{id} |
| | | </select> |
| | | <select id="getChargingGunList" resultType="com.ruoyi.chargingPile.api.vo.TChargingPileVO"> |
| | | select id,code, `name`, `number` from t_charging_pile |
| | |
| | | <version>4.7.1</version> |
| | | </dependency> |
| | | |
| | | <!--spirngboot集成mongodb--> |
| | | <!--mongodb--> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-data-mongodb</artifactId> |
| | | </dependency> |
| | | |
| | | <!--华为云--> |
| | | <dependency> |
| | | <groupId>com.huaweicloud.sdk</groupId> |
| | | <artifactId>huaweicloud-sdk-core</artifactId> |
| | | <version>[3.0.40-rc, 3.2.0)</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.huaweicloud.sdk</groupId> |
| | | <artifactId>huaweicloud-sdk-iotda</artifactId> |
| | | <version>[3.0.40-rc, 3.2.0)</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.huaweicloud.sdk</groupId> |
| | | <artifactId>huaweicloud-sdk-bundle</artifactId> |
| | | <version>3.1.87</version> |
| | | </dependency> |
| | | |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
New file |
| | |
| | | package com.ruoyi.integration.iotda.builder; |
| | | |
| | | import com.huaweicloud.sdk.core.auth.AbstractCredentials; |
| | | import com.huaweicloud.sdk.core.auth.BasicCredentials; |
| | | import com.huaweicloud.sdk.core.auth.ICredential; |
| | | import com.huaweicloud.sdk.core.region.Region; |
| | | import com.huaweicloud.sdk.iam.v3.IamClient; |
| | | import com.huaweicloud.sdk.iam.v3.region.IamRegion; |
| | | import com.huaweicloud.sdk.iotda.v5.IoTDAClient; |
| | | import com.ruoyi.integration.iotda.config.IotDAConfig; |
| | | import com.ruoyi.integration.iotda.constant.IotConstant; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class IotBuilder { |
| | | |
| | | @Autowired |
| | | private IotDAConfig config; |
| | | |
| | | /** |
| | | * iot build |
| | | * |
| | | * @return |
| | | */ |
| | | public IoTDAClient buildIot() { |
| | | ICredential auth = new BasicCredentials() |
| | | // 标准版/企业版需要使用衍生算法,基础版请删除配置"withDerivedPredicate"; |
| | | .withDerivedPredicate(AbstractCredentials.DEFAULT_DERIVED_PREDICATE) // Used in derivative ak/sk authentication scenarios |
| | | .withAk(config.getAk()) |
| | | .withSk(config.getSk()); |
| | | return IoTDAClient.newBuilder() |
| | | .withCredential(auth) |
| | | // 标准版/企业版:需自行创建Region对象,基础版:请使用IoTDARegion的region对象,如"withRegion(IoTDARegion.CN_NORTH_4)" |
| | | .withRegion(new Region("cn-north-4", IotConstant.URL)) |
| | | .build(); |
| | | } |
| | | /** |
| | | * iam build |
| | | * |
| | | * @return |
| | | */ |
| | | public IamClient buildIam() { |
| | | ICredential auth = new BasicCredentials() |
| | | // 标准版/企业版需要使用衍生算法,基础版请删除配置"withDerivedPredicate"; |
| | | .withDerivedPredicate(AbstractCredentials.DEFAULT_DERIVED_PREDICATE) // Used in derivative ak/sk authentication scenarios |
| | | .withAk(config.getAk()) |
| | | .withSk(config.getSk()); |
| | | return IamClient.newBuilder() |
| | | .withCredential(auth) |
| | | .withRegion(IamRegion.valueOf("cn-north-4")) |
| | | .build(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.iotda.config; |
| | | |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Data |
| | | @ToString |
| | | @Component |
| | | @ConfigurationProperties(prefix = "iot.account.conf") |
| | | public class IotAccountConfig { |
| | | |
| | | /** |
| | | * hostAccount配置 |
| | | */ |
| | | private String hostAccount; |
| | | /** |
| | | * iamAccount配置 |
| | | */ |
| | | private String iamAccount; |
| | | /** |
| | | * iamPassword配置 |
| | | */ |
| | | private String iamPassword; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.iotda.config; |
| | | |
| | | import lombok.Data; |
| | | import lombok.ToString; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Data |
| | | @ToString |
| | | @Component |
| | | @ConfigurationProperties(prefix = "iot.conf") |
| | | public class IotDAConfig { |
| | | |
| | | /** |
| | | * ak配置 |
| | | */ |
| | | private String ak; |
| | | /** |
| | | * sk配置 |
| | | */ |
| | | private String sk; |
| | | /** |
| | | * endpoint配置 938d8d39e2.iotda.cn-north-4.myhuaweicloud.com |
| | | */ |
| | | private String endpoint; |
| | | /** |
| | | * project_id配置 0cc59978c61e4b4da24e8c3d02937b45 |
| | | */ |
| | | private String projectId; |
| | | /** |
| | | * Instance-Id配置 c60f266a-57a2-460c-a24e-eabda84602eb |
| | | */ |
| | | private String instanceId; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.iotda.constant; |
| | | |
| | | public class IotConstant { |
| | | /** |
| | | * 华为云iot token |
| | | */ |
| | | public static final String IOT_TOKEN = "iot_token"; |
| | | /** |
| | | * 模式 |
| | | */ |
| | | public static final String PASSWORD = "password"; |
| | | /** |
| | | * URL |
| | | */ |
| | | public static final String URL = "https://iotda.cn-north-4.myhuaweicloud.com"; |
| | | /** |
| | | * 创建产品 |
| | | */ |
| | | public static final String CREATE_PRODUCT = URL+"/v5/iot/{project_id}/products"; |
| | | /** |
| | | * 创建产品 |
| | | */ |
| | | public static final String DELETE_PRODUCT = URL+"/v5/iot/{project_id}/products/{product_id}"; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.iotda.utils.api; |
| | | |
| | | import com.huaweicloud.sdk.core.auth.AbstractCredentials; |
| | | import com.huaweicloud.sdk.core.auth.ICredential; |
| | | import com.huaweicloud.sdk.core.exception.ConnectionException; |
| | | import com.huaweicloud.sdk.core.exception.RequestTimeoutException; |
| | | import com.huaweicloud.sdk.core.exception.ServiceResponseException; |
| | | import com.huaweicloud.sdk.iotda.v5.IoTDAClient; |
| | | import com.huaweicloud.sdk.iotda.v5.model.*; |
| | | import com.ruoyi.common.core.utils.CodeGenerateUtils; |
| | | import com.ruoyi.common.core.utils.uuid.UUID; |
| | | import com.ruoyi.integration.iotda.builder.IotBuilder; |
| | | import com.ruoyi.integration.iotda.config.IotAccountConfig; |
| | | import com.ruoyi.integration.iotda.config.IotDAConfig; |
| | | import com.ruoyi.integration.iotda.constant.IotConstant; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * iot接口调用工具类 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class IotInterfaceUtil { |
| | | |
| | | private static final String dataFormat = "json"; |
| | | private static final String protocolType = "HTTPS"; |
| | | private static final String deviceType = "充电桩"; |
| | | private static final String serviceType = "直流充电"; |
| | | |
| | | @Autowired |
| | | private IotBuilder iotBuilder; |
| | | @Autowired |
| | | private IotDAConfig iotDAConfig; |
| | | |
| | | private String decodeUrl(String url) { |
| | | return MessageFormat.format(url, iotDAConfig.getProjectId()); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 创建产品 |
| | | * @param productId 产品ID,使用UUID.randomUUID().toString()生成 需替换特殊字符 "-" 为空 |
| | | * @param productName 产品名称 |
| | | * @return CreateProductResponse |
| | | */ |
| | | public CreateProductResponse createProductSolution(String productId,String productName) { |
| | | CreateProductRequest request = new CreateProductRequest(); |
| | | AddProduct body = new AddProduct(); |
| | | List<ServiceCapability> listbodyServiceCapabilities = new ArrayList<>(); |
| | | listbodyServiceCapabilities.add( |
| | | new ServiceCapability() |
| | | .withServiceId(CodeGenerateUtils.generateVolumeSn()) |
| | | .withServiceType(serviceType) |
| | | ); |
| | | body.withServiceCapabilities(listbodyServiceCapabilities); |
| | | body.withDataFormat(dataFormat); |
| | | body.withProtocolType(protocolType); |
| | | body.withDeviceType(deviceType); |
| | | body.withName(productName); |
| | | body.withProductId(productId); |
| | | request.withBody(body); |
| | | request.withInstanceId(iotDAConfig.getInstanceId()); |
| | | try { |
| | | CreateProductResponse response = iotBuilder.buildIot().createProduct(request); |
| | | log.info("创建产品:{}",response.toString()); |
| | | return response; |
| | | } catch (ConnectionException | RequestTimeoutException e) { |
| | | e.printStackTrace(); |
| | | } catch (ServiceResponseException e) { |
| | | e.printStackTrace(); |
| | | log.info(String.valueOf(e.getHttpStatusCode())); |
| | | log.info(e.getRequestId()); |
| | | log.info(e.getErrorCode()); |
| | | log.info(e.getErrorMsg()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除产品 |
| | | * @param productId 产品ID,使用UUID.randomUUID().toString()生成 需替换特殊字符 "-" 为空 |
| | | * @return DeleteProductResponse |
| | | */ |
| | | public DeleteProductResponse deleteProductRequest(String productId) { |
| | | DeleteProductRequest request = new DeleteProductRequest(); |
| | | request.withProductId(productId); |
| | | request.withInstanceId(iotDAConfig.getInstanceId()); |
| | | try { |
| | | DeleteProductResponse response = iotBuilder.buildIot().deleteProduct(request); |
| | | log.info("删除产品:{}",response.toString()); |
| | | return response; |
| | | } catch (ConnectionException e) { |
| | | e.printStackTrace(); |
| | | } catch (RequestTimeoutException e) { |
| | | e.printStackTrace(); |
| | | } catch (ServiceResponseException e) { |
| | | e.printStackTrace(); |
| | | System.out.println(e.getHttpStatusCode()); |
| | | System.out.println(e.getRequestId()); |
| | | System.out.println(e.getErrorCode()); |
| | | System.out.println(e.getErrorMsg()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 创建设备 |
| | | * @param productId 产品ID |
| | | * @param nodeId 设备标识码 通常使用IMEI、MAC地址或Serial No作为node_id |
| | | * @param deviceId 设备ID 使用CodeGenerateUtils.generateVolumeSn() |
| | | * @param deviceName 设备名称 |
| | | * @param description 设备描述 |
| | | * @return AddDeviceResponse |
| | | */ |
| | | public AddDeviceResponse addDeviceRequest(String productId,String nodeId,String deviceId,String deviceName,String description) { |
| | | AddDeviceRequest request = new AddDeviceRequest(); |
| | | AddDevice body = new AddDevice(); |
| | | body.withDeviceId(deviceId); |
| | | body.withNodeId(nodeId); |
| | | body.withDeviceName(deviceName); |
| | | body.withProductId(productId); |
| | | body.withDescription(description); |
| | | request.withBody(body); |
| | | try { |
| | | AddDeviceResponse response = iotBuilder.buildIot().addDevice(request); |
| | | log.info("创建设备:{}",response.toString()); |
| | | return response; |
| | | } catch (ConnectionException e) { |
| | | e.printStackTrace(); |
| | | } catch (RequestTimeoutException e) { |
| | | e.printStackTrace(); |
| | | } catch (ServiceResponseException e) { |
| | | e.printStackTrace(); |
| | | System.out.println(e.getHttpStatusCode()); |
| | | System.out.println(e.getRequestId()); |
| | | System.out.println(e.getErrorCode()); |
| | | System.out.println(e.getErrorMsg()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 修改设备 |
| | | * @param deviceId 设备ID 使用已有设备编号 |
| | | * @param deviceName 设备名称 |
| | | * @param description 设备描述 |
| | | * @return UpdateDeviceResponse |
| | | */ |
| | | public UpdateDeviceResponse updateDeviceRequest(String deviceId,String deviceName,String description) { |
| | | UpdateDeviceRequest request = new UpdateDeviceRequest(); |
| | | request.withDeviceId(deviceId); |
| | | UpdateDevice body = new UpdateDevice(); |
| | | body.withDescription(description); |
| | | body.withDeviceName(deviceName); |
| | | request.withBody(body); |
| | | try { |
| | | UpdateDeviceResponse response = iotBuilder.buildIot().updateDevice(request); |
| | | log.info("修改设备:{}",response.toString()); |
| | | return response; |
| | | } catch (ConnectionException e) { |
| | | e.printStackTrace(); |
| | | } catch (RequestTimeoutException e) { |
| | | e.printStackTrace(); |
| | | } catch (ServiceResponseException e) { |
| | | e.printStackTrace(); |
| | | System.out.println(e.getHttpStatusCode()); |
| | | System.out.println(e.getRequestId()); |
| | | System.out.println(e.getErrorCode()); |
| | | System.out.println(e.getErrorMsg()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 冻结设备 |
| | | * @param deviceId 设备ID 使用已有设备编号 |
| | | * @return FreezeDeviceResponse |
| | | */ |
| | | public FreezeDeviceResponse freezeDeviceRequest(String deviceId) { |
| | | FreezeDeviceRequest request = new FreezeDeviceRequest(); |
| | | request.withDeviceId(deviceId); |
| | | try { |
| | | FreezeDeviceResponse response = iotBuilder.buildIot().freezeDevice(request); |
| | | log.info("冻结设备:{}",response.toString()); |
| | | return response; |
| | | } catch (ConnectionException e) { |
| | | e.printStackTrace(); |
| | | } catch (RequestTimeoutException e) { |
| | | e.printStackTrace(); |
| | | } catch (ServiceResponseException e) { |
| | | e.printStackTrace(); |
| | | System.out.println(e.getHttpStatusCode()); |
| | | System.out.println(e.getRequestId()); |
| | | System.out.println(e.getErrorCode()); |
| | | System.out.println(e.getErrorMsg()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 解冻设备 |
| | | * @param deviceId 设备ID 使用已有设备编号 |
| | | * @return UnfreezeDeviceResponse |
| | | */ |
| | | public UnfreezeDeviceResponse unfreezeDeviceRequest(String deviceId) { |
| | | UnfreezeDeviceRequest request = new UnfreezeDeviceRequest(); |
| | | request.withDeviceId(deviceId); |
| | | try { |
| | | UnfreezeDeviceResponse response = iotBuilder.buildIot().unfreezeDevice(request); |
| | | log.info("解冻设备:{}",response.toString()); |
| | | return response; |
| | | } catch (ConnectionException e) { |
| | | e.printStackTrace(); |
| | | } catch (RequestTimeoutException e) { |
| | | e.printStackTrace(); |
| | | } catch (ServiceResponseException e) { |
| | | e.printStackTrace(); |
| | | System.out.println(e.getHttpStatusCode()); |
| | | System.out.println(e.getRequestId()); |
| | | System.out.println(e.getErrorCode()); |
| | | System.out.println(e.getErrorMsg()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 删除设备 |
| | | * @param deviceId 设备ID 使用已有设备编号 |
| | | * @return DeleteDeviceResponse |
| | | */ |
| | | public DeleteDeviceResponse deleteDeviceRequest(String deviceId) { |
| | | DeleteDeviceRequest request = new DeleteDeviceRequest(); |
| | | request.withDeviceId(deviceId); |
| | | try { |
| | | DeleteDeviceResponse response = iotBuilder.buildIot().deleteDevice(request); |
| | | log.info("删除设备:{}",response.toString()); |
| | | return response; |
| | | } catch (ConnectionException e) { |
| | | e.printStackTrace(); |
| | | } catch (RequestTimeoutException e) { |
| | | e.printStackTrace(); |
| | | } catch (ServiceResponseException e) { |
| | | e.printStackTrace(); |
| | | System.out.println(e.getHttpStatusCode()); |
| | | System.out.println(e.getRequestId()); |
| | | System.out.println(e.getErrorCode()); |
| | | System.out.println(e.getErrorMsg()); |
| | | } |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.iotda.utils.listener; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * iotda消息监听 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class IotMessageListener { |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.iotda.utils.produce; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * iotda消息发送 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class IotMessageProduce { |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.iotda.utils.time; |
| | | |
| | | import java.time.Instant; |
| | | import java.time.ZoneOffset; |
| | | import java.time.format.DateTimeFormatter; |
| | | |
| | | public class UtcToSeconds { |
| | | public static long convertToSeconds(String utcTimeString) { |
| | | Instant instant = Instant.parse(utcTimeString); |
| | | long seconds = instant.atOffset(ZoneOffset.UTC).toEpochSecond(); |
| | | return seconds; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String utcTimeString = "2023-04-01T12:00:00Z"; |
| | | long seconds = convertToSeconds(utcTimeString); |
| | | System.out.println("Seconds since epoch: " + seconds); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.iotda.utils.token; |
| | | |
| | | import com.huaweicloud.sdk.core.exception.ConnectionException; |
| | | import com.huaweicloud.sdk.core.exception.RequestTimeoutException; |
| | | import com.huaweicloud.sdk.core.exception.ServiceResponseException; |
| | | import com.huaweicloud.sdk.iam.v3.model.*; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.integration.iotda.constant.IotConstant; |
| | | import com.ruoyi.integration.iotda.builder.IotBuilder; |
| | | import com.ruoyi.integration.iotda.config.IotAccountConfig; |
| | | import com.ruoyi.integration.iotda.utils.time.UtcToSeconds; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class IotTokenUtil { |
| | | @Autowired |
| | | private IotBuilder iotBuilder; |
| | | @Autowired |
| | | private IotAccountConfig accountConfig; |
| | | @Autowired |
| | | private RedisService redisService; |
| | | |
| | | /** |
| | | * 获取token |
| | | * @return |
| | | */ |
| | | public KeystoneCreateUserTokenByPasswordResponse getToken() { |
| | | KeystoneCreateUserTokenByPasswordRequest request = new KeystoneCreateUserTokenByPasswordRequest(); |
| | | KeystoneCreateUserTokenByPasswordRequestBody body = new KeystoneCreateUserTokenByPasswordRequestBody(); |
| | | PwdPasswordUserDomain domainUser = new PwdPasswordUserDomain(); |
| | | domainUser.withName(accountConfig.getHostAccount()); |
| | | PwdPasswordUser userPassword = new PwdPasswordUser(); |
| | | userPassword.withDomain(domainUser) |
| | | .withName(accountConfig.getIamAccount()) |
| | | .withPassword(accountConfig.getIamPassword()); |
| | | PwdPassword passwordIdentity = new PwdPassword(); |
| | | passwordIdentity.withUser(userPassword); |
| | | List<PwdIdentity.MethodsEnum> listIdentityMethods = new ArrayList<>(); |
| | | listIdentityMethods.add(PwdIdentity.MethodsEnum.fromValue(IotConstant.PASSWORD)); |
| | | PwdIdentity identityAuth = new PwdIdentity(); |
| | | identityAuth.withMethods(listIdentityMethods) |
| | | .withPassword(passwordIdentity); |
| | | PwdAuth authbody = new PwdAuth(); |
| | | authbody.withIdentity(identityAuth); |
| | | body.withAuth(authbody); |
| | | request.withBody(body); |
| | | try { |
| | | KeystoneCreateUserTokenByPasswordResponse response = iotBuilder.buildIam().keystoneCreateUserTokenByPassword(request); |
| | | redisService.setCacheObject(IotConstant.IOT_TOKEN, response.getXSubjectToken(), UtcToSeconds.convertToSeconds(response.getToken().getExpiresAt()), TimeUnit.SECONDS); |
| | | return response; |
| | | } catch (ConnectionException e) { |
| | | e.printStackTrace(); |
| | | } catch (RequestTimeoutException e) { |
| | | e.printStackTrace(); |
| | | } catch (ServiceResponseException e) { |
| | | e.printStackTrace(); |
| | | System.out.println(e.getHttpStatusCode()); |
| | | System.out.println(e.getRequestId()); |
| | | System.out.println(e.getErrorCode()); |
| | | System.out.println(e.getErrorMsg()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-other</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-account</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <!-- ruoyi-modules-chargingPile-api --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-order</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-chargingPile</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | |
| | | |
| | |
| | | package com.ruoyi.order.controller; |
| | | import java.time.LocalDateTime; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | import com.ruoyi.order.service.TExchangeOrderService; |
| | | import com.ruoyi.order.service.TShoppingOrderService; |
| | | import com.ruoyi.order.service.TVipOrderService; |
| | | import com.ruoyi.other.api.dto.ExchangeDto; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | |
| | | |
| | | |
| | | @PostMapping("/getById") |
| | | public R<Long> getById(@RequestParam("goodId") Integer goodId,@RequestParam("userId") Long userId){ |
| | | return R.ok(exchangeOrderService.lambdaQuery().eq(TExchangeOrder::getGoodsId,goodId).eq(TExchangeOrder::getAppUserId,userId).ne(TExchangeOrder::getStatus,4).count()); |
| | | } |
| | | |
| | | @PostMapping("/create") |
| | | public R<Long> exchangeCreate(@RequestBody ExchangeDto exchangeDto){ |
| | | TExchangeOrder tExchangeOrder = new TExchangeOrder(); |
| | | tExchangeOrder.setCode(""); |
| | | tExchangeOrder.setAppUserId(exchangeDto.getUserId()); |
| | | tExchangeOrder.setOrderType(0); |
| | | tExchangeOrder.setGoodsId(0); |
| | | tExchangeOrder.setCouponId(0); |
| | | tExchangeOrder.setPurchaseQuantity(0); |
| | | tExchangeOrder.setAppUserAddressId(0L); |
| | | tExchangeOrder.setPoints(0); |
| | | tExchangeOrder.setRemark(""); |
| | | tExchangeOrder.setStatus(0); |
| | | tExchangeOrder.setExpressCompany(""); |
| | | tExchangeOrder.setExpressNumber(""); |
| | | tExchangeOrder.setConsignerId(0); |
| | | tExchangeOrder.setConsignerTime(LocalDateTime.now()); |
| | | tExchangeOrder.setReceivingTime(LocalDateTime.now()); |
| | | tExchangeOrder.setCancellationTime(LocalDateTime.now()); |
| | | tExchangeOrder.setCancellationId(0); |
| | | tExchangeOrder.setCreateTime(LocalDateTime.now()); |
| | | tExchangeOrder.setDelFlag(false); |
| | | return R.ok(); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/getMyExchangeOrder") |
| | |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-account</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-other</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-order</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <!-- SpringCloud Alibaba Nacos Config --> |
| | | <dependency> |
| | |
| | | import com.ruoyi.other.service.TActivityService; |
| | | import com.ruoyi.other.service.TCouponService; |
| | | import com.ruoyi.other.service.TGoodsService; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据id获取优惠券信息 |
| | | * @param id |
| | |
| | | package com.ruoyi.other.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.dto.EnterpriseQuery; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.other.api.domain.TEnterpriseUserApplication; |
| | | import com.ruoyi.other.query.PassDto; |
| | | import com.ruoyi.other.service.TEnterpriseUserApplicationService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | private final TEnterpriseUserApplicationService enterpriseUserApplicationService; |
| | | private final TokenService tokenService; |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Autowired |
| | | public TEnterpriseUserApplicationController(TEnterpriseUserApplicationService enterpriseUserApplicationService, TokenService tokenService) { |
| | |
| | | * 添加计费策略管理 |
| | | */ |
| | | @Log(title = "添加集团用户申请", businessType = BusinessType.INSERT) |
| | | @ApiOperation(tags = {"小程序-计费策略"},value = "添加集团用户申请") |
| | | @ApiOperation(tags = {"小程序-集团用户"},value = "添加集团用户申请") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@Validated @RequestBody TEnterpriseUserApplication dto) { |
| | | // 用户id |
| | |
| | | return AjaxResult.ok(enterpriseUserApplicationService.save(dto)); |
| | | } |
| | | |
| | | @Log(title = "添加集团用户申请", businessType = BusinessType.INSERT) |
| | | @ApiOperation(tags = {"后台-申请表单-集团用户"},value = "后台添加集团用户申请") |
| | | @PostMapping(value = "/back/add") |
| | | public AjaxResult<Boolean> backAdd(@Validated @RequestBody TEnterpriseUserApplication dto) { |
| | | // 用户id |
| | | return AjaxResult.ok(enterpriseUserApplicationService.save(dto)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(tags = {"后台-申请表单-集团用户"},value = "集团用户列表") |
| | | @PostMapping(value = "/page") |
| | | public AjaxResult<Boolean> page(@RequestBody TEnterpriseUserApplication dto) { |
| | | public R<Page<TEnterpriseUserApplication>> page(EnterpriseQuery enterpriseQuery) { |
| | | // 用户id |
| | | dto.setAppUserId(tokenService.getLoginUserApplet().getUserId()); |
| | | return AjaxResult.ok(enterpriseUserApplicationService.save(dto)); |
| | | if (enterpriseQuery.getPhone()!=null) { |
| | | List<Long> userIds = appUserClient.getUserIdsByPhone(enterpriseQuery.getPhone()).getData(); |
| | | if (userIds.isEmpty()){ |
| | | return R.ok(); |
| | | } |
| | | Page<TEnterpriseUserApplication> page = enterpriseUserApplicationService.lambdaQuery().in(TEnterpriseUserApplication::getAppUserId, userIds).page(Page.of(enterpriseQuery.getPageCurr(), enterpriseQuery.getPageSize())); |
| | | return R.ok(page); |
| | | }else { |
| | | Page<TEnterpriseUserApplication> page = enterpriseUserApplicationService.lambdaQuery().page(Page.of(enterpriseQuery.getPageCurr(), enterpriseQuery.getPageSize())); |
| | | return R.ok(page); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ApiOperation(tags = {"后台-申请表单-集团用户"},value = "备注") |
| | | @PostMapping(value = "/remark") |
| | | public AjaxResult pass(@RequestBody PassDto passDto) { |
| | | // 用户id |
| | | TEnterpriseUserApplication byId = enterpriseUserApplicationService.getById(passDto.getId()); |
| | | byId.setRemark(passDto.getRemark()); |
| | | |
| | | enterpriseUserApplicationService.updateById(byId); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @ApiOperation(tags = {"后台-申请表单-集团用户"},value = "备注") |
| | | @DeleteMapping(value = "/delete") |
| | | public AjaxResult delete(String ids) { |
| | | String[] split = ids.split(","); |
| | | for (String s : split) { |
| | | enterpriseUserApplicationService.removeById(s); |
| | | } |
| | | return AjaxResult.success(); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.other.controller; |
| | | |
| | | |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | | import com.ruoyi.other.api.domain.TActivity; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.other.api.dto.AdvertisingDTO; |
| | | import com.ruoyi.other.api.dto.ExchangeDto; |
| | | import com.ruoyi.other.api.dto.GoodsDTO; |
| | | import com.ruoyi.other.service.TActivityService; |
| | | import com.ruoyi.other.service.TAdvertisingService; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private TGoodsService goodsService; |
| | | @Autowired |
| | | private TActivityService activityService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | @GetMapping("/getInfo") |
| | | @ApiOperation(tags = {"管理后台-商品管理"},value = "商品查看详情") |
| | | @ApiOperation(tags = {"管理后台-商品管理","小程序-兑换商城"},value = "商品查看详情") |
| | | public AjaxResult<TGoods> getInfo(Integer id) { |
| | | return AjaxResult.ok(goodsService.getById(id)); |
| | | } |
| | |
| | | return AjaxResult.ok(goodsService.pageList(dto)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(tags = {"小程序-兑换商城"},value = "商品列表分页查询") |
| | | @PostMapping(value = "/app/pageList") |
| | | public AjaxResult<PageInfo<TGoods>> apppageList(BasePage basePage) { |
| | | return AjaxResult.ok(goodsService.pageList1(basePage)); |
| | | } |
| | | |
| | | @ApiOperation(tags = {"小程序-兑换商城"},value = "兑换商品") |
| | | @PostMapping(value = "/app/shop") |
| | | public AjaxResult<PageInfo<TGoods>> shop(@RequestBody ExchangeDto exchangeDto) { |
| | | //查询当前商品信息 |
| | | TGoods good = goodsService.getById(exchangeDto.getGoodId()); |
| | | |
| | | //检查当前用户积分是否够 |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | TAppUser user = appUserClient.getUserById(userId).getData(); |
| | | if (user.getPoints()<good.getRedeemPoints()){ |
| | | return AjaxResult.error("当前用户积分不足"); |
| | | } |
| | | //检查当前用户是否到达兑换上限 |
| | | Long count = orderClient.getExchangeById(exchangeDto.getGoodId(), userId).getData(); |
| | | if (good.getLimitExchangeTimes()!=-1&&count>=good.getLimitExchangeTimes()){ |
| | | return AjaxResult.error("当前用户已到达兑换上限"); |
| | | } |
| | | //生成积分兑换成功的订单 |
| | | orderClient.exchangeCreate(exchangeDto); |
| | | |
| | | //如果是优惠卷,赠送优惠卷给用户 |
| | | |
| | | |
| | | |
| | | |
| | | //生成消耗积分的记录 |
| | | return AjaxResult.success(); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据id获取商品信息 |
| | | * @param id |
| | |
| | | public interface TGoodsMapper extends BaseMapper<TGoods> { |
| | | |
| | | List<TGoods> pageList(@Param("pageInfo")PageInfo<TGoods> pageInfo, @Param("req") GoodsDTO dto); |
| | | List<TGoods> pageList1(@Param("pageInfo")PageInfo<TGoods> pageInfo); |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.other.query; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2024/8/20 18:25 |
| | | */ |
| | | @Data |
| | | public class PassDto { |
| | | Integer id; |
| | | String remark; |
| | | } |
| | |
| | | package com.ruoyi.other.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.other.api.dto.GoodsDTO; |
| | |
| | | public interface TGoodsService extends IService<TGoods> { |
| | | |
| | | PageInfo<TGoods> pageList(GoodsDTO dto); |
| | | PageInfo<TGoods> pageList1(BasePage basePage); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.other.service.impl; |
| | | |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | @Override |
| | | public PageInfo<TGoods> pageList1(BasePage basePage) { |
| | | GoodsDTO dto = new GoodsDTO(); |
| | | dto.setType(2); |
| | | dto.setStatus(1); |
| | | dto.setPageCurr(basePage.getPageCurr()); |
| | | dto.setPageSize(basePage.getPageSize()); |
| | | PageInfo<TGoods> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); |
| | | List<TGoods> list = this.baseMapper.pageList1(pageInfo); |
| | | |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | for (TGoods temp : list) { |
| | | stringBuilder.append(temp.getId()).append(","); |
| | | } |
| | | if (StringUtils.hasLength(stringBuilder)){ |
| | | // 去除最后一个字符 |
| | | stringBuilder.deleteCharAt(stringBuilder.length()-1); |
| | | } |
| | | if (list.isEmpty()) { |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | String string = stringBuilder.toString(); |
| | | // 订单号加上商品类型 |
| | | String res = string+"-"+dto.getType(); |
| | | |
| | | List<Integer> data = orderClient.getSalesCountByGoodsId(res).getData(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | list.get(i).setSalesCount(data.get(i)); |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | } |
| | |
| | | <select id="pageList" resultType="com.ruoyi.other.api.domain.TAdvertising"> |
| | | select * from t_advertising |
| | | <where> |
| | | <if test="req.name != null and req.name != ''"> |
| | | AND `name` LIKE concat('%',#{req.name}, '%') |
| | | <if test="req.title != null and req.title != ''"> |
| | | AND `name` LIKE concat('%',#{req.title}, '%') |
| | | </if> |
| | | <if test="req.state == 1"> |
| | | <if test="req.startState == 1"> |
| | | AND start_time >= NOW() |
| | | </if> |
| | | <if test="req.state == 2"> |
| | | <if test="req.startState == 2"> |
| | | AND start_time <= NOW() AND end_time >= NOW() |
| | | </if> |
| | | <if test="req.state == 3"> |
| | | <if test="req.startState == 3"> |
| | | AND end_time <= NOW() |
| | | </if> |
| | | AND del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} |
| | |
| | | ORDER BY create_time DESC |
| | | </select> |
| | | |
| | | <select id="pageList1" resultType="com.ruoyi.other.api.domain.TGoods"> |
| | | select * from t_goods |
| | | <where> |
| | | AND del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} |
| | | </where> |
| | | ORDER BY |
| | | CASE WHEN `inventory` = 0 THEN 0 ELSE 1 END DESC, |
| | | `redeem_points` ASC; |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <setting name="cacheEnabled" value="true"/> |
| | | <!-- 延迟加载的全局开关。当开启时,所有关联对象都会延迟加载。默认 false --> |
| | | <!-- <setting name="lazyLoadingEnabled" value="true"/> --> |
| | | <setting name="mapUnderscoreToCamelCase" value="false"/><!--是否将map下划线方式转为驼峰式命名--> |
| | | <setting name="mapUnderscoreToCamelCase" value="true"/><!--是否将map下划线方式转为驼峰式命名--> |
| | | <!-- 当开启时,任何方法的调用都会加载该对象的所有属性。默认 false,可通过select标签的 fetchType来覆盖--> |
| | | <!-- <setting name="aggressiveLazyLoading" value="false"/>--> |
| | | <!-- Mybatis 创建具有延迟加载能力的对象所用到的代理工具,默认JAVASSIST --> |