| @@ -15,9 +15,8 @@ import org.apache.ibatis.annotations.Param; | |||
| public interface WxCouponMerchantMapper extends CommonMapper<WxCouponMerchant, Long> { | |||
| List<WxCouponMerchant> findList(WxCouponMerchant wxCouponMerchant); | |||
| List<WxMerchantVo> findMerchantVoList(@Param("productId")Long productId,@Param("tenantId")String tenantId); | |||
| List<WxMerchantVo> findMerchantNameList(@Param("productId")Long productId,@Param("tenantId")String tenantId); | |||
| List<WxMerchantVo> findMerchantBaseList(@Param("productId")Long productId,@Param("tenantId")String tenantId); | |||
| List<WxCouponMerchant> findMerchantListByProduct(@Param("productId")Long productId,@Param("tenantId")String tenantId); | |||
| List<Long> findMerchantIdListByProduct(@Param("productId")Long productId,@Param("tenantId")String tenantId); | |||
| List<WxMerchantProductVo> findMerchantProduct(@Param("tenantId")String tenantId,@Param("merchantIdList")List<Long> merchantIdList); | |||
| List<WxMerchantProductVo> findOnlyMerchantProduct(@Param("tenantId")String tenantId,@Param("merchantIdList")List<Long> merchantIdList); | |||
| List<Long> findMerchantProductIds(@Param("tenantId")String tenantId,@Param("merchantIdList")List<Long> merchantIdList,@Param("status")Integer status); | |||
| @@ -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<String, Object> detailByShopId(TenantEntity tenantInfo, Long shopId); | |||
| List<Long> getFloorBuildMerchantIds(TenantEntity tenantEntity,String floorRule,Long building,Long floor,Integer merchantShopDel,Integer shopDel ) ; | |||
| List<WxMerchantVo> findMerchantListByProduct(TenantEntity tenantEntity,Long productId,boolean hasShop); | |||
| } | |||
| @@ -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<String, Object> 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<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantNameList(couponId,tenantId); | |||
| private boolean isCouponMerchantValid(Long couponId,TenantEntity tenantEntity) { | |||
| List<WxMerchantVo> 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) { | |||
| @@ -359,8 +359,8 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| } | |||
| private boolean isCouponMerchantValid(Long couponId,String tenantId) { | |||
| List<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantNameList(couponId,tenantId); | |||
| private boolean isCouponMerchantValid(Long couponId,TenantEntity tenantEntity) { | |||
| List<WxMerchantVo> 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<WxCouponMerchant> wxCouponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); | |||
| List<Long> 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<WxMerchantVo> findMerchantListByProduct(TenantEntity tenantEntity,Long productId,boolean hasShop) { | |||
| List<Long> merchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(productId, tenantEntity.getTenantId()); | |||
| Map<Long,WxMerchant> merchantMap = new HashMap<Long,WxMerchant>(); | |||
| Map<Long, List<WxShopVo>> merchantShopVoMap = null; | |||
| if (null != merchantIds && merchantIds.size() > 0 ) { | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.updateTenantInfo(tenantEntity); | |||
| merchantQ.setIds(merchantIds); | |||
| List<WxMerchant> 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<WxCouponMerchant> couponMerchantList = wxCouponMerchantMapper.findMerchantListByProduct(productId, tenantEntity.getTenantId()); | |||
| if (null != couponMerchantList) { | |||
| List<WxMerchantVo> retList = new ArrayList<WxMerchantVo>(); | |||
| 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; | |||
| } | |||
| } | |||
| @@ -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<WxOrder> 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<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantNameList(couponId,tenantId); | |||
| private boolean isCouponMerchantValid(Long couponId,TenantEntity tenantEntity) { | |||
| List<WxMerchantVo> 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+"商户信息没找到"); | |||
| } | |||
| @@ -84,71 +84,21 @@ | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <sql id="allMerchantVoColumns"> | |||
| 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 | |||
| </sql> | |||
| <resultMap id="MerchantVoResultMap" type="com.iformall.domain.vo.WxMerchantVo"> | |||
| <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="img_url" jdbcType="VARCHAR" property="merchantImgUrl"/> | |||
| <result column="name" jdbcType="VARCHAR" property="merchantName"/> | |||
| <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone"/> | |||
| <result column="status" jdbcType="VARCHAR" property="merchantStatus"/> | |||
| <result column="business_id" jdbcType="INTEGER" property="businessId"/> | |||
| <result column="sub_business_id" jdbcType="INTEGER" property="subBusinessId"/> | |||
| <result column="parameter" jdbcType="VARCHAR" property="parameter"/> | |||
| <result column="link_line_phone" property="linkLinePhone"/> | |||
| <collection column="{merchantId=id}" property="shopVoList" | |||
| ofType="com.iformall.domain.vo.WxShopVo" | |||
| javaType="java.util.List" | |||
| select="com.iformall.mapper.WxShopMapper.findShopVoList"> | |||
| </collection> | |||
| </resultMap> | |||
| <select id="findMerchantVoList" parameterType="java.util.Map" resultMap="MerchantVoResultMap"> | |||
| select | |||
| <include refid="allMerchantVoColumns"/> | |||
| 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} | |||
| </select> | |||
| <sql id="allMerchantNameColumns"> | |||
| m.id,m.name,m.status | |||
| </sql> | |||
| <sql id="allMerchantBaseColumns"> | |||
| m.id, | |||
| m.img_url,m.name,m.link_phone,m.status,m.business_id,m.sub_business_id, | |||
| cm.parameter | |||
| </sql> | |||
| <select id="findMerchantNameList" parameterType="java.util.Map" resultMap="MerchantVoResultMap"> | |||
| select | |||
| <include refid="allMerchantNameColumns"/> | |||
| <select id="findMerchantIdListByProduct" parameterType="java.util.Map" resultMap="BaseResultMap"> | |||
| 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> | |||
| <select id="findMerchantBaseList" parameterType="java.util.Map" resultMap="MerchantVoResultMap"> | |||
| <select id="findMerchantListByProduct" parameterType="java.util.Map" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allMerchantBaseColumns"/> | |||
| 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} | |||
| </select> | |||
| <resultMap id="MerchantProductVoResultMap" type="com.iformall.domain.vo.WxMerchantProductVo"> | |||
| <result column="product_id" jdbcType="BIGINT" property="productId"/> | |||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/> | |||