Commit a4958369 by 王祖波

提现通知

parent fb89eb2b
package com.gic.haoban.manage.api.dto.qdto.content;
import java.io.Serializable;
import java.math.BigDecimal;
public class ClerkCashListQDTO implements Serializable {
/**
* 导购id
*/
private String clerkId;
/**
* 佣金金额
*/
private BigDecimal applyAmount;
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public BigDecimal getApplyAmount() {
return applyAmount;
}
public void setApplyAmount(BigDecimal applyAmount) {
this.applyAmount = applyAmount;
}
}
package com.gic.haoban.manage.api.dto.qdto.content;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import java.io.Serializable;
import java.util.List;
public class ClerkCashNotifyQDTO implements Serializable {
/**
* 企业id
*/
private String enterpriseId;
private List<ClerkCashListQDTO> cashList;
private NoticeMessageTypeEnum cashTypeEnum;
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public List<ClerkCashListQDTO> getCashList() {
return cashList;
}
public void setCashList(List<ClerkCashListQDTO> cashList) {
this.cashList = cashList;
}
public NoticeMessageTypeEnum getCashTypeEnum() {
return cashTypeEnum;
}
public void setCashTypeEnum(NoticeMessageTypeEnum cashTypeEnum) {
this.cashTypeEnum = cashTypeEnum;
}
}
......@@ -77,9 +77,13 @@ public enum NoticeMessageTypeEnum {
MATERIAL_REPORT_NOTIFY_WEEK(6002, "素材周报通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_week_notify", "/pages/route/index?pageType=", "hbapp_mate_report", "materialWeek", "clerkMaterialsReport"),
POTENTIAL_CUSTOMER_NOTIFY(6003, "销售线索通知", NoticeMessageCategoryTypeEnum.POTENTIAL_CUSTOMER.getType(), "potential_customer_notify", "/pages/route/index?pageType=", "hbapp_sales_clue_center", "salesLeadNotice", "haobanNotice"),
MATERIAL_REPORT_NOTIFY_MONTH(6004, "素材月报通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_month_notify", "/pages/route/index?pageType=", "hbapp_mate_report", "materialMonth", "clerkMaterialsReport"),
CLERK_COMMISSION_NOTIFY(6005, "客户下单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "clerk_commission_notify", "/pages/route/index?pageType=", "hbapp_withdraw_list", "clerkCommissionNotify", "haobanNotice");
CLERK_COMMISSION_NOTIFY(6005, "客户下单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "clerk_commission_notify", "/pages/route/index?pageType=", "hbapp_withdraw_list", "clerkCommissionNotify", "haobanNotice"),
CASH_APPLY_REFUSE_NOTIFY(7001,"提现通知", NoticeMessageCategoryTypeEnum.OTHER.getType(),"cash_apply_refuse_notify","/pages/route/index?pageType=","hbapp_withdraw_list","cashApplyRefuseNotify","haobanNotice"),
CASH_APPLY_FAIL_NOTIFY(7002,"提现通知", NoticeMessageCategoryTypeEnum.OTHER.getType(),"cash_apply_fail_notify","/pages/route/index?pageType=","hbapp_withdraw_list","cashApplyFailNotify","haobanNotice"),
CASH_APPLY_OFFLINE_SUCCESS_NOTIFY(7003,"提现通知", NoticeMessageCategoryTypeEnum.OTHER.getType(),"cash_apply_offline_success_notify","/pages/route/index?pageType=","hbapp_withdraw_list","cashApplyOfflineSuccessNotify","haobanNotice");
/**
* 消息类型
*/
......
......@@ -16,4 +16,11 @@ public interface CommissionTaskApiService {
* @param prams
*/
ServiceResponse<Void> handlerCommissionNotify(String prams);
/**
* 处理提现消息通知
* @param params
* @return
*/
ServiceResponse<Void> handlerCashNotify(String params);
}
......@@ -5,19 +5,20 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.api.dto.qdto.content.ClerkCashListQDTO;
import com.gic.haoban.manage.api.dto.qdto.content.ClerkCashNotifyQDTO;
import com.gic.haoban.manage.service.pojo.bo.commission.ClerkCommissionStaticsBO;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.message.NoticeMessageHandler;
import com.gic.message.center.api.subscribe.model.NoticeMessageForm;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author MUSI
......@@ -77,4 +78,52 @@ public class CommissionNotifyInnerService {
noticeMessageHandler.sendMessage(noticeMessageForm);
}
/**
* 处理提现消息
* @param clerkCashNotifyQDTO
*/
public void handlerCashNotify(ClerkCashNotifyQDTO clerkCashNotifyQDTO) {
log.info("handlerCashNotify params:{}", JSONObject.toJSONString(clerkCashNotifyQDTO));
List<ClerkCashListQDTO> cashList = clerkCashNotifyQDTO.getCashList();
if (CollectionUtils.isEmpty(cashList)) {
log.info("导购提现消息列表为空");
return;
}
List<String> clerkIdList = cashList.stream().map(ClerkCashListQDTO::getClerkId).collect(Collectors.toList());
List<StaffClerkRelationDTO> list = staffClerkRelationService.listByClerkIds(clerkIdList);
if (CollectionUtils.isEmpty(list)) {
log.info("handlerCashNotify 处理导购提现消息,导购不存在 {}", JSON.toJSONString(clerkIdList));
return;
}
Map<String, BigDecimal> cashMap = cashList.stream().collect(Collectors.toMap(ClerkCashListQDTO::getClerkId, ClerkCashListQDTO::getApplyAmount));
for (StaffClerkRelationDTO staffClerkRelationDTO : list) {
String staffId = staffClerkRelationDTO.getStaffId();
String clerkId = staffClerkRelationDTO.getClerkId();
String uniqueKey = UUID.randomUUID().toString().replaceAll("-", "");
Map<String, String> params = new HashMap<>();
params.put("currentTab", "1");
BigDecimal applyAmount = cashMap.get(clerkId);
params.put("applyAmount", applyAmount.toPlainString());
JSONObject innerParams = new JSONObject();
innerParams.put("currentTab", "1");
NoticeMessageTypeEnum cashTypeEnum = clerkCashNotifyQDTO.getCashTypeEnum();
String pageUrl = NoticeMessageUtil.buildMiniAppUrl(cashTypeEnum, innerParams.toJSONString());
params.put("page", pageUrl);
params.put("pageParams", innerParams.toJSONString());
NoticeMessageForm noticeMessageForm = NoticeMessageForm
.builder()
.businessId(clerkId)
.messageCode(cashTypeEnum.getMessageCode())
.mqRouterCode(cashTypeEnum.getRouterCode())
.enterpriseId(clerkCashNotifyQDTO.getEnterpriseId())
.uniqueKey(uniqueKey)
.createTime(new Date())
.userIdList(Collections.singletonList(clerkId))
.variableMap(params)
.build();
noticeMessageForm.setStaffIdList(Collections.singletonList(staffId));
noticeMessageHandler.sendMessage(noticeMessageForm,true);
}
}
}
......@@ -3,15 +3,14 @@ package com.gic.haoban.manage.service.service.message;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.haoban.manage.service.service.notify.out.NoticeMessageApiServiceImpl;
import com.gic.message.center.api.subscribe.model.NoticeMessageForm;
import com.gic.mq.sdk.GicMQClient;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
import static org.slf4j.LoggerFactory.getLogger;
......@@ -28,6 +27,10 @@ public class NoticeMessageHandler {
* 发送小程序消息
*/
public void sendMessage(NoticeMessageForm noticeMessageForm){
sendMessage(noticeMessageForm, false);
}
public void sendMessage(NoticeMessageForm noticeMessageForm,boolean delay){
logger.info("消息中心发送消息实体:{}", JSONObject.toJSONString(noticeMessageForm));
if (ObjectUtil.isEmpty(noticeMessageForm.getMessageCode()) || ObjectUtil.isEmpty(noticeMessageForm.getMqRouterCode())) {
......@@ -35,9 +38,36 @@ public class NoticeMessageHandler {
}
GicMQClient client = GICMQClientUtil.getClientInstance();
try {
client.sendMessage(noticeMessageForm.getMqRouterCode(), JSONObject.toJSONString(noticeMessageForm));
client.sendMessage(noticeMessageForm.getMqRouterCode(), JSONObject.toJSONString(noticeMessageForm), sendDelayValue(delay));
} catch (Exception e) {
logger.error("消息中心发送消息实体发送异常 ", e);
}
}
private int sendDelayValue(boolean delay) {
if (!delay) {
return 0;
}
LocalDateTime currentDateTime = LocalDateTime.now();
// 设置当天的8点
LocalDateTime dateTime8AM = LocalDateTime.of(currentDateTime.toLocalDate(), LocalTime.of(8, 0, 0));
// 设置当天的22点
LocalDateTime dateTime10PM = LocalDateTime.of(currentDateTime.toLocalDate(), LocalTime.of(22, 0, 0));
// 设置明天的8点
LocalDateTime nextDay8AM = dateTime8AM.plusDays(1);
long secondsDiff;
if (currentDateTime.isAfter(dateTime8AM) && currentDateTime.isBefore(dateTime10PM)) {
secondsDiff = 0;
} else if (currentDateTime.isAfter(dateTime10PM) && currentDateTime.isBefore(nextDay8AM)) {
secondsDiff = dateTime10PM.until(nextDay8AM, ChronoUnit.SECONDS);
} else {
secondsDiff = currentDateTime.until(dateTime8AM, ChronoUnit.SECONDS);
}
return (int) secondsDiff;
}
}
......@@ -3,6 +3,7 @@ package com.gic.haoban.manage.service.service.out.impl.content.task;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.service.content.task.CommissionTaskApiService;
import com.gic.haoban.manage.api.dto.qdto.content.ClerkCashNotifyQDTO;
import com.gic.haoban.manage.service.pojo.bo.commission.ClerkCommissionStaticsBO;
import com.gic.haoban.manage.service.service.commission.CommissionNotifyInnerService;
import org.apache.commons.lang3.StringUtils;
......@@ -40,4 +41,15 @@ public class CommissionTaskApiServiceImpl implements CommissionTaskApiService {
commissionNotifyInnerService.handlerCommissionNotify(commissionStaticsBO);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> handlerCashNotify(String params) {
if (StringUtils.isBlank(params)) {
log.info("处理导购提现消息通知, 参数为空 {}", params);
return ServiceResponse.success();
}
ClerkCashNotifyQDTO clerkCashNotifyQDTO = JSON.parseObject(params, ClerkCashNotifyQDTO.class);
commissionNotifyInnerService.handlerCashNotify(clerkCashNotifyQDTO);
return ServiceResponse.success();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment