| | |
| | | <spring.mongodb.version>1.10.10.RELEASE</spring.mongodb.version> |
| | | <solrj.version>5.5.5</solrj.version> |
| | | <logback.version>1.2.3</logback.version> |
| | | <dubbo.version>2.7.5</dubbo.version> |
| | | <curator.version>4.0.1</curator.version> |
| | | <zookeeper.version>3.4.6</zookeeper.version> |
| | | </properties> |
| | | |
| | | <dependencies> |
| | |
| | | <scope>system</scope> |
| | | <systemPath>${basedir}/libs/javax.servlet-api-3.1.0.jar</systemPath> |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>showapi</groupId> |
| | |
| | | <version>27.0.1-jre</version> |
| | | </dependency> |
| | | |
| | | <!-- dubbo --> |
| | | <dependency> |
| | | <groupId>org.apache.dubbo</groupId> |
| | | <artifactId>dubbo</artifactId> |
| | | <version>${dubbo.version}</version> |
| | | <!--<exclusions>--> |
| | | <!--<exclusion>--> |
| | | <!--<groupId>com.google.guava</groupId>--> |
| | | <!--<artifactId>guava</artifactId>--> |
| | | <!--</exclusion>--> |
| | | <!--</exclusions>--> |
| | | </dependency> |
| | | <!-- zookeeper --> |
| | | <dependency> |
| | | <groupId>org.apache.zookeeper</groupId> |
| | | <artifactId>zookeeper</artifactId> |
| | | <version>${zookeeper.version}</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-log4j12</artifactId> |
| | | </exclusion> |
| | | <exclusion> |
| | | <groupId>log4j</groupId> |
| | | <artifactId>log4j</artifactId> |
| | | </exclusion> |
| | | <exclusion> |
| | | <groupId>io.netty</groupId> |
| | | <artifactId>netty</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.curator</groupId> |
| | | <artifactId>curator-framework</artifactId> |
| | | <version>${curator.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.curator</groupId> |
| | | <artifactId>curator-recipes</artifactId> |
| | | <version>${curator.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.101tec</groupId> |
| | | <artifactId>zkclient</artifactId> |
| | | <version>0.10</version> |
| | | </dependency> |
| | | |
| | | |
| | | </dependencies> |
| | |
| | | import com.alipay.api.response.AlipayTradeQueryResponse; |
| | | import com.yeshi.buwan.domain.vip.VIPOrderRecord; |
| | | import com.yeshi.buwan.exception.vip.VIPException; |
| | | import com.yeshi.buwan.service.inter.order.OrderService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | import com.yeshi.buwan.util.RedisManager; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private VIPService vipService; |
| | | private OrderService orderService; |
| | | |
| | | @RequestMapping("printPayForm") |
| | | public void printPayForm(String formId, HttpServletResponse response) { |
| | |
| | | if ("TRADE_SUCCESS".equalsIgnoreCase(tradeStatus)) { |
| | | String id = VIPOrderUtil.getIdFromOutOrderNo(outTradeNo); |
| | | logger.info("订单ID:{}", id); |
| | | vipService.checkOrderPayState(id); |
| | | orderService.checkOrderPayState(id); |
| | | } |
| | | response.getWriter().print("success"); |
| | | response.getWriter().close(); |
| | |
| | | import com.yeshi.buwan.funtv.FunTVUtil; |
| | | import com.yeshi.buwan.service.imp.DetailSystemConfigService; |
| | | import com.yeshi.buwan.service.imp.SearchService; |
| | | import com.yeshi.buwan.service.inter.order.OrderService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | private VIPService vipService; |
| | | |
| | | @Resource |
| | | private OrderService orderService; |
| | | |
| | | @Resource |
| | | private SearchService searchService; |
| | | |
| | | Logger logger = LoggerFactory.getLogger(TestController.class); |
| | |
| | | |
| | | @RequestMapping("vipPay") |
| | | public void vipPay(String id) { |
| | | VIPOrderRecord record = vipService.getOrderRecord(id); |
| | | VIPOrderRecord record = orderService.getOrderRecord(id); |
| | | try { |
| | | vipService.paySuccess(record.getId(), VIPOrderRecord.PAY_WAY_ALIPAY, record.getMoney(), new Date()); |
| | | orderService.paySuccess(record.getId(), VIPOrderRecord.PAY_WAY_ALIPAY, record.getMoney(), new Date()); |
| | | } catch (VIPException e) { |
| | | e.printStackTrace(); |
| | | } catch (PPTVException e) { |
| | |
| | | package com.yeshi.buwan.controller; |
| | | |
| | | import com.yeshi.buwan.service.inter.order.OrderService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.log.LoggerUtil; |
| | |
| | | Logger logger = LoggerFactory.getLogger(WXController.class); |
| | | |
| | | @Resource |
| | | private VIPService vipService; |
| | | private OrderService orderService; |
| | | |
| | | private static String decryptToString(String apiV3Key, String associatedData, String nonce, String ciphertext) |
| | | throws GeneralSecurityException, IOException { |
| | |
| | | //支付成功 |
| | | if (tradeState.equalsIgnoreCase("SUCCESS")) { |
| | | String id = VIPOrderUtil.getIdFromOutOrderNo(outTradeNo); |
| | | vipService.checkOrderPayState(id); |
| | | orderService.checkOrderPayState(id); |
| | | } |
| | | break; |
| | | } |
| | |
| | | import com.yeshi.buwan.domain.vip.UserVIPInfo; |
| | | import com.yeshi.buwan.domain.vip.VIPOrderRecord; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | | import com.yeshi.buwan.service.inter.order.OrderService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | import com.yeshi.buwan.util.Constant; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | |
| | | |
| | | @Resource |
| | | private VIPService vipService; |
| | | |
| | | @Resource |
| | | private OrderService orderService; |
| | | |
| | | @Resource |
| | | private LoginUserService loginUserService; |
| | |
| | | } |
| | | } |
| | | |
| | | List<VIPOrderRecord> list = vipService.listOrderRecord(uid, state, page, Constant.pageCount); |
| | | long count = vipService.countOrderRecord(uid, state); |
| | | List<VIPOrderRecord> list = orderService.listOrderRecord(uid, state, page, Constant.pageCount); |
| | | long count = orderService.countOrderRecord(uid, state); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pageEntity", new PageEntity(page, Constant.pageCount, (int) count)); |
| | | data.put("list", getGson().toJson(list)); |
| | |
| | | import com.google.gson.*; |
| | | import com.yeshi.buwan.domain.system.SystemConfig; |
| | | import com.yeshi.buwan.domain.user.LoginUser; |
| | | import com.yeshi.buwan.domain.vip.UserVIPInfo; |
| | | 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.domain.vip.*; |
| | | import com.yeshi.buwan.exception.goldcorn.GoldCornException; |
| | | import com.yeshi.buwan.exception.order.OrderException; |
| | | import com.yeshi.buwan.exception.order.PayException; |
| | | import com.yeshi.buwan.exception.vip.VIPException; |
| | | import com.yeshi.buwan.pptv.entity.VideoPPTVMap; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | | import com.yeshi.buwan.service.inter.juhe.PPTVService; |
| | | import com.yeshi.buwan.service.inter.order.OrderService; |
| | | import com.yeshi.buwan.service.inter.system.SystemConfigService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPPriceService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | |
| | | private VIPService vipService; |
| | | |
| | | @Resource |
| | | private OrderService orderService; |
| | | |
| | | @Resource |
| | | private LoginUserService loginUserService; |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private PPTVService pptvService; |
| | | |
| | | |
| | | @RequestMapping("getVIPPriceList") |
| | |
| | | }).create(); |
| | | JSONObject root = new JSONObject(); |
| | | |
| | | List<VIPOrderRecord> list = vipService.listOrderRecord(loginUid, null, page, Constant.pageCount); |
| | | List<VIPOrderRecord> list = orderService.listOrderRecord(loginUid, null, page, Constant.pageCount); |
| | | for (VIPOrderRecord record : list) { |
| | | record.setIpInfo(null); |
| | | record.setUpdateTime(null); |
| | | } |
| | | long count = vipService.countOrderRecord(loginUid, null); |
| | | long count = orderService.countOrderRecord(loginUid, null); |
| | | root.put("list", gson.toJson(list)); |
| | | root.put("count", count); |
| | | return JsonUtilV2.loadTrueJson(root.toString()); |
| | |
| | | */ |
| | | @RequestMapping("createOrder") |
| | | @ResponseBody |
| | | public String createOrder(AcceptData acceptData, HttpServletRequest request, String loginUid, String priceId, int payWay) { |
| | | public String createOrder(AcceptData acceptData, HttpServletRequest request, String loginUid, String priceId, String infoId, Integer goldCorn, int payWay) { |
| | | |
| | | if (StringUtil.isNullOrEmpty(loginUid)) { |
| | | return JsonUtilV2.loadFalseJson("用户未登录"); |
| | |
| | | return JsonUtilV2.loadFalseJson(10001, "请绑定电话号码"); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(priceId) && StringUtil.isNullOrEmpty(infoId)) { |
| | | return JsonUtilV2.loadFalseJson("请选择购买类型"); |
| | | } |
| | | |
| | | OrderType orderType = OrderType.vip; |
| | | |
| | | if (!StringUtil.isNullOrEmpty(infoId)) { |
| | | orderType = OrderType.video; |
| | | } |
| | | |
| | | |
| | | String ip = IPUtil.getRemotIP(request); |
| | | VIPPrice vipPrice = vipPriceService.selectByPrimaryKey(priceId); |
| | | if (vipPrice == null) { |
| | | return JsonUtilV2.loadFalseJson("套餐不存在"); |
| | | |
| | | VIPPrice vipPrice = null; |
| | | if (orderType == OrderType.video) { |
| | | //视频 |
| | | VideoPPTVMap map = pptvService.selectVideoPPTVMapByInfoId(infoId); |
| | | if (map == null) { |
| | | return JsonUtilV2.loadFalseJson("影片不存在"); |
| | | } |
| | | } else { |
| | | vipPrice = vipPriceService.selectByPrimaryKey(priceId); |
| | | if (vipPrice == null) { |
| | | return JsonUtilV2.loadFalseJson("套餐不存在"); |
| | | } |
| | | } |
| | | |
| | | VIPOrderRecord record = new VIPOrderRecord(); |
| | | record.setUid(loginUid); |
| | | record.setType(vipPrice.getType()); |
| | | if (vipPrice != null) |
| | | record.setType(vipPrice.getType()); |
| | | |
| | | record.setOrderType(orderType); |
| | | record.setVideoInfoId(infoId); |
| | | record.setGoldCorn(goldCorn); |
| | | record.setMoney(vipPrice.getActualPrice()); |
| | | record.setPayWay(payWay); |
| | | record.setState(VIPOrderRecord.STATE_NOT_PAY); |
| | | record.setIpInfo(IPUtil.getRemotIP(request) + ":" + IPUtil.getRemotePort(request)); |
| | | try { |
| | | vipService.addVIPRecord(record); |
| | | } catch (VIPException e) { |
| | | orderService.createOrder(record); |
| | | } catch (OrderException e) { |
| | | logger.error("生成订单出错", e); |
| | | return JsonUtilV2.loadFalseJson("生成订单出错"); |
| | | } |
| | | |
| | | String orderNo = VIPOrderUtil.getOutOrderNo(record.getId()); |
| | | |
| | | try { |
| | | orderService.payOrder(record); |
| | | } catch (OrderException e) { |
| | | e.printStackTrace(); |
| | | } catch (GoldCornException e) { |
| | | e.printStackTrace(); |
| | | } catch (PayException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | String orderNo = VIPOrderUtil.getOutOrderNo(record.getOrderType(), record.getId()); |
| | | switch (payWay) { |
| | | case VIPOrderRecord |
| | | .PAY_WAY_ALIPAY: { |
| | |
| | | @ResponseBody |
| | | @RequestSerializableByKey(key = "'vip-checkPay-'+#id") |
| | | public String checkPay(AcceptData acceptData, String loginUid, String id) { |
| | | VIPOrderRecord record = vipService.getOrderRecord(id); |
| | | VIPOrderRecord record = orderService.getOrderRecord(id); |
| | | if (record == null || !record.getUid().equalsIgnoreCase(loginUid)) { |
| | | return JsonUtilV2.loadFalseJson("记录不存在/不是您的订单"); |
| | | } |
| | | |
| | | record = vipService.checkOrderPayState(id); |
| | | record = orderService.checkOrderPayState(id); |
| | | //未支付 |
| | | if (record != null && record.getState() != VIPOrderRecord.STATE_PAY) { |
| | | return JsonUtilV2.loadFalseJson(1, "支付未完成"); |
| | |
| | | package com.yeshi.buwan.dao.vip; |
| | | |
| | | import com.yeshi.buwan.dao.base.BaseDao; |
| | | import com.yeshi.buwan.domain.vip.OrderType; |
| | | import com.yeshi.buwan.domain.vip.VIPOrderRecord; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | |
| | | hql += " and r.uid=" + daoQuery.uid; |
| | | } |
| | | |
| | | if (daoQuery.orderType != null) { |
| | | hql += " and r.orderType=" + daoQuery.orderType; |
| | | } |
| | | |
| | | hql += " order by r.createTime desc"; |
| | | return hql; |
| | | } |
| | |
| | | |
| | | |
| | | public long count(DaoQuery daoQuery) { |
| | | return super.getCount(getHql(daoQuery),null); |
| | | return super.getCount(getHql(daoQuery), null); |
| | | } |
| | | |
| | | public static class DaoQuery { |
| | | public Integer state; |
| | | public OrderType orderType; |
| | | public String uid; |
| | | public int start; |
| | | public int count; |
New file |
| | |
| | | package com.yeshi.buwan.domain.vip; |
| | | |
| | | public enum OrderType { |
| | | |
| | | //VIP |
| | | vip, |
| | | //单片 |
| | | video; |
| | | |
| | | } |
| | |
| | | //已支付 |
| | | public final static int STATE_PAY = 1; |
| | | |
| | | //订单已取消 |
| | | public final static int STATE_CANCEL = -1; |
| | | |
| | | //支付宝 |
| | | public final static int PAY_WAY_ALIPAY = 1; |
| | |
| | | //微信 |
| | | public final static int PAY_WAY_WX = 2; |
| | | |
| | | //影视豆支付 |
| | | public final static int PAY_WAY_GOLDCORN = 3; |
| | | |
| | | //支付宝+影视豆 |
| | | public final static int PAY_WAY_ALIPAY_GOLDCORN = 13; |
| | | |
| | | //微信+影视豆 |
| | | public final static int PAY_WAY_WX_GOLDCORN = 23; |
| | | |
| | | //订单类型 |
| | | private OrderType orderType; |
| | | |
| | | private String id; |
| | | //用户ID |
| | | private String uid; |
| | | //状态 |
| | | private Integer state; |
| | | |
| | | //资金支付状态 |
| | | private Boolean moneyPay; |
| | | |
| | | //资金支付状态 |
| | | private Boolean goldCornPay; |
| | | |
| | | //影视豆 |
| | | private Integer goldCorn; |
| | | |
| | | //单片ID |
| | | private String videoInfoId; |
| | | |
| | | //类型 |
| | | private VIPPriceType type; |
| | | |
| | | //资金 |
| | | private BigDecimal money; |
| | | //支付方式 |
| | |
| | | private Date payTime; |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | |
| | | //会员开始时间 |
| | | private Date vipStartTime; |
| | | //会员结束时间 |
| | | private Date vipEndTime; |
| | | |
| | | //备注 |
| | | private String remarks; |
| | | |
| | | |
| | | public Boolean getMoneyPay() { |
| | | return moneyPay; |
| | | } |
| | | |
| | | public void setMoneyPay(Boolean moneyPay) { |
| | | this.moneyPay = moneyPay; |
| | | } |
| | | |
| | | public Boolean getGoldCornPay() { |
| | | return goldCornPay; |
| | | } |
| | | |
| | | public void setGoldCornPay(Boolean goldCornPay) { |
| | | this.goldCornPay = goldCornPay; |
| | | } |
| | | |
| | | public Date getVipStartTime() { |
| | | return vipStartTime; |
| | |
| | | public void setIpInfo(String ipInfo) { |
| | | this.ipInfo = ipInfo; |
| | | } |
| | | |
| | | public Integer getGoldCorn() { |
| | | return goldCorn; |
| | | } |
| | | |
| | | public void setGoldCorn(Integer goldCorn) { |
| | | this.goldCorn = goldCorn; |
| | | } |
| | | |
| | | public String getVideoInfoId() { |
| | | return videoInfoId; |
| | | } |
| | | |
| | | public void setVideoInfoId(String videoInfoId) { |
| | | this.videoInfoId = videoInfoId; |
| | | } |
| | | |
| | | |
| | | public OrderType getOrderType() { |
| | | return orderType; |
| | | } |
| | | |
| | | public void setOrderType(OrderType orderType) { |
| | | this.orderType = orderType; |
| | | } |
| | | |
| | | public String getRemarks() { |
| | | return remarks; |
| | | } |
| | | |
| | | public void setRemarks(String remarks) { |
| | | this.remarks = remarks; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.dto.order; |
| | | |
| | | public class PayWayInfoDTO { |
| | | private int payWay; |
| | | private String payUrl; |
| | | |
| | | public PayWayInfoDTO(int payWay, String payUrl) { |
| | | this.payWay = payWay; |
| | | this.payUrl = payUrl; |
| | | } |
| | | |
| | | public int getPayWay() { |
| | | return payWay; |
| | | } |
| | | |
| | | public void setPayWay(int payWay) { |
| | | this.payWay = payWay; |
| | | } |
| | | |
| | | public String getPayUrl() { |
| | | return payUrl; |
| | | } |
| | | |
| | | public void setPayUrl(String payUrl) { |
| | | this.payUrl = payUrl; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.exception.goldcorn; |
| | | |
| | | public class GoldCornException extends Exception { |
| | | |
| | | private int code; |
| | | private String msg; |
| | | |
| | | public GoldCornException(int code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.exception.order; |
| | | |
| | | public class OrderException extends Exception { |
| | | |
| | | private int code; |
| | | private String msg; |
| | | |
| | | public OrderException(int code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.exception.order; |
| | | |
| | | public class PayException extends Exception { |
| | | |
| | | private int code; |
| | | private String msg; |
| | | |
| | | public PayException(int code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.yeshi.buwan.pptv; |
| | | |
| | | import com.yeshi.buwan.domain.user.LoginUserExtra; |
| | | import com.yeshi.buwan.domain.vip.OrderType; |
| | | import com.yeshi.buwan.domain.vip.VIPOrderRecord; |
| | | import com.yeshi.buwan.domain.vip.VIPPrice; |
| | | import com.yeshi.buwan.exception.PPTVException; |
| | | import com.yeshi.buwan.exception.vip.VIPException; |
| | | import com.yeshi.buwan.pptv.entity.PPTVSeries; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | | import com.yeshi.buwan.service.inter.juhe.PPTVService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPPriceService; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | @Resource |
| | | private LoginUserService loginUserService; |
| | | |
| | | @Resource |
| | | private PPTVService pptvService; |
| | | |
| | | /** |
| | | * 购买VIP |
| | | * |
| | |
| | | public void buyVIP(VIPOrderRecord record) throws PPTVException, VIPException { |
| | | if (record.getState() != VIPOrderRecord.STATE_PAY) { |
| | | throw new VIPException(11, "尚未支付成功"); |
| | | } |
| | | |
| | | if (record.getOrderType() != OrderType.vip) { |
| | | throw new VIPException(41, "不是VIP订单"); |
| | | } |
| | | VIPPrice price = vipPriceService.selectByType(record.getType()); |
| | | if (price == null) { |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 购买单片 |
| | | * |
| | | * @param record |
| | | * @throws PPTVException |
| | | * @throws VIPException |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void buyVideo(VIPOrderRecord record) throws PPTVException, VIPException { |
| | | if (record.getState() != VIPOrderRecord.STATE_PAY) { |
| | | throw new VIPException(11, "尚未支付成功"); |
| | | } |
| | | |
| | | if (record.getOrderType() != OrderType.video) { |
| | | throw new VIPException(41, "不是单片订单"); |
| | | } |
| | | |
| | | PPTVSeries pptvSeries = pptvService.getSeriesDetail(record.getVideoInfoId()); |
| | | if (pptvSeries == null) { |
| | | throw new VIPException(41, "影片信息获取失败"); |
| | | } |
| | | |
| | | if (pptvSeries.getGoodsInfo() == null || StringUtil.isNullOrEmpty(pptvSeries.getGoodsInfo().getGoodsNo())) { |
| | | throw new VIPException(41, "影片商品信息为空"); |
| | | } |
| | | |
| | | |
| | | LoginUserExtra extra = loginUserService.getExtra(record.getUid()); |
| | | if (extra == null) { |
| | | throw new VIPException(13, "用户信息获取失败"); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(extra.getPptvUid())) { |
| | | throw new VIPException(14, "pptvuid获取失败"); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(extra.getPptvOpenId())) { |
| | | loginUserService.updatePPTVOpenId(record.getUid()); |
| | | } |
| | | |
| | | boolean success = PPTVApiUtil.buyGoods(extra.getPptvOpenId(), "buwan_" + record.getId(), pptvSeries.getGoodsInfo().getGoodsNo(), record.getPayTime()); |
| | | if (!success) { |
| | | throw new VIPException(21, "PPTV会员购买失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.service.imp.order; |
| | | |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.response.AlipayTradeQueryResponse; |
| | | import com.yeshi.buwan.dao.vip.VIPOrderRecordDao; |
| | | import com.yeshi.buwan.domain.vip.OrderType; |
| | | import com.yeshi.buwan.domain.vip.UserVIPInfo; |
| | | import com.yeshi.buwan.domain.vip.VIPOrderRecord; |
| | | import com.yeshi.buwan.domain.vip.VIPPriceType; |
| | | import com.yeshi.buwan.dto.order.PayWayInfoDTO; |
| | | import com.yeshi.buwan.exception.PPTVException; |
| | | import com.yeshi.buwan.exception.goldcorn.GoldCornException; |
| | | import com.yeshi.buwan.exception.order.OrderException; |
| | | import com.yeshi.buwan.exception.order.PayException; |
| | | import com.yeshi.buwan.exception.vip.VIPException; |
| | | import com.yeshi.buwan.pptv.PPTVVipManager; |
| | | import com.yeshi.buwan.service.inter.order.OrderService; |
| | | import com.yeshi.buwan.util.Constant; |
| | | import com.yeshi.buwan.util.RedisManager; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.user.VipUtil; |
| | | import com.yeshi.buwan.util.vip.VIPOrderUtil; |
| | | import org.hibernate.Query; |
| | | import org.hibernate.Session; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.yeshi.utils.alipay.AlipayH5PayUtil; |
| | | import org.yeshi.utils.entity.wx.WXPayOrderInfoV3; |
| | | import org.yeshi.utils.wx.WXPayV3Util; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | @Service |
| | | public class OrderServiceImpl implements OrderService { |
| | | |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger("OrderService"); |
| | | |
| | | private static Logger orderLogger = LoggerFactory.getLogger("order"); |
| | | |
| | | @Resource |
| | | private VIPOrderRecordDao vipOrderRecordDao; |
| | | |
| | | @Resource |
| | | private PPTVVipManager pptvVipManager; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public VIPOrderRecord createOrder(VIPOrderRecord record) throws OrderException { |
| | | if (record.getMoney() == null || record.getType() == null || record.getOrderType() == null || record.getUid() == null) { |
| | | throw new OrderException(1, "参数不完整"); |
| | | } |
| | | |
| | | if (record.getState() == null) { |
| | | record.setState(VIPOrderRecord.STATE_NOT_PAY); |
| | | } |
| | | |
| | | if (record.getCreateTime() == null) { |
| | | record.setCreateTime(new Date()); |
| | | } |
| | | |
| | | record.setMoneyPay(false); |
| | | record.setGoldCornPay(false); |
| | | Serializable id = vipOrderRecordDao.save(record); |
| | | record.setId(id.toString()); |
| | | orderLogger.info("订单创建成功:id-{} 类型-{}", record.getId(), record.getOrderType().name()); |
| | | return record; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public PayWayInfoDTO payOrder(VIPOrderRecord record) throws OrderException, GoldCornException, PayException { |
| | | //TODO 影视豆支付 |
| | | String orderNo = VIPOrderUtil.getOutOrderNo(record.getOrderType(), record.getId()); |
| | | switch (record.getPayWay()) { |
| | | case VIPOrderRecord |
| | | .PAY_WAY_ALIPAY_GOLDCORN: |
| | | //TODO 扣影视豆 |
| | | orderLogger.info("订单影视豆支付成功:id-{}", record.getId()); |
| | | case VIPOrderRecord |
| | | .PAY_WAY_ALIPAY: { |
| | | //生成支付宝支付订单 |
| | | String form = VipUtil.getVipChargeAlipayForm(record.getId(), orderNo, record.getMoney()); |
| | | //暂存2分钟 |
| | | String id = StringUtil.Md5(UUID.randomUUID().toString() + "#" + System.currentTimeMillis()); |
| | | redisManager.cacheCommonString(id, form, 120); |
| | | String payUrl = Constant.HOST + "/BuWan/alipay/printPayForm?formId=" + id; |
| | | orderLogger.info("订单创建支付宝支付链接成功:id-{} 链接-{}", record.getId(), payUrl); |
| | | return new PayWayInfoDTO(VIPOrderRecord |
| | | .PAY_WAY_ALIPAY, payUrl); |
| | | } |
| | | case VIPOrderRecord |
| | | .PAY_WAY_WX_GOLDCORN: |
| | | //TODO 扣影视豆 |
| | | orderLogger.info("订单影视豆支付成功:id-{} 类型-{}", record.getId(), record.getOrderType().name()); |
| | | case VIPOrderRecord |
| | | .PAY_WAY_WX: { |
| | | //生成微信支付订单 |
| | | try { |
| | | String title = ""; |
| | | if (record.getOrderType() == OrderType.vip) { |
| | | title = "影视大全VIP-" + record.getType().getName(); |
| | | } else { |
| | | title = "单片购买"; |
| | | } |
| | | String payUrl = VipUtil.createWXOrder(record.getId(), record.getIpInfo(), orderNo, record.getMoney(), title); |
| | | orderLogger.info("订单创建微信支付链接成功:id-{} 链接-{}", record.getId(), payUrl); |
| | | return new PayWayInfoDTO(VIPOrderRecord.PAY_WAY_WX, payUrl); |
| | | } catch (Exception e) { |
| | | logger.error("生成微信支付订单出错", e); |
| | | throw new PayException(2, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | case VIPOrderRecord.PAY_WAY_GOLDCORN: { |
| | | //TODO 扣影视豆 |
| | | orderLogger.info("订单影视豆支付成功:id-{}", record.getId()); |
| | | } |
| | | break; |
| | | } |
| | | throw new OrderException(1, "支付方式不存在"); |
| | | } |
| | | |
| | | private int getPayState(VIPOrderRecord record) { |
| | | switch (record.getPayWay()) { |
| | | case VIPOrderRecord.PAY_WAY_ALIPAY: |
| | | case VIPOrderRecord.PAY_WAY_WX: |
| | | if (record.getMoneyPay() != null && record.getMoneyPay()) |
| | | return VIPOrderRecord.STATE_PAY; |
| | | else |
| | | return VIPOrderRecord.STATE_NOT_PAY; |
| | | case VIPOrderRecord.PAY_WAY_ALIPAY_GOLDCORN: |
| | | case VIPOrderRecord.PAY_WAY_WX_GOLDCORN: |
| | | if (record.getMoneyPay() != null && record.getMoneyPay() && record.getGoldCornPay() != null && record.getGoldCornPay()) |
| | | return VIPOrderRecord.STATE_PAY; |
| | | else |
| | | return VIPOrderRecord.STATE_NOT_PAY; |
| | | case VIPOrderRecord.PAY_WAY_GOLDCORN: |
| | | if (record.getGoldCornPay() != null && record.getGoldCornPay()) |
| | | return VIPOrderRecord.STATE_PAY; |
| | | else |
| | | return VIPOrderRecord.STATE_NOT_PAY; |
| | | } |
| | | return VIPOrderRecord.STATE_NOT_PAY; |
| | | } |
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public VIPOrderRecord paySuccess(String id, int payWay, BigDecimal payMoney, Date payTime) throws |
| | | VIPException, PPTVException { |
| | | orderLogger.info("订单支付成功目的执行:id-{},支付方式-{},支付金额-{},支付时间-{}", id, payWay, payMoney, payTime.getTime()); |
| | | |
| | | Session session = vipOrderRecordDao.getSession(); |
| | | |
| | | //修改记录 |
| | | Query query = session.createSQLQuery("select * from wk_vip_order_record r where r.id=? for update").addEntity(VIPOrderRecord.class).setCacheable(false).setParameter(0, id); |
| | | List<VIPOrderRecord> list = query.list(); |
| | | |
| | | if (list != null && list.size() > 0) { |
| | | VIPOrderRecord record = list.get(0); |
| | | if (record.getState() != VIPOrderRecord.STATE_NOT_PAY) |
| | | throw new VIPException(1, "订单未处于待支付状态"); |
| | | |
| | | |
| | | if (record.getPayWay() != VIPOrderRecord.PAY_WAY_GOLDCORN) { |
| | | record.setPayMoney(payMoney); |
| | | record.setMoneyPay(true); |
| | | } else { |
| | | record.setGoldCornPay(true); |
| | | } |
| | | |
| | | record.setPayTime(payTime); |
| | | record.setUpdateTime(new Date()); |
| | | record.setState(getPayState(record)); |
| | | |
| | | //已经支付成功 |
| | | if (record.getState() == VIPOrderRecord.STATE_PAY) { |
| | | session.createSQLQuery("insert into wk_vip_order_pay_success(id,create_time) value(?,now())").setParameter(0, id).executeUpdate(); |
| | | |
| | | } |
| | | |
| | | if (record.getOrderType() == OrderType.vip) { |
| | | Date[] expireDate = addExpireTime(session, record.getUid(), payTime, record.getType()); |
| | | record.setVipStartTime(expireDate[0]); |
| | | record.setVipEndTime(expireDate[1]); |
| | | if (expireDate == null) { |
| | | throw new VIPException(2, "添加用户会员时间出错"); |
| | | } |
| | | session.update(record); |
| | | |
| | | |
| | | if (record.getState() == VIPOrderRecord.STATE_PAY) { |
| | | orderLogger.info("订单全部支付成功:id-{}", id); |
| | | //购买VIP |
| | | pptvVipManager.buyVIP(record); |
| | | orderLogger.info("购买VIP成功:id-{}", id); |
| | | } else { |
| | | orderLogger.info("订单部分支付成功:id-{}", id); |
| | | } |
| | | |
| | | } else if (record.getOrderType() == OrderType.video) { |
| | | record.setVipStartTime(payTime); |
| | | //7天之内有效 |
| | | record.setVipEndTime(new Date(payTime.getTime() + 1000 * 60 * 60L * 24 * 7)); |
| | | session.update(record); |
| | | //单片购买成功(7天有效期) |
| | | if (record.getState() == VIPOrderRecord.STATE_PAY) { |
| | | orderLogger.info("订单全部支付成功:id-{}", id); |
| | | //购买单片 |
| | | pptvVipManager.buyVideo(record); |
| | | orderLogger.info("购买单片成功:id-{}", id); |
| | | } else { |
| | | orderLogger.info("订单部分支付成功:id-{}", id); |
| | | } |
| | | } |
| | | |
| | | return record; |
| | | } else { |
| | | throw new VIPException(10, "订单不存在"); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void cancelOrder(String id, String reason) throws OrderException { |
| | | |
| | | Session session = vipOrderRecordDao.getSession(); |
| | | Query query = session.createSQLQuery("select * from wk_vip_order_record r where r.id=? for update").addEntity(VIPOrderRecord.class).setCacheable(false).setParameter(0, id); |
| | | List<VIPOrderRecord> list = query.list(); |
| | | //订单不存在 |
| | | if (list == null || list.size() == 0) |
| | | throw new OrderException(1, "订单不存在"); |
| | | VIPOrderRecord record = list.get(0); |
| | | if (record.getState() == VIPOrderRecord.STATE_PAY) { |
| | | throw new OrderException(1, "已支付成功的订单不能取消"); |
| | | } |
| | | |
| | | if (record.getPayWay() != VIPOrderRecord.PAY_WAY_GOLDCORN && record.getMoneyPay() != null && record.getMoneyPay()) { |
| | | throw new OrderException(2, "资金支付成功的订单不能取消"); |
| | | } |
| | | |
| | | //返回豆 |
| | | if (record.getGoldCornPay() != null && record.getGoldCornPay() && record.getGoldCorn() != null && record.getGoldCorn() > 0) { |
| | | //TODO 退回影视豆 |
| | | |
| | | |
| | | } |
| | | |
| | | //设置订单状态 |
| | | record.setState(VIPOrderRecord.STATE_CANCEL); |
| | | record.setUpdateTime(new Date()); |
| | | record.setRemarks(reason); |
| | | vipOrderRecordDao.update(record); |
| | | orderLogger.info("取消订单成功:id-{}", id); |
| | | } |
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public VIPOrderRecord checkOrderPayState(String id) { |
| | | VIPOrderRecord record = vipOrderRecordDao.find(VIPOrderRecord.class, id); |
| | | if (record.getState() == VIPOrderRecord.STATE_PAY) |
| | | return record; |
| | | |
| | | switch (record.getPayWay()) { |
| | | case VIPOrderRecord.PAY_WAY_ALIPAY: { |
| | | //支付宝 |
| | | AlipayTradeQueryResponse res = null; |
| | | try { |
| | | res = AlipayH5PayUtil.queryOrder(VipUtil.getAlipayApp(), VIPOrderUtil.getOutOrderNo(record.getOrderType(), id), null); |
| | | //支付成功 |
| | | if (res.isSuccess() && "TRADE_SUCCESS".equalsIgnoreCase(res.getTradeStatus())) { |
| | | try { |
| | | return paySuccess(id, VIPOrderRecord.PAY_WAY_ALIPAY, new BigDecimal(res.getTotalAmount()), new Date()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } catch (AlipayApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | break; |
| | | case VIPOrderRecord.PAY_WAY_WX: { |
| | | //微信 |
| | | try { |
| | | WXPayOrderInfoV3 info = WXPayV3Util.getPayOrderInfo(VIPOrderUtil.getOutOrderNo(record.getOrderType(), id), VipUtil.getWXAPP()); |
| | | if (info != null && info.getTrade_state().equalsIgnoreCase("SUCCESS")) { |
| | | paySuccess(id, record.getPayWay(), new BigDecimal(info.getAmount().getPayer_total()).divide(new BigDecimal(100), 2, RoundingMode.FLOOR), new Date()); |
| | | return record; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | return record; |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<VIPOrderRecord> listOrderRecord(String uid, Integer state, int page, int pageSize) { |
| | | |
| | | VIPOrderRecordDao.DaoQuery query = new VIPOrderRecordDao.DaoQuery(); |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | query.uid = uid; |
| | | query.state = state; |
| | | |
| | | return vipOrderRecordDao.list(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countOrderRecord(String uid, Integer state) { |
| | | VIPOrderRecordDao.DaoQuery query = new VIPOrderRecordDao.DaoQuery(); |
| | | query.uid = uid; |
| | | query.state = state; |
| | | return vipOrderRecordDao.count(query); |
| | | } |
| | | |
| | | @Override |
| | | public VIPOrderRecord getOrderRecord(String id) { |
| | | return vipOrderRecordDao.find(VIPOrderRecord.class, id); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 续期 |
| | | * |
| | | * @param session |
| | | * @param uid |
| | | * @param payTime |
| | | * @param type |
| | | * @return |
| | | */ |
| | | private Date[] addExpireTime(Session session, String uid, Date payTime, VIPPriceType type) { |
| | | if (type == null || uid == null) |
| | | return null; |
| | | List list = session.createSQLQuery("select * from wk_user_vip i where i.uid=? for update").addEntity(UserVIPInfo.class).setParameter(0, uid).list(); |
| | | if (list == null || list.size() == 0) { |
| | | //新增 |
| | | UserVIPInfo vip = new UserVIPInfo(); |
| | | vip.setUid(uid); |
| | | vip.setCreateTime(new Date()); |
| | | vip.setExpireDate(getExpireTime(payTime, null, type)); |
| | | session.save(vip); |
| | | return new Date[]{payTime, vip.getExpireDate()}; |
| | | } else { |
| | | //修改 |
| | | UserVIPInfo vipInfo = (UserVIPInfo) list.get(0); |
| | | Date expireDate = getExpireTime(payTime, vipInfo.getExpireDate(), type); |
| | | session.createQuery("update UserVIPInfo i set i.expireDate=? ,i.updateTime=? where i.uid=?").setParameter(0, expireDate).setParameter(1, new Date()).setParameter(2, uid).executeUpdate(); |
| | | |
| | | return new Date[]{vipInfo.getExpireDate() == null ? new Date() : vipInfo.getExpireDate(), expireDate}; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取到期时间 |
| | | * |
| | | * @param payTime |
| | | * @param expireTime |
| | | * @param type |
| | | * @return |
| | | */ |
| | | private Date getExpireTime(Date payTime, Date expireTime, VIPPriceType type) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | if (expireTime != null) { |
| | | calendar.setTimeInMillis(expireTime.getTime()); |
| | | } else { |
| | | calendar.setTimeInMillis(payTime.getTime()); |
| | | } |
| | | if (type == VIPPriceType.day) { |
| | | calendar.add(Calendar.DAY_OF_WEEK, 1); |
| | | } else if (type == VIPPriceType.week) { |
| | | calendar.add(Calendar.WEEK_OF_YEAR, 1); |
| | | } else if (type == VIPPriceType.month) { |
| | | calendar.add(Calendar.MONTH, 1); |
| | | } else if (type == VIPPriceType.season) { |
| | | calendar.add(Calendar.MONTH, 3); |
| | | } else if (type == VIPPriceType.halfYear) { |
| | | calendar.add(Calendar.MONTH, 6); |
| | | } else if (type == VIPPriceType.year) { |
| | | calendar.add(Calendar.YEAR, 1); |
| | | } |
| | | return new Date(calendar.getTimeInMillis()); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.yeshi.buwan.service.imp.vip; |
| | | |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.response.AlipayTradeQueryResponse; |
| | | import com.yeshi.buwan.dao.vip.UserVIPInfoDao; |
| | | import com.yeshi.buwan.dao.vip.VIPOrderRecordDao; |
| | | import com.yeshi.buwan.domain.vip.UserVIPInfo; |
| | | import com.yeshi.buwan.domain.vip.VIPOrderRecord; |
| | | import com.yeshi.buwan.domain.vip.VIPPriceType; |
| | | import com.yeshi.buwan.exception.PPTVException; |
| | | import com.yeshi.buwan.exception.vip.VIPException; |
| | | import com.yeshi.buwan.pptv.PPTVVipManager; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | import com.yeshi.buwan.util.log.LoggerUtil; |
| | | import com.yeshi.buwan.util.user.VipUtil; |
| | | import com.yeshi.buwan.util.vip.VIPOrderUtil; |
| | | import org.hibernate.Query; |
| | | import org.hibernate.Session; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.yeshi.utils.alipay.AlipayH5PayUtil; |
| | | import org.yeshi.utils.entity.wx.WXPayOrderInfoV3; |
| | | import org.yeshi.utils.wx.WXPayV3Util; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | Logger logger = LoggerFactory.getLogger(VIPServiceImpl.class); |
| | | |
| | | @Resource |
| | | private VIPOrderRecordDao vipOrderRecordDao; |
| | | |
| | | @Resource |
| | | private UserVIPInfoDao userVIPInfoDao; |
| | | |
| | | @Resource |
| | | private PPTVVipManager pptvVipManager; |
| | | |
| | | |
| | | /** |
| | | * VIP购买记录 |
| | | * |
| | | * @param record |
| | | * @throws VIPException |
| | | */ |
| | | @Override |
| | | public void addVIPRecord(VIPOrderRecord record) throws VIPException { |
| | | if (record.getMoney() == null || record.getType() == null || record.getUid() == null) { |
| | | throw new VIPException(1, "参数不完整"); |
| | | } |
| | | |
| | | if (record.getState() == null) { |
| | | record.setState(VIPOrderRecord.STATE_NOT_PAY); |
| | | } |
| | | |
| | | if (record.getCreateTime() == null) { |
| | | record.setCreateTime(new Date()); |
| | | } |
| | | Serializable id = vipOrderRecordDao.save(record); |
| | | record.setId(id.toString()); |
| | | } |
| | | |
| | | /** |
| | | * 支付成功 |
| | | * |
| | | * @param id |
| | | * @param payWay |
| | | * @param payMoney |
| | | * @param payTime |
| | | * @throws VIPException |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public VIPOrderRecord paySuccess(final String id, int payWay, BigDecimal payMoney, Date payTime) throws VIPException, PPTVException { |
| | | LoggerUtil.getTestLogger().info("支付成功:开始执行{}", id); |
| | | |
| | | Session session = vipOrderRecordDao.getSession(); |
| | | |
| | | //修改记录 |
| | | Query query = session.createSQLQuery("select * from wk_vip_order_record r where r.id=? for update").addEntity(VIPOrderRecord.class).setCacheable(false).setParameter(0, id); |
| | | List<VIPOrderRecord> list = query.list(); |
| | | |
| | | if (list != null && list.size() > 0) { |
| | | VIPOrderRecord record = list.get(0); |
| | | if (record.getState() == VIPOrderRecord.STATE_PAY) |
| | | throw new VIPException(1, "订单已经支付"); |
| | | |
| | | session.createSQLQuery("insert into wk_vip_order_pay_success(id,create_time) value(?,now())").setParameter(0, id).executeUpdate(); |
| | | |
| | | record.setPayWay(payWay); |
| | | record.setPayMoney(payMoney); |
| | | record.setPayTime(payTime); |
| | | record.setUpdateTime(new Date()); |
| | | |
| | | record.setState(VIPOrderRecord.STATE_PAY); |
| | | |
| | | |
| | | Date[] expireDate = addExpireTime(session, record.getUid(), payTime, record.getType()); |
| | | if (expireDate == null) { |
| | | throw new VIPException(2, "添加用户会员时间出错"); |
| | | } |
| | | |
| | | record.setVipStartTime(expireDate[0]); |
| | | record.setVipEndTime(expireDate[1]); |
| | | |
| | | session.update(record); |
| | | |
| | | |
| | | LoggerUtil.getTestLogger().info("支付成功:修改记录{}", id); |
| | | //购买VIP |
| | | pptvVipManager.buyVIP(record); |
| | | LoggerUtil.getTestLogger().info("支付成功:购买VIP成功{}", id); |
| | | return record; |
| | | } else { |
| | | throw new VIPException(10, "订单不存在"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 续期 |
| | | * |
| | | * @param session |
| | | * @param uid |
| | | * @param payTime |
| | | * @param type |
| | | * @return |
| | | */ |
| | | private Date[] addExpireTime(Session session, String uid, Date payTime, VIPPriceType type) { |
| | | if (type == null || uid == null) |
| | | return null; |
| | | List list = session.createSQLQuery("select * from wk_user_vip i where i.uid=? for update").addEntity(UserVIPInfo.class).setParameter(0, uid).list(); |
| | | if (list == null || list.size() == 0) { |
| | | //新增 |
| | | UserVIPInfo vip = new UserVIPInfo(); |
| | | vip.setUid(uid); |
| | | vip.setCreateTime(new Date()); |
| | | vip.setExpireDate(getExpireTime(payTime, null, type)); |
| | | session.save(vip); |
| | | return new Date[]{payTime, vip.getExpireDate()}; |
| | | } else { |
| | | //修改 |
| | | UserVIPInfo vipInfo = (UserVIPInfo) list.get(0); |
| | | Date expireDate = getExpireTime(payTime, vipInfo.getExpireDate(), type); |
| | | session.createQuery("update UserVIPInfo i set i.expireDate=? ,i.updateTime=? where i.uid=?").setParameter(0, expireDate).setParameter(1, new Date()).setParameter(2, uid).executeUpdate(); |
| | | |
| | | return new Date[]{vipInfo.getExpireDate() == null ? new Date() : vipInfo.getExpireDate(), expireDate}; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取到期时间 |
| | | * |
| | | * @param payTime |
| | | * @param expireTime |
| | | * @param type |
| | | * @return |
| | | */ |
| | | private Date getExpireTime(Date payTime, Date expireTime, VIPPriceType type) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | if (expireTime != null) { |
| | | calendar.setTimeInMillis(expireTime.getTime()); |
| | | } else { |
| | | calendar.setTimeInMillis(payTime.getTime()); |
| | | } |
| | | if (type == VIPPriceType.day) { |
| | | calendar.add(Calendar.DAY_OF_WEEK, 1); |
| | | } else if (type == VIPPriceType.week) { |
| | | calendar.add(Calendar.WEEK_OF_YEAR, 1); |
| | | } else if (type == VIPPriceType.month) { |
| | | calendar.add(Calendar.MONTH, 1); |
| | | } else if (type == VIPPriceType.season) { |
| | | calendar.add(Calendar.MONTH, 3); |
| | | } else if (type == VIPPriceType.halfYear) { |
| | | calendar.add(Calendar.MONTH, 6); |
| | | } else if (type == VIPPriceType.year) { |
| | | calendar.add(Calendar.YEAR, 1); |
| | | } |
| | | return new Date(calendar.getTimeInMillis()); |
| | | } |
| | | |
| | | @Override |
| | | public UserVIPInfo getVIPInfo(String uid) { |
| | | return userVIPInfoDao.find(UserVIPInfo.class, uid); |
| | | } |
| | | |
| | | @Override |
| | | public List<VIPOrderRecord> listOrderRecord(String uid, Integer state, int page, int pageSize) { |
| | | |
| | | VIPOrderRecordDao.DaoQuery query = new VIPOrderRecordDao.DaoQuery(); |
| | | query.start = (page - 1) * pageSize; |
| | | query.count = pageSize; |
| | | query.uid = uid; |
| | | query.state = state; |
| | | |
| | | return vipOrderRecordDao.list(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countOrderRecord(String uid, Integer state) { |
| | | VIPOrderRecordDao.DaoQuery query = new VIPOrderRecordDao.DaoQuery(); |
| | | query.uid = uid; |
| | | query.state = state; |
| | | return vipOrderRecordDao.count(query); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public VIPOrderRecord checkOrderPayState(String id) { |
| | | VIPOrderRecord record = vipOrderRecordDao.find(VIPOrderRecord.class, id); |
| | | if (record.getState() == VIPOrderRecord.STATE_PAY) |
| | | return record; |
| | | |
| | | switch (record.getPayWay()) { |
| | | case VIPOrderRecord.PAY_WAY_ALIPAY: { |
| | | //支付宝 |
| | | AlipayTradeQueryResponse res = null; |
| | | try { |
| | | res = AlipayH5PayUtil.queryOrder(VipUtil.getAlipayApp(), VIPOrderUtil.getOutOrderNo(id), null); |
| | | //支付成功 |
| | | if (res.isSuccess() && "TRADE_SUCCESS".equalsIgnoreCase(res.getTradeStatus())) { |
| | | try { |
| | | return paySuccess(id, VIPOrderRecord.PAY_WAY_ALIPAY, new BigDecimal(res.getTotalAmount()), new Date()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } catch (AlipayApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | break; |
| | | case VIPOrderRecord.PAY_WAY_WX: { |
| | | //微信 |
| | | try { |
| | | WXPayOrderInfoV3 info = WXPayV3Util.getPayOrderInfo(VIPOrderUtil.getOutOrderNo(id), VipUtil.getWXAPP()); |
| | | if (info != null && info.getTrade_state().equalsIgnoreCase("SUCCESS")) { |
| | | paySuccess(id, record.getPayWay(), new BigDecimal(info.getAmount().getPayer_total()).divide(new BigDecimal(100), 2, RoundingMode.FLOOR), new Date()); |
| | | return record; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | return record; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public VIPOrderRecord getOrderRecord(String id) { |
| | | return vipOrderRecordDao.find(VIPOrderRecord.class, id); |
| | | } |
| | | |
| | | @Transactional |
New file |
| | |
| | | package com.yeshi.buwan.service.inter.order; |
| | | |
| | | import com.yeshi.buwan.domain.vip.VIPOrderRecord; |
| | | import com.yeshi.buwan.dto.order.PayWayInfoDTO; |
| | | import com.yeshi.buwan.exception.PPTVException; |
| | | import com.yeshi.buwan.exception.goldcorn.GoldCornException; |
| | | import com.yeshi.buwan.exception.order.OrderException; |
| | | import com.yeshi.buwan.exception.order.PayException; |
| | | import com.yeshi.buwan.exception.vip.VIPException; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | public interface OrderService { |
| | | |
| | | |
| | | /** |
| | | * 创建订单 |
| | | * |
| | | * @param orderRecord |
| | | * @return |
| | | * @throws OrderException |
| | | */ |
| | | public VIPOrderRecord createOrder(VIPOrderRecord orderRecord) throws OrderException; |
| | | |
| | | |
| | | /** |
| | | * 获取订单记录 |
| | | * |
| | | * @param uid |
| | | * @param state |
| | | * @return |
| | | */ |
| | | public List<VIPOrderRecord> listOrderRecord(String uid, Integer state, int page, int pageSize); |
| | | |
| | | |
| | | /** |
| | | * @param uid |
| | | * @param state |
| | | * @return |
| | | */ |
| | | public long countOrderRecord(String uid, Integer state); |
| | | |
| | | |
| | | /** |
| | | * 检测支付状态 |
| | | * |
| | | * @param id |
| | | */ |
| | | public VIPOrderRecord checkOrderPayState(String id); |
| | | |
| | | |
| | | public VIPOrderRecord getOrderRecord(String id); |
| | | |
| | | |
| | | /** |
| | | * 支付订单 |
| | | * |
| | | * @param record |
| | | */ |
| | | public PayWayInfoDTO payOrder(VIPOrderRecord record) throws OrderException, GoldCornException, PayException; |
| | | |
| | | |
| | | /** |
| | | * 支付成功 |
| | | * |
| | | * @param id |
| | | * @param payWay |
| | | * @param payMoney |
| | | * @param payTime |
| | | * @return |
| | | * @throws VIPException |
| | | * @throws PPTVException |
| | | */ |
| | | public VIPOrderRecord paySuccess(final String id, int payWay, BigDecimal payMoney, Date payTime) throws VIPException, PPTVException; |
| | | |
| | | |
| | | /** |
| | | * 取消订单 |
| | | * |
| | | * @param id |
| | | */ |
| | | public void cancelOrder(String id, String reason) throws OrderException; |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | public interface VIPService { |
| | | |
| | | /** |
| | | * 添加记录 |
| | | * |
| | | * @param record |
| | | */ |
| | | public void addVIPRecord(VIPOrderRecord record) throws VIPException; |
| | | |
| | | |
| | | /** |
| | | * 支付成功 |
| | | * |
| | | * @param id |
| | | * @param payMoney |
| | | * @param payTime |
| | | * @throws VIPException |
| | | */ |
| | | public VIPOrderRecord paySuccess(String id, int payWay, BigDecimal payMoney, Date payTime) throws VIPException, PPTVException; |
| | | |
| | | |
| | | /** |
| | | * 获取会员信息 |
| | |
| | | */ |
| | | public UserVIPInfo getVIPInfo(String uid); |
| | | |
| | | |
| | | /** |
| | | * 获取订单记录 |
| | | * |
| | | * @param uid |
| | | * @param state |
| | | * @return |
| | | */ |
| | | public List<VIPOrderRecord> listOrderRecord(String uid, Integer state, int page, int pageSize); |
| | | |
| | | /** |
| | | * @param uid |
| | | * @param state |
| | | * @return |
| | | */ |
| | | public long countOrderRecord(String uid, Integer state); |
| | | |
| | | |
| | | /** |
| | | * 检测支付状态 |
| | | * |
| | | * @param id |
| | | */ |
| | | public VIPOrderRecord checkOrderPayState(String id); |
| | | |
| | | |
| | | public VIPOrderRecord getOrderRecord(String id); |
| | | |
| | | public void initUserVipInfo(String loginUid); |
| | | |
| | |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public List<UserVIPInfo> listVIPUser(Date minVIPExpireDate,Date maxVIPExpireDate, int page, int pageSize); |
| | | public List<UserVIPInfo> listVIPUser(Date minVIPExpireDate, Date maxVIPExpireDate, int page, int pageSize); |
| | | |
| | | /** |
| | | * @param minVIPExpireDate |
| | | * @return |
| | | */ |
| | | public long countVIPUser(Date minVIPExpireDate,Date maxVIPExpireDate); |
| | | public long countVIPUser(Date minVIPExpireDate, Date maxVIPExpireDate); |
| | | |
| | | |
| | | public boolean isVIP(String loginUid); |
| | |
| | | package com.yeshi.buwan.util.vip; |
| | | |
| | | import com.yeshi.buwan.domain.vip.OrderType; |
| | | |
| | | public class VIPOrderUtil { |
| | | |
| | | /** |
| | | * 获取第三方订单号 |
| | | * |
| | | * @param orderType |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public static String getOutOrderNo(String id) { |
| | | return "buwan_vip_" + id; |
| | | public static String getOutOrderNo(OrderType orderType, String id) { |
| | | if (orderType == OrderType.vip) |
| | | return "buwan_vip_" + id; |
| | | else |
| | | return "buwan_video_" + id; |
| | | } |
| | | |
| | | |
| | | public static String getIdFromOutOrderNo(String orderNo) { |
| | | return orderNo.replace("buwan_vip_", ""); |
| | | return orderNo.replace("buwan_vip_", "").replace("buwan_video_", ""); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xmlns:dubbo="http://dubbo.apache.org/schema/dubbo" |
| | | xmlns="http://www.springframework.org/schema/beans" |
| | | xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |
| | | http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd"> |
| | | <dubbo:application name="main-consumer"> |
| | | <dubbo:parameter key="qos.enable" value="true"></dubbo:parameter> |
| | | <dubbo:parameter key="qos.accept.foreign.ip" value="false"></dubbo:parameter> |
| | | <dubbo:parameter key="qos.port" value="33333"></dubbo:parameter> |
| | | </dubbo:application> |
| | | |
| | | <dubbo:registry address="zookeeper://134.175.68.214:2181"/> |
| | | |
| | | <!-- url=dubbo://192.168.3.122:20882/com.yeshi.goods.facade.service.TaoBaoCouponCacheService --> |
| | | </beans> |
| | |
| | | <param name="type">12</param> |
| | | </type> |
| | | </property> |
| | | |
| | | <property name="orderType" column="order_type"> |
| | | <type name="org.hibernate.type.EnumType"> |
| | | <param name="enumClass">com.yeshi.buwan.domain.vip.OrderType</param> |
| | | <param name="type">12</param> |
| | | </type> |
| | | </property> |
| | | |
| | | |
| | | <property name="money" column="money" type="java.math.BigDecimal"></property> |
| | | <property name="payWay" column="pay_way" type="integer"></property> |
| | | <property name="payMoney" column="pay_money" type="java.math.BigDecimal"></property> |
| | |
| | | |
| | | <property name="ipInfo" column="ip_info" type="string"></property> |
| | | |
| | | <property name="goldCorn" column="gold_corn" type="integer"></property> |
| | | <property name="videoInfoId" column="video_info_id" type="string"></property> |
| | | <property name="payWay" column="pay_way" type="integer"></property> |
| | | <property name="moneyPay" column="money_pay" type="boolean"></property> |
| | | <property name="goldCornPay" column="gold_corn_pay" type="boolean"></property> |
| | | |
| | | |
| | | </class> |
| | | |
| | | |
| | |
| | | </bean> |
| | | |
| | | |
| | | <bean |
| | | class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/> |
| | | <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/> |
| | | |
| | | <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" |
| | | init-method="init" destroy-method="close"> |
| | |
| | | <!-- Solr搜索引擎数据管理 --> |
| | | <import resource="solr.xml"></import> |
| | | <import resource="xxl-job.xml"></import> |
| | | <import resource="consumer.xml"></import> |
| | | </beans> |
| | |
| | | import com.yeshi.buwan.job.AdJob; |
| | | import com.yeshi.buwan.service.imp.DetailSystemConfigService; |
| | | import com.yeshi.buwan.service.inter.system.SystemConfigService; |
| | | import com.yeshi.buwan.util.rank.IqiyiRankUtil; |
| | | import com.yeshi.buwan.vo.ad.BannerVO; |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | |
| | | import org.springframework.test.context.web.WebAppConfiguration; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.util.Date; |
| | |
| | | @Test |
| | | public void addSystemConfig() { |
| | | SystemConfig systemConfig = new SystemConfig(); |
| | | systemConfig.setBeizhu(""); |
| | | systemConfig.setKey("iqiyi_update_video_name"); |
| | | systemConfig.setName("爱奇艺特殊更新的视频名称"); |
| | | systemConfig.setValue("《卧底》,没关系,是青春啊!,山海情(原声版),我的时代,你的时代,你好,安怡"); |
| | | systemConfig.setCreateTime(new Date()); |
| | | systemConfig.setId(SystemConfig.createId(systemConfig.getKey())); |
| | | systemConfigDao.save(systemConfig); |
| | | // systemConfig.setBeizhu(""); |
| | | // systemConfig.setKey("iqiyi_update_video_name"); |
| | | // systemConfig.setName("爱奇艺特殊更新的视频名称"); |
| | | // systemConfig.setValue("《卧底》,没关系,是青春啊!,山海情(原声版),我的时代,你的时代,你好,安怡"); |
| | | // systemConfig.setCreateTime(new Date()); |
| | | // systemConfig.setId(SystemConfig.createId(systemConfig.getKey())); |
| | | // systemConfigDao.save(systemConfig); |
| | | // |
| | | // systemConfig = new SystemConfig(); |
| | | // systemConfig.setBeizhu(""); |
| | | // systemConfig.setKey("default_portrait"); |
| | | // systemConfig.setName("默认头像"); |
| | | // systemConfig.setValue("https://buwan-1255749512.cos.ap-guangzhou.myqcloud.com/resource/ic_portrait_default.png"); |
| | | // systemConfig.setCreateTime(new Date()); |
| | | // systemConfig.setId(SystemConfig.createId(systemConfig.getKey())); |
| | | // systemConfigDao.save(systemConfig); |
| | | |
| | | |
| | | systemConfig = new SystemConfig(); |
| | | systemConfig.setBeizhu(""); |
| | | systemConfig.setKey("default_portrait"); |
| | | systemConfig.setName("默认头像"); |
| | | systemConfig.setValue("https://buwan-1255749512.cos.ap-guangzhou.myqcloud.com/resource/ic_portrait_default.png"); |
| | | systemConfig.setKey("thirdUidPrefix"); |
| | | systemConfig.setName("第三方用户ID的前缀"); |
| | | try { |
| | | systemConfig.setValue("buwan-"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | systemConfig.setCreateTime(new Date()); |
| | | systemConfig.setId(SystemConfig.createId(systemConfig.getKey())); |
| | | systemConfigDao.save(systemConfig); |
| | |
| | | public void videoPlay() throws Exception { |
| | | Set<String> sets = new HashSet<>(); |
| | | Gson gson = new Gson(); |
| | | Scanner scanner = new Scanner(new FileInputStream("C:\\Users\\Administrator\\Desktop\\日志\\布丸播放\\play_2021_03_23.log")); |
| | | Scanner scanner = new Scanner(new FileInputStream("C:\\Users\\Administrator\\Desktop\\日志\\布丸播放\\play_2021_04_07.log")); |
| | | Map<String, Integer> countMap = new HashMap<>(); |
| | | List<String> videoList = new ArrayList<>(); |
| | | while (scanner.hasNextLine()) { |
| | |
| | | @Test |
| | | public void userActive() throws Exception { |
| | | Gson gson = new Gson(); |
| | | List<String> list = loadLog("C:\\Users\\Administrator\\Desktop\\日志\\布丸播放\\active_2021_03_31.log"); |
| | | List<String> list = loadLog("C:\\Users\\Administrator\\Desktop\\日志\\布丸播放\\active_2021_04_07.log"); |
| | | Map<String, List<UserActiveLogInfo>> map = new HashMap<>(); |
| | | for (String st : list) { |
| | | UserActiveLogInfo activeLogInfo = gson.fromJson(st, UserActiveLogInfo.class); |
| | |
| | | |
| | | if (actions.contains("search-videoDetail")) { |
| | | searchPlayCount++; |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | System.out.println("搜索之后播放总数:" + searchPlayCount + "比例为:" + getPercent(map.size(), searchPlayCount)); |
| | | System.out.println("搜索之后未播放总数:" + searchNoPlay + "比例为:" + getPercent(map.size(), searchNoPlay)); |
| | | System.out.println("未搜索也未播放总数:" + noSearchAndPlay + "比例为:" + getPercent(map.size(), noSearchAndPlay)); |
| | | System.out.println("搜索满意度:" +getPercent(searchCount, searchPlayCount)); |
| | | System.out.println("搜索满意度:" + getPercent(searchCount, searchPlayCount)); |
| | | System.out.println("未能成功进入首页总数:" + noComeInCount + "比例为:" + getPercent(map.size(), noComeInCount)); |
| | | System.out.println("进入首页后无动作的总数:" + comeinAndNoAction + "比例为:" + getPercent(map.size(), comeinAndNoAction)); |
| | | } |
| | |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.test.context.ContextConfiguration; |
| | | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
| | | import org.springframework.test.context.web.WebAppConfiguration; |
| | |
| | | import java.util.*; |
| | | |
| | | |
| | | //@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 |
| | | //@ContextConfiguration(locations = {"classpath:spring.xml"}) |
| | | //@WebAppConfiguration |
| | | @RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 |
| | | @ContextConfiguration(locations = {"classpath:spring.xml"}) |
| | | @WebAppConfiguration |
| | | public class PPTVTest { |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Test |
| | | public void update() { |
| | | try { |
| | | pptvVideoUpdate.updateLatestVideo(""); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // try { |
| | | // pptvVideoUpdate.updateLatestVideo(""); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | // List<PPTVSeries> list = PPTVApiUtil.getUpdateList(); |
| | | // System.out.println(list); |
| | | List<PPTVSeries> list = PPTVApiUtil.getUpdateList(); |
| | | System.out.println(list); |
| | | } |
| | | |
| | | @Test |
| | |
| | | |
| | | @Test |
| | | public void getApiDetail() { |
| | | PPTVApiUtil.getDetail("9040633"); |
| | | PPTVSeries series = PPTVApiUtil.getDetail("28544897"); |
| | | System.out.println(series); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void buy() { |
| | | PPTVApiUtil.buyGoods("257dfd950c20ad25dee9f99ef926c0f8", "danpian-1", "AB5574873120458", new Date()); |
| | | } |
| | | |
| | | @Test |
| | | public void updateGoodsInfo() { |
| | | Query query = new Query(); |
| | | query.addCriteria(new Criteria("goodsInfo").is(null).andOperator(Criteria.where("free").is("1"))); |
| | | query.limit(400); |
| | | List<PPTVSeries> list = pptvSeriesDao.findList(query); |
| | | for (PPTVSeries series : list) { |
| | | PPTVSeries detail = PPTVApiUtil.getDetail(series.getSeriesCode()); |
| | | query = new Query(); |
| | | query.addCriteria(Criteria.where("_id").is(detail.getInfoID())); |
| | | Update update = new Update(); |
| | | update.set("goodsInfo", detail.getGoodsInfo()); |
| | | pptvSeriesDao.update(query, update); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | 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.order.OrderException; |
| | | import com.yeshi.buwan.exception.vip.VIPException; |
| | | import com.yeshi.buwan.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.util.Constant; |
| | |
| | | |
| | | @Resource |
| | | private VIPService vipService; |
| | | |
| | | |
| | | @Resource |
| | | private OrderService orderService; |
| | | |
| | | @Resource |
| | | private PPTVVipManager pptvVipManager; |
| | |
| | | record.setUid(766693 + ""); |
| | | |
| | | try { |
| | | vipService.addVIPRecord(record); |
| | | } catch (VIPException e) { |
| | | orderService.createOrder(record); |
| | | } catch (OrderException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void listRecord() { |
| | | List<VIPOrderRecord> list = vipService.listOrderRecord(null, null, 1, 10); |
| | | long count = vipService.countOrderRecord(null, null); |
| | | List<VIPOrderRecord> list = orderService.listOrderRecord(null, null, 1, 10); |
| | | long count = orderService.countOrderRecord(null, null); |
| | | |
| | | |
| | | list = vipService.listOrderRecord(766693 + "", null, 1, 10); |
| | | count = vipService.countOrderRecord(766693 + "", null); |
| | | list = orderService.listOrderRecord(766693 + "", null, 1, 10); |
| | | count = orderService.countOrderRecord(766693 + "", null); |
| | | |
| | | |
| | | list = vipService.listOrderRecord(766693 + "", VIPOrderRecord.STATE_NOT_PAY, 1, 10); |
| | | count = vipService.countOrderRecord(766693 + "", VIPOrderRecord.STATE_NOT_PAY); |
| | | list = orderService.listOrderRecord(766693 + "", VIPOrderRecord.STATE_NOT_PAY, 1, 10); |
| | | count = orderService.countOrderRecord(766693 + "", VIPOrderRecord.STATE_NOT_PAY); |
| | | |
| | | list = vipService.listOrderRecord(766693 + "", VIPOrderRecord.STATE_PAY, 1, 10); |
| | | count = vipService.countOrderRecord(766693 + "", VIPOrderRecord.STATE_PAY); |
| | | list = orderService.listOrderRecord(766693 + "", VIPOrderRecord.STATE_PAY, 1, 10); |
| | | count = orderService.countOrderRecord(766693 + "", VIPOrderRecord.STATE_PAY); |
| | | |
| | | System.out.println(list); |
| | | } |
| | |
| | | |
| | | @Test |
| | | public void test3() throws Exception { |
| | | VIPOrderRecord record = vipService.getOrderRecord("82"); |
| | | VIPOrderRecord record = orderService.getOrderRecord("82"); |
| | | pptvVipManager.buyVIP(record); |
| | | } |
| | | |