|
@@ -1,17 +1,28 @@
|
|
|
package com.cyksj.web.controller.channel;
|
|
package com.cyksj.web.controller.channel;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
|
|
+import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.channel.ChannelPopularizeMapper;
|
|
import com.cyksj.mapper.channel.ChannelPopularizeMapper;
|
|
|
import com.cyksj.mapper.channel.ChannelPopularizeVisitMapper;
|
|
import com.cyksj.mapper.channel.ChannelPopularizeVisitMapper;
|
|
|
import com.cyksj.mapper.channel.MoviesVisitRecordMapper;
|
|
import com.cyksj.mapper.channel.MoviesVisitRecordMapper;
|
|
|
|
|
+import com.cyksj.mapper.manage.coupon.CouponSkuMapper;
|
|
|
import com.cyksj.model.entity.ChannelPopularize;
|
|
import com.cyksj.model.entity.ChannelPopularize;
|
|
|
import com.cyksj.model.entity.ChannelPopularizeVisit;
|
|
import com.cyksj.model.entity.ChannelPopularizeVisit;
|
|
|
import com.cyksj.model.entity.MoviesVisitRecord;
|
|
import com.cyksj.model.entity.MoviesVisitRecord;
|
|
|
|
|
+import com.cyksj.model.views.CouponTfPopularizeView;
|
|
|
|
|
+import com.cyksj.web.util.StpUserUtil;
|
|
|
|
|
+import com.ejlchina.searcher.BeanSearcher;
|
|
|
|
|
+import com.ejlchina.searcher.param.Operator;
|
|
|
|
|
+import com.ejlchina.searcher.util.MapBuilder;
|
|
|
|
|
+import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @author chan
|
|
* @author chan
|
|
|
* @date 2022/12/13 2:36 PM
|
|
* @date 2022/12/13 2:36 PM
|
|
@@ -27,12 +38,34 @@ public class ChannelController {
|
|
|
|
|
|
|
|
private final MoviesVisitRecordMapper moviesVisitRecordMapper;
|
|
private final MoviesVisitRecordMapper moviesVisitRecordMapper;
|
|
|
|
|
|
|
|
|
|
+ private final BeanSearcher beanSearcher;
|
|
|
|
|
+
|
|
|
|
|
+ private final CouponSkuMapper couponSkuMapper;
|
|
|
|
|
+
|
|
|
@GetMapping("/get/{id}")
|
|
@GetMapping("/get/{id}")
|
|
|
- public Result<ChannelPopularize> getById(@PathVariable Long id){
|
|
|
|
|
|
|
+ public Result<ChannelPopularize> getById(@PathVariable Long id, Boolean isLogin) {
|
|
|
ChannelPopularize channelPopularize = popularizeMapper.selectById(id);
|
|
ChannelPopularize channelPopularize = popularizeMapper.selectById(id);
|
|
|
- if(channelPopularize == null){
|
|
|
|
|
|
|
+ if (channelPopularize == null) {
|
|
|
throw BusinessRuntimeException.getInstance("该链接不存在!");
|
|
throw BusinessRuntimeException.getInstance("该链接不存在!");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (StrUtil.isNotBlank(channelPopularize.getCouponIds())) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ List<Long> couponIds = Jsons.parseList(channelPopularize.getCouponIds(), Long.class);
|
|
|
|
|
+ Long userId = (isLogin != null && !isLogin) ? null : StpUserUtil.getLoginIdAsLong();
|
|
|
|
|
+ MapBuilder builder = MapUtils.builder().field(CouponTfPopularizeView::getCouponId, couponIds).op(Operator.InList);
|
|
|
|
|
+ if (userId != null) {
|
|
|
|
|
+ builder.put("user_id", String.format("and cu.user_id = %s", userId));
|
|
|
|
|
+ }
|
|
|
|
|
+ List<CouponTfPopularizeView> couponTfPopularizeViews = beanSearcher.searchAll(CouponTfPopularizeView.class, builder.build());
|
|
|
|
|
+ couponTfPopularizeViews.forEach(data -> {
|
|
|
|
|
+ String str = couponSkuMapper.selectGoodsSkuStr(data.getCouponId());
|
|
|
|
|
+ data.setGoodsSkuStr(str.replaceAll(",", "/").replaceAll(";", ""));
|
|
|
|
|
+ });
|
|
|
|
|
+ channelPopularize.setCoupons(couponTfPopularizeViews);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ System.out.println(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
ChannelPopularizeVisit channelPopularizeVisit = new ChannelPopularizeVisit();
|
|
ChannelPopularizeVisit channelPopularizeVisit = new ChannelPopularizeVisit();
|
|
|
channelPopularizeVisit.setPopularizeId(id);
|
|
channelPopularizeVisit.setPopularizeId(id);
|
|
|
channelPopularizeVisitMapper.insert(channelPopularizeVisit);
|
|
channelPopularizeVisitMapper.insert(channelPopularizeVisit);
|