|
|
|
@@ -26,6 +26,7 @@ import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Isolation; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
@@ -81,6 +82,14 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
TtGoodsCategoryMapper ttGoodsCategoryMapper; |
|
|
|
|
|
|
|
@Lazy |
|
|
|
@Autowired |
|
|
|
WxCouponMallService wxCouponMallService; |
|
|
|
|
|
|
|
@Lazy |
|
|
|
@Autowired |
|
|
|
WxMerchantService wxMerchantService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData couponList(TtCouponVo ttCouponVo, Integer pageNum, Integer pageSize) { |
|
|
|
@@ -163,11 +172,60 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { |
|
|
|
} |
|
|
|
|
|
|
|
//获取门店,确保所有门店匹配poi |
|
|
|
List<Long> merchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), coupon.getTenantId()); |
|
|
|
TtMerchantPoi poiQ = new TtMerchantPoi(); |
|
|
|
poiQ.updateTenantInfo(coupon); |
|
|
|
poiQ.setIds(merchantIds); |
|
|
|
List<TtMerchantPoi> pois = ttMerchantPoiMapper.findList(poiQ); |
|
|
|
List<Long> merchantIds = null; |
|
|
|
List<WxCouponMall> couponMallList = null; |
|
|
|
if (EnumCouponType.isParentCoupon(coupon.getType())) { |
|
|
|
WxCouponMall couponMall = new WxCouponMall(); |
|
|
|
couponMall.updateTenantInfo(coupon); |
|
|
|
couponMall.setProductId(coupon.getId()); |
|
|
|
couponMall.setStatus(EnumCouponMallStatus.FINISED.getCode()); |
|
|
|
couponMallList = wxCouponMallService.list(couponMall, false); |
|
|
|
if (null == couponMallList || couponMallList.size() <= 0 ) { |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),"未完成设置关联商场"); |
|
|
|
} |
|
|
|
for (int i = 0 ; i < couponMallList.size(); i++ ) { |
|
|
|
WxCouponMall cm = couponMallList.get(i); |
|
|
|
List<Long> mchids = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), cm.getMallTenantId()); |
|
|
|
if (null != mchids) { |
|
|
|
if (null == merchantIds) { |
|
|
|
merchantIds = new ArrayList<Long>(); |
|
|
|
} |
|
|
|
merchantIds.addAll(mchids); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
merchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), coupon.getTenantId()); |
|
|
|
} |
|
|
|
if (null == merchantIds || merchantIds.size() <= 0) { |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),"未设置商户"); |
|
|
|
} |
|
|
|
|
|
|
|
List<TtMerchantPoi> pois = null; |
|
|
|
if (EnumCouponType.isParentCoupon(coupon.getType())) { |
|
|
|
if (null == couponMallList || couponMallList.size() <= 0 ) { |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),"未完成设置关联商场"); |
|
|
|
} |
|
|
|
for (int i = 0 ; i < couponMallList.size(); i++ ) { |
|
|
|
WxCouponMall cm = couponMallList.get(i); |
|
|
|
TtMerchantPoi poiQ = new TtMerchantPoi(); |
|
|
|
poiQ.setTenantId(cm.getTenantId()); |
|
|
|
poiQ.setIds(merchantIds); |
|
|
|
List<TtMerchantPoi> pois1 = ttMerchantPoiMapper.findList(poiQ); |
|
|
|
if (null != pois1) { |
|
|
|
if (null == pois) { |
|
|
|
pois = new ArrayList<TtMerchantPoi>(); |
|
|
|
} |
|
|
|
pois.addAll(pois1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}else { |
|
|
|
TtMerchantPoi poiQ = new TtMerchantPoi(); |
|
|
|
poiQ.updateTenantInfo(coupon); |
|
|
|
poiQ.setIds(merchantIds); |
|
|
|
pois = ttMerchantPoiMapper.findList(poiQ); |
|
|
|
} |
|
|
|
|
|
|
|
if(pois == null || pois.isEmpty()){ |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),"未找到poi门店"); |
|
|
|
} |
|
|
|
@@ -181,12 +239,24 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { |
|
|
|
poiList.add(poiStruct); |
|
|
|
} |
|
|
|
|
|
|
|
WxMerchant merchantQ = new WxMerchant(); |
|
|
|
merchantQ.updateTenantInfo(coupon); |
|
|
|
merchantQ.setIds(merchantIds); |
|
|
|
merchantQ.setSortColumns(BaseEntity.SortField.MerchantAdmin); |
|
|
|
WxMerchant merchant = wxMerchantMapper.findIdNameList(merchantQ).get(0); |
|
|
|
|
|
|
|
WxMerchant payAccountMerchant = null; |
|
|
|
if (EnumCouponType.isParentCoupon(coupon.getType())) { |
|
|
|
if (EnumCouponType.COUPON_DOUYIN_PLAT.getCode() == coupon.getType()) { |
|
|
|
payAccountMerchant = wxMerchantService.findAdmin(coupon); |
|
|
|
}else if (EnumCouponType.COUPON_DOUYIN_BRAND.getCode() == coupon.getType()) { |
|
|
|
payAccountMerchant = wxMerchantService.findBrandAdmin(coupon, coupon.getBrand()); |
|
|
|
}else { |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),"当前券类型未找到收款商户"); |
|
|
|
} |
|
|
|
|
|
|
|
}else { |
|
|
|
WxMerchant merchantQ = new WxMerchant(); |
|
|
|
merchantQ.updateTenantInfo(coupon); |
|
|
|
merchantQ.setIds(merchantIds); |
|
|
|
merchantQ.setSortColumns(BaseEntity.SortField.MerchantAdmin); |
|
|
|
payAccountMerchant = wxMerchantMapper.findIdNameList(merchantQ).get(0); |
|
|
|
} |
|
|
|
|
|
|
|
//投放到抖音渠道,获取详情地址,以做审核 |
|
|
|
WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); |
|
|
|
wxCouponChannelQuery.updateTenantInfo(coupon); |
|
|
|
@@ -244,7 +314,7 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { |
|
|
|
prostruct.setCategoryId(ttattrs.getCategoryId()); |
|
|
|
prostruct.setProductType(ttattrs.getProductType()); |
|
|
|
prostruct.setBizLine(5);//默认小程序 |
|
|
|
prostruct.setAccountName(merchant.getName()); |
|
|
|
prostruct.setAccountName(payAccountMerchant.getName()); |
|
|
|
|
|
|
|
prostruct.setSoldStartTime((long) DateUtils.getSecondTimestamp(wxCouponChannel.getBeginTime())); |
|
|
|
prostruct.setSoldEndTime((long) DateUtils.getSecondTimestamp(wxCouponChannel.getEndTime())); |
|
|
|
|