| @@ -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); | |||
| } | |||
| @@ -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<WxCoupon, Long> { | |||
| List<Long> findIdsListHasConditons(WxCoupon couponQ); | |||
| List<TtCouponVo> ttgoodslist(TtCouponVo ttCouponVo); | |||
| } | |||
| @@ -142,7 +142,42 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| @Override | |||
| public ResultData ttgoodslist(TtCouponVo ttCouponVo, Integer pageNum, Integer pageSize) { | |||
| return null; | |||
| PageInfo<TtCouponVo> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxCouponMapper.ttgoodslist(ttCouponVo)); | |||
| List<TtCouponVo> couponList = pageInfo.getList(); | |||
| if(!couponList.isEmpty()){ | |||
| List<Long> 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<WxCouponChannel> list = wxCouponChannelMapper.findList(wxCouponChannel); | |||
| if (!list.isEmpty()) { | |||
| Map<Long, List<WxCouponChannel>> groupBy = list.stream().collect(Collectors.groupingBy(WxCouponChannel::getCouponId)); | |||
| for (TtCouponVo temp : couponList) { | |||
| if (groupBy.get(temp.getId()) != null) { | |||
| List<Integer> 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<WxCoupon> 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); | |||
| @@ -5,6 +5,7 @@ | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||
| <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/> | |||
| <result column="spu_id" jdbcType="VARCHAR" property="spuId"/> | |||
| <result column="status" jdbcType="INTEGER" property="status"/> | |||
| <result column="status_desc" jdbcType="VARCHAR" property="statusDesc"/> | |||
| @@ -18,7 +19,7 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `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` | |||
| </sql> | |||
| @@ -37,6 +38,10 @@ | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != couponChannelId "> | |||
| and `coupon_channel_id` = #{couponChannelId} | |||
| </if> | |||
| <if test=" null != spuId and '' != spuId"> | |||
| and `spu_id` = #{spuId} | |||
| </if> | |||
| @@ -1317,5 +1317,112 @@ | |||
| and c.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| </select> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.vo.TtCouponVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/> | |||
| <result column="title" jdbcType="VARCHAR" property="title"/> | |||
| <result column="sale_price" jdbcType="INTEGER" property="salePrice"/> | |||
| <result column="send_type" jdbcType="INTEGER" property="sendType"/> | |||
| <result column="valid_type" jdbcType="INTEGER" property="validType"/> | |||
| <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/> | |||
| <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/> | |||
| <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/> | |||
| <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/> | |||
| <result column="valid_days" jdbcType="INTEGER" property="validDays"/> | |||
| <result column="price" jdbcType="INTEGER" property="price"/> | |||
| <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/> | |||
| <result column="orig_price" jdbcType="INTEGER" property="origPrice"/> | |||
| <result column="unit" jdbcType="INTEGER" property="unit"/> | |||
| <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/> | |||
| <result column="inventory" jdbcType="INTEGER" property="inventory"/> | |||
| <result column="status" jdbcType="INTEGER" property="status"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="business" jdbcType="INTEGER" property="business"/> | |||
| <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/> | |||
| <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | |||
| <result column="credit_price" jdbcType="INTEGER" property="creditPrice"/> | |||
| <result column="credit_refund" jdbcType="INTEGER" property="creditRefund"/> | |||
| <result column="content_type" property="contentType"/> | |||
| <result column="source_type" jdbcType="INTEGER" property="sourceType"/> | |||
| <result column="product_type" jdbcType="INTEGER" property="productType"/> | |||
| <result column="category_id" jdbcType="INTEGER" property="categoryId"/> | |||
| <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/> | |||
| <result column="spu_id" jdbcType="VARCHAR" property="spuId"/> | |||
| <result column="status" jdbcType="INTEGER" property="status"/> | |||
| <result column="status_desc" jdbcType="VARCHAR" property="statusDesc"/> | |||
| <result column="last_status" jdbcType="INTEGER" property="lastStatus"/> | |||
| <result column="last_status_desc" jdbcType="VARCHAR" property="lastStatusDesc"/> | |||
| </resultMap> | |||
| <select id="findList" parameterType="com.iformall.domain.vo.TtCouponVo" resultMap="TtCouponVoResultMap"> | |||
| select c.`id`,c.`tenant_id`,c.`parent_tenant_id`,c.`type`,c.`cover_img`, | |||
| c.`title`,c.`sub_title`,c.`sale_price`,c.`freight_price`,c.`send_type`, | |||
| c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.pick_start_date,c.pick_end_date, | |||
| c.`valid_days`,c.`price`,c.tail_price,c.orig_price,c.`unit`,c.`remain_inventory`,c.`inventory`, | |||
| c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`, | |||
| c.`auto_refund`,c.`credit_price`,c.`credit_refund`, | |||
| c.content_type,c.source_type,c.product_type,c.category_id, | |||
| poi.coupon_channel_id,poi.spu_id,poi.status,poi.status_desc,poi.last_status,poi.last_status_desc | |||
| from wx_coupon c | |||
| left join tt_coupon_channel_poi poi on poi.id = c.id | |||
| where c.`type` = #{type} | |||
| <if test=" null != id "> | |||
| and c.`id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and c.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and c.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != title and ''!=title"> | |||
| and c.`title` like concat('%', #{title},'%') | |||
| </if> | |||
| <if test=" null != sendType "> | |||
| and c.`send_type` = #{sendType} | |||
| </if> | |||
| <if test=" null != status"> | |||
| and c.`status` = #{status} | |||
| </if> | |||
| <if test=" null != startdate and null!=enddate"> | |||
| and c.`create_date` between #{startdate} and #{enddate} | |||
| </if> | |||
| <if test=" null != sourceType "> | |||
| and c.`source_type` = #{sourceType} | |||
| </if> | |||
| <if test=" null != couponChannelId "> | |||
| and poi.`coupon_channel_id` = #{couponChannelId} | |||
| </if> | |||
| <if test=" null != spuId and '' != spuId"> | |||
| and poi.`spu_id` = #{spuId} | |||
| </if> | |||
| <if test=" null != status"> | |||
| and poi.`status` = #{status} | |||
| </if> | |||
| <if test=" null != lastStatus"> | |||
| and poi.`last_status` = #{lastStatus} | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </select> | |||
| </mapper> | |||