Просмотр исходного кода

fix couponMerchant

release_toaliyun_real
winter 4 лет назад
Родитель
Сommit
a12c899232
6 измененных файлов: 112 добавлений и 71 удалений
  1. +2
    -3
      mallinkService/src/main/java/com/iformall/mapper/WxCouponMerchantMapper.java
  2. +3
    -0
      mallinkService/src/main/java/com/iformall/service/WxMerchantService.java
  3. +19
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java
  4. +59
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java
  5. +22
    -3
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  6. +7
    -57
      mallinkService/src/main/resources/mapper/WxCouponMerchantMapper.xml

+ 2
- 3
mallinkService/src/main/java/com/iformall/mapper/WxCouponMerchantMapper.java Просмотреть файл

@@ -15,9 +15,8 @@ import org.apache.ibatis.annotations.Param;
public interface WxCouponMerchantMapper extends CommonMapper<WxCouponMerchant, Long> { public interface WxCouponMerchantMapper extends CommonMapper<WxCouponMerchant, Long> {


List<WxCouponMerchant> findList(WxCouponMerchant wxCouponMerchant); 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> findMerchantProduct(@Param("tenantId")String tenantId,@Param("merchantIdList")List<Long> merchantIdList);
List<WxMerchantProductVo> findOnlyMerchantProduct(@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); List<Long> findMerchantProductIds(@Param("tenantId")String tenantId,@Param("merchantIdList")List<Long> merchantIdList,@Param("status")Integer status);


+ 3
- 0
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.domain.vo.WxMerchantVo;
import com.iformall.enums.EnumPayWay; import com.iformall.enums.EnumPayWay;


import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;


import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@@ -183,5 +184,7 @@ public interface WxMerchantService {
Map<String, Object> detailByShopId(TenantEntity tenantInfo, Long shopId); Map<String, Object> detailByShopId(TenantEntity tenantInfo, Long shopId);
List<Long> getFloorBuildMerchantIds(TenantEntity tenantEntity,String floorRule,Long building,Long floor,Integer merchantShopDel,Integer shopDel ) ; List<Long> getFloorBuildMerchantIds(TenantEntity tenantEntity,String floorRule,Long building,Long floor,Integer merchantShopDel,Integer shopDel ) ;
List<WxMerchantVo> findMerchantListByProduct(TenantEntity tenantEntity,Long productId,boolean hasShop);


} }

+ 19
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java Просмотреть файл

@@ -29,6 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; 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.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -46,18 +47,28 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
WxCouponChannelMapper wxCouponChannelMapper; WxCouponChannelMapper wxCouponChannelMapper;
@Autowired @Autowired
WxCouponMapper wxCouponMapper; WxCouponMapper wxCouponMapper;
@Lazy
@Autowired @Autowired
WxCouponService wxCouponService; WxCouponService wxCouponService;
@Autowired @Autowired
WxMerchantMapper wxMerchantMapper; WxMerchantMapper wxMerchantMapper;
@Autowired @Autowired
WxCouponMerchantMapper wxCouponMerchantMapper; WxCouponMerchantMapper wxCouponMerchantMapper;
@Lazy
@Autowired @Autowired
WxScreenAdService wxScreenAdService; WxScreenAdService wxScreenAdService;
@Lazy
@Autowired @Autowired
WxOrderService wxOrderService; WxOrderService wxOrderService;
@Lazy
@Autowired @Autowired
QrCodeService qrCodeService; QrCodeService qrCodeService;
@Autowired @Autowired
WxCardInfoMapper wxCardInfoMapper; WxCardInfoMapper wxCardInfoMapper;
@Autowired @Autowired
@@ -73,6 +84,10 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
@Qualifier("objectCommonRedisTemplate") @Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> redisTemplate; RedisTemplate<String, Object> redisTemplate;


@Lazy
@Autowired
WxMerchantService wxMerchantService;
/** /**
* B端业务端 * B端业务端
* @param record * @param record
@@ -410,8 +425,8 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
return retPageInfo; 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())))){ if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())))){
return true; return true;
} }
@@ -451,7 +466,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
} }


if(!EnumCouponType.COUPON_GIFT.getCode().equals(wxCoupon.getType()) 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()); logger.debug(wxCoupon.getId()+couponid+ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage());
vo.toCouponChannnelVo(wxCoupon,channelId); vo.toCouponChannnelVo(wxCoupon,channelId);
vo.setErrorMsg(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage()); vo.setErrorMsg(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage());
@@ -541,7 +556,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
cvo.setQrCode(cc.getQrCode()); cvo.setQrCode(cc.getQrCode());
cvo.setTtQrCode(cc.getTtQrCode()); cvo.setTtQrCode(cc.getTtQrCode());
if (hasMerchant) { if (hasMerchant) {
cvo.setMerchantVoList(wxCouponMerchantMapper.findMerchantVoList(cc.getCouponId(), cc.getTenantId()));
cvo.setMerchantVoList(wxMerchantService.findMerchantListByProduct(cc,cc.getCouponId(), true));
} }
return cvo; return cvo;
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {


+ 59
- 4
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<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())))){ if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())))){
return true; return true;
} }
@@ -432,7 +432,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {
List<WxCouponMerchant> wxCouponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); List<WxCouponMerchant> wxCouponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant);
List<Long> couponIds = wxCouponMerchantList.stream().map(cm -> cm.getProductId()).collect(Collectors.toList()); 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 wxCoupon = new WxCoupon();
wxCoupon.setId(cid); wxCoupon.setId(cid);
wxCoupon.updateTenantInfo(wxMerchant); wxCoupon.updateTenantInfo(wxMerchant);
@@ -1566,5 +1566,60 @@ public class WxMerchantServiceImpl implements WxMerchantService {
return getShopMerchantMap(shopId,2); 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;
}
} }

+ 22
- 3
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.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; 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.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -114,12 +115,15 @@ public class WxOrderServiceImpl implements WxOrderService {
@Autowired @Autowired
WxCouponOrderMapper wxCouponOrderMapper; WxCouponOrderMapper wxCouponOrderMapper;


@Lazy
@Autowired @Autowired
WxCouponOrderService wxCouponOrderService; WxCouponOrderService wxCouponOrderService;


@Lazy
@Autowired @Autowired
WxCUserService wxCUserService; WxCUserService wxCUserService;


@Lazy
@Autowired @Autowired
WxCUserBasicInfoService wxCUserBasicInfoService; WxCUserBasicInfoService wxCUserBasicInfoService;


@@ -129,21 +133,27 @@ public class WxOrderServiceImpl implements WxOrderService {
@Autowired @Autowired
WxMerchantBUserMapper wxMerchantBUserMapper; WxMerchantBUserMapper wxMerchantBUserMapper;


@Lazy
@Autowired @Autowired
WxAppinfoService wxAppinfoService; WxAppinfoService wxAppinfoService;


@Lazy
@Autowired @Autowired
WxPayOrderService wxPayOrderService; WxPayOrderService wxPayOrderService;


@Lazy
@Autowired @Autowired
WxScoreRulesService wxScoreRulesService; WxScoreRulesService wxScoreRulesService;


@Lazy
@Autowired @Autowired
WxCUserTagsService wxCUserTagsService; WxCUserTagsService wxCUserTagsService;


@Lazy
@Autowired @Autowired
WxCouponActionLogService wxCouponActionLogService; WxCouponActionLogService wxCouponActionLogService;


@Lazy
@Autowired @Autowired
WxProfitSharingOrderService wxProfitSharingOrderService; WxProfitSharingOrderService wxProfitSharingOrderService;


@@ -153,6 +163,7 @@ public class WxOrderServiceImpl implements WxOrderService {
@Autowired @Autowired
WxCardInfoMapper wxCardInfoMapper; WxCardInfoMapper wxCardInfoMapper;


@Lazy
@Autowired @Autowired
WxCouponSendService wxCouponSendService; WxCouponSendService wxCouponSendService;


@@ -162,6 +173,7 @@ public class WxOrderServiceImpl implements WxOrderService {
@Autowired @Autowired
WxOrderGroupMapper wxOrderGroupMapper; WxOrderGroupMapper wxOrderGroupMapper;


@Lazy
@Autowired @Autowired
WxCreditHistoryService wxCreditHistoryService; WxCreditHistoryService wxCreditHistoryService;


@@ -174,6 +186,7 @@ public class WxOrderServiceImpl implements WxOrderService {
@Autowired @Autowired
private WxCUserBasicInfoMapper wxCUserBasicInfoMapper; private WxCUserBasicInfoMapper wxCUserBasicInfoMapper;


@Lazy
@Autowired @Autowired
private WxMsgLimitService wxMsgLimitService; private WxMsgLimitService wxMsgLimitService;


@@ -183,9 +196,11 @@ public class WxOrderServiceImpl implements WxOrderService {
@Autowired @Autowired
ExcelService excelService; ExcelService excelService;
@Lazy
@Autowired @Autowired
WxCouponService wxCouponService; WxCouponService wxCouponService;


@Lazy
@Autowired @Autowired
WxCouponChannelService wxCouponChannelService; WxCouponChannelService wxCouponChannelService;
@@ -199,6 +214,10 @@ public class WxOrderServiceImpl implements WxOrderService {
@Autowired @Autowired
OrderFactory orderFactory; OrderFactory orderFactory;
@Lazy
@Autowired
WxMerchantService wxMerchantService;
@Override @Override
public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record)); return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record));
@@ -812,8 +831,8 @@ public class WxOrderServiceImpl implements WxOrderService {
* @param couponId * @param couponId
* @return * @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())))) { if (merchantVoList.stream().anyMatch((cm -> cm.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())))) {
return true; return true;
} }
@@ -2408,7 +2427,7 @@ public class WxOrderServiceImpl implements WxOrderService {
} }
if (EnumCouponType.mustHasMerchant(coupon.getType())) { if (EnumCouponType.mustHasMerchant(coupon.getType())) {
// 检查券商户信息 // 检查券商户信息
if (!isCouponMerchantValid(coupon.getId(),coupon.getTenantId())) {
if (!isCouponMerchantValid(coupon.getId(),coupon)) {
logger.error("商户不存在, couponId: " + coupon.getId()); logger.error("商户不存在, couponId: " + coupon.getId());
throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),premsg+"商户信息没找到"); throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),premsg+"商户信息没找到");
} }


+ 7
- 57
mallinkService/src/main/resources/mapper/WxCouponMerchantMapper.xml Просмотреть файл

@@ -84,71 +84,21 @@
<include refid="dynamicWhereConditions" /> <include refid="dynamicWhereConditions" />
</select> </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 from wx_coupon_merchant cm
left join wx_merchant m on m.id = cm.merchant_id
where cm.status = 0 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>
<select id="findMerchantBaseList" parameterType="java.util.Map" resultMap="MerchantVoResultMap">
<select id="findMerchantListByProduct" parameterType="java.util.Map" resultMap="BaseResultMap">
select select
<include refid="allMerchantBaseColumns"/>
cm.parameter,cm.merchant_id
from wx_coupon_merchant cm from wx_coupon_merchant cm
left join wx_merchant m on m.id = cm.merchant_id
where cm.status = 0 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>


<resultMap id="MerchantProductVoResultMap" type="com.iformall.domain.vo.WxMerchantProductVo"> <resultMap id="MerchantProductVoResultMap" type="com.iformall.domain.vo.WxMerchantProductVo">
<result column="product_id" jdbcType="BIGINT" property="productId"/> <result column="product_id" jdbcType="BIGINT" property="productId"/>
<result column="merchant_id" jdbcType="BIGINT" property="merchantId"/> <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>


Загрузка…
Отмена
Сохранить