ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/InfoCouponDto.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -35,8 +36,10 @@ private BigDecimal discount; @ApiModelProperty(value = "结束时间") @TableField("end_time") @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private LocalDateTime endTime; @ApiModelProperty(value = "开始时间") @TableField("start_time") @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private LocalDateTime startTime; } ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/ListInfoCouponDto.java
@@ -12,7 +12,9 @@ @Data public class ListInfoCouponDto { List<InfoCouponDto> infoCouponDtoList1; List<InfoCouponDto> infoCouponDtoList2; List<InfoCouponDto> infoCouponDtoList; Integer num1; Integer num2; } ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserFallbackFactory.java
@@ -54,6 +54,11 @@ } @Override public R changeDown(PointChangeDto points) { return null; } @Override public R<TAppUser> selectByPhone(String phone) { return R.fail("积分变化失败:"+throwable.getMessage()); } ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java
@@ -58,6 +58,8 @@ @PostMapping("/t-app-user/user/points/change") R change(@RequestBody PointChangeDto points); @PostMapping("/t-app-user/user/points/change/down") R changeDown(@RequestBody PointChangeDto points); /** * 通过手机号查询用户 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/VipInfoDto.java
@@ -32,4 +32,7 @@ @ApiModelProperty(value = "最高总折扣") private BigDecimal totalDiscount; @ApiModelProperty(value = "会员名称") private String name; } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
@@ -513,7 +513,7 @@ appUserInfoDto.setVipExpireTime(byId.getVipEndTime()); } //判断当天是否签到 Long count = signService.lambdaQuery().eq(TAppUserSign::getSignDay, LocalDate.now()).count(); Long count = signService.lambdaQuery().eq(TAppUserSign::getAppUserId,userId).eq(TAppUserSign::getSignDay, LocalDate.now()).count(); appUserInfoDto.setIsSign(count>0?1:0); //获取当前拥有的优惠卷数量 Long coupons = appCouponService.lambdaQuery().eq(TAppCoupon::getAppUserId, userId).eq(TAppCoupon::getStatus, 1).count(); @@ -525,6 +525,7 @@ } appUserInfoDto.setUserCars(list); appUserInfoDto.setFirstAdd(byId.getFirstAdd()!=null?byId.getFirstAdd():0); appUserInfoDto.setPoints(byId.getPoints()==null?0:byId.getPoints()); return R.ok(appUserInfoDto); @@ -544,6 +545,7 @@ InfoCouponDto infoCouponDto = new InfoCouponDto(); BeanUtils.copyProperties(coupon, infoCouponDto); infoCouponDto.setId(tAppCoupon.getId()); infoCouponDto.setEndTime(tAppCoupon.getEndTime()); couponDtos1.add(infoCouponDto); } @@ -557,6 +559,7 @@ InfoCouponDto infoCouponDto = new InfoCouponDto(); BeanUtils.copyProperties(coupon, infoCouponDto); infoCouponDto.setId(tAppCoupon.getId()); infoCouponDto.setEndTime(tAppCoupon.getEndTime()); couponDtos2.add(infoCouponDto); } for (TAppCoupon tAppCoupon : list2) { @@ -564,13 +567,19 @@ InfoCouponDto infoCouponDto = new InfoCouponDto(); BeanUtils.copyProperties(coupon, infoCouponDto); infoCouponDto.setId(tAppCoupon.getId()); infoCouponDto.setEndTime(tAppCoupon.getEndTime()); couponDtos2.add(infoCouponDto); } ListInfoCouponDto listInfoCouponDto = new ListInfoCouponDto(); listInfoCouponDto.setInfoCouponDtoList1(couponDtos1); listInfoCouponDto.setInfoCouponDtoList2(couponDtos2); if (type==1){ listInfoCouponDto.setInfoCouponDtoList(couponDtos1); }else { listInfoCouponDto.setInfoCouponDtoList(couponDtos2); } listInfoCouponDto.setNum1(couponDtos1.size()); listInfoCouponDto.setNum2(couponDtos2.size()); return R.ok(listInfoCouponDto); } @@ -808,6 +817,15 @@ return R.ok(); } @PostMapping(value = "/user/points/change/down") public R changeDown(@RequestBody PointChangeDto points) { TAppUser byId = appUserService.getById(points.getUserId()); pointDetailUtil.addDetail(byId.getPoints(),byId.getPoints()-points.getPoints(),points.getType(),points.getUserId(),points.getRemark(),"JF"); byId.setPoints(byId.getPoints()-points.getPoints()); appUserService.updateById(byId); return R.ok(); } @ApiOperation(value = "添加编辑车辆", tags = {"小程序-个人中心-车辆"}) @PostMapping(value = "/user/car/addOrUpdate") public R carAdd(@RequestBody TAppUserCar appUserCar) { ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TExchangeOrderController.java
@@ -202,8 +202,6 @@ for (int i = 0; i < split1.length; i++) { Integer reduce = tShoppingOrderService.list(new QueryWrapper<TShoppingOrder>() .eq("order_type",1) .eq("goods_id", split[i]) .eq("payment_status", 2) .ne("refund_status", 2)) .stream().map(TShoppingOrder::getPurchaseQuantity).reduce(0, Integer::sum); res.add(reduce); @@ -211,11 +209,7 @@ break; case 2: for (int i = 0; i < split1.length; i++) { Integer reduce = exchangeOrderService.list(new QueryWrapper<TExchangeOrder>() .eq("order_type",1) .ne("status",4) .eq("goods_id", split[i]) ) Integer reduce = exchangeOrderService.list(new QueryWrapper<TExchangeOrder>().eq("order_type",1).ne("status",4).eq("goods_id", split1[i])) .stream().map(TExchangeOrder::getPurchaseQuantity).reduce(0, Integer::sum); res.add(reduce); } @@ -283,7 +277,7 @@ tExchangeOrder.setCouponId(exchangeDto.getGoodId()); } tExchangeOrder.setPurchaseQuantity(1); tExchangeOrder.setAppUserAddressId(Long.valueOf(exchangeDto.getAddressId())); tExchangeOrder.setAppUserAddressId(exchangeDto.getAddressId()==null?null:Long.valueOf(exchangeDto.getAddressId())); tExchangeOrder.setPoints(exchangeDto.getPoint()); tExchangeOrder.setRemark(""); if (exchangeDto.getGoodType()==1){ ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -519,10 +519,12 @@ time += between; } // 总收入 if (chargingOrderVO.getRefundStatus() == 2){ if (chargingOrderVO.getRefundStatus() !=null && chargingOrderVO.getRefundStatus() == 2){ income = income.add(chargingOrderVO.getPaymentAmount().subtract(chargingOrderVO.getRefundAmount())); }else{ income = income.add(chargingOrderVO.getPaymentAmount()); if (chargingOrderVO.getPaymentAmount()!=null){ income = income.add(chargingOrderVO.getPaymentAmount()); } } for (TChargingOrderAccountingStrategy tChargingOrderAccountingStrategy : chargingOrderId) { // 累计电费 @@ -544,11 +546,14 @@ // 车牌号 chargingOrderVO.setPhone(data.getPhone()); List<Long> longs = new ArrayList<>(); longs.add(chargingOrderVO.getAppUserCarId()); List<TAppUserCar> data1 = appUserCarClient.getCarByIds(longs).getData(); if (!data1.isEmpty()){ chargingOrderVO.setLicensePlate(data1.get(0).getLicensePlate()); if (chargingOrderVO.getAppUserCarId()!=null){ longs.add(chargingOrderVO.getAppUserCarId()); List<TAppUserCar> data1 = appUserCarClient.getCarByIds(longs).getData(); if (!data1.isEmpty()){ chargingOrderVO.setLicensePlate(data1.get(0).getLicensePlate()); } } } } tCharingOrderVO.setTotal(total); ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java
@@ -110,10 +110,25 @@ @GetMapping("/getInfo") @ApiOperation(tags = {"管理后台-商品管理","小程序-兑换商城"},value = "商品查看详情") @ApiOperation(tags = {"管理后台-商品管理"},value = "商品查看详情") public AjaxResult<TGoods> getInfo(Integer id) { return AjaxResult.ok(goodsService.getById(id)); TGoods byId = goodsService.getById(id); return AjaxResult.ok(byId); } @GetMapping("/getInfoByType") @ApiOperation(tags = {"小程序-兑换商城"},value = "商品查看详情") public AjaxResult getInfoByType(Integer goodType,Integer id) { if (goodType==1){ TGoods byId = goodsService.getById(id); return AjaxResult.ok(byId);} else { TCoupon byId = couponService.getById(id); return AjaxResult.ok(byId); } } @@ -130,6 +145,40 @@ return AjaxResult.ok(goodsService.pageList1(appGoodQuery)); } @ApiOperation(tags = {"小程序-兑换商城"},value = "积分兑换商品检查数量") @PostMapping(value = "/app/shop/check") public R check(@RequestBody ExchangeDto exchangeDto) { //检查当前用户积分是否够 Long userId = tokenService.getLoginUserApplet().getUserId(); Integer point = 0; if (exchangeDto.getGoodType()==1) { //查询当前商品信息 TGoods good = goodsService.getById(exchangeDto.getGoodId()); point = good.getRedeemPoints(); //检查当前用户是否到达兑换上限 Long count = orderClient.getExchangeById(exchangeDto.getGoodId(), userId,exchangeDto.getGoodType()).getData(); if (good.getLimitExchangeTimes() != -1 && count >= good.getLimitExchangeTimes()) { return R.fail("当前用户已兑换"+count+"张"); } TAppUser user = appUserClient.getUserById(userId).getData(); if (user.getPoints()<good.getRedeemPoints()){ return R.fail("当前用户积分不足"); } }else { TCoupon coupon = couponService.getById(exchangeDto.getGoodId()); point = coupon.getRedeemPoints(); Long count = orderClient.getExchangeById(exchangeDto.getGoodId(), userId,exchangeDto.getGoodType()).getData(); if (coupon.getInventoryQuantity() != -1 && count >= coupon.getInventoryQuantity()) { return R.fail("当前用户已到达兑换"+coupon+"次"); } } return R.ok(); } @ApiOperation(tags = {"小程序-兑换商城"},value = "积分兑换商品") @PostMapping(value = "/app/shop") public AjaxResult<PageInfo<TGoods>> shop(@RequestBody ExchangeDto exchangeDto) { @@ -144,7 +193,7 @@ //检查当前用户是否到达兑换上限 Long count = orderClient.getExchangeById(exchangeDto.getGoodId(), userId,exchangeDto.getGoodType()).getData(); if (good.getLimitExchangeTimes() != -1 && count >= good.getLimitExchangeTimes()) { return AjaxResult.error("当前用户已到达兑换上限"); return AjaxResult.error("当前用户已兑换"+count+"张"); } TAppUser user = appUserClient.getUserById(userId).getData(); if (user.getPoints()<good.getRedeemPoints()){ @@ -156,10 +205,11 @@ Long count = orderClient.getExchangeById(exchangeDto.getGoodId(), userId,exchangeDto.getGoodType()).getData(); if (coupon.getInventoryQuantity() != -1 && count >= coupon.getInventoryQuantity()) { return AjaxResult.error("当前用户已到达兑换上限"); return AjaxResult.error("当前用户已到达兑换"+coupon+"次"); } } exchangeDto.setPoint(point); exchangeDto.setUserId(userId); //生成积分兑换成功的订单 R<Long> longR = orderClient.exchangeCreate(exchangeDto); if (exchangeDto.getGoodType()==2) { @@ -177,7 +227,7 @@ pointChangeDto.setPoints(point); pointChangeDto.setRemark(longR.getData().toString()); pointChangeDto.setType(6); appUserClient.change(pointChangeDto); appUserClient.changeDown(pointChangeDto); return AjaxResult.success(); ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java
@@ -143,8 +143,8 @@ @ApiOperation(value = "会员信息", tags = {"小程序-个人中心"}) @PostMapping("/vipInfo") public AjaxResult<VipInfoDto> vipInfo() { @GetMapping("/vipInfo") public R<List<VipInfoDto>> vipInfo() { List<VipInfoDto> vipInfoDtos = new ArrayList<>(); List<TVip> vips = vipService.lambdaQuery().eq(TVip::getReveal, 1).list(); for (TVip vip : vips) { @@ -156,6 +156,7 @@ vipInfoDto.setDiscountTimes(vip.getDiscountTimes()); vipInfoDto.setDoubleIntegration(vip.getDoubleIntegration()); vipInfoDto.setMallExclusivePrice(vip.getMallExclusivePrice()); vipInfoDto.setName(vip.getName()); List<SendCouponDto> javaList = JSON.parseArray(vip.getCoupon()).toJavaList(SendCouponDto.class); List<VipCouponDto> vipCouponDtos = new ArrayList<>(); if (!javaList.isEmpty()){ @@ -180,7 +181,7 @@ vipInfoDto.setTotalDiscount(total); vipInfoDtos.add(vipInfoDto); } return AjaxResult.success(vipInfoDtos); return R.ok(vipInfoDtos); } } ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TGoodsMapper.xml
@@ -52,23 +52,23 @@ <select id="pageList1" resultType="com.ruoyi.other.api.domain.TGoods"> SELECT id,name,redeem_points,inventory,original_price,preferential_price,vip_price id,name,redeem_points as redeemPoints,inventory,original_price as originalPrice ,preferential_price as preferentialPrice,vip_price as vipPrice,1 as goodType,cover_picture as coverPicture FROM t_goods WHERE `status` = 1 and del_flag = 0 and type = #{appGoodQuery.type} UNION ALL SELECT id,name,redeem_points,inventory_quantity as inventory,payment_amount as original_price,payment_amount as preferential_price,vip_payment_amount as vip_price id,name,redeem_points as redeemPoints,inventory_quantity as inventory,payment_amount as originalPrice,payment_amount as preferentiaPrice,vip_payment_amount as vipPrice,2 as goodType,cover_picture as coverPicture FROM t_coupon WHERE `status`= 1 and del_flag = 0 and type = #{appGoodQuery.type} WHERE `status`= 1 and del_flag = 0 and ways_to_obtain != #{appGoodQuery.type} ORDER BY CASE WHEN `inventory` = 0 THEN 0 ELSE 1 END DESC, `redeem_points` ASC `redeemPoints` ASC </select> </mapper>