Commit ccc5a09e by 吴博

feat: [1006296] 会员商品自动上架

parent bd921820
......@@ -9,6 +9,7 @@ import com.pcloud.common.utils.ResponseHandleUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -54,4 +55,17 @@ public class MemberActivityConsr {
}
return new HashMap<>();
}
public List<Long> getProductIdsByMemberActivity(Long activityId) {
if (null == activityId) {
return new ArrayList<>();
}
log.info("查平台会员作品id信息,activityIds=" + activityId);
try {
return ResponseHandleUtil.parseList(activityService.getProductIdsByMemberActivity(activityId), Long.class);
} catch (Exception e) {
log.error("查平台会员活动信息activityService.getProductIdsByMemberActivity" + e.getMessage(), e);
}
return new ArrayList<>();
}
}
......@@ -121,7 +121,6 @@ import com.pcloud.channelcenter.qrcode.entity.QrcodeTemp;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.channelcenter.wechat.entity.AccountSetting;
import com.pcloud.channelcenter.wechat.entity.Message;
import com.pcloud.combinedmarketing.memberActivity.dto.ActivityBaseInfoDTO;
import com.pcloud.combinedmarketing.memberActivity.dto.ActivityBaseInfoWithPriceDTO;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.constant.AdviserTaskConstants;
......@@ -150,7 +149,6 @@ import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.resourcecenter.product.dto.ProductLabelDto;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import com.pcloud.wechatgroup.wxwork.dto.WxworkGroupQrcodeBaseDTO;
import com.pcloud.wechatgroup.wxwork.dto.WxworkQrcodeBaseDTO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
......@@ -169,6 +167,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
......@@ -1729,9 +1728,44 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
this.updateOwnMessage4Qr(updateResourcePageVO.getSceneId());
this.sendMemberActivityQueue(resourcePageId);
});
//更新会员商品渠道
ThreadPoolUtils.UPDATE_PRODUCT_CHANNEL.execute(()->{
if (CollectionUtils.isNotEmpty(updateResourcePageVO.getColumnVOS())) {
List<UpdateResourceColumnVO> memberActivitys = updateResourcePageVO.getColumnVOS().stream().filter(e -> ResourcePageConstants.ColumnTypeEnum.MEMBER_ACTIVITY.getCode().equals(e.getColumnType())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(memberActivitys) && null != memberActivitys.get(0) &&
null != memberActivitys.get(0).getItemVOList() && null != memberActivitys.get(0).getItemVOList().get(0)) {
UpdateResourceColumnVO updateResourceColumnVO = memberActivitys.get(0);
Long serveId = updateResourceColumnVO.getItemVOList().get(0).getServeId();
List<Long> productIds = memberActivityConsr.getProductIdsByMemberActivity(serveId);
if (CollUtil.isNotEmpty(productIds)) {
autoOnChannel(BookProps.getDefaultChannelId(), productIds);
//上架书刊渠道
autoOnChannel(page.getChannelId(), productIds);
}
}
}
});
return resourcePageId;
}
private void autoOnChannel(Long channelId, List<Long> productIds) {
//上架默认渠道
Map<Long, String> longStringMap = productConsr.productAutoOnShelves(channelId, productIds);
//删除手动下架的商品
if (CollUtil.isNotEmpty(longStringMap)) {
Iterator<Long> iterator = productIds.iterator();
while (iterator.hasNext()) {
Long next = iterator.next();
if (longStringMap.keySet().contains(next)) {
iterator.remove();
}
}
if (CollUtil.isNotEmpty(productIds)) {
productConsr.productAutoOnShelves(BookProps.getDefaultChannelId(), productIds);
}
}
}
private void updateResourcePageBookstore(Long resourcePageId, List<ResourcePageBookstore> resourcePageBookstoreList, ResourcePageFixtureTypeEnum fixtureTypeEnum) {
resourcePageBookstoreBiz.deleteByResourcePageId(resourcePageId, fixtureTypeEnum.fixtureType);
if (CollUtil.isNotEmpty(resourcePageBookstoreList)) {
......
......@@ -96,6 +96,12 @@ public class ThreadPoolUtils {
public static final ThreadPoolExecutor FILL_SERVICE_POOL = new ThreadPoolExecutor(8, 8, 0, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("fill-service-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
/**
* 会员商品更新上架渠道
*/
public static final ThreadPoolExecutor UPDATE_PRODUCT_CHANNEL = new ThreadPoolExecutor(8, 8, 0, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("update-product-channel-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
}
......@@ -45,6 +45,19 @@ public class BookProps {
private static Long operateOfficalId;
//默认公众号id
private static Long defaultChannelId;
public static Long getDefaultChannelId() {
return defaultChannelId;
}
@Value("${default.channel.id}")
public void setDefaultChannelId(Long defaultChannelId) {
BookProps.defaultChannelId = defaultChannelId;
}
public static Long getOperateOfficalId() {
return operateOfficalId;
}
......
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