|
@@ -1,5 +1,6 @@
|
|
package com.caimei365.order.service.impl;
|
|
package com.caimei365.order.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.caimei365.order.components.WeChatService;
|
|
import com.caimei365.order.components.WeChatService;
|
|
import com.caimei365.order.mapper.BaseMapper;
|
|
import com.caimei365.order.mapper.BaseMapper;
|
|
import com.caimei365.order.mapper.OrderCommonMapper;
|
|
import com.caimei365.order.mapper.OrderCommonMapper;
|
|
@@ -117,9 +118,22 @@ public class ReceiptServiceImpl implements ReceiptService {
|
|
Map<String, Object> infoData = appletsInfo.getData();
|
|
Map<String, Object> infoData = appletsInfo.getData();
|
|
String openid = (String) infoData.get(WeChatService.Keys.OPEN_ID);
|
|
String openid = (String) infoData.get(WeChatService.Keys.OPEN_ID);
|
|
String unionId = (String) infoData.get(WeChatService.Keys.UNION_ID);
|
|
String unionId = (String) infoData.get(WeChatService.Keys.UNION_ID);
|
|
- receiptMapper.updateOpenidByMobile(openid, unionId, mobile);
|
|
|
|
|
|
+ if (StringUtils.isBlank(unionId)) {
|
|
|
|
+ try {
|
|
|
|
+ String sessionKey = (String) infoData.get(WeChatService.Keys.SESSION_KEY);
|
|
|
|
+ String result = WeChatService.decrypt(encryptedData, sessionKey, iv, "UTF-8");
|
|
|
|
+ log.info("解密数据>>>>>>" + result);
|
|
|
|
+ Map parseMap = JSONObject.parseObject(result, Map.class);
|
|
|
|
+ assert parseMap != null;
|
|
|
|
+ unionId = parseMap.get(WeChatService.Keys.UNION_ID).toString();
|
|
|
|
+ infoData.put(WeChatService.Keys.UNION_ID, unionId);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("微信解密unionId失败:", e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
receiptUser.setOpenid(openid);
|
|
receiptUser.setOpenid(openid);
|
|
receiptUser.setUnionId(unionId);
|
|
receiptUser.setUnionId(unionId);
|
|
|
|
+ receiptMapper.updateOpenidByMobile(openid, unionId, mobile);
|
|
} else {
|
|
} else {
|
|
return ResponseJson.error(appletsInfo.getMsg(), null);
|
|
return ResponseJson.error(appletsInfo.getMsg(), null);
|
|
}
|
|
}
|
|
@@ -1070,23 +1084,20 @@ public class ReceiptServiceImpl implements ReceiptService {
|
|
receiptPo.setConfirmUserPermissionId(receiptUser.getId());
|
|
receiptPo.setConfirmUserPermissionId(receiptUser.getId());
|
|
receiptPo.setConfirmDate(time);
|
|
receiptPo.setConfirmDate(time);
|
|
receiptMapper.updateReceipt(receiptPo);
|
|
receiptMapper.updateReceipt(receiptPo);
|
|
- // 关联成功推送模板消息给审核人员(3财务)
|
|
|
|
- List<String> openidList = receiptMapper.getOpenidListByUserType(3);
|
|
|
|
|
|
+
|
|
|
|
+ // 关联成功推送模板消息给指定人员(用户权限: 1收款列表访问,2收款详情访问,3收款录入,4收款关联订单,5收款关联返佣,6收款关联供应商退款,7收款审核)
|
|
|
|
+ List<String> openidList = receiptMapper.getOpenidListByPermission(Collections.singletonList(7));
|
|
openidList.removeIf(Objects::isNull);
|
|
openidList.removeIf(Objects::isNull);
|
|
double associateAmount = receiptMapper.countAssociateAmountById(receipt.getId());
|
|
double associateAmount = receiptMapper.countAssociateAmountById(receipt.getId());
|
|
String associateTitle = "收款和订单已确认关联,请及时审核!";
|
|
String associateTitle = "收款和订单已确认关联,请及时审核!";
|
|
String associateDate = receipt.getReceiptDate();
|
|
String associateDate = receipt.getReceiptDate();
|
|
String associateType = receiptMapper.getReceiptTypeStrById(receipt.getPayType());
|
|
String associateType = receiptMapper.getReceiptTypeStrById(receipt.getPayType());
|
|
String remarkText = "收款类型:" + associateType + ",确认时间:"+receipt.getConfirmDate();
|
|
String remarkText = "收款类型:" + associateType + ",确认时间:"+receipt.getConfirmDate();
|
|
-
|
|
|
|
- //todo 跳转到详情页
|
|
|
|
- // 跳转链接 crm旧链接:/api/user/receivables/toReceivablesPage.rpc?pageName=listToDesc&id=receipt.getId()
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- String redirectUrl = "";
|
|
|
|
|
|
+ // 跳转到【普通款项待审核】页面
|
|
|
|
+ String pagePath = "/pages/relation/ordinary/examine-detail?id="+receipt.getId();
|
|
for (String openid : openidList) {
|
|
for (String openid : openidList) {
|
|
// sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接)
|
|
// sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接)
|
|
- weChatService.sendTemplateMsg(openid, associateTitle, associateAmount, associateDate, remarkText, redirectUrl);
|
|
|
|
|
|
+ weChatService.sendTemplateMsg(openid, associateTitle, associateAmount, associateDate, remarkText, pagePath);
|
|
}
|
|
}
|
|
return ResponseJson.success("关联收款信息成功!", null);
|
|
return ResponseJson.success("关联收款信息成功!", null);
|
|
}
|
|
}
|
|
@@ -1516,41 +1527,98 @@ public class ReceiptServiceImpl implements ReceiptService {
|
|
receiptPo.setReviewDate(time);
|
|
receiptPo.setReviewDate(time);
|
|
receiptMapper.updateReceipt(receiptPo);
|
|
receiptMapper.updateReceipt(receiptPo);
|
|
|
|
|
|
- // 推送消息给指定人员
|
|
|
|
- if (3 == receiptStatus) {
|
|
|
|
- // 审核通过
|
|
|
|
- String title = "订单支付成功!";
|
|
|
|
- String openid = receiptUser.getOpenid();
|
|
|
|
- String date = receiptPo.getReceiptDate();
|
|
|
|
- for (OrderReceiptRelationPo relationItem : listRelation) {
|
|
|
|
- // 订单信息
|
|
|
|
- OrderVo order = orderCommonMapper.getOrderByOrderId(relationItem.getOrderId());
|
|
|
|
- String remarkText = "订单ID:"+order.getOrderId()+","+order.getReceiptStatus()+",买家:"+order.getUserName();
|
|
|
|
-
|
|
|
|
- //todo /spCmOrder/listDetails.rpc?orderId="+order.getOrderId()
|
|
|
|
- String redirectUrl = "";
|
|
|
|
- // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接)
|
|
|
|
- weChatService.sendTemplateMsg(openid, title, relationItem.getAssociateAmount(), date, remarkText, redirectUrl);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
|
|
+ // 审核未通过 推送模板消息给指定人员
|
|
|
|
+ if (4 == receiptStatus) {
|
|
// 审核未通过
|
|
// 审核未通过
|
|
String title = "订单审核未通过,请重新确认审核!";
|
|
String title = "订单审核未通过,请重新确认审核!";
|
|
String date = receipt.getReceiptDate();
|
|
String date = receipt.getReceiptDate();
|
|
String receiptTypeStr = receiptMapper.getReceiptTypeStrById(receipt.getPayType());
|
|
String receiptTypeStr = receiptMapper.getReceiptTypeStrById(receipt.getPayType());
|
|
String remarkText = "收款类型:"+ receiptTypeStr +";"+"审核时间:"+receiptPo.getReviewDate();
|
|
String remarkText = "收款类型:"+ receiptTypeStr +";"+"审核时间:"+receiptPo.getReviewDate();
|
|
double associateAmount = receiptMapper.countAssociateAmountById(receipt.getId());
|
|
double associateAmount = receiptMapper.countAssociateAmountById(receipt.getId());
|
|
- List<String> openidList = receiptMapper.getOpenidListByUserType(1);
|
|
|
|
|
|
+ // (用户权限: 1收款列表访问,2收款详情访问,3收款录入,4收款关联订单,5收款关联返佣,6收款关联供应商退款,7收款审核)
|
|
|
|
+ List<String> openidList = receiptMapper.getOpenidListByPermission(Collections.singletonList(4));
|
|
openidList.removeIf(Objects::isNull);
|
|
openidList.removeIf(Objects::isNull);
|
|
|
|
+ // 跳转到【普通款项待审核】页面
|
|
|
|
+ String pagePath = "/pages/relation/ordinary/examine-detail?id="+receipt.getId();
|
|
|
|
+ for (String openid : openidList) {
|
|
|
|
+ // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接)
|
|
|
|
+ weChatService.sendTemplateMsg(openid, title, associateAmount, date, remarkText, pagePath);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return ResponseJson.success("审核收款信息成功!", null);
|
|
|
|
+ }
|
|
|
|
|
|
- // todo /api/user/receivables/toReceivablesPage.rpc?pageName="+pageName+"&id="+receipt.getId()
|
|
|
|
- String redirectUrl = "";
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 微信收款信息推送(待确认超时)
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void sendWechatMsgConfirmTimeout() {
|
|
|
|
+ //待确认超时
|
|
|
|
+ ReceiptParamsBo paramsBo = new ReceiptParamsBo();
|
|
|
|
+ String[] receiptStatusArr = "1".split(",");
|
|
|
|
+ paramsBo.setReceiptStatusArr(receiptStatusArr);
|
|
|
|
+ paramsBo.setStartDate("2022-01-01 00:00:00");
|
|
|
|
+ List<ReceiptVo> list = receiptMapper.getReceiptList(paramsBo);
|
|
|
|
+ list.removeIf(Objects::isNull);
|
|
|
|
+ // (用户权限: 1收款列表访问,2收款详情访问,3收款录入,4收款关联订单,5收款关联返佣,6收款关联供应商退款,7收款审核)
|
|
|
|
+ List<String> openidList = receiptMapper.getOpenidListByPermission(Arrays.asList(4,5,6));
|
|
|
|
+ openidList.removeIf(Objects::isNull);
|
|
|
|
+ String title = "超时未确认,请及时查看详情并确认关联!";
|
|
|
|
+ String pagePath = "";
|
|
|
|
+ for (ReceiptVo receipt : list) {
|
|
|
|
+ // 收款款项类型:1订单款,2非订单款,3返佣款,5供应商退款
|
|
|
|
+ Integer receiptType = receipt.getReceiptType();
|
|
|
|
+ if (null != receiptType && 1 == receiptType) {
|
|
|
|
+ // 未关联普通款项
|
|
|
|
+ pagePath = "/pages/relation/ordinary/index?id="+receipt.getId();
|
|
|
|
+ }
|
|
|
|
+ if (null != receiptType && 3 == receiptType) {
|
|
|
|
+ // 未关联返佣款项
|
|
|
|
+ pagePath = "/pages/relation/return/index?id="+receipt.getId();
|
|
|
|
+ }
|
|
|
|
+ if (null != receiptType && 5 == receiptType) {
|
|
|
|
+ // 未关联供应商退款
|
|
|
|
+ pagePath = "/pages/relation/refund/index?id="+receipt.getId();
|
|
|
|
+ }
|
|
|
|
+ double amount = receipt.getReceiptAmount();
|
|
|
|
+ String date = receipt.getReceiptDate();
|
|
|
|
+ String receiptTypeStr = receiptMapper.getReceiptTypeStrById(receipt.getPayType());
|
|
|
|
+ String remarkText = "收款类型:" + receiptTypeStr;
|
|
|
|
+ for (String openid : openidList) {
|
|
|
|
+ // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接)
|
|
|
|
+ weChatService.sendTemplateMsg(openid, title, amount, date, remarkText, pagePath);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 微信收款信息推送(待审核超时)
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void sendWechatMsgAuditTimeout() {
|
|
|
|
+ //待审核超时
|
|
|
|
+ ReceiptParamsBo paramsBo = new ReceiptParamsBo();
|
|
|
|
+ String[] receiptStatusArr = "2".split(",");
|
|
|
|
+ paramsBo.setReceiptStatusArr(receiptStatusArr);
|
|
|
|
+ paramsBo.setStartDate("2022-01-01 00:00:00");
|
|
|
|
+ List<ReceiptVo> list = receiptMapper.getReceiptList(paramsBo);
|
|
|
|
+ list.removeIf(Objects::isNull);
|
|
|
|
+ // (用户权限: 1收款列表访问,2收款详情访问,3收款录入,4收款关联订单,5收款关联返佣,6收款关联供应商退款,7收款审核)
|
|
|
|
+ List<String> openidList = receiptMapper.getOpenidListByPermission(Collections.singletonList(7));
|
|
|
|
+ openidList.removeIf(Objects::isNull);
|
|
|
|
+ String title = "超时未审核,请及时查看详情并审核!";
|
|
|
|
+ for (ReceiptVo receipt : list) {
|
|
|
|
+ double amount = receiptMapper.countAssociateAmountById(receipt.getId());
|
|
|
|
+ String date = receipt.getConfirmDate();
|
|
|
|
+ String receiptTypeStr = receiptMapper.getReceiptTypeStrById(receipt.getPayType());
|
|
|
|
+ String remarkText = "收款类型:" + receiptTypeStr + ",确认时间:"+receipt.getConfirmDate();
|
|
|
|
+ // 跳转到【普通款项待审核】页面
|
|
|
|
+ String pagePath = "/pages/relation/ordinary/examine-detail?id="+receipt.getId();
|
|
for (String openid : openidList) {
|
|
for (String openid : openidList) {
|
|
// sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接)
|
|
// sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接)
|
|
- weChatService.sendTemplateMsg(openid, title, associateAmount, date, remarkText, redirectUrl);
|
|
|
|
|
|
+ weChatService.sendTemplateMsg(openid, title, amount, date, remarkText, pagePath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return ResponseJson.success("审核收款信息成功!", null);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1643,6 +1711,18 @@ public class ReceiptServiceImpl implements ReceiptService {
|
|
String userName = baseMapper.getUserNameByUserId(receipt.getUserId());
|
|
String userName = baseMapper.getUserNameByUserId(receipt.getUserId());
|
|
receipt.setUserName(userName);
|
|
receipt.setUserName(userName);
|
|
}
|
|
}
|
|
|
|
+ if (null != receipt.getReceiptUserPermissionId()) {
|
|
|
|
+ String receiptUserName = receiptMapper.getReceiptUserNameById(receipt.getReceiptUserPermissionId());
|
|
|
|
+ receipt.setReceiptUserName(receiptUserName);
|
|
|
|
+ }
|
|
|
|
+ if (null != receipt.getConfirmUserPermissionId()) {
|
|
|
|
+ String confirmUserName = receiptMapper.getReceiptUserNameById(receipt.getConfirmUserPermissionId());
|
|
|
|
+ receipt.setConfirmUserName(confirmUserName);
|
|
|
|
+ }
|
|
|
|
+ if (null != receipt.getReviewUserPermissionId()) {
|
|
|
|
+ String reviewUserName = receiptMapper.getReceiptUserNameById(receipt.getReviewUserPermissionId());
|
|
|
|
+ receipt.setReviewUserName(reviewUserName);
|
|
|
|
+ }
|
|
ReceiptTypeVo type = receiptMapper.getReceiptTypeById(receipt.getPayType());
|
|
ReceiptTypeVo type = receiptMapper.getReceiptTypeById(receipt.getPayType());
|
|
receipt.setPayTypeText(type.getType());
|
|
receipt.setPayTypeText(type.getType());
|
|
receipt.setReceiptTypeText(ReceiptType.getTypeDesc(receipt.getReceiptType()));
|
|
receipt.setReceiptTypeText(ReceiptType.getTypeDesc(receipt.getReceiptType()));
|