|
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.szwl.constant.ConfigConsts;
|
|
|
import com.szwl.exception.MyException;
|
|
|
import com.szwl.feign.SzwlFeign;
|
|
|
import com.szwl.mapper.TCoinOrderMapper;
|
|
@@ -18,6 +19,7 @@ import com.szwl.mapper.TOrderMapper;
|
|
|
import com.szwl.model.bean.ChartBean;
|
|
|
import com.szwl.model.bean.ChartColumn;
|
|
|
import com.szwl.model.bean.OrderDaoChuDTO;
|
|
|
+import com.szwl.model.bean.WeChatTemplateMsg;
|
|
|
import com.szwl.model.bo.ChartType;
|
|
|
import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.bo.ResponseModel;
|
|
@@ -35,11 +37,13 @@ import com.szwl.service.OrderStatisticsMonthService;
|
|
|
import com.szwl.service.OrderStatisticsYearService;
|
|
|
import com.szwl.service.RefundSendRecordService;
|
|
|
import com.szwl.service.TOrderService;
|
|
|
+import com.szwl.util.WechatUtils;
|
|
|
import com.szwl.util.YunPianSms;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -260,7 +264,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String setMessage(Long id, String customerPhone, Long adminId) {
|
|
|
+ public String setMessage(Long id, String customerPhone, Long adminId, String reason) {
|
|
|
TOrder order = tOrderMapper.selectById(id);
|
|
|
String result = "";
|
|
|
RefundSendRecord refundSendRecord = new RefundSendRecord();
|
|
@@ -323,11 +327,11 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
String clientId6 = clientId.substring(clientId.length() - 6);
|
|
|
if (StringUtils.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
// 如果是七云科技的用户
|
|
|
- result = YunPianSms.sendSms(appid, getScMessage(sn, price, payTime,
|
|
|
+ result = YunPianSms.sendSms(appid, YunPianSms.getScMessage(sn, price, payTime,
|
|
|
equipment.getName(), clientId6, customerPhone), phone, uid, CALLBACK_URL);
|
|
|
} else {
|
|
|
// 如果是申泽智能的用户
|
|
|
- result = YunPianSms.sendSms(appid, getSzMessage(sn, price, payTime,
|
|
|
+ result = YunPianSms.sendSms(appid, YunPianSms.getSzMessage(sn, price, payTime,
|
|
|
equipment.getName(), clientId6, customerPhone), phone, uid, CALLBACK_URL);
|
|
|
}
|
|
|
refundSendRecord.setPhone(phone);
|
|
@@ -338,6 +342,21 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
result = "设备运营者手机号为空";
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 推送微信订单
|
|
|
+ // 判断是否开启订单推送功能
|
|
|
+ if (admin != null && StringUtils.isNotEmpty(admin.getOrderNotice()) && admin.getOrderNotice().equals("1")) {
|
|
|
+ String openId = R.getDataIfSuccess(szwlFeign.getOpenId(admin.getId()));
|
|
|
+ // 获取openId
|
|
|
+ if (StringUtils.isNotEmpty(openId)) {
|
|
|
+ this.WechatRefundMessage(openId, equipment, order, companyType, reason);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
refundSendRecord.setStatus(0);
|
|
|
refundSendRecordService.save(refundSendRecord);
|
|
|
}
|
|
@@ -685,7 +704,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
query.eq(OrderStatisticsMonth::getAdminId, admin.getId());
|
|
|
}
|
|
|
}
|
|
|
- if (param.getAdminIds()!= null && !param.getAdminIds().isEmpty()) {
|
|
|
+ if (param.getAdminIds() != null && !param.getAdminIds().isEmpty()) {
|
|
|
query.in(OrderStatisticsMonth::getAdminId, param.getAdminIds());
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(param.getIfForeign())) {
|
|
@@ -783,7 +802,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
query.eq(OrderStatisticsYear::getAdminId, admin.getId());
|
|
|
}
|
|
|
}
|
|
|
- if (param.getAdminIds()!= null && !param.getAdminIds().isEmpty()) {
|
|
|
+ if (param.getAdminIds() != null && !param.getAdminIds().isEmpty()) {
|
|
|
query.in(OrderStatisticsYear::getAdminId, param.getAdminIds());
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(param.getIfForeign())) {
|
|
@@ -1073,7 +1092,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
query.eq(OrderStatisticsYear::getAdminId, admin.getId());
|
|
|
}
|
|
|
}
|
|
|
- if (param.getAdminIds()!= null && !param.getAdminIds().isEmpty()) {
|
|
|
+ if (param.getAdminIds() != null && !param.getAdminIds().isEmpty()) {
|
|
|
query.in(OrderStatisticsYear::getAdminId, param.getAdminIds());
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(param.getIfForeign())) {
|
|
@@ -1168,7 +1187,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
query.eq(OrderStatisticsMonth::getAdminId, admin.getId());
|
|
|
}
|
|
|
}
|
|
|
- if (param.getAdminIds()!= null && !param.getAdminIds().isEmpty()) {
|
|
|
+ if (param.getAdminIds() != null && !param.getAdminIds().isEmpty()) {
|
|
|
query.in(OrderStatisticsMonth::getAdminId, param.getAdminIds());
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(param.getIfForeign())) {
|
|
@@ -1256,6 +1275,57 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void WechatRefundMessage(String openId, TEquipment equipment, TOrder order, String companyType, String reason) {
|
|
|
+ String accessToken = "";
|
|
|
+ try {
|
|
|
+ if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin("2738"));
|
|
|
+ accessToken = admin.getApiKey();
|
|
|
+ } else {
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin("2739"));
|
|
|
+ accessToken = admin.getApiKey();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 模板参数
|
|
|
+ Map<String, WeChatTemplateMsg> sendMag = new HashMap();
|
|
|
+ String clientId = equipment.getClientId();
|
|
|
+ // 模版参数
|
|
|
+ if(StringUtils.isNotEmpty(equipment.getName())) {
|
|
|
+ if(equipment.getName().length() > 20) {
|
|
|
+ sendMag.put("thing11", new WeChatTemplateMsg(equipment.getName().substring(0, 15) + "..."));
|
|
|
+ } else {
|
|
|
+ sendMag.put("thing11", new WeChatTemplateMsg(equipment.getName()));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ sendMag.put("thing11", new WeChatTemplateMsg(clientId.substring(clientId.length() - 6)));
|
|
|
+ }
|
|
|
+
|
|
|
+ String sn = order.getSn();
|
|
|
+ if (sn.length() > 32) {
|
|
|
+ sendMag.put("character_string8", new WeChatTemplateMsg(sn.substring(0, 28) + "..."));
|
|
|
+ } else {
|
|
|
+ sendMag.put("character_string8", new WeChatTemplateMsg(sn));
|
|
|
+ }
|
|
|
+ sendMag.put("character_string10", new WeChatTemplateMsg(clientId.substring(clientId.length() - 6)));
|
|
|
+ sendMag.put("const5", new WeChatTemplateMsg(reason));
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ Map<String, Object> sendBody = new HashMap<>();
|
|
|
+ sendBody.put("touser", openId);
|
|
|
+ sendBody.put("data", sendMag);
|
|
|
+ if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
|
|
|
+ sendBody.put("template_id", ConfigConsts.SZ_REFUND_MESSAGE_ID);
|
|
|
+ sendBody.put("url", "https://szwlh.sunzee.com.cn/shenze/#/login");
|
|
|
+ } else {
|
|
|
+ sendBody.put("template_id", ConfigConsts.SC_REFUND_MESSAGE_ID);
|
|
|
+ sendBody.put("url", "http://sevencloud.com.cn/sc/#/login");
|
|
|
+ }
|
|
|
+ WechatUtils.sendMessage(accessToken, restTemplate, sendBody);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private List<StatisticsClientIdTarget> exportStatisticsByClientId(List<OrderDaoChuDTO> dataList) {
|
|
|
List<StatisticsClientIdTarget> clientIdTargetList = new ArrayList<>();
|
|
|
for (OrderDaoChuDTO orderDaoChuDTO : dataList) {
|
|
@@ -1275,6 +1345,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
|
|
|
/**
|
|
|
* 封装
|
|
|
+ *
|
|
|
* @param dataList
|
|
|
* @return
|
|
|
*/
|
|
@@ -1295,6 +1366,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
|
|
|
/**
|
|
|
* 分页查询
|
|
|
+ *
|
|
|
* @param pageNo
|
|
|
* @param param
|
|
|
* @return
|