Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile
| | |
| | | @TableField(exist = false) |
| | | private String orderNum; |
| | | |
| | | @TableField(exist = false) |
| | | private Integer goodType; |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private String vipName; |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | List<Map<String,Object>> equipmentMapOut1; |
| | | @ApiModelProperty("交流离网率") |
| | | List<Map<String,Object>> equipmentMapOut2; |
| | | @ApiModelProperty("需求电流满足率") |
| | | List<Map<String,Object>> needElec; |
| | | @ApiModelProperty("需求电流满足率直流") |
| | | List<Map<String,Object>> needElec1; |
| | | @ApiModelProperty("需求电流满足率交流") |
| | | List<Map<String,Object>> needElec2; |
| | | double average1; |
| | | double average2; |
| | | double average3; |
| | | double average4; |
| | | } |
| | |
| | | public class TCharingUserMapVO { |
| | | @ApiModelProperty("上分折线图") |
| | | private List<Map<String,Object>> map; |
| | | private List<Map<String,Object>> map1; |
| | | @ApiModelProperty("用户标签") |
| | | private List<Map<String,Object>> userMaps; |
| | | @ApiModelProperty("单位消费") |
| | |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.TExchangeOrder; |
| | | import com.ruoyi.other.api.domain.*; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.dto.UnitListQueryDto; |
| | | import com.ruoyi.other.api.feignClient.IntegralRuleClient; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | |
| | | .eq(userListQueryDto.getStatus() != null, TAppUser::getStatus, userListQueryDto.getStatus()) |
| | | .eq(userListQueryDto.getVipTypeId() != null, TAppUser::getVipId, userListQueryDto.getVipTypeId()) |
| | | .in(!userIds.isEmpty(),TAppUser::getId,userIds) |
| | | .orderByDesc(BasePojo::getCreateTime) |
| | | .page(Page.of(userListQueryDto.getPageCurr(), userListQueryDto.getPageSize())); |
| | | if (page.getRecords().isEmpty()){ |
| | | return R.ok(page); |
| | |
| | | for (TAppUserIntegralChange record : page.getRecords()) { |
| | | record.setDateTime(record.getCreateTime()); |
| | | record.setUid(record.getId().toString()); |
| | | if (record.getChangeType()==2){ |
| | | if (record.getChangeType()==2||record.getChangeType()==3){ |
| | | R<TChargingOrder> tChargingOrderR = chargingOrderClient.orderDetail(Long.valueOf(record.getExtension())); |
| | | if (tChargingOrderR.getData()!=null) { |
| | | record.setOrderNum(tChargingOrderR.getData().getCode()); |
| | |
| | | @GetMapping(value = "/user/points/detail") |
| | | public R<TAppUserIntegralChange> pointsDetail(String id) { |
| | | TAppUserIntegralChange byId = integralChangeService.getById(id); |
| | | TExchangeOrder data = exchangeOrderClient.orderDetail(Long.valueOf(byId.getExtension())).getData(); |
| | | if (data!=null) { |
| | | byId.setGoodType(data.getOrderType()); |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | | |
| | |
| | | }else { |
| | | appUserInfoDto.setIsVip(1); |
| | | appUserInfoDto.setVipExpireTime(byId.getVipEndTime()); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | //判断当天是否签到 |
| | | Long count = signService.lambdaQuery().eq(TAppUserSign::getAppUserId,userId).eq(TAppUserSign::getSignDay, LocalDate.now()).count(); |
| | |
| | | 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 = "设置头像", tags = {"小程序-个人中心"}) |
| | | @GetMapping(value = "/user/set/avatar") |
| | | public R avatar(String url) { |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | TAppUser byId = appUserService.getById(userId); |
| | | byId.setAvatar(url); |
| | | appUserService.updateById(byId); |
| | | |
| | | return R.ok(); |
| | | |
| | | } |
| | | |
| | |
| | | String brand = CarBrandUtil.getBrand(); |
| | | JSONObject jsonObject = JSON.parseObject(brand); |
| | | JSONArray data = jsonObject.getJSONArray("data"); |
| | | JSONArray data1 = new JSONArray(); |
| | | if (name!=null) { |
| | | for (int i = 0; i < data.size(); i++) { |
| | | JSONObject brand1 = data.getJSONObject(i); |
| | | String o = (String) brand1.get("name"); |
| | | if (o.contains(name)) { |
| | | data1.add(brand1); |
| | | } |
| | | } |
| | | return R.ok(data1); |
| | | } |
| | | return R.ok(data); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.api.dto.SendCouponDto; |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.api.vo.GetAppUserVipDetail; |
| | | import com.ruoyi.account.service.TAppUserVipDetailService; |
| | | import com.ruoyi.account.util.VipInfoDto; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.dto.VipCouponDto; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Resource |
| | | private VipClient vipClient; |
| | | @Resource |
| | | private OtherClient otherClient; |
| | | |
| | | @GetMapping("/getVipUseDetail") |
| | | @ApiOperation(value = "生效会员列表", tags = {"小程序-个人中心"}) |
| | | public R<List<TAppUserVipDetail>> getVipUseDetail(){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | List<TAppUserVipDetail> list = appUserVipDetailService.lambdaQuery().eq(TAppUserVipDetail::getAppUserId, userId).last(" and now() between start_time and end_time order by start_time asc").list(); |
| | | List<TAppUserVipDetail> list = appUserVipDetailService.lambdaQuery().eq(TAppUserVipDetail::getAppUserId, userId).last(" and now() <= end_time order by start_time asc").list(); |
| | | |
| | | for (TAppUserVipDetail tAppUserVipDetail : list) { |
| | | if(null != tAppUserVipDetail.getVipId()){ |
| | |
| | | tAppUserVipDetail.setVipName(data.getName()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | return R.ok(list); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.account.service.TAppCouponService; |
| | | import com.ruoyi.account.service.TAppUserVipDetailService; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | | import com.ruoyi.order.api.query.TChargingCountQuery; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.dto.SendCouponDto; |
| | | import com.ruoyi.account.api.feignClient.AppCouponClient; |
| | | import com.ruoyi.account.api.model.TAppCoupon; |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.mapper.TAppUserVipDetailMapper; |
| | |
| | | import com.ruoyi.account.service.TAppCouponService; |
| | | import com.ruoyi.account.service.TAppUserVipDetailService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.service.TAppUserService; |
| | | import com.ruoyi.account.service.TAppUserVipDetailService; |
| | | import org.intellij.lang.annotations.RegExp; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | package com.ruoyi.account.util; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.ruoyi.account.api.dto.SendCouponDto; |
| | | import com.ruoyi.account.api.model.TAppCoupon; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | |
| | | // 更新最后的连续天数 |
| | | maxContinuousDays = Math.max(maxContinuousDays, currentContinuousDays); |
| | | |
| | | return maxContinuousDays; |
| | | return currentContinuousDays; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.account.util; |
| | | |
| | | import com.ruoyi.other.api.dto.VipCouponDto; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class VipInfoDto { |
| | | private Integer id; |
| | | @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; |
| | | |
| | | @ApiModelProperty(value = "双倍积分开关(0=否,1=是)") |
| | | private Integer doubleIntegration; |
| | | |
| | | @ApiModelProperty(value = "商城专享价开关(0=否,1=是)") |
| | | private Integer mallExclusivePrice; |
| | | @ApiModelProperty(value = "可赠送的优惠卷列表") |
| | | |
| | | private List<VipCouponDto> vipCouponDtos; |
| | | |
| | | @ApiModelProperty(value = "最高总折扣") |
| | | private BigDecimal totalDiscount; |
| | | |
| | | @ApiModelProperty(value = "会员名称") |
| | | private String name; |
| | | } |
| | |
| | | import com.ruoyi.chargingPile.api.model.Partner; |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.common.core.utils.WebUtils; |
| | | import com.ruoyi.common.core.web.domain.BasePojo; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.order.api.model.ExportUidDto; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | |
| | | public AjaxResult<Page<TApplyChargingPile>> page(@RequestBody ApplyChargingQuery applyChargingQuery) { |
| | | Page<TApplyChargingPile> page = applyChargingPileService.lambdaQuery() |
| | | .like(applyChargingQuery.getLandlordPhone() != null && !applyChargingQuery.getLandlordPhone().equals(""), TApplyChargingPile::getLandlordPhone, applyChargingQuery.getLandlordPhone()) |
| | | .orderByDesc(BasePojo::getCreateTime ) |
| | | .page(Page.of(applyChargingQuery.getPageCurr(), applyChargingQuery.getPageSize())); |
| | | return AjaxResult.ok(page); |
| | | } |
| | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | if (parkingRecordQueryDto.getDayType()==1) { |
| | | List<Map<String, Object>> maps = parkingRecordService.parkingData(parkingRecordQueryDto); |
| | | tParkLotRecordVO.setMaps(maps); |
| | | |
| | | |
| | | List<Map<String, Object>> charMap = new ArrayList<>(); |
| | | // 生成从 "00:00" 到 "23:00" 的时间数据 |
| | | for (int hour = 0; hour < 24; hour++) { |
| | | String time = String.format("%02d:00", hour); |
| | | Map<String, Object> mapWithTimeValue = findMapWithTimeValue(maps, time); |
| | | if (mapWithTimeValue!=null){ |
| | | charMap.add(mapWithTimeValue); |
| | | }else { |
| | | Map<String, Object> timeMap = new HashMap<>(); |
| | | timeMap.put("time", time); // 初始化值为 null |
| | | timeMap.put("orders", 0); |
| | | timeMap.put("timeoutAmount", 0); |
| | | |
| | | charMap.add(timeMap); |
| | | } |
| | | } |
| | | |
| | | tParkLotRecordVO.setMaps(charMap); |
| | | }else { |
| | | List<Map<String, Object>> maps = parkingRecordService.parkingDataByDate(parkingRecordQueryDto); |
| | | if(parkingRecordQueryDto.getDayType()==2||parkingRecordQueryDto.getDayType()==3){ |
| | | //按日 |
| | | // 解析 startTime 和 endTime 为 LocalDate |
| | | LocalDate startDate = parkingRecordQueryDto.getStartTime(); |
| | | LocalDate endDate = parkingRecordQueryDto.getEndTime(); |
| | | |
| | | List<Map<String, Object>> dateRangeStatistics = new ArrayList<>(); |
| | | |
| | | // 遍历日期范围 |
| | | while (!startDate.isAfter(endDate)) { |
| | | String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | Map<String, Object> dailyStats = findMapWithDateValue(maps, formattedDate); |
| | | |
| | | if (dailyStats != null) { |
| | | dateRangeStatistics.add(dailyStats); |
| | | } else { |
| | | Map<String, Object> dateMap = new HashMap<>(); |
| | | dateMap.put("time", formattedDate); |
| | | dateMap.put("electrovalence", 0); |
| | | dateMap.put("orderCount", 0); |
| | | dateMap.put("servicecharge", 0); |
| | | dateMap.put("electricity", 0); |
| | | dateRangeStatistics.add(dateMap); |
| | | } |
| | | |
| | | // 移动到下一天 |
| | | startDate = startDate.plusDays(1); |
| | | } |
| | | tParkLotRecordVO.setMaps(dateRangeStatistics); |
| | | |
| | | }else { |
| | | |
| | | } |
| | | |
| | | tParkLotRecordVO.setMaps(maps); |
| | | } |
| | | |
| | |
| | | return R.ok(tParkLotRecordVO); |
| | | |
| | | } |
| | | private static Map<String, Object> findMapWithTimeValue(List<Map<String, Object>> charMap1,String timeValue) { |
| | | for (Map<String, Object> map : charMap1) { |
| | | if (map.containsKey("time") && map.get("time").equals(timeValue)) { |
| | | return map; |
| | | } |
| | | } |
| | | return null; // 如果没有找到,返回 null |
| | | } |
| | | |
| | | |
| | | private Map<String, Object> findMapWithDateValue(List<Map<String, Object>> list, String date) { |
| | | for (Map<String, Object> map : list) { |
| | | if (date.equals(map.get("time"))) { |
| | | return map; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | @ResponseBody |
| | | @PostMapping(value = "/parking/work") |
| | | @ApiOperation(value = "停车订单统计", tags = {"管理后台-工作台"}) |
| | |
| | | Long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(TChargingGun.class) |
| | | .eq(TChargingGun::getStatus, 1)); |
| | | HashMap<String, Integer> objectObjectHashMap1 = new HashMap<>(); |
| | | objectObjectHashMap1.put("1", count.intValue()); |
| | | objectObjectHashMap1.put("charge_mode",1); |
| | | objectObjectHashMap1.put("modeCount", count.intValue()); |
| | | statusStatistics.add(objectObjectHashMap1); |
| | | // statusStatistics.put(1, count.intValue()); |
| | | // 故障 |
| | | count = this.baseMapper.selectCount(Wrappers.lambdaQuery(TChargingGun.class) |
| | | .eq(TChargingGun::getStatus, 7)); |
| | | HashMap<String, Integer> objectObjectHashMap2 = new HashMap<>(); |
| | | objectObjectHashMap2.put("2", count.intValue()); |
| | | // objectObjectHashMap2.put("2", count.intValue()); |
| | | objectObjectHashMap2.put("charge_mode",2); |
| | | objectObjectHashMap2.put("modeCount", count.intValue()); |
| | | statusStatistics.add(objectObjectHashMap2); |
| | | |
| | | // statusStatistics.put(2, count.intValue()); |
| | |
| | | count = this.baseMapper.selectCount(Wrappers.lambdaQuery(TChargingGun.class) |
| | | .in(TChargingGun::getStatus, Arrays.asList(3,4,5,6))); |
| | | HashMap<String, Integer> objectObjectHashMap = new HashMap<>(); |
| | | objectObjectHashMap.put("3", count.intValue()); |
| | | objectObjectHashMap.put("charge_mode",3); |
| | | objectObjectHashMap.put("modeCount", count.intValue()); |
| | | statusStatistics.add(objectObjectHashMap); |
| | | |
| | | // statusStatistics.put(3, count.intValue()); |
| | |
| | | </select> |
| | | <select id="parkingData" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS TIME, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS time, |
| | | count( 1 ) AS orders, |
| | | SUM( timeout_amount ) AS timeoutAmount |
| | | FROM |
| | |
| | | AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId} |
| | | </if> |
| | | GROUP BY |
| | | TIME |
| | | time |
| | | ORDER BY |
| | | TIME |
| | | time |
| | | </select> |
| | | <select id="parkingDataByDate" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT( create_time, '%Y-%m-%d' ) AS TIME, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d' ) AS time, |
| | | count( 1 ) AS orders, |
| | | SUM( timeout_amount ) AS timeoutAmount |
| | | FROM |
| | |
| | | AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId} |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 2"> |
| | | AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | AND WEEKOFYEAR( create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 3"> |
| | | AND MONTH( co.create_time ) = MONTH(CURDATE()) |
| | | AND MONTH( create_time ) = MONTH(CURDATE()) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 4"> |
| | | AND YEAR( co.create_time ) = YEAR(CURDATE() ) |
| | | AND YEAR( create_time ) = YEAR(CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 5"> |
| | | <if test="parkingRecordQueryDto.startTime != null"> |
| | | AND co.create_time >= #{parkingRecordQueryDto.startTime} |
| | | AND create_time >= #{parkingRecordQueryDto.startTime} |
| | | </if> |
| | | <if test="parkingRecordQueryDto.endTime != null"> |
| | | AND co.create_time <= #{parkingRecordQueryDto.endTime} |
| | | AND create_time <= #{parkingRecordQueryDto.endTime} |
| | | </if> |
| | | </if> |
| | | </where> |
| | | GROUP BY |
| | | TIME |
| | | time |
| | | ORDER BY |
| | | TIME |
| | | time |
| | | |
| | | |
| | | </select> |
| | |
| | | AND DATE( create_time ) = CURDATE() |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 2"> |
| | | AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | AND WEEKOFYEAR( create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 3"> |
| | | AND MONTH( co.create_time ) = MONTH(CURDATE()) |
| | | AND MONTH( create_time ) = MONTH(CURDATE()) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 4"> |
| | | AND YEAR( co.create_time ) = YEAR(CURDATE() ) |
| | | AND YEAR( create_time ) = YEAR(CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 5"> |
| | | <if test="parkingRecordQueryDto.startTime != null"> |
| | | AND co.create_time >= #{parkingRecordQueryDto.startTime} |
| | | AND create_time >= #{parkingRecordQueryDto.startTime} |
| | | </if> |
| | | <if test="parkingRecordQueryDto.endTime != null"> |
| | | AND co.create_time <= #{parkingRecordQueryDto.endTime} |
| | | AND create_time <= #{parkingRecordQueryDto.endTime} |
| | | </if> |
| | | </if> |
| | | </where> |
| | |
| | | AND DATE( create_time ) = CURDATE() |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 2"> |
| | | AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | AND WEEKOFYEAR( create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 3"> |
| | | AND MONTH( co.create_time ) = MONTH(CURDATE()) |
| | | AND MONTH( create_time ) = MONTH(CURDATE()) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 4"> |
| | | AND YEAR( co.create_time ) = YEAR(CURDATE() ) |
| | | AND YEAR( create_time ) = YEAR(CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 5"> |
| | | <if test="parkingRecordQueryDto.startTime != null"> |
| | | AND co.create_time >= #{parkingRecordQueryDto.startTime} |
| | | AND create_time >= #{parkingRecordQueryDto.startTime} |
| | | </if> |
| | | <if test="parkingRecordQueryDto.endTime != null"> |
| | | AND co.create_time <= #{parkingRecordQueryDto.endTime} |
| | | AND create_time <= #{parkingRecordQueryDto.endTime} |
| | | </if> |
| | | </if> |
| | | </where> |
| | |
| | | AND DATE( create_time ) = CURDATE() |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 2"> |
| | | AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | AND WEEKOFYEAR( create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 3"> |
| | | AND MONTH( co.create_time ) = MONTH(CURDATE()) |
| | | AND MONTH( create_time ) = MONTH(CURDATE()) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 4"> |
| | | AND YEAR( co.create_time ) = YEAR(CURDATE() ) |
| | | AND YEAR( create_time ) = YEAR(CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 5"> |
| | | <if test="parkingRecordQueryDto.startTime != null"> |
| | | AND co.create_time >= #{parkingRecordQueryDto.startTime} |
| | | AND create_time >= #{parkingRecordQueryDto.startTime} |
| | | </if> |
| | | <if test="parkingRecordQueryDto.endTime != null"> |
| | | AND co.create_time <= #{parkingRecordQueryDto.endTime} |
| | | AND create_time <= #{parkingRecordQueryDto.endTime} |
| | | </if> |
| | | </if> |
| | | </where> |
| | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @GetMapping(value = "/work/shop") |
| | | @PostMapping(value = "/work/shop") |
| | | @ApiOperation(value = "购物收入", tags = {"后台-工作台"}) |
| | | public R workShop(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) { |
| | | //count近6个月的数据 |
| | |
| | | //上方折现 |
| | | if (statisticsQueryDto.getDayType()==1){ |
| | | List<Map<String,Object>> map = chargingOrderService.usersDay(); |
| | | tCharingUserMapVO.setMap(map); |
| | | |
| | | List<Map<String, Object>> charMap = new ArrayList<>(); |
| | | // 生成从 "00:00" 到 "23:00" 的时间数据 |
| | | for (int hour = 0; hour < 24; hour++) { |
| | | String time = String.format("%02d:00", hour); |
| | | Map<String, Object> mapWithTimeValue = findMapWithTimeValue(map, time); |
| | | if (mapWithTimeValue!=null){ |
| | | charMap.add(mapWithTimeValue); |
| | | }else { |
| | | Map<String, Object> timeMap = new HashMap<>(); |
| | | timeMap.put("time", time); // 初始化值为 null |
| | | timeMap.put("counts", 0); |
| | | |
| | | charMap.add(timeMap); |
| | | } |
| | | } |
| | | |
| | | List<Map<String,Object>> map1 = chargingOrderService.usersDay1(); |
| | | |
| | | List<Map<String, Object>> charMap1 = new ArrayList<>(); |
| | | // 生成从 "00:00" 到 "23:00" 的时间数据 |
| | | for (int hour = 0; hour < 24; hour++) { |
| | | String time = String.format("%02d:00", hour); |
| | | Map<String, Object> mapWithTimeValue = findMapWithTimeValue(map1, time); |
| | | if (mapWithTimeValue!=null){ |
| | | charMap1.add(mapWithTimeValue); |
| | | }else { |
| | | Map<String, Object> timeMap = new HashMap<>(); |
| | | timeMap.put("time", time); // 初始化值为 null |
| | | timeMap.put("counts", 0); |
| | | |
| | | charMap1.add(timeMap); |
| | | } |
| | | } |
| | | |
| | | |
| | | tCharingUserMapVO.setMap(charMap); |
| | | tCharingUserMapVO.setMap1(charMap1); |
| | | }else { |
| | | List<Map<String,Object>> map = chargingOrderService.usersByQuery(statisticsQueryDto); |
| | | |
| | | |
| | | //按日 |
| | | // 解析 startTime 和 endTime 为 LocalDate |
| | | LocalDate startDate = statisticsQueryDto.getStartTime(); |
| | | LocalDate endDate = statisticsQueryDto.getEndTime(); |
| | | |
| | | List<Map<String, Object>> dateRangeStatistics = new ArrayList<>(); |
| | | |
| | | // 遍历日期范围 |
| | | while (!startDate.isAfter(endDate)) { |
| | | String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | Map<String, Object> dailyStats = findMapWithDateValue(map, formattedDate); |
| | | |
| | | if (dailyStats != null) { |
| | | dateRangeStatistics.add(dailyStats); |
| | | } else { |
| | | Map<String, Object> dateMap = new HashMap<>(); |
| | | dateMap.put("time", formattedDate); |
| | | dateMap.put("counts", 0); |
| | | dateRangeStatistics.add(dateMap); |
| | | } |
| | | |
| | | // 移动到下一天 |
| | | startDate = startDate.plusDays(1); |
| | | } |
| | | |
| | | tCharingUserMapVO.setMap(map); |
| | | } |
| | | |
| | |
| | | List<Map<String,Object>> equipmentMap1 = chargingOrderService.equipmentUserType1(siteIds,statisticsQueryDto); |
| | | //交流可用率 |
| | | List<Map<String,Object>> equipmentMap2= chargingOrderService.equipmentUserType2(siteIds,statisticsQueryDto); |
| | | |
| | | //取出直流可用率和交流可用率的percent的平均值保留两位小数 |
| | | |
| | | double average1 = calculateAveragePercent(equipmentMap1, equipmentMap2); |
| | | System.out.printf("The average percent is: %.2f\n", average1); |
| | | |
| | | |
| | | //直流故障率 |
| | | List<Map<String,Object>> equipmentMapbroke1 = chargingOrderService.equipmentMapbroke1(siteIds,statisticsQueryDto); |
| | | //交流故障率 |
| | | List<Map<String,Object>> equipmentMapbroke2 = chargingOrderService.equipmentMapbroke2(siteIds,statisticsQueryDto); |
| | | |
| | | |
| | | double average2 = calculateAveragePercent(equipmentMapbroke1, equipmentMapbroke2); |
| | | System.out.printf("The average percent is: %.2f\n", average2); |
| | | //直流离网率 |
| | | List<Map<String,Object>> equipmentMapOut1 = chargingOrderService.equipmentMapOut1(siteIds,statisticsQueryDto); |
| | | //交流离网率 |
| | | List<Map<String,Object>> equipmentMapOut2 = chargingOrderService.equipmentMapOut2(siteIds,statisticsQueryDto); |
| | | |
| | | double average3 = calculateAveragePercent(equipmentMapOut1, equipmentMapOut2); |
| | | System.out.printf("The average percent is: %.2f\n", average3); |
| | | |
| | | //需求电流满足率 |
| | | List<Map<String,Object>> needElec = chargingOrderService.needElec(siteIds,statisticsQueryDto); |
| | | List<Map<String,Object>> needElec1 = chargingOrderService.needElec(siteIds,statisticsQueryDto); |
| | | List<Map<String,Object>> needElec2 = chargingOrderService.needElec1(siteIds,statisticsQueryDto); |
| | | |
| | | double average4 = calculateAveragePercent(needElec1, needElec2); |
| | | System.out.printf("The average percent is: %.2f\n", average4); |
| | | |
| | | |
| | | |
| | | TCharingUserEquimentVO tCharingUserEquimentVO = new TCharingUserEquimentVO(); |
| | | tCharingUserEquimentVO.setEquipmentMap1(equipmentMap1); |
| | |
| | | tCharingUserEquimentVO.setEquipmentMapbroke2(equipmentMapbroke2); |
| | | tCharingUserEquimentVO.setEquipmentMapOut1(equipmentMapOut1); |
| | | tCharingUserEquimentVO.setEquipmentMapOut2(equipmentMapOut2); |
| | | tCharingUserEquimentVO.setNeedElec(needElec); |
| | | tCharingUserEquimentVO.setNeedElec1(needElec1); |
| | | tCharingUserEquimentVO.setNeedElec2(needElec2); |
| | | tCharingUserEquimentVO.setAverage1(average1); |
| | | tCharingUserEquimentVO.setAverage2(average2); |
| | | tCharingUserEquimentVO.setAverage3(average3); |
| | | tCharingUserEquimentVO.setAverage4(average4); |
| | | return R.ok(tCharingUserEquimentVO); |
| | | } |
| | | |
| | | |
| | | private static double calculateAveragePercent(List<Map<String, Object>> mapList1, List<Map<String, Object>> mapList2) { |
| | | int totalElements = mapList1.size() + mapList2.size(); |
| | | double sum = 0.0; |
| | | |
| | | // 累加两个列表中所有元素的 "percent" 值 |
| | | for (Map<String, Object> map : mapList1) { |
| | | if (map.containsKey("percent")) { |
| | | sum += Double.parseDouble((String) map.get("percent")); |
| | | } |
| | | } |
| | | for (Map<String, Object> map : mapList2) { |
| | | if (map.containsKey("percent")) { |
| | | sum += Double.parseDouble((String) map.get("percent")); |
| | | } |
| | | } |
| | | |
| | | // 防止除以零错误 |
| | | if (totalElements == 0) { |
| | | return 0.0; |
| | | } |
| | | |
| | | // 计算平均值 |
| | | return sum / totalElements; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping(value = "/work/charge") |
| | | @ApiOperation(value = "上方充电数据统计", tags = {"管理后台-工作台"}) |
| | |
| | | tExchangeOrder.setPurchaseQuantity(1); |
| | | tExchangeOrder.setAppUserAddressId(exchangeDto.getAddressId()==null?null:Long.valueOf(exchangeDto.getAddressId())); |
| | | tExchangeOrder.setPoints(exchangeDto.getPoint()); |
| | | tExchangeOrder.setRemark(""); |
| | | tExchangeOrder.setRemark(exchangeDto.getRemark()); |
| | | if (exchangeDto.getGoodType()==1){ |
| | | tExchangeOrder.setStatus(1); |
| | | }else { |
| | |
| | | @ApiOperation(value = "获取兑换订单详情", tags = {"小程序-兑换记录"}) |
| | | public AjaxResult<ExchangeOrderGoodsInfo> getGoodsExchangeOrder(@PathVariable String id){ |
| | | ExchangeOrderGoodsInfo goodsExchangeOrder = exchangeOrderService.getGoodsExchangeOrder(id); |
| | | |
| | | return AjaxResult.success(goodsExchangeOrder); |
| | | } |
| | | |
| | |
| | | shoppingOrder.setOrderType(exchangeDto.getGoodType()); |
| | | if (exchangeDto.getGoodType() == 1) { |
| | | shoppingOrder.setGoodsId(exchangeDto.getGoodId()); |
| | | shoppingOrder.setStatus(1); |
| | | |
| | | } else { |
| | | shoppingOrder.setCouponId(exchangeDto.getGoodId()); |
| | | shoppingOrder.setStatus(3); |
| | | |
| | | } |
| | | shoppingOrder.setPurchaseQuantity(exchangeDto.getNum()); |
| | | shoppingOrder.setAppUserAddressId(exchangeDto.getAddressId()); |
| | |
| | | shoppingOrder.setPaymentStatus(1); |
| | | shoppingOrder.setPaymentType(exchangeDto.getPayMethod()); |
| | | shoppingOrder.setRemark(exchangeDto.getRemark()); |
| | | shoppingOrder.setStatus(1); |
| | | shoppingOrder.setPhone(exchangeDto.getPhone()); |
| | | shoppingOrder.setCreateTime(LocalDateTime.now()); |
| | | shoppingOrder.setDelFlag(false); |
| | |
| | | package com.ruoyi.order.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | |
| | | @ApiModelProperty("支付金额") |
| | | private BigDecimal payAmount; |
| | | @ApiModelProperty("支付时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime payTime; |
| | | @ApiModelProperty("退款金额") |
| | | private BigDecimal refundAmount; |
| | |
| | | |
| | | Map<String, Object> queryPowerLevel(@Param("siteIds") List<Integer> siteIds,@Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto); |
| | | |
| | | List<Map<String, Object>> queryOrderCountAndMoneyBySiteIdDate(List<Integer> siteIds); |
| | | List<Map<String, Object>> queryOrderCountAndMoneyBySiteIdDate(@Param("siteIds")List<Integer> siteIds); |
| | | |
| | | List<Map<String, Object>> usersDay(); |
| | | List<Map<String, Object>> usersDay1(); |
| | | |
| | | List<Map<String, Object>> usersByQuery(ChargingStatisticsQueryDto statisticsQueryDto); |
| | | List<Map<String, Object>> usersByQuery(@Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto); |
| | | |
| | | List<Map<String, Object>> getUserTagCount(); |
| | | |
| | | List<Map<String, Object>> getVipCount(); |
| | | |
| | | List<Map<String, Object>> unitConsumption(ChargingStatisticsQueryDto statisticsQueryDto); |
| | | List<Map<String, Object>> unitConsumption(@Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto); |
| | | |
| | | List<Map<String, Object>> carUserMethod(); |
| | | |
| | |
| | | |
| | | Map<String, Object> countLocalCar(); |
| | | |
| | | Long getAver(List<Integer> siteIds); |
| | | Long getAver(@Param("siteIds") List<Integer> siteIds); |
| | | |
| | | List<Map<String, Object>> getLevelEvaluate(List<Integer> siteIds); |
| | | List<Map<String, Object>> getLevelEvaluate(@Param("siteIds")List<Integer> siteIds); |
| | | |
| | | List<Map<String, Object>> countBySource(List<Integer> siteIds); |
| | | List<Map<String, Object>> countBySource(@Param("siteIds")List<Integer> siteIds); |
| | | |
| | | List<Map<String, Object>> equipmentUserType1(@Param("siteIds") List<Integer> siteIds, @Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto); |
| | | |
| | |
| | | List<Map<String, Object>> getchargingCapacity(@Param("siteIds")List<Integer> siteIds,@Param("statisticsQueryDto") ChargingDetailQueryDto statisticsQueryDto); |
| | | |
| | | List<Map<String, Object>> countAllUserData(); |
| | | |
| | | List<Map<String, Object>> needElec1(@Param("siteIds")List<Integer> siteIds,@Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto); |
| | | } |
| | |
| | | */ |
| | | List<TOrderEvaluateVO> getOrderEvaluateBySiteId(@Param("siteId")Integer siteId); |
| | | |
| | | List<Map<String, Object>> goodTop(List<Integer> siteIds); |
| | | List<Map<String, Object>> goodTop(@Param("siteIds")List<Integer> siteIds); |
| | | |
| | | List<Map<String, Object>> badTop(List<Integer> siteIds); |
| | | List<Map<String, Object>> badTop(@Param("siteIds")List<Integer> siteIds); |
| | | } |
| | |
| | | List<Map<String, Object>> queryOrderCountAndMoneyBySiteIdDate(List<Integer> siteIds); |
| | | |
| | | List<Map<String, Object>> usersDay(); |
| | | List<Map<String, Object>> usersDay1(); |
| | | |
| | | List<Map<String, Object>> usersByQuery(ChargingStatisticsQueryDto statisticsQueryDto); |
| | | |
| | |
| | | List<Map<String, Object>> getchargingCapacity(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto); |
| | | |
| | | List<Map<String, Object>> countAllUserData(); |
| | | |
| | | List<Map<String, Object>> needElec1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto); |
| | | } |
| | |
| | | package com.ruoyi.order.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.ruoyi.order.api.dto.SettlementConfirmAdd; |
| | | import com.ruoyi.order.api.feignClient.AccountingStrategyDetailOrderClient; |
| | | import com.ruoyi.order.api.feignClient.AccountingStrategyOrderClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient; |
| | | import com.ruoyi.order.api.model.*; |
| | | import com.ruoyi.order.api.query.ChargingOrderQuery; |
| | | import com.ruoyi.order.api.query.SettlementListQuery; |
| | |
| | | import com.ruoyi.payment.api.model.WxPaymentRefundModel; |
| | | import com.ruoyi.payment.api.vo.*; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> usersDay1() { |
| | | return this.baseMapper.usersDay1(); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> usersByQuery(ChargingStatisticsQueryDto statisticsQueryDto) { |
| | | return this.baseMapper.usersByQuery(statisticsQueryDto); |
| | | } |
| | |
| | | |
| | | @Resource |
| | | private TShoppingOrderService shoppingOrderService; |
| | | @Resource |
| | | private TShoppingOrderRefundService shoppingOrderRefundService; |
| | | @Override |
| | | public R payRefund(PayOrderRefundDto payOrderQueryDto) { |
| | | if (payOrderQueryDto.getType()==1){ |
| | |
| | | model.setAmount(amount); |
| | | R<String> orderR = wxPaymentClient.refundOrderR(model); |
| | | if(200 == orderR.getCode()){ |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | this.baseMapper.updateById(tChargingOrder); |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | } |
| | | } |
| | |
| | | RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | if(null != resp){ |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-DDTHH:mm:ss+TIMEZONE"); |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | this.baseMapper.updateById(tChargingOrder); |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | |
| | | } |
| | |
| | | } |
| | | if (payOrderQueryDto.getType()==2){ |
| | | TShoppingOrder tChargingOrder = shoppingOrderService.getById(payOrderQueryDto.getOrderId()); |
| | | TChargingOrderRefund chargingOrderRefund = new TChargingOrderRefund(); |
| | | chargingOrderRefund.setChargingOrderId(tChargingOrder.getId()); |
| | | TShoppingOrderRefund chargingOrderRefund = new TShoppingOrderRefund(); |
| | | chargingOrderRefund.setShoppingOrderId(tChargingOrder.getId()); |
| | | chargingOrderRefund.setRefundAmount(payOrderQueryDto.getRefundAmount()); |
| | | chargingOrderRefund.setRefundStatus(1); |
| | | chargingOrderRefund.setPayType(tChargingOrder.getPaymentType()); |
| | |
| | | model.setAmount(amount); |
| | | R<String> orderR = wxPaymentClient.refundOrderR(model); |
| | | if(200 == orderR.getCode()){ |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | shoppingOrderService.updateById(tChargingOrder); |
| | | shoppingOrderRefundService.save(chargingOrderRefund); |
| | | } |
| | | } |
| | | |
| | |
| | | RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | if(null != resp){ |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-DDTHH:mm:ss+TIMEZONE"); |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | shoppingOrderService.updateById(tChargingOrder); |
| | | |
| | | shoppingOrderRefundService.save(chargingOrderRefund); |
| | | |
| | | } |
| | | } |
| | |
| | | return this.baseMapper.countAllUserData(); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> needElec1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) { |
| | | return this.baseMapper.needElec1(siteIds,statisticsQueryDto); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")); |
| | | // String format1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")); |
| | |
| | | AND o.code LIKE CONCAT('%',#{data.code},'%') |
| | | </if> |
| | | <if test="data.phone != null and data.phone != ''"> |
| | | AND o.phone LIKE CONCAT('%',#{data.phone},'%') |
| | | AND i.phone LIKE CONCAT('%',#{data.phone},'%') |
| | | </if> |
| | | <if test="data.type != null"> |
| | | AND o.type = #{data.type} |
| | |
| | | <if test="data.isRefund == 1"> |
| | | AND o.refund_status is not null |
| | | </if> |
| | | <if test="data.isRefund == 1"> |
| | | <if test="data.isRefund == 2"> |
| | | AND o.refund_status is null |
| | | </if> |
| | | |
| | |
| | | |
| | | </select> |
| | | <select id="usersDay" resultType="java.util.Map"> |
| | | |
| | | SELECT |
| | | 'today' AS data_type, |
| | | '1' as type, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS TIME, |
| | | count(DISTINCT app_user_id) AS counts |
| | | FROM |
| | | t_charging_order |
| | | WHERE |
| | | del_flag = 0 |
| | | AND recharge_payment_status = 2 |
| | | AND ISNULL( refund_status ) |
| | | AND DATE ( create_time ) = CURDATE() |
| | | GROUP BY |
| | | TIME |
| | | UNION all |
| | | SELECT |
| | | 'today' AS data_type, |
| | | '2' as type, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS TIME, |
| | | |
| | | DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS time, |
| | | count(1) AS counts |
| | | FROM |
| | | charging_pile_account.t_app_user |
| | |
| | | del_flag = 0 |
| | | AND DATE ( create_time ) = CURDATE() |
| | | GROUP BY |
| | | TIME |
| | | time |
| | | </select> |
| | | <select id="usersByQuery" resultType="java.util.Map"> |
| | | |
| | | |
| | | <select id="usersDay1" resultType="java.util.Map"> |
| | | SELECT |
| | | 'today' AS data_type, |
| | | '1' as type, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d' ) AS TIME, |
| | | count(DISTINCT app_user_id) AS counts |
| | | DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS time, |
| | | count(DISTINCT app_user_id) AS counts |
| | | FROM |
| | | t_charging_order |
| | | WHERE |
| | | del_flag = 0 |
| | | AND recharge_payment_status = 2 |
| | | AND ISNULL( refund_status ) |
| | | <if test="statisticsQueryDto.dayType =1 "> |
| | | AND DATE(create_time) = CURDATE() |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType =2 "> |
| | | AND WEEKOFYEAR(create_time) = WEEKOFYEAR(CURDATE()) |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType =3 "> |
| | | AND MONTH(create_time) = MONTH(CURDATE()) |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType =4"> |
| | | AND YEAR(create_time) = YEAR(CURDATE()) |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType =5"> |
| | | <if test="statisticsQueryDto.startTime != null"> |
| | | AND create_time >= #{statisticsQueryDto.startTime} |
| | | </if> |
| | | <if test="statisticsQueryDto.endTime != null"> |
| | | AND create_time <= #{statisticsQueryDto.endTime} |
| | | </if> |
| | | </if> |
| | | AND DATE ( create_time ) = CURDATE() |
| | | GROUP BY |
| | | TIME |
| | | UNION all |
| | | time |
| | | </select> |
| | | <select id="usersByQuery" resultType="java.util.Map"> |
| | | |
| | | SELECT |
| | | 'today' AS data_type, |
| | | '2' as type, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d' ) AS TIME, |
| | | |
| | | DATE_FORMAT( create_time, '%Y-%m-%d' ) AS time, |
| | | count(1) AS counts |
| | | FROM |
| | | charging_pile_account.t_app_user |
| | |
| | | </if> |
| | | </if> |
| | | GROUP BY |
| | | TIME |
| | | time |
| | | |
| | | |
| | | </select> |
| | | <select id="getUserTagCount" resultType="java.util.Map"> |
| | | SELECT user_tag_id,COUNT(1) as count from ( |
| | | SELECT |
| | | tt.`name`, |
| | | COUNT( 1 ) AS count |
| | | FROM |
| | | ( |
| | | SELECT |
| | | a.app_user_id, |
| | | a.user_tag_id, |
| | | a.create_time |
| | | FROM |
| | | charging_pile_account.t_app_user_tag a |
| | | JOIN ( |
| | | SELECT |
| | | app_user_id, |
| | | MAX(create_time) AS max_create_time |
| | | FROM |
| | | charging_pile_account.t_app_user_tag |
| | | GROUP BY |
| | | app_user_id |
| | | ) b ON a.app_user_id = b.app_user_id AND a.create_time = b.max_create_time |
| | | JOIN ( SELECT app_user_id, MAX( create_time ) AS max_create_time FROM charging_pile_account.t_app_user_tag GROUP BY app_user_id ) b ON a.app_user_id = b.app_user_id |
| | | AND a.create_time = b.max_create_time |
| | | ) o |
| | | GROUP BY o.user_tag_id |
| | | LEFT JOIN `charging_pile_other`.`t_user_tag` tt on o.user_tag_id = tt.id |
| | | GROUP BY |
| | | tt.name |
| | | </select> |
| | | <select id="getVipCount" resultType="java.util.Map"> |
| | | SELECT vip_id,count(1) as Counts |
| | | FROM charging_pile_account.t_app_user |
| | | WHERE del_flag = 0 |
| | | GROUP BY vip_id |
| | | SELECT |
| | | tv.`name`, |
| | | count(1) AS Counts |
| | | FROM |
| | | charging_pile_account.t_app_user ta |
| | | LEFT JOIN `charging_pile_other`.`t_vip` tv on ta.vip_id = tv.id |
| | | WHERE |
| | | ta.del_flag = 0 |
| | | GROUP BY |
| | | tv.`name` |
| | | </select> |
| | | <select id="unitConsumption" resultType="java.util.Map"> |
| | | SELECT |
| | | tc.`name`, |
| | | au.company_id as companyId, |
| | | SUM( co.charging_capacity ) as chargingCapacity |
| | | FROM |
| | | charging_pile_order.t_charging_order co |
| | | LEFT JOIN charging_pile_account.t_app_user au ON co.app_user_id = au.id |
| | | LEFT JOIN `charging_pile_other`.`t_company` tc on au.company_id = tc.id |
| | | |
| | | <where> |
| | | co.del_flag = 0 |
| | | <if test="statisticsQueryDto.dayType == 1"> |
| | |
| | | </if> |
| | | </where> |
| | | GROUP BY |
| | | au.company_id |
| | | tc.`name`, au.company_id |
| | | </select> |
| | | <select id="carUserMethod" resultType="java.util.Map"> |
| | | SELECT |
| | |
| | | `t_order_evaluate` te |
| | | LEFT JOIN t_charging_order co on te.order_id = co.id |
| | | WHERE |
| | | 1 = 1 |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | | AND co.site_id IN |
| | | <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> |
| | | #{siteId} |
| | | </foreach> |
| | | </if> |
| | | te.del_flag = 0 |
| | | AND te.del_flag = 0 |
| | | |
| | | </select> |
| | | <select id="getLevelEvaluate" resultType="java.util.Map"> |
| | |
| | | source_name as source |
| | | from t_charging_order |
| | | where 1=1 |
| | | del_flag = 0 |
| | | AND del_flag = 0 |
| | | AND recharge_payment_status = 2 |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | | and site_id IN |
| | |
| | | </if> |
| | | |
| | | |
| | | ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as siteName |
| | | ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as siteName |
| | | FROM |
| | | `charging_pile_order`.`t_charging_order` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id |
| | |
| | | </if> |
| | | |
| | | |
| | | ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as siteName |
| | | ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as siteName |
| | | FROM |
| | | `charging_pile_order`.`t_charging_order` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id |
| | |
| | | )) |
| | | </if> |
| | | |
| | | ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1 |
| | | ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as name1 |
| | | FROM |
| | | `charging_pile_service`.`t_fault_message` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id |
| | |
| | | )) |
| | | </if> |
| | | |
| | | ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1 |
| | | ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as name1 |
| | | FROM |
| | | `charging_pile_service`.`t_fault_message` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id |
| | |
| | | )) |
| | | </if> |
| | | |
| | | ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1 |
| | | ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as name1 |
| | | FROM |
| | | `charging_pile_service`.`t_fault_message` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id |
| | |
| | | )) |
| | | </if> |
| | | |
| | | ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1 |
| | | ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as name1 |
| | | FROM |
| | | `charging_pile_service`.`t_fault_message` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id |
| | |
| | | SELECT |
| | | FORMAT((SUM(co.current) / SUM(co.need_elec)), 2) AS percent, |
| | | co.charging_gun_id, |
| | | tc.name, |
| | | cp.name AS gun_name |
| | | tc.name as name, |
| | | cp.name AS siteName |
| | | FROM |
| | | `charging_pile_order`.`t_charging_order` co |
| | | 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> |
| | | cp.type = 1 |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | | and co.site_id IN |
| | | <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> |
| | |
| | | |
| | | |
| | | </select> |
| | | <select id="needElec1" resultType="java.util.Map"> |
| | | SELECT |
| | | FORMAT((SUM(co.current) / SUM(co.need_elec)), 2) AS percent, |
| | | co.charging_gun_id, |
| | | tc.name as name, |
| | | cp.name AS siteName |
| | | FROM |
| | | `charging_pile_order`.`t_charging_order` co |
| | | 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> |
| | | cp.type = 2 |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | | and co.site_id IN |
| | | <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> |
| | | #{siteId} |
| | | </foreach> |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType == 1"> |
| | | AND DATE( co.create_time ) = CURDATE() |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType == 2"> |
| | | AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType == 3"> |
| | | AND MONTH( co.create_time ) = MONTH(CURDATE()) |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType == 4"> |
| | | AND YEAR( co.create_time ) = YEAR(CURDATE() ) |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType == 5"> |
| | | <if test="statisticsQueryDto.startTime != null"> |
| | | AND co.create_time >= #{statisticsQueryDto.startTime} |
| | | </if> |
| | | <if test="statisticsQueryDto.endTime != null"> |
| | | AND co.create_time <= #{statisticsQueryDto.endTime} |
| | | </if> |
| | | </if> |
| | | </where> |
| | | GROUP BY |
| | | tc.name, |
| | | cp.name, |
| | | co.charging_gun_id; |
| | | </select> |
| | | </mapper> |
| | |
| | | order by a.create_time desc |
| | | </select> |
| | | <select id="goodTop" resultType="java.util.Map"> |
| | | SELECT count(1) as counts ,ot.evaluation_tag_id |
| | | from t_order_evaluate_tag ot |
| | | left join t_order_evaluate te on ot.order_evaluate_id = te.id |
| | | left join t_charging_order co on te.order_id = co.id |
| | | SELECT |
| | | count( 1 ) AS counts, |
| | | |
| | | tt.`name` |
| | | FROM |
| | | t_order_evaluate_tag ot |
| | | LEFT JOIN t_order_evaluate te ON ot.order_evaluate_id = te.id |
| | | LEFT JOIN t_charging_order co ON te.order_id = co.id |
| | | LEFT JOIN `charging_pile_other`.`t_evaluation_tag` tt on ot.evaluation_tag_id = tt.id |
| | | WHERE ot.evaluation_tag_id in ( |
| | | SELECT id from `charging_pile_other`.`t_evaluation_tag` WHERE type = 1 |
| | | ) <if test="null != siteIds"> |
| | |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY ot.evaluation_tag_id |
| | | ORDER BY counts desc |
| | | limit 5 |
| | | GROUP BY |
| | | tt.`name` |
| | | ORDER BY |
| | | counts DESC |
| | | LIMIT 5 |
| | | |
| | | |
| | | |
| | | </select> |
| | | <select id="badTop" resultType="java.util.Map"> |
| | | SELECT count(1) as counts ,ot.evaluation_tag_id |
| | | from t_order_evaluate_tag ot |
| | | left join t_order_evaluate te on ot.order_evaluate_id = te.id |
| | | left join t_charging_order co on te.order_id = co.id |
| | | SELECT |
| | | count( 1 ) AS counts, |
| | | |
| | | tt.`name` |
| | | FROM |
| | | t_order_evaluate_tag ot |
| | | LEFT JOIN t_order_evaluate te ON ot.order_evaluate_id = te.id |
| | | LEFT JOIN t_charging_order co ON te.order_id = co.id |
| | | LEFT JOIN `charging_pile_other`.`t_evaluation_tag` tt on ot.evaluation_tag_id = tt.id |
| | | WHERE ot.evaluation_tag_id in ( |
| | | SELECT id from `charging_pile_other`.`t_evaluation_tag` WHERE type = 3 |
| | | ) <if test="null != siteIds"> |
| | |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY ot.evaluation_tag_id |
| | | ORDER BY counts desc |
| | | limit 5 |
| | | GROUP BY |
| | | tt.`name` |
| | | ORDER BY |
| | | counts DESC |
| | | LIMIT 5 |
| | | </select> |
| | | </mapper> |
| | |
| | | payment_amount |
| | | FROM |
| | | t_shopping_order |
| | | <where> |
| | | |
| | | WHERE del_flag = 0 and payment_status = 2 and ISNULL(refund_status) and status!=4 |
| | | <if test="null != sixBefore"> |
| | | and DATE_FORMAT(create_time, '%Y-%m-%d') >= DATE_FORMAT(#{sixBefore}, '%Y-%m-%d') |
| | | and create_time >= #{sixBefore} |
| | | </if> |
| | | <if test="null != status"> |
| | | and status = #{status} |
| | | </if> |
| | | </where> |
| | | |
| | | |
| | | ) AS subquery |
| | | GROUP BY |
| | | DATE_FORMAT( subquery.create_time, '%m' ); |
| | | DATE_FORMAT( subquery.create_time, '%m' ) |
| | | |
| | | |
| | | </select> |
| | |
| | | </select> |
| | | <select id="sixBefore" resultType="com.ruoyi.order.dto.SixVipDto"> |
| | | SELECT |
| | | DATE_FORMAT(subquery.create_time, '%Y-%m') AS MONTH, |
| | | subquery.vip_id, |
| | | COUNT(1) AS orderNum, |
| | | SUM(subquery.payment_amount) AS paymentAmount |
| | | DATE_FORMAT(subquery.create_time, '%Y-%m') AS MONTH, |
| | | COUNT(1) AS orderNum, |
| | | SUM(subquery.payment_amount) AS paymentAmount, |
| | | tp.`name` |
| | | FROM ( |
| | | SELECT |
| | | vip_id, |
| | | create_time, |
| | | payment_amount |
| | | FROM |
| | | t_vip_order |
| | | SELECT |
| | | vip_id, |
| | | create_time, |
| | | payment_amount |
| | | FROM |
| | | t_vip_order |
| | | <where> |
| | | del_flag = 0 AND |
| | | payment_status = 2 AND |
| | | refund_amount IS NULL |
| | | <if test="sixBefore != null"> |
| | | AND create_time > #{sixBefore} |
| | | </if> |
| | | </where> |
| | | ) AS subquery |
| | | ) AS subquery |
| | | LEFT JOIN `charging_pile_other`.`t_vip` tp on subquery.vip_id = tp.id |
| | | GROUP BY |
| | | DATE_FORMAT(subquery.create_time, '%Y-%m'), |
| | | subquery.vip_id; |
| | | DATE_FORMAT(subquery.create_time, '%Y-%m'), |
| | | tp.`name`; |
| | | |
| | | |
| | | </select> |
| | |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.domain.BasePojo; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | |
| | | // Page<TEnterpriseUserApplication> page = enterpriseUserApplicationService.lambdaQuery().in(TEnterpriseUserApplication::getAppUserId, userIds).page(Page.of(enterpriseQuery.getPageCurr(), enterpriseQuery.getPageSize())); |
| | | // return R.ok(page); |
| | | // }else { |
| | | Page<TEnterpriseUserApplication> page = enterpriseUserApplicationService.lambdaQuery().eq(enterpriseQuery.getPhone()!=null&&enterpriseQuery.getPhone()!="",TEnterpriseUserApplication::getPhone,enterpriseQuery.getPhone()).page(Page.of(enterpriseQuery.getPageCurr(), enterpriseQuery.getPageSize())); |
| | | Page<TEnterpriseUserApplication> page = enterpriseUserApplicationService.lambdaQuery().eq(enterpriseQuery.getPhone()!=null&&enterpriseQuery.getPhone()!="",TEnterpriseUserApplication::getPhone,enterpriseQuery.getPhone()).orderByDesc(BasePojo::getCreateTime).page(Page.of(enterpriseQuery.getPageCurr(), enterpriseQuery.getPageSize())); |
| | | return R.ok(page); |
| | | // } |
| | | } |
| | |
| | | |
| | | @GetMapping("/getInfoByType") |
| | | @ApiOperation(tags = {"小程序-兑换商城"},value = "商品查看详情") |
| | | public AjaxResult getInfoByType(Integer goodType,Integer id) { |
| | | public R getInfoByType(Integer goodType,Integer id) { |
| | | if (goodType==1){ |
| | | TGoods byId = goodsService.getById(id); |
| | | return AjaxResult.ok(byId);} |
| | | if (byId==null||byId.getStatus()==2){ |
| | | return R.fail(2,"内容不存在"); |
| | | } |
| | | return R.ok(byId);} |
| | | else { |
| | | TCoupon byId = couponService.getById(id); |
| | | return AjaxResult.ok(byId); |
| | | if (byId==null||byId.getStatus()==2){ |
| | | return R.fail(2,"内容不存在"); |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | | } |
| | | |
| | |
| | | }else { |
| | | //减少库存 |
| | | good.setInventory(good.getInventory()-exchangeDto.getNum()); |
| | | goodsService.updateById(good); |
| | | } |
| | | if (user.getPoints()<good.getRedeemPoints()){ |
| | | return AjaxResult.error("当前用户积分不足"); |
| | |
| | | if (coupon.getInventoryQuantity() != -1 && count >= coupon.getInventoryQuantity()) { |
| | | return AjaxResult.error("当前用户已到达兑换"+coupon+"次"); |
| | | }else { |
| | | coupon.setInventoryQuantity(coupon.getInventoryQuantity()-exchangeDto.getNum()); |
| | | coupon.setInventoryQuantity(coupon.getInventoryQuantity()-1); |
| | | couponService.updateById(coupon); |
| | | } |
| | | |
| | | |
| | |
| | | PointChangeDto pointChangeDto = new PointChangeDto(); |
| | | pointChangeDto.setUserId(userId); |
| | | pointChangeDto.setPoints(point); |
| | | pointChangeDto.setRemark(longR.getData().toString()); |
| | | pointChangeDto.setRemark(String.valueOf(longR.getData().getId())); |
| | | pointChangeDto.setType(6); |
| | | pointChangeDto.setCode(longR.getData().getCode()); |
| | | appUserClient.changeDown(pointChangeDto); |
| | | return AjaxResult.success(); |
| | | return AjaxResult.success(longR.getData().getId()); |
| | | |
| | | |
| | | } |
| | |
| | | BigDecimal vipDiscount = new BigDecimal(0); |
| | | if (exchangeDto.getGoodType()==1){ |
| | | TGoods good = goodsService.getById(exchangeDto.getGoodId()); |
| | | if (good.getStatus()==2){ |
| | | return R.fail("当前商品已下架"); |
| | | } |
| | | BigDecimal originalPrice = good.getPreferentialPrice(); |
| | | exchangeDto.setTitle("【商品购买】"+good.getName()); |
| | | if (isVip){ |
| | |
| | | }else { |
| | | |
| | | TCoupon coupon = couponService.getById(exchangeDto.getGoodId()); |
| | | if (coupon.getStatus()==2){ |
| | | return R.fail("当前商品已下架"); |
| | | } |
| | | exchangeDto.setTitle("【优惠卷购买】"+coupon.getName()); |
| | | BigDecimal originalPrice = coupon.getPaymentAmount(); |
| | | if (isVip){ |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.account.api.dto.SendCouponDto; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @ApiOperation(value = "当前生效会员信息", tags = {"小程序-个人中心"}) |
| | | @GetMapping("/recent/vipInfo") |
| | | public R<List<VipInfoDto>> recentVipInfo() { |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | TAppUser data = appUserClient.getUserById(userId).getData(); |
| | | if (data.getVipEndTime()!=null&&data.getVipEndTime().isAfter(LocalDateTime.now())) { |
| | | |
| | | List<VipInfoDto> vipInfoDtos = new ArrayList<>(); |
| | | List<TVip> vips = vipService.lambdaQuery().eq(TVip::getId, data.getVipId()).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()); |
| | | vipInfoDto.setId(vip.getId()); |
| | | List<SendCouponDto> javaList = JSON.parseArray(vip.getCoupon()).toJavaList(SendCouponDto.class); |
| | | List<VipCouponDto> vipCouponDtos = new ArrayList<>(); |
| | | if (!javaList.isEmpty()) { |
| | | for (SendCouponDto sendCouponDto : javaList) { |
| | | VipCouponDto vipCouponDto = new VipCouponDto(); |
| | | TCoupon byId = couponService.getById(sendCouponDto.getId()); |
| | | vipCouponDto.setNum(sendCouponDto.getNumber()); |
| | | vipCouponDto.setTCoupon(byId); |
| | | vipCouponDtos.add(vipCouponDto); |
| | | } |
| | | } |
| | | |
| | | vipInfoDto.setVipCouponDtos(vipCouponDtos); |
| | | |
| | | //计算总折扣 |
| | | BigDecimal total = BigDecimal.ZERO; |
| | | total = total.add(vip.getMaximumDeduction().multiply(BigDecimal.valueOf(vip.getDiscountTimes()))); |
| | | for (VipCouponDto vipCouponDto : vipCouponDtos) { |
| | | TCoupon tCoupon = vipCouponDto.getTCoupon(); |
| | | if (tCoupon.getPreferentialMode() == 2) { |
| | | total.add(tCoupon.getMaximumDiscountAmount()); |
| | | } else { |
| | | total.add(tCoupon.getDiscountAmount()); |
| | | } |
| | | } |
| | | vipInfoDto.setTotalDiscount(total); |
| | | vipInfoDto.setTimeAmount(vip.getMaximumDeduction().multiply(BigDecimal.valueOf(vip.getDiscountTimes()))); |
| | | vipInfoDtos.add(vipInfoDto); |
| | | } |
| | | return R.ok(vipInfoDtos); |
| | | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "购买会员", tags = {"小程序-个人中心"}) |
| | |
| | | ) { |
| | | |
| | | TVip byId = vipService.getById(vipId); |
| | | if (byId==null){ |
| | | return R.ok("当前会员不存在,请刷新后重试。"); |
| | | } |
| | | BigDecimal payMoney = BigDecimal.ZERO; |
| | | BigDecimal discountMoney = BigDecimal.ZERO; |
| | | BigDecimal discount = BigDecimal.ZERO; |