lin 3 лет назад
Родитель
Сommit
849101d2f0
4 измененных файлов: 104 добавлений и 18 удалений
  1. +2
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java
  2. +1
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumCouponType.java
  3. +82
    -12
      mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java
  4. +19
    -5
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java

+ 2
- 0
mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java Просмотреть файл

@@ -1,6 +1,7 @@
package com.iformall.controller.market; package com.iformall.controller.market;


import com.iformall.annotation.SystemControllerLog; import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode; import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController; import com.iformall.controller.base.BaseController;
@@ -119,6 +120,7 @@ public class TtCouponGoodsController extends BaseController {


} }


@TenantIgnore
@ApiOperation("提交审核") @ApiOperation("提交审核")
@PostMapping("product/save") @PostMapping("product/save")
@SystemControllerLog(description = "提交审核") @SystemControllerLog(description = "提交审核")


+ 1
- 1
mallinkService/src/main/java/com/iformall/enums/EnumCouponType.java Просмотреть файл

@@ -157,7 +157,7 @@ public enum EnumCouponType {
if(type == null) { if(type == null) {
return false; return false;
} }
if(type == COUPON_DOUYIN_PLAT.getCode()) {
if(type == COUPON_DOUYIN_PLAT.getCode() || type == COUPON_DOUYIN_BRAND.getCode()) {
return true; return true;
} }
return false; return false;


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

@@ -26,6 +26,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; 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.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
@@ -81,6 +82,14 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService {


@Autowired @Autowired
TtGoodsCategoryMapper ttGoodsCategoryMapper; TtGoodsCategoryMapper ttGoodsCategoryMapper;
@Lazy
@Autowired
WxCouponMallService wxCouponMallService;
@Lazy
@Autowired
WxMerchantService wxMerchantService;


@Override @Override
public ResultData couponList(TtCouponVo ttCouponVo, Integer pageNum, Integer pageSize) { public ResultData couponList(TtCouponVo ttCouponVo, Integer pageNum, Integer pageSize) {
@@ -163,11 +172,60 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService {
} }


//获取门店,确保所有门店匹配poi //获取门店,确保所有门店匹配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()){ if(pois == null || pois.isEmpty()){
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),"未找到poi门店"); return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),"未找到poi门店");
} }
@@ -181,12 +239,24 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService {
poiList.add(poiStruct); 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(); WxCouponChannel wxCouponChannelQuery = new WxCouponChannel();
wxCouponChannelQuery.updateTenantInfo(coupon); wxCouponChannelQuery.updateTenantInfo(coupon);
@@ -244,7 +314,7 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService {
prostruct.setCategoryId(ttattrs.getCategoryId()); prostruct.setCategoryId(ttattrs.getCategoryId());
prostruct.setProductType(ttattrs.getProductType()); prostruct.setProductType(ttattrs.getProductType());
prostruct.setBizLine(5);//默认小程序 prostruct.setBizLine(5);//默认小程序
prostruct.setAccountName(merchant.getName());
prostruct.setAccountName(payAccountMerchant.getName());


prostruct.setSoldStartTime((long) DateUtils.getSecondTimestamp(wxCouponChannel.getBeginTime())); prostruct.setSoldStartTime((long) DateUtils.getSecondTimestamp(wxCouponChannel.getBeginTime()));
prostruct.setSoldEndTime((long) DateUtils.getSecondTimestamp(wxCouponChannel.getEndTime())); prostruct.setSoldEndTime((long) DateUtils.getSecondTimestamp(wxCouponChannel.getEndTime()));


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

@@ -527,7 +527,8 @@ public class WxCouponServiceImpl implements WxCouponService {
}catch(Exception e) { }catch(Exception e) {
return new ResultData(Result.ERROR,e.getMessage()); return new ResultData(Result.ERROR,e.getMessage());
} }
}else if (EnumCouponType.checkCreateWithMalls(record.getType())) {
}
if (EnumCouponType.checkCreateWithMalls(record.getType())) {
String[] mallTenantIds = record.getMallTenantIds(); String[] mallTenantIds = record.getMallTenantIds();
if (null == mallTenantIds || mallTenantIds.length <= 0 ) { if (null == mallTenantIds || mallTenantIds.length <= 0 ) {
return new ResultData(Result.ERROR,"请选择商场"); return new ResultData(Result.ERROR,"请选择商场");
@@ -556,7 +557,9 @@ public class WxCouponServiceImpl implements WxCouponService {
wxCouponMerchantMapper.insert(cm); wxCouponMerchantMapper.insert(cm);
}); });
} }
}else if (EnumCouponType.checkCreateWithMalls(record.getType())) {
}
if (EnumCouponType.checkCreateWithMalls(record.getType())) {
for (String mt : record.getMallTenantIds()) { for (String mt : record.getMallTenantIds()) {
WxCouponMall mall = new WxCouponMall(); WxCouponMall mall = new WxCouponMall();
mall.updateTenantInfo(record); mall.updateTenantInfo(record);
@@ -564,7 +567,12 @@ public class WxCouponServiceImpl implements WxCouponService {
mall.setProductId(record.getId()); mall.setProductId(record.getId());
mall.setCreateDate(new Date()); mall.setCreateDate(new Date());
mall.setUpdateDate(new Date()); mall.setUpdateDate(new Date());
mall.setStatus(EnumCouponMallStatus.UNFINISED.getCode());
//如果是直接设置到商户的,直接变为已完成
if (EnumCouponType.checkCreateWithMerchants(record.getType())) {
mall.setStatus(EnumCouponMallStatus.FINISED.getCode());
}else {
mall.setStatus(EnumCouponMallStatus.UNFINISED.getCode());
}
wxCouponMallMapper.insert(mall); wxCouponMallMapper.insert(mall);
} }
} }
@@ -602,7 +610,9 @@ public class WxCouponServiceImpl implements WxCouponService {
logger.error("updateCouponMerchants error.",e); logger.error("updateCouponMerchants error.",e);
return new ResultData(Result.ERROR,"更新商户出错。"+e.getMessage()); return new ResultData(Result.ERROR,"更新商户出错。"+e.getMessage());
} }
}else if (EnumCouponType.checkCreateWithMalls(record.getType())) {
}
if (EnumCouponType.checkCreateWithMalls(record.getType())) {
WxCouponMall couponMall = new WxCouponMall(); WxCouponMall couponMall = new WxCouponMall();
couponMall.updateTenantInfo(record); couponMall.updateTenantInfo(record);
couponMall.setProductId(record.getId()); couponMall.setProductId(record.getId());
@@ -614,7 +624,11 @@ public class WxCouponServiceImpl implements WxCouponService {
mall.setProductId(record.getId()); mall.setProductId(record.getId());
mall.setCreateDate(new Date()); mall.setCreateDate(new Date());
mall.setUpdateDate(new Date()); mall.setUpdateDate(new Date());
mall.setStatus(EnumCouponMallStatus.UNFINISED.getCode());
if (EnumCouponType.checkCreateWithMerchants(record.getType())) {
mall.setStatus(EnumCouponMallStatus.FINISED.getCode());
}else {
mall.setStatus(EnumCouponMallStatus.UNFINISED.getCode());
}
wxCouponMallMapper.insert(mall); wxCouponMallMapper.insert(mall);
} }
} }


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