From 49c5d881d50acac8dc2659f31b2206c36f83c862 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期二, 27 八月 2024 12:06:41 +0800
Subject: [PATCH] 修改

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java |   12 ++-
 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/ListInfoCouponDto.java          |   18 ++++++
 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      |   73 ++++++++++++++++++------
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TCouponController.java           |    7 ++
 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                          |    4 
 7 files changed, 147 insertions(+), 29 deletions(-)

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..6536aa8
--- /dev/null
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/dto/ListInfoCouponDto.java
@@ -0,0 +1,18 @@
+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> infoCouponDtoList1;
+    List<InfoCouponDto> infoCouponDtoList2;
+
+}
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..951755c 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);
@@ -530,24 +531,47 @@
     }
 
     @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());
+                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);
-
+            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());
+            couponDtos2.add(infoCouponDto);
         }
 
 
-        return R.ok(couponDtos);
-
+        ListInfoCouponDto listInfoCouponDto = new ListInfoCouponDto();
+        listInfoCouponDto.setInfoCouponDtoList1(couponDtos1);
+        listInfoCouponDto.setInfoCouponDtoList2(couponDtos2);
+        return R.ok(listInfoCouponDto);
 
     }
 
@@ -834,7 +858,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 +899,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-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 31ebc79..07cc2a4 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
@@ -462,7 +462,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()));
@@ -473,9 +475,11 @@
 			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){
 				income = income.add(chargingOrderVO.getPaymentAmount().subtract(chargingOrderVO.getRefundAmount()));
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/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..c60fde9 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
@@ -58,7 +58,7 @@
         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,inventory_quantity as inventory,payment_amount as original_price,payment_amount as preferential_price,vip_payment_amount as vip_price
         FROM
             t_coupon
         WHERE `status`= 1 and del_flag = 0 and type = #{appGoodQuery.type}
@@ -68,7 +68,7 @@
                 WHEN `inventory` = 0 THEN
                     0 ELSE 1
                 END DESC,
-            `redeem_points` ASC;
+            `redeem_points` ASC
     </select>
 
 </mapper>

--
Gitblit v1.7.1