提交 4b1c0742 作者: gh

Merge remote-tracking branch 'origin/master'

......@@ -403,6 +403,8 @@ public class CustomerServiceCommonAsyncComponent {
// 遍历处理客服链接
int idx = 1;
boolean normal = true;
boolean needLink = true;
for (ReferralEntity sourceReferralEntity : sourceReferralList) {
// 生成新的链接数据
ReferralEntity targetReferralEntity = new ReferralEntity();
......@@ -431,12 +433,16 @@ public class CustomerServiceCommonAsyncComponent {
// 常用链接
generateDelayUsualLink(dateStr, targetReferralEntity, targetAuthInfo);
} else {
needLink = false;
LOCAL_LOG.info("newsType: {}, 不需要获取链接", newsType);
}
targetReferralEntityList.add(targetReferralEntity);
// 图文主表只有一个素材链接,文本主表不需要存素材链接
String referral = targetReferralEntity.getReferral();
if (needLink && StringUtils.isBlank(referral)) {
normal = false;
}
targetCustomerGraphics.setSourceUrl(referral);
if (type.equals(CustomerCommonConstant.CUSTOMER_TYPE_VALUE_TEXT)) {
// 文本类型替换h5链接
......@@ -457,8 +463,8 @@ public class CustomerServiceCommonAsyncComponent {
idx += 1;
}
}
targetCustomerGraphics.setSendStatus(normal ? CustomerCommonConstant.SEND_STATUS_ACTIVE : CustomerCommonConstant.SEND_STATUS_LINK_ERROR);
targetCustomerGraphics.setSendStatus(CustomerCommonConstant.SEND_STATUS_ACTIVE);
if (StringUtils.isNotBlank(h5Context)) {
targetCustomerGraphics.setContent(h5Context.toString().replace(CustomerCommonConstant.H5_STYLE_CODE, ""));
}
......@@ -548,7 +554,7 @@ public class CustomerServiceCommonAsyncComponent {
* 以下是公有方法
*/
public void getCopyReferral(String dateStr, AuthInfoVO authInfoVo, ReferralEntity referralEntity) {
// ygAccessLimit(true, authInfoVo.getStoreType());
ygAccessLimit(true, authInfoVo.getStoreType());
referralEntity.setStoreType(authInfoVo.getStoreType());
// 非常用链接类型的name需要处理
String name = referralEntity.getName();
......@@ -649,6 +655,7 @@ public class CustomerServiceCommonAsyncComponent {
@RabbitListener(queues = RabbitCommonNameConstant.YG_LIMIT_DEATH_QUEUE)
public void listener() {
LOCAL_LOG.info("消费");
redisTemplate.opsForValue().decrement(CustomerCommonConstant.YANG_GUANG_ACCESS_LIMIT_REDIS_KEY);
}
......
......@@ -37,4 +37,6 @@ public class CrowdPackageCommonConstant {
public static final Pattern NUMBER_COMPILE = Pattern.compile("[\\d]");
public static final Long HOUR_TO_MILLION_RATE = 60 * 60 * 1000L;
}
......@@ -63,7 +63,7 @@ public class CustomerCommonConstant {
public final static Integer SEND_STATUS_ACTIVE = 9;
public final static Integer SEND_STATUS_SENT_SUCCESS = 3;
public final static Integer SEND_STATUS_LINK_ERROR = 3;
public final static Integer SEND_STATUS_SENT_FAIL = 4;
......
......@@ -11,6 +11,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.List;
/**
......@@ -28,8 +29,11 @@ public class CrowdPackageController {
@ApiOperation("新增人群包")
@GetMapping("/insertPackage")
public GenericsResult<CrowdPackageCommonIdVO> insertCrowdPackage(@RequestParam(required = false) Long id, @RequestParam(required = false) String name) {
return crowdPackageService.insertCrowdPackage(id, name);
public GenericsResult<CrowdPackageCommonIdVO> insertCrowdPackage(@RequestParam(required = false) Long id,
@RequestParam(required = false) String name,
@RequestParam(required = false) Double activeTimeMin,
@RequestParam(required = false) Double activeTimeMax) {
return crowdPackageService.insertCrowdPackage(id, name, activeTimeMin, activeTimeMax);
}
@ApiOperation("向人群包内新增条件")
......
......@@ -3,9 +3,11 @@ package com.yaoyaozw.customer.entity;
import java.io.Serializable;
import java.util.Date;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yaoyaozw.customer.constants.CrowdPackageCommonConstant;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
......@@ -34,6 +36,18 @@ public class CrowdPackage implements Serializable {
private String packageName;
/**
* 活跃时间左边界
*/
@TableField("active_time_min")
private Long activeTimeMin;
/**
* 活跃时间右边界
*/
@TableField("active_time_max")
private Long activeTimeMax;
/**
* 人群包用户人数
*/
@TableField("crowd_num")
......@@ -71,9 +85,15 @@ public class CrowdPackage implements Serializable {
private static final long serialVersionUID = 1L;
public CrowdPackage(Long id, String packageName) {
public CrowdPackage(Long id, String packageName, Double activeTimeMin, Double activeTimeMax) {
this.id = id;
this.packageName = packageName;
if (ObjectUtil.isNotNull(activeTimeMin)) {
this.activeTimeMin = activeTimeMin.longValue() * CrowdPackageCommonConstant.HOUR_TO_MILLION_RATE;
}
if (ObjectUtil.isNotNull(activeTimeMax)) {
this.activeTimeMax = activeTimeMax.longValue() * CrowdPackageCommonConstant.HOUR_TO_MILLION_RATE;
}
}
public void handleInfo(Date now, Long userId, Boolean isCreate) {
......
......@@ -51,11 +51,6 @@ public interface KanbanCommonMapper {
*/
List<CommonOptionResponseVO> getStoreTypeEntity(@Param("storeKeySet") Set<String> storeKeySet);
/**
* @param appId 应用程序id
* @return {@link String}
*/
String getStoreTypeNameByAppId(@Param("appId") String appId);
......
......@@ -57,4 +57,10 @@ public interface MaterialCommonMapper {
*/
List<CustomerCommonLink> getCommonLinkMapping(@Param("currentKey") String currentKey);
/**
* @param appId 应用程序id
* @return {@link String}
*/
String getStoreTypeNameByAppId(@Param("appId") String appId);
}
......@@ -38,8 +38,6 @@ public class SchedulingTask {
private CustomerDelayPublishService customerDelayPublishService;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private CrowdPackageServiceImpl crowdPackageService;
......@@ -127,7 +125,7 @@ public class SchedulingTask {
/**
* 从redis中更新人群包人数
*/
// @Scheduled(cron = "0 0/15 * * * ?")
@Scheduled(cron = "0 0/15 * * * ?")
public void updateCrowdPackageNumFromRedis() {
crowdPackageService.updateCrowdPackageNumFromRedis();
}
......
......@@ -7,6 +7,7 @@ import com.yaoyaozw.customer.dto.crowd.CrowdPackageQueryDTO;
import com.yaoyaozw.customer.dto.crowd.CrowdPackageConditionDTO;
import com.yaoyaozw.customer.entity.CrowdPackage;
import com.yaoyaozw.customer.vo.crowd.*;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
......@@ -20,9 +21,11 @@ public interface CrowdPackageService extends IService<CrowdPackage> {
*
* @param id 人群包id
* @param name 人群包名
* @param activeTimeMin 活跃时间左边界
* @param activeTimeMax 活跃时间右边界
* @return {@link BaseResult}
*/
GenericsResult<CrowdPackageCommonIdVO> insertCrowdPackage(Long id, String name);
GenericsResult<CrowdPackageCommonIdVO> insertCrowdPackage(Long id, String name, Double activeTimeMin, Double activeTimeMax);
/**
......
......@@ -65,12 +65,12 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
@Override
public GenericsResult<CrowdPackageCommonIdVO> insertCrowdPackage(Long id, String name) {
public GenericsResult<CrowdPackageCommonIdVO> insertCrowdPackage(Long id, String name, Double activeTimeMin, Double activeTimeMax) {
// 根据是否传了主键判断是创建还是更新
boolean isCreate = ObjectUtil.isNull(id);
// 获取操作人
Long userId = tokenManager.getUserIdFromToken();
CrowdPackage crowdPackage = new CrowdPackage(id, name);
CrowdPackage crowdPackage = new CrowdPackage(id, name, activeTimeMin, activeTimeMax);
crowdPackage.handleInfo(new Date(), userId, isCreate);
if (ObjectUtil.isNotNull(name)) {
// 判断是否有重名
......@@ -128,7 +128,7 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
if (ObjectUtil.isNull(byId)) {
return new GenericsResult<>(false, "无法获取主体数据");
}
CrowdPackageDetailVO vo = new CrowdPackageDetailVO(id, byId.getPackageName());
CrowdPackageDetailVO vo = new CrowdPackageDetailVO(byId);
// 获取条件数据
List<CrowdPackageConditionMatch> conditionMatchList = matchService.list(new QueryWrapper<CrowdPackageConditionMatch>().eq("package_id", id));
JSONArray jsonArray = JSONUtil.parseArray(conditionMatchList);
......
......@@ -18,6 +18,7 @@ import com.yaoyaozw.customer.entity.CustomerGraphicsDelay;
import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.mapper.CustomerGraphicsDelayMapper;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import com.yaoyaozw.customer.mapper.MaterialCommonMapper;
import com.yaoyaozw.customer.service.AuthorizerInfoService;
import com.yaoyaozw.customer.service.CustomerDelayTextService;
import com.yaoyaozw.customer.service.CustomerGraphicsDelayService;
......@@ -56,9 +57,9 @@ public class CustomerDelayTextServiceImpl extends ServiceImpl<CustomerGraphicsDe
@Autowired
private CustomerServiceCommonAsyncComponent commonAsyncComponent;
@Autowired
private KanbanCommonMapper kanbanCommonMapper;
@Autowired
private CustomerGraphicsDelayService graphicsDelayService;
@Autowired
private MaterialCommonMapper materialCommonMapper;
@Override
public GenericsResult<String> insertCustomerDelay(CustomerDelayTextSaveDTO saveDto) {
......@@ -113,7 +114,7 @@ public class CustomerDelayTextServiceImpl extends ServiceImpl<CustomerGraphicsDe
referralEntity.setName(nameModel);
}
String storeTypeName = kanbanCommonMapper.getStoreTypeNameByAppId(referralDto.getAppId());
String storeTypeName = materialCommonMapper.getStoreTypeNameByAppId(referralDto.getAppId());
referralEntity.setStoreTypeName(storeTypeName);
// 获取链接
// 日期
......
......@@ -21,6 +21,7 @@ import com.yaoyaozw.customer.entity.CustomerGraphicsDelay;
import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.mapper.CustomerGraphicsDelayMapper;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import com.yaoyaozw.customer.mapper.MaterialCommonMapper;
import com.yaoyaozw.customer.service.AuthorizerInfoService;
import com.yaoyaozw.customer.service.CustomerDelayTextService;
import com.yaoyaozw.customer.service.CustomerGraphicsDelayService;
......@@ -66,6 +67,8 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
private KanbanCommonMapper kanbanCommonMapper;
@Autowired
private CustomerServiceCommonAsyncComponent commonAsyncComponent;
@Autowired
private MaterialCommonMapper materialCommonMapper;
@Override
......@@ -122,6 +125,8 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
localLog.info("获取链接name模板: {}", linkNameModel);
referralEntity.setName(linkNameModel);
}
String storeTypeName = materialCommonMapper.getStoreTypeNameByAppId(customerGraphicsDelay.getAppId());
referralEntity.setStoreTypeName(storeTypeName);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
String dateStr = dateFormat.format(new Date());
......@@ -136,16 +141,18 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
return new BaseResult().error("获取链接异常" + e.getMessage());
}
}
try {
customerGraphicsDelay.setSourceUrl(referralEntity.getReferral());
} catch (Exception e) {
return new BaseResult().error(e.getMessage());
}
boolean mainResult = super.saveOrUpdate(customerGraphicsDelay);
if (!mainResult) {
localLog.info("主体数据生成异常");
return new BaseResult().error("新增/更新 主体数据异常");
}
String storeTypeName = kanbanCommonMapper.getStoreTypeNameByAppId(customerGraphicsDelay.getAppId());
referralEntity.setStoreTypeName(storeTypeName);
boolean referralResult = referralEntityService.saveOrUpdate(referralEntity);
if (!referralResult) {
return new BaseResult().error("新增/更新 链接数据异常");
......
package com.yaoyaozw.customer.vo.crowd;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.yaoyaozw.customer.constants.CrowdPackageCommonConstant;
import com.yaoyaozw.customer.entity.CrowdPackage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -26,11 +29,23 @@ public class CrowdPackageDetailVO implements Serializable {
@ApiModelProperty("人群包名")
private String packageName;
@ApiModelProperty("活跃时间左边界")
private Double activeTimeMin;
@ApiModelProperty("活跃时间右边界")
private Double activeTimeMax;
@ApiModelProperty("已配置的人群包条件")
private List<CrowdPackageConditionMatchVO> conditionList;
public CrowdPackageDetailVO(Long packageId, String packageName) {
this.packageId = packageId;
this.packageName = packageName;
public CrowdPackageDetailVO(CrowdPackage byId) {
this.packageId = byId.getId();
this.packageName = byId.getPackageName();
if (ObjectUtil.isNotNull(byId.getActiveTimeMin())) {
this.activeTimeMin = byId.getActiveTimeMin().doubleValue() / CrowdPackageCommonConstant.HOUR_TO_MILLION_RATE;
}
if (ObjectUtil.isNotNull(byId.getActiveTimeMax())) {
this.activeTimeMax = byId.getActiveTimeMax().doubleValue() / CrowdPackageCommonConstant.HOUR_TO_MILLION_RATE;
}
}
}
......@@ -51,15 +51,4 @@
</select>
<select id="getStoreTypeNameByAppId" resultType="java.lang.String">
select
se.store_name
from account_entity ae
left join store_entity se
on ae.store_id = se.id
where ae.app_id = #{appId}
and is_active = 1
</select>
</mapper>
\ No newline at end of file
......@@ -51,4 +51,16 @@
where dict_current_key = #{currentKey}
</if>
</select>
<select id="getStoreTypeNameByAppId" resultType="java.lang.String">
select
b.explanation
from authorizer_info a
left join account_dictionary b
on b.type = 'StoreType'
and a.store_type = b.`value`
where a.appid = #{appId}
limit 1
</select>
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论