|
|
|
@@ -8,10 +8,7 @@ import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.WxCoupon; |
|
|
|
import com.iformall.domain.po.WxCouponChannel; |
|
|
|
import com.iformall.domain.po.WxMerchant; |
|
|
|
import com.iformall.enums.EnumCouponStatus; |
|
|
|
import com.iformall.enums.EnumCouponType; |
|
|
|
import com.iformall.enums.EnumCouponValidType; |
|
|
|
import com.iformall.enums.EnumMerchantStatus; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.service.WxCouponChannelService; |
|
|
|
import com.iformall.service.WxCouponService; |
|
|
|
import com.iformall.service.WxMerchantService; |
|
|
|
@@ -39,58 +36,6 @@ public class WxCouponController extends BaseController { |
|
|
|
@Autowired |
|
|
|
private WxCouponService wxCouponService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxCouponChannelService wxCouponChannelService; |
|
|
|
|
|
|
|
private ResultData listType(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize, Integer type) { |
|
|
|
if (null == wxCoupon) wxCoupon = new WxCoupon(); |
|
|
|
wxCoupon.setTenantId(getTenantId()); |
|
|
|
wxCoupon.setSortColumns(WxCoupon.Field.Id_DESC); |
|
|
|
PageInfo<WxCoupon> page = null; |
|
|
|
if (wxCoupon.getStatus() != null && wxCoupon.getStatus() == -1) |
|
|
|
wxCoupon.setStatus(null); |
|
|
|
page = wxCouponService.listAsPage(wxCoupon, pageNum, pageSize, type); |
|
|
|
|
|
|
|
List<WxCoupon> wxCouponList = page.getList(); |
|
|
|
|
|
|
|
if (wxCouponList.isEmpty()) { |
|
|
|
return new ResultData(page); |
|
|
|
} |
|
|
|
|
|
|
|
List<Long> ids = wxCouponList.stream().map(p -> p.getId()).collect(Collectors.toList()); |
|
|
|
WxCouponChannel wxCouponChannel = new WxCouponChannel(); |
|
|
|
wxCouponChannel.setTenantId(getTenantId()); |
|
|
|
wxCouponChannel.setCouponIds(ids); |
|
|
|
wxCouponChannel.setStatus(0); |
|
|
|
//上架状态 |
|
|
|
List<WxCouponChannel> list = wxCouponChannelService.listAsPage(wxCouponChannel, 1, 10000).getList(); |
|
|
|
if (!list.isEmpty()) { |
|
|
|
Map<Long, List<WxCouponChannel>> groupBy = list.stream().collect(Collectors.groupingBy(WxCouponChannel::getCouponId)); |
|
|
|
for (WxCoupon temp : wxCouponList) { |
|
|
|
|
|
|
|
if (groupBy.get(temp.getId()) != null) { |
|
|
|
List<Integer> channels = new ArrayList<>(); |
|
|
|
for (WxCouponChannel tempchannel : groupBy.get(temp.getId())) { |
|
|
|
if (!channels.contains(tempchannel.getTargetAd())) { |
|
|
|
channels.add(tempchannel.getTargetAd()); |
|
|
|
} |
|
|
|
} |
|
|
|
String sss = JSON.toJSONString(channels); |
|
|
|
temp.setChannels(sss); |
|
|
|
} else { |
|
|
|
temp.setChannels(""); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
for (WxCoupon temp : wxCouponList) { |
|
|
|
temp.setChannels(""); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return new ResultData(page); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("分页列表接口") |
|
|
|
@GetMapping("listCoupon") |
|
|
|
@@ -99,7 +44,9 @@ public class WxCouponController extends BaseController { |
|
|
|
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) |
|
|
|
public ResultData listCoupon(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { |
|
|
|
logger.debug("[" + getIpAddr() + "] WxCouponController::listCoupon"); |
|
|
|
return listType(wxCoupon, pageNum, pageSize, 0); //券列表 |
|
|
|
if (wxCoupon == null) wxCoupon = new WxCoupon(); |
|
|
|
wxCoupon.setTenantId(getTenantId()); |
|
|
|
return wxCouponService.listType(wxCoupon, pageNum, pageSize, 0); //券列表 |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("卡分页列表接口") |
|
|
|
@@ -109,7 +56,9 @@ public class WxCouponController extends BaseController { |
|
|
|
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) |
|
|
|
public ResultData listCard(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { |
|
|
|
logger.debug("[" + getIpAddr() + "] WxCouponController::listCard"); |
|
|
|
return listType(wxCoupon, pageNum, pageSize, EnumCouponType.CARD_MULTIMCH.getCode()); //卡列表 |
|
|
|
if (wxCoupon == null) wxCoupon = new WxCoupon(); |
|
|
|
wxCoupon.setTenantId(getTenantId()); |
|
|
|
return wxCouponService.listType(wxCoupon, pageNum, pageSize, EnumCouponType.CARD_MULTIMCH.getCode()); //卡列表 |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("砍价分页列表接口") |
|
|
|
@@ -119,7 +68,9 @@ public class WxCouponController extends BaseController { |
|
|
|
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) |
|
|
|
public ResultData listPress(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { |
|
|
|
logger.debug("[" + getIpAddr() + "] WxCouponController::listPress"); |
|
|
|
return listType(wxCoupon, pageNum, pageSize, EnumCouponType.COUPON_PRESS.getCode()); //砍价列表 |
|
|
|
if (wxCoupon == null) wxCoupon = new WxCoupon(); |
|
|
|
wxCoupon.setTenantId(getTenantId()); |
|
|
|
return wxCouponService.listType(wxCoupon, pageNum, pageSize, EnumCouponType.COUPON_PRESS.getCode()); //砍价列表 |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("分页列表接口") |
|
|
|
@@ -129,7 +80,9 @@ public class WxCouponController extends BaseController { |
|
|
|
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) |
|
|
|
public ResultData list(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { |
|
|
|
logger.debug("[" + getIpAddr() + "] WxCouponController::list"); |
|
|
|
return listType(wxCoupon, pageNum, pageSize, null); //全列表 |
|
|
|
if (wxCoupon == null) wxCoupon = new WxCoupon(); |
|
|
|
wxCoupon.setTenantId(getTenantId()); |
|
|
|
return wxCouponService.listType(wxCoupon, pageNum, pageSize, null); //全列表 |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("新增接口") |
|
|
|
|