|
|
@@ -1,5 +1,6 @@
|
|
|
package com.yc.ship.module.trade.service.smsSendconfig;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
@@ -11,6 +12,11 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.yc.ship.framework.common.pojo.PageResult;
|
|
|
import com.yc.ship.framework.common.util.object.BeanUtils;
|
|
|
import com.yc.ship.framework.mybatis.core.util.MyBatisUtils;
|
|
|
+import com.yc.ship.module.system.dal.dataobject.dict.DictDataDO;
|
|
|
+import com.yc.ship.module.system.dal.dataobject.sms.SmsTemplateDO;
|
|
|
+import com.yc.ship.module.system.dal.mysql.dict.DictDataMapper;
|
|
|
+import com.yc.ship.module.system.dal.mysql.sms.SmsTemplateMapper;
|
|
|
+import com.yc.ship.module.system.service.sms.SmsSendService;
|
|
|
import com.yc.ship.module.trade.api.sms.dto.SmsReqDTO;
|
|
|
import com.yc.ship.module.trade.controller.admin.smsSendconfig.vo.SmsSendconfigPageReqVO;
|
|
|
import com.yc.ship.module.trade.controller.admin.smsSendconfig.vo.SmsSendconfigQueryRespVO;
|
|
|
@@ -18,6 +24,7 @@ import com.yc.ship.module.trade.controller.admin.smsSendconfig.vo.SmsSendconfigS
|
|
|
import com.yc.ship.module.trade.dal.dataobject.smsProduct.SmsProductDO;
|
|
|
import com.yc.ship.module.trade.dal.dataobject.smsSendLog.SmsSendLogDO;
|
|
|
import com.yc.ship.module.trade.dal.dataobject.smsSendconfig.SmsSendconfigDO;
|
|
|
+import com.yc.ship.module.trade.dal.mysql.order.TradeOrderMapper;
|
|
|
import com.yc.ship.module.trade.dal.mysql.smsProduct.SmsProductMapper;
|
|
|
import com.yc.ship.module.trade.dal.mysql.smsSendLog.SmsSendLogMapper;
|
|
|
import com.yc.ship.module.trade.dal.mysql.smsSendconfig.SmsSendconfigMapper;
|
|
|
@@ -59,9 +66,20 @@ public class SmsSendconfigServiceImpl implements SmsSendconfigService {
|
|
|
@Resource
|
|
|
private SmsServiceImpl smsService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private SmsSendService smsSendService;
|
|
|
+
|
|
|
@Resource
|
|
|
private SmsSendLogMapper smsSendLogMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TradeOrderMapper tradeOrderMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SmsTemplateMapper smsTemplateMapper;
|
|
|
+ @Resource
|
|
|
+ private DictDataMapper dictDataMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Long createSmsSendconfig(SmsSendconfigSaveReqVO createReqVO) {
|
|
|
// 插入
|
|
|
@@ -285,4 +303,77 @@ public class SmsSendconfigServiceImpl implements SmsSendconfigService {
|
|
|
return new PageResult<>(page.getRecords(), page.getTotal());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param type 1 上水 2 下水
|
|
|
+ * @param code
|
|
|
+ * @param day 天数
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Async
|
|
|
+ public void upSmsSendMsg(int type, String code, int day) {
|
|
|
+ // 查询订单联系人
|
|
|
+ List<Map<String,Object>> linkList = tradeOrderMapper.queryOrderLink(day,type);
|
|
|
+ // 查询接站登记人
|
|
|
+ List<Map<String,Object>> jzPhoneList = tradeOrderMapper.queryOrderJzPhone(day,type);
|
|
|
+ // 查询短信配置
|
|
|
+ SmsTemplateDO smsTemplateDO = smsTemplateMapper.selectByCode(code);
|
|
|
+ // 合并两个列表并去重
|
|
|
+ Set<String> phoneSet = new HashSet<>();
|
|
|
+ Map<String, Map<String, Object>> phoneDataMap = new HashMap<>();
|
|
|
+
|
|
|
+ if (linkList != null) {
|
|
|
+ for (Map<String, Object> map : linkList) {
|
|
|
+ String phone = (String) map.get("link_mobile");
|
|
|
+ if (phone != null && !phone.isEmpty()) {
|
|
|
+ phoneSet.add(phone);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (jzPhoneList != null) {
|
|
|
+ for (Map<String, Object> map : jzPhoneList) {
|
|
|
+ String phone = (String) map.get("phone");
|
|
|
+ if (phone != null && !phone.isEmpty()) {
|
|
|
+ phoneSet.add(phone);
|
|
|
+ if (!phoneDataMap.containsKey(phone)) {
|
|
|
+ phoneDataMap.put(phone, map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> phoneList = new ArrayList<>(phoneSet);
|
|
|
+ List<String> params = smsTemplateDO.getParams();// ["【pick】","【time】"]
|
|
|
+ Map<String, Object> templateParams = new HashMap<>();
|
|
|
+ if(type == 1){
|
|
|
+ // 上水
|
|
|
+ // 获取上水抵达三峡游客中心 查询数据字典
|
|
|
+ List<DictDataDO> arriveDataLis = dictDataMapper.selectListByStatusAndDictType(0, "up_arrive");
|
|
|
+ if(day == -1){
|
|
|
+ // 获取上水登船时间 查询数据字典
|
|
|
+ List<DictDataDO> dictDataList = dictDataMapper.selectListByStatusAndDictType(0, "up_board");
|
|
|
+ templateParams.put(params.get(0), dictDataList.get(0).getLabel());
|
|
|
+ templateParams.put(params.get(1), arriveDataLis.get(0).getLabel());
|
|
|
+ }else{
|
|
|
+ templateParams.put(params.get(0), DateUtil.format(DateUtil.offsetDay(new Date(), day), "yyyy年MM月dd日"));
|
|
|
+ templateParams.put(params.get(1), arriveDataLis.get(0).getLabel());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ // 下水
|
|
|
+ if(day == -1){
|
|
|
+ // 获取下水登船时间 查询数据字典
|
|
|
+ List<DictDataDO> dictDataList = dictDataMapper.selectListByStatusAndDictType(0, "down_board");
|
|
|
+ templateParams.put(params.get(0), dictDataList.get(0).getLabel());
|
|
|
+ }else{
|
|
|
+ templateParams.put(params.get(0), DateUtil.format(DateUtil.offsetDay(new Date(), day), "yyyy年MM月dd日"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(CollectionUtil.isNotEmpty(phoneList)){
|
|
|
+ for(String phone : phoneList){
|
|
|
+// log.info("【短信发送】:phone:{}", phone);
|
|
|
+// log.info("【短信发送】:templateParams:{}", templateParams);
|
|
|
+ smsSendService.sendSingleSmsToAdmin(phone, null, smsTemplateDO.getId(), templateParams);
|
|
|
+ }
|
|
|
+// smsSendService.sendSingleSmsToAdmin("18071246889", null, smsTemplateDO.getId(), templateParams);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|