| | |
| | | */ |
| | | public class TestHex { |
| | | |
| | | @Test |
| | | public void testHex() throws Exception { |
| | | try (BufferedReader reader = reader("target/test-classes/JT808.txt")) { |
| | | reader.lines().filter(hex -> !hex.isEmpty()).forEach(hex -> BeanTest.selfCheck(hex)); |
| | | } |
| | | } |
| | | // @Test |
| | | // public void testHex() throws Exception { |
| | | // try (BufferedReader reader = reader("target/test-classes/JT808.txt")) { |
| | | // reader.lines().filter(hex -> !hex.isEmpty()).forEach(hex -> BeanTest.selfCheck(hex)); |
| | | // } |
| | | // } |
| | | |
| | | @Test |
| | | public void testSubpackage() throws Exception { |
| | | try (BufferedReader reader = reader("target/test-classes/JT1078.txt")) { |
| | | reader.lines().filter(hex -> !hex.isEmpty()).forEach(hex -> { |
| | | JTMessage message = BeanTest.coder.decode(Unpooled.wrappedBuffer(ByteBufUtil.decodeHexDump(hex))); |
| | | if (message != null) |
| | | System.out.println(BeanTest.gson.toJson(message)); |
| | | }); |
| | | } |
| | | } |
| | | // @Test |
| | | // public void testSubpackage() throws Exception { |
| | | // try (BufferedReader reader = reader("target/test-classes/JT1078.txt")) { |
| | | // reader.lines().filter(hex -> !hex.isEmpty()).forEach(hex -> { |
| | | // JTMessage message = BeanTest.coder.decode(Unpooled.wrappedBuffer(ByteBufUtil.decodeHexDump(hex))); |
| | | // if (message != null) |
| | | // System.out.println(BeanTest.gson.toJson(message)); |
| | | // }); |
| | | // } |
| | | // } |
| | | |
| | | public static BufferedReader reader(String path) throws FileNotFoundException { |
| | | return new BufferedReader(new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8)); |
| | |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("修改状态") |
| | | @PostMapping("/updStatus") |
| | | @RequiresPermissions("business:discount:update") |
| | | public ApiResponse updStatus(@RequestBody Discount discount) { |
| | | discountService.updStatus(discount); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation("分页查询") |
| | | @PostMapping("/page") |
| | | @RequiresPermissions("business:discount:query") |
| | |
| | | @ApiOperation("根据ID查询") |
| | | @GetMapping("/{id}") |
| | | @RequiresPermissions("business:discountmember:query") |
| | | public ApiResponse findById(@PathVariable String id) { |
| | | public ApiResponse<DiscountMember> findById(@PathVariable String id) { |
| | | return ApiResponse.success(discountMemberService.getDetail(id)); |
| | | } |
| | | |
| | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @author 江蹄蹄 |
| | |
| | | public ApiResponse<PageData<Goodsorder>> findPage (@RequestBody PageWrap<Goodsorder> pageWrap) { |
| | | return ApiResponse.success(goodsorderService.findPage(pageWrap)); |
| | | } |
| | | |
| | | @ApiOperation("线上交易汇总数据接口") |
| | | @PostMapping("/getTotalData") |
| | | @RequiresPermissions("business:goodsorder:query") |
| | |
| | | for (Goodsorder goodsorder:goodsorders) { |
| | | DiscountGoodsorderExportVO discountGoodsorderExportVO = new DiscountGoodsorderExportVO(); |
| | | BeanUtils.copyProperties(goodsorder,discountGoodsorderExportVO); |
| | | discountGoodsorderExportVO.setPayMoney(discountGoodsorderExportVO.getPayMoney()); |
| | | discountGoodsorderExportVO.setPayMoney(discountGoodsorderExportVO.getMoney()); |
| | | discountGoodsorderExportVO.setOrigin(Constants.ZERO); |
| | | discountGoodsorderExportVOList.add(discountGoodsorderExportVO); |
| | | } |
| | | ExcelExporter.build(DiscountGoodsorderExportVO.class).exportWithFirstAndEnd(discountGoodsorderExportVOList, "订单列表_"+System.currentTimeMillis(),"订单列表_"+ DateUtil.getPlusTime2(DateUtil.getCurrentDate()),null, response); |
| | |
| | | @PostMapping("/backGoodsorder") |
| | | @RequiresPermissions("business:goodsorder:query") |
| | | public ApiResponse backGoodsorder(@RequestBody GoodsorderBackDTO goodsorderBackDTO){ |
| | | if(Objects.nonNull(goodsorderBackDTO) && Objects.isNull(goodsorderBackDTO.getBackType())){ |
| | | goodsorderBackDTO.setBackType(Constants.ONE); |
| | | } |
| | | goodsorderService.backGoodsorder(goodsorderBackDTO); |
| | | return ApiResponse.success(null); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * 定时关闭 超时未支付的订单 |
| | | * 30 秒刷新一次 |
| | | * @throws Exception |
| | | */ |
| | | @Scheduled(cron = "0/15 * * * * ? ") |
| | | public void autCancel() throws Exception { |
| | | log.info("=====================开始定时刷新关闭超时未支付的订单======================="); |
| | | goodsorderService.autCancel(); |
| | | log.info("=====================结束定时刷新关闭超时未支付的订单======================="); |
| | | } |
| | | |
| | | /** |
| | | * 站点车辆满架率预警 |
| | | * @throws Exception |
| | | */ |
| | |
| | | public void updateById(SystemDictData systemDictData) { |
| | | SystemDictData queryDto = new SystemDictData(); |
| | | queryDto.setDictId(systemDictData.getDictId()); |
| | | queryDto.setCode(systemDictData.getCode()); |
| | | queryDto.setLabel(systemDictData.getLabel()); |
| | | queryDto.setDeleted(Constants.ZERO); |
| | | SystemDictData dictData = systemDictDataService.findOne(queryDto); |
| | | if (dictData != null && !dictData.getId().equals(systemDictData.getId())) { |
| | |
| | | |
| | | PLATFORM_REFUND(3,"平台退款", "平台退款"), |
| | | |
| | | DISCOUNT(4,"平台套餐", "平台套餐") |
| | | DISCOUNT(4,"套餐购买", "套餐购买") |
| | | |
| | | ; |
| | | String name; |
| | |
| | | public static final String LEASE_NOTICE_URL = "LEASE_NOTICE_URL"; |
| | | //押金 |
| | | public static final String RENT_DEPOSIT = "RENT_DEPOSIT"; |
| | | //电车临停自动关锁时长(分钟) |
| | | public static final String PAUSE_AUTO_CLOSE_TIME = "PAUSE_AUTO_CLOSE_TIME"; |
| | | |
| | | //温馨提示 |
| | | public static final String TIPS = "TIPS"; |
| | | //温馨提示 |
| | |
| | | return dt1; |
| | | } |
| | | |
| | | |
| | | |
| | | public static Date StringToDateFormat(String DATE,String format) { |
| | | if(StringUtils.isBlank(DATE)){ |
| | | return null; |
| | | } |
| | | DateFormat df = new SimpleDateFormat(format); |
| | | Date dt1 = null; |
| | | try { |
| | | dt1 = df.parse(DATE); |
| | | } catch (Exception exception) { |
| | | exception.printStackTrace(); |
| | | } |
| | | return dt1; |
| | | } |
| | | |
| | | |
| | | public static String getXDaysAfter(Date date, Integer days){ |
| | | Timestamp currentTimestamp = new Timestamp(date.getTime()); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(currentTimestamp); |
| | | calendar.add(Calendar.DAY_OF_YEAR, days-1); // 在当前时间基础上添加指定的天数 |
| | | calendar.add(Calendar.DAY_OF_YEAR, days); // 在当前时间基础上添加指定的天数 |
| | | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
| | | return formatter.format(calendar.getTime()); |
| | | } |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | try { |
| | | System.out.println(DateUtil.getBetweenDays("2025-02-13","2025-02-15")); |
| | | System.out.println(DateUtil.getCurrDate()); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | |
| | | Map<String, TemplateData> m = new HashMap<>(4); |
| | | m.put("character_string1", new TemplateData(bikeCode)); |
| | | //解锁时间 |
| | | m.put("date3", new TemplateData(DateUtil.getDate(startTime,"yyyy-MM-dd HH:mm"))); |
| | | m.put("date3", new TemplateData(DateUtil.getFomartDate(startTime,"yyyy/MM/dd HH:mm"))); |
| | | //上锁时间 |
| | | m.put("date4", new TemplateData(DateUtil.getDate(endTime,"yyyy-MM-dd HH:mm"))); |
| | | m.put("date4", new TemplateData(DateUtil.getFomartDate(endTime,"yyyy/MM/dd HH:mm"))); |
| | | //温馨提醒 |
| | | m.put("thing5", new TemplateData("临时锁车已超过最大时长,已自动还车")); |
| | | wxMsgVo.setPage(goodsOrderUrl + goodsOrderId); |
| | |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @ExcelColumn(name="创建时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createDate; |
| | | |
| | | @ApiModelProperty(value = "创建人") |
| | |
| | | |
| | | @ApiModelProperty(value = "编辑时间") |
| | | @ExcelColumn(name="编辑时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date editDate; |
| | | |
| | | @ApiModelProperty(value = "编辑人") |
| | |
| | | @ApiModelProperty(value = "每日单价", example = "1") |
| | | private BigDecimal dayPrice; |
| | | |
| | | @ApiModelProperty(value = "小程序查询使用", hidden = true) |
| | | @TableField(exist = false) |
| | | private Integer minShow; |
| | | |
| | | @ApiModelProperty(value = "创建人名称") |
| | | @TableField(exist = false) |
| | | private String creatorName; |
| | | |
| | | |
| | | @ApiModelProperty(value = "最后编辑人") |
| | | @TableField(exist = false) |
| | | private String editorName; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "图片全路径", example = "1") |
| | |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @ExcelColumn(name="创建时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createDate; |
| | | |
| | | @ApiModelProperty(value = "创建人") |
| | |
| | | |
| | | @ApiModelProperty(value = "编辑时间") |
| | | @ExcelColumn(name="编辑时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date editDate; |
| | | |
| | | @ApiModelProperty(value = "编辑人") |
| | |
| | | private String id; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createDate; |
| | | |
| | | @ApiModelProperty(value = "创建人") |
| | | private String creator; |
| | | |
| | | @ApiModelProperty(value = "编辑时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date editDate; |
| | | |
| | | @ApiModelProperty(value = "编辑人") |
| | |
| | | private String openid; |
| | | |
| | | @ApiModelProperty(value = "支付方式 0微信 1支付宝") |
| | | @ExcelColumn(name="支付方式",index = 7 ,width = 10,valueMapping = "0=微信;1=支付宝;",align = HorizontalAlignment.CENTER) |
| | | @ExcelColumn(name="支付方式",index = 7 ,width = 10,valueMapping = "0=微信;1=支付宝;",align = HorizontalAlignment.CENTER) |
| | | private Integer payWay; |
| | | |
| | | @ApiModelProperty(value = "订单来源") |
| | | @ExcelColumn(name="订单来源",index = 8 ,width = 10,valueMapping = "0=小程序端;",align = HorizontalAlignment.CENTER) |
| | | @ExcelColumn(name="订单来源",index = 8 ,width = 10,valueMapping = "0=小程序端;",align = HorizontalAlignment.CENTER) |
| | | private Integer origin; |
| | | |
| | | |
| | |
| | | @ApiModelProperty(value = "订单主键") |
| | | private String goodsOrderId; |
| | | |
| | | @ApiModelProperty(value = "骑行状态:-1=未骑行;0=请求开锁中 ;1=骑行中; 2=已还车; 3=开锁失败;") |
| | | @ApiModelProperty(value = "骑行状态:-1=未骑行;0=请求开锁中 ;1=骑行中; 2=已还车; 3=开锁失败;4=临时随车;") |
| | | private Integer rideStatus; |
| | | |
| | | @ApiModelProperty(value = "小程序是否停止服务 0否 1是") |
| | |
| | | @ApiModel("骑行记录状态信息返回类") |
| | | public class MemberRidesDetailResponse { |
| | | |
| | | |
| | | @ApiModelProperty(value = "骑行记录主键") |
| | | private String id; |
| | | |
| | |
| | | @ApiModelProperty(value = "骑行记录主键") |
| | | private String rideId; |
| | | |
| | | @ApiModelProperty(value = "车辆类型") |
| | | private String bikeTypeName; |
| | | |
| | | @ApiModelProperty(value = "套餐卡信息") |
| | | private DiscountMember discountMember; |
| | | |
| | |
| | | |
| | | void autoCancelRefunOrder(); |
| | | |
| | | DiscountMember getUseDiscount(String memberId, Integer driveTime); |
| | | DiscountMember getUseDiscount(String memberId, Integer driveTime,Integer type); |
| | | |
| | | void autCancel(); |
| | | } |
| | |
| | | low = Double.parseDouble(collect.get(Constants.LOW_BIKE_VOLTAGE).getCode()); |
| | | }catch (Exception e){ |
| | | } |
| | | if(pageWrap.getModel().getType() == Constants.ONE){ |
| | | if(pageWrap.getModel().getLowVoltage() == Constants.ONE){ |
| | | //低电量 |
| | | queryWrapper.lt(Bikes::getVoltage,low); |
| | | }else{ |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.DiscountLogMapper; |
| | | import com.doumee.dao.business.model.DiscountLog; |
| | | import com.doumee.dao.business.model.DiscountMember; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.service.business.DiscountLogService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 用户套餐卡使用调整日志表Service实现 |
| | |
| | | @Override |
| | | public PageData<DiscountLog> findPage(PageWrap<DiscountLog> pageWrap) { |
| | | IPage<DiscountLog> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<DiscountLog> queryWrapper = new QueryWrapper<>(); |
| | | MPJLambdaWrapper<DiscountLog> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | if (pageWrap.getModel().getId() != null) { |
| | | queryWrapper.lambda().eq(DiscountLog::getId, pageWrap.getModel().getId()); |
| | | } |
| | | if (pageWrap.getModel().getCreateDate() != null) { |
| | | queryWrapper.lambda().ge(DiscountLog::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); |
| | | queryWrapper.lambda().le(DiscountLog::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); |
| | | } |
| | | if (pageWrap.getModel().getCreator() != null) { |
| | | queryWrapper.lambda().eq(DiscountLog::getCreator, pageWrap.getModel().getCreator()); |
| | | } |
| | | if (pageWrap.getModel().getEditDate() != null) { |
| | | queryWrapper.lambda().ge(DiscountLog::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); |
| | | queryWrapper.lambda().le(DiscountLog::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); |
| | | } |
| | | if (pageWrap.getModel().getEditor() != null) { |
| | | queryWrapper.lambda().eq(DiscountLog::getEditor, pageWrap.getModel().getEditor()); |
| | | } |
| | | if (pageWrap.getModel().getIsdeleted() != null) { |
| | | queryWrapper.lambda().eq(DiscountLog::getIsdeleted, pageWrap.getModel().getIsdeleted()); |
| | | } |
| | | if (pageWrap.getModel().getInfo() != null) { |
| | | queryWrapper.lambda().eq(DiscountLog::getInfo, pageWrap.getModel().getInfo()); |
| | | } |
| | | if (pageWrap.getModel().getDiscountMemberId() != null) { |
| | | queryWrapper.lambda().eq(DiscountLog::getDiscountMemberId, pageWrap.getModel().getDiscountMemberId()); |
| | | } |
| | | if (pageWrap.getModel().getType() != null) { |
| | | queryWrapper.lambda().eq(DiscountLog::getType, pageWrap.getModel().getType()); |
| | | } |
| | | if (pageWrap.getModel().getRideTime() != null) { |
| | | queryWrapper.lambda().eq(DiscountLog::getRideTime, pageWrap.getModel().getRideTime()); |
| | | } |
| | | if (pageWrap.getModel().getRidePrice() != null) { |
| | | queryWrapper.lambda().eq(DiscountLog::getRidePrice, pageWrap.getModel().getRidePrice()); |
| | | } |
| | | if (pageWrap.getModel().getEditInfo() != null) { |
| | | queryWrapper.lambda().eq(DiscountLog::getEditInfo, pageWrap.getModel().getEditInfo()); |
| | | } |
| | | if (pageWrap.getModel().getEditDays() != null) { |
| | | queryWrapper.lambda().eq(DiscountLog::getEditDays, pageWrap.getModel().getEditDays()); |
| | | } |
| | | if (pageWrap.getModel().getGoodsorderId() != null) { |
| | | queryWrapper.lambda().eq(DiscountLog::getGoodsorderId, pageWrap.getModel().getGoodsorderId()); |
| | | } |
| | | for(PageWrap.SortData sortData: pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | DiscountLog model = pageWrap.getModel(); |
| | | queryWrapper.selectAll(DiscountLog.class) |
| | | .selectAs(SystemUser::getRealname,DiscountLog::getCreatorName) |
| | | .leftJoin(SystemUser.class,SystemUser::getId,DiscountLog::getCreator) |
| | | .eq(DiscountLog::getIsdeleted, Constants.ZERO) |
| | | .eq(Objects.nonNull(model.getType()),DiscountLog::getType,model.getType()) |
| | | .eq(StringUtils.isNotBlank(model.getDiscountMemberId()),DiscountLog::getDiscountMemberId,model.getDiscountMemberId()); |
| | | PageData<DiscountLog> pageData = PageData.from(discountLogMapper.selectJoinPage(page, DiscountLog.class,queryWrapper)); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(pageData.getRecords())){ |
| | | for (DiscountLog discountLog:pageData.getRecords()) { |
| | | if(Constants.equalsInteger(discountLog.getType(),Constants.ZERO)&&Objects.nonNull(discountLog.getRidePrice())){ |
| | | discountLog.setRidePrice( |
| | | Constants.translateMoney(discountLog.getRidePrice()) |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | return PageData.from(discountLogMapper.selectPage(page, queryWrapper)); |
| | | return pageData; |
| | | } |
| | | |
| | | @Override |
| | |
| | | if(Objects.isNull(discountMember)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | List<DiscountLog> discountLogList = discountLogMapper.selectJoinList(DiscountLog.class,new MPJLambdaWrapper<DiscountLog>() |
| | | .selectAll(DiscountLog.class) |
| | | .selectAs(SystemUser::getRealname,DiscountLog::getCreatorName) |
| | | .eq(DiscountLog::getDiscountMemberId,discountMember.getId()) |
| | | .eq(DiscountLog::getIsdeleted,Constants.ZERO) |
| | | .orderByDesc(DiscountLog::getId) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(discountLogList)){ |
| | | discountMember.setDiscountLogList(discountLogList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ZERO)).collect(Collectors.toList())); |
| | | discountMember.setOptLogList(discountLogList.stream().filter(i->!Constants.equalsInteger(i.getType(),Constants.ZERO)).collect(Collectors.toList())); |
| | | discountMember.setUseTimes(discountMember.getDiscountLogList().size()); |
| | | } |
| | | // List<DiscountLog> discountLogList = discountLogMapper.selectJoinList(DiscountLog.class,new MPJLambdaWrapper<DiscountLog>() |
| | | // .selectAll(DiscountLog.class) |
| | | // .selectAs(SystemUser::getRealname,DiscountLog::getCreatorName) |
| | | // .leftJoin(SystemUser.class,SystemUser::getId,DiscountLog::getCreator) |
| | | // .eq(DiscountLog::getDiscountMemberId,discountMember.getId()) |
| | | // .eq(DiscountLog::getIsdeleted,Constants.ZERO) |
| | | // .orderByDesc(DiscountLog::getId) |
| | | // ); |
| | | // discountMember.setUseTimes(discountMember.getDiscountLogList().size()); |
| | | // if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(discountLogList)){ |
| | | // discountMember.setDiscountLogList(discountLogList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ZERO)).collect(Collectors.toList())); |
| | | // discountMember.setOptLogList(discountLogList.stream().filter(i->!Constants.equalsInteger(i.getType(),Constants.ZERO)).collect(Collectors.toList())); |
| | | // |
| | | // } |
| | | return discountMember; |
| | | } |
| | | |
| | |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | DiscountMember model = pageWrap.getModel(); |
| | | queryWrapper.selectAll(DiscountMember.class) |
| | | .selectAs(Member::getOpenid,DiscountMember::getOpenid) |
| | | .select(" ( select count(1) from discount_log d where d.discount_member_id = t.id and d.type = 0 ) ",DiscountMember::getUseTimes) |
| | | .leftJoin(Member.class,Member::getId,DiscountMember::getMemberId) |
| | | .like(StringUtils.isNotBlank(model.getCode()),DiscountMember::getCode,model.getCode()) |
| | | .like(StringUtils.isNotBlank(model.getName()),DiscountMember::getName,model.getName()) |
| | | .like(StringUtils.isNotBlank(model.getOpenid()),Member::getOpenid,model.getOpenid()) |
| | | .eq(Objects.nonNull(model.getStatus()),DiscountMember::getStatus,model.getStatus()) |
| | | .orderByDesc(DiscountMember::getId); |
| | | .ne(DiscountMember::getStatus,Constants.TWO) |
| | | .orderByDesc(DiscountMember::getCode); |
| | | return PageData.from(discountMemberJoinMapper.selectJoinPage(page, DiscountMember.class,queryWrapper)); |
| | | } |
| | | |
| | |
| | | .orderByDesc(DiscountMember::getId); |
| | | List<DiscountMember> list = discountMemberJoinMapper.selectJoinList(DiscountMember.class,queryWrapper); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到可报废的套餐卡信息"); |
| | | return; |
| | | } |
| | | for (DiscountMember discountMember:list) { |
| | | if(!Constants.equalsInteger(discountMember.getStatus(),Constants.ZERO)){ |
| | | continue; |
| | | } |
| | | discountMemberMapper.update(null,new UpdateWrapper<DiscountMember>().lambda() |
| | | .set(DiscountMember::getStatus,Constants.ONE) |
| | | .eq(DiscountMember::getId,discountMember.getId()) |
| | |
| | | discountLog.setGoodsorderId(discountMember.getGoodsorderId()); |
| | | discountLogMapper.insert(discountLog); |
| | | } |
| | | //退款操作 |
| | | } |
| | | |
| | | |
| | |
| | | @Override |
| | | public void adjust(DiscountMemberDTO model){ |
| | | if(Objects.isNull(model) |
| | | || Objects.isNull(model.getAddDays())){ |
| | | || Objects.isNull(model.getAddDays())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | |
| | | discountLog.setDiscountMemberId(discountMember.getId()); |
| | | discountLog.setType(Constants.TWO); |
| | | discountLog.setGoodsorderId(discountMember.getGoodsorderId()); |
| | | discountLog.setEditInfo(model.getInfo()); |
| | | discountLog.setInfo(model.getInfo()); |
| | | discountLog.setEditDays(model.getAddDays()); |
| | | discountLog.setEditInfo("将有效期增加"+model.getAddDays()+"天, 调整后有效期至"+useEndDate); |
| | | discountLogMapper.insert(discountLog); |
| | | |
| | | } |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | discount.setIsdeleted(Constants.ZERO); |
| | | discount.setCreateDate(new Date()); |
| | | discount.setCreator(userInfo.getId()); |
| | | discount.setEditDate(new Date()); |
| | | discount.setEditor(userInfo.getId()); |
| | | if(Constants.equalsInteger(discount.getUseType(),Constants.ZERO)){ |
| | | discount.setUseDays((int) (DateUtil.getBetweenDays(DateUtil.dateToString(discount.getUseStartDate(),"yyyy-MM-dd"),DateUtil.dateToString(discount.getUseEndDate(),"yyyy-MM-dd")))); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | public void vaildReq(Discount discount) { |
| | | public void vaildReq(Discount discount){ |
| | | if(Objects.isNull(discount) |
| | | || StringUtils.isBlank(discount.getName()) |
| | | || Objects.isNull(discount.getType()) |
| | |
| | | ( discount.getUseStartDate().getTime()>discount.getUseEndDate().getTime()) ){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"使用时段信息错误"); |
| | | } |
| | | |
| | | //指定日期生效 |
| | | if(Constants.equalsInteger(discount.getUseType(),Constants.TWO) && |
| | | ( discount.getUseStartDate().getTime()<discount.getStartDate().getTime() || |
| | | discount.getUseStartDate().getTime() > discount.getEndDate().getTime() |
| | | ) ){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"使用时段信息错误"); |
| | | } |
| | | if(Objects.isNull(discount.getSaleDayLimit())){ |
| | | discount.setSaleDayLimit(Constants.ZERO); |
| | | } |
| | | if(Objects.isNull(discount.getSaleLimit())){ |
| | | discount.setSaleLimit(Constants.ZERO); |
| | | } |
| | | if(Constants.equalsInteger(discount.getUseType(),Constants.TWO)){ |
| | | discount.setUseEndDate( DateUtil.StringToDateFormat(DateUtil.getXDaysAfter(discount.getUseStartDate(),discount.getUseDays()),"yyyy-MM-dd")); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void updateById(Discount discount) { |
| | | LoginUserInfo userInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(Objects.isNull(discount) |
| | | || StringUtils.isBlank(discount.getId())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Discount model = discountMapper.selectById(discount.getId()); |
| | | if(Objects.isNull(model)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!Constants.equalsInteger(model.getStatus(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未禁用无法进行修改"); |
| | | } |
| | | this.vaildReq(discount); |
| | | discount.setEditDate(new Date()); |
| | | discount.setEditor(userInfo.getId()); |
| | | if(Constants.equalsInteger(discount.getUseType(),Constants.ZERO)){ |
| | | discount.setUseDays((int) (DateUtil.getBetweenDays(DateUtil.dateToString(discount.getUseStartDate(),"yyyy-MM-dd"),DateUtil.dateToString(discount.getUseEndDate(),"yyyy-MM-dd")))); |
| | | } |
| | | discountMapper.updateById(discount); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public Discount findById(String id) { |
| | | Discount discount = discountJoinMapper.selectOne(new MPJLambdaWrapper<Discount>() |
| | | .selectAll(Discount.class) |
| | | .selectAll(Discount.class) |
| | | .select(" s1.realname ",Discount::getCreatorName) |
| | | .select(" s2.realname ",Discount::getEditorName) |
| | | .select(" (select count(1) from goodsorder g where g.obj_type = 0 and g.obj_id = t.id and g.pay_status = 1 ) ",Discount::getSaleNum) |
| | | .leftJoin(SystemUser.class,SystemUser::getId,Discount::getCreator) |
| | | .leftJoin(" system_user s1 on s1.id = t.creator") |
| | | .leftJoin(" system_user s2 on s2.id = t.editor") |
| | | .eq(Discount::getId,id) |
| | | ); |
| | | if(Objects.isNull(discount)){ |
| | |
| | | .eq(Objects.nonNull(modele.getBikeOrElec()) && Constants.equalsInteger(modele.getBikeOrElec(),Constants.ONE),Discount::getIsbike, Constants.ONE) |
| | | .eq(Objects.nonNull(modele.getBikeOrElec()) && Constants.equalsInteger(modele.getBikeOrElec(),Constants.TWO),Discount::getIselecbike, Constants.ONE) |
| | | .eq(Discount::getIsdeleted, Constants.ZERO) |
| | | .eq( pageWrap.getModel().getStatus() !=null,BikeRepair::getStatus,pageWrap.getModel().getStatus()); |
| | | .eq( pageWrap.getModel().getStatus() !=null,BikeRepair::getStatus,pageWrap.getModel().getStatus()) |
| | | .apply( Objects.nonNull(modele.getMinShow())," now() BETWEEN t.start_date and ( t.end_date + INTERVAL '1 day' ) ") |
| | | ; |
| | | queryWrapper.orderByDesc(Discount::getCreateDate); |
| | | PageData<Discount> pageData = PageData.from(discountJoinMapper.selectJoinPage(page, Discount.class,queryWrapper)); |
| | | for (Discount discount:pageData.getRecords()) { |
| | |
| | | @Override |
| | | public void dealPrice(Discount discount){ |
| | | if(Objects.isNull(discount) |
| | | || Objects.isNull(discount.getUseEndDate()) |
| | | || Objects.isNull(discount.getUseStartDate()) |
| | | || Objects.isNull(discount.getUseDays()) |
| | | || Objects.isNull(discount.getPrice()) |
| | | || discount.getPrice().compareTo(BigDecimal.ZERO)==0 |
| | | ){ |
| | |
| | | MPJLambdaWrapper<Goodsorder> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(Goodsorder.class); |
| | | queryWrapper.selectAs(Member::getOpenid, Goodsorder::getOpenid); |
| | | queryWrapper.selectAs(DiscountMember::getName, Goodsorder::getDiscountName); |
| | | queryWrapper.leftJoin(Member.class, Member::getId ,Goodsorder::getMemberId); |
| | | queryWrapper.select("(select r.name from discount_member r where r.isdeleted=0 and r.goodsorder_id=t.id limit 1) as discountName"); |
| | | queryWrapper.leftJoin(DiscountMember.class, DiscountMember::getGoodsorderId ,Goodsorder::getId); |
| | | // queryWrapper.select("(select r.name from discount_member r where r.isdeleted=0 and r.goodsorder_id=t.id limit 1) as discountName"); |
| | | queryWrapper.select("(select max(r.done_date) from refund r where r.obj_id=t.id and r.status in(0,2)) as refund_date"); |
| | | queryWrapper.select("(select sum(r.money) from refund r where r.obj_id=t.id and r.status in(0,2)) as refund_money"); |
| | | //时间段筛选 |
| | |
| | | queryWrapper.like(model.getCode() !=null,Goodsorder::getCode,model.getCode()); |
| | | queryWrapper.like(model.getId() !=null,Goodsorder::getId,model.getId()); |
| | | queryWrapper.eq(model.getStatus() !=null,Goodsorder::getStatus,model.getStatus()); |
| | | queryWrapper.eq(model.getPayWay() !=null,Goodsorder::getPayWay,model.getPayWay()); |
| | | queryWrapper.like(model.getOnlineOrderid() !=null,Goodsorder::getOnlineOrderid,model.getOnlineOrderid()); |
| | | queryWrapper.like(model.getOpenid() !=null,Member::getOpenid,model.getOpenid()); |
| | | queryWrapper.eq(Goodsorder::getIsdeleted,Constants.ZERO); |
| | | //如果是骑行订单只显示支付成功的 |
| | | queryWrapper.eq(Constants.equalsInteger(model.getType(),Constants.ZERO),Goodsorder::getPayStatus,Constants.ONE); |
| | | queryWrapper.in(Constants.equalsInteger(model.getType(),Constants.ONE),Goodsorder::getStatus,Constants.ONE,Constants.ZERO); |
| | | |
| | | return queryWrapper; |
| | | } |
| | |
| | | if(Objects.nonNull(pageWrap.getModel().getCloseStatus()) && pageWrap.getModel().getCloseStatus().equals(Constants.ONE)){ |
| | | queryWrapper.eq(Goodsorder::getStatus,Constants.GOODSORDER_STATUS.CLOSE.getKey()); |
| | | } |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getDiscountName()),Goodsorder::getDiscountName,pageWrap.getModel().getDiscountName()); |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getDiscountName()),DiscountMember::getName,pageWrap.getModel().getDiscountName()); |
| | | IPage<Goodsorder> goodsorderIPage = goodsorderJoinMapper.selectJoinPage(page, Goodsorder.class, queryWrapper); |
| | | if (!CollectionUtils.isEmpty(goodsorderIPage.getRecords())){ |
| | | goodsorderIPage.getRecords().forEach(s->{ |
| | |
| | | discountMapper.selectList(new QueryWrapper<Discount>().lambda() |
| | | .eq(Discount::getIsdeleted,Constants.ZERO) |
| | | .eq(Discount::getStatus,Constants.ZERO) |
| | | .apply(" now() BETWEEN start_date and ( end_date + INTERVAL '1 day' ) ") |
| | | .orderByDesc(Discount::getId) |
| | | .last(" limit 3 ") |
| | | ) |
| | |
| | | memberRidesResponse.setVoltageStatus(this.getVoltageStatus(bikes)); |
| | | } |
| | | //查询当前的骑行套餐 |
| | | memberRidesResponse.setDiscountMember(this.getUseDiscount(memberId,Constants.ZERO)); |
| | | memberRidesResponse.setDiscountMember(this.getUseDiscount(memberId,Constants.ZERO,memberRides.getType())); |
| | | homeResponse.setMemberRidesResponse(memberRidesResponse); |
| | | } |
| | | } |
| | |
| | | if(Constants.equalsInteger(goodsorder.getType(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED); |
| | | } |
| | | goodsorder.setMoney(Constants.translateMoney(goodsorder.getMoney())); |
| | | goodsorderDetailVO.setGoodsOrder(goodsorder); |
| | | Member member = memberMapper.selectById(goodsorder.getMemberId()); |
| | | if(Objects.nonNull(member)){ |
| | |
| | | .eq(Refund::getObjId,goodsorder.getId()) |
| | | .orderByDesc(Refund::getId) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(refunds)){ |
| | | for (Refund refund:refunds) { |
| | | if(Objects.nonNull(refund.getMoney())){ |
| | | refund.setMoney(Constants.translateMoney(refund.getMoney())); |
| | | } |
| | | } |
| | | } |
| | | goodsorderDetailVO.setRefundList(refunds); |
| | | |
| | | return goodsorderDetailVO; |
| | |
| | | freeTime = Integer.parseInt(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME, Constants.FREE_RENT_TIME).getCode()); |
| | | }catch (Exception e){ |
| | | } |
| | | closeMoney = getCloseMoneyByRides(memberRides,freeTime,true,goodsorder.getMoney(),goodsorder.getMemberId()).getAmount(); |
| | | closeMoney = getCloseMoneyByRides(memberRides,freeTime,true,goodsorder.getMoney(),goodsorder.getMemberId(),true).getAmount(); |
| | | //实际结算价格,记录在最高车型记录上 |
| | | // memberRides.get(0).setActualPrice(closeMoney); |
| | | } |
| | |
| | | transactionsMapper.insert(transactions); |
| | | } |
| | | |
| | | private RidesDetailResponse getCloseMoneyByRides(List<MemberRides> memberRides,int freeTime,boolean isClose,BigDecimal yjMoney,String memberId) { |
| | | private RidesDetailResponse getCloseMoneyByRides(List<MemberRides> memberRides,int freeTime,boolean isClose,BigDecimal yjMoney,String memberId,Boolean unOver) { |
| | | RidesDetailResponse ridesDetailResponse = new RidesDetailResponse(); |
| | | ridesDetailResponse.setHaveDisCount(Constants.ZERO); |
| | | BigDecimal closeMoney = new BigDecimal(0.00); |
| | |
| | | topRides.setActualPrice(closeMoney); |
| | | } |
| | | //查询是否存在套餐信息 |
| | | DiscountMember discountMember = this.getUseDiscount(memberId,durationSum); |
| | | DiscountMember discountMember = this.getUseDiscount(memberId,durationSum,Objects.nonNull(topRides)?topRides.getType():null); |
| | | //计算抵扣金额 |
| | | if(Objects.nonNull(discountMember) && discountMember.getSurplusTime() > Constants.ZERO && Objects.nonNull(topRides)){ |
| | | //unOver 是否未结算 未结算的订单根据当前套餐查询 已结算的订单根据已生成的数据进行查询 |
| | | if(Objects.nonNull(discountMember) && Objects.nonNull(topRides) && unOver){ |
| | | //存储抵扣记录 |
| | | DiscountLog discountLog = new DiscountLog(); |
| | | discountLog.setIsdeleted(Constants.ZERO); |
| | |
| | | discountLog.setEditInfo("骑行抵扣"); |
| | | discountLog.setGoodsorderId(topRides.getOrdreId()); |
| | | //如果骑行时间小于等于剩余时间 则直接添加 骑行卡使用数据 修正实际支付金额 |
| | | if(discountMember.getSurplusTime() >= durationSum){ |
| | | if(Constants.equalsInteger(discountMember.getLimitType(),Constants.ZERO) || discountMember.getSurplusTime() >= durationSum){ |
| | | discountLog.setRideTime(durationSum); |
| | | discountLog.setRidePrice(closeMoney); |
| | | topRides.setActualPrice(BigDecimal.ZERO); |
| | |
| | | }else{ |
| | | int baseTime =Constants.formatIntegerNum(topRides.getBaseTime()); |
| | | BigDecimal closeDisCountMoney = Constants.formatDecimalNum(topRides.getBasePrice()); |
| | | //如果是一口价方式,价格直接为一口价baseMoney,如果不是计算正常价格 |
| | | //减去优惠时长剩余时长 |
| | | Integer durationDisCountSum = durationSum - discountMember.getSurplusTime(); |
| | | discountLog.setRideTime(discountMember.getSurplusTime()); |
| | | discountLog.setRideTime(durationDisCountSum<=Constants.ZERO?discountMember.getSurplusTime():Constants.ZERO); |
| | | //如果是一口价方式,价格直接为一口价baseMoney,如果不是计算正常价格 |
| | | if(baseTime != -1){//不是一口价 |
| | | if(durationDisCountSum > baseTime && Constants.formatIntegerNum(topRides.getUnitTime())>0){ |
| | | //如果超出了起步价格,计算超出价格 |
| | |
| | | //计算金额累计超出部门价格(超出时间单位*超出单位时间价格) |
| | | closeDisCountMoney = closeDisCountMoney.add(unit.multiply(Constants.formatDecimalNum(topRides.getUnitPrice()))); |
| | | } |
| | | discountLog.setRidePrice(closeMoney.subtract(closeDisCountMoney)); |
| | | discountLog.setRidePrice(durationDisCountSum<=Constants.ZERO?closeMoney.subtract(closeDisCountMoney):BigDecimal.ZERO); |
| | | }else{ |
| | | discountLog.setRidePrice(BigDecimal.ZERO); |
| | | } |
| | | } |
| | | discountLogMapper.insert(discountLog); |
| | | ridesDetailResponse.setHaveDisCount(Constants.ONE); |
| | | if(isClose&&discountLog.getRideTime()>Constants.ZERO){ |
| | | discountLogMapper.insert(discountLog); |
| | | } |
| | | ridesDetailResponse.setHaveDisCount(discountLog.getRideTime()>Constants.ZERO?Constants.ONE:Constants.ZERO); |
| | | ridesDetailResponse.setDisCountMoney(discountLog.getRidePrice()); |
| | | }else if(Objects.nonNull(discountMember) && Objects.nonNull(topRides) |
| | | && !unOver ){ |
| | | //已还车则查询是否有 套餐卡使用记录 |
| | | List<DiscountLog> discountLogList = discountLogMapper.selectList(new QueryWrapper<DiscountLog>().lambda().eq(DiscountLog::getGoodsorderId,topRides.getOrdreId()).eq(DiscountLog::getType,Constants.ZERO) |
| | | .eq(DiscountLog::getIsdeleted,Constants.ZERO)); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(discountLogList)){ |
| | | ridesDetailResponse.setHaveDisCount(Constants.ONE); |
| | | ridesDetailResponse.setDisCountMoney(discountLogList.stream().map(i->i.getRidePrice()).reduce(BigDecimal.ZERO,BigDecimal::add)); |
| | | } |
| | | } |
| | | //如果订单价格封顶了,取订单 价格 |
| | | if(Constants.compareBigdecimal(closeMoney, yjMoney) ==1){ |
| | |
| | | LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(Objects.isNull(goodsorderBackDTO) |
| | | || StringUtils.isBlank(goodsorderBackDTO.getOrderId()) |
| | | || StringUtils.isBlank(goodsorderBackDTO.getReason()) |
| | | || Objects.isNull(goodsorderBackDTO.getBackType()) |
| | | || Objects.isNull(goodsorderBackDTO.getMoney())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | |
| | | .selectAs(BaseParam::getSortnum,MemberRides::getSortnum) |
| | | .leftJoin(BaseParam.class,BaseParam::getId,MemberRides::getParamId) |
| | | .eq(MemberRides::getOrdreId,id) |
| | | .in(MemberRides::getStatus,Constants.MEMBER_RIDES_STATUS.RIDES_RUNNING.getKey(),Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey()) |
| | | .in(MemberRides::getStatus,Constants.MEMBER_RIDES_STATUS.RIDES_RUNNING.getKey() |
| | | ,Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey(),Constants.MEMBER_RIDES_STATUS.RIDES_PAUSING.getKey()) |
| | | .orderByDesc(MemberRides::getCreateDate)); |
| | | if (!CollectionUtils.isEmpty(memberRides)){ |
| | | //预计结算价格和计算时长 |
| | |
| | | return memberRidesResponse; |
| | | }).collect(Collectors.toList()); |
| | | //累计和预算结算金额 |
| | | RidesDetailResponse ridesDetailResponse = getCloseMoneyByRides(memberRides,freeTime,false,goodsorder.getMoney(),goodsorder.getMemberId()); |
| | | RidesDetailResponse ridesDetailResponse = getCloseMoneyByRides(memberRides,freeTime,false,goodsorder.getMoney(),goodsorder.getMemberId(), |
| | | Constants.equalsInteger(goodsorder.getStatus(),Constants.GOODSORDER_STATUS.CLOSE.getKey())?false:true); |
| | | if(Constants.formatIntegerNum(goodsorder.getStatus())!= Constants.goodsorderStatus.pay){ |
| | | //如果非已支付但未结算,使用订单金额 |
| | | ridesDetailResponse.setAmount(goodsorder.getCloseMoney()); |
| | |
| | | discountMember.setMemberId(memberId); |
| | | discountMember.setStatus(Constants.TWO); |
| | | discountMember.setGoodsorderId(goodsorderId); |
| | | if(!Constants.equalsInteger(discountMember.getUseType(),Constants.ZERO)){ |
| | | if(Constants.equalsInteger(discountMember.getUseType(),Constants.ONE)){ |
| | | discountMember.setUseStartDate(DateUtil.StringToDateFormat(DateUtil.getCurrDate(),"yyyy-MM-dd")); |
| | | } |
| | | discountMember.setUseEndDate( DateUtil.StringToDateFormat(DateUtil.getXDaysAfter(discountMember.getUseStartDate(),discountMember.getUseDays()-1),"yyyy-MM-dd")); |
| | | } |
| | | discountMemberMapper.insert(discountMember); |
| | | |
| | | Goodsorder goodsorder = new Goodsorder(); |
| | | goodsorder.setId(goodsorderId); |
| | | goodsorder.setCreateDate(new Date()); |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到套餐信息"); |
| | | } |
| | | if(!(Constants.equalsInteger(discount.getIsdeleted(),Constants.ZERO) |
| | | ||Constants.equalsInteger(discount.getStatus(),Constants.ZERO))){ |
| | | && Constants.equalsInteger(discount.getStatus(),Constants.ZERO))){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"套餐已下架,无法进行购买,请刷新查看"); |
| | | } |
| | | if(!(discount.getStartDate().getTime() < System.currentTimeMillis() |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"套餐开放时间未到,无法进行购买"); |
| | | } |
| | | //验证是否超过今日可售卖数量 |
| | | if(Objects.nonNull(discount.getSaleDayLimit())){ |
| | | if(Objects.nonNull(discount.getSaleDayLimit())&&discount.getSaleDayLimit()>Constants.ZERO){ |
| | | if(goodsorderMapper.selectCount(new QueryWrapper<Goodsorder>().lambda() |
| | | .eq(Goodsorder::getType,Constants.ONE) |
| | | .eq(Goodsorder::getObjId,discount.getId()) |
| | |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"套餐今日发行量已售罄,请明日查看!"); |
| | | } |
| | | } |
| | | if(Objects.nonNull(discount.getSaleLimit())){ |
| | | if(Objects.nonNull(discount.getSaleLimit())&&discount.getSaleLimit()>Constants.ZERO){ |
| | | if(goodsorderMapper.selectCount(new QueryWrapper<Goodsorder>().lambda() |
| | | .eq(Goodsorder::getType,Constants.ONE) |
| | | .eq(Goodsorder::getObjId,discount.getId()) |
| | | .in(Goodsorder::getStatus,Constants.ZERO,Constants.ONE) |
| | | .apply(" EXTRACT(YEAR FROM create_date) = EXTRACT(YEAR FROM CURRENT_DATE) ") |
| | | )>=discount.getSaleDayLimit()){ |
| | | )>=discount.getSaleLimit()){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"套餐发行量已售罄!"); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | private Object getWxPayResponse(Goodsorder goodsorder,String openid){ |
| | | Object response = null; |
| | | //调起支付 |
| | | Object response = null; |
| | | PrepayRequest request = new PrepayRequest(); |
| | | request.setAttach("createGoodsOrder"); |
| | | request.setDescription(Constants.equalsInteger(goodsorder.getType(),Constants.ZERO)?"森林公园自行车骑行押金支付":"森林公园自行车购买骑行套餐支付"); |
| | |
| | | Goodsorder goodsorder = this.goodsorderMapper.selectOne(new QueryWrapper<Goodsorder>() |
| | | .eq("member_id",memberId) |
| | | .eq("status",Constants.goodsorderStatus.pay) |
| | | .eq("type",Constants.ZERO) |
| | | .last(" limit 1 ")); |
| | | if(Objects.isNull(goodsorder)){ |
| | | throw new BusinessException(ResponseStatus.NO_UNCLOSEED_ORDER.getCode(),"无骑行订单记录"); |
| | |
| | | * @param memberId |
| | | */ |
| | | @Override |
| | | public DiscountMember getUseDiscount(String memberId,Integer driveTime){ |
| | | public DiscountMember getUseDiscount(String memberId,Integer driveTime,Integer type){ |
| | | if(Objects.isNull(type)){ |
| | | return null; |
| | | } |
| | | String today = DateUtil.getToday(); |
| | | //判断今天是否为节假日 |
| | | Holidays holidays = new Holidays(); |
| | |
| | | "and d.isdeleted = 0 and d.type = 0 and EXTRACT(DAY FROM d.create_date) = EXTRACT(DAY FROM CURRENT_DATE) ) " , DiscountMember::getUseTime)//查询今日已使用时间 |
| | | .eq(DiscountMember::getStatus,Constants.ZERO) |
| | | .eq(DiscountMember::getMemberId,memberId) |
| | | .le(DiscountMember::getUseStartDate, Utils.Date.getStart(DateUtil.stringToDate(today,"yyyy-MM-dd"))) |
| | | .ge(DiscountMember::getUseEndDate, Utils.Date.getEnd(DateUtil.stringToDate(today,"yyyy-MM-dd"))) |
| | | .apply(" t.use_start_date <= '"+today+"' and t.use_end_date >= '"+today+"' ") |
| | | |
| | | .eq(Constants.equalsInteger(holiday,Constants.ZERO),DiscountMember::getUseWorkday,Constants.ONE) |
| | | .eq(Constants.equalsInteger(holiday,Constants.ONE),DiscountMember::getUseHoliday,Constants.ONE) |
| | | |
| | | .eq(Constants.equalsInteger(type,Constants.ZERO),DiscountMember::getIsbike,Constants.ONE) |
| | | .eq(Constants.equalsInteger(type,Constants.ONE),DiscountMember::getIselecbike,Constants.ONE) |
| | | .orderByDesc(DiscountMember::getLimitType) |
| | | .orderByDesc(DiscountMember::getLimitTime) |
| | | ); |
| | |
| | | if(list.size()>Constants.ZERO){ |
| | | //d1在前则升序 反之降序 |
| | | list.sort((d1,d2)-> Integer.compare(d2.getSurplusTime(),d1.getSurplusTime())); |
| | | return list.get(Constants.ZERO); |
| | | } |
| | | return list.get(Constants.ZERO); |
| | | }else{ |
| | | //无无期限的套餐 优先查询剩余时长大于骑行时长的信息(取时间最小的套餐) 再查询小于骑行时长的套餐 |
| | | List<DiscountMember> list = discountMemberList.stream().filter(i->i.getSurplusTime()>=driveTime).collect(Collectors.toList()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){ |
| | | if(list.size()>Constants.ZERO){ |
| | | //d1在前则升序 反之降序 |
| | | list.sort((d1,d2)-> Integer.compare(d2.getSurplusTime(),d1.getSurplusTime())); |
| | | list.sort((d1,d2)-> Integer.compare(d1.getSurplusTime(),d2.getSurplusTime())); |
| | | return list.get(Constants.ZERO); |
| | | } |
| | | return list.get(Constants.ZERO); |
| | | |
| | | } |
| | | list = discountMemberList.stream().filter(i->i.getSurplusTime()<driveTime).collect(Collectors.toList()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(list)){ |
| | | if(list.size()>Constants.ZERO){ |
| | | list.sort((d1,d2)-> Integer.compare(d1.getSurplusTime(),d2.getSurplusTime())); |
| | | list.sort((d1,d2)-> Integer.compare(d2.getSurplusTime(),d1.getSurplusTime())); |
| | | } |
| | | return list.get(Constants.ZERO); |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void autCancel(){ |
| | | goodsorderMapper.update(null,new UpdateWrapper<Goodsorder>().lambda() |
| | | .set(Goodsorder::getStatus,Constants.GOODSORDER_STATUS.CANCEL.getKey()) |
| | | .set(Goodsorder::getEditDate,DateUtil.getCurrDateTime()) |
| | | .set(Goodsorder::getEditDate,DateUtil.getCurrDateTime()) |
| | | .eq(Goodsorder::getStatus,Constants.GOODSORDER_STATUS.UN_PAY.getKey()) |
| | | .apply(" NOW() >= create_date + INTERVAL '30 min' ") |
| | | ); |
| | |
| | | } |
| | | }else{ |
| | | //如果是电车,请求web端接口关闭车辆信息 |
| | | bike = sendCloseElecBikeRequest(memberRides.getBikeCode(),Constants.ONE); |
| | | bike = sendCloseElecBikeRequest(model.getOrdreId(),memberRides.getBikeCode()); |
| | | } |
| | | logInfo = bike!=null?bike.getForceBackInfo():null; |
| | | Integer freeRentTime = Integer.valueOf(collect.get(Constants.FREE_RENT_TIME).getCode()); |
| | |
| | | /** |
| | | * 如果是电车,请求web端接口关闭车辆信息 |
| | | */ |
| | | private Bikes sendCloseElecBikeRequest(String bikeCode,int type) { |
| | | private Bikes sendCloseElecBikeRequest(String goodOrderId,String bikeCode) { |
| | | Bikes bike = bikesMapper.selectOne(new QueryWrapper<Bikes>().lambda() |
| | | .eq(Bikes::getType,Constants.ONE) |
| | | .eq(Bikes::getIsdeleted,Constants.ZERO) |
| | |
| | | return null; |
| | | } |
| | | bike.setForceBackInfo("强制还车关闭车锁失败!"); |
| | | if(StringUtils.isNotBlank(bike.getDeviceSn())){ |
| | | if(StringUtils.isNotBlank(bike.getDeviceSn())) { |
| | | try { |
| | | //请求地址 |
| | | String url = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ELEC_BIKE_CONTRIL_API_URL).getCode(); |
| | | String url = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.ELEC_BIKE_CONTRIL_API_URL).getCode(); |
| | | JSONObject param = new JSONObject(); |
| | | param.put("clientId",StringTools.leftTrip(bike.getDeviceSn(),'0')); |
| | | param.put("type",type);//0开锁 1关锁 |
| | | String res = HttpsUtil.postJsonString(url,param.toJSONString()); |
| | | param.put("id", goodOrderId); |
| | | String res = HttpsUtil.postJsonString(url, param.toJSONString()); |
| | | JSONObject json = JSONObject.parseObject(res); |
| | | if(json.get("code").equals("200")){ |
| | | if (json.get("code").equals("200")) { |
| | | //发起指令成功 |
| | | bike.setForceBackInfo("强制还车关闭车锁成功!"); |
| | | }else{ |
| | | bike.setForceBackInfo("强制还车关闭车锁失败!"+json.get("msg")); |
| | | } else { |
| | | bike.setForceBackInfo("强制还车关闭车锁失败!" + json.get("msg")); |
| | | } |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else{ |
| | | bike.setForceBackInfo("强制还车关闭车锁失败,未绑定控制器sn!"); |
| | | } |
| | | bikesMapper.updateById(bike); |
| | | return bike; |
| | | } |
| | | // private Bikes sendCloseElecBikeRequest(String bikeCode,int type) { |
| | | // Bikes bike = bikesMapper.selectOne(new QueryWrapper<Bikes>().lambda() |
| | | // .eq(Bikes::getType,Constants.ONE) |
| | | // .eq(Bikes::getIsdeleted,Constants.ZERO) |
| | | // .eq(Bikes::getCode,bikeCode) |
| | | // ); |
| | | // if(bike == null){ |
| | | // return null; |
| | | // } |
| | | // bike.setForceBackInfo("强制还车关闭车锁失败!"); |
| | | // if(StringUtils.isNotBlank(bike.getDeviceSn())){ |
| | | // try { |
| | | // //请求地址 |
| | | // String url = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ELEC_BIKE_CONTRIL_API_URL).getCode(); |
| | | // JSONObject param = new JSONObject(); |
| | | // param.put("clientId",StringTools.leftTrip(bike.getDeviceSn(),'0')); |
| | | // param.put("type",type);//0开锁 1关锁 |
| | | // String res = HttpsUtil.postJsonString(url,param.toJSONString()); |
| | | // JSONObject json = JSONObject.parseObject(res); |
| | | // if(json.get("code").equals("200")){ |
| | | // //发起指令成功 |
| | | // bike.setForceBackInfo("强制还车关闭车锁成功!"); |
| | | // }else{ |
| | | // bike.setForceBackInfo("强制还车关闭车锁失败!"+json.get("msg")); |
| | | // } |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // } |
| | | // }else{ |
| | | // bike.setForceBackInfo("强制还车关闭车锁失败,未绑定控制器sn!"); |
| | | // } |
| | | // bikesMapper.updateById(bike); |
| | | // return bike; |
| | | // } |
| | | |
| | | public static void main(String[] args) { |
| | | String url = "http://localhost:10025/jtt808/device/8500"; |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"当前车辆类型无法租赁,请联系管理员!"); |
| | | } |
| | | memberRidesResponse.setBikeCode(bike.getCode()); |
| | | memberRidesResponse.setBikeTypeName(baseParam.getName()); |
| | | memberRidesResponse.setBikeType(baseParam.getName()); |
| | | MemberRides memberRides = new MemberRides(); |
| | | this.dealMemberRidesData(baseParam.getId(),memberRides); |
| | | memberRidesResponse.setBasePrice(memberRides.getBasePrice()); |
| | |
| | | memberRidesResponse.getUnitPrice() |
| | | ,memberRidesResponse.getUnitTime())); |
| | | //查询当前的骑行套餐 |
| | | memberRidesResponse.setDiscountMember(goodsorderService.getUseDiscount(memberId,Constants.ZERO)); |
| | | memberRidesResponse.setDiscountMember(goodsorderService.getUseDiscount(memberId,Constants.ZERO,bikeType)); |
| | | return memberRidesResponse; |
| | | } |
| | | |
| | |
| | | //购买套餐 处理内容 |
| | | DiscountMember discountMember = discountMemberMapper.selectById(transactions.getObjId()); |
| | | if(Objects.nonNull(discountMember)){ |
| | | transactions.setContent(discountMember.getName() +" 有效期" + DateUtil.dateToString(discountMember.getUseStartDate(),"yyyy-MM-dd") +"-"+DateUtil.dateToString(discountMember.getUseEndDate(),"yyyy-MM-dd")); |
| | | transactions.setContent(discountMember.getName() +" | 有效期" + DateUtil.dateToString(discountMember.getUseStartDate(),"yyyy-MM-dd") +" 至 "+DateUtil.dateToString(discountMember.getUseEndDate(),"yyyy-MM-dd")); |
| | | } |
| | | }else if(Constants.equalsInteger(transactions.getType(),Constants.TRANSACTIONS_TYPE.PLATFORM_REFUND.getKey())){ |
| | | DiscountMember discountMember = discountMemberMapper.selectOne( |
| | | new QueryWrapper<DiscountMember>().lambda().eq(DiscountMember::getGoodsorderId, transactions.getOrderId()).last("limit 1")); |
| | | if(Objects.nonNull(discountMember)){ |
| | | transactions.setContent(discountMember.getName() +" 有效期" + DateUtil.dateToString(discountMember.getUseStartDate(),"yyyy-MM-dd") +"-"+DateUtil.dateToString(discountMember.getUseEndDate(),"yyyy-MM-dd")); |
| | | transactions.setContent(discountMember.getName() +" | 有效期" + DateUtil.dateToString(discountMember.getUseStartDate(),"yyyy-MM-dd") +" 至 "+DateUtil.dateToString(discountMember.getUseEndDate(),"yyyy-MM-dd")); |
| | | } |
| | | } |
| | | } |
| | |
| | | apiV3Key: iF3kC8pL8dZ9iU3hN5fX9zI6eF4xQ6fT |
| | | serialNumer: 368B835A194384FD583B83B77977B84127D2F655 |
| | | mchKey: W97N53Q71326D6JZ2E9HY5M4VT4BAC8S |
| | | notifyUrl: http://xiaopiqiu3.natapp1.cc/api/wxPayNotify |
| | | refundNotifyUrl: http://xiaopiqiu3.natapp1.cc/api/wxRefundNotify |
| | | # notifyUrl: https://dmtest.ahapp.net/bike_h5_api/api/wxPayNotify |
| | | keyPath: D://apiclient_cert.p12 |
| | | privateCertPath: D://apiclient_cert.pem |
| | | privateKeyPath: D://apiclient_key.pem |
| | | # notifyUrl: http://xiaopiqiu3.natapp1.cc/api/wxPayNotify |
| | | # refundNotifyUrl: http://xiaopiqiu3.natapp1.cc/api/wxRefundNotify |
| | | notifyUrl: https://dmtest.ahapp.net/bike_h5_api/api/wxPayNotify |
| | | refundNotifyUrl: https://dmtest.ahapp.net/bike_h5_api/api/wxRefundNotify |
| | | keyPath: /usr/local/aliConfig/bike/apiclient_cert.p12 |
| | | privateCertPath: /usr/local/aliConfig/bike/apiclient_cert.pem |
| | | privateKeyPath: /usr/local/aliConfig/bike/apiclient_key.pem |
| | | #服务商-------------end--- |
| | | existsSub: 1 |
| | | appSecret: 1ceb7c9dff3c4330d653adc3ca55ea24 |
| | |
| | | public ApiResponse<PageData<Discount>> discountPage (@RequestBody PageWrap<Discount> pageWrap) { |
| | | Discount discount = new Discount(); |
| | | discount.setStatus(Constants.ZERO); |
| | | discount.setMinShow(Constants.ZERO); |
| | | pageWrap.setModel(discount); |
| | | return ApiResponse.success(discountService.findPage(pageWrap)); |
| | | } |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true), |
| | | }) |
| | | public ApiResponse openElecBike(@RequestBody OpenElecBikeRequest param) { |
| | | public ApiResponse<MemberRidesDetailResponse> openElecBike(@RequestBody OpenElecBikeRequest param) { |
| | | param.setMemberId(getMemberId()); |
| | | jtt808Service.openLock(param); |
| | | return ApiResponse.success( null); |
| | | return ApiResponse.success(jtt808Service.openLock(param)); |
| | | } |
| | | |
| | | @LoginRequired |
| | |
| | | return ApiResponse.success( null); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "强制还车", notes = "强制还车") |
| | | @PostMapping("/forceBack") |
| | | public ApiResponse forceBack(@RequestBody Goodsorder goodsorder) { |
| | | jtt808Service.forceBack(goodsorder.getId()); |
| | | return ApiResponse.success( null); |
| | | } |
| | | } |
| | |
| | | @Autowired |
| | | private MemberRidesJoinMapper memberRidesJoinMapper; |
| | | |
| | | |
| | | @Autowired |
| | | private PricingParamMapper pricingParamMapper; |
| | | |
| | |
| | | return data; |
| | | } |
| | | |
| | | /** |
| | | * 手动还车 |
| | | * @param param |
| | | */ |
| | | @Transactional(rollbackFor = {BusinessException.class}) |
| | | public void backElecBike(BackElecBikeRequest param) { |
| | | Member member = memberMapper.selectById(param.getMemberId()); |
| | |
| | | gparam.setStatus(Constants.goodsorderStatus.pay); |
| | | gparam.setType(Constants.ZERO); |
| | | Goodsorder goodsorder = goodsorderService.findOne(gparam); |
| | | this.backBike(goodsorder); |
| | | } |
| | | |
| | | /** |
| | | * 自动还车 |
| | | * @param id |
| | | */ |
| | | @Transactional |
| | | public void forceBack(String id){ |
| | | Goodsorder goodsorder = goodsorderService.findById(id); |
| | | this.backBike(goodsorder); |
| | | } |
| | | |
| | | |
| | | @Transactional(rollbackFor = {BusinessException.class}) |
| | | public void backBike(Goodsorder goodsorder){ |
| | | if(Objects.isNull(goodsorder)){ |
| | | throw new BusinessException(ResponseStatus.NO_UNCLOSEED_ORDER.getCode(),"无骑行订单记录"); |
| | | } |
| | |
| | | if(Constants.equalsInteger(rides.getStatus(),Constants.MEMBER_RIDES_STATUS.RIDES_RUNNING.getKey()) |
| | | &&Constants.equalsInteger(rides.getType(),Constants.ONE)){ |
| | | //如果是电车并且是骑行中 进行关锁处理 |
| | | // Bikes bike = getElecBikeByCode(rides.getBikeCode()); |
| | | // //查询停车站点信息 |
| | | // if(bike.getSiteId() ==null){ |
| | | // throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,请按要求前往停车点停车!"); |
| | | // } |
| | | // lockBikes(bike.getDeviceSn(),Constants.ZERO);//发起关锁指令请求 |
| | | Bikes bike = getElecBikeByCode(rides.getBikeCode()); |
| | | //查询停车站点信息 |
| | | if(bike.getSiteId() ==null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,请按要求前往停车点停车!"); |
| | | } |
| | | lockBikes(bike.getDeviceSn(),Constants.ZERO);//发起关锁指令请求 |
| | | backIds.add(rides.getId()); |
| | | rides.setStatus(Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey());//已还车 |
| | | // rides.setBackSiteId(bike.getSiteId());//还车站点 |
| | | rides.setBackSiteId(bike.getSiteId());//还车站点 |
| | | |
| | | rides.setBackDate(new Date()); |
| | | Integer freeRentTime = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME, Constants.FREE_RENT_TIME).getCode()); |
| | |
| | | APIResult<T0201_0500> data = result.block(); |
| | | if(!data.isSuccess()){ |
| | | //如果开锁失败,则返回异常 |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,"+(type ==0?"车辆开锁":"车辆关锁")+"失败,请稍后重试,或者联系园区管理人员!"); |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,"+(type ==0?"车辆关锁":"车辆开锁")+"失败,请稍后重试,或者联系园区管理人员!"); |
| | | } |
| | | } |
| | | |
| | |
| | | Goodsorder gparam = new Goodsorder(); |
| | | gparam.setMemberId(param.getMemberId()); |
| | | gparam.setStatus(Constants.goodsorderStatus.pay); |
| | | gparam.setType(Constants.ZERO); |
| | | Goodsorder goodsorder = goodsorderService.findOne(gparam); |
| | | if(Objects.isNull(goodsorder)){ |
| | | throw new BusinessException(ResponseStatus.NO_UNCLOSEED_ORDER.getCode(),"对不起,未查询到您当前有骑行中订单记录"); |
| | |
| | | if(memberRides ==null || memberRides.getBikeCode() == null){ |
| | | throw new BusinessException(ResponseStatus.NO_UNCLOSEED_ORDER.getCode(),"对不起,未查询到您当前有骑行中记录"); |
| | | } |
| | | // Bikes bike = getElecBikeByCode(memberRides.getBikeCode()); |
| | | // //查询停车位置是否符合停车位置规范 |
| | | // checkPausePostionBiz(bike); |
| | | Bikes bike = getElecBikeByCode(memberRides.getBikeCode()); |
| | | //查询停车位置是否符合停车位置规范 |
| | | checkPausePostionBiz(bike); |
| | | memberRides.setPauseDate(new Date()); |
| | | memberRides.setEditDate(memberRides.getBackDate()); |
| | | memberRides.setStatus(Constants.MEMBER_RIDES_STATUS.RIDES_PAUSING.getKey()); |
| | |
| | | //如果车辆类型是空 |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), " 该车型暂时不能借车操作哦,请更换其他车型重试!"); |
| | | } |
| | | cacheOpenLock.put(bike.getCode(), 1); |
| | | cacheOpenLock.put(openElecBikeRequest.getCode(), 1); |
| | | try { |
| | | //判断当前是否已支付押金 |
| | | Goodsorder goodsorder = goodsorderService.findOneByWrapper(new QueryWrapper<Goodsorder>() |
| | |
| | | //根据车型查询计价方案 |
| | | isValidePricingType(bike,memberRides) ; |
| | | MemberRidesDetailResponse memberRidesDetailResponse = new MemberRidesDetailResponse(); |
| | | // this.lockBikes(bike.getDeviceSn(),1); |
| | | this.lockBikes(bike.getDeviceSn(),1); |
| | | //存储骑行记录 |
| | | memberRides.setId(Constants.getUUID()); |
| | | memberRides.setIsdeleted(Constants.ZERO); |
| | |
| | | memberRidesJoinMapper.insert(memberRides); |
| | | BeanUtils.copyProperties(memberRides, memberRidesDetailResponse); |
| | | return memberRidesDetailResponse; |
| | | }catch (Exception e){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "开锁失败,请联系管理员"); |
| | | }catch (BusinessException biz){ |
| | | throw biz; |
| | | }catch (Exception biz){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR); |
| | | }finally { |
| | | cacheOpenLock.remove(bike.getCode()); |
| | | cacheOpenLock.remove(openElecBikeRequest.getCode()); |
| | | } |
| | | } |
| | | |
| | |
| | | Goodsorder gparam = new Goodsorder(); |
| | | gparam.setMemberId(param.getMemberId()); |
| | | gparam.setStatus(Constants.goodsorderStatus.pay); |
| | | gparam.setType(Constants.ZERO); |
| | | Goodsorder goodsorder = goodsorderService.findOne(gparam); |
| | | if(Objects.isNull(goodsorder)){ |
| | | throw new BusinessException(ResponseStatus.NO_UNCLOSEED_ORDER.getCode(),"对不起,未查询到您当前有骑行中订单记录"); |
| | |
| | | .eq(MemberRides::getIsdeleted,Constants.ZERO) |
| | | .eq(MemberRides::getType,Constants.ONE) |
| | | .eq(MemberRides::getStatus,Constants.MEMBER_RIDES_STATUS.RIDES_PAUSING.getKey()) |
| | | .apply(" NOW() >= t.create_date + INTERVAL '2 hours' ") |
| | | .apply(" NOW() >= (t.create_date + INTERVAL '"+systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.PAUSE_AUTO_CLOSE_TIME).getCode()+" min') ") |
| | | ); |
| | | |
| | | ; |
| | | for (MemberRides timeOutRides:memberRidesList) { |
| | | Goodsorder goodsorder = goodsorderService.findById(timeOutRides.getOrdreId()); |
| | | //查询骑行记录 |
| | |
| | | rides.setStatus(Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey());//已还车 |
| | | rides.setBackSiteId(bike.getSiteId());//还车站点 |
| | | rides.setBackDate(new Date()); |
| | | Integer freeRentTime = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME, Constants.FREE_RENT_TIME).getCode()); |
| | | Integer rideTime = DateUtil.betweenMin(rides.getRentDate(), rides.getBackDate()); |
| | | //计算骑行计费时长 |
| | | rides.setDuration( rideTime > freeRentTime ? rideTime : 0 ); |
| | | rides.setEditDate(rides.getBackDate()); |
| | | memberRidesJoinMapper.updateById(rides);//更新骑行状态为已还车 |
| | | } |
| | |
| | | //发送小程序通知 |
| | | Member member = memberMapper.selectById(goodsorder.getMemberId()); |
| | | if(Objects.nonNull(member)&&StringUtils.isNotBlank(member.getOpenid())){ |
| | | sendWxMessage.bookingsCancel(member.getOpenid(),goodsorder.getId(), WxMiniConfig.wxMaService.getAccessToken(),timeOutRides.getBikeCode(),goodsorder.getPayDate(),goodsorder.getEndDate()); |
| | | sendWxMessage.bookingsCancel(member.getOpenid(),goodsorder.getId(), |
| | | WxMiniConfig.wxMaService.getAccessToken(), |
| | | timeOutRides.getBikeCode(),goodsorder.getPayDate(),goodsorder.getEditDate()); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |