|
@@ -8,9 +8,18 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
8
|
8
|
import com.huiju.estateagents.base.BaseController;
|
9
|
9
|
import com.huiju.estateagents.base.ResponseBean;
|
10
|
10
|
import com.huiju.estateagents.common.CommConstant;
|
|
11
|
+import com.huiju.estateagents.common.SMSUtils;
|
11
|
12
|
import com.huiju.estateagents.common.StringUtils;
|
|
13
|
+import com.huiju.estateagents.entity.SysSmsSetting;
|
|
14
|
+import com.huiju.estateagents.mapper.SysSmsSettingMapper;
|
|
15
|
+import com.huiju.estateagents.sample.entity.TaContact;
|
12
|
16
|
import com.huiju.estateagents.sample.entity.TaH5Demand;
|
|
17
|
+import com.huiju.estateagents.sample.entity.TaH5Sample;
|
|
18
|
+import com.huiju.estateagents.sample.entity.TaSampleContact;
|
|
19
|
+import com.huiju.estateagents.sample.service.ITaContactService;
|
13
|
20
|
import com.huiju.estateagents.sample.service.ITaH5DemandService;
|
|
21
|
+import com.huiju.estateagents.sample.service.ITaH5SampleService;
|
|
22
|
+import com.huiju.estateagents.sample.service.ITaSampleContactService;
|
14
|
23
|
import com.huiju.estateagents.service.ITaOrgService;
|
15
|
24
|
import org.apache.poi.ss.formula.functions.T;
|
16
|
25
|
import org.omg.CORBA.INTERNAL;
|
|
@@ -33,6 +42,7 @@ import java.util.List;
|
33
|
42
|
import java.util.HashMap;
|
34
|
43
|
import java.util.List;
|
35
|
44
|
import java.util.Map;
|
|
45
|
+import java.util.stream.Collectors;
|
36
|
46
|
|
37
|
47
|
|
38
|
48
|
/**
|
|
@@ -52,9 +62,24 @@ public class TaH5DemandController extends BaseController {
|
52
|
62
|
@Autowired
|
53
|
63
|
public ITaH5DemandService iTaH5DemandService;
|
54
|
64
|
|
|
65
|
+ @Autowired
|
|
66
|
+ public ITaH5SampleService iTaH5SampleService;
|
|
67
|
+
|
|
68
|
+ @Autowired
|
|
69
|
+ private ITaSampleContactService iTaSampleContactService;
|
|
70
|
+
|
|
71
|
+ @Autowired
|
|
72
|
+ private ITaContactService taContactService;
|
|
73
|
+
|
55
|
74
|
@Autowired
|
56
|
75
|
private ITaOrgService iTaOrgService;
|
57
|
76
|
|
|
77
|
+ @Autowired
|
|
78
|
+ SysSmsSettingMapper sysSmsSettingMapper;
|
|
79
|
+
|
|
80
|
+ @Autowired
|
|
81
|
+ SMSUtils smsUtils;
|
|
82
|
+
|
58
|
83
|
/**
|
59
|
84
|
* 分页查询列表
|
60
|
85
|
* @param pageNum
|
|
@@ -117,6 +142,19 @@ public class TaH5DemandController extends BaseController {
|
117
|
142
|
}else {
|
118
|
143
|
responseBean.addError("fail");
|
119
|
144
|
}
|
|
145
|
+ TaH5Sample taH5Sample = iTaH5SampleService.getById(taH5Demand.getSampleId());
|
|
146
|
+ QueryWrapper<TaSampleContact> queryWrapper = new QueryWrapper();
|
|
147
|
+ queryWrapper.eq("sample_id",taH5Sample.getSampleId());
|
|
148
|
+ List<TaSampleContact> sampleContactList = iTaSampleContactService.list(queryWrapper);
|
|
149
|
+ if (sampleContactList.size() > 0) {
|
|
150
|
+ List<TaContact> taContactList = taContactService.list(new QueryWrapper<TaContact>().in("contact_id", sampleContactList.stream().map(TaSampleContact::getContactId).collect(Collectors.toList())));
|
|
151
|
+ taH5Sample.setTaContactList(taContactList);
|
|
152
|
+ String[] smsParams = {taH5Demand.getDemandStatus().toString(), taH5Demand.getRemark()};
|
|
153
|
+ for (TaContact taContact : taContactList){
|
|
154
|
+ sendSmsMessage(taContact.getPhone(), CommConstant.MESSAGE_CONTENT_OF_DEMAND, smsParams);
|
|
155
|
+ }
|
|
156
|
+
|
|
157
|
+ }
|
120
|
158
|
}catch (Exception e){
|
121
|
159
|
e.printStackTrace();
|
122
|
160
|
logger.error("taH5DemandAdd -=- {}",e.toString());
|
|
@@ -331,4 +369,29 @@ public class TaH5DemandController extends BaseController {
|
331
|
369
|
}
|
332
|
370
|
return responseBean;
|
333
|
371
|
}
|
|
372
|
+
|
|
373
|
+ private String sendSmsMessage(String tel, String type, String[] params) {
|
|
374
|
+ if (StringUtils.isEmpty(tel) || StringUtils.isEmpty(type)) {
|
|
375
|
+ return "短信发送失败: 没有手机号或者短信模板";
|
|
376
|
+ }
|
|
377
|
+
|
|
378
|
+ QueryWrapper<SysSmsSetting> query = new QueryWrapper<>();
|
|
379
|
+ query.eq("sms_type", type);
|
|
380
|
+ query.eq("status", CommConstant.STATUS_NORMAL);
|
|
381
|
+ query.last("limit 1");
|
|
382
|
+
|
|
383
|
+ SysSmsSetting smsSetting = sysSmsSettingMapper.selectOne(query);
|
|
384
|
+ if (null == smsSetting) {
|
|
385
|
+
|
|
386
|
+ // TODO 写消息发送日志
|
|
387
|
+
|
|
388
|
+ return "没有设置有效的【" + type + "】短信模板";
|
|
389
|
+ }
|
|
390
|
+
|
|
391
|
+ boolean success = smsUtils.sendMessage(smsSetting.getTplCode(), tel, params);
|
|
392
|
+
|
|
393
|
+ // TODO 写消息发送日志
|
|
394
|
+
|
|
395
|
+ return success ? null : "短信发送失败";
|
|
396
|
+ }
|
334
|
397
|
}
|