New file |
| | |
| | | package com.ruoyi.order.api.factory; |
| | | |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 充电订单服务降级处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class OrderFallbackFactory implements FallbackFactory<ChargingOrderClient> |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(OrderFallbackFactory.class); |
| | | |
| | | |
| | | @Override |
| | | public ChargingOrderClient create(Throwable cause) { |
| | | log.error("商品订单调用失败:{}", cause.getMessage()); |
| | | return new ChargingOrderClient() { |
| | | |
| | | }; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.order.api.feignClient; |
| | | |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.order.api.factory.ChargingOrderFallbackFactory; |
| | | import com.ruoyi.order.api.factory.OrderFallbackFactory; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 后台订单服务 |
| | | * @author ruoyi |
| | | */ |
| | | @FeignClient(contextId = "OrderClient", value = ServiceNameConstants.CONTRACT_ORDER, fallbackFactory = OrderFallbackFactory.class) |
| | | public interface OrderClient { |
| | | |
| | | @PostMapping("/t-exchange-order/getSalesCountByGoodsIds") |
| | | R<List<Integer>> getSalesCountByGoodsId(String goodsIds); |
| | | } |
| | |
| | | com.ruoyi.order.api.factory.ChargingOrderFallbackFactory |
| | | com.ruoyi.order.api.factory.ChargingOrderFallbackFactory |
| | | com.ruoyi.order.api.factory.OrderFallbackFactory |
| | |
| | | @TableField("status") |
| | | private Integer status; |
| | | |
| | | |
| | | @ApiModelProperty(value = "活动状态 1未开始 2已开始 3已结束") |
| | | @TableField(exist = false) |
| | | private Integer startState; |
| | | |
| | | |
| | | } |
| | |
| | | private Integer status; |
| | | |
| | | |
| | | |
| | | @ApiModelProperty(value = "销量") |
| | | @TableField(exist = false) |
| | | private Integer salesCount; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.other.api.dto; |
| | | |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel("商品管理列表查询DTO") |
| | | public class GoodsDTO extends BasePage { |
| | | @ApiModelProperty(value = "商品状态 1上架 2下架") |
| | | private Integer status; |
| | | @ApiModelProperty(value = "商品名称") |
| | | private String name; |
| | | @ApiModelProperty(value = "1现金购买 2积分兑换 ") |
| | | private Integer type; |
| | | @ApiModelProperty(value = "1全部 2已售罄 ") |
| | | private Integer otherState; |
| | | } |
| | |
| | | package com.ruoyi.other.api.factory; |
| | | |
| | | import com.ruoyi.other.api.feignClient.GoodsClient; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | import com.ruoyi.account.api.dto.UnitListQueryDto; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TCompany; |
| | | import com.ruoyi.other.api.feignClient.GoodsClient; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | * 车辆合同的serviceid |
| | | */ |
| | | public static final String CONTRACT_SERVICE = "ruoyi-contract"; |
| | | public static final String CONTRACT_ORDER = "ruoyi-order"; |
| | | } |
| | |
| | | package com.ruoyi.other.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.TActivity; |
| | | import com.ruoyi.other.api.domain.TAdvertising; |
| | | import com.ruoyi.other.api.dto.AdvertisingDTO; |
| | | 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.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2024-08-06 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/t-activity") |
| | | @RequestMapping("/activity") |
| | | public class TActivityController { |
| | | |
| | | @Autowired |
| | | private TActivityService activityService; |
| | | @PostMapping("/saveActivity") |
| | | @ApiOperation(tags = {"管理后台-活动管理"},value = "活动添加") |
| | | public AjaxResult saveActivity(@RequestBody TActivity dto) { |
| | | activityService.save(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | @GetMapping("/delete") |
| | | @ApiOperation(tags = {"管理后台-活动管理"},value = "活动删除") |
| | | public AjaxResult delete(Integer id) { |
| | | activityService.removeById(id); |
| | | return AjaxResult.success(); |
| | | } |
| | | @PostMapping("/updateVip") |
| | | @ApiOperation(tags = {"管理后台-活动管理"},value = "活动修改") |
| | | public AjaxResult updateActivity(@RequestBody TActivity dto) { |
| | | activityService.updateById(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | @GetMapping("/getInfo") |
| | | @ApiOperation(tags = {"管理后台-活动管理"},value = "活动查看详情") |
| | | public AjaxResult<TActivity> getInfo(Integer id) { |
| | | return AjaxResult.ok(activityService.getById(id)); |
| | | } |
| | | @ApiOperation(tags = {"管理后台-活动管理"},value = "活动列表分页查询") |
| | | @PostMapping(value = "/pageList") |
| | | public AjaxResult<PageInfo<TActivity>> pageList(@RequestBody AdvertisingDTO dto) { |
| | | return AjaxResult.ok(activityService.pageList(dto)); |
| | | } |
| | | } |
| | | |
| | |
| | | @Autowired |
| | | private TAdvertisingService advertisingService; |
| | | @PostMapping("/saveAdvertising") |
| | | @ApiOperation(value = "广告添加") |
| | | @ApiOperation(tags = {"管理后台-广告管理"},value = "广告添加") |
| | | public AjaxResult saveAdvertising(@RequestBody TAdvertising dto) { |
| | | advertisingService.save(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | @GetMapping("/delete") |
| | | @ApiOperation(value = "广告删除") |
| | | @ApiOperation(tags = {"管理后台-广告管理"},value = "广告删除") |
| | | public AjaxResult delete(Integer id) { |
| | | advertisingService.removeById(id); |
| | | return AjaxResult.success(); |
| | | } |
| | | @PostMapping("/updateVip") |
| | | @ApiOperation(value = "广告修改") |
| | | @ApiOperation(tags = {"管理后台-广告管理"},value = "广告修改") |
| | | public AjaxResult updateVip(@RequestBody TAdvertising dto) { |
| | | advertisingService.updateById(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | @GetMapping("/getInfo") |
| | | @ApiOperation(value = "广告查看详情") |
| | | @ApiOperation(tags = {"管理后台-广告管理"},value = "广告查看详情") |
| | | public AjaxResult<TAdvertising> getInfo(Integer id) { |
| | | return AjaxResult.ok(advertisingService.getById(id)); |
| | | } |
| | | @ApiOperation(value = "广告列表分页查询") |
| | | @ApiOperation(tags = {"管理后台-广告管理"},value = "广告列表分页查询") |
| | | @PostMapping(value = "/pageList") |
| | | public AjaxResult<PageInfo<TAdvertising>> pageList(AdvertisingDTO dto) { |
| | | public AjaxResult<PageInfo<TAdvertising>> pageList(@RequestBody AdvertisingDTO dto) { |
| | | return AjaxResult.ok(advertisingService.pageList(dto)); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.other.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | 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.GoodsDTO; |
| | | import com.ruoyi.other.service.TActivityService; |
| | | import com.ruoyi.other.service.TAdvertisingService; |
| | | import com.ruoyi.other.service.TGoodsService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RestController |
| | | @RequestMapping("/t-goods") |
| | | public class TGoodsController { |
| | | |
| | | @Autowired |
| | | private TGoodsService goodsService; |
| | | @Autowired |
| | | private TActivityService activityService; |
| | | @PostMapping("/saveGoods") |
| | | @ApiOperation(tags = {"管理后台-商品管理"},value = "商品添加") |
| | | public AjaxResult saveActivity(@RequestBody TGoods dto) { |
| | | goodsService.save(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | @GetMapping("/delete") |
| | | @ApiOperation(tags = {"管理后台-商品管理"},value = "商品删除") |
| | | public AjaxResult delete(Integer id) { |
| | | goodsService.removeById(id); |
| | | return AjaxResult.success(); |
| | | } |
| | | @PostMapping("/updateVip") |
| | | @ApiOperation(tags = {"管理后台-商品管理"},value = "商品修改") |
| | | public AjaxResult updateActivity(@RequestBody TGoods dto) { |
| | | goodsService.updateById(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | @GetMapping("/getInfo") |
| | | @ApiOperation(tags = {"管理后台-商品管理"},value = "商品查看详情") |
| | | public AjaxResult<TGoods> getInfo(Integer id) { |
| | | return AjaxResult.ok(goodsService.getById(id)); |
| | | } |
| | | @ApiOperation(tags = {"管理后台-商品管理"},value = "商品列表分页查询") |
| | | @PostMapping(value = "/pageList") |
| | | public AjaxResult<PageInfo<TGoods>> pageList(@RequestBody GoodsDTO dto) { |
| | | return AjaxResult.ok(goodsService.pageList(dto)); |
| | | } |
| | | } |
| | | |
| | |
| | | package com.ruoyi.other.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.TActivity; |
| | | import com.ruoyi.other.api.domain.TAdvertising; |
| | | import com.ruoyi.other.api.dto.AdvertisingDTO; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface TActivityMapper extends BaseMapper<TActivity> { |
| | | |
| | | List<TActivity> pageList(@Param("pageInfo")PageInfo<TActivity> pageInfo, @Param("req") AdvertisingDTO dto); |
| | | } |
| | |
| | | package com.ruoyi.other.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.TActivity; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.other.api.dto.GoodsDTO; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface TGoodsMapper extends BaseMapper<TGoods> { |
| | | |
| | | List<TGoods> pageList(@Param("pageInfo")PageInfo<TGoods> pageInfo, @Param("req") GoodsDTO dto); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.other.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.TActivity; |
| | | import com.ruoyi.other.api.dto.AdvertisingDTO; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface TActivityService extends IService<TActivity> { |
| | | |
| | | PageInfo<TActivity> pageList(AdvertisingDTO dto); |
| | | } |
| | |
| | | package com.ruoyi.other.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.other.api.dto.GoodsDTO; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface TGoodsService extends IService<TGoods> { |
| | | |
| | | PageInfo<TGoods> pageList(GoodsDTO dto); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.other.service.impl; |
| | | |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.TActivity; |
| | | import com.ruoyi.other.api.domain.TAdvertising; |
| | | import com.ruoyi.other.api.dto.AdvertisingDTO; |
| | | import com.ruoyi.other.mapper.TActivityMapper; |
| | | import com.ruoyi.other.service.TActivityService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class TActivityServiceImpl extends ServiceImpl<TActivityMapper, TActivity> implements TActivityService { |
| | | |
| | | @Override |
| | | public PageInfo<TActivity> pageList(AdvertisingDTO dto) { |
| | | |
| | | PageInfo<TActivity> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); |
| | | List<TActivity> list = this.baseMapper.pageList(pageInfo,dto); |
| | | for (TActivity tAdvertising : list) { |
| | | // 如果开始时间大于当前时间 那么设置状态startState为1 未开始 |
| | | if (tAdvertising.getStartTime().isAfter(LocalDateTime.now())) { |
| | | tAdvertising.setStartState(1); |
| | | } else if (tAdvertising.getEndTime().isBefore(LocalDateTime.now())) { |
| | | tAdvertising.setStartState(3); |
| | | } else { |
| | | tAdvertising.setStartState(2); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public PageInfo<TAdvertising> pageList(AdvertisingDTO dto) { |
| | | |
| | | PageInfo<TAdvertising> pageInfo = new PageInfo<>(dto.getStartState(),dto.getPageSize()); |
| | | PageInfo<TAdvertising> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); |
| | | List<TAdvertising> list = this.baseMapper.pageList(pageInfo,dto); |
| | | for (TAdvertising tAdvertising : list) { |
| | | // 如果开始时间大于当前时间 那么设置状态startState为1 未开始 |
| | | if (tAdvertising.getStartTime().isAfter(LocalDateTime.now())) { |
| | | tAdvertising.setStartState(1); |
| | | } else if (tAdvertising.getEndTime().isBefore(LocalDateTime.now())) { |
| | | tAdvertising.setStartState(3); |
| | | } else { |
| | | tAdvertising.setStartState(2); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | |
| | | package com.ruoyi.other.service.impl; |
| | | |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.other.api.dto.GoodsDTO; |
| | | import com.ruoyi.other.mapper.TGoodsMapper; |
| | | import com.ruoyi.other.service.TGoodsService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class TGoodsServiceImpl extends ServiceImpl<TGoodsMapper, TGoods> implements TGoodsService { |
| | | |
| | | @Autowired |
| | | private OrderClient goodsClient; |
| | | @Override |
| | | public PageInfo<TGoods> pageList(GoodsDTO dto) { |
| | | PageInfo<TGoods> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); |
| | | List<TGoods> list = this.baseMapper.pageList(pageInfo,dto); |
| | | |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | for (TGoods temp : list) { |
| | | stringBuilder.append(temp.getId()).append(","); |
| | | } |
| | | if (StringUtils.hasLength(stringBuilder)){ |
| | | // 去除最后一个字符 |
| | | stringBuilder.deleteCharAt(stringBuilder.length()-1); |
| | | } |
| | | String string = stringBuilder.toString(); |
| | | // goodsClient |
| | | // 远程调用cha'xun |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | } |
| | |
| | | <sql id="Base_Column_List"> |
| | | id, name, img, start_time, end_time, jump_type, jump_url, status, create_time, del_flag |
| | | </sql> |
| | | <select id="pageList" resultType="com.ruoyi.other.api.domain.TActivity"> |
| | | select * from t_activity |
| | | <where> |
| | | <if test="req.name != null and req.name != ''"> |
| | | AND `name` LIKE concat('%',#{req.name}, '%') |
| | | </if> |
| | | <if test="req.state == 1"> |
| | | AND start_time >= NOW() |
| | | </if> |
| | | <if test="req.state == 2"> |
| | | AND start_time <= NOW() AND end_time >= NOW() |
| | | </if> |
| | | <if test="req.state == 3"> |
| | | AND end_time <= NOW() |
| | | </if> |
| | | AND del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} |
| | | </where> |
| | | ORDER BY create_time DESC |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <sql id="Base_Column_List"> |
| | | id, type, name, cover_picture, details_picture, dispatch_address, service_description, original_price, preferential_price, vip_price, redeem_points, limit_exchange_times, inventory, underlying_sales, describe, introduce, explain, status, create_time, del_flag |
| | | </sql> |
| | | <select id="pageList" resultType="com.ruoyi.other.api.domain.TGoods"> |
| | | select * from t_goods |
| | | <where> |
| | | <if test="req.name != null and req.name != ''"> |
| | | AND `name` LIKE concat('%',#{req.name}, '%') |
| | | </if> |
| | | <if test="req.type != null"> |
| | | AND `type` = #{req.type} |
| | | </if> |
| | | <if test="req.status != null"> |
| | | AND status = #{req.status} |
| | | </if> |
| | | <if test="req.otherState != null and req.otherState = 2"> |
| | | AND inventory = 0 |
| | | </if> |
| | | AND del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} |
| | | </where> |
| | | ORDER BY create_time DESC |
| | | </select> |
| | | |
| | | </mapper> |