Commit 20127ca8 by 王祖波

Merge branch 'feature-content3' into 'master'

Feature content3

See merge request !1345
parents 2c475469 d1adb4e2
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;
}
}
package com.gic.haoban.manage.api.dto.statistics.commission;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Author MUSI
* @Date 2023/6/9 9:49 AM
* @Description
* @Version
**/
public class ClerkCommissionStaticsDTO implements Serializable {
/**
* 企业id
*/
private String enterpriseId;
/**
* 导购id
*/
private String clerkId;
/**
* 客户数量
*/
private Integer memberCount;
/**
* 佣金金额
*/
private BigDecimal commissionAmount;
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public Integer getMemberCount() {
return memberCount;
}
public void setMemberCount(Integer memberCount) {
this.memberCount = memberCount;
}
public BigDecimal getCommissionAmount() {
return commissionAmount;
}
public void setCommissionAmount(BigDecimal commissionAmount) {
this.commissionAmount = commissionAmount;
}
}
......@@ -10,7 +10,7 @@ public enum AlertTypeEnum {
CLOUD_STORE_CHANGE(4, "观云台门店进回收站", null),
ES_BID_PAGE(5, "es查询存在大分页", "https://oapi.dingtalk.com/robot/send?access_token=04b381d2b95816d28ed37c73d300537cbd2e67dc6670258ab85a6b3ef227d3b3"),
GET_NEW_EXTERNAL_USERID(6, "转换外部联系人id", null),
WEWORK_PAY(7, "向员工付款", null),
WEWORK_PAY(7, "向员工付款", "https://oapi.dingtalk.com/robot/send?access_token=c5b67bc21d943eca362b951c9a7030822cec63b7220feb8cdcdfbc88b6438172"),
FEE_ALARM(8, "30天后接口许可证即将到期", "https://oapi.dingtalk.com/robot/send?access_token=8bff312a35700ae99a4b8a26d90038fe6bddc5e3e6a0a0d348c9c84c0473979a"),
;
private Integer type;
......
......@@ -75,11 +75,15 @@ public enum NoticeMessageTypeEnum {
//
MATERIAL_NEW_NOTIFY(6001, "素材上新通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_new_notify", "/pages/route/index?pageType=", "hbapp_material_center", "materialsNotice", "clerkMaterialsNotice"),
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"),
POTENTIAL_CUSTOMER_NOTIFY(6003, "销售线索通知", NoticeMessageCategoryTypeEnum.POTENTIAL_CUSTOMER.getType(), "potential_customer_notify", "/pages/route/index?pageType=", "hbapp_sales_clue_center", "salesLeadNotice", "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");
/**
* 消息类型
*/
......
package com.gic.haoban.manage.api.service.content.task;
import com.gic.api.base.commons.ServiceResponse;
/**
* @Author MUSI
* @Date 2023/6/7 2:15 PM
* @Description
* @Version
* 佣金统计接口
**/
public interface CommissionTaskApiService {
/**
* 处理佣金消息通知
* @param prams
*/
ServiceResponse<Void> handlerCommissionNotify(String prams);
/**
* 处理提现消息通知
* @param params
* @return
*/
ServiceResponse<Void> handlerCashNotify(String params);
}
......@@ -3,6 +3,7 @@ package com.gic.haoban.manage.api.service.out;
import java.util.List;
import com.gic.haoban.manage.api.dto.SecretSettingDTO;
import org.hibernate.event.spi.SaveOrUpdateEvent;
/**
* @author mozhu
......@@ -16,6 +17,20 @@ public interface SecretSettingApiService {
* @return
*/
SecretSettingDTO getSecretSetting(String wxEnterpriseId, int secretType);
/**
* 获取SecretSetting列表
* @param wxEnterpriseIdList
* @param secretType
* @return
*/
List<SecretSettingDTO> getSecretSettingList(List<String> wxEnterpriseIdList, int secretType);
/**
* 保存或更新配置
* @param secretSetting
*/
void saveOrUpdateSecretSetting(SecretSettingDTO secretSetting);
public List<SecretSettingDTO> exsitGicEidMemberApp(String wxEnterpriseId);
}
......@@ -40,6 +40,17 @@ public interface SecretSettingMapper {
TabSecretSetting getSecretSetting(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("secretType") int secretType,
@Param("enterpriseId") String enterpriseId);
/**
* 批量获取配置
* @param wxEnterpriseIdList
* @param secretType
* @param enterpriseId
* @return
*/
List<TabSecretSetting> getSecretSettingList(@Param("wxEnterpriseIdList") List<String> wxEnterpriseIdList,
@Param("secretType") int secretType,
@Param("enterpriseId") String enterpriseId);
/**
*
......
package com.gic.haoban.manage.service.pojo.bo.commission;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Author MUSI
* @Date 2023/6/7 2:26 PM
* @Description
* @Version
**/
@Data
public class ClerkCommissionStaticsBO implements Serializable {
/**
* 企业id
*/
private String enterpriseId;
/**
* 导购id
*/
private String clerkId;
/**
* 客户数量
*/
private Integer memberCount;
/**
* 佣金金额
*/
private BigDecimal commissionAmount;
}
......@@ -4,8 +4,6 @@ import com.gic.haoban.manage.api.dto.SecretSettingDTO;
import java.util.List;
import org.apache.ibatis.annotations.Param;
/**
* Created 2020/6/3.
*
......@@ -42,6 +40,14 @@ public interface SecretSettingService {
public SecretSettingDTO getSecretSetting(String wxEnterpriseId,int secretType);
/**
* 通过wx企业id获取密钥设置列表
* @param wxEnterpriseIdList
* @param secretType
* @return
*/
public List<SecretSettingDTO> getSecretSettingList(List<String> wxEnterpriseIdList, int secretType);
/**
* 根据会员小程序类型获取
* @param wxEnterpriseId
* @param enterpriseId
......
package com.gic.haoban.manage.service.service.commission;
import com.alibaba.fastjson.JSON;
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.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author MUSI
* @Date 2023/6/7 2:31 PM
* @Description
* @Version
* 佣金服务内部服务
**/
@Slf4j
@Component
public class CommissionNotifyInnerService {
@Autowired
private StaffClerkRelationService staffClerkRelationService;
@Autowired
private NoticeMessageHandler noticeMessageHandler;
/**
* 处理导购佣金
* @param commissionStaticsBo
*/
public void handlerCommissionNotify(ClerkCommissionStaticsBO commissionStaticsBo) {
log.info("handlerCommissionNotify params:{}", JSONObject.toJSONString(commissionStaticsBo));
String clerkId = commissionStaticsBo.getClerkId();
StaffClerkRelationDTO staffClerkRelationDTO = staffClerkRelationService.getByClerkId(clerkId);
if (staffClerkRelationDTO == null) {
log.info("handlerCommissionNotify 处理导购佣金消息,导购不存在 {}", clerkId);
return;
}
if (staffClerkRelationDTO.getClerkType() != null && staffClerkRelationDTO.getClerkType() == 2) {
log.info("导购为区经角色 {}, 不发送消息", JSON.toJSONString(staffClerkRelationDTO));
return;
}
String staffId = staffClerkRelationDTO.getStaffId();
String uniqueKey = UUID.randomUUID().toString().replaceAll("-", "");
Map<String, String> params = new HashMap<>();
params.put("currentTab", "0");
params.put("commissAmount", commissionStaticsBo.getCommissionAmount().toPlainString());
params.put("memberNum", commissionStaticsBo.getMemberCount() + "");
JSONObject innerParams = new JSONObject();
innerParams.put("currentTab", "0");
String pageUrl = NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.CLERK_COMMISSION_NOTIFY, innerParams.toJSONString());
params.put("page", pageUrl);
params.put("pageParams", innerParams.toJSONString());
NoticeMessageForm noticeMessageForm = NoticeMessageForm
.builder()
.businessId(clerkId)
.messageCode(NoticeMessageTypeEnum.CLERK_COMMISSION_NOTIFY.getMessageCode())
.mqRouterCode(NoticeMessageTypeEnum.CLERK_COMMISSION_NOTIFY.getRouterCode())
.enterpriseId(commissionStaticsBo.getEnterpriseId())
.uniqueKey(uniqueKey)
.createTime(new Date())
.userIdList(Collections.singletonList(clerkId))
.variableMap(params)
.build();
noticeMessageForm.setStaffIdList(Collections.singletonList(staffId));
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);
}
}
}
......@@ -85,6 +85,13 @@ public class SecretSettingServiceImpl implements SecretSettingService {
}
@Override
public List<SecretSettingDTO> getSecretSettingList(List<String> wxEnterpriseIdList, int secretType) {
List<TabSecretSetting> secretSettingList = secretSettingMapper.getSecretSettingList(wxEnterpriseIdList, secretType, null);
return EntityUtil.changeEntityListByJSON(SecretSettingDTO.class, secretSettingList);
}
@Override
public SecretSettingDTO getMemberSecretSetting(String wxEnterpriseId, String enterpriseId) {
if (StringUtils.isNotBlank(enterpriseId) && !"-1".equals(enterpriseId)) {
TabSecretSetting secretSetting = secretSettingMapper.getSecretSetting(wxEnterpriseId, SecretTypeEnum.MEMBER_WAPP.getVal(), enterpriseId);
......
......@@ -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;
}
}
......@@ -21,6 +21,7 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
......@@ -208,6 +209,7 @@ public class CheckQywxSettingApiServiceImpl implements CheckQywxSettingApiServic
text.append("链路:[").append(messageDTO.getTraceId()).append("](").append(traceUrl).append(")");
}
markdownMap.put("text", text.toString());
logger.info("dingding推送Url:{}", dingUrl);
String post = HttpUtil.post(dingUrl, JSONObject.toJSONString(dingMap));
logger.info("dingding推送alert:{}", post);
......
......@@ -22,7 +22,17 @@ public class SecretSettingApiServiceImpl implements SecretSettingApiService {
public SecretSettingDTO getSecretSetting(String wxEnterpriseId, int secretType) {
return secretSettingService.getSecretSetting(wxEnterpriseId, secretType);
}
@Override
public List<SecretSettingDTO> getSecretSettingList(List<String> wxEnterpriseIdList, int secretType) {
return secretSettingService.getSecretSettingList(wxEnterpriseIdList, secretType);
}
@Override
public void saveOrUpdateSecretSetting(SecretSettingDTO secretSetting) {
secretSettingService.saveSecretSetting(secretSetting);
}
@Override
public List<SecretSettingDTO> exsitGicEidMemberApp(String wxEnterpriseId) {
return this.secretSettingService.exsitGicEidMemberApp(wxEnterpriseId);
......
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @Author MUSI
* @Date 2023/6/7 2:16 PM
* @Description
* @Version
**/
@Component("commissionTaskApiService")
public class CommissionTaskApiServiceImpl implements CommissionTaskApiService {
@Autowired
private CommissionNotifyInnerService commissionNotifyInnerService;
private static final Logger log = LoggerFactory.getLogger(CommissionTaskApiService.class);
/**
* 处理佣金消息通知
*
* @param params
*/
@Override
public ServiceResponse<Void> handlerCommissionNotify(String params) {
if (StringUtils.isBlank(params)) {
log.info("处理导购佣金消息通知, 参数为空 {}", params);
return ServiceResponse.success();
}
ClerkCommissionStaticsBO commissionStaticsBO = JSON.parseObject(params, ClerkCommissionStaticsBO.class);
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();
}
}
......@@ -227,4 +227,7 @@
<dubbo:reference interface="com.gic.member.api.service.MemberOutApiService" id="memberOutApiService" timeout="10000" retries="0" check="false"/>
<dubbo:reference interface="com.gic.operating.api.service.HaobanWxEnterpriseApiService" id="haobanWxEnterpriseApiService" timeout="10000" retries="0" check="false"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.content.task.CommissionTaskApiService"
ref="commissionTaskApiService" timeout="10000" />
</beans>
\ No newline at end of file
......@@ -96,6 +96,22 @@
</if>
ORDER BY create_time desc LIMIT 1
</select>
<select id="getSecretSettingList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_haoban_secret_setting
where wx_enterprise_id in
<foreach collection="wxEnterpriseIdList" item="wxEnterpriseId" open="(" separator="," close=")">
#{wxEnterpriseId,jdbcType=VARCHAR}
</foreach>
and status_flag=1
and secret_type=#{secretType}
<if test="enterpriseId!=null">
and enterprise_id=#{enterpriseId,jdbcType=VARCHAR}
</if>
ORDER BY create_time desc
</select>
<select id="exsitGicEidMemberApp" resultType="com.gic.haoban.manage.api.dto.SecretSettingDTO">
select enterprise_id enterpriseId , secret_id secretId from tab_haoban_secret_setting where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
......
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.service.content.task.CommissionTaskApiService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @Author MUSI
* @Date 2023/6/7 4:34 PM
* @Description
* @Version
**/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class CommissionClerkTest {
@Autowired
private CommissionTaskApiService commissionTaskApiService;
@Test
public void clerkCommission() {
ServiceResponse<Void> serviceResponse = commissionTaskApiService.handlerCommissionNotify("");
System.out.println(JSON.toJSONString(serviceResponse));
}
}
......@@ -66,7 +66,7 @@ public class HmLinkTest {
HmBatchModifyQDTO qdto = new HmBatchModifyQDTO();
qdto.setHmIdList(Arrays.asList(517064205447217236L,457922550308036636L));
qdto.setWxEnterpriseId("ca66a01b79474c40b3e7c7f93daf1a3b");
qdto.setOptStaffId("fefd1c81641711e69d0818c58a146fd2");
//qdto.setOptStaffId("fefd1c81641711e69d0818c58a146fd2");
qdto.setOptName("达摩管理员");
qdto.setOptType(1);
qdto.setClerkIdList(Arrays.asList("4a566818111a45bbae9f962580df82c0"));
......
......@@ -246,6 +246,12 @@
<artifactId>haoban-task-api</artifactId>
<version>${haoban-task-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>haoban-commission-api</artifactId>
<version>${haoban-commission-api}</version>
</dependency>
</dependencies>
<build>
......
package com.gic.haoban.manage.web.controller.commission;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.commission.api.dto.commissiondetail.CommissionSettleDetailDTO;
import com.gic.haoban.commission.api.qdto.commissiondetail.CommissionSettleOrderItemQDTO;
import com.gic.haoban.commission.api.qdto.commissiondetail.CommissionSettleOrderQDTO;
import com.gic.haoban.commission.api.service.local.CommissionSettleDetailApiService;
import com.gic.haoban.manage.web.controller.goods.GoodsInfoAdaptor;
import com.gic.store.goods.dto.goods.GoodsSpuInfoDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @Author MUSI
* @Date 2023/6/16 4:30 PM
* @Description
* @Version
* 佣金管理
**/
@Slf4j
@Component
public class CommissionManager {
@Autowired
private GoodsInfoAdaptor goodsInfoAdaptor;
@Autowired
private CommissionSettleDetailApiService commissionSettleDetailApiService;
/**
* 查询商品佣金
* @param enterpriseId
* @param storeId
* @param clerkId
* @param goodsIds
* @return
*/
public Map<String, BigDecimal> calcGoodsCommission(String enterpriseId, String storeId, String clerkId, List<String> goodsIds) {
if (CollectionUtils.isEmpty(goodsIds)) {
return Collections.emptyMap();
}
if (StringUtils.isAnyBlank(storeId, clerkId, enterpriseId)) {
log.info("查询商品佣金异常 参数缺失 storeId:{} clerkID:{}", storeId, clerkId);
return Collections.emptyMap();
}
Map<String, GoodsSpuInfoDTO> minPriceMap = goodsInfoAdaptor.queryGoodsMinPrice(enterpriseId, goodsIds);
if (MapUtils.isEmpty(minPriceMap)) {
log.info("计算商品佣金 参数异常");
return Collections.emptyMap();
}
List<CommissionSettleOrderItemQDTO> settleOrderItems = new ArrayList<>();
for (Map.Entry<String, GoodsSpuInfoDTO> entry : minPriceMap.entrySet()) {
String goodsId = entry.getKey();
GoodsSpuInfoDTO goodsSpuInfoDTO = entry.getValue();
CommissionSettleOrderItemQDTO commissionSettleOrderItemQDTO = new CommissionSettleOrderItemQDTO();
commissionSettleOrderItemQDTO.setGoodsId(goodsId);
commissionSettleOrderItemQDTO.setGoodsCode(goodsSpuInfoDTO.getGoodsCode());
commissionSettleOrderItemQDTO.setGoodsNum(1);
commissionSettleOrderItemQDTO.setGoodsPayAmount(goodsSpuInfoDTO.getMinPrice().doubleValue());
settleOrderItems.add(commissionSettleOrderItemQDTO);
}
CommissionSettleOrderQDTO commissionSettleOrderQDTO = new CommissionSettleOrderQDTO();
commissionSettleOrderQDTO.setIsOrder(0);
commissionSettleOrderQDTO.setOrderChannel(1);
commissionSettleOrderQDTO.setEnterpriseId(enterpriseId);
commissionSettleOrderQDTO.setOrderStoreId(storeId);
commissionSettleOrderQDTO.setOrderClerkId(clerkId);
commissionSettleOrderQDTO.setItems(settleOrderItems);
log.info("计算商品佣金参数: {}", JSON.toJSONString(commissionSettleOrderQDTO));
ServiceResponse<List<CommissionSettleDetailDTO>> serviceResponse = commissionSettleDetailApiService.calcDetailByOrder(commissionSettleOrderQDTO);
log.info("计算商品佣金结果: {}", JSON.toJSONString(serviceResponse));
if (!serviceResponse.isSuccess() || CollectionUtils.isEmpty(serviceResponse.getResult())) {
log.info("计算商品佣金, 商品佣金为空 {}", JSON.toJSONString(serviceResponse));
return Collections.emptyMap();
}
return serviceResponse.getResult()
.stream()
.collect(Collectors.toMap(CommissionSettleDetailDTO::getGoodsId, item -> {
Double commissionAmount = item.getCommissionAmount();
return Optional.ofNullable(commissionAmount).map(BigDecimal::new).orElse(BigDecimal.ZERO);
}, (v1, v2) -> v1));
}
}
......@@ -17,6 +17,7 @@ import com.gic.content.api.service.ContentMaterialApiService;
import com.gic.content.api.service.ContentMaterialShareApiService;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.web.controller.commission.CommissionManager;
import com.gic.haoban.manage.web.controller.content.adaptor.ClerkStoreAdaptor;
import com.gic.haoban.manage.web.controller.goods.GoodsInfoAdaptor;
import com.gic.haoban.manage.web.qo.content.ContentColumnClerkViewQO;
......@@ -36,10 +37,12 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
......@@ -56,11 +59,12 @@ public class ContentMaterialController {
private ContentMaterialApiService contentMaterialApiService;
@Autowired
private ContentMaterialShareApiService contentMaterialShareApiService;
@Autowired
private ClerkStoreAdaptor clerkStoreAdaptor;
@Autowired
private GoodsInfoAdaptor goodsInfoAdaptor;
@Autowired
private CommissionManager commissionManager;
/**
......@@ -141,8 +145,16 @@ public class ContentMaterialController {
Page<ContentMaterialFrontDTO> responseResult = serviceResponse.getResult();
Page<ContentMaterialInfoVO> result = new Page<>();
result.setTotalCount(responseResult.getTotalCount());
List<String> goodsIds = responseResult.getResult()
.stream()
.filter(item -> CollectionUtils.isNotEmpty(item.getContentGoodsList()))
.map(item -> item.getContentGoodsList().get(0).getGoodsId())
.distinct()
.collect(Collectors.toList());
Map<String, BigDecimal> commissionMap = commissionManager.calcGoodsCommission(contentMaterialQO.getEnterpriseId(), contentMaterialQO.getStoreId(),
contentMaterialQO.getClerkId(), goodsIds);
List<ContentMaterialInfoVO> contentMaterialInfos = responseResult.getResult().stream()
.map(item -> getContentMaterialInfoVO(goodsShowStatus, item))
.map(item -> getContentMaterialInfoVO(goodsShowStatus, item, commissionMap))
.collect(Collectors.toList());
result.setResult(contentMaterialInfos);
result.setCurrentPage(contentMaterialQO.getPageNum());
......@@ -156,7 +168,7 @@ public class ContentMaterialController {
* @param item
* @return
*/
private ContentMaterialInfoVO getContentMaterialInfoVO(List<Integer> goodsShowStatus, ContentMaterialFrontDTO item) {
private ContentMaterialInfoVO getContentMaterialInfoVO(List<Integer> goodsShowStatus, ContentMaterialFrontDTO item, Map<String, BigDecimal> commissionMap) {
ContentMaterialInfoVO contentMaterialInfoVO = new ContentMaterialInfoVO();
BeanUtils.copyProperties(item, contentMaterialInfoVO);
if (CollectionUtils.isNotEmpty(item.getContentGoodsList())) {
......@@ -167,6 +179,8 @@ public class ContentMaterialController {
SimpleGoodsInfoVO simpleGoodsInfoVO = new SimpleGoodsInfoVO();
BeanUtils.copyProperties(temp, simpleGoodsInfoVO);
simpleGoodsInfoVO.setGoodsImg(temp.getGoodsImageUrl());
BigDecimal commission = commissionMap.get(temp.getGoodsId());
simpleGoodsInfoVO.setCommission(commission);
return simpleGoodsInfoVO;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(goodsInfoVOS)) {
......
......@@ -5,9 +5,9 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.app.aggregation.api.dto.GoodsSettingDTO;
import com.gic.haoban.app.aggregation.api.service.SettingApiService;
import com.gic.haoban.manage.web.qo.content.ContentMaterialQO;
import com.gic.store.goods.dto.goods.GoodsSpuInfoDTO;
import com.gic.store.goods.dto.qdto.GoodsListQDTO;
import com.gic.store.goods.service.GoodsCenterApiService;
import com.gic.store.goods.service.GoodsInfoOutApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -19,6 +19,8 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -37,6 +39,8 @@ public class GoodsInfoAdaptor {
private SettingApiService settingApiService;
@Autowired
private GoodsInfoOutApiService goodsInfoOutApiService;
@Autowired
private GoodsCenterApiService goodsCenterApiService;
public List<String> queryGoodsIdWithSearch(String enterpriseId, String search) {
// 根据关键字查询1000个商品
......@@ -101,4 +105,26 @@ public class GoodsInfoAdaptor {
}
return showStatus;
}
/**
* 查询商品最小价格
* @param enterpriseId
* @param goodsIds
* @return
*/
public Map<String, GoodsSpuInfoDTO> queryGoodsMinPrice(String enterpriseId, List<String> goodsIds) {
if (org.springframework.util.CollectionUtils.isEmpty(goodsIds)) {
return Collections.emptyMap();
}
ServiceResponse<List<GoodsSpuInfoDTO>> serviceResponse = goodsCenterApiService.queryGoodsMinPrice(enterpriseId, goodsIds);
if (!serviceResponse.isSuccess() || com.alibaba.dubbo.common.utils.CollectionUtils.isEmpty(serviceResponse.getResult())) {
log.info("查询商品最小价格异常 {}", JSON.toJSONString(serviceResponse));
return Collections.emptyMap();
}
return serviceResponse
.getResult()
.stream()
.collect(Collectors.toMap(GoodsSpuInfoDTO::getGoodsId, Function.identity()));
}
}
......@@ -25,6 +25,11 @@ public class ContentMaterialShareInfoVO implements Serializable {
private String goodsShortLink;
/**
* 短链错误信息
*/
private String linkErrMsg;
/**
* 商品二维码
*/
private String goodsQrcode;
......
......@@ -61,5 +61,10 @@ public class SimpleGoodsInfoVO implements Serializable {
*/
private Integer status;
/**
* 商品佣金
*/
private BigDecimal commission;
}
......@@ -145,5 +145,9 @@
<dubbo:reference interface="com.gic.haoban.task.api.service.TelTaskApiService" id="telTaskApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference id="dataTargetConfigNewVersionsApiService" interface="com.gic.enterprise.api.service.target.DataTargetConfigNewVersionsApiService" timeout="100000" retries="0" check="false" />
<dubbo:reference id="storeGroupService" interface="com.gic.enterprise.api.service.StoreGroupService" timeout="10000" retries="0" check="false" />
<dubbo:reference interface="com.gic.store.goods.service.GoodsCenterApiService"
id="goodsCenterApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference interface="com.gic.haoban.commission.api.service.local.CommissionSettleDetailApiService"
id="commissionSettleDetailApiService" timeout="10000" retries="0" check="false" />
</beans>
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