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-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TAppUserAddress.java | 24 +++ ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java | 29 ++- ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/InfoCouponDto.java | 3 ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/ChargingGunCountVO.java | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TExchangeOrderServiceImpl.java | 4 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserAddressController.java | 37 ++++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java | 60 +++++++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java | 25 +++ ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/VipInfoDto.java | 10 + ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/ListInfoCouponDto.java | 20 ++ ruoyi-service/ruoyi-account/src/main/resources/mapper/account/TAppUserAddressMapper.xml | 7 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TExchangeOrderController.java | 15 - ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserFallbackFactory.java | 5 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/CarBrandUtil.java | 54 +++++++ ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java | 93 ++++++++++-- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TCouponController.java | 7 + ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java | 2 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java | 8 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TGoodsMapper.xml | 8 19 files changed, 348 insertions(+), 65 deletions(-) diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/InfoCouponDto.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/InfoCouponDto.java index d3bff84..d6fcd90 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/InfoCouponDto.java +++ b/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; } diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/ListInfoCouponDto.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/ListInfoCouponDto.java new file mode 100644 index 0000000..65b3bc1 --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/ListInfoCouponDto.java @@ -0,0 +1,20 @@ +package com.ruoyi.account.api.dto; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +@Data +public class ListInfoCouponDto { + List<InfoCouponDto> infoCouponDtoList; + Integer num1; + Integer num2; + + +} diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserFallbackFactory.java index 47eccaf..bb60f76 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserFallbackFactory.java +++ b/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()); } diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java index 0ad197c..f7c1da1 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java +++ b/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); /** * 通过手机号查询用户 diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TAppUserAddress.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TAppUserAddress.java index da2021c..a636720 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TAppUserAddress.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TAppUserAddress.java @@ -33,6 +33,10 @@ @TableId("id") private Long id; + @ApiModelProperty(value = "主键") + @TableField(exist = false) + private String uid; + @ApiModelProperty(value = "用户id") @TableField("app_user_id") private Long appUserId; @@ -45,6 +49,14 @@ @TableField("phone") private String phone; + @ApiModelProperty(value = "省名称") + @TableField("province") + private String province; + + @ApiModelProperty(value = "省编号") + @TableField("province_code") + private String provinceCode; + @ApiModelProperty(value = "市名称") @TableField("city") private String city; @@ -53,10 +65,22 @@ @TableField("city_code") private String cityCode; + @ApiModelProperty(value = "区县") + @TableField("district") + private String district; + + @ApiModelProperty(value = "区县code") + @TableField("district_code") + private String districtCode; + @ApiModelProperty(value = "详细地址") @TableField("address") private String address; + @ApiModelProperty(value = "门牌号") + @TableField("house_number") + private String houseNumber; + @ApiModelProperty(value = "经度") @TableField("lon") private String lon; diff --git a/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/ChargingGunCountVO.java b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/ChargingGunCountVO.java index 4587086..59479ca 100644 --- a/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/ChargingGunCountVO.java +++ b/ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/ChargingGunCountVO.java @@ -9,7 +9,7 @@ @ApiModel(value = "ChargingGunCountVO对象",description = "充电枪数量VO") public class ChargingGunCountVO extends Site { - @ApiModelProperty(value = "充电枪在线数量") + @ApiModelProperty(value = "充电枪空闲数量") private Integer freeCount; @ApiModelProperty(value = "充电枪总数数量") private Integer totalCount; diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/VipInfoDto.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/VipInfoDto.java index 0783c96..86e0ed5 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/VipInfoDto.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/VipInfoDto.java @@ -12,12 +12,19 @@ @ApiModelProperty("月卡价格") private BigDecimal monthlyCard; + @ApiModelProperty(value = "月卡折扣") + private BigDecimal monthlyCardDiscount; @ApiModelProperty("季卡价格") private BigDecimal seasonCard; + @ApiModelProperty(value = "季卡折扣") + private BigDecimal seasonCardDiscount; @ApiModelProperty("年卡价格") private BigDecimal annualCard; + @ApiModelProperty(value = "年卡折扣") + private BigDecimal annualCardDiscount; @ApiModelProperty("最高抵扣价格") private BigDecimal maximumDeduction; + private BigDecimal timeAmount; @ApiModelProperty("抵扣次数") private Integer discountTimes; @@ -32,4 +39,7 @@ @ApiModelProperty(value = "最高总折扣") private BigDecimal totalDiscount; + + @ApiModelProperty(value = "会员名称") + private String name; } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserAddressController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserAddressController.java index 1ed7199..d779300 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserAddressController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserAddressController.java @@ -53,19 +53,23 @@ public AjaxResult<List<TAppUserAddress>> queryAddress() { // 用户id Long userId = tokenService.getLoginUserApplet().getUserId(); - return AjaxResult.ok(appUserAddressService.list(Wrappers.<TAppUserAddress>lambdaQuery().eq(TAppUserAddress::getAppUserId, userId))); + List<TAppUserAddress> list = appUserAddressService.list(Wrappers.<TAppUserAddress>lambdaQuery().eq(TAppUserAddress::getAppUserId, userId)); + list.forEach(e->e.setUid(e.getId().toString())); + return AjaxResult.ok(list); } /** * 查询用户默认地址列表 */ - @ApiOperation(tags = {"小程序-用户地址"},value = "查询用户默认地址列表") + @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))); + TAppUserAddress appUserAddress = appUserAddressService.getOne(Wrappers.<TAppUserAddress>lambdaQuery().eq(TAppUserAddress::getAppUserId, userId) + .eq(TAppUserAddress::getDefaultAddress, 1)); + appUserAddress.setUid(appUserAddress.getId().toString()); + return AjaxResult.ok(appUserAddress); } @@ -85,6 +89,20 @@ /** * 修改用户地址 */ + @ApiOperation(tags = {"小程序-用户地址"},value = "设置默认地址") + @GetMapping(value = "/setDefaultAddress") + public AjaxResult<String> setDefaultAddress(@RequestParam(value = "id") Long id) { + // 修改用户默认地址 + appUserAddressService.updateDefaultAddress(1,tokenService.getLoginUserApplet().getUserId()); + TAppUserAddress appUserAddress = appUserAddressService.getById(id); + appUserAddress.setDefaultAddress(1); + appUserAddressService.updateById(appUserAddress); + return AjaxResult.success(); + } + + /** + * 修改用户地址 + */ @ApiOperation(tags = {"小程序-用户地址"},value = "修改用户地址") @PostMapping(value = "/update") public AjaxResult<Boolean> update(@RequestBody TAppUserAddress dto) { @@ -94,6 +112,17 @@ } /** + * 通过地址id 查询地址信息 + * @param id + * @return + */ + @ApiOperation(tags = {"小程序-用户地址"},value = "查询用户地址详情") + @GetMapping(value = "/getDetailById") + public R<TAppUserAddress> getDetailById(@RequestParam(value = "id")Long id) { + return R.ok(appUserAddressService.getById(id)); + } + + /** * 删除用户地址 */ @ApiOperation(tags = {"小程序-用户地址"},value = "删除用户地址") 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")); + } } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/CarBrandUtil.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/CarBrandUtil.java index 568c5c6..3327e7d 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/CarBrandUtil.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/CarBrandUtil.java @@ -172,4 +172,58 @@ } return ""; } + + + public static String getDetailById(String brandId) throws Exception { + // Create a new request. + Request httpClientRequest = new Request(); + try { + // Set the request parameters. + // AppKey, AppSecrect, Method and Url are required parameters. + // Directly writing AK/SK in code is risky. For security, encrypt your AK/SK and store them in the configuration file or environment variables. + // In this example, the AK/SK are stored in environment variables for identity authentication. + // Before running this example, set environment variables HUAWEICLOUD_SDK_AK and HUAWEICLOUD_SDK_SK. + httpClientRequest.setKey("9a4a2b69afe141718f6843c5d39961ec"); + httpClientRequest.setSecret("541845f206324bbc933065b44fc98c47"); + httpClientRequest.setMethod("POST"); + // Set a request URL in the format of https://{Endpoint}/{URI}. + httpClientRequest.setUrl("https://vehiclequery.apistore.huaweicloud.com/vehicle/query/detail"); + httpClientRequest.addHeader("Content-Type", "text/plain"); + httpClientRequest.addQueryStringParam("modelId",brandId); + // Set a body for http request. +// httpClientRequest.setBody("put your request body here"); + } catch (Exception e) { +// LOGGER.error(e.getMessage()); + return ""; + } + CloseableHttpClient client = null; + try { + // Sign the request. + HttpRequestBase signedRequest = Client.sign(httpClientRequest, Constant.SIGNATURE_ALGORITHM_SDK_HMAC_SHA256); + if (Constant.DO_VERIFY) { + // creat httpClient and verify ssl certificate + HostName.setUrlHostName(httpClientRequest.getHost()); + client = (CloseableHttpClient) SSLCipherSuiteUtil.createHttpClientWithVerify(Constant.INTERNATIONAL_PROTOCOL); + } else { + // creat httpClient and do not verify ssl certificate + client = (CloseableHttpClient) SSLCipherSuiteUtil.createHttpClient(Constant.INTERNATIONAL_PROTOCOL); + } + HttpResponse response = client.execute(signedRequest); + // Print the body of the response. + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { +// LOGGER.info("Processing Body with name: {} and value: {}", System.getProperty("line.separator"), +// EntityUtils.toString(resEntity, "UTF-8")); + String string = EntityUtils.toString(resEntity, "UTF-8"); + return string; + } + } catch (Exception e) { + LOGGER.error(e.getMessage()); + } finally { + if (client != null) { + client.close(); + } + } + return ""; + } } diff --git a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/TAppUserAddressMapper.xml b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/TAppUserAddressMapper.xml index c8ffb59..7e582cd 100644 --- a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/TAppUserAddressMapper.xml +++ b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/TAppUserAddressMapper.xml @@ -8,9 +8,14 @@ <result column="app_user_id" property="appUserId" /> <result column="name" property="name" /> <result column="phone" property="phone" /> + <result column="province" property="province" /> + <result column="provinceCode" property="provinceCode" /> <result column="city" property="city" /> <result column="city_code" property="cityCode" /> + <result column="district" property="district" /> + <result column="district_code" property="districtCode" /> <result column="address" property="address" /> + <result column="house_number" property="houseNumber" /> <result column="lon" property="lon" /> <result column="lat" property="lat" /> <result column="default_address" property="defaultAddress" /> @@ -20,7 +25,7 @@ <!-- 通用查询结果列 --> <sql id="Base_Column_List"> - id, app_user_id, name, phone, city, city_code, address, lon, lat, default_address, create_time, del_flag + id, app_user_id, name, phone, province,provinceCode,city, city_code,district,district_code, address,house_number, lon, lat, default_address, create_time, del_flag </sql> </mapper> diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TExchangeOrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TExchangeOrderController.java index 721c8ba..2c79bee 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TExchangeOrderController.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TExchangeOrderController.java @@ -195,26 +195,21 @@ String[] split = goodsIds.split("-"); // 取出最后一位字符 类型1查询现金购买 类型2查询积分兑换 String s = split[split.length - 1]; + String[] split1 = split[0].split(","); List<Integer> res = new ArrayList<>(); switch (Integer.parseInt(s)){ case 1: - for (int i = 0; i < split.length-1; i++) { + 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); } break; case 2: - for (int i = 0; i < split.length-1; i++) { - Integer reduce = exchangeOrderService.list(new QueryWrapper<TExchangeOrder>() - .eq("order_type",1) - .ne("status",4) - .eq("goods_id", split[i]) - ) + 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", split1[i])) .stream().map(TExchangeOrder::getPurchaseQuantity).reduce(0, Integer::sum); res.add(reduce); } @@ -282,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){ diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java index 99efbec..196a5ce 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java @@ -502,7 +502,9 @@ BigDecimal electronicMoney = new BigDecimal("0"); BigDecimal serviceMoney = new BigDecimal("0"); for (ChargingOrderVO chargingOrderVO : list) { - total = total.add(chargingOrderVO.getChargingCapacity()); + if (chargingOrderVO.getChargingCapacity()!=null){ + total = total.add(chargingOrderVO.getChargingCapacity()); + } // 充电订单 明细记录 List<TChargingOrderAccountingStrategy> chargingOrderId = chargingOrderAccountingStrategyService.list(new QueryWrapper<TChargingOrderAccountingStrategy>() .eq("charging_order_id", chargingOrderVO.getId())); @@ -513,14 +515,18 @@ LocalDateTime startTime = chargingOrderVO.getStartTime(); LocalDateTime endTime = chargingOrderVO.getEndTime(); // 计算时间差 秒 充电时长 - long between = ChronoUnit.SECONDS.between(startTime, endTime); - chargingOrderVO.setChargingSecond(between); - time += between; + if (startTime!=null && endTime!=null){ + long between = ChronoUnit.SECONDS.between(startTime, endTime); + chargingOrderVO.setChargingSecond(between); + 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) { // 累计电费 @@ -542,11 +548,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); diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TExchangeOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TExchangeOrderServiceImpl.java index 9b71839..d554e24 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TExchangeOrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TExchangeOrderServiceImpl.java @@ -86,7 +86,7 @@ name = goods.getName(); imgUrl = goods.getCoverPicture(); }else{ - TCoupon coupon = couponClient.getCouponById1(tExchangeOrder.getGoodsId()).getData(); + TCoupon coupon = couponClient.getCouponById1(tExchangeOrder.getCouponId()).getData(); name = coupon.getName(); imgUrl = coupon.getCoverPicture(); } @@ -122,7 +122,7 @@ name = goods.getName(); imgUrl = goods.getCoverPicture(); }else{ - TCoupon coupon = couponClient.getCouponById1(exchangeOrder.getGoodsId()).getData(); + TCoupon coupon = couponClient.getCouponById1(exchangeOrder.getCouponId()).getData(); info.setCouponType(coupon.getType()); info.setDays(coupon.getDays()); info.setEndTime(coupon.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TCouponController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TCouponController.java index 792106f..34d1ff5 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TCouponController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TCouponController.java @@ -197,5 +197,12 @@ return R.ok(coupon); } + @PostMapping(value = "/getCouponById") + public R<TCoupon> getCouponById(@RequestParam("id") Integer id){ + TCoupon coupon = tCouponService.getById(id); + return R.ok(coupon); + } + + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java index 004ff33..6021c3a 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java +++ b/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(); diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java index e0a0fae..b60c3de 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java @@ -25,6 +25,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -143,19 +144,34 @@ @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(); + LocalDateTime now = LocalDateTime.now(); for (TVip vip : vips) { VipInfoDto vipInfoDto = new VipInfoDto(); vipInfoDto.setMonthlyCard(vip.getMonthlyCardReveal()==1?vip.getMonthlyCard():null); vipInfoDto.setSeasonCard(vip.getSeasonCardReveal()==1?vip.getSeasonCard():null); vipInfoDto.setAnnualCard(vip.getAnnualCardReveal()==1?vip.getAnnualCard():null); + //判断是否在折扣时间内,然后设置折扣价格 + if (vip.getMonthlyCardDiscountStart()!=null&&(now.isAfter(vip.getMonthlyCardDiscountStart())&&now.isBefore(vip.getMonthlyCardDiscountEnd()))){ + vipInfoDto.setMonthlyCardDiscount(vip.getMonthlyCardDiscount()); + } + if (vip.getSeasonCardDiscountStart()!=null&&(now.isAfter(vip.getSeasonCardDiscountStart())&&now.isBefore(vip.getSeasonCardDiscountEnd()))){ + vipInfoDto.setSeasonCardDiscount(vip.getSeasonCardDiscount()); + } + if (vip.getAnnualCardDiscountStart()!=null&&(now.isAfter(vip.getAnnualCardDiscountStart())&&now.isBefore(vip.getAnnualCardDiscountEnd()))){ + vipInfoDto.setAnnualCardDiscount(vip.getAnnualCardDiscount()); + } + + + vipInfoDto.setMaximumDeduction(vip.getMaximumDeduction()); 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()){ @@ -175,12 +191,13 @@ total = total.add(vip.getMaximumDeduction().multiply(BigDecimal.valueOf(vip.getDiscountTimes()))); for (VipCouponDto vipCouponDto : vipCouponDtos) { TCoupon tCoupon = vipCouponDto.getTCoupon(); - total.add(tCoupon.getDiscount()); + total.add(tCoupon.getMaximumDiscountAmount()); } vipInfoDto.setTotalDiscount(total); + vipInfoDto.setTimeAmount(vip.getMaximumDeduction().multiply(BigDecimal.valueOf(vip.getDiscountTimes()))); vipInfoDtos.add(vipInfoDto); } - return AjaxResult.success(vipInfoDtos); + return R.ok(vipInfoDtos); } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java index 7a58640..b9f434d 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TGoodsServiceImpl.java @@ -83,10 +83,10 @@ // 订单号加上商品类型 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)); - } +// 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; } diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TGoodsMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TGoodsMapper.xml index 417dd0b..fb2632b 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TGoodsMapper.xml +++ b/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 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> -- Gitblit v1.7.1