|
|
|
@@ -5,14 +5,13 @@ import com.iformall.annotation.SystemControllerLog; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.controller.base.BaseController; |
|
|
|
import com.iformall.domain.po.BaseEntity; |
|
|
|
import com.iformall.domain.po.MallUserInfo; |
|
|
|
import com.iformall.domain.po.WxCoupon; |
|
|
|
import com.iformall.domain.po.WxCouponPresent; |
|
|
|
import com.iformall.domain.po.*; |
|
|
|
import com.iformall.enums.EnumCouponPasswordStatus; |
|
|
|
import com.iformall.enums.EnumCouponStatus; |
|
|
|
import com.iformall.enums.EnumCouponValidType; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.service.PushLimitService; |
|
|
|
import com.iformall.service.WxCouponPasswordService; |
|
|
|
import com.iformall.service.WxCouponPresentService; |
|
|
|
import com.iformall.service.WxCouponService; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
@@ -25,6 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author gongbiao |
|
|
|
@@ -44,6 +46,9 @@ public class WxCouponPresentController extends BaseController { |
|
|
|
@Autowired |
|
|
|
WxCouponService wxCouponService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxCouponPasswordService wxCouponPasswordService; |
|
|
|
|
|
|
|
@ApiOperation("分页列表接口") |
|
|
|
@GetMapping("/list") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@@ -99,8 +104,30 @@ public class WxCouponPresentController extends BaseController { |
|
|
|
if (!wxCoupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode())) { |
|
|
|
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); |
|
|
|
} |
|
|
|
|
|
|
|
//获取手机号 |
|
|
|
String phones = wxCouponPresent.getPhones(); |
|
|
|
String[] phoneSplit = phones.split(","); |
|
|
|
Set<String> phoneSet = new HashSet<>(phoneSplit.length); |
|
|
|
for (String phone : phoneSplit) { |
|
|
|
if (!phone.isEmpty()) { |
|
|
|
phoneSet.add(phone); |
|
|
|
} |
|
|
|
} |
|
|
|
//查询有效券数量 |
|
|
|
WxCouponPassword wxCouponPassword = new WxCouponPassword(); |
|
|
|
wxCouponPassword.setTenantId(user.getTenantId()); |
|
|
|
wxCouponPassword.setCouponId(wxCouponPresent.getCouponId()); |
|
|
|
wxCouponPassword.setStatus(EnumCouponPasswordStatus.INIT.getCode()); |
|
|
|
List<WxCouponPassword> list = wxCouponPasswordService.findList(wxCouponPassword); |
|
|
|
if (phoneSet.size() > list.size()) { |
|
|
|
logger.info(ErrorCode.REMAIN_IS_EMPTY.getMessage()); |
|
|
|
return new ResultData(ErrorCode.REMAIN_IS_EMPTY); |
|
|
|
} |
|
|
|
|
|
|
|
wxCouponPresent.setCouponName(wxCoupon.getTitle()); |
|
|
|
return wxCouponPresentService.add(wxCouponPresent); |
|
|
|
wxCouponPresentService.add(wxCouponPresent, list, phoneSet); |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
} |