|
@@ -18,6 +18,10 @@ import com.huiju.estateagents.center.taUser.entity.TaUser;
|
18
|
18
|
import com.huiju.estateagents.center.taUser.mapper.TaUserMapper;
|
19
|
19
|
import com.huiju.estateagents.common.CommConstant;
|
20
|
20
|
import com.huiju.estateagents.common.CommonUtils;
|
|
21
|
+import com.huiju.estateagents.common.SMSUtils;
|
|
22
|
+import com.huiju.estateagents.common.StringUtils;
|
|
23
|
+import com.huiju.estateagents.entity.SysSmsSetting;
|
|
24
|
+import com.huiju.estateagents.mapper.SysSmsSettingMapper;
|
21
|
25
|
import com.huiju.estateagents.redpack.entity.TaOrgAccount;
|
22
|
26
|
import com.huiju.estateagents.redpack.entity.TaOrgAccountBlocked;
|
23
|
27
|
import com.huiju.estateagents.redpack.entity.TaOrgAccountCertificate;
|
|
@@ -33,6 +37,8 @@ import com.huiju.estateagents.redpack.mapper.TaOrgOrderDetailMapper;
|
33
|
37
|
import com.huiju.estateagents.redpack.mapper.TaOrgOrderMapper;
|
34
|
38
|
import com.huiju.estateagents.redpack.mapper.TaOrgRefundApplicationMapper;
|
35
|
39
|
import com.huiju.estateagents.redpack.service.ITaOrgAccountService;
|
|
40
|
+import com.huiju.estateagents.sample.entity.TaContact;
|
|
41
|
+import com.huiju.estateagents.sample.mapper.TaContactMapper;
|
36
|
42
|
|
37
|
43
|
import io.swagger.models.auth.In;
|
38
|
44
|
|
|
@@ -71,6 +77,15 @@ public class TaOrgAccountServiceImpl extends ServiceImpl<TaOrgAccountMapper, TaO
|
71
|
77
|
@Autowired
|
72
|
78
|
private TaUserMapper taUserMapper;
|
73
|
79
|
|
|
80
|
+ @Autowired
|
|
81
|
+ private TaContactMapper taContactMapper;
|
|
82
|
+
|
|
83
|
+ @Autowired
|
|
84
|
+ SysSmsSettingMapper sysSmsSettingMapper;
|
|
85
|
+
|
|
86
|
+ @Autowired
|
|
87
|
+ SMSUtils smsUtils;
|
|
88
|
+
|
74
|
89
|
@Override
|
75
|
90
|
@Transactional(rollbackFor = {RuntimeException.class})
|
76
|
91
|
public ResponseBean rechargeAccount(String accountId, TaOrgAccount taOrgAccount, Integer orgId, Integer userId) {
|
|
@@ -109,6 +124,11 @@ public class TaOrgAccountServiceImpl extends ServiceImpl<TaOrgAccountMapper, TaO
|
109
|
124
|
return responseBean;
|
110
|
125
|
}
|
111
|
126
|
|
|
127
|
+ TaContact taContact = selectSmsContactUser();
|
|
128
|
+ String[] smsParams = {"业务平台充值成功", taOrgOrder.getTradeNo() + taOrgAccount.getMiniappName()};
|
|
129
|
+ // 短信发送
|
|
130
|
+ sendSmsMessage(taContact.getPhone(), CommConstant.ITEM_TYPE_RECHARGE, smsParams);
|
|
131
|
+
|
112
|
132
|
return responseBean;
|
113
|
133
|
}
|
114
|
134
|
|
|
@@ -154,6 +174,30 @@ public class TaOrgAccountServiceImpl extends ServiceImpl<TaOrgAccountMapper, TaO
|
154
|
174
|
return responseBean;
|
155
|
175
|
}
|
156
|
176
|
|
|
177
|
+ TaContact taContact = selectSmsContactUser();
|
|
178
|
+ String[] smsParams = {"业务平台退款申请", taOrgOrder.getTradeNo() + taOrgAccount.getMiniappName()};
|
|
179
|
+ // 短信发送
|
|
180
|
+ sendSmsMessage(taContact.getPhone(), CommConstant.ITEM_TYPE_REFUND, smsParams);
|
|
181
|
+
|
|
182
|
+ return responseBean;
|
|
183
|
+ }
|
|
184
|
+
|
|
185
|
+ @Override
|
|
186
|
+ public ResponseBean getOrgAccountById(Integer orgId) {
|
|
187
|
+ ResponseBean responseBean = new ResponseBean<>();
|
|
188
|
+ TaOrgAccount taOrgAccount = taOrgAccountMapper.getOrgAccountById(orgId);
|
|
189
|
+
|
|
190
|
+ //查询总充值金额
|
|
191
|
+ Integer totalRechargeAmount = taOrgOrderMapper.countTotalRechargeAmount(orgId);
|
|
192
|
+
|
|
193
|
+ //查询退款冻结额
|
|
194
|
+ Integer totalBlockAmount = taOrgAccountBlockedMapper.countTotalBlockAmount(orgId);
|
|
195
|
+
|
|
196
|
+ //账户余额=总充值金额-已消费金额-已退款额-退款冻结额
|
|
197
|
+ Integer balance = totalRechargeAmount - taOrgAccount.getPurchaseAmount() - taOrgAccount.getTotalRefund() - totalBlockAmount;
|
|
198
|
+ taOrgAccount.setRealBalance(balance);
|
|
199
|
+
|
|
200
|
+ responseBean.addSuccess(taOrgAccount);
|
157
|
201
|
return responseBean;
|
158
|
202
|
}
|
159
|
203
|
|
|
@@ -307,4 +351,37 @@ public class TaOrgAccountServiceImpl extends ServiceImpl<TaOrgAccountMapper, TaO
|
307
|
351
|
TaUser taUser = taUserMapper.selectOne(taUserQueryWrapper);
|
308
|
352
|
return taUser;
|
309
|
353
|
}
|
|
354
|
+
|
|
355
|
+ private String sendSmsMessage(String tel, String type, String[] params) {
|
|
356
|
+ if (StringUtils.isEmpty(tel) || StringUtils.isEmpty(type)) {
|
|
357
|
+ return "短信发送失败: 没有手机号或者短信模板";
|
|
358
|
+ }
|
|
359
|
+
|
|
360
|
+ QueryWrapper<SysSmsSetting> query = new QueryWrapper<>();
|
|
361
|
+ query.eq("sms_type", type);
|
|
362
|
+ query.eq("status", CommConstant.STATUS_NORMAL);
|
|
363
|
+ query.last("limit 1");
|
|
364
|
+
|
|
365
|
+ SysSmsSetting smsSetting = sysSmsSettingMapper.selectOne(query);
|
|
366
|
+ if (null == smsSetting) {
|
|
367
|
+
|
|
368
|
+ // TODO 写消息发送日志
|
|
369
|
+
|
|
370
|
+ return "没有设置有效的【" + type + "】短信模板";
|
|
371
|
+ }
|
|
372
|
+
|
|
373
|
+ boolean success = smsUtils.sendMessage(smsSetting.getTplCode(), tel, params);
|
|
374
|
+
|
|
375
|
+ // TODO 写消息发送日志
|
|
376
|
+
|
|
377
|
+ return success ? null : "短信发送失败";
|
|
378
|
+ }
|
|
379
|
+
|
|
380
|
+ public TaContact selectSmsContactUser(){
|
|
381
|
+ //获取操作人
|
|
382
|
+ QueryWrapper<TaContact> taContactQueryWrapper = new QueryWrapper<>();
|
|
383
|
+ taContactQueryWrapper.eq("contact_Type", CommConstant.FINANCE);
|
|
384
|
+ TaContact taContact = taContactMapper.selectOne(taContactQueryWrapper);
|
|
385
|
+ return taContact;
|
|
386
|
+ }
|
310
|
387
|
}
|