package com.hxh.spring.test.vip;
|
|
import com.yeshi.buwan.domain.vip.VIPOrderRecord;
|
import com.yeshi.buwan.domain.vip.VIPPrice;
|
import com.yeshi.buwan.domain.vip.VIPPriceType;
|
import com.yeshi.buwan.exception.vip.VIPException;
|
import com.yeshi.buwan.service.inter.vip.VIPPriceService;
|
import com.yeshi.buwan.service.inter.vip.VIPService;
|
import org.junit.Test;
|
import org.junit.runner.RunWith;
|
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.web.WebAppConfiguration;
|
|
import javax.annotation.Resource;
|
import java.math.BigDecimal;
|
import java.util.Date;
|
import java.util.List;
|
|
@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试
|
@ContextConfiguration(locations = {"classpath:spring.xml"})
|
@WebAppConfiguration
|
public class VIPTest {
|
|
@Resource
|
private VIPPriceService vipPriceService;
|
|
@Resource
|
private VIPService vipService;
|
|
@Test
|
public void addVIPPrice() {
|
VIPPrice price = new VIPPrice();
|
price.setPrice(new BigDecimal(8));
|
price.setType(VIPPriceType.month);
|
price.setPptvGoodsNo("DA7559531560894");
|
price.setShow(true);
|
try {
|
vipPriceService.addPrice(price);
|
} catch (VIPException e) {
|
e.printStackTrace();
|
}
|
|
price = new VIPPrice();
|
price.setPrice(new BigDecimal(24));
|
price.setType(VIPPriceType.season);
|
price.setPptvGoodsNo("DA7559574625089");
|
price.setShow(true);
|
try {
|
vipPriceService.addPrice(price);
|
} catch (VIPException e) {
|
e.printStackTrace();
|
}
|
|
|
price = new VIPPrice();
|
price.setPrice(new BigDecimal(45));
|
price.setType(VIPPriceType.halfYear);
|
price.setPptvGoodsNo("DA6989580247516");
|
price.setShow(true);
|
try {
|
vipPriceService.addPrice(price);
|
} catch (VIPException e) {
|
e.printStackTrace();
|
}
|
|
|
price = new VIPPrice();
|
price.setPrice(new BigDecimal(88));
|
price.setType(VIPPriceType.year);
|
price.setPptvGoodsNo("DA8129574268091");
|
price.setShow(true);
|
try {
|
vipPriceService.addPrice(price);
|
} catch (VIPException e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
@Test
|
public void listVIPPrice() {
|
List<VIPPrice> list = vipPriceService.listValidPrice();
|
System.out.println(list);
|
}
|
|
|
@Test
|
public void addOrderRecord() {
|
VIPPrice price = vipPriceService.selectByPrimaryKey("172a8327fcd3685ab3c0f740d031da09");
|
VIPOrderRecord record = new VIPOrderRecord();
|
record.setMoney(price.getPrice());
|
record.setType(price.getType());
|
record.setUid(766693 + "");
|
|
try {
|
vipService.addVIPRecord(record);
|
} catch (VIPException e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void listRecord() {
|
List<VIPOrderRecord> list = vipService.listOrderRecord(null, null, 1, 10);
|
long count = vipService.countOrderRecord(null, null);
|
|
|
list = vipService.listOrderRecord(766693 + "", null, 1, 10);
|
count = vipService.countOrderRecord(766693 + "", null);
|
|
|
list = vipService.listOrderRecord(766693 + "", VIPOrderRecord.STATE_NOT_PAY, 1, 10);
|
count = vipService.countOrderRecord(766693 + "", VIPOrderRecord.STATE_NOT_PAY);
|
|
list = vipService.listOrderRecord(766693 + "", VIPOrderRecord.STATE_PAY, 1, 10);
|
count = vipService.countOrderRecord(766693 + "", VIPOrderRecord.STATE_PAY);
|
|
System.out.println(list);
|
}
|
|
@Test
|
public void paySuccess() {
|
try {
|
vipService.paySuccess("2", VIPOrderRecord.PAY_WAY_ALIPAY, new BigDecimal("2.99"), new Date());
|
} catch (VIPException e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
}
|