| | |
| | | //车辆类型数据 |
| | | public static final String BIKE_TYPE ="0,1,2,3,4,5,6,7,8" ; |
| | | public static final String MINI_PROGRAMME_REALEASE ="MINI_PROGRAMME_REALEASE" ; |
| | | public static final String TIME_OUT_TEMPID ="TIME_OUT_TEMPID" ; |
| | | |
| | | public static final int FOUR =4 ; |
| | | public static final String PAUSE_BIKE_TYPE ="PAUSE_BIKE_TYPE" ; |
| | | public static final String HEART_TIME_EXPIRE_TIME ="HEART_TIME_EXPIRE_TIME" ; |
| | |
| | | package com.doumee.core.wx; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | |
| | | @Slf4j |
| | | public class SendWxMessage { |
| | | |
| | | private static String programUrl = "packagesMine/meetingDetails/meetingDetails?id="; |
| | | private static String goodsOrderUrl = "pages/settlementDetails/settlementDetails?goodsOrderId="; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | public void bookingsCancel(String openid, String goodsOrderId, String accessToken, String bikeCode, Date startTime, Date endTime){ |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | log.info("微信小程序->微信消息通知 临时锁车超时 -> accessToken:{}",accessToken); |
| | | //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取) |
| | | String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken; |
| | | //拼接推送的模版 |
| | | WxMsgVO wxMsgVo = new WxMsgVO(); |
| | | //用户的openid(要发送给那个用户) |
| | | wxMsgVo.setTouser(openid); |
| | | //订阅消息模板id |
| | | wxMsgVo.setTemplate_id(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.TIME_OUT_TEMPID).getCode()); |
| | | 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("date4", new TemplateData(DateUtil.getDate(endTime,"yyyy-MM-dd HH:mm"))); |
| | | //温馨提醒 |
| | | m.put("thing5", new TemplateData("临时锁车已超过最大时长,已自动还车")); |
| | | wxMsgVo.setPage(goodsOrderUrl + goodsOrderId); |
| | | wxMsgVo.setData(m); |
| | | ResponseEntity<String> responseEntity = |
| | | restTemplate.postForEntity(url, wxMsgVo, String.class); |
| | | log.info("微信小程序->微信消息通知 临时锁车超时:{}", JSONObject.toJSONString(responseEntity)); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | "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) |
| | | .ge(DiscountMember::getUseStartDate, Utils.Date.getStart(DateUtil.StringToDate(today))) |
| | | .le(DiscountMember::getUseEndDate, Utils.Date.getEnd(DateUtil.StringToDate(today))) |
| | | .ge(DiscountMember::getUseStartDate, Utils.Date.getStart(DateUtil.stringToDate(today,"yyyy-MM-dd"))) |
| | | .le(DiscountMember::getUseEndDate, Utils.Date.getEnd(DateUtil.stringToDate(today,"yyyy-MM-dd"))) |
| | | .eq(Constants.equalsInteger(holiday,Constants.ONE),DiscountMember::getUseHoliday,Constants.ONE) |
| | | .orderByDesc(DiscountMember::getLimitType) |
| | | .orderByDesc(DiscountMember::getLimitTime) |
| | |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.PositionUtil; |
| | | import com.doumee.core.utils.StringTools; |
| | | import com.doumee.core.wx.SendWxMessage; |
| | | import com.doumee.core.wx.WxMiniConfig; |
| | | import com.doumee.core.wx.WxMiniUtilService; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.join.BikesJoinMapper; |
| | |
| | | import com.doumee.service.business.GoodsorderService; |
| | | import com.doumee.service.business.PricingRuleService; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import me.chanjar.weixin.common.error.WxErrorException; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Autowired |
| | | private HolidaysMapper holidaysMapper; |
| | | |
| | | @Autowired |
| | | private SendWxMessage sendWxMessage; |
| | | |
| | | |
| | | @Autowired |
| | |
| | | /** |
| | | * 临时停车超时 自动还车 |
| | | */ |
| | | public void autoBackBike(){ |
| | | public void autoBackBike() throws WxErrorException { |
| | | List<MemberRides> memberRidesList = memberRidesJoinMapper.selectJoinList(MemberRides.class,new MPJLambdaWrapper<MemberRides>() |
| | | .selectAll(MemberRides.class) |
| | | .leftJoin(Goodsorder.class,Goodsorder::getId,MemberRides::getOrdreId) |
| | |
| | | goodsorder.setEditDate(date); |
| | | goodsorder.setEditor(null); |
| | | goodsorderService.dealCloseGoodsorderBiz( goodsorder,Constants.REFUND_TYPE.NORMAL.getKey(),memberRides); |
| | | //发送小程序通知 |
| | | 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()); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | // } |
| | | |
| | | |
| | | @Scheduled(fixedDelay = 1000L * 5L ) |
| | | @Scheduled(fixedDelay = 1000L * 100L ) |
| | | public void autoBackBike() throws Exception { |
| | | log.info("=====================临时停车超时 自动还车===========start============"); |
| | | jtt808Service.autoBackBike(); |