package com.hxh.spring.test.vip;
|
|
import com.yeshi.buwan.domain.vip.*;
|
import com.yeshi.buwan.exception.PPTVException;
|
import com.yeshi.buwan.exception.ParamsException;
|
import com.yeshi.buwan.exception.order.OrderException;
|
import com.yeshi.buwan.exception.vip.VIPException;
|
import com.yeshi.buwan.exception.vip.VideoBuyRecordException;
|
import com.yeshi.buwan.job.OrderJob;
|
import com.yeshi.buwan.util.user.VipUtil;
|
import com.yeshi.buwan.util.vip.VIPOrderUtil;
|
import com.yeshi.buwan.videos.pptv.PPTVVipManager;
|
import com.yeshi.buwan.service.inter.order.OrderService;
|
import com.yeshi.buwan.service.inter.vip.VIPPriceService;
|
import com.yeshi.buwan.service.inter.vip.VIPService;
|
import com.yeshi.buwan.service.inter.vip.VideoBuyRecordService;
|
import com.yeshi.buwan.util.Constant;
|
import com.yeshi.buwan.util.HttpUtil;
|
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 org.yeshi.utils.alipay.AlipayH5PayUtil;
|
import org.yeshi.utils.wx.WXPayV3Util;
|
|
import javax.annotation.Resource;
|
import java.io.File;
|
import java.io.FileInputStream;
|
import java.math.BigDecimal;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Scanner;
|
|
//@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试
|
//@ContextConfiguration(locations = {"classpath:spring.xml"})
|
//@WebAppConfiguration
|
public class VIPTest {
|
|
@Resource
|
private VIPPriceService vipPriceService;
|
|
@Resource
|
private VIPService vipService;
|
|
|
@Resource
|
private OrderService orderService;
|
|
@Resource
|
private PPTVVipManager pptvVipManager;
|
|
@Resource
|
private OrderJob orderJob;
|
|
@Resource
|
private VideoBuyRecordService videoBuyRecordService;
|
|
@Test
|
public void addVIPPrice() {
|
VIPPrice price = new VIPPrice();
|
price.setActualPrice(new BigDecimal("8.8"));
|
price.setPrice(new BigDecimal("14.8"));
|
price.setType(VIPPriceType.month);
|
price.setPptvGoodsNo("DA7559531560894");
|
price.setShow(true);
|
try {
|
vipPriceService.addPrice(price);
|
} catch (VIPException e) {
|
e.printStackTrace();
|
}
|
|
price = new VIPPrice();
|
price.setActualPrice(new BigDecimal("22.8"));
|
price.setPrice(new BigDecimal("37.8"));
|
price.setType(VIPPriceType.season);
|
price.setPptvGoodsNo("DA7559574625089");
|
price.setShow(true);
|
try {
|
vipPriceService.addPrice(price);
|
} catch (VIPException e) {
|
e.printStackTrace();
|
}
|
|
|
price = new VIPPrice();
|
price.setActualPrice(new BigDecimal("42"));
|
price.setPrice(new BigDecimal("68.8"));
|
price.setType(VIPPriceType.halfYear);
|
price.setPptvGoodsNo("DA6989580247516");
|
price.setShow(true);
|
try {
|
vipPriceService.addPrice(price);
|
} catch (VIPException e) {
|
e.printStackTrace();
|
}
|
|
|
price = new VIPPrice();
|
price.setActualPrice(new BigDecimal("77.8"));
|
price.setPrice(new BigDecimal("128.8"));
|
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");
|
OrderRecord record = new OrderRecord();
|
record.setMoney(price.getActualPrice());
|
record.setType(price.getType());
|
record.setUid(766693 + "");
|
|
try {
|
orderService.createOrder(record);
|
} catch (OrderException e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void listRecord() {
|
List<OrderRecord> list = orderService.listOrderRecord(null, null, null, 1, 10);
|
long count = orderService.countOrderRecord(null, null, null);
|
|
|
list = orderService.listOrderRecord(766693 + "", null, null, 1, 10);
|
count = orderService.countOrderRecord(766693 + "", null, null);
|
|
|
list = orderService.listOrderRecord(766693 + "", null, OrderRecord.STATE_NOT_PAY, 1, 10);
|
count = orderService.countOrderRecord(766693 + "", null, OrderRecord.STATE_NOT_PAY);
|
|
list = orderService.listOrderRecord(766693 + "", null, OrderRecord.STATE_PAY, 1, 10);
|
count = orderService.countOrderRecord(766693 + "", null, OrderRecord.STATE_PAY);
|
|
System.out.println(list);
|
}
|
|
@Test
|
public void paySuccess() {
|
// try {
|
// vipService.paySuccess("",OrderRecord.PAY_WAY_WX,new BigDecimal("14.8"),)
|
// } catch (Exception e) {
|
// e.printStackTrace();
|
// }
|
}
|
|
public static void main(String[] args) {
|
for (int i = 0; i < 10; i++) {
|
final int p = i;
|
new Thread(new Runnable() {
|
@Override
|
public void run() {
|
HttpUtil.get("http://192.168.3.122:8080/BuWan/test/vipPay?id=36");
|
System.out.println("执行完成:" + p);
|
}
|
}).start();
|
}
|
}
|
|
|
@Test
|
public void list() {
|
Boolean vip = true;
|
Date minDate = null;
|
Date maxDate = null;
|
if (vip != null) {
|
if (vip) {
|
minDate = new Date(System.currentTimeMillis() + 1000 * 60 * 5);
|
} else {
|
minDate = new Date(0L);
|
maxDate = new Date();
|
}
|
}
|
|
List<UserVIPInfo> list = vipService.listVIPUser(minDate, maxDate, 1, Constant.pageCount);
|
long count = vipService.countVIPUser(minDate, maxDate);
|
System.out.println(count);
|
}
|
|
|
@Test
|
public void test3() throws Exception {
|
OrderRecord record = orderService.getOrderRecord("1000592");
|
pptvVipManager.buyVIP(record);
|
}
|
|
@Test
|
public void cancelOrder() {
|
try {
|
orderJob.cancelOrder("1000140");
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void addBuyVideoRecord() {
|
VideoBuyRecord record = new VideoBuyRecord();
|
record.setId("123123");
|
record.setGoodsNo("123123123");
|
record.setStartTime(new Date());
|
record.setEndTime(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24L));
|
record.setLoginUid("766693");
|
record.setInfoId("381072");
|
record.setCid("32459137");
|
try {
|
videoBuyRecordService.addRecord(record);
|
} catch (ParamsException e) {
|
e.printStackTrace();
|
} catch (VideoBuyRecordException e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void buyVideo() {
|
try {
|
pptvVipManager.buyVideo(orderService.getOrderRecord("1000155"));
|
} catch (PPTVException e) {
|
e.printStackTrace();
|
} catch (OrderException e) {
|
e.printStackTrace();
|
} catch (VideoBuyRecordException e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void refoundWX() {
|
//退款
|
try {
|
Scanner scanner = new Scanner(new FileInputStream(new File("C:\\Users\\Administrator\\Desktop\\wx退款订单.txt")));
|
while (scanner.hasNextLine()) {
|
String st = scanner.nextLine();
|
String[] sts = st.split(" ");
|
String line = "";
|
line += "buwan_vip_" + sts[0] + ",";
|
line += sts[1] + ",";
|
line += "影视大全VIP权益终止退回,";
|
line += "buwan_vip_" + sts[0];
|
System.out.println(line);
|
}
|
|
scanner.close();
|
} catch (Exception e) {
|
|
}
|
|
|
}
|
|
@Test
|
public void refoundAlipay() {
|
//退款
|
try {
|
Scanner scanner = new Scanner(new FileInputStream(new File("C:\\Users\\Administrator\\Desktop\\退款\\alipay.txt")));
|
while (scanner.hasNextLine()) {
|
String st = scanner.nextLine();
|
String[] sts = st.split(" ");
|
String id = sts[0];
|
String money = sts[1];
|
String orderId = VIPOrderUtil.getOutOrderNo(OrderType.vip, id);
|
AlipayH5PayUtil.refund(VipUtil.getAlipayApp(), orderId, null, new BigDecimal(money), orderId);
|
}
|
|
scanner.close();
|
} catch (Exception e) {
|
|
}
|
|
|
}
|
|
//
|
|
}
|