Helius
2021-12-29 1975ada3e42a06d4e3ff1cc36b3613020208ce1b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
 * projectName: zq-erp
 * fileName: TaiYanAliyunSmsService.java
 * packageName: com.matrix.system.hive.service
 * date: 2021-10-28 11:18
 * copyright(c) 2021 http://www.hydee.cn/ Inc. All rights reserved.
 */
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.common.service.BusParameterSettingService;
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;
 
/**
 * @version: V1.0
 * @author: JiangYouYao
 * @className: TaiYanAliyunSmsService
 * @packageName: com.matrix.system.hive.service
 * @description: 肽妍短信提醒服务
 * @data: 2021-10-28 11:18
 **/
@Service
@AllArgsConstructor
public class TaiYanAliyunSmsService {
 
    SysVipInfoDao vipInfoDao;
 
    SmsUtils smsUtils;
 
    SysShopInfoService shopInfoService;
 
    SysBeauticianStateService sysBeauticianStateService;
 
    BusParameterSettingService busParameterSettingService;
    /**
     * 预约成功短信提醒
     *
     * @param services
     */
    @Async
    public void sendYycgNotice(SysProjServices services) {
        //短信接口为肽妍公司定制,暂时写死
        if (chackSetting(services)) return;
 
        SysVipInfo sysVipInfo = vipInfoDao.selectById(services.getVipId());
        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);
        }
 
 
    }
 
 
    /**
     * 项目划扣短信提醒
     *
     * @param services
     */
    @Async
    public void sendHkNotice(SysProjServices services) {
        if (chackSetting(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);
                }
 
            }
        }
 
 
    }
 
    private boolean chackSetting(SysProjServices services) {
        //短信接口为肽妍公司定制,暂时写死
        if (services.getCompanyId() != 17L) {
            return true;
        }
        if (!busParameterSettingService.isSettingOpen(AppConstance.OPEN_SMS_NOTICE, services.getCompanyId())) {
            return true;
        }
        return false;
    }
 
 
}