直接帖代码了
这个是测试类
import java.util.HashMap;
import java.util.Map;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.google.gson.Gson;
public class OperateShopCouponServiceImplTest {
@InjectMocks
private OperateShopCouponServiceImpl operateShopCouponServiceImpl;
@Mock
private UserInfoService userInfoService;
@Mock
private PromotionBaseService promotionBaseService;
@Mock
private ShopCouponTemplateSendService shopCouponTemplateSendService;
@Mock
private CouponAccountService couponAccountService;
@Mock
private ShopFavoriteCommonService shopFavoriteCommonService;
@Mock
private OperateShopCouponExportService operateShopCouponExportService;
@Mock
private ShopFavoriteGiftService shopFavoriteGiftService;
@Mock
private PageShardingDalClient dalClient;
@SuppressWarnings("unchecked")
@DataProvider
public Object[][] dp1() {
String reqJsonStr = "{'pageCode':'111','pageName':'222','pageChannel':'31'}";
Map reqMap = new Gson().fromJson(reqJsonStr, Map.class);
return new Object[][] { { reqMap } };
}
@BeforeClass
public void beforeClass() {
// 自动将依赖的类注入待测类
MockitoAnnotations.initMocks(this);
}
// 品牌商保存测试
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void insertPromotionInfoTestP(Map inputMap) {
Mockito.reset(promotionBaseService);
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("showRegion", "1");
paramMap.put("baseAmount", "1");
paramMap.put("couponType", "1");
paramMap.put("assignedRole", "03");
paramMap.put("rewardAmount", 112222);
paramMap.put("activityTimesLimit", 1000000000);
// 执行特定方法,构造返回值
Map newParamMap = new HashMap();
newParamMap.put("sendFlag", "");
newParamMap.put("activityCode", "");
newParamMap.put("excludeProduct", "");
newParamMap.put("donationFlag", "");
newParamMap.put("operationType", "");
newParamMap.put("showRegion", "");
newParamMap.put("activityStatus", "");
newParamMap.put("activityType", "");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "K");
Mockito.when(userInfoService.getSupplyinfoByCode(newParamMap))
.thenReturn(supplyInfoMap);
CouponAccountBean couponAccountBean1 = new CouponAccountBean();
couponAccountBean1.setReceiveFlag("F");
Mockito.when(
couponAccountService.activeCreateAddStop(Mockito
.any(CouponAccountBean.class))).thenReturn(
couponAccountBean1);
// 调用接口
operateShopCouponServiceImpl.insertPromotionInfoP(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void insertPromotionInfoTestP1(Map inputMap) {
Mockito.reset(promotionBaseService);
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("baseAmount", "");
paramMap.put("channelInfo", "22");
paramMap.put("assignedRole", "03");
paramMap.put("rewardAmount", 112222);
paramMap.put("productCode", "3335526");
paramMap.put("supplierType", "P");
paramMap.put("activityTimesLimit", 1000000000);
// 执行特定方法,构造返回值
Map newParamMap = new HashMap();
newParamMap.put("sendFlag", "");
newParamMap.put("activityCode", "");
newParamMap.put("excludeProduct", "");
newParamMap.put("donationFlag", "");
newParamMap.put("operationType", "");
newParamMap.put("showRegion", "");
newParamMap.put("activityStatus", "");
newParamMap.put("activityType", "");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "K");
Mockito.when(userInfoService.getSupplyinfoByCode(newParamMap))
.thenReturn(supplyInfoMap);
CouponAccountBean couponAccountBean1 = new CouponAccountBean();
couponAccountBean1.setReceiveFlag("S");
CouponAccountBean couponAccountBean3 = new CouponAccountBean();
couponAccountBean3.setReceiveFlag("S");
Mockito.when(
couponAccountService.activeCreateAddStop(Mockito
.any(CouponAccountBean.class)))
.thenReturn(couponAccountBean1).thenReturn(couponAccountBean3);
Mockito.when(
operateShopCouponExportService.createOrModifyShopCouponInfoP(
paramMap, "1")).thenReturn("XXX");
Map responseMap = new HashMap();
responseMap.put("flag", "1");
Mockito.when(operateShopCouponExportService.send(Mockito.anyString()))
.thenReturn(responseMap);
CouponAccountBean ticketRuleIdNoticeBean = new CouponAccountBean();
ticketRuleIdNoticeBean.setReceiveFlag("F");
Mockito.when(
couponAccountService.ticketRuleIdNotice(Mockito.anyString(),
Mockito.anyString(), Mockito.anyString())).thenReturn(
ticketRuleIdNoticeBean);
// 调用接口
operateShopCouponServiceImpl.insertPromotionInfoP(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void insertPromotionInfoTestP11(Map inputMap) {
Mockito.reset(promotionBaseService);
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("baseAmount", "1213415");
paramMap.put("assignedRole", "03");
paramMap.put("rewardAmount", 112222);
paramMap.put("activityTimesLimit", 1000000000);
String[] showRegion = { "33", "22" };
paramMap.put("showRegion", showRegion);
String[] channelInfo = { "21", "32" };
paramMap.put("channelInfo", channelInfo);
String[] productCode = { "21223355", "3253565" };
paramMap.put("productCode", productCode);
// 执行特定方法,构造返回值
Map newParamMap = new HashMap();
newParamMap.put("sendFlag", "");
newParamMap.put("activityCode", "");
newParamMap.put("excludeProduct", "");
newParamMap.put("donationFlag", "");
newParamMap.put("operationType", "");
newParamMap.put("showRegion", showRegion);
newParamMap.put("activityStatus", "");
newParamMap.put("activityType", "");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "S");
Mockito.when(userInfoService.getSupplyinfoByCode(newParamMap))
.thenReturn(supplyInfoMap);
CouponAccountBean couponAccountBean1 = new CouponAccountBean();
couponAccountBean1.setReceiveFlag("S");
CouponAccountBean couponAccountBean3 = new CouponAccountBean();
couponAccountBean3.setReceiveFlag("S");
Mockito.when(
couponAccountService.activeCreateAddStop(Mockito
.any(CouponAccountBean.class)))
.thenReturn(couponAccountBean1).thenReturn(couponAccountBean3);
Mockito.when(
operateShopCouponExportService.createOrModifyShopCouponInfoP(
paramMap, "1")).thenReturn("XXX");
Map responseMap = new HashMap();
responseMap.put("flag", "0");
Mockito.when(operateShopCouponExportService.send(Mockito.anyString()))
.thenReturn(responseMap);
CouponAccountBean ticketRuleIdNoticeBean = new CouponAccountBean();
ticketRuleIdNoticeBean.setReceiveFlag("F");
Mockito.when(
couponAccountService.ticketRuleIdNotice(Mockito.anyString(),
Mockito.anyString(), Mockito.anyString())).thenReturn(
ticketRuleIdNoticeBean);
// 调用接口
operateShopCouponServiceImpl.insertPromotionInfoP(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void insertPromotionInfoTestP111(Map inputMap) {
Mockito.reset(promotionBaseService);
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("baseAmount", "");
paramMap.put("assignedRole", "03");
paramMap.put("rewardAmount", 112222);
paramMap.put("activityTimesLimit", 1000000000);
paramMap.put("startTime", "2017-04-12");
String[] showRegion = { "66", "55" };
paramMap.put("showRegion", showRegion);
String[] channelInfo = { "21", "32" };
paramMap.put("channelInfo", channelInfo);
String[] productCode = { "21223355", "3253565" };
paramMap.put("productCode", productCode);
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "K");
Mockito.when(userInfoService.getSupplyinfoByCode(paramMap))
.thenReturn(supplyInfoMap);
CouponAccountBean couponAccountBean1 = new CouponAccountBean();
couponAccountBean1.setReceiveFlag("S");
CouponAccountBean couponAccountBean3 = new CouponAccountBean();
couponAccountBean3.setReceiveFlag("F");
Mockito.when(
couponAccountService.activeCreateAddStop(Mockito
.any(CouponAccountBean.class)))
.thenReturn(couponAccountBean1).thenReturn(couponAccountBean3);
Mockito.when(
operateShopCouponExportService.createOrModifyShopCouponInfoP(
paramMap, "1")).thenReturn("XXX");
Map responseMap = new HashMap();
Mockito.when(operateShopCouponExportService.send(Mockito.anyString()))
.thenReturn(responseMap);
// 调用接口
operateShopCouponServiceImpl.insertPromotionInfoP(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void updatePromotionBasePTest(Map inputMap) {
Mockito.reset(promotionBaseService);
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("baseAmount", "");
paramMap.put("assignedRole", "03");
paramMap.put("operateAmount", 10000000);
paramMap.put("rewardAmount", 112222);
paramMap.put("activityTimesLimit", 1000000000);
paramMap.put("startTime", "2017-04-12");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "K");
Mockito.when(userInfoService.getSupplyinfoByCode(paramMap))
.thenReturn(supplyInfoMap);
CouponAccountBean couponAccountBean1 = new CouponAccountBean();
couponAccountBean1.setReceiveFlag("S");
CouponAccountBean couponAccountBean3 = new CouponAccountBean();
couponAccountBean3.setReceiveFlag("F");
Mockito.when(
couponAccountService.activeCreateAddStop(Mockito
.any(CouponAccountBean.class)))
.thenReturn(couponAccountBean1).thenReturn(couponAccountBean3);
Mockito.when(
operateShopCouponExportService.createOrModifyShopCouponInfoP(
paramMap, "1")).thenReturn("XXX");
Map responseMap = new HashMap();
Mockito.when(operateShopCouponExportService.send(Mockito.anyString()))
.thenReturn(responseMap);
// 调用接口
operateShopCouponServiceImpl.updatePromotionBaseP(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void updatePromotionBasePTest1(Map inputMap) {
Mockito.reset(promotionBaseService);
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("baseAmount", "");
paramMap.put("assignedRole", "03");
paramMap.put("operateAmount", 10000000);
paramMap.put("rewardAmount", 112222);
paramMap.put("activityTimesLimit", 1000000000);
paramMap.put("startTime", "2017-04-12");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "K");
Mockito.when(userInfoService.getSupplyinfoByCode(paramMap))
.thenReturn(supplyInfoMap);
CouponAccountBean couponAccountBean1 = new CouponAccountBean();
couponAccountBean1.setReceiveFlag("F");
Mockito.when(
couponAccountService.activeCreateAddStop(Mockito
.any(CouponAccountBean.class)))
.thenReturn(couponAccountBean1);
// 调用接口
operateShopCouponServiceImpl.updatePromotionBaseP(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void updatePromotionBasePTest11(Map inputMap) {
Mockito.reset(promotionBaseService);
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("baseAmount", "");
paramMap.put("assignedRole", "03");
paramMap.put("operateAmount", 10000000);
paramMap.put("rewardAmount", 112222);
paramMap.put("activityTimesLimit", 1000000000);
paramMap.put("startTime", "2017-04-12");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "K");
Mockito.when(userInfoService.getSupplyinfoByCode(paramMap))
.thenReturn(supplyInfoMap);
CouponAccountBean couponAccountBean1 = new CouponAccountBean();
couponAccountBean1.setReceiveFlag("S");
CouponAccountBean couponAccountBean3 = new CouponAccountBean();
couponAccountBean3.setReceiveFlag("S");
Mockito.when(
couponAccountService.activeCreateAddStop(Mockito
.any(CouponAccountBean.class)))
.thenReturn(couponAccountBean1).thenReturn(couponAccountBean3);
Mockito.when(
operateShopCouponExportService.createOrModifyShopCouponInfoP(
paramMap, "2")).thenReturn("XXX");
Map responseMap = new HashMap();
responseMap.put("flag", "1");
Mockito.when(operateShopCouponExportService.send(Mockito.anyString()))
.thenReturn(responseMap);
// 调用接口
operateShopCouponServiceImpl.updatePromotionBaseP(paramMap);
}
更新测试
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void updatePromotionBasePTest111(Map inputMap) {
Mockito.reset(promotionBaseService);
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("baseAmount", "");
paramMap.put("assignedRole", "03");
paramMap.put("operateAmount", 10000000);
paramMap.put("rewardAmount", 112222);
paramMap.put("activityTimesLimit", 1000000000);
paramMap.put("startTime", "2017-04-12");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "K");
Mockito.when(userInfoService.getSupplyinfoByCode(paramMap))
.thenReturn(supplyInfoMap);
CouponAccountBean couponAccountBean1 = new CouponAccountBean();
couponAccountBean1.setReceiveFlag("S");
CouponAccountBean couponAccountBean3 = new CouponAccountBean();
couponAccountBean3.setReceiveFlag("S");
Mockito.when(
couponAccountService.activeCreateAddStop(Mockito
.any(CouponAccountBean.class)))
.thenReturn(couponAccountBean1).thenReturn(couponAccountBean3);
Mockito.when(
operateShopCouponExportService.createOrModifyShopCouponInfoP(
paramMap, "2")).thenReturn("XXX");
Map responseMap = new HashMap();
responseMap.put("flag", "0");
Mockito.when(operateShopCouponExportService.send(Mockito.anyString()))
.thenReturn(responseMap);
// 调用接口
operateShopCouponServiceImpl.updatePromotionBaseP(paramMap);
}
异常测试
@SuppressWarnings("unchecked")
@Test(expectedExceptions = MpmsSystemException.class)
public void insertPromotionInfoRuntimeExceptionTestP() {
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("showRegion", "3");
paramMap.put("baseAmount", "");
paramMap.put("assignedRole", "03");
paramMap.put("rewardAmount", 112222);
paramMap.put("activityTimesLimit", 1000000000);
paramMap.put("startTime", "2017-04-12");
// 执行特定方法,构造返回值
Map newParamMap = new HashMap();
newParamMap.put("sendFlag", "");
newParamMap.put("activityCode", "");
newParamMap.put("excludeProduct", "");
newParamMap.put("donationFlag", "");
newParamMap.put("operationType", "");
newParamMap.put("showRegion", "");
newParamMap.put("activityStatus", "");
newParamMap.put("activityType", "");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "C");
Mockito.when(userInfoService.getSupplyinfoByCode(newParamMap))
.thenReturn(supplyInfoMap);
Mockito.when(userInfoService.getSupplyinfoByCode(newParamMap))
.thenReturn(supplyInfoMap);
Mockito.doThrow(RuntimeException.class).when(promotionBaseService)
.savePromotionBaseP((Map[]) Mockito.anyVararg());
operateShopCouponServiceImpl.insertPromotionInfoP(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void insertPromotionInfoTest(Map inputMap) {
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("showRegion", "1");
paramMap.put("baseAmount", "1");
paramMap.put("assignedRole", "03");
// 执行特定方法,构造返回值
Map newParamMap = new HashMap();
newParamMap.put("sendFlag", "");
newParamMap.put("activityCode", "");
newParamMap.put("excludeProduct", "");
newParamMap.put("donationFlag", "");
newParamMap.put("operationType", "");
newParamMap.put("showRegion", "");
newParamMap.put("activityStatus", "");
newParamMap.put("activityType", "");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "K");
Mockito.when(userInfoService.getSupplyinfoByCode(newParamMap))
.thenReturn(supplyInfoMap);
// 调用接口
operateShopCouponServiceImpl.insertPromotionInfo(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void insertPromotionInfoTest1(Map inputMap) {
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("showRegion", "3");
paramMap.put("baseAmount", "");
// 执行特定方法,构造返回值
Map newParamMap = new HashMap();
newParamMap.put("sendFlag", "");
newParamMap.put("activityCode", "");
newParamMap.put("excludeProduct", "");
newParamMap.put("donationFlag", "");
newParamMap.put("operationType", "");
newParamMap.put("showRegion", "");
newParamMap.put("activityStatus", "");
newParamMap.put("activityType", "");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "K");
Mockito.when(userInfoService.getSupplyinfoByCode(newParamMap))
.thenReturn(supplyInfoMap);
// 调用接口
operateShopCouponServiceImpl.insertPromotionInfo(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void insertPromotionInfoTest11(Map inputMap) {
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("showRegion", "3");
paramMap.put("baseAmount", "0");
// 执行特定方法,构造返回值
Map newParamMap = new HashMap();
newParamMap.put("sendFlag", "");
newParamMap.put("activityCode", "");
newParamMap.put("excludeProduct", "");
newParamMap.put("donationFlag", "");
newParamMap.put("operationType", "");
newParamMap.put("showRegion", "");
newParamMap.put("activityStatus", "");
newParamMap.put("activityType", "");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "K");
Mockito.when(userInfoService.getSupplyinfoByCode(newParamMap))
.thenReturn(supplyInfoMap);
// 调用接口
operateShopCouponServiceImpl.insertPromotionInfo(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void insertPromotionInfoTest2(Map inputMap) {
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("showRegion", "");
paramMap.put("baseAmount", "1");
// 执行特定方法,构造返回值
Map newParamMap = new HashMap();
newParamMap.put("sendFlag", "");
newParamMap.put("activityCode", "");
newParamMap.put("excludeProduct", "");
newParamMap.put("donationFlag", "");
newParamMap.put("operationType", "");
newParamMap.put("showRegion", "");
newParamMap.put("activityStatus", "");
newParamMap.put("activityType", "");
newParamMap.put("assignedRole", "02");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "C");
Mockito.when(userInfoService.getSupplyinfoByCode(newParamMap))
.thenReturn(supplyInfoMap);
// 调用接口
operateShopCouponServiceImpl.insertPromotionInfo(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void insertPromotionInfoTest22(Map inputMap) {
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("showRegion", "");
paramMap.put("baseAmount", "");
paramMap.put("isShop", "Y");
paramMap.put("excludeProduct", "2");
// 执行特定方法,构造返回值
Map newParamMap = new HashMap();
newParamMap.put("sendFlag", "");
newParamMap.put("activityCode", "");
newParamMap.put("excludeProduct", "");
newParamMap.put("donationFlag", "");
newParamMap.put("operationType", "");
newParamMap.put("showRegion", "");
newParamMap.put("activityStatus", "");
newParamMap.put("activityType", "");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "C");
Mockito.when(userInfoService.getSupplyinfoByCode(newParamMap))
.thenReturn(supplyInfoMap);
// 调用接口
operateShopCouponServiceImpl.insertPromotionInfo(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void insertPromotionInfoTest222(Map inputMap) {
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("showRegion", "");
paramMap.put("baseAmount", "");
paramMap.put("isShop", "Y");
paramMap.put("excludeProduct", "1");
// 执行特定方法,构造返回值
Map newParamMap = new HashMap();
newParamMap.put("sendFlag", "");
newParamMap.put("activityCode", "");
newParamMap.put("excludeProduct", "");
newParamMap.put("donationFlag", "");
newParamMap.put("operationType", "");
newParamMap.put("showRegion", "");
newParamMap.put("activityStatus", "");
newParamMap.put("activityType", "");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "C");
Mockito.when(userInfoService.getSupplyinfoByCode(newParamMap))
.thenReturn(supplyInfoMap);
// 调用接口
operateShopCouponServiceImpl.insertPromotionInfo(paramMap);
}
@SuppressWarnings("unchecked")
@Test(dataProvider = "dp1", groups = "exectest")
public void insertPromotionInfoTest2222(Map inputMap) {
// 构造请求参数
Map paramMap = Mockito.anyMap();
paramMap.put("showRegion", "");
paramMap.put("baseAmount", "0");
paramMap.put("isShop", "N");
// 执行特定方法,构造返回值
Map newParamMap = new HashMap();
newParamMap.put("sendFlag", "");
newParamMap.put("activityCode", "");
newParamMap.put("excludeProduct", "");
newParamMap.put("donationFlag", "");
newParamMap.put("operationType", "");
newParamMap.put("showRegion", "");
newParamMap.put("activityStatus", "");
newParamMap.put("activityType", "");
Map supplyInfoMap = new HashMap();
supplyInfoMap.put("supplierType", "C");
Mockito.when(userInfoService.getSupplyinfoByCode(newParamMap))
.thenReturn(supplyInfoMap);
// 调用接口
operateShopCouponServiceImpl.insertPromotionInfo(paramMap);
}
}
下面贴上被测试类
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class OperateShopCouponServiceImpl implements OperateShopCouponService {
private static final String ACTIVITY_ID = "activityId";
private static SnfLogger logger = SnfLoggerFactory.getLogger(OperateShopCouponServiceImpl.class);
private static Logger snlogger = LoggerFactory.getLogger(OperateShopCouponServiceImpl.class);
private static final String NAMESPACE = OperateShopCouponServiceImpl.class.getName();
private static final int START_FALG_SIZE = 6;
private static final int END_FLAG_SIZE = 7;
private static final long DEFAULTNUM = 180l * 24 * 60 * 60 * 1000;
@Autowired
private UserInfoService userInfoService;
private static Search4PageDynamicDataReqService search4PageDynamicDataReqService = ServiceLocator.getService(Search4PageDynamicDataReqService.class, null);
private static FavorActivityGiftService favorActivityGiftService = ServiceLocator.getService(FavorActivityGiftService.class, null);
private static GiftOfReviewService giftOfReviewService = ServiceLocator.getService(GiftOfReviewService.class, null);
private ChangeActivityStatusHttpRequest changeActivityStatusHttpRequest;
@Autowired
private PageShardingDalClient dalClient;
@Autowired
private PromotionBaseService promotionBaseService;
@Autowired
private CommonPromotionService commonPromotionService;
@Autowired
private CouponAccountService couponAccountService;
@Autowired
private ShopFavoriteCommonService shopFavoriteCommonService;
@Autowired
private ShopFavoriteGiftService shopFavoriteGiftService;
@Autowired
private ShopCouponTemplateSendService shopCouponTemplateSendService;
@Autowired
private OperateShopCouponExportService operateShopCouponExportService;
@EsbEIHttpWired
public void setChangeActivityStatusHttpRequest(ChangeActivityStatusHttpRequest changeActivityStatusHttpRequest) {
this.changeActivityStatusHttpRequest = changeActivityStatusHttpRequest;
}
@Override
public int getActivityCountByMonth(Map paramMap) {
int count = 0;
paramMap.put("activityType", CommonPromotionConstant.TYPE_13);
if("P".equals(MapUtils.getString(paramMap, MPMSCommonConstant.SUPPLIER_TYPE))){
paramMap.put("activityType", CommonPromotionConstant.TYPE_60);
}
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, 0);
c.set(Calendar.DAY_OF_MONTH, 1);// 设置为1号,当前日期既为本月第一天
String firstTime = format1.format(c.getTime());
// 获取当前月最后一天
Calendar ca = Calendar.getInstance();
ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
String lastTime = format2.format(ca.getTime());
paramMap.put("firstTime", firstTime);
paramMap.put("lastTime", lastTime);
List