| | |
| | | import com.google.gson.*; |
| | | import com.yeshi.buwan.domain.user.LoginUser; |
| | | import com.yeshi.buwan.domain.vip.*; |
| | | import com.yeshi.buwan.dto.order.PPTVVideoPrice; |
| | | 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.entity.PPTVSeries; |
| | | import com.yeshi.buwan.pptv.entity.VideoPPTVMap; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | | import com.yeshi.buwan.service.inter.juhe.PPTVService; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.lang.reflect.Type; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | |
| | | }).create(); |
| | | JSONObject root = new JSONObject(); |
| | | |
| | | List<OrderRecord> list = orderService.listOrderRecord(loginUid, OrderType.vip,null, page, Constant.pageCount); |
| | | List<OrderRecord> list = orderService.listOrderRecord(loginUid, OrderType.vip, null, page, Constant.pageCount); |
| | | for (OrderRecord record : list) { |
| | | record.setIpInfo(null); |
| | | record.setUpdateTime(null); |
| | | } |
| | | long count = orderService.countOrderRecord(loginUid, OrderType.vip,null); |
| | | long count = orderService.countOrderRecord(loginUid, OrderType.vip, null); |
| | | root.put("list", gson.toJson(list)); |
| | | root.put("count", count); |
| | | return JsonUtilV2.loadTrueJson(root.toString()); |
| | |
| | | |
| | | String ip = IPUtil.getRemotIP(request); |
| | | |
| | | OrderRecord record = new OrderRecord(); |
| | | |
| | | VIPPrice vipPrice = null; |
| | | |
| | | if (orderType == OrderType.video) { |
| | | //视频 |
| | | VideoPPTVMap map = pptvService.selectVideoPPTVMapByInfoId(infoId); |
| | | if (map == null) { |
| | | return JsonUtilV2.loadFalseJson("影片不存在"); |
| | | } |
| | | PPTVSeries pptvSeries = pptvService.selectSeriesByInfoId(infoId); |
| | | if (pptvSeries == null) { |
| | | return JsonUtilV2.loadFalseJson("影片不存在"); |
| | | } |
| | | record.setRemarks(pptvSeries.getName()); |
| | | } else { |
| | | vipPrice = vipPriceService.selectByPrimaryKey(priceId); |
| | | if (vipPrice == null) { |
| | |
| | | } |
| | | } |
| | | |
| | | OrderRecord record = new OrderRecord(); |
| | | |
| | | record.setUid(loginUid); |
| | | if (vipPrice != null) |
| | | if (vipPrice != null) { |
| | | record.setType(vipPrice.getType()); |
| | | record.setMoney(vipPrice.getActualPrice()); |
| | | } else { |
| | | PPTVVideoPrice price = new Gson().fromJson(systemConfigService.getConfigValueByKeyCache("videoPrice"), PPTVVideoPrice.class); |
| | | record.setMoney(price.getActualPrice().subtract(new BigDecimal(goldCorn).divide(new BigDecimal(100), 2, RoundingMode.UP))); |
| | | } |
| | | |
| | | record.setOrderType(orderType); |
| | | record.setVideoInfoId(infoId); |
| | | record.setGoldCorn(goldCorn); |
| | | record.setMoney(vipPrice.getActualPrice()); |
| | | record.setPayWay(payWay); |
| | | record.setState(OrderRecord.STATE_NOT_PAY); |
| | | record.setIpInfo(IPUtil.getRemotIP(request) + ":" + IPUtil.getRemotePort(request)); |
| | |
| | | } |
| | | |
| | | |
| | | PayWayInfoDTO payResult = null; |
| | | |
| | | try { |
| | | orderService.payOrder(record); |
| | | payResult = orderService.payOrder(record); |
| | | } catch (OrderException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtilV2.loadFalseJson(e.getMessage()); |
| | | } catch (GoldCornException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtilV2.loadFalseJson(e.getMessage()); |
| | | } catch (PayException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtilV2.loadFalseJson(e.getMessage()); |
| | | } catch (VIPException e) { |
| | | return JsonUtilV2.loadFalseJson(e.getMessage()); |
| | | } catch (PPTVException e) { |
| | | return JsonUtilV2.loadFalseJson(e.getMessage()); |
| | | } |
| | | |
| | | String orderNo = VIPOrderUtil.getOutOrderNo(record.getOrderType(), record.getId()); |
| | | switch (payWay) { |
| | | case OrderRecord |
| | | .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); |
| | | org.json.JSONObject data = new org.json.JSONObject(); |
| | | data.put("payUrl", Constant.HOST + "/BuWan/alipay/printPayForm?formId=" + id); |
| | | data.put("payWay", payWay); |
| | | return JsonUtilV2.loadTrueJson(data.toString()); |
| | | } |
| | | |
| | | |
| | | case OrderRecord |
| | | .PAY_WAY_WX: { |
| | | //生成微信支付订单 |
| | | try { |
| | | String payUrl = VipUtil.createWXOrder(record.getId(), ip, orderNo, vipPrice.getActualPrice(), "影视大全VIP-" + vipPrice.getType().getName()); |
| | | org.json.JSONObject data = new org.json.JSONObject(); |
| | | data.put("payUrl", payUrl); |
| | | data.put("payWay", payWay); |
| | | return JsonUtilV2.loadTrueJson(data.toString()); |
| | | } catch (Exception e) { |
| | | logger.error("生成微信支付订单出错", e); |
| | | return JsonUtilV2.loadFalseJson("生成微信支付订单出错"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return JsonUtilV2.loadFalseJson("请选择支付方式"); |
| | | return JsonUtilV2.loadTrueJson(new Gson().toJson(payResult)); |
| | | } |
| | | |
| | | /** |