| | |
| | | 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.exception.vip.VideoBuyRecordException; |
| | | import com.yeshi.buwan.pptv.entity.PPTVSeries; |
| | | import com.yeshi.buwan.pptv.entity.VideoPPTVMap; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | |
| | | }).create(); |
| | | JSONObject root = new JSONObject(); |
| | | |
| | | List<OrderRecord> list = orderService.listOrderRecord(loginUid, OrderType.valueOf(type), null, page, Constant.pageCount); |
| | | List<OrderRecord> list = orderService.listOrderRecord(loginUid, type == null ? null : OrderType.valueOf(type), null, page, Constant.pageCount); |
| | | |
| | | List<OrderInfoVO> voList = new ArrayList<>(); |
| | | for (OrderRecord record : list) { |
| | | voList.add(OrderInfoVO.create(record)); |
| | | } |
| | | long count = orderService.countOrderRecord(loginUid, OrderType.valueOf(type), null); |
| | | long count = orderService.countOrderRecord(loginUid, type == null ? null : OrderType.valueOf(type), null); |
| | | root.put("list", gson.toJson(voList)); |
| | | root.put("count", count); |
| | | return JsonUtilV2.loadTrueJson(root.toString()); |
| | |
| | | */ |
| | | @RequestMapping("createOrder") |
| | | @ResponseBody |
| | | public String createOrder(AcceptData acceptData, HttpServletRequest request, String loginUid, String priceId, String infoId, Integer goldCorn, int payWay) { |
| | | public String createOrder(AcceptData acceptData, HttpServletRequest request, String loginUid, String priceId, String cid, String vid, Integer goldCorn, int payWay) { |
| | | |
| | | if (StringUtil.isNullOrEmpty(loginUid)) { |
| | | return JsonUtilV2.loadFalseJson("用户未登录"); |
| | |
| | | return JsonUtilV2.loadFalseJson("用户不存在"); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(user.getPhone())) { |
| | | if (StringUtil.isNullOrEmpty(user.getPhone()) && payWay != OrderRecord.PAY_WAY_IAPP) { |
| | | return JsonUtilV2.loadFalseJson(10001, "请绑定电话号码"); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(priceId) && StringUtil.isNullOrEmpty(infoId)) { |
| | | if (StringUtil.isNullOrEmpty(priceId) && StringUtil.isNullOrEmpty(cid)) { |
| | | return JsonUtilV2.loadFalseJson("请选择购买类型"); |
| | | } |
| | | |
| | |
| | | |
| | | OrderType orderType = OrderType.vip; |
| | | |
| | | if (!StringUtil.isNullOrEmpty(infoId)) { |
| | | if (!StringUtil.isNullOrEmpty(cid)) { |
| | | orderType = OrderType.video; |
| | | } |
| | | |
| | |
| | | VIPPrice vipPrice = null; |
| | | |
| | | if (orderType == OrderType.video) { |
| | | //视频 |
| | | VideoPPTVMap map = pptvService.selectVideoPPTVMapByInfoId(infoId); |
| | | if (map == null) { |
| | | PPTVSeries pptvSeries = pptvService.selectSeriesBySeriesCode(cid); |
| | | if (pptvSeries == null) { |
| | | return JsonUtilV2.loadFalseJson("影片不存在"); |
| | | } |
| | | PPTVSeries pptvSeries = pptvService.selectSeriesByInfoId(infoId); |
| | | if (pptvSeries == null) { |
| | | //视频 |
| | | VideoPPTVMap map = pptvService.selectVideoPPTVMapByPPInfo(pptvSeries.getInfoID(), vid); |
| | | if (map == null) { |
| | | return JsonUtilV2.loadFalseJson("影片不存在"); |
| | | } |
| | | record.setRemarks(pptvSeries.getName()); |
| | |
| | | } |
| | | |
| | | record.setOrderType(orderType); |
| | | record.setVideoInfoId(infoId); |
| | | record.setVideoCid(cid); |
| | | record.setVideoVid(vid); |
| | | record.setGoldCorn(goldCorn); |
| | | record.setPayWay(payWay); |
| | | record.setState(OrderRecord.STATE_NOT_PAY); |
| | |
| | | return JsonUtilV2.loadFalseJson(e.getMessage()); |
| | | } catch (PPTVException e) { |
| | | return JsonUtilV2.loadFalseJson(e.getMessage()); |
| | | } catch (VideoBuyRecordException e) { |
| | | return JsonUtilV2.loadFalseJson("单片购买失败"); |
| | | } |
| | | return JsonUtilV2.loadTrueJson(new Gson().toJson(payResult)); |
| | | if (payResult.getPayWay() == OrderRecord.PAY_WAY_IAPP) { |
| | | //苹果内购 |
| | | JSONObject root = new JSONObject(); |
| | | root.put("orderNo", record.getId()); |
| | | root.put("productId", vipPrice.getIosProductId()); |
| | | return JsonUtilV2.loadTrueJson(root.toString()); |
| | | } else { |
| | | return JsonUtilV2.loadTrueJson(new Gson().toJson(payResult)); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 检查是否支付 |
| | |
| | | * @param acceptData |
| | | * @param loginUid |
| | | * @param id |
| | | * @param receipt -ios支付结果receipt |
| | | * @return |
| | | */ |
| | | @RequestMapping("checkPay") |
| | | @ResponseBody |
| | | @RequestSerializableByKey(key = "'vip-checkPay-'+#id") |
| | | public String checkPay(AcceptData acceptData, String loginUid, String id) { |
| | | public String checkPay(AcceptData acceptData, String loginUid, String id, String receipt) { |
| | | OrderRecord record = orderService.getOrderRecord(id); |
| | | if (record == null || !record.getUid().equalsIgnoreCase(loginUid)) { |
| | | return JsonUtilV2.loadFalseJson("记录不存在/不是您的订单"); |
| | | } |
| | | |
| | | record = orderService.checkOrderPayState(id); |
| | | //未支付 |
| | | if (record != null && record.getState() != OrderRecord.STATE_PAY) { |
| | | return JsonUtilV2.loadFalseJson(1, "支付未完成"); |
| | | if (record.getPayWay() == OrderRecord.PAY_WAY_IAPP) { |
| | | try { |
| | | orderService.checkApplePay(record.getId(), receipt); |
| | | JSONObject data = new JSONObject(); |
| | | return JsonUtilV2.loadTrueJson(data.toString()); |
| | | } catch (Exception e) { |
| | | return JsonUtilV2.loadFalseJson(e.getMessage()); |
| | | } |
| | | } else { |
| | | record = orderService.checkOrderPayState(id); |
| | | //未支付 |
| | | if (record != null && record.getState() != OrderRecord.STATE_PAY) { |
| | | return JsonUtilV2.loadFalseJson(1, "支付未完成"); |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("money", record.getPayMoney() == null ? record.getMoney() : record.getPayMoney()); |
| | | return JsonUtilV2.loadTrueJson(data.toString()); |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("money", record.getPayMoney() == null ? record.getMoney() : record.getPayMoney()); |
| | | |
| | | return JsonUtilV2.loadTrueJson(data.toString()); |
| | | } |
| | | |
| | | |