| | |
| | | package com.yeshi.buwan.pptv; |
| | | |
| | | import com.yeshi.buwan.domain.user.LoginUserExtra; |
| | | 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.service.inter.LoginUserService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPPriceService; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * PPTV会员 |
| | |
| | | @Component |
| | | public class PPTVVipManager { |
| | | |
| | | @Resource |
| | | private VIPPriceService vipPriceService; |
| | | |
| | | @Resource |
| | | private LoginUserService loginUserService; |
| | | |
| | | /** |
| | | * 购买VIP |
| | | * @param record |
| | | * @throws PPTVException |
| | | * @throws VIPException |
| | | */ |
| | | public void buyVIP() { |
| | | public void buyVIP(VIPOrderRecord record) throws PPTVException, VIPException { |
| | | if (record.getState() != VIPOrderRecord.STATE_PAY) { |
| | | throw new VIPException(11, "尚未支付成功"); |
| | | } |
| | | VIPPrice price = vipPriceService.selectByType(record.getType()); |
| | | if (price == null) { |
| | | throw new VIPException(12, "无法获取价格套餐"); |
| | | } |
| | | |
| | | 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(), price.getPptvGoodsNo(), record.getPayTime()); |
| | | if (!success) { |
| | | throw new VIPException(21, "PPTV会员购买失败"); |
| | | } |
| | | } |
| | | |
| | | |