From 7d797c3f197371bb66c8ed3e60327817e9f0364c Mon Sep 17 00:00:00 2001 From: luodangjia <luodangjia> Date: 星期三, 28 八月 2024 13:57:39 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java | 93 ++++++++++++++++++++++++++++++++++++---------- 1 files changed, 73 insertions(+), 20 deletions(-) diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java index 776fb34..a106416 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java @@ -340,6 +340,7 @@ //累计充电次数 R<Long> useOrderCount = chargingOrderClient.useOrderCount(appUser.getId()); appUser.setOrderCount(useOrderCount.getData()); + appUser.setUid(appUser.getId().toString()); } return R.ok(page); @@ -512,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(); @@ -524,30 +525,62 @@ } appUserInfoDto.setUserCars(list); appUserInfoDto.setFirstAdd(byId.getFirstAdd()!=null?byId.getFirstAdd():0); + appUserInfoDto.setPoints(byId.getPoints()==null?0:byId.getPoints()); return R.ok(appUserInfoDto); } @ApiOperation(value = "优惠卷列表不分页(1可使用2不可用)", tags = {"小程序-个人中心"}) - @PostMapping(value = "/user/coupon") - public R<List<InfoCouponDto>> userCoupon(@RequestParam("type") Integer type) { + @GetMapping(value = "/user/coupon") + public R<ListInfoCouponDto> userCoupon(@RequestParam("type") Integer type) { + Long userId = tokenService.getLoginUserApplet().getUserId(); LocalDateTime now = LocalDateTime.now(); - List<InfoCouponDto> couponDtos = new ArrayList<>(); - List<TAppCoupon> list = appCouponService.lambdaQuery().le(TAppCoupon::getStartTime, now).ge(TAppCoupon::getEndTime, now).eq(TAppCoupon::getStatus, type).list(); - for (TAppCoupon tAppCoupon : list) { + List<InfoCouponDto> couponDtos1 = new ArrayList<>(); + + List<TAppCoupon> list = appCouponService.lambdaQuery().eq(TAppCoupon::getAppUserId, userId).ge(TAppCoupon::getEndTime, now).eq(TAppCoupon::getStatus, 1).list(); + for (TAppCoupon tAppCoupon : list) { + TCoupon coupon = JSON.toJavaObject(JSON.parseObject(tAppCoupon.getCouponJson()), TCoupon.class); + InfoCouponDto infoCouponDto = new InfoCouponDto(); + BeanUtils.copyProperties(coupon, infoCouponDto); + infoCouponDto.setId(tAppCoupon.getId()); + infoCouponDto.setEndTime(tAppCoupon.getEndTime()); + couponDtos1.add(infoCouponDto); + + } + + List<TAppCoupon> list1 = appCouponService.lambdaQuery().eq(TAppCoupon::getAppUserId, userId).eq(TAppCoupon::getStatus, 2).list(); + List<TAppCoupon> list2 = appCouponService.lambdaQuery().eq(TAppCoupon::getAppUserId, userId).lt(TAppCoupon::getEndTime, now).list(); + + List<InfoCouponDto> couponDtos2 = new ArrayList<>(); + for (TAppCoupon tAppCoupon : list1) { TCoupon coupon = JSON.toJavaObject(JSON.parseObject(tAppCoupon.getCouponJson()), TCoupon.class); InfoCouponDto infoCouponDto = new InfoCouponDto(); - BeanUtils.copyProperties(coupon,infoCouponDto); + BeanUtils.copyProperties(coupon, infoCouponDto); infoCouponDto.setId(tAppCoupon.getId()); - couponDtos.add(infoCouponDto); - + infoCouponDto.setEndTime(tAppCoupon.getEndTime()); + couponDtos2.add(infoCouponDto); + } + for (TAppCoupon tAppCoupon : list2) { + TCoupon coupon = JSON.toJavaObject(JSON.parseObject(tAppCoupon.getCouponJson()), TCoupon.class); + InfoCouponDto infoCouponDto = new InfoCouponDto(); + BeanUtils.copyProperties(coupon, infoCouponDto); + infoCouponDto.setId(tAppCoupon.getId()); + infoCouponDto.setEndTime(tAppCoupon.getEndTime()); + couponDtos2.add(infoCouponDto); } - return R.ok(couponDtos); - + ListInfoCouponDto listInfoCouponDto = new ListInfoCouponDto(); + if (type==1){ + listInfoCouponDto.setInfoCouponDtoList(couponDtos1); + }else { + listInfoCouponDto.setInfoCouponDtoList(couponDtos2); + } + listInfoCouponDto.setNum1(couponDtos1.size()); + listInfoCouponDto.setNum2(couponDtos2.size()); + return R.ok(listInfoCouponDto); } @@ -784,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) { @@ -834,7 +876,7 @@ return R.ok(); } @ApiOperation(value = "添加编辑车辆", tags = {"小程序-个人中心-车辆"}) - @DeleteMapping(value = "/user/car/delete") + @GetMapping(value = "/user/car/delete") public R carDelete(String id) { boolean b = appUserCarService.removeById(id); return R.ok(); @@ -875,15 +917,26 @@ public R getSeries(String id) throws Exception { String modelById = CarBrandUtil.getSeriesById(id); JSONObject jsonObject = JSON.parseObject(modelById); - JSONArray data = jsonObject.getJSONArray("data"); - JSONArray backList = new JSONArray(); - for (Object datum : data) { - JSONObject jsonObject1 = JSON.parseObject(datum.toString()); - JSONArray list = jsonObject1.getJSONArray("list"); - backList.addAll(list); - } - return R.ok(backList); + JSONObject data1 = jsonObject.getJSONObject("data"); + JSONArray data = data1.getJSONArray("list"); +// JSONArray data = jsonObject.getJSONArray(data1.get("list").toString()); +// JSONArray backList = new JSONArray(); +// for (Object datum : data) { +// JSONObject jsonObject1 = JSON.parseObject(datum.toString()); +// JSONArray list = jsonObject1.getJSONArray("list"); +// backList.addAll(jsonObject1); +// } + return R.ok(data); } + + @ApiOperation(value = "根据车型获取详情", tags = {"小程序-个人中心-车辆"}) + @GetMapping(value = "/user/car/getDetail") + public R getDetail(String id) throws Exception { + String detailById = CarBrandUtil.getDetailById(id); + JSONObject jsonObject = JSON.parseObject(detailById); + + return R.ok(jsonObject.getJSONObject("data")); + } } -- Gitblit v1.7.1