From 7bf7e4c6656287b1b9005d58d6ec45e0da5d8dc4 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期六, 26 十月 2024 10:02:11 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile

---
 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml                                        |  218 ++++++++++++++++++------------------------
 ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TParkingRecordMapper.xml                          |    2 
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java                            |    2 
 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserCarClient.java                         |    3 
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserCarController.java                         |    5 
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java                            |    5 
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java                   |    2 
 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TInviteUser.java                                    |    2 
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyDetailController.java |   10 +-
 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml                                        |    5 
 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserCarFallbackFactory.java                    |    7 +
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java                          |   15 +-
 12 files changed, 132 insertions(+), 144 deletions(-)

diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserCarFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserCarFallbackFactory.java
index 41202e3..e15cc67 100644
--- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserCarFallbackFactory.java
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserCarFallbackFactory.java
@@ -31,7 +31,12 @@
             public R<List<TAppUserCar>> getCarByIds(List<Long> carIds) {
                 return R.fail("根据用户车辆id查询车辆信息失败:"+throwable.getMessage());
             }
-    
+
+            @Override
+            public R<TAppUserCar> getCarById(String id) {
+                return R.fail("根据用户车辆id查询车辆信息失败:"+throwable.getMessage());
+            }
+
             @Override
             public R<TAppUserCar> getAppUserCarByLicensePlate(String licensePlate) {
                 return R.fail("根据车牌号查询数据失败:" + throwable.getMessage());
diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserCarClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserCarClient.java
index bce08c1..344c06a 100644
--- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserCarClient.java
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserCarClient.java
@@ -8,6 +8,7 @@
 import com.ruoyi.common.core.domain.R;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -28,6 +29,8 @@
      */
     @PostMapping(value = "/t-app-user-car/t-app-user-car/getCarByIds")
     public R<List<TAppUserCar>> getCarByIds(@RequestBody List<Long> carIds);
+    @PostMapping(value = "/t-app-user-car/t-app-user-car/getCarById/{id}")
+    public R<TAppUserCar> getCarById(@PathVariable("id") String id);
     
     
     /**
diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TInviteUser.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TInviteUser.java
index 710d212..79cae9d 100644
--- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TInviteUser.java
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TInviteUser.java
@@ -50,6 +50,8 @@
     @TableField("create_time")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime createTime;
+    @TableField(exist = false)
+    private String avatar;
 
 
 }
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserCarController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserCarController.java
index 97b6d63..67ff1d8 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserCarController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserCarController.java
@@ -36,7 +36,10 @@
     public R<List<TAppUserCar>> getCarByIds(@RequestBody List<Long> carIds){
         return R.ok(appUserCarService.list(Wrappers.lambdaQuery(TAppUserCar.class).in(TAppUserCar::getId,carIds)));
     }
-    
+    @PostMapping(value = "/t-app-user-car/getCarById/{id}")
+    public R<TAppUserCar> getCarById(@PathVariable("id")String id){
+        return R.ok(appUserCarService.lambdaQuery().eq(TAppUserCar::getId,id).one());
+    }
     
     /**
      * 根据车牌号查询数据
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 f06c968..7f880e2 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
@@ -765,8 +765,11 @@
     @PostMapping(value = "/user/invite/page")
     public R<Page<TInviteUser>> invitePage(@RequestBody BasePage basePage) {
         Long userId = tokenService.getLoginUserApplet().getUserId();
-
         Page<TInviteUser> page = inviteUserService.lambdaQuery().eq(TInviteUser::getAppUserId, userId).isNotNull(TInviteUser::getAward).orderByDesc(TInviteUser::getCreateTime).page(Page.of(basePage.getPageCurr(), basePage.getPageSize()));
+        for (TInviteUser record : page.getRecords()) {
+            TAppUser byId = appUserService.getById(record.getBeInvitedAppUserId());
+            record.setAvatar(byId.getAvatar());
+        }
         return R.ok(page);
     }
 
diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyDetailController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyDetailController.java
index 89d4819..3bd8ac6 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyDetailController.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TAccountingStrategyDetailController.java
@@ -114,13 +114,13 @@
     public R<TAccountingStrategyDetail> getDetailByCode(@RequestParam("code") String code){
         // 查询桩
         TChargingPile chargingPile = chargingPileService.getOne(Wrappers.lambdaQuery(TChargingPile.class)
-                .eq(TChargingPile::getCode,code)
+                .eq(TChargingPile::getCode,code).eq(TChargingPile::getDelFlag, 0)
                 .last("LIMIT 1"));
         if(Objects.isNull(chargingPile)){
             return R.fail("未查询到该桩设备");
         }
         TChargingGun chargingGun = chargingGunService.getOne(Wrappers.lambdaQuery(TChargingGun.class)
-                .eq(TChargingGun::getChargingPileId, chargingPile.getId())
+                .eq(TChargingGun::getChargingPileId, chargingPile.getId()).eq(TChargingGun::getDelFlag, 0)
                 .last("LIMIT 1"));
         TAccountingStrategy accountingStrategy = accountingStrategyService.getById(chargingGun.getAccountingStrategyId());
         TAccountingStrategyDetail one;
@@ -146,7 +146,7 @@
     public R<Boolean> checkChargingStrategy(@RequestBody CheckChargingStrategyDTO dto){
         // 查询桩
         TChargingPile chargingPile = chargingPileService.getOne(Wrappers.lambdaQuery(TChargingPile.class)
-                .eq(TChargingPile::getCode,dto.getCode())
+                .eq(TChargingPile::getCode,dto.getCode()).eq(TChargingPile::getDelFlag, 0)
                 .last("LIMIT 1"));
         if(Objects.isNull(chargingPile)){
             return R.ok(false);
@@ -180,13 +180,13 @@
     public R<List<TAccountingStrategyDetail>> getDetailListByCode(@RequestParam("code") String code){
         // 查询桩
         TChargingPile chargingPile = chargingPileService.getOne(Wrappers.lambdaQuery(TChargingPile.class)
-                .eq(TChargingPile::getCode,code)
+                .eq(TChargingPile::getCode,code).eq(TChargingPile::getDelFlag, 0)
                 .last("LIMIT 1"));
         if(Objects.isNull(chargingPile)){
             return R.fail("未查询到该桩设备");
         }
         TChargingGun chargingGun = chargingGunService.getOne(Wrappers.lambdaQuery(TChargingGun.class)
-                .eq(TChargingGun::getChargingPileId, chargingPile.getId())
+                .eq(TChargingGun::getChargingPileId, chargingPile.getId()).eq(TChargingGun::getDelFlag, 0)
                 .last("LIMIT 1"));
         TAccountingStrategy accountingStrategy = accountingStrategyService.getById(chargingGun.getAccountingStrategyId());
         if(Objects.nonNull(accountingStrategy)){
diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
index 8228a4c..e56a27f 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
@@ -394,7 +394,7 @@
 		Site site = this.getById(id);
 		site.setAccountingStrategyId(accountingStrategyId);
 		this.updateById(site);
-		List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getChargingPileId, id).eq(TChargingGun::getDelFlag, 0));
+		List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getSiteId, id).eq(TChargingGun::getDelFlag, 0));
 		for (TChargingGun tChargingGun : list) {
 			tChargingGun.setAccountingStrategyId(accountingStrategyId);
 		}
diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TParkingRecordMapper.xml b/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TParkingRecordMapper.xml
index e88746d..c5e4070 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TParkingRecordMapper.xml
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TParkingRecordMapper.xml
@@ -69,7 +69,7 @@
                 AND code LIKE concat('%',#{query.code},'%')
             </if>
             <if test="query.licensePlate != null and query.licensePlate != ''">
-                AND licensePlate LIKE concat('%',#{query.licensePlate},'%')
+                AND license_plate LIKE concat('%',#{query.licensePlate},'%')
             </if>
             <if test="query.lotIds != null and query.lotIds.size()>0">
                 AND parking_lot_id IN
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java
index 6730597..05cf05f 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java
@@ -320,7 +320,7 @@
                 chargingBillRefundExport.setCode(tChargingOrder.getCode());
                 chargingBillRefundExport.setPayTime(tChargingOrder.getCreateTime()!=null?DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getCreateTime())):"");
                 if (tChargingOrder.getRefundTime()!=null){
-                    chargingBillRefundExport.setRefundTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(tChargingOrder.getRefundTime())));
+                    chargingBillRefundExport.setRefundTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",DateUtils.toDate(one.getRefundTime())));
                 }
                 chargingBillRefundExport.setRefundMoney(one.getRefundAmount().toString());
                 chargingBillRefundExport.setRefundRemark(one.getRefundReason());
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
index 0100bb5..1a968ba 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -351,12 +351,12 @@
         chargingOrderInfoVO.setSurplus(byId.getTotalElectricity()!=null?byId.getTotalElectricity().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
         chargingOrderInfoVO.setTotalPower(byId.getPower()!=null?byId.getPower().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
         if (byId.getAppUserCarId()!=null){
-            List<TAppUserCar> data = appUserCarClient.getCarByIds(Arrays.asList(byId.getAppUserCarId())).getData();
-            if (!data.isEmpty()){
-                chargingOrderInfoVO.setLicensePlate(data.get(0).getLicensePlate());
-                chargingOrderInfoVO.setVehicleBrand(data.get(0).getVehicleBrand());
-                chargingOrderInfoVO.setVehicleModel(data.get(0).getVehicleModel());
-                chargingOrderInfoVO.setVehicleUse(data.get(0).getVehicleUse());
+            TAppUserCar data = appUserCarClient.getCarById(byId.getAppUserCarId()+"").getData();
+            if (data!=null){
+                chargingOrderInfoVO.setLicensePlate(data.getLicensePlate());
+                chargingOrderInfoVO.setVehicleBrand(data.getVehicleBrand());
+                chargingOrderInfoVO.setVehicleModel(data.getVehicleModel());
+                chargingOrderInfoVO.setVehicleUse(data.getVehicleUse());
             }
         }
         // 时段总服务费
@@ -811,7 +811,6 @@
         Map<String,ChargingOrderVO> map  = new HashMap<>();
         for (UploadRealTimeMonitoringData uploadRealTimeMonitoringData : data1) {
             ChargingOrderAndUploadRealTimeMonitoringDataDto dataDto = new ChargingOrderAndUploadRealTimeMonitoringDataDto();
-            BeanUtils.copyProperties(uploadRealTimeMonitoringData,dataDto);
             ChargingOrderQuery dto = new ChargingOrderQuery();
             dto.setCode(uploadRealTimeMonitoringData.getTransaction_serial_number());
             TCharingOrderVO vo = chargingOrderService.chargingOrder(dto);
@@ -820,6 +819,8 @@
                 if (chargingOrderVO != null) {
                     BeanUtils.copyProperties(chargingOrderVO, dataDto);
                 }
+                BeanUtils.copyProperties(uploadRealTimeMonitoringData,dataDto);
+
                 dtos.add(dataDto);
             }else {
                 continue;
diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
index 92f06df..8e66a69 100644
--- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
+++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -401,6 +401,7 @@
         CAST(SUM(service_charge-coupon_discount_amount) AS DECIMAL(20, 6)) as  servicecharge,
         CAST(SUM(charging_capacity) AS DECIMAL(20, 6)) as electrovalence,
         CAST(SUM(electrovalence) AS DECIMAL(20, 4)) AS paymentAmount,
+        SUM(payment_amount) AS paymoney,
     count(1) as orderCount
         FROM
             t_charging_order
@@ -972,7 +973,7 @@
                 LEFT JOIN  `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id
                 LEFT JOIN  `charging_pile_service`.`t_charging_pile` cp on tc.charging_pile_id = cp.id
         WHERE
-            co.start_time IS NOT NULL AND co.end_time IS NOT NULL and cp.type = 1
+            co.start_time IS NOT NULL AND co.end_time IS NOT NULL and tc.type = 4
         <if test="siteIds != null and siteIds.size() > 0">
             and co.site_id IN
             <foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
@@ -1032,7 +1033,7 @@
         LEFT JOIN  `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id
         LEFT JOIN  `charging_pile_service`.`t_charging_pile` cp on tc.charging_pile_id = cp.id
         WHERE
-        co.start_time IS NOT NULL AND co.end_time IS NOT NULL and cp.type = 2
+        co.start_time IS NOT NULL AND co.end_time IS NOT NULL and tc.type in (2,3)
         <if test="siteIds != null and siteIds.size() > 0">
             and co.site_id IN
             <foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml
index f539844..588abad 100644
--- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml
+++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml
@@ -97,133 +97,103 @@
             AND t1.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
         </if>
         </if>
-        <if test="req.orderType == null or req.orderType == 2">
-        <if test="req.type == null or req.type == 1 or req.type == 2">
-            union all
-            select t2.code ,t2.order_amount as paymentAmount,
-            t2.coupon_discount_amount as couponDiscountAmount,
-            t2.vip_discount_amount as vipDiscountAmount,
-            t2.payment_amount as orderAmount,
-            t2.create_time as createTime,
-            t2.app_user_id as appUserId,
-            2 as orderType
-            from t_shopping_order t2
-            where 1 = 1
-            <if test="null != req.code and req.code!=''">
-                and t2.code  LIKE CONCAT('%',#{req.code},'%')
+        <if test="req.siteId == null">
+            <if test="req.orderType == null or req.orderType == 2">
+                <if test="req.type == null or req.type == 1 or req.type == 2">
+                    union all
+                    select t2.code ,t2.order_amount as paymentAmount,
+                    t2.coupon_discount_amount as couponDiscountAmount,
+                    t2.vip_discount_amount as vipDiscountAmount,
+                    t2.payment_amount as orderAmount,
+                    t2.create_time as createTime,
+                    t2.app_user_id as appUserId,
+                    2 as orderType
+                    from t_shopping_order t2
+                    where 1 = 1
+                    <if test="null != req.code and req.code!=''">
+                        and t2.code  LIKE CONCAT('%',#{req.code},'%')
+                    </if>
+                    <if test="req.type != null and req.type != '' and req.type == 1">
+                        and (t2.coupon_discount_amount  > 0)
+                    </if>
+                    <if test="req.type != null and req.type != '' and req.type == 2">
+                        and ( t2.vip_discount_amount  > 0)
+                    </if>
+                    <if test="req.type == null ">
+                        and (t2.vip_discount_amount  > 0 or t2.coupon_discount_amount  > 0)
+                    </if>
+                    <if test="null != req.userIds and req.userIds.size()>0" >
+                        and t2.app_user_id in
+                        <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
+                            #{item}
+                        </foreach>
+                    </if>
+                    <if test="req.endTime != null and req.endTime != '' and req.startTime != null and req.startTime != ''">
+                        AND (t2.create_time between CONCAT(#{req.startTime},':00') and CONCAT(#{req.endTime},':59'))
+                    </if>
+                    and t2.payment_status =2
+                    AND t2.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
+                </if>
             </if>
-            <if test="req.type != null and req.type != '' and req.type == 1">
-                and (t2.coupon_discount_amount  > 0)
+            <if test="req.orderType == null or req.orderType == 3">
+                <if test="req.type == null or req.type == 3">
+                    union all
+                    select t3.code ,t3.order_amount as orderAmount,
+                    0 as couponDiscountAmount,
+                    t3.discount_amount as vipDiscountAmount,
+                    t3.payment_amount as paymentAmount,
+                    t3.create_time as createTime,
+                    t3.app_user_id as appUserId,
+                    3 as orderType
+                    from t_vip_order t3
+                    where 1 = 1
+                    and t3.type =1
+                    <if test="null != req.code and req.code!=''">
+                        and t3.code  LIKE CONCAT('%',#{req.code},'%')
+                    </if>
+                    <if test="req.type == null ">
+                        and t3.discount_amount  > 0
+                    </if>
+                    <if test="null != req.userIds and req.userIds.size()>0" >
+                        and t3.app_user_id in
+                        <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
+                            #{item}
+                        </foreach>
+                    </if>
+                    <if test="req.endTime != null and req.endTime != '' and req.startTime != null and req.startTime != ''">
+                        AND (t3.create_time between CONCAT(#{req.startTime},':00') and CONCAT(#{req.endTime},':59'))
+                    </if>
+                    and t3.payment_status =2
+                    AND t3.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
+                </if>
             </if>
-            <if test="req.type != null and req.type != '' and req.type == 2">
-                and ( t2.vip_discount_amount  > 0)
-            </if>
-            <if test="req.type == null ">
-                and (t2.vip_discount_amount  > 0 or t2.coupon_discount_amount  > 0)
-            </if>
-            <if test="null != req.userIds and req.userIds.size()>0" >
-                and t2.app_user_id in
-                <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
-                    #{item}
-                </foreach>
-            </if>
-            <if test="req.endTime != null and req.endTime != '' and req.startTime != null and req.startTime != ''">
-                AND (t2.create_time between CONCAT(#{req.startTime},':00') and CONCAT(#{req.endTime},':59'))
-            </if>
-            and t2.payment_status =2
-            AND t2.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
-        </if>
-        </if>
-        <if test="req.orderType == null or req.orderType == 3">
-            <if test="req.type == null or req.type == 3">
-                union all
-                select t3.code ,t3.order_amount as orderAmount,
-                0 as couponDiscountAmount,
-                t3.discount_amount as vipDiscountAmount,
-                t3.payment_amount as paymentAmount,
-                t3.create_time as createTime,
-                t3.app_user_id as appUserId,
-                3 as orderType
-                from t_vip_order t3
-                where 1 = 1
-                and t3.type =1
-                <if test="null != req.code and req.code!=''">
-                    and t3.code  LIKE CONCAT('%',#{req.code},'%')
-                </if>
-                <if test="req.type == null ">
-                    and t3.discount_amount  > 0
-                </if>
-                <if test="null != req.userIds and req.userIds.size()>0" >
-                    and t3.app_user_id in
-                    <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
-                        #{item}
-                    </foreach>
-                </if>
-                <if test="req.endTime != null and req.endTime != '' and req.startTime != null and req.startTime != ''">
-                    AND (t3.create_time between CONCAT(#{req.startTime},':00') and CONCAT(#{req.endTime},':59'))
-                </if>
-                and t3.payment_status =2
-                AND t3.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
-            </if>
-        </if>
-        <if test="req.orderType == null or req.orderType == 4">
-            <if test="req.type == null or req.type == 4">
-                union all
-                select t4.code ,t4.order_amount as orderAmount,
-                0 as couponDiscountAmount,
-                t4.discount_amount as vipDiscountAmount,
-                t4.payment_amount as paymentAmount,
-                t4.create_time as createTime,
-                t4.app_user_id as appUserId,
-                4 as orderType
-                from t_vip_order t4
-                where 1 = 1
-                and t4.type =2
-                <if test="null != req.code and req.code!=''">
-                    and t4.code  LIKE CONCAT('%',#{req.code},'%')
-                </if>
-                <if test="req.type == null ">
-                    and t4.discount_amount  > 0
-                </if>
-                <if test="null != req.userIds and req.userIds.size()>0" >
-                    and t4.app_user_id in
-                    <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
-                        #{item}
-                    </foreach>
-                </if>
-                <if test="req.endTime != null and req.endTime != '' and req.startTime != null and req.startTime != ''">
-                    AND (t4.create_time between CONCAT(#{req.startTime},':00') and CONCAT(#{req.endTime},':59'))
-                </if>
-                and t4.payment_status =2
-                AND t4.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
-            </if>
-        </if>
-        <if test="req.orderType == null or req.orderType == 4">
-            <if test="req.type == null or req.type == 4">
-                union all
-                select t5.code ,t5.order_amount as orderAmount,
-                0 as couponDiscountAmount,
-                0 as vipDiscountAmount,
-                0 as paymentAmount,
-                t5.create_time as createTime,
-                t5.app_user_id as appUserId,
-                4 as orderType
-                from t_grant_vip t5
-                where 1 = 1
-                <if test="null != req.code and req.code!=''">
-                    and t5.code  LIKE CONCAT('%',#{req.code},'%')
-                </if>
-                <if test="null != req.userIds and req.userIds.size()>0" >
-                    and t5.app_user_id in
-                    <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
-                        #{item}
-                    </foreach>
-                </if>
-                <if test="req.endTime != null and req.endTime != '' and req.startTime != null and req.startTime != ''">
-                    AND (t5.create_time between CONCAT(#{req.startTime},':00') and CONCAT(#{req.endTime},':59'))
-                </if>
-                AND t5.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
+            <if test="req.orderType == null or req.orderType == 4">
+                <if test="req.type == null or req.type == 4">
+                    union all
+                    select t5.code ,t5.order_amount as orderAmount,
+                    0 as couponDiscountAmount,
+                    0 as vipDiscountAmount,
+                    0 as paymentAmount,
+                    t5.create_time as createTime,
+                    t5.app_user_id as appUserId,
+                    4 as orderType
+                    from t_grant_vip t5
+                    where 1 = 1
+                    <if test="null != req.code and req.code!=''">
+                        and t5.code  LIKE CONCAT('%',#{req.code},'%')
+                    </if>
+                    <if test="null != req.userIds and req.userIds.size()>0" >
+                        and t5.app_user_id in
+                        <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
+                            #{item}
+                        </foreach>
+                    </if>
+                    <if test="req.endTime != null and req.endTime != '' and req.startTime != null and req.startTime != ''">
+                        AND (t5.create_time between CONCAT(#{req.startTime},':00') and CONCAT(#{req.endTime},':59'))
+                    </if>
+                    AND t5.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
 
+                </if>
             </if>
         </if>
     </select>

--
Gitblit v1.7.1