diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMerchantMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMerchantMapper.java index 60cdf389e..6a5d04c05 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMerchantMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMerchantMapper.java @@ -15,9 +15,8 @@ import org.apache.ibatis.annotations.Param; public interface WxCouponMerchantMapper extends CommonMapper { List findList(WxCouponMerchant wxCouponMerchant); - List findMerchantVoList(@Param("productId")Long productId,@Param("tenantId")String tenantId); - List findMerchantNameList(@Param("productId")Long productId,@Param("tenantId")String tenantId); - List findMerchantBaseList(@Param("productId")Long productId,@Param("tenantId")String tenantId); + List findMerchantListByProduct(@Param("productId")Long productId,@Param("tenantId")String tenantId); + List findMerchantIdListByProduct(@Param("productId")Long productId,@Param("tenantId")String tenantId); List findMerchantProduct(@Param("tenantId")String tenantId,@Param("merchantIdList")List merchantIdList); List findOnlyMerchantProduct(@Param("tenantId")String tenantId,@Param("merchantIdList")List merchantIdList); List findMerchantProductIds(@Param("tenantId")String tenantId,@Param("merchantIdList")List merchantIdList,@Param("status")Integer status); diff --git a/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java b/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java index cc6742024..47d783627 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java @@ -12,6 +12,7 @@ import com.iformall.domain.vo.WxMerchantTradeVo; import com.iformall.domain.vo.WxMerchantVo; import com.iformall.enums.EnumPayWay; +import org.apache.ibatis.annotations.Param; import org.springframework.web.bind.annotation.ModelAttribute; import javax.servlet.http.HttpServletRequest; @@ -183,5 +184,7 @@ public interface WxMerchantService { Map detailByShopId(TenantEntity tenantInfo, Long shopId); List getFloorBuildMerchantIds(TenantEntity tenantEntity,String floorRule,Long building,Long floor,Integer merchantShopDel,Integer shopDel ) ; + + List findMerchantListByProduct(TenantEntity tenantEntity,Long productId,boolean hasShop); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index fc30aab6c..9fa0a296a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -29,6 +29,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Lazy; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ValueOperations; import org.springframework.stereotype.Service; @@ -46,18 +47,28 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { WxCouponChannelMapper wxCouponChannelMapper; @Autowired WxCouponMapper wxCouponMapper; + + @Lazy @Autowired WxCouponService wxCouponService; + @Autowired WxMerchantMapper wxMerchantMapper; @Autowired WxCouponMerchantMapper wxCouponMerchantMapper; + + @Lazy @Autowired WxScreenAdService wxScreenAdService; + + @Lazy @Autowired WxOrderService wxOrderService; + + @Lazy @Autowired QrCodeService qrCodeService; + @Autowired WxCardInfoMapper wxCardInfoMapper; @Autowired @@ -73,6 +84,10 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { @Qualifier("objectCommonRedisTemplate") RedisTemplate redisTemplate; + @Lazy + @Autowired + WxMerchantService wxMerchantService; + /** * B端业务端 * @param record @@ -410,8 +425,8 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { return retPageInfo; } - private boolean isCouponMerchantValid(Long couponId,String tenantId) { - List merchantVoList = wxCouponMerchantMapper.findMerchantNameList(couponId,tenantId); + private boolean isCouponMerchantValid(Long couponId,TenantEntity tenantEntity) { + List merchantVoList = wxMerchantService.findMerchantListByProduct(tenantEntity,couponId,false); if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())))){ return true; } @@ -451,7 +466,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } if(!EnumCouponType.COUPON_GIFT.getCode().equals(wxCoupon.getType()) - && !isCouponMerchantValid(wxCoupon.getId(),wxCoupon.getTenantId())) { + && !isCouponMerchantValid(wxCoupon.getId(),wxCoupon)) { logger.debug(wxCoupon.getId()+couponid+ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage()); vo.toCouponChannnelVo(wxCoupon,channelId); vo.setErrorMsg(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage()); @@ -541,7 +556,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { cvo.setQrCode(cc.getQrCode()); cvo.setTtQrCode(cc.getTtQrCode()); if (hasMerchant) { - cvo.setMerchantVoList(wxCouponMerchantMapper.findMerchantVoList(cc.getCouponId(), cc.getTenantId())); + cvo.setMerchantVoList(wxMerchantService.findMerchantListByProduct(cc,cc.getCouponId(), true)); } return cvo; } catch (IllegalAccessException e) { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index 6dd5a531d..807dbdbaf 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -359,8 +359,8 @@ public class WxMerchantServiceImpl implements WxMerchantService { } - private boolean isCouponMerchantValid(Long couponId,String tenantId) { - List merchantVoList = wxCouponMerchantMapper.findMerchantNameList(couponId,tenantId); + private boolean isCouponMerchantValid(Long couponId,TenantEntity tenantEntity) { + List merchantVoList = findMerchantListByProduct(tenantEntity,couponId,false); if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())))){ return true; } @@ -432,7 +432,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { List wxCouponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); List couponIds = wxCouponMerchantList.stream().map(cm -> cm.getProductId()).collect(Collectors.toList()); - couponIds.stream().filter(cid -> !isCouponMerchantValid(cid,wxCouponMerchant.getTenantId())).forEach(cid -> { + couponIds.stream().filter(cid -> !isCouponMerchantValid(cid,wxCouponMerchant)).forEach(cid -> { WxCoupon wxCoupon = new WxCoupon(); wxCoupon.setId(cid); wxCoupon.updateTenantInfo(wxMerchant); @@ -1566,5 +1566,60 @@ public class WxMerchantServiceImpl implements WxMerchantService { return getShopMerchantMap(shopId,2); } - + @Override + public List findMerchantListByProduct(TenantEntity tenantEntity,Long productId,boolean hasShop) { + List merchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(productId, tenantEntity.getTenantId()); + Map merchantMap = new HashMap(); + Map> merchantShopVoMap = null; + if (null != merchantIds && merchantIds.size() > 0 ) { + WxMerchant merchantQ = new WxMerchant(); + merchantQ.updateTenantInfo(tenantEntity); + merchantQ.setIds(merchantIds); + List merchantList = wxMerchantMapper.findList(merchantQ); + if (null != merchantList) { + for (int i = 0 ; i < merchantList.size(); i++) { + WxMerchant m = merchantList.get(i); + if (null != m) { + merchantMap.put(m.getId(), m); + } + } + } + if (hasShop) { + merchantShopVoMap = wxShopService.findMerchantShopVoListMap(tenantEntity, merchantIds); + } + } + List couponMerchantList = wxCouponMerchantMapper.findMerchantListByProduct(productId, tenantEntity.getTenantId()); + if (null != couponMerchantList) { + List retList = new ArrayList(); + for (int i = 0 ; i < couponMerchantList.size() ; i++) { + WxCouponMerchant cm = couponMerchantList.get(i); + if (null != cm) { + WxMerchantVo vo = new WxMerchantVo(); + vo.setParameter(cm.getParameter()); + if (null != cm.getMerchantId()) { + WxMerchant m = merchantMap.get(cm.getMerchantId()); + if (null != m) { + vo.setId(m.getId()); + vo.setMerchantImgUrl(m.getImgUrl()); + vo.setMerchantName(m.getName()); + vo.setMerchantLinkPhone(m.getLinkPhone()); + vo.setMerchantStatus(m.getStatus()); + vo.setBusinessId(m.getBusinessId()); + vo.setSubBusinessId(m.getSubBusinessId()); + vo.setLinkLinePhone(m.getLinkLinePhone()); + if (null != merchantShopVoMap) { + vo.setShopVoList(merchantShopVoMap.get(m.getId())); + } + } + } + retList.add(vo); + } + } + if (retList.size() <=0 ) { + return null; + } + return retList; + } + return null; + } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index 0068499be..ee12f686f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory; import org.springframework.aop.framework.AopContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Lazy; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ValueOperations; import org.springframework.stereotype.Service; @@ -114,12 +115,15 @@ public class WxOrderServiceImpl implements WxOrderService { @Autowired WxCouponOrderMapper wxCouponOrderMapper; + @Lazy @Autowired WxCouponOrderService wxCouponOrderService; + @Lazy @Autowired WxCUserService wxCUserService; + @Lazy @Autowired WxCUserBasicInfoService wxCUserBasicInfoService; @@ -129,21 +133,27 @@ public class WxOrderServiceImpl implements WxOrderService { @Autowired WxMerchantBUserMapper wxMerchantBUserMapper; + @Lazy @Autowired WxAppinfoService wxAppinfoService; + @Lazy @Autowired WxPayOrderService wxPayOrderService; + @Lazy @Autowired WxScoreRulesService wxScoreRulesService; + @Lazy @Autowired WxCUserTagsService wxCUserTagsService; + @Lazy @Autowired WxCouponActionLogService wxCouponActionLogService; + @Lazy @Autowired WxProfitSharingOrderService wxProfitSharingOrderService; @@ -153,6 +163,7 @@ public class WxOrderServiceImpl implements WxOrderService { @Autowired WxCardInfoMapper wxCardInfoMapper; + @Lazy @Autowired WxCouponSendService wxCouponSendService; @@ -162,6 +173,7 @@ public class WxOrderServiceImpl implements WxOrderService { @Autowired WxOrderGroupMapper wxOrderGroupMapper; + @Lazy @Autowired WxCreditHistoryService wxCreditHistoryService; @@ -174,6 +186,7 @@ public class WxOrderServiceImpl implements WxOrderService { @Autowired private WxCUserBasicInfoMapper wxCUserBasicInfoMapper; + @Lazy @Autowired private WxMsgLimitService wxMsgLimitService; @@ -183,9 +196,11 @@ public class WxOrderServiceImpl implements WxOrderService { @Autowired ExcelService excelService; + @Lazy @Autowired WxCouponService wxCouponService; + @Lazy @Autowired WxCouponChannelService wxCouponChannelService; @@ -199,6 +214,10 @@ public class WxOrderServiceImpl implements WxOrderService { @Autowired OrderFactory orderFactory; + @Lazy + @Autowired + WxMerchantService wxMerchantService; + @Override public PageInfo listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record)); @@ -812,8 +831,8 @@ public class WxOrderServiceImpl implements WxOrderService { * @param couponId * @return */ - private boolean isCouponMerchantValid(Long couponId,String tenantId) { - List merchantVoList = wxCouponMerchantMapper.findMerchantNameList(couponId,tenantId); + private boolean isCouponMerchantValid(Long couponId,TenantEntity tenantEntity) { + List merchantVoList = wxMerchantService.findMerchantListByProduct(tenantEntity,couponId,false); if (merchantVoList.stream().anyMatch((cm -> cm.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())))) { return true; } @@ -2408,7 +2427,7 @@ public class WxOrderServiceImpl implements WxOrderService { } if (EnumCouponType.mustHasMerchant(coupon.getType())) { // 检查券商户信息 - if (!isCouponMerchantValid(coupon.getId(),coupon.getTenantId())) { + if (!isCouponMerchantValid(coupon.getId(),coupon)) { logger.error("商户不存在, couponId: " + coupon.getId()); throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),premsg+"商户信息没找到"); } diff --git a/mallinkService/src/main/resources/mapper/WxCouponMerchantMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMerchantMapper.xml index 47f64516d..910ec2175 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMerchantMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMerchantMapper.xml @@ -84,71 +84,21 @@ - - m.id,m.img_url,m.name,m.link_phone,m.status,m.business_id,m.sub_business_id, - cm.parameter,m.link_line_phone - - - - - - - - - - - - - - - - - - - - - - - - m.id,m.name,m.status - - - - m.id, - m.img_url,m.name,m.link_phone,m.status,m.business_id,m.sub_business_id, - cm.parameter - - - + select distinct cm.merchant_id from wx_coupon_merchant cm - left join wx_merchant m on m.id = cm.merchant_id where cm.status = 0 - and cm.product_id = #{productId} and cm.tenant_id = #{tenantId} + and cm.product_id = #{productId} and cm.tenant_id = #{tenantId} - - select - + cm.parameter,cm.merchant_id from wx_coupon_merchant cm - left join wx_merchant m on m.id = cm.merchant_id where cm.status = 0 - and cm.product_id = #{productId} and cm.tenant_id = #{tenantId} + and cm.product_id = #{productId} and cm.tenant_id = #{tenantId} - -