消息推送
parent
33cdab43d3
commit
d2dfd390b2
|
|
@ -469,6 +469,8 @@ public class OrderPagingResult {
|
|||
*/
|
||||
private String driverPhone;
|
||||
|
||||
private Long driverUserId;
|
||||
|
||||
/**
|
||||
* 驾驶证
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.base.Strings;
|
||||
import com.njzscloud.common.core.ex.Exceptions;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
|
|
@ -27,9 +28,7 @@ import com.njzscloud.common.ws.support.WsMsg;
|
|||
import com.njzscloud.supervisory.biz.constant.AuditStatus;
|
||||
import com.njzscloud.supervisory.biz.constant.BizObj;
|
||||
import com.njzscloud.supervisory.biz.pojo.entity.*;
|
||||
import com.njzscloud.supervisory.biz.service.BizAuditConfigService;
|
||||
import com.njzscloud.supervisory.biz.service.BizWarnService;
|
||||
import com.njzscloud.supervisory.biz.service.TruckLocationTrackService;
|
||||
import com.njzscloud.supervisory.biz.service.*;
|
||||
import com.njzscloud.supervisory.constant.Constant;
|
||||
import com.njzscloud.supervisory.device.pojo.entity.DeviceLocalizerEntity;
|
||||
import com.njzscloud.supervisory.expense.contant.BillingType;
|
||||
|
|
@ -56,10 +55,19 @@ import com.njzscloud.supervisory.order.utils.FileUtil;
|
|||
import com.njzscloud.supervisory.station.pojo.entity.StationManageEntity;
|
||||
import com.njzscloud.supervisory.station.service.StationManageService;
|
||||
import com.njzscloud.supervisory.sys.auth.pojo.result.MyResult;
|
||||
import com.njzscloud.supervisory.sys.role.pojo.entity.RoleEntity;
|
||||
import com.njzscloud.supervisory.sys.role.service.RoleService;
|
||||
import com.njzscloud.supervisory.sys.stationletter.constant.WarnCategory;
|
||||
import com.njzscloud.supervisory.sys.user.pojo.entity.UserEntity;
|
||||
import com.njzscloud.supervisory.sys.user.pojo.result.SysUserRoleEntity;
|
||||
import com.njzscloud.supervisory.sys.user.service.UserRoleService;
|
||||
import com.njzscloud.supervisory.sys.user.service.UserService;
|
||||
import com.njzscloud.supervisory.voicebox.service.CloudVoiceboxService;
|
||||
import com.njzscloud.supervisory.wxPay.contant.TempType;
|
||||
import com.njzscloud.supervisory.wxPay.dto.RefundRequestDto;
|
||||
import com.njzscloud.supervisory.wxPay.param.TemplateMessageParam;
|
||||
import com.njzscloud.supervisory.wxPay.service.PaymentService;
|
||||
import com.njzscloud.supervisory.wxPay.service.WechatTemplateMessageService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
|
@ -99,6 +107,13 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
private final MoneyAccountService moneyAccountService;
|
||||
private final MoneyChangeDetailService moneyChangeDetailService;
|
||||
private final PaymentService paymentService;
|
||||
private final WechatTemplateMessageService wechatTemplateMessageService;
|
||||
private final BizDriverService bizDriverService;
|
||||
private final BizCompanyService bizCompanyService;
|
||||
private final RoleService roleService;
|
||||
private final UserRoleService userRoleService;
|
||||
private final UserService userService;
|
||||
private final BizTruckService bizTruckService;
|
||||
private final AtomicBoolean test_thread_running = new AtomicBoolean(false);
|
||||
Thread test_thread = null;
|
||||
@Value("${app.check-gps:false}")
|
||||
|
|
@ -150,6 +165,18 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
if (transCompanyId != null) {
|
||||
BizCompanyEntity transCompanyEntity = baseMapper.getTransInfo(transCompanyId);
|
||||
cloudVoiceboxService.play(transCompanyEntity.getUserId(), "您有新的待分配订单,请及时处理");
|
||||
// 通知清运公司
|
||||
try {
|
||||
TemplateMessageParam param = new TemplateMessageParam();
|
||||
param.setUserId(transCompanyEntity.getUserId());
|
||||
param.setTempType(TempType.TRANS_COMPANY.getVal());
|
||||
param.setSn(orderInfoEntity.getSn());
|
||||
param.setGoodsName(entity.getGoodsName());
|
||||
param.setStartAddress(cargoPlace.getAreaName() + cargoPlace.getTownName() + cargoPlace.getAddress());
|
||||
wechatTemplateMessageService.sendTemplateMessage(param);
|
||||
} catch (Exception e) {
|
||||
log.error("通知失败", e);
|
||||
}
|
||||
} else {
|
||||
cloudVoiceboxService.play(1L, "您有新的待分配订单,请及时处理");
|
||||
}
|
||||
|
|
@ -593,6 +620,38 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
.setCheckStatus(checkStatus)
|
||||
.setAuditMemo(auditOrderParam.getAuditMemo())
|
||||
);
|
||||
// auditStatus为市待审核状态通知市,通过状态通知司机
|
||||
try {
|
||||
TemplateMessageParam param = new TemplateMessageParam();
|
||||
param.setUserId(detail.getDriverUserId());
|
||||
param.setSn(detail.getSn());
|
||||
OrderGoodsEntity entity = orderGoodsService.getById(detail.getGoodsId());
|
||||
param.setGoodsName(entity.getGoodsName());
|
||||
param.setLicensePlate(detail.getLicensePlate());
|
||||
if (AuditStatus.ShiDaiShenHe.equals(auditStatus)) {
|
||||
param.setCfCompanyName(detail.getNickname());
|
||||
param.setTempType(TempType.AUDIT_PENDING.getVal());
|
||||
RoleEntity roleEntity = roleService.getOne(Wrappers.lambdaQuery(RoleEntity.class).eq(
|
||||
RoleEntity::getRoleCode, config.getCityRole()));
|
||||
List<SysUserRoleEntity> userIds = userRoleService.list(Wrappers.lambdaQuery(SysUserRoleEntity.class)
|
||||
.eq(SysUserRoleEntity::getRoleId, roleEntity.getId()));
|
||||
for (SysUserRoleEntity userRoleEntity : userIds) {
|
||||
param.setUserId(userRoleEntity.getUserId());
|
||||
}
|
||||
wechatTemplateMessageService.sendTemplateMessage(param);
|
||||
} else if (AuditStatus.TongGuo.equals(auditStatus)) {
|
||||
param.setTempType(TempType.AUDIT_OK.getVal());
|
||||
param.setDriverName(detail.getDriverName());
|
||||
param.setEndAddress(detail.getStationName());
|
||||
wechatTemplateMessageService.sendTemplateMessage(param);
|
||||
} else if (AuditStatus.BoHui.equals(auditStatus)) {
|
||||
param.setTempType(TempType.AUDIT_REJECT.getVal());
|
||||
param.setStartAddress(detail.getAreaName() + detail.getTownName() + detail.getAddress());
|
||||
wechatTemplateMessageService.sendTemplateMessage(param);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("通知失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
|
@ -655,6 +714,22 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
.setAssignmentDriverTime(LocalDateTime.now())
|
||||
.setOrderStatus(OrderStatus.DaiJieDan)
|
||||
);
|
||||
// 通知司机
|
||||
try {
|
||||
BizDriverEntity driverEntity = bizDriverService.getById(driverId);
|
||||
TemplateMessageParam param = new TemplateMessageParam();
|
||||
param.setUserId(driverEntity.getUserId());
|
||||
param.setTempType(TempType.DRIVER.getVal());
|
||||
param.setSn(orderInfo.getSn());
|
||||
param.setDriverName(driverEntity.getDriverName());
|
||||
OrderCargoPlaceEntity cargoPlace = orderCargoPlaceService.getById(orderInfo.getCargoPlaceId());
|
||||
param.setStartAddress(cargoPlace.getAreaName() + cargoPlace.getTownName() + cargoPlace.getAddress());
|
||||
BizCompanyEntity companyEntity = bizCompanyService.getById(orderInfo.getStationId());
|
||||
param.setEndAddress(companyEntity.getStationName());
|
||||
wechatTemplateMessageService.sendTemplateMessage(param);
|
||||
} catch (Exception e) {
|
||||
log.error("通知失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean assignmentTrafficCompany(AssignmentOrderParam assignmentOrderParam,
|
||||
|
|
@ -673,7 +748,21 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
);
|
||||
// OrderInfoEntity orderInfoEntity = this.getById(orderInfoId);
|
||||
// settleForTransCompany(orderInfoEntity, 0);
|
||||
|
||||
// 通知清运公司
|
||||
try {
|
||||
TemplateMessageParam param = new TemplateMessageParam();
|
||||
BizCompanyEntity transCompanyEntity = baseMapper.getTransInfo(transCompanyId);
|
||||
param.setUserId(transCompanyEntity.getUserId());
|
||||
param.setTempType(TempType.TRANS_COMPANY.getVal());
|
||||
param.setSn(orderInfo.getSn());
|
||||
OrderGoodsEntity entity = orderGoodsService.getById(orderInfo.getGoodsId());
|
||||
param.setGoodsName(entity.getGoodsName());
|
||||
OrderCargoPlaceEntity cargoPlace = orderCargoPlaceService.getById(orderInfo.getCargoPlaceId());
|
||||
param.setStartAddress(cargoPlace.getAreaName() + cargoPlace.getTownName() + cargoPlace.getAddress());
|
||||
wechatTemplateMessageService.sendTemplateMessage(param);
|
||||
} catch (Exception e) {
|
||||
log.error("通知失败", e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -708,6 +797,38 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
.setTruckId(truckId)
|
||||
.setOrderStatus(OrderStatus.YiJieDan)
|
||||
);
|
||||
try {
|
||||
// 通知审核人
|
||||
RoleEntity roleEntity = new RoleEntity();
|
||||
if (null != bizAuditConfigEntity && !Strings.isNullOrEmpty(bizAuditConfigEntity.getAreaRole())
|
||||
&& AuditStatus.QuDaiShenHe.equals(auditStatus)) {
|
||||
roleEntity = roleService.getOne(Wrappers.lambdaQuery(RoleEntity.class).eq(
|
||||
RoleEntity::getRoleCode, bizAuditConfigEntity.getAreaRole()));
|
||||
} else if (null != bizAuditConfigEntity && !Strings.isNullOrEmpty(bizAuditConfigEntity.getCityRole())
|
||||
&& AuditStatus.ShiDaiShenHe.equals(auditStatus)) {
|
||||
roleEntity = roleService.getOne(Wrappers.lambdaQuery(RoleEntity.class).eq(
|
||||
RoleEntity::getRoleCode, bizAuditConfigEntity.getCityRole()));
|
||||
}
|
||||
if (null != roleEntity && null != roleEntity.getId()) {
|
||||
List<SysUserRoleEntity> userIds = userRoleService.list(Wrappers.lambdaQuery(SysUserRoleEntity.class)
|
||||
.eq(SysUserRoleEntity::getRoleId, roleEntity.getId()));
|
||||
TemplateMessageParam param = new TemplateMessageParam();
|
||||
param.setTempType(TempType.AUDIT_PENDING.getVal());
|
||||
param.setSn(orderInfo.getSn());
|
||||
OrderGoodsEntity entity = orderGoodsService.getById(orderInfo.getGoodsId());
|
||||
param.setGoodsName(entity.getGoodsName());
|
||||
BizTruckEntity truckEntity = bizTruckService.getById(orderInfo.getTruckId());
|
||||
param.setLicensePlate(truckEntity.getLicensePlate());
|
||||
for (SysUserRoleEntity userRoleEntity : userIds) {
|
||||
UserEntity userEntity = userService.getById(userRoleEntity.getUserId());
|
||||
param.setUserId(userRoleEntity.getUserId());
|
||||
param.setCfCompanyName(userEntity.getNickname());
|
||||
wechatTemplateMessageService.sendTemplateMessage(param);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("通知失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
|
@ -1426,7 +1547,7 @@ public class OrderInfoService extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||
LocalDateTime endTime = searchParam.getEndTime();
|
||||
QueryWrapper<OrderPagingResult> ew = Wrappers.query();
|
||||
ew.like(StrUtil.isNotBlank(searchParam.getSn()), "a.sn", searchParam.getSn());
|
||||
ew.like(StrUtil.isNotBlank(searchParam.getLicensePlate()), "e.license_plate", searchParam.getLicensePlate());
|
||||
ew.like(StrUtil.isNotBlank(searchParam.getLicensePlate()), "d.license_plate", searchParam.getLicensePlate());
|
||||
ew.like(StrUtil.isNotBlank(searchParam.getPhone()), "a.phone", searchParam.getPhone());
|
||||
ew.like(StrUtil.isNotBlank(searchParam.getNickname()), "a.contacts", searchParam.getNickname());
|
||||
ew.ge(startTime != null, "a.create_time", startTime);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.njzscloud.supervisory.wxPay.contant;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* 推送类型
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum TempType {
|
||||
TRANS_COMPANY("transCompany", "清运公司"),// 清运公司
|
||||
DRIVER("driver", "司机"), // 司机
|
||||
AUDIT_PENDING("auditPending", "待审核"),
|
||||
AUDIT_OK("auditOk", "审核通过"),
|
||||
AUDIT_REJECT("auditReject", "审核驳回"),
|
||||
;
|
||||
private final String val;
|
||||
private final String txt;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.njzscloud.supervisory.wxPay.contant;
|
||||
|
||||
public class TemplateID {
|
||||
|
||||
public static final String TRANS_COMPANY_TEMP_ID = "PAqlS9-hKgKB_Li8Nx4hgMXBp9kOTFrCD_scJtBC1fM";
|
||||
|
||||
public static final String DRIVER_TEMP_ID = "IwHV1nWwu8pO8Ppntyd7KzzV5S00dOEjbsgAFhz9tJM";
|
||||
|
||||
public static final String AUDIT_PENDING = "0SzJv9l51KTvgXvKhQOwifR5pegR3gC1o3IAY8NpEcE";
|
||||
|
||||
public static final String AUDIT_OK = "3peGD6joWVyZ7B29lfJH_gK0oRqharynt0sXlIHE4cg";
|
||||
|
||||
public static final String AUDIT_REJECT = "vDFOJjrB3VNKGIRe5I_LOrfIPDTTdlZoL537CYqjW64";
|
||||
|
||||
}
|
||||
|
|
@ -1,15 +1,12 @@
|
|||
package com.njzscloud.supervisory.wxPay.controller;
|
||||
|
||||
import com.njzscloud.common.core.utils.R;
|
||||
import com.njzscloud.supervisory.wxPay.dto.TemplateData;
|
||||
import com.njzscloud.supervisory.wxPay.param.TemplateMessageParam;
|
||||
import com.njzscloud.supervisory.wxPay.service.WechatTemplateMessageService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付相关接口
|
||||
* 使用微信支付官方SDK的生产级实现
|
||||
|
|
@ -32,21 +29,11 @@ public class WechatTemplateMessageController {
|
|||
}
|
||||
|
||||
@PostMapping("/send-order-notice")
|
||||
public String sendOrderNotice(@RequestParam String openId) {
|
||||
public String sendOrderNotice(@RequestBody TemplateMessageParam param) {
|
||||
try {
|
||||
// 构建模板数据
|
||||
Map<String, TemplateData> data = new HashMap<>();
|
||||
data.put("first", new TemplateData("下单待审核通知"));
|
||||
data.put("character_string6", new TemplateData("202312010001"));
|
||||
data.put("thing4", new TemplateData("LuanMa"));
|
||||
data.put("time5", new TemplateData("2023-12-01 10:30:00"));
|
||||
data.put("remark", new TemplateData("感谢您的购买!"));
|
||||
|
||||
// 发送模板消息
|
||||
String templateId = "HXr8xxYERp2TrkdfBgdRJGSJeMT_8mXF7Yjz6NDBUFw"; // 在公众号后台获取
|
||||
|
||||
return wechatTemplateMessageService.sendTemplateMessage(openId, templateId, data,
|
||||
null, null);
|
||||
wechatTemplateMessageService.sendTemplateMessage(param);
|
||||
return "发送成功";
|
||||
} catch (Exception e) {
|
||||
return "发送失败: " + e.getMessage();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
package com.njzscloud.supervisory.wxPay.param;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class TemplateMessageParam {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 推送类型
|
||||
*/
|
||||
private String tempType;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 货物名称
|
||||
*/
|
||||
private String goodsName;
|
||||
|
||||
/**
|
||||
* 装货地点
|
||||
*/
|
||||
private String startAddress;
|
||||
|
||||
/**
|
||||
* 卸货地点
|
||||
*/
|
||||
private String endAddress;
|
||||
|
||||
/**
|
||||
* 司机名称
|
||||
*/
|
||||
private String driverName;
|
||||
|
||||
/**
|
||||
* 产废单位
|
||||
*/
|
||||
private String cfCompanyName;
|
||||
|
||||
/**
|
||||
* 车牌号
|
||||
*/
|
||||
private String licensePlate;
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.njzscloud.supervisory.wxPay.service;
|
||||
|
||||
import com.njzscloud.supervisory.wxPay.dto.TemplateData;
|
||||
import com.njzscloud.supervisory.wxPay.param.TemplateMessageParam;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -11,8 +13,10 @@ public interface WechatTemplateMessageService {
|
|||
|
||||
void bind(String code);
|
||||
|
||||
String sendTemplateMessage(String openId, String templateId,
|
||||
Map<String, TemplateData> data,
|
||||
String url, String miniProgram);
|
||||
/**
|
||||
* 发送消息
|
||||
*/
|
||||
@Async
|
||||
void sendTemplateMessage(TemplateMessageParam param);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,23 @@
|
|||
package com.njzscloud.supervisory.wxPay.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.base.Strings;
|
||||
import com.njzscloud.common.core.ex.Exceptions;
|
||||
import com.njzscloud.common.security.util.SecurityUtil;
|
||||
import com.njzscloud.supervisory.sys.user.pojo.entity.UserEntity;
|
||||
import com.njzscloud.supervisory.sys.user.service.UserService;
|
||||
import com.njzscloud.supervisory.wxPay.contant.TempType;
|
||||
import com.njzscloud.supervisory.wxPay.contant.TemplateID;
|
||||
import com.njzscloud.supervisory.wxPay.contant.WxApiConfig;
|
||||
import com.njzscloud.supervisory.wxPay.dto.TemplateData;
|
||||
import com.njzscloud.supervisory.wxPay.param.TemplateMessageParam;
|
||||
import com.njzscloud.supervisory.wxPay.service.WechatTemplateMessageService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -23,7 +28,7 @@ import java.util.Map;
|
|||
@RequiredArgsConstructor
|
||||
public class WechatTemplateMessageServiceImpl implements WechatTemplateMessageService {
|
||||
|
||||
public final UserService userService;
|
||||
private final UserService userService;
|
||||
|
||||
@Override
|
||||
public void bind(String code) {
|
||||
|
|
@ -62,15 +67,76 @@ public class WechatTemplateMessageServiceImpl implements WechatTemplateMessageSe
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTemplateMessage(TemplateMessageParam param) {
|
||||
// UserEntity userEntity = userService.getById(param.getUserId());
|
||||
UserEntity userEntity = new UserEntity();
|
||||
userEntity.setOpenid("owC-r2Bf1axK1C2MQ6nOaCDbKuHw");
|
||||
if (null != userEntity && !Strings.isNullOrEmpty(userEntity.getOpenid())) {
|
||||
Map<String, TemplateData> data;
|
||||
if (TempType.TRANS_COMPANY.getVal().equals(param.getTempType())) {
|
||||
// 通知清运公司指派司机
|
||||
// 构建模板数据
|
||||
data = new HashMap<>();
|
||||
data.put("character_string2", new TemplateData(param.getSn()));
|
||||
data.put("thing19", new TemplateData(param.getGoodsName()));
|
||||
data.put("thing4", new TemplateData(param.getStartAddress()));
|
||||
sendMessage(userEntity.getOpenid(), TemplateID.TRANS_COMPANY_TEMP_ID, data, null, null);
|
||||
} else if (TempType.DRIVER.getVal().equals(param.getTempType())) {
|
||||
// 通知司机
|
||||
// 构建模板数据
|
||||
data = new HashMap<>();
|
||||
data.put("character_string5", new TemplateData(param.getSn()));
|
||||
data.put("thing7", new TemplateData(param.getDriverName()));
|
||||
data.put("thing2", new TemplateData(param.getStartAddress()));
|
||||
data.put("thing3", new TemplateData(param.getEndAddress()));
|
||||
sendMessage(userEntity.getOpenid(), TemplateID.DRIVER_TEMP_ID, data, null, null);
|
||||
} else if (TempType.AUDIT_PENDING.getVal().equals(param.getTempType())) {
|
||||
// 待审核
|
||||
// 构建模板数据
|
||||
data = new HashMap<>();
|
||||
data.put("character_string5", new TemplateData(param.getSn()));
|
||||
data.put("thing11", new TemplateData(param.getGoodsName()));
|
||||
data.put("thing9", new TemplateData(param.getCfCompanyName()));
|
||||
data.put("car_number13", new TemplateData(param.getLicensePlate()));
|
||||
sendMessage(userEntity.getOpenid(), TemplateID.AUDIT_PENDING, data, null, null);
|
||||
} else if (TempType.AUDIT_OK.getVal().equals(param.getTempType())) {
|
||||
// 审核通过
|
||||
// 构建模板数据
|
||||
data = new HashMap<>();
|
||||
data.put("character_string1", new TemplateData(param.getSn()));
|
||||
data.put("thing4", new TemplateData(param.getGoodsName()));
|
||||
data.put("thing8", new TemplateData(param.getDriverName()));
|
||||
data.put("car_number7", new TemplateData(param.getLicensePlate()));
|
||||
data.put("thing3", new TemplateData(param.getEndAddress()));
|
||||
sendMessage(userEntity.getOpenid(), TemplateID.AUDIT_OK, data, null, null);
|
||||
} else if (TempType.AUDIT_REJECT.getVal().equals(param.getTempType())) {
|
||||
// 审核驳回
|
||||
// 构建模板数据
|
||||
data = new HashMap<>();
|
||||
data.put("character_string8", new TemplateData(param.getSn()));
|
||||
data.put("thing4", new TemplateData(param.getGoodsName()));
|
||||
data.put("thing2", new TemplateData(param.getStartAddress()));
|
||||
sendMessage(userEntity.getOpenid(), TemplateID.AUDIT_REJECT, data, null, null);
|
||||
}
|
||||
} else {
|
||||
log.info("未查询到用户信息或不存在openid,无法通知");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送模板消息
|
||||
*/
|
||||
@Override
|
||||
public String sendTemplateMessage(String openId, String templateId,
|
||||
public void sendMessage(String openId, String templateId,
|
||||
Map<String, TemplateData> data,
|
||||
String url, String miniProgram) {
|
||||
// 1. 获取Access Token
|
||||
String accessToken = getAccessToken();
|
||||
if (Strings.isNullOrEmpty(accessToken)) {
|
||||
log.error("获取Access Token失败");
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 构建请求数据
|
||||
JSONObject requestData = new JSONObject();
|
||||
|
|
@ -108,12 +174,11 @@ public class WechatTemplateMessageServiceImpl implements WechatTemplateMessageSe
|
|||
// 5. 处理响应
|
||||
JSONObject jsonResponse = JSONObject.parseObject(response);
|
||||
if (null == jsonResponse) {
|
||||
throw Exceptions.clierr("发送模板消息失败,jsonResponse为null");
|
||||
log.error("发送模板消息失败,jsonResponse为null");
|
||||
return;
|
||||
}
|
||||
if (jsonResponse.getIntValue("errcode") == 0) {
|
||||
return "发送成功";
|
||||
} else {
|
||||
throw Exceptions.clierr("发送模板消息失败: " + jsonResponse.getString("errmsg"));
|
||||
if (jsonResponse.getIntValue("errcode") != 0) {
|
||||
log.error("发送模板消息失败: " + jsonResponse.getString("errmsg"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,10 +192,12 @@ public class WechatTemplateMessageServiceImpl implements WechatTemplateMessageSe
|
|||
String response = restTemplate.getForObject(tokenUrl, String.class);
|
||||
JSONObject jsonResponse = JSONObject.parseObject(response);
|
||||
if (null == jsonResponse) {
|
||||
throw Exceptions.clierr("获取Access Token失败");
|
||||
log.error("获取Access Token失败");
|
||||
return "";
|
||||
}
|
||||
if (jsonResponse.getIntValue("errcode") != 0) {
|
||||
throw Exceptions.clierr("发送模板消息失败: " + jsonResponse.getString("errmsg"));
|
||||
log.error("发送模板消息失败: " + jsonResponse.getString("errmsg"));
|
||||
return "";
|
||||
}
|
||||
return jsonResponse.getString("access_token");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
og.goods_name,
|
||||
bp.project_name,
|
||||
bc1.company_name AS trans_company_name,
|
||||
bc2.company_name AS cf_company_name,
|
||||
bc2.nickname AS cf_company_name,
|
||||
bt.license_plate,
|
||||
bt.picture truck_picture,
|
||||
bt.carrying_capacity,
|
||||
|
|
@ -66,7 +66,7 @@
|
|||
LEFT JOIN order_goods og ON oi.goods_id = og.id
|
||||
LEFT JOIN biz_project bp ON oi.project_id = bp.id AND bp.deleted = 0
|
||||
LEFT JOIN biz_company bc1 ON oi.trans_company_id = bc1.id AND bc1.deleted = 0
|
||||
LEFT JOIN biz_company bc2 ON oi.user_id = bc2.user_id AND bc2.deleted = 0
|
||||
LEFT JOIN sys_user bc2 ON oi.user_id = bc2.id AND bc2.deleted = 0
|
||||
LEFT JOIN biz_truck bt ON oi.truck_id = bt.id AND bt.deleted = 0
|
||||
LEFT JOIN biz_driver bd ON oi.driver_id = bd.id AND bd.deleted = 0
|
||||
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
|
||||
|
|
@ -96,7 +96,7 @@
|
|||
og.goods_name,
|
||||
bp.project_name,
|
||||
bc1.company_name AS trans_company_name,
|
||||
bc2.company_name AS cf_company_name,
|
||||
bc2.nickname AS cf_company_name,
|
||||
bt.license_plate,
|
||||
bt.picture,
|
||||
bt.carrying_capacity,
|
||||
|
|
@ -109,7 +109,7 @@
|
|||
LEFT JOIN order_goods og ON oi.goods_id = og.id
|
||||
LEFT JOIN biz_project bp ON oi.project_id = bp.id AND bp.deleted = 0
|
||||
LEFT JOIN biz_company bc1 ON oi.trans_company_id = bc1.id AND bc1.deleted = 0
|
||||
LEFT JOIN biz_company bc2 ON oi.user_id = bc2.user_id AND bc2.deleted = 0
|
||||
LEFT JOIN sys_user bc2 ON oi.user_id = bc2.id AND bc2.deleted = 0
|
||||
LEFT JOIN biz_truck bt ON oi.truck_id = bt.id AND bt.deleted = 0
|
||||
LEFT JOIN biz_driver bd ON oi.driver_id = bd.id AND bd.deleted = 0
|
||||
WHERE bw.id = #{id} AND bw.deleted = 0
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@
|
|||
e.tare_weight history_tare_weight,
|
||||
p.txt truck_category,
|
||||
e.picture truck_picture,
|
||||
f.user_id driver_user_id,
|
||||
f.driver_name,
|
||||
f.phone driver_phone,
|
||||
f.driving_licence,
|
||||
|
|
@ -231,7 +232,7 @@
|
|||
e.txt AS truck_category,
|
||||
a.estimated_quantity,
|
||||
TIME_FORMAT( f.in_time, '%H:%i' ) AS in_time,
|
||||
g.company_name AS cf_company_name,
|
||||
g.nickname AS cf_company_name,
|
||||
h.area_name,
|
||||
ROUND( f.rough_weight / 1000, 2 ) AS rough_weight,
|
||||
ROUND( f.tare_weight / 1000, 2 ) AS tare_weight,
|
||||
|
|
@ -246,7 +247,7 @@
|
|||
LEFT JOIN sys_dict_item e ON d.truck_category = e.val
|
||||
AND e.dict_key = 'vehicle_type'
|
||||
LEFT JOIN order_car_in_out f ON f.id = a.car_in_out_id
|
||||
LEFT JOIN biz_company g ON a.user_id = g.user_id
|
||||
LEFT JOIN sys_user g ON a.user_id = g.id
|
||||
LEFT JOIN order_cargo_place h ON h.id = a.cargo_place_id
|
||||
LEFT JOIN biz_driver i ON i.id = a.driver_id
|
||||
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
|
||||
|
|
|
|||
Loading…
Reference in New Issue