From 688c783bf0e758c1815fb2a91f9482d1f6f80c62 Mon Sep 17 00:00:00 2001 From: xhxu Date: Wed, 8 Jun 2022 20:03:35 +0800 Subject: [PATCH] //tt product --- .../controller/market/WxCouponController.java | 2 + .../com/iformall/mapper/WxCouponMapper.java | 2 + .../service/impl/WxCouponServiceImpl.java | 53 +++++++-- .../mapper/TtCouponChannelPoiMapper.xml | 7 +- .../main/resources/mapper/WxCouponMapper.xml | 107 ++++++++++++++++++ 5 files changed, 162 insertions(+), 9 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java index 28823db69..f87c5a94d 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java @@ -86,6 +86,8 @@ public class WxCouponController extends BaseController { ttCouponVo.setSortColumns(coryColumn); ttCouponVo.setSortColumn(null); } + if (ttCouponVo.getStatus() != null && ttCouponVo.getStatus() == -1) + ttCouponVo.setStatus(null); return wxCouponService.ttgoodslist(ttCouponVo, pageNum, pageSize); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java index 40dc53672..20758a52f 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java @@ -4,6 +4,7 @@ import java.util.*; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxTopic; import com.iformall.domain.po.base.TenantEntity; +import com.iformall.domain.vo.TtCouponVo; import com.iformall.domain.vo.WxCouponCVo; import com.iformall.domain.vo.WxCouponStatisVo; import org.apache.ibatis.annotations.Param; @@ -121,4 +122,5 @@ public interface WxCouponMapper extends CommonMapper { List findIdsListHasConditons(WxCoupon couponQ); + List ttgoodslist(TtCouponVo ttCouponVo); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index 26fc53f8a..f17f6f7aa 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -142,7 +142,42 @@ public class WxCouponServiceImpl implements WxCouponService { @Override public ResultData ttgoodslist(TtCouponVo ttCouponVo, Integer pageNum, Integer pageSize) { - return null; + PageInfo pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxCouponMapper.ttgoodslist(ttCouponVo)); + List couponList = pageInfo.getList(); + + if(!couponList.isEmpty()){ + List ids = couponList.stream().map(p -> p.getId()).collect(toList()); + WxCouponChannel wxCouponChannel = new WxCouponChannel(); + wxCouponChannel.updateTenantInfo(ttCouponVo); + wxCouponChannel.setCouponIds(ids); + wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); + //上架状态 + List list = wxCouponChannelMapper.findList(wxCouponChannel); + if (!list.isEmpty()) { + Map> groupBy = list.stream().collect(Collectors.groupingBy(WxCouponChannel::getCouponId)); + for (TtCouponVo temp : couponList) { + if (groupBy.get(temp.getId()) != null) { + List channels = new ArrayList<>(); + for (WxCouponChannel tempchannel : groupBy.get(temp.getId())) { + if (!channels.contains(tempchannel.getTargetAd())) { + channels.add(tempchannel.getTargetAd()); + } + } + String sss = JSON.toJSONString(channels); + temp.setChannels(sss); + } else { + temp.setChannels(""); + } + + } + } else { + for (TtCouponVo temp : couponList) { + temp.setChannels(""); + } + + } + } + return new ResultData(pageInfo); } @Override @@ -208,6 +243,7 @@ public class WxCouponServiceImpl implements WxCouponService { } return new ResultData(page); } + @Override public List list(WxCoupon wxCoupon){ @@ -1205,9 +1241,10 @@ public class WxCouponServiceImpl implements WxCouponService { @Override @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) public ResultData productSave(WxCoupon coupon) { - if(coupon.getProductType() == null || coupon.getCategoryId() == null - || coupon.getProductAttrKeyValueMap().isEmpty() - || coupon.getSkuAttrKeyValueMap().isEmpty()){ + WxCoupon ttattrs = this.getAttrsById(coupon.getId(), coupon.getTenantId()); + if(ttattrs.getProductType() == null || ttattrs.getCategoryId() == null + || ttattrs.getProductAttrKeyValueMap().isEmpty() + || ttattrs.getSkuAttrKeyValueMap().isEmpty()){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该券缺少必要属性"); } //添加到审核渠道 @@ -1224,8 +1261,8 @@ public class WxCouponServiceImpl implements WxCouponService { Product.ProductStruct prostruct = new Product.ProductStruct(); prostruct.setOutId(coupon.getId().toString()); prostruct.setProductName(coupon.getTitle()); - prostruct.setCategoryId(coupon.getCategoryId()); - prostruct.setProductType(coupon.getProductType()); + prostruct.setCategoryId(ttattrs.getCategoryId()); + prostruct.setProductType(ttattrs.getProductType()); prostruct.setBizLine(5);//默认小程序 prostruct.setAccountName(merchantList.get(0).getMerchantName()); // prostruct.setSoldStartTime(); @@ -1238,7 +1275,7 @@ public class WxCouponServiceImpl implements WxCouponService { poiList.add(poiStruct); } prostruct.setPoiList(poiList); - prostruct.setAttrKeyValueMap(coupon.getProductAttrKeyValueMap()); + prostruct.setAttrKeyValueMap(ttattrs.getProductAttrKeyValueMap()); product.setProduct(prostruct); Product.SkuStruct skuStruct = new Product.SkuStruct(); @@ -1250,7 +1287,7 @@ public class WxCouponServiceImpl implements WxCouponService { stockStruct.setStockQty(coupon.getInventory()); skuStruct.setStock(stockStruct); skuStruct.setStatus(1); - skuStruct.setAttrKeyValueMap(coupon.getSkuAttrKeyValueMap()); + skuStruct.setAttrKeyValueMap(ttattrs.getSkuAttrKeyValueMap()); product.setSku(skuStruct); String productId = ttWebService.getGoodsService().productSave(product); diff --git a/mallinkService/src/main/resources/mapper/TtCouponChannelPoiMapper.xml b/mallinkService/src/main/resources/mapper/TtCouponChannelPoiMapper.xml index 9992266bd..be4e34675 100644 --- a/mallinkService/src/main/resources/mapper/TtCouponChannelPoiMapper.xml +++ b/mallinkService/src/main/resources/mapper/TtCouponChannelPoiMapper.xml @@ -5,6 +5,7 @@ + @@ -18,7 +19,7 @@ - `id`,`tenant_id`,`parent_tenant_id`,`spu_id`, + `id`,`tenant_id`,`parent_tenant_id`,`coupon_channel_id`,`spu_id`, `status`,`status_desc`,`last_status`,`last_status_desc`, `create_date`,`update_date` @@ -37,6 +38,10 @@ and `parent_tenant_id` = #{parentTenantId} + + and `coupon_channel_id` = #{couponChannelId} + + and `spu_id` = #{spuId} diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index f7069666d..414e1d642 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -1317,5 +1317,112 @@ and c.`parent_tenant_id` = #{parentTenantId} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +