From f379de6364a7f3b4ddc397d4bf6f70ab13bf6618 Mon Sep 17 00:00:00 2001
From: 935090232@qq.com <ak473600000>
Date: Thu, 28 Oct 2021 14:03:54 +0800
Subject: [PATCH] 实现简单短信提醒
---
zq-erp/src/test/java/com/matrix/ParameterSettingsTool.java | 13 ++++
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java | 2
zq-erp/src/main/resources/templates/views/admin/shop/parameterSetting-form.html | 8 ++
zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java | 8 ++
zq-erp/src/main/java/com/matrix/system/hive/service/TaiYanAliyunSmsService.java | 111 ++++++++++++++++++++++++++++--------
zq-erp/src/test/java/com/matrix/TaiYanAliyunSmsServiceTest.java | 2
6 files changed, 119 insertions(+), 25 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java b/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java
index 5fecc8b..82a26fc 100644
--- a/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java
+++ b/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java
@@ -582,6 +582,14 @@
* 门店是否只能取消待付款订单,服务单
*/
public static final String SHOP_MANAGE_ABLE_CANCEL_DFK_ORDER = "shopManageAbleCancelDfkOrder";
+ /**
+ * 服务记录跟进模板
+ */
+ public static final String SERVICE_FLOW_TEMPLATE = "SERVICE_FLOW_TEMPLATE";
+ /**
+ * 开启短信提醒
+ */
+ public static final String OPEN_SMS_NOTICE = "OPEN_SMS_NOTICE";
/**
* 赠送金额购买产品算赠送购买
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/TaiYanAliyunSmsService.java b/zq-erp/src/main/java/com/matrix/system/hive/service/TaiYanAliyunSmsService.java
index 828f1ad..382487a 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/TaiYanAliyunSmsService.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/TaiYanAliyunSmsService.java
@@ -8,20 +8,24 @@
package com.matrix.system.hive.service;
import com.google.common.collect.Maps;
+import com.matrix.core.tools.DateUtil;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.SmsUtils;
import com.matrix.core.tools.StringUtils;
+import com.matrix.system.common.bean.BusParameterSettings;
+import com.matrix.system.common.constance.AppConstance;
+import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.hive.bean.SysBeauticianState;
import com.matrix.system.hive.bean.SysProjServices;
+import com.matrix.system.hive.bean.SysShopInfo;
import com.matrix.system.hive.bean.SysVipInfo;
import com.matrix.system.hive.dao.SysVipInfoDao;
import lombok.AllArgsConstructor;
-import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
-import java.util.stream.Collectors;
/**
* @version: V1.0
@@ -39,40 +43,97 @@
SmsUtils smsUtils;
+ SysShopInfoService shopInfoService;
+
SysBeauticianStateService sysBeauticianStateService;
+
+ BusParameterSettingsDao busParameterSettingsDao;
/**
* 预约成功短信提醒
+ *
* @param services
*/
- @Async
+// @Async
public void sendYycgNotice(SysProjServices services) {
-
//短信接口为肽妍公司定制,暂时写死
- if(services.getCompanyId()!=17L){
+ if (services.getCompanyId() != 17L) {
return;
}
-
+ if (isCloseSmsNotice(services)){
+ return;
+ }
SysVipInfo sysVipInfo = vipInfoDao.selectById(services.getVipId());
-
- HashMap<String, String> param = Maps.newHashMap();
-
- List<SysBeauticianState> sysBeauticianStates = sysBeauticianStateService.findBySerId(services.getId());
-
- String projNames = sysBeauticianStates.stream().map(item -> {
- if(item.getProjInfo()!=null){
- return item.getProjInfo().getName();
- }else{
- return "";
- }
- } ).collect(Collectors.joining(","));
-
- LogUtil.debug("发送阿里云短信手机号{},项目{}",sysVipInfo.getPhone(), projNames);
- if(StringUtils.isNotBlank(projNames)
- && StringUtils.isNotBlank(sysVipInfo.getPhone())){
- param.put("projName",projNames);
- smsUtils.sendSms(sysVipInfo.getPhone(),"SMS_227005614",param);
+ SysShopInfo shopInfo = shopInfoService.findById(services.getShopId());
+ String date = DateUtil.dateFormatStr(new Date(), "yyyy年MM月dd日");
+ LogUtil.debug("发送阿里云预约成功短信,手机号={}", sysVipInfo.getPhone());
+ if (StringUtils.isNotBlank(sysVipInfo.getPhone())) {
+ HashMap<String, String> param = Maps.newHashMap();
+ param.put("date", date);
+ param.put("tel", shopInfo.getShopTel());
+ param.put("shopName", shopInfo.getShopName());
+ smsUtils.sendSms(sysVipInfo.getPhone(), "SMS_226995798", param);
}
+
}
-}
\ No newline at end of file
+
+
+ /**
+ * 判断是否开启了短信提醒
+ * @param services
+ * @return
+ */
+ private boolean isCloseSmsNotice(SysProjServices services) {
+ BusParameterSettings openSmsNoticeSetting = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.OPEN_SMS_NOTICE, services.getCompanyId());
+ if (StringUtils.isBlank(openSmsNoticeSetting.getParamValue())
+ || AppConstance.IS_N.equals(openSmsNoticeSetting.getParamValue())) {
+ LogUtil.debug("未开启短信提醒");
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * 项目划扣短信提醒
+ *
+ * @param services
+ */
+// @Async
+ public void sendHkNotice(SysProjServices services) {
+ //短信接口为肽妍公司定制,暂时写死
+ if (services.getCompanyId() != 17L) {
+ return;
+ }
+ if (isCloseSmsNotice(services)){
+ return;
+ }
+ SysVipInfo sysVipInfo = vipInfoDao.selectById(services.getVipId());
+ SysShopInfo shopInfo = shopInfoService.findById(services.getShopId());
+ String date = DateUtil.dateFormatStr(new Date(), "yyyy年MM月dd日");
+
+ List<SysBeauticianState> items = sysBeauticianStateService.findBySerId(services.getId());
+ for (SysBeauticianState item : items) {
+ if (item.getProjInfo() != null) {
+ String projName = item.getProjInfo().getName();
+ LogUtil.debug("发送阿里云项目划扣短信,手机号={}", sysVipInfo.getPhone());
+ if (StringUtils.isNotBlank(sysVipInfo.getPhone())) {
+ HashMap<String, String> param = Maps.newHashMap();
+ param.put("date", date);
+ param.put("projName", projName);
+ param.put("count", item.getCount() + "");
+ param.put("balanceCount", item.getProjUse().getSurplusCount() + "");
+ param.put("tel", shopInfo.getShopTel());
+ param.put("shopName", shopInfo.getShopName());
+ smsUtils.sendSms(sysVipInfo.getPhone(), "SMS_226995796", param);
+ }
+
+ }
+ }
+
+
+ }
+
+
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java
index 83bdf21..efb59fb 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java
@@ -661,6 +661,8 @@
UniformMsgParam uniformMsgParam = new UniformMsgParam(projServices.getCompanyId(), UniformMsgParam.GZH_FWWC);
uniformMsgParam.put("serviceId", projServices.getId());
asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam);
+ //发送划扣短信提醒
+ taiYanAliyunSmsService.sendHkNotice(projServices);
return result;
}
diff --git a/zq-erp/src/main/resources/templates/views/admin/shop/parameterSetting-form.html b/zq-erp/src/main/resources/templates/views/admin/shop/parameterSetting-form.html
index 751099b..0fbaf6f 100644
--- a/zq-erp/src/main/resources/templates/views/admin/shop/parameterSetting-form.html
+++ b/zq-erp/src/main/resources/templates/views/admin/shop/parameterSetting-form.html
@@ -71,6 +71,14 @@
</el-checkbox-group>
</div>
</div>
+
+ <div class="form-group" v-if="paramSetting.type==5">
+ <label class="col-md-2 control-label">{{paramSetting.name}}</label>
+ <div class="col-md-8">
+ <el-input type="textarea" :rows="2" v-model="paramSetting.userValue"></el-input>
+ </div>
+ </div>
+
</template>
diff --git a/zq-erp/src/test/java/com/matrix/ParameterSettingsTool.java b/zq-erp/src/test/java/com/matrix/ParameterSettingsTool.java
index a3fab25..99c0860 100644
--- a/zq-erp/src/test/java/com/matrix/ParameterSettingsTool.java
+++ b/zq-erp/src/test/java/com/matrix/ParameterSettingsTool.java
@@ -105,6 +105,19 @@
newSetting8.setCategory("店务配置");
newSettings.add(newSetting8);
+ ParameterSettings newSetting9=new ParameterSettings();
+ newSetting9.setCode(AppConstance.SERVICE_FLOW_TEMPLATE);
+ newSetting9.setName("跟进记录模板");
+ newSetting9.setType(5);
+ newSetting9.setCategory("店务配置");
+ newSettings.add(newSetting9);
+
+ ParameterSettings newSetting10=new ParameterSettings();
+ newSetting10.setCode(AppConstance.OPEN_SMS_NOTICE);
+ newSetting10.setName("是否开启短信提醒");
+ newSetting10.setType(1);
+ newSetting10.setCategory("店务配置");
+ newSettings.add(newSetting10);
for (ParameterSettings newSetting : newSettings) {
List<ParameterSettings> parameterSettings = parameterSettingsDao.selectByModel(newSetting);
diff --git a/zq-erp/src/test/java/com/matrix/TaiYanAliyunSmsServiceTest.java b/zq-erp/src/test/java/com/matrix/TaiYanAliyunSmsServiceTest.java
index 5f2690e..58b7772 100644
--- a/zq-erp/src/test/java/com/matrix/TaiYanAliyunSmsServiceTest.java
+++ b/zq-erp/src/test/java/com/matrix/TaiYanAliyunSmsServiceTest.java
@@ -31,6 +31,8 @@
SysProjServices byId = projServicesService.findById(215550L);
byId.setVipId(5949L);
taiYanAliyunSmsService.sendYycgNotice(byId);
+ taiYanAliyunSmsService.sendHkNotice(byId);
+
}
--
Gitblit v1.9.1