| | |
| | | |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.internal.util.AlipaySignature; |
| | | 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.vip.VIPService; |
| | | 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.json.JSONObject; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.alipay.AlipayH5PayUtil; |
| | | import org.yeshi.utils.entity.alipay.AlipayAppInfo; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private VIPService vipService; |
| | | |
| | | @RequestMapping("printPayForm") |
| | | public void printPayForm(String formId, HttpServletResponse response) { |
| | |
| | | String outTradeNo = map.get("out_trade_no"); |
| | | String tradeStatus = map.get("trade_status"); |
| | | |
| | | //支付成功 |
| | | if ("TRADE_SUCCESS".equalsIgnoreCase(tradeStatus)) { |
| | | |
| | | } |
| | | |
| | | logger.info("支付回调:" + new JSONObject(map).toString()); |
| | | AlipayAppInfo app = VipUtil.getAlipayApp(); |
| | |
| | | try { |
| | | boolean right = AlipaySignature.rsaCheckV1(map, app.getAlipayPublicKey(), "GBK", map.get("sign_type")); |
| | | if (right) { |
| | | //支付成功 |
| | | if ("TRADE_SUCCESS".equalsIgnoreCase(tradeStatus)) { |
| | | AlipayTradeQueryResponse res = AlipayH5PayUtil.queryOrder(app, outTradeNo, null); |
| | | //支付成功 |
| | | if (res.isSuccess() && "TRADE_SUCCESS".equalsIgnoreCase(res.getTradeStatus())) { |
| | | String id = VIPOrderUtil.getIdFromOutOrderNo(outTradeNo); |
| | | try { |
| | | vipService.paySuccess(id, VIPOrderRecord.PAY_WAY_ALIPAY, new BigDecimal(res.getPayAmount()), new Date()); |
| | | } catch (VIPException e) { |
| | | e.printStackTrace(); |
| | | logger.error("支付成功回调出错 id:{}", id, e); |
| | | } |
| | | } |
| | | } |
| | | response.getWriter().print("success"); |
| | | response.getWriter().close(); |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.controller; |
| | | |
| | | import com.yeshi.buwan.pptv.PPTVApiUtil; |
| | | import com.yeshi.buwan.pptv.PPTVUtil; |
| | | import com.yeshi.buwan.util.AESUtil; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import org.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | |
| | | @Controller |
| | | @RequestMapping("pptv") |
| | | public class PPTVController { |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("user/{code}") |
| | | public void validCode(@PathVariable String code, HttpServletResponse response) throws IOException { |
| | | response.setContentType("application/json;charset=UTF-8"); |
| | | PPTVUtil.PPTVCodeInfo codeInfo = PPTVUtil.decryptPPTVCode(code); |
| | | if (codeInfo == null) { |
| | | response.getWriter().print(loadFalseResult(1, "code校验失败,解码失败")); |
| | | } else { |
| | | //间隔时间大于1天 |
| | | if (System.currentTimeMillis() - codeInfo.time > 1000 * 60 * 60L * 24) { |
| | | response.getWriter().print(loadFalseResult(2, "code校验失败,时间超限")); |
| | | return; |
| | | } |
| | | response.getWriter().print(loadTrueResult(codeInfo.pptvUid)); |
| | | } |
| | | } |
| | | |
| | | private String loadFalseResult(int code, String msg) { |
| | | JSONObject root = new JSONObject(); |
| | | root.put("code", code); |
| | | root.put("infoMsg", msg); |
| | | return root.toString(); |
| | | } |
| | | |
| | | |
| | | private String loadTrueResult(String pptvUid) { |
| | | JSONObject root = new JSONObject(); |
| | | root.put("code", 100); |
| | | root.put("infoMsg", "code校验成功"); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("userid", pptvUid); |
| | | data.put("channelNo", PPTVApiUtil.CHANNEL_ID); |
| | | data.put("appKey", PPTVApiUtil.APP_KEY); |
| | | root.put("data", data); |
| | | return root.toString(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.yeshi.buwan.controller; |
| | | |
| | | import com.yeshi.buwan.domain.vip.VIPOrderRecord; |
| | | import com.yeshi.buwan.exception.vip.VIPException; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.user.VipUtil; |
| | | import com.yeshi.buwan.util.vip.VIPOrderUtil; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.slf4j.Logger; |
| | |
| | | import org.yeshi.utils.entity.wx.WXAPPInfo; |
| | | import org.yeshi.utils.wx.WXPayV3Util; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.NoSuchPaddingException; |
| | | import javax.crypto.spec.GCMParameterSpec; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.security.GeneralSecurityException; |
| | | import java.security.InvalidAlgorithmParameterException; |
| | | import java.security.InvalidKeyException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.Base64; |
| | | import java.util.Date; |
| | | |
| | | @Controller |
| | | @RequestMapping("wx") |
| | | public class WXController { |
| | | Logger logger = LoggerFactory.getLogger(WXController.class); |
| | | |
| | | @Resource |
| | | private VIPService vipService; |
| | | |
| | | private static String decryptToString(String apiV3Key, String associatedData, String nonce, String ciphertext) |
| | | throws GeneralSecurityException, IOException { |
| | |
| | | * @throws Exception |
| | | */ |
| | | private void process(HttpServletRequest request) throws Exception { |
| | | WXAPPInfo wxappInfo = new WXAPPInfo(); |
| | | WXAPPInfo wxappInfo = VipUtil.getWXAPP(); |
| | | //验证证书序列号 |
| | | String mchSerialNo = request.getHeader("Wechatpay-Serial"); |
| | | if (!mchSerialNo.equalsIgnoreCase(wxappInfo.getMchSerialNo())) { |
| | |
| | | if (tradeState.equalsIgnoreCase("SUCCESS")) { |
| | | boolean isPaySuccess = WXPayV3Util.isPaySuccess(outTradeNo, wxappInfo); |
| | | if (isPaySuccess) { |
| | | //TODO 支付成功 |
| | | BigDecimal money = new BigDecimal(decript.optJSONObject("amount").optInt("total")).divide(new BigDecimal(100), 2, RoundingMode.FLOOR); |
| | | String id = VIPOrderUtil.getIdFromOutOrderNo(outTradeNo); |
| | | try { |
| | | vipService.paySuccess(id, VIPOrderRecord.PAY_WAY_WX, money, new Date()); |
| | | } catch (VIPException e) { |
| | | logger.error("订单支付成功处理出错:{}", id, e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | commentParser.bindQQ(acceptData, request, out); |
| | | } else if (method.equalsIgnoreCase("bindWX")) { |
| | | commentParser.bindWX(acceptData, request, out); |
| | | } else if (method.equalsIgnoreCase("allowOneKeyLogin")) { |
| | | commentParser.allowOneKeyLogin(acceptData, request, out); |
| | | } |
| | | out.close(); |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.controller.api; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.buwan.controller.parser.UserParser; |
| | | import com.yeshi.buwan.domain.user.LoginUser; |
| | | import com.yeshi.buwan.domain.user.LoginUserExtra; |
| | | import com.yeshi.buwan.domain.vip.UserVIPInfo; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | | import com.yeshi.buwan.service.inter.SMSService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | import com.yeshi.buwan.util.JsonUtil; |
| | | import com.yeshi.buwan.util.RedisManager; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.factory.vo.UserInfoVOFactory; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | | import com.yeshi.buwan.vo.client.user.UserInfoVO; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpSession; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/v2/user") |
| | | public class UserController { |
| | | |
| | | @Resource |
| | | private LoginUserService loginUserService; |
| | | |
| | | @Resource |
| | | private VIPService vipService; |
| | | |
| | | |
| | | @RequestMapping("getUserInfo") |
| | | @ResponseBody |
| | | public String getUserInfo(AcceptData acceptData, String loginUid) { |
| | | LoginUser loginUser = loginUserService.getLoginUser(loginUid); |
| | | if (loginUser == null) { |
| | | return JsonUtil.loadFalseJson("用户不存在"); |
| | | } |
| | | |
| | | LoginUserExtra extra = loginUserService.getExtra(loginUid); |
| | | //初始化用户信息 |
| | | if (extra == null) |
| | | extra = loginUserService.initExtra(loginUid); |
| | | |
| | | UserVIPInfo vipInfo = vipService.getVIPInfo(loginUid); |
| | | UserInfoVO vo = UserInfoVOFactory.create(loginUser, extra, vipInfo); |
| | | return JsonUtil.loadTrueJson(new Gson().toJson(vo)); |
| | | } |
| | | |
| | | |
| | | @RequestMapping("updateUserInfo") |
| | | @ResponseBody |
| | | public String updateUserInfo(AcceptData acceptData, String portrait, String loginUid, String nickName, String birthday, String sex, String personSign, HttpSession session) { |
| | | |
| | | LoginUser loginUser = new LoginUser(); |
| | | LoginUserExtra extra = new LoginUserExtra(); |
| | | loginUser.setId(loginUid); |
| | | extra.setId(loginUid); |
| | | if (!StringUtil.isNullOrEmpty(portrait)) { |
| | | loginUser.setPortrait(UserParser.savePortrait(portrait, session)); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(nickName)) { |
| | | loginUser.setName(nickName); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(birthday)) { |
| | | loginUser.setBirthday(birthday); |
| | | extra.setBirthday(birthday); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(sex)) { |
| | | loginUser.setSex(sex); |
| | | extra.setSex(sex); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(personSign)) { |
| | | loginUser.setSign(personSign); |
| | | extra.setSign(personSign); |
| | | } |
| | | loginUserService.updateSelectiveByPrimaryKey(loginUser); |
| | | loginUserService.updateSelectiveByPrimaryKey(extra); |
| | | return JsonUtil.loadTrueJson(""); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.controller.api; |
| | | |
| | | import com.google.gson.*; |
| | | 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.exception.vip.VIPException; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPPriceService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | import com.yeshi.buwan.util.*; |
| | | import com.yeshi.buwan.util.user.VipUtil; |
| | | import com.yeshi.buwan.util.vip.VIPOrderUtil; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | | import com.yeshi.buwan.vo.client.user.UserInfoVO; |
| | | import net.sf.json.JSONObject; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.lang.reflect.Type; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/v2/vip") |
| | | public class VIPController { |
| | | |
| | | Logger logger = LoggerFactory.getLogger(VIPController.class); |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private VIPService vipService; |
| | | |
| | | @Resource |
| | | private LoginUserService loginUserService; |
| | | |
| | | @Resource |
| | | private VIPPriceService vipPriceService; |
| | | |
| | | |
| | | @RequestMapping("getVIPPriceList") |
| | | @ResponseBody |
| | | public String getVIPPriceList(AcceptData acceptData, String loginUid) { |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().registerTypeAdapter(VIPPriceType.class, new JsonSerializer<VIPPriceType>() { |
| | | @Override |
| | | public JsonElement serialize(VIPPriceType value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | return new JsonPrimitive(value.getName()); |
| | | } |
| | | } |
| | | }).create(); |
| | | JSONObject root = new JSONObject(); |
| | | if (!StringUtil.isNullOrEmpty(loginUid)) { |
| | | LoginUser user = loginUserService.getLoginUser(loginUid); |
| | | if (user == null) { |
| | | return JsonUtilV2.loadFalseJson("用户不存在"); |
| | | } |
| | | UserVIPInfo vipInfo = vipService.getVIPInfo(loginUid); |
| | | UserInfoVO userInfoVO = new UserInfoVO(); |
| | | userInfoVO.setId(user.getId()); |
| | | userInfoVO.setNickName(user.getName()); |
| | | userInfoVO.setPortrait(user.getPortrait()); |
| | | if (vipInfo != null && vipInfo.getExpireDate() != null) |
| | | userInfoVO.setVipExpireTime(vipInfo.getExpireDate().getTime()); |
| | | root.put("user", new Gson().toJson(userInfoVO)); |
| | | } |
| | | |
| | | List<VIPPrice> vipPriceList = vipPriceService.listValidPrice(); |
| | | root.put("list", gson.toJson(vipPriceList)); |
| | | return JsonUtilV2.loadTrueJson(root.toString()); |
| | | } |
| | | |
| | | /** |
| | | * 生成订单 |
| | | * |
| | | * @param acceptData |
| | | * @param loginUid |
| | | * @return |
| | | */ |
| | | @RequestMapping("createOrder") |
| | | @ResponseBody |
| | | public String createOrder(AcceptData acceptData, HttpServletRequest request, String loginUid, String priceId, int payWay) { |
| | | |
| | | if (StringUtil.isNullOrEmpty(loginUid)) { |
| | | return JsonUtilV2.loadFalseJson("用户未登录"); |
| | | } |
| | | |
| | | LoginUser user = loginUserService.getLoginUser(loginUid); |
| | | if (user == null) { |
| | | return JsonUtilV2.loadFalseJson("用户不存在"); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(user.getPhone())) { |
| | | return JsonUtilV2.loadFalseJson(10001,"请绑定电话号码"); |
| | | } |
| | | |
| | | |
| | | String ip = IPUtil.getRemotIP(request); |
| | | VIPPrice vipPrice = vipPriceService.selectByPrimaryKey(priceId); |
| | | if (vipPrice == null) { |
| | | return JsonUtilV2.loadFalseJson("套餐不存在"); |
| | | } |
| | | |
| | | VIPOrderRecord record = new VIPOrderRecord(); |
| | | record.setUid(loginUid); |
| | | record.setType(vipPrice.getType()); |
| | | record.setMoney(vipPrice.getPrice()); |
| | | record.setState(VIPOrderRecord.STATE_NOT_PAY); |
| | | try { |
| | | vipService.addVIPRecord(record); |
| | | } catch (VIPException e) { |
| | | logger.error("生成订单出错", e); |
| | | return JsonUtilV2.loadFalseJson("生成订单出错"); |
| | | } |
| | | |
| | | String orderNo = VIPOrderUtil.getOutOrderNo(record.getId()); |
| | | switch (payWay) { |
| | | case VIPOrderRecord |
| | | .PAY_WAY_ALIPAY: { |
| | | //生成支付宝支付订单 |
| | | String form = VipUtil.getVipChargeAlipayForm(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", "http://api.ysdq.yeshitv.com:8089/BuWan/alipay/printPayForm?formId=" + id); |
| | | data.put("payWay", payWay); |
| | | return JsonUtilV2.loadTrueJson(data.toString()); |
| | | } |
| | | |
| | | |
| | | case VIPOrderRecord |
| | | .PAY_WAY_WX: { |
| | | //生成微信支付订单 |
| | | try { |
| | | String payUrl = VipUtil.createWXOrder(ip, orderNo, vipPrice.getPrice(), "影视大全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("请选择支付方式"); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.yeshi.buwan.service.imp.push.PushService; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | | import com.yeshi.buwan.service.inter.SMSService; |
| | | import com.yeshi.buwan.util.AliyunOneKeyLoginUtil; |
| | | import com.yeshi.buwan.util.JsonUtil; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.*; |
| | | import com.yeshi.buwan.util.annotation.RequireUid; |
| | | import com.yeshi.buwan.util.wx.MyWXLoginUtil; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | |
| | | import java.io.PrintWriter; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | |
| | | |
| | | @Resource |
| | | private SMSService smsService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @RequireUid |
| | | public void getReadState(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 允许一键登录 |
| | | * |
| | | * @param acceptData |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | public void allowOneKeyLogin(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | Long loginUid = StringUtil.isNullOrEmpty(request.getParameter("loginUid")) ? null : Long.parseLong(request.getParameter("loginUid")); |
| | | if (loginUid == null || loginUid == 0L) { |
| | | out.print(JsonUtil.loadFalseJson("尚未登录")); |
| | | return; |
| | | } |
| | | String device = request.getParameter("Device"); |
| | | long time = System.currentTimeMillis(); |
| | | |
| | | String key = "onkeylogin-" + StringUtil.Md5(device + "#" + TimeUtil.getGernalTime(time, "yyyyMMdd")); |
| | | |
| | | //一个设备一天之内只能允许5次 |
| | | String value = redisManager.getCommonString(key); |
| | | if (!StringUtil.isNullOrEmpty(value) && Integer.parseInt(value) > 10) { |
| | | out.print(JsonUtil.loadFalseJson("一键登录次数超限,请明天再试")); |
| | | return; |
| | | } |
| | | out.print(JsonUtil.loadTrueJson("")); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 电话号码绑定 |
| | |
| | | String code = request.getParameter("code"); |
| | | String accessToken = request.getParameter("accessToken"); |
| | | String systemId = request.getParameter("system"); |
| | | String device = request.getParameter("Device"); |
| | | |
| | | long time = System.currentTimeMillis(); |
| | | |
| | | |
| | | if (loginUid == null || loginUid == 0L) { |
| | | out.print(JsonUtil.loadFalseJson("登录失败")); |
| | | out.print(JsonUtil.loadFalseJson("尚未登录")); |
| | | return; |
| | | } |
| | | |
| | |
| | | if (!StringUtil.isNullOrEmpty(accessToken)) { |
| | | //一键登录 |
| | | mobile = AliyunOneKeyLoginUtil.getMobile(accessToken, ""); |
| | | |
| | | //增加一键登录的次数 |
| | | String key = "onkeylogin-" + StringUtil.Md5(device + "#" + TimeUtil.getGernalTime(time, "yyyyMMdd")); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTimeInMillis(time); |
| | | calendar.add(Calendar.DAY_OF_WEEK, 1); |
| | | int s = (int) ((TimeUtil.convertGernalTime(TimeUtil.getGernalTime(calendar.getTimeInMillis(), "yyyyMMdd"), "yyyyMMdd") - time) / 1000); |
| | | redisManager.increase(key, s); |
| | | } else { |
| | | //通过验证码登录 |
| | | //判断验证码是否正确 |
| | |
| | | return; |
| | | } |
| | | |
| | | if (smsService.verifyBindVCode(phone, code)) { |
| | | if (!smsService.verifyBindVCode(phone, code)) { |
| | | out.print(JsonUtil.loadFalseJson("验证码错误")); |
| | | return; |
| | | } |
| | |
| | | } |
| | | |
| | | try { |
| | | smsService.sendBindVCode(Long.parseLong(loginUid), phone, 6); |
| | | smsService.sendBindVCode(loginUid, phone, 6); |
| | | } catch (SMSException e) { |
| | | e.printStackTrace(); |
| | | out.print(JsonUtil.loadFalseJson(e.getMessage())); |
| | |
| | | JSONObject adNew = new JSONObject(); |
| | | |
| | | String ip = IPUtil.getRemotIP(request); |
| | | |
| | | //会员链接 |
| | | String vipLink = map.get("vip_link"); |
| | | data.put("vipLink", vipLink); |
| | | |
| | | ADConfig splashConfig = getAdShowType("ad_splash_config", acceptData.getChannel(), acceptData.getVersion(), map); |
| | | |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.yeshi.buwan.domain.*; |
| | | import com.yeshi.buwan.pptv.PPTVUtil; |
| | | import com.yeshi.buwan.pptv.entity.PPTVSeries; |
| | | import com.yeshi.buwan.service.imp.*; |
| | | import com.yeshi.buwan.service.inter.juhe.PPTVService; |
| | | import com.yeshi.buwan.util.annotation.RequireUid; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | | import org.apache.commons.httpclient.HttpClient; |
| | |
| | | import org.springframework.stereotype.Controller; |
| | | |
| | | import com.yeshi.buwan.domain.entity.PlayUrl; |
| | | import com.yeshi.buwan.service.imp.AdService; |
| | | import com.yeshi.buwan.service.imp.AttentionService; |
| | | import com.yeshi.buwan.service.imp.ClassService; |
| | | import com.yeshi.buwan.service.imp.CollectionService; |
| | | import com.yeshi.buwan.service.imp.CommentService; |
| | | import com.yeshi.buwan.service.imp.ConfigService; |
| | | import com.yeshi.buwan.service.imp.HomeAdService; |
| | | import com.yeshi.buwan.service.imp.HomeTypeService; |
| | | import com.yeshi.buwan.service.imp.StatisticsService; |
| | | import com.yeshi.buwan.service.imp.SystemService; |
| | | import com.yeshi.buwan.service.imp.UserService; |
| | | import com.yeshi.buwan.service.imp.VideoManager; |
| | | import com.yeshi.buwan.util.CacheUtil; |
| | | import com.yeshi.buwan.util.Constant; |
| | | import com.yeshi.buwan.util.JsonUtil; |
| | |
| | | |
| | | @Resource |
| | | private VideoDetailUtil videoDetailUtil; |
| | | |
| | | @Resource |
| | | private ResourceVideoService resourceVideoService; |
| | | |
| | | @Resource |
| | | private PPTVService pptvService; |
| | | |
| | | @RequireUid |
| | | public void getHomeAd(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); |
| | | |
| | | VideoInfo info = (videoDeailUtil.getVideoInfo(detailSystem.getId(), videoId, resourceId, resourceList, |
| | | CacheUtil.getMD5Long(resourceList))); |
| | | //获取优先展示的渠道 |
| | | if (StringUtil.isNullOrEmpty(resourceId)) { |
| | | Set<Long> rids = new HashSet<>(); |
| | | rids.addAll(resourceList); |
| | | VideoResource defaultVideoResource = resourceVideoService.getDefaultVideoResource(videoId, rids); |
| | | if (defaultVideoResource != null) { |
| | | resourceId = defaultVideoResource.getId(); |
| | | } |
| | | } |
| | | |
| | | //PPTV网页播放 |
| | | if (resourceId != null && Integer.parseInt(resourceId) == PPTVUtil.RESOURCE_ID) { |
| | | JSONObject data = new JSONObject(); |
| | | PPTVSeries series = pptvService.getSeriesDetailByVideoId(videoId); |
| | | String playUrl = PPTVUtil.getPlayUrl(series, series.getSeries().get(0)); |
| | | data.put("videoId", videoId); |
| | | data.put("playUrl", playUrl); |
| | | data.put("pptv", true); |
| | | out.print(JsonUtil.loadTrueJson(data.toString())); |
| | | return; |
| | | } |
| | | |
| | | |
| | | VideoInfo info = videoDeailUtil.getVideoInfo(detailSystem.getId(), videoId, resourceId, resourceList, |
| | | CacheUtil.getMD5Long(resourceList)); |
| | | |
| | | List<VideoType> typeList = classService.getVideoTypeList(info.getId()); |
| | | if (typeList != null && typeList.size() > 0) { |
| | |
| | | if (StringUtil.isNullOrEmpty(vd.getExtraId())) |
| | | vd.setExtraId(vd.getId() + ""); |
| | | } |
| | | System.out.println(info.getPlayPicture()); |
| | | // info.setPicture(VideoPictureUtil.getShowPicture(info, platform, |
| | | // version)); |
| | | |
| | | // 过滤版权视频关键字 |
| | | |
| | | // 统计添加 |
| | | // statisticsService.addStatistics(detailSystem.getId(), videoId); |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | array.add("http://cloud.letv.com"); |
| | | if ((acceptData.getPlatform().equalsIgnoreCase("android") |
| | | && acceptData.getVersion() > 12) || acceptData.getPlatform().equalsIgnoreCase("ios")) { |
| | | for (String st : Constant.POJIE_LIST) |
| | | array.add(st); |
| | | } |
| | | |
| | | long count = commentService.getComment2ListCount(videoId, thirdType); |
| | | if (info != null) |
| | | info.setCommentCount((int) count); |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.File; |
| | | import java.io.PrintWriter; |
| | | import java.util.*; |
| | |
| | | String pwd = request.getParameter("Pwd");// 密码 |
| | | String nickName = request.getParameter("NickName");// 昵称 |
| | | String code = request.getParameter("VerifyCode");// 验证码 |
| | | String portrait = request.getParameter("Portrait");// 验证码 |
| | | |
| | | |
| | | if (StringUtil.isNullOrEmpty(account)) { |
| | |
| | | user.setName(nickName); |
| | | user.setOpenid(account); |
| | | user.setPwd(StringUtil.Md5(pwd)); |
| | | user.setPortrait(savePortrait(request)); |
| | | user.setPortrait(savePortrait(portrait, request.getSession())); |
| | | user.setIpinfo(ip + ":" + port); |
| | | |
| | | String result = userService.registerByEmail(user); |
| | |
| | | String birthDay = request.getParameter("BirthDay");// 生日 |
| | | String personalSign = request.getParameter("PersonalSign");// 个性签名 |
| | | String loginUid = request.getParameter("LoginUid");// 个性签名 |
| | | String portrait = request.getParameter("Portrait"); |
| | | if (StringUtil.isNullOrEmpty(loginUid)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传LoginUid")); |
| | | return; |
| | |
| | | if (user != null) { |
| | | if (!StringUtil.isNullOrEmpty(nickName)) |
| | | user.setName(nickName); |
| | | String potrait = savePortrait(request); |
| | | String potrait = savePortrait(portrait, request.getSession()); |
| | | if (!StringUtil.isNullOrEmpty(potrait)) |
| | | user.setPortrait(potrait); |
| | | if (!StringUtil.isNullOrEmpty(sex)) |
| | |
| | | |
| | | } |
| | | |
| | | private String savePortrait(HttpServletRequest request) { |
| | | String base64 = request.getParameter("Portrait"); |
| | | public static String savePortrait(String base64, HttpSession session) { |
| | | if (StringUtil.isNullOrEmpty(base64)) |
| | | return ""; |
| | | |
| | | String fileName = "portrait_" + System.currentTimeMillis() + ".jpg"; |
| | | // 定义上传路径 |
| | | String path = request.getSession().getServletContext().getRealPath("upload") + "/" + fileName; |
| | | if (!new File(request.getSession().getServletContext().getRealPath("upload") + "/").exists()) |
| | | new File(request.getSession().getServletContext().getRealPath("upload") + "/").mkdirs(); |
| | | String path = session.getServletContext().getRealPath("upload") + "/" + fileName; |
| | | if (!new File(session.getServletContext().getRealPath("upload") + "/").exists()) |
| | | new File(session.getServletContext().getRealPath("upload") + "/").mkdirs(); |
| | | boolean isS = StringUtil.generateImageFromBase64(base64, path); |
| | | if (!isS) |
| | | return ""; |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | public void update(String hql, final Serializable[] params) { |
| | | hibernateTemplate.execute(new HibernateCallback() { |
| | | public Object doInHibernate(Session session) throws HibernateException { |
| | | Query query = session.createQuery(hql); |
| | | if (params != null) |
| | | for (int i = 0; i < params.length; i++) { |
| | | query.setParameter(i, params[i]); |
| | | } |
| | | query.executeUpdate(); |
| | | return null; |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public List<T> list(String hql) { |
| | | return (List<T>) hibernateTemplate.find(hql); |
| | |
| | | String hql = "select count(*) " + hqlStr.substring(fromIndex); |
| | | |
| | | Query query = session.createQuery(hql); |
| | | if (wheres != null) |
| | | for (int i = 0; i < wheres.length; i++) { |
| | | query.setParameter(i, wheres[i]); |
| | | } |
| | |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import com.yeshi.buwan.domain.user.LoginUser; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Repository |
| | | public class LoginUserDao extends BaseDao<LoginUser> { |
| | | |
| | | |
| | | public void updateSelective(LoginUser loginUser) { |
| | | |
| | | String hql = "update LoginUser u set "; |
| | | List<Serializable> params = new ArrayList<>(); |
| | | List<String> sets = new ArrayList<>(); |
| | | if (loginUser.getPhone() != null) { |
| | | sets.add("u.phone=?"); |
| | | params.add(loginUser.getPhone()); |
| | | } |
| | | |
| | | if (loginUser.getName() != null) { |
| | | sets.add("u.name=?"); |
| | | params.add(loginUser.getName()); |
| | | } |
| | | |
| | | |
| | | if (loginUser.getPortrait() != null) { |
| | | sets.add("u.portrait=?"); |
| | | params.add(loginUser.getPortrait()); |
| | | } |
| | | |
| | | if (loginUser.getSex() != null) { |
| | | sets.add("u.sex=?"); |
| | | params.add(loginUser.getSex()); |
| | | } |
| | | |
| | | if (loginUser.getSign() != null) { |
| | | sets.add("u.sign=?"); |
| | | params.add(loginUser.getSign()); |
| | | } |
| | | |
| | | if (loginUser.getBirthday() != null) { |
| | | sets.add("u.birthday=?"); |
| | | params.add(loginUser.getBirthday()); |
| | | } |
| | | |
| | | if (loginUser.getWxOpenId() != null) { |
| | | sets.add("u.wxOpenId=?"); |
| | | params.add(loginUser.getWxOpenId()); |
| | | } |
| | | |
| | | if (loginUser.getWxUnionId() != null) { |
| | | sets.add("u.wxUnionId=?"); |
| | | params.add(loginUser.getWxUnionId()); |
| | | } |
| | | |
| | | if (loginUser.getQqOpenId() != null) { |
| | | sets.add("u.qqOpenId=?"); |
| | | params.add(loginUser.getQqOpenId()); |
| | | } |
| | | |
| | | if (sets.size() > 0) { |
| | | params.add(loginUser.getId()); |
| | | Serializable[] ps = new Serializable[params.size()]; |
| | | params.toArray(ps); |
| | | update(hql + StringUtil.concat(sets, ",") + " where u.id=?", ps); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | update.set("wxSex", bean.getWxSex()); |
| | | } |
| | | |
| | | if (bean.getPptvUid() != null) { |
| | | update.set("pptvUid", bean.getPptvUid()); |
| | | } |
| | | |
| | | if (bean.getPptvOpenId() != null) { |
| | | update.set("pptvOpenId", bean.getPptvOpenId()); |
| | | } |
| | | |
| | | if (bean.getCreateTime() != null) { |
| | | update.set("createTime", bean.getCreateTime()); |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.dao.vip; |
| | | |
| | | import com.yeshi.buwan.dao.base.BaseDao; |
| | | import com.yeshi.buwan.domain.vip.UserVIPInfo; |
| | | import com.yeshi.buwan.domain.vip.VIPOrderRecord; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Repository |
| | | public class UserVIPInfoDao extends BaseDao<UserVIPInfo> { |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.dao.vip; |
| | | |
| | | import com.yeshi.buwan.dao.base.BaseDao; |
| | | import com.yeshi.buwan.domain.vip.VIPOrderRecord; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Repository |
| | | public class VIPOrderRecordDao extends BaseDao<VIPOrderRecord> { |
| | | |
| | | |
| | | private String getHql(DaoQuery daoQuery) { |
| | | |
| | | String hql = "from VIPOrderRecord r where 1=1"; |
| | | |
| | | if (daoQuery.state != null) { |
| | | hql += " and r.state=" + daoQuery.state; |
| | | } |
| | | |
| | | if (daoQuery.uid != null) { |
| | | hql += " and r.uid=" + daoQuery.uid; |
| | | } |
| | | return hql; |
| | | } |
| | | |
| | | |
| | | public List<VIPOrderRecord> list(DaoQuery daoQuery) { |
| | | return super.list(getHql(daoQuery), daoQuery.start, daoQuery.count, null); |
| | | } |
| | | |
| | | |
| | | public long count(DaoQuery daoQuery) { |
| | | return super.getCount(getHql(daoQuery),null); |
| | | } |
| | | |
| | | public static class DaoQuery { |
| | | public Integer state; |
| | | public String uid; |
| | | public int start; |
| | | public int count; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.dao.vip; |
| | | |
| | | import com.yeshi.buwan.dao.base.MongodbBaseDao; |
| | | import com.yeshi.buwan.domain.vip.VIPPrice; |
| | | import javafx.print.Collation; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Repository |
| | | public class VIPPriceDao extends MongodbBaseDao<VIPPrice> { |
| | | public List<VIPPrice> listAll(Boolean show) { |
| | | Query query = new Query(); |
| | | if (show != null) |
| | | query.addCriteria(Criteria.where("show").is(show)); |
| | | query.with(new Sort(new Sort.Order(Sort.Direction.ASC, "order"))); |
| | | return findList(query); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | public final static int STATE_NORMAL=0; |
| | | public final static int STATE_UNREGISTER=1;//已经注销 |
| | | |
| | | public final static int LOGIN_TYPE_QQ=1; |
| | | public final static int LOGIN_TYPE_WX=2; |
| | | public final static int LOGIN_TYPE_EMAIL=3; |
| | | public final static int LOGIN_TYPE_PHONE=4; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | import org.springframework.data.annotation.Id; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | import org.springframework.data.mongodb.core.mapping.Field; |
| | | |
| | | import java.util.Date; |
| | | |
| | |
| | | private String birthday; |
| | | private String sign; |
| | | |
| | | private String email; |
| | | |
| | | private String qqOpenId; |
| | | private String qqNickName; |
| | | private String qqPortrait; |
| | |
| | | |
| | | //PPTV的用户ID |
| | | private String pptvUid; |
| | | private String pptvOpenId; |
| | | |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | public String getEmail() { |
| | | return email; |
| | | } |
| | | |
| | | public void setEmail(String email) { |
| | | this.email = email; |
| | | } |
| | | |
| | | public String getPptvUid() { |
| | | return pptvUid; |
| | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public String getPptvOpenId() { |
| | | return pptvOpenId; |
| | | } |
| | | |
| | | public void setPptvOpenId(String pptvOpenId) { |
| | | this.pptvOpenId = pptvOpenId; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.domain.vip; |
| | | |
| | | import java.util.Date; |
| | | |
| | | public class UserVIPInfo { |
| | | private String uid; |
| | | //到期时间 |
| | | private Date expireDate; |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | public String getUid() { |
| | | return uid; |
| | | } |
| | | |
| | | public void setUid(String uid) { |
| | | this.uid = uid; |
| | | } |
| | | |
| | | public Date getExpireDate() { |
| | | return expireDate; |
| | | } |
| | | |
| | | public void setExpireDate(Date expireDate) { |
| | | this.expireDate = expireDate; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | } |
| | |
| | | //状态 |
| | | private Integer state; |
| | | //类型 |
| | | private VIPPrice.VIPPriceType type; |
| | | private VIPPriceType type; |
| | | //资金 |
| | | private BigDecimal money; |
| | | //支付方式 |
| | |
| | | this.state = state; |
| | | } |
| | | |
| | | public VIPPrice.VIPPriceType getType() { |
| | | public VIPPriceType getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(VIPPrice.VIPPriceType type) { |
| | | public void setType(VIPPriceType type) { |
| | | this.type = type; |
| | | } |
| | | |
| | |
| | | package com.yeshi.buwan.domain.vip; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | |
| | | @Document(collection = "vipPrice") |
| | | public class VIPPrice { |
| | | public enum VIPPriceType { |
| | | week("周会员"), month("包月"), season("包季"), year("包年"); |
| | | |
| | | private String name; |
| | | |
| | | private VIPPriceType(String name) { |
| | | this.name = name; |
| | | } |
| | | } |
| | | |
| | | @Expose |
| | | private String id; |
| | | @Expose |
| | | private VIPPriceType type; |
| | | @Expose |
| | | private BigDecimal price; |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | //PPTV的vip商品类型 |
| | | private String pptvGoodsNo; |
| | | private Boolean show; |
| | | |
| | | //排序值 |
| | | private Integer order; |
| | | |
| | | |
| | | public Boolean getShow() { |
| | | return show; |
| | | } |
| | | |
| | | public void setShow(Boolean show) { |
| | | this.show = show; |
| | | } |
| | | |
| | | |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public VIPPriceType getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(VIPPriceType type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public BigDecimal getPrice() { |
| | | return price; |
| | | } |
| | | |
| | | public void setPrice(BigDecimal price) { |
| | | this.price = price; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public void setUpdateTime(Date updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public Integer getOrder() { |
| | | return order; |
| | | } |
| | | |
| | | public void setOrder(Integer order) { |
| | | this.order = order; |
| | | } |
| | | |
| | | public String getPptvGoodsNo() { |
| | | return pptvGoodsNo; |
| | | } |
| | | |
| | | public void setPptvGoodsNo(String pptvGoodsNo) { |
| | | this.pptvGoodsNo = pptvGoodsNo; |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.domain.vip; |
| | | |
| | | public enum VIPPriceType { |
| | | day("包天"), week("包周"), month("包月"), season("包季"), halfYear("半年"), year("包年"); |
| | | |
| | | private String name; |
| | | |
| | | private VIPPriceType(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getName() { |
| | | return this.name; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.exception.vip; |
| | | |
| | | public class VIPException extends Exception { |
| | | |
| | | private int code; |
| | | private String msg; |
| | | |
| | | public VIPException(int code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.yeshi.buwan.pptv; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.buwan.pptv.entity.PPTVProgram; |
| | | import com.yeshi.buwan.pptv.entity.PPTVSeries; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.TimeUtil; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.commons.httpclient.HttpClient; |
| | | import org.apache.commons.httpclient.NameValuePair; |
| | | import org.apache.commons.httpclient.methods.PostMethod; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.yeshi.utils.HttpUtil; |
| | | |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | |
| | | public class PPTVApiUtil { |
| | | static Logger logger = LoggerFactory.getLogger(PPTVApiUtil.class); |
| | | |
| | | private final static String APP_KEY = "eb324ec4439e193c38fd8d7fdbdae9af"; |
| | | private final static String APP_SECRET = "163cf4fa3780091e61a48c6abb6246d3"; |
| | | private final static String CHANNEL_ID = "111111"; |
| | | //正式 |
| | | public final static String APP_KEY = "9227024a6c540a7f8571d75c469da9ba"; |
| | | private final static String APP_SECRET = "f3e922ac18f9da6c816d3012f8b7e575"; |
| | | |
| | | //测试 |
| | | // private final static String APP_KEY = "eb324ec4439e193c38fd8d7fdbdae9af"; |
| | | // private final static String APP_SECRET = "163cf4fa3780091e61a48c6abb6246d3"; |
| | | |
| | | |
| | | public final static String CHANNEL_ID = "253350"; |
| | | private final static String CANAL = "buwan"; |
| | | |
| | | private static String getBase64(String str) { |
| | | String st = StringUtil.getBase64(str).replace("\r\n", ""); |
| | |
| | | } |
| | | |
| | | private static List<PPTVSeries> getList(String method) { |
| | | String result = baseRequest(null, method); |
| | | String result = baseRequest(new HashMap<>(), method); |
| | | logger.error(result); |
| | | List<String> list = parseUrls(result); |
| | | List<PPTVSeries> totalList = new ArrayList<>(); |
| | |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("uid", uid); |
| | | String result = baseRequest("https://coapi.pptv.com/coapi-web/api/http/sopRequest", params, "pptv.channel.openid.get"); |
| | | logger.info(result); |
| | | System.out.println(result); |
| | | JSONObject resultJSON = JSONObject.fromObject(result); |
| | | return resultJSON.optJSONObject("response").optJSONObject("body").optString("openId"); |
| | | } |
| | |
| | | */ |
| | | public static void login(String code) { |
| | | String url = String.format("https://coapi.pptv.com/coapi-web/api/getUserToken/%s/%s.htm", APP_KEY, code); |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("code", code); |
| | | String result = baseRequest(url, params, ""); |
| | | logger.info(result); |
| | | String result = HttpUtil.get(url); |
| | | |
| | | System.out.println(result); |
| | | // JSONObject resultJSON = JSONObject.fromObject(result); |
| | | // return resultJSON.optJSONObject("response").optJSONObject("body").optString("openId"); |
| | | } |
| | |
| | | import com.yeshi.buwan.domain.VideoType; |
| | | import com.yeshi.buwan.pptv.entity.PPTVProgram; |
| | | import com.yeshi.buwan.pptv.entity.PPTVSeries; |
| | | import com.yeshi.buwan.util.AESUtil; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.video.VideoConstant; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取pptv的用户ID |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public static String getPPTVUid(String uid) { |
| | | return "buwan_" + uid; |
| | | } |
| | | |
| | | /** |
| | | * 获取pptvcode |
| | | * |
| | | * @param pptvUid |
| | | * @return |
| | | */ |
| | | public static String getPPTVCode(String pptvUid) { |
| | | if (StringUtil.isNullOrEmpty(pptvUid)) |
| | | return null; |
| | | return AESUtil.encrypt(pptvUid + "#" + System.currentTimeMillis()); |
| | | } |
| | | |
| | | public static String getUidFromPPTVUid(String pptvUid) { |
| | | return pptvUid.split("_")[1]; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 解密PPTVCode |
| | | * |
| | | * @param code |
| | | * @return |
| | | */ |
| | | public static PPTVCodeInfo decryptPPTVCode(String code) { |
| | | String info = AESUtil.decrypt(code); |
| | | if (StringUtil.isNullOrEmpty(info)) { |
| | | return null; |
| | | } else { |
| | | String[] sts = info.split("#"); |
| | | if (sts.length != 2) |
| | | return null; |
| | | PPTVCodeInfo codeInfo = new PPTVCodeInfo(); |
| | | codeInfo.pptvUid = sts[0]; |
| | | codeInfo.time = Long.parseLong(sts[1]); |
| | | return codeInfo; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取播放链接 |
| | | * |
| | | * @param series |
| | | * @param program |
| | | * @return |
| | | */ |
| | | public static String getPlayUrl(PPTVSeries series, PPTVProgram program) { |
| | | //programtype 电影-3 其他-2 |
| | | return String.format("https://acmd.api.pptv.com/2021/bwysdqmovie_thrid_h5.html?cid=%s&vid=%s&programtype=%s", series.getSeriesCode(), program.getProgramCode(), series.getProgramType().contains("电影") ? 3 : 2); |
| | | } |
| | | |
| | | |
| | | public static class PPTVCodeInfo { |
| | | public String pptvUid; |
| | | public long time; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.pptv; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * PPTV会员 |
| | | */ |
| | | @Component |
| | | public class PPTVVipManager { |
| | | |
| | | |
| | | /** |
| | | * 购买VIP |
| | | */ |
| | | public void buyVIP() { |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.yeshi.buwan.domain.user.LoginUser; |
| | | import com.yeshi.buwan.domain.user.LoginUserExtra; |
| | | import com.yeshi.buwan.exception.LoginUserException; |
| | | import com.yeshi.buwan.pptv.PPTVUtil; |
| | | import com.yeshi.buwan.service.inter.LoginUserService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | loginUserDao.update(user); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void bindQQ(String loginUid, String openId, String nickName, String portrait) throws LoginUserException { |
| | | |
| | |
| | | } |
| | | |
| | | LoginUser other = getLoginUserByQQOpenId(user.getSystemId(), openId); |
| | | if (other != null) { |
| | | if (other != null && !other.getId().equalsIgnoreCase(loginUid)) { |
| | | throw new LoginUserException("QQ已被其他账户绑定"); |
| | | } |
| | | LoginUser update = new LoginUser(); |
| | | update.setId(loginUid); |
| | | update.setQqOpenId(openId); |
| | | loginUserDao.updateSelective(update); |
| | | |
| | | user.setQqOpenId(openId); |
| | | loginUserDao.update(user); |
| | | |
| | | LoginUserExtra extra = new LoginUserExtra(); |
| | | LoginUserExtra extra = loginUserExtraDao.get(loginUid); |
| | | if (extra == null) { |
| | | extra = new LoginUserExtra(); |
| | | extra.setId(loginUid); |
| | | } |
| | | extra.setQqNickName(nickName); |
| | | extra.setQqOpenId(openId); |
| | | extra.setQqPortrait(portrait); |
| | | if (loginUserExtraDao.get(loginUid) == null) { |
| | | if (extra.getId() == null) { |
| | | initExtra(extra); |
| | | } else { |
| | | loginUserExtraDao.updateSelective(extra); |
| | | loginUserExtraDao.save(extra); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void bindWX(String loginUid, WeiXinUser weiXinUser) throws LoginUserException { |
| | | LoginUser user = getLoginUser(loginUid); |
| | |
| | | } |
| | | |
| | | LoginUser other = getLoginUserByWxUnionId(user.getSystemId(), weiXinUser.getUnionid()); |
| | | if (other != null) { |
| | | if (other != null && !other.getId().equalsIgnoreCase(loginUid)) { |
| | | throw new LoginUserException("微信已被其他账户绑定"); |
| | | } |
| | | user.setWxOpenId(weiXinUser.getOpenid()); |
| | | user.setWxUnionId(weiXinUser.getUnionid()); |
| | | loginUserDao.update(user); |
| | | LoginUser update = new LoginUser(); |
| | | update.setId(loginUid); |
| | | update.setWxOpenId(weiXinUser.getOpenid()); |
| | | update.setWxUnionId(weiXinUser.getUnionid()); |
| | | loginUserDao.updateSelective(update); |
| | | |
| | | LoginUserExtra extra = new LoginUserExtra(); |
| | | LoginUserExtra extra = null;//loginUserExtraDao.get(loginUid); |
| | | if (extra == null) { |
| | | extra = new LoginUserExtra(); |
| | | extra.setId(loginUid); |
| | | } |
| | | extra.setWxNickName(weiXinUser.getNickname()); |
| | | extra.setWxOpenId(weiXinUser.getOpenid()); |
| | | extra.setWxUnionId(weiXinUser.getUnionid()); |
| | |
| | | if (loginUserExtraDao.get(loginUid) == null) { |
| | | initExtra(extra); |
| | | } else { |
| | | extra.setUpdateTime(new Date()); |
| | | loginUserExtraDao.updateSelective(extra); |
| | | } |
| | | |
| | | System.out.println("12213"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public LoginUserExtra getExtra(String uid) { |
| | | return loginUserExtraDao.get(uid); |
| | | } |
| | | |
| | | @Override |
| | | public LoginUserExtra initExtra(String uid) { |
| | | LoginUser user = getLoginUser(uid); |
| | | if (user == null) |
| | | return null; |
| | | LoginUserExtra extra = new LoginUserExtra(); |
| | | extra.setId(uid); |
| | | extra.setCreateTime(new Date()); |
| | | //之前的用户邮箱登录 |
| | | if (user.getLoginType() == LoginUser.LOGIN_TYPE_QQ) { |
| | | user.setQqOpenId(user.getOpenid()); |
| | | extra.setQqOpenId(user.getOpenid()); |
| | | extra.setQqPortrait(user.getPortrait()); |
| | | } else if (user.getLoginType() == LoginUser.LOGIN_TYPE_EMAIL) { |
| | | user.setEmail(user.getOpenid()); |
| | | extra.setEmail(user.getOpenid()); |
| | | } else if (user.getLoginType() == LoginUser.LOGIN_TYPE_WX) { |
| | | user.setWxOpenId(user.getOpenid()); |
| | | extra.setWxOpenId(user.getOpenid()); |
| | | extra.setWxPortrait(user.getPortrait()); |
| | | } |
| | | |
| | | extra.setBirthday(user.getBirthday()); |
| | | extra.setSex(user.getSex()); |
| | | extra.setSign(user.getSign()); |
| | | extra.setIpinfo(user.getIpinfo()); |
| | | extra.setDevice(user.getDevice()); |
| | | extra.setPptvUid(PPTVUtil.getPPTVUid(uid)); |
| | | //TODO 初始化附加信息 |
| | | loginUserDao.update(user); |
| | | loginUserExtraDao.save(extra); |
| | | return extra; |
| | | } |
| | | |
| | | @Override |
| | | public void updateSelectiveByPrimaryKey(LoginUser loginUser) { |
| | | loginUserDao.updateSelective(loginUser); |
| | | } |
| | | |
| | | @Override |
| | | public void updateSelectiveByPrimaryKey(LoginUserExtra extra) { |
| | | loginUserExtraDao.updateSelective(extra); |
| | | } |
| | | } |
| | |
| | | package com.yeshi.buwan.service.imp; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | import com.yeshi.buwan.dao.VideoResourceMapExtraInfoDao; |
| | | import com.yeshi.buwan.dao.juhe.iqiyi.VideoIqiyiDao; |
| | |
| | | return getResourceList(videoInfoList); |
| | | } |
| | | |
| | | /** |
| | | * 获取默认的源 |
| | | * |
| | | * @param videoId |
| | | * @param avaiableResourceIds |
| | | * @return |
| | | */ |
| | | public VideoResource getDefaultVideoResource(String videoId, Set<Long> avaiableResourceIds) { |
| | | List<ResourceVideo> resourceVideoList = resourceVideoDao.list("FROM ResourceVideo rv where rv.video.id=? order by rv.resource.orderby desc", videoId); |
| | | //删除无用来源 |
| | | for (int i = 0; i < resourceVideoList.size(); i++) { |
| | | if (!avaiableResourceIds.contains(Long.parseLong(resourceVideoList.get(i).getResource().getId())) || resourceVideoList.get(i).getResource() == null) { |
| | | resourceVideoList.remove(i--); |
| | | } |
| | | } |
| | | //排序 |
| | | |
| | | List<VideoResource> resourceList = new ArrayList<>(); |
| | | |
| | | for (ResourceVideo rv : resourceVideoList) { |
| | | resourceList.add(rv.getResource()); |
| | | } |
| | | |
| | | Comparator<VideoResource> cm = new Comparator<VideoResource>() { |
| | | @Override |
| | | public int compare(VideoResource o1, VideoResource o2) { |
| | | return o2.getOrderby() - o1.getOrderby(); |
| | | } |
| | | }; |
| | | |
| | | Collections.sort(resourceList, cm); |
| | | if (resourceList.size() > 0) |
| | | return resourceList.get(0); |
| | | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据视频ID与ResourceId查询 |
| | |
| | | private RedisManager redisManager; |
| | | |
| | | @Override |
| | | public void sendBindVCode(Long uid, String phone, int codeLength) throws SMSException { |
| | | public void sendBindVCode(String uid, String phone, int codeLength) throws SMSException { |
| | | String limitKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLIMIT, uid + ""); |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSVCode, phone + "-" + 0); |
| | | if (StringUtil.isNullOrEmpty(redisManager.getCommonString(limitKey))) |
| | | if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(limitKey))) |
| | | throw new SMSException(1001, "请过60秒再试"); |
| | | |
| | | |
| | | String msgCode = StringUtil.getVerifyCode(codeLength); |
| | | String msgCode = StringUtil.getNumberVerifyCode(codeLength); |
| | | |
| | | TencentSMSConfig tencentSMSConfig = Constant.tencentSMSConfig; |
| | | |
| | |
| | | throw new SMSException(result.result, "短信发送失败"); |
| | | } |
| | | //保存验证码 |
| | | redisManager.cacheCommonString(key, msgCode, 60 * 2); |
| | | redisManager.cacheCommonString(key, msgCode, 60 * 5); |
| | | //60s后再发送 |
| | | redisManager.cacheCommonString(limitKey, "1", 60); |
| | | } |
| | |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSVCode, phone + "-" + 0); |
| | | String cacheCode = redisManager.getCommonString(key); |
| | | if (cacheCode != null && cacheCode.equalsIgnoreCase(code)) { |
| | | redisManager.removeCommonString(key); |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public PPTVSeries getSeriesDetailByVideoId(String videoId) { |
| | | VideoPPTVMap map = videoPPTVMapDao.get(videoId); |
| | | if (map == null) { |
| | | return null; |
| | | } |
| | | return getSeriesDetail(map.getInfoId()); |
| | | } |
| | | |
| | | /** |
| | | * 删除剧集 |
| | | * |
New file |
| | |
| | | package com.yeshi.buwan.service.imp.vip; |
| | | |
| | | import com.yeshi.buwan.dao.vip.VIPPriceDao; |
| | | import com.yeshi.buwan.domain.vip.VIPPrice; |
| | | import com.yeshi.buwan.exception.vip.VIPException; |
| | | import com.yeshi.buwan.service.inter.vip.VIPPriceService; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class VIPPriceServiceImpl implements VIPPriceService { |
| | | |
| | | @Resource |
| | | private VIPPriceDao vipPriceDao; |
| | | |
| | | @Override |
| | | public void addPrice(VIPPrice price) throws VIPException { |
| | | if (price == null || price.getPrice() == null || price.getType() == null) { |
| | | throw new VIPException(1, "参数不完整"); |
| | | } |
| | | |
| | | if (price.getCreateTime() == null) { |
| | | price.setCreateTime(new Date()); |
| | | } |
| | | |
| | | if (price.getOrder() == null) { |
| | | price.setOrder(price.getPrice().multiply(new BigDecimal(100)).intValue()); |
| | | } |
| | | |
| | | |
| | | price.setId(StringUtil.Md5(price.getType().name())); |
| | | vipPriceDao.save(price); |
| | | } |
| | | |
| | | @Override |
| | | public List<VIPPrice> listValidPrice() { |
| | | return vipPriceDao.listAll(true); |
| | | } |
| | | |
| | | @Override |
| | | public VIPPrice selectByPrimaryKey(String id) { |
| | | return vipPriceDao.get(id); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.service.imp.vip; |
| | | |
| | | 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.vip.VIPException; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | import org.hibernate.HibernateException; |
| | | import org.hibernate.LockMode; |
| | | import org.hibernate.Query; |
| | | import org.hibernate.Session; |
| | | import org.springframework.orm.hibernate4.HibernateCallback; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class VIPServiceImpl implements VIPService { |
| | | |
| | | @Resource |
| | | private VIPOrderRecordDao vipOrderRecordDao; |
| | | |
| | | @Resource |
| | | private UserVIPInfoDao userVIPInfoDao; |
| | | |
| | | |
| | | /** |
| | | * 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 void paySuccess(final String id, int payWay, BigDecimal payMoney, Date payTime) throws VIPException { |
| | | VIPException exception = (VIPException) vipOrderRecordDao.excute(new HibernateCallback() { |
| | | @Override |
| | | public VIPException doInHibernate(Session session) throws HibernateException { |
| | | //修改记录 |
| | | Query query = session.createQuery("from VIPOrderRecord as r where r.id=? ").setParameter(0, id); |
| | | query.setLockMode("r", LockMode.UPGRADE); |
| | | List<VIPOrderRecord> list = query.list(); |
| | | |
| | | if (list != null && list.size() > 0) { |
| | | if (list.get(0).getState() == VIPOrderRecord.STATE_PAY) |
| | | return new VIPException(1, "订单已经支付"); |
| | | |
| | | Date[] expireDate = addExpireTime(session, list.get(0).getUid(), payTime, list.get(0).getType()); |
| | | if (expireDate == null) { |
| | | return new VIPException(2, "添加用户会员时间出错"); |
| | | } |
| | | session.createQuery("update VIPOrderRecord r set r.payWay=?,r.payMoney=?,r.payTime=?,r.updateTime=?,r.vipStartTime=?,r.vipEndTime=?,r.state=? where r.id=? ") |
| | | .setParameter(0, payWay) |
| | | .setParameter(1, payMoney) |
| | | .setParameter(2, payTime) |
| | | .setParameter(3, new Date()) |
| | | .setParameter(4, expireDate[0]) |
| | | .setParameter(5, expireDate[1]) |
| | | .setParameter(6, VIPOrderRecord.STATE_PAY) |
| | | .setParameter(7, id).executeUpdate(); |
| | | } else { |
| | | return new VIPException(10, "订单不存在"); |
| | | } |
| | | return null; |
| | | } |
| | | }); |
| | | |
| | | if (exception != null) |
| | | throw exception; |
| | | } |
| | | |
| | | /** |
| | | * 续期 |
| | | * |
| | | * @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.createQuery("from UserVIPInfo i where i.uid=?").setParameter(0, uid).setLockMode("i", LockMode.UPGRADE).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(), 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); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 初始化附加信息 |
| | | * |
| | | * @param extra |
| | | */ |
| | | public void initExtra(LoginUserExtra extra); |
| | |
| | | */ |
| | | public void bindWX(String loginUid, WeiXinUser info) throws LoginUserException; |
| | | |
| | | |
| | | /** |
| | | * 获取附加信息 |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | public LoginUserExtra getExtra(String uid); |
| | | |
| | | |
| | | /** |
| | | * 初始化附加信息 |
| | | * |
| | | * @param uid |
| | | */ |
| | | public LoginUserExtra initExtra(String uid); |
| | | |
| | | |
| | | /** |
| | | * 根据主键更新 |
| | | * |
| | | * @param loginUser |
| | | */ |
| | | public void updateSelectiveByPrimaryKey(LoginUser loginUser); |
| | | |
| | | |
| | | /** |
| | | * 根据主键更新 |
| | | * @param extra |
| | | */ |
| | | public void updateSelectiveByPrimaryKey(LoginUserExtra extra); |
| | | |
| | | } |
| | |
| | | * @param codeLength |
| | | * @throws SMSException |
| | | */ |
| | | public void sendBindVCode(Long uid, String phone, int codeLength) throws SMSException; |
| | | public void sendBindVCode(String uid, String phone, int codeLength) throws SMSException; |
| | | |
| | | /** |
| | | * 验证码是否在正确 |
| | |
| | | public void save(PPTVSeries series); |
| | | |
| | | |
| | | /** |
| | | * 根据视频ID查询专辑详情 |
| | | * |
| | | * @param videoId |
| | | * @return |
| | | */ |
| | | public PPTVSeries getSeriesDetailByVideoId(String videoId); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.service.inter.vip; |
| | | |
| | | import com.yeshi.buwan.domain.vip.VIPPrice; |
| | | import com.yeshi.buwan.exception.vip.VIPException; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface VIPPriceService { |
| | | |
| | | /** |
| | | * 添加套餐 |
| | | * |
| | | * @param price |
| | | */ |
| | | public void addPrice(VIPPrice price) throws VIPException; |
| | | |
| | | |
| | | /** |
| | | * 拉取列表 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<VIPPrice> listValidPrice(); |
| | | |
| | | |
| | | /** |
| | | * 主键查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public VIPPrice selectByPrimaryKey(String id); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.service.inter.vip; |
| | | |
| | | import com.yeshi.buwan.domain.vip.UserVIPInfo; |
| | | import com.yeshi.buwan.domain.vip.VIPOrderRecord; |
| | | import com.yeshi.buwan.exception.vip.VIPException; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | public interface VIPService { |
| | | |
| | | /** |
| | | * 添加记录 |
| | | * |
| | | * @param record |
| | | */ |
| | | public void addVIPRecord(VIPOrderRecord record) throws VIPException; |
| | | |
| | | |
| | | /** |
| | | * 支付成功 |
| | | * |
| | | * @param id |
| | | * @param payMoney |
| | | * @param payTime |
| | | * @throws VIPException |
| | | */ |
| | | public void paySuccess(String id, int payWay, BigDecimal payMoney, Date payTime) throws VIPException; |
| | | |
| | | |
| | | /** |
| | | * 获取会员信息 |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | 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); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.util; |
| | | |
| | | import com.google.gson.Gson; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | import javax.persistence.Entity; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Entity |
| | | public class JsonUtilV2 { |
| | | |
| | | private static Gson baseGson = new Gson(); |
| | | |
| | | public static String loadTrueJson(String data) { |
| | | JSONObject root = new JSONObject(); |
| | | root.put("code", 0); |
| | | root.put("data", data); |
| | | root.put("msg", ""); |
| | | String st = DESUtil.encode(root.toString()); |
| | | return st; |
| | | } |
| | | |
| | | public static String loadFalseJson(int code, String msg) { |
| | | JSONObject root = new JSONObject(); |
| | | root.put("code", code); |
| | | root.put("msg", msg); |
| | | String st = DESUtil.encode(root.toString()); |
| | | return st; |
| | | } |
| | | |
| | | public static String loadFalseJson(String msg) { |
| | | return loadFalseJson(1, msg); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | list.add(Long.parseLong(vr.getId())); |
| | | else if (resourceName.indexOf("风行") > -1) |
| | | list.add(Long.parseLong(vr.getId())); |
| | | else if (resourceName.indexOf("PPTV") > -1) { |
| | | //3.8.7以后的Android支持 |
| | | if (versionCode >= 105) { |
| | | list.add(Long.parseLong(vr.getId())); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } else if ("ios".equalsIgnoreCase(platform)) { |
| | | if (versionCode < 14) { |
| | |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public void increase(String key,int s) { |
| | | Jedis jedis = getJedis(); |
| | | try { |
| | | jedis.incr(key); |
| | | jedis.expire(key, s); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | |
| | | public void expire(String key, int seconds) { |
| | | Jedis jedis = getJedis(); |
| | | try { |
| | |
| | | * @return |
| | | */ |
| | | public static String getVerifyCode() { |
| | | return getNumberVerifyCode(6); |
| | | } |
| | | |
| | | public static String getNumberVerifyCode(int number) { |
| | | String sts = "0123456789"; |
| | | String code = ""; |
| | | for (int i = 0; i < 6; i++) { |
| | | for (int i = 0; i < number; i++) { |
| | | int p = (int) (Math.random() * 10); |
| | | code += sts.charAt(p); |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.util.factory.vo; |
| | | |
| | | import com.yeshi.buwan.domain.user.LoginUser; |
| | | import com.yeshi.buwan.domain.user.LoginUserExtra; |
| | | import com.yeshi.buwan.domain.vip.UserVIPInfo; |
| | | import com.yeshi.buwan.pptv.PPTVUtil; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.vo.client.user.UserInfoVO; |
| | | |
| | | public class UserInfoVOFactory { |
| | | |
| | | |
| | | public static UserInfoVO create(LoginUser user, LoginUserExtra extra, UserVIPInfo vipInfo) { |
| | | UserInfoVO vo = new UserInfoVO(); |
| | | vo.setId(user.getId()); |
| | | vo.setPptvCode(PPTVUtil.getPPTVCode(extra.getPptvUid())); |
| | | vo.setQqNickName(extra.getQqNickName()); |
| | | vo.setBirthday(extra.getBirthday()); |
| | | vo.setEmail(getHiddenEmail(extra.getEmail())); |
| | | vo.setNickName(user.getName()); |
| | | vo.setPhone(getHiddenPhone(user.getPhone())); |
| | | vo.setPortrait(user.getPortrait()); |
| | | vo.setQqOpenId(getHiddenOpenId(extra.getQqOpenId())); |
| | | vo.setSex(extra.getSex()); |
| | | vo.setSign(extra.getSign()); |
| | | if (vipInfo != null && vipInfo.getExpireDate() != null) |
| | | vo.setVipExpireTime(vipInfo.getExpireDate().getTime()); |
| | | vo.setWxName(extra.getWxNickName()); |
| | | vo.setWxUnionId(getHiddenOpenId(extra.getWxUnionId())); |
| | | return vo; |
| | | } |
| | | |
| | | |
| | | private static String getHiddenPhone(String phone) { |
| | | if (StringUtil.isNullOrEmpty(phone)) { |
| | | return null; |
| | | } |
| | | if (phone.length() < 11) { |
| | | return phone; |
| | | } |
| | | return phone.substring(0, 3) + "****" + phone.substring(phone.length() - 4, phone.length()); |
| | | } |
| | | |
| | | private static String getHiddenOpenId(String openId) { |
| | | if (StringUtil.isNullOrEmpty(openId)) { |
| | | return null; |
| | | } |
| | | if (openId.length() < 11) { |
| | | return openId; |
| | | } |
| | | return openId.substring(0, 4) + "****" + openId.substring(openId.length() - 4, openId.length() - 4); |
| | | } |
| | | |
| | | private static String getHiddenEmail(String email) { |
| | | if (StringUtil.isNullOrEmpty(email)) { |
| | | return null; |
| | | } |
| | | int index = email.indexOf("@"); |
| | | if (index < 0) |
| | | return null; |
| | | |
| | | String prefix = email.substring(0, index); |
| | | if (prefix.length() < 2) |
| | | return prefix.substring(0, 1) + "**" + email.substring(index, email.length()); |
| | | return prefix.substring(0, 2) + "**" + email.substring(index, email.length()); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.yeshi.buwan.util.user; |
| | | |
| | | import com.alipay.api.AlipayApiException; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.yeshi.utils.alipay.AlipayH5PayUtil; |
| | | import org.yeshi.utils.entity.alipay.AlipayAppInfo; |
| | | import org.yeshi.utils.entity.wx.WXAPPInfo; |
| | | import org.yeshi.utils.entity.wx.WXPlaceOrderParams; |
| | | import org.yeshi.utils.wx.WXPayV3Util; |
| | | |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.Properties; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取微信app |
| | | * |
| | | * @return |
| | | */ |
| | | |
| | | public static WXAPPInfo getWXAPP() { |
| | | String privateKey = ""; |
| | | try { |
| | | String content = IOUtils.toString(VipUtil.class.getClassLoader().getResourceAsStream("wx/apiclient_key.pem")); |
| | | privateKey = content.replace("-----BEGIN PRIVATE KEY-----", "") |
| | | .replace("-----END PRIVATE KEY-----", "") |
| | | .replaceAll("\\s+", ""); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | |
| | | Properties properties = new Properties(); |
| | | try { |
| | | properties.load(VipUtil.class.getClassLoader().getResourceAsStream("wxpay.properties")); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String appId = properties.getProperty("app_id"); |
| | | String mchId = properties.getProperty("mch_id"); |
| | | String mchSerialNo = properties.getProperty("mch_serial_no"); |
| | | String apiV3Key = properties.getProperty("api_v3_key"); |
| | | |
| | | WXAPPInfo app = new WXAPPInfo(appId, mchId, mchSerialNo, privateKey, apiV3Key); |
| | | |
| | | return app; |
| | | } |
| | | |
| | | /** |
| | | * 获取会员充值支付宝支付表单 |
| | | * |
| | | * @param orderNo |
| | |
| | | try { |
| | | String goodsTitle = "影视大全会员充值"; |
| | | String returnUrl = "http://vip.ysdq.yeshitv.com"; |
| | | String notifyUrl = "http://193.112.34.40:8089/BuWan/alipay/pay"; |
| | | String notifyUrl = "http://api.ysdq.yeshitv.com:8089/BuWan/alipay/pay"; |
| | | AlipayAppInfo appInfo = getAlipayApp(); |
| | | String form = AlipayH5PayUtil.createOrderForm(appInfo, orderNo, money, goodsTitle, returnUrl, notifyUrl); |
| | | return form; |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 微信下单 |
| | | * |
| | | * @param ip |
| | | * @param orderNo |
| | | * @param money |
| | | * @param title |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static String createWXOrder(String ip, String orderNo, BigDecimal money, String title) throws Exception { |
| | | WXPlaceOrderParams params = new WXPlaceOrderParams(); |
| | | params.setIp(ip); |
| | | params.setOrderNo(orderNo); |
| | | params.setNotifyUrl("http://api.ysdq.yeshitv.com:8089/BuWan/wx/pay/vip"); |
| | | params.setFee(money); |
| | | params.setBody(title); |
| | | params.setApp(getWXAPP()); |
| | | String payUrl = WXPayV3Util.createH5Order(params, "http://vip.ysdq.yeshitv.com/wx_result.html"); |
| | | return payUrl; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.util.vip; |
| | | |
| | | public class VIPOrderUtil { |
| | | |
| | | /** |
| | | * 获取第三方订单号 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public static String getOutOrderNo(String id) { |
| | | return "buwan_vip_" + id; |
| | | } |
| | | |
| | | |
| | | public static String getIdFromOutOrderNo(String orderNo) { |
| | | return orderNo.replace("buwan_vip_", ""); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.vo.client.user; |
| | | |
| | | public class UserInfoVO { |
| | | private String id; |
| | | private String nickName; |
| | | private String portrait; |
| | | private String sex; |
| | | private String birthday; |
| | | private String sign; |
| | | |
| | | private String pptvCode; |
| | | //绑定的电话号码 |
| | | |
| | | private String qqOpenId; |
| | | private String qqNickName; |
| | | private String wxUnionId; |
| | | private String wxName; |
| | | private String phone; |
| | | private String email; |
| | | |
| | | //VIP到期时间 |
| | | private Long vipExpireTime; |
| | | |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getNickName() { |
| | | return nickName; |
| | | } |
| | | |
| | | public void setNickName(String nickName) { |
| | | this.nickName = nickName; |
| | | } |
| | | |
| | | public String getPortrait() { |
| | | return portrait; |
| | | } |
| | | |
| | | public void setPortrait(String portrait) { |
| | | this.portrait = portrait; |
| | | } |
| | | |
| | | public String getSex() { |
| | | return sex; |
| | | } |
| | | |
| | | public void setSex(String sex) { |
| | | this.sex = sex; |
| | | } |
| | | |
| | | public String getBirthday() { |
| | | return birthday; |
| | | } |
| | | |
| | | public void setBirthday(String birthday) { |
| | | this.birthday = birthday; |
| | | } |
| | | |
| | | public String getSign() { |
| | | return sign; |
| | | } |
| | | |
| | | public void setSign(String sign) { |
| | | this.sign = sign; |
| | | } |
| | | |
| | | public String getPptvCode() { |
| | | return pptvCode; |
| | | } |
| | | |
| | | public void setPptvCode(String pptvCode) { |
| | | this.pptvCode = pptvCode; |
| | | } |
| | | |
| | | public String getQqOpenId() { |
| | | return qqOpenId; |
| | | } |
| | | |
| | | public void setQqOpenId(String qqOpenId) { |
| | | this.qqOpenId = qqOpenId; |
| | | } |
| | | |
| | | public String getQqNickName() { |
| | | return qqNickName; |
| | | } |
| | | |
| | | public void setQqNickName(String qqNickName) { |
| | | this.qqNickName = qqNickName; |
| | | } |
| | | |
| | | public String getWxUnionId() { |
| | | return wxUnionId; |
| | | } |
| | | |
| | | public void setWxUnionId(String wxUnionId) { |
| | | this.wxUnionId = wxUnionId; |
| | | } |
| | | |
| | | public String getWxName() { |
| | | return wxName; |
| | | } |
| | | |
| | | public void setWxName(String wxName) { |
| | | this.wxName = wxName; |
| | | } |
| | | |
| | | public String getPhone() { |
| | | return phone; |
| | | } |
| | | |
| | | public void setPhone(String phone) { |
| | | this.phone = phone; |
| | | } |
| | | |
| | | public String getEmail() { |
| | | return email; |
| | | } |
| | | |
| | | public void setEmail(String email) { |
| | | this.email = email; |
| | | } |
| | | |
| | | public Long getVipExpireTime() { |
| | | return vipExpireTime; |
| | | } |
| | | |
| | | public void setVipExpireTime(Long vipExpireTime) { |
| | | this.vipExpireTime = vipExpireTime; |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version='1.0' encoding='UTF-8'?> |
| | | <!DOCTYPE hibernate-mapping PUBLIC |
| | | "-//Hibernate/Hibernate Mapping DTD 3.0//EN" |
| | | "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> |
| | | <hibernate-mapping package="com.yeshi.buwan.domain.vip"> |
| | | <class name="UserVIPInfo" table="wk_user_vip"> |
| | | <id name="uid" column="uid"> |
| | | </id> |
| | | |
| | | <property name="expireDate" column="expire_date" type="timestamp"></property> |
| | | <property name="createTime" column="create_time" type="timestamp"></property> |
| | | <property name="updateTime" column="update_time" type="timestamp"></property> |
| | | |
| | | </class> |
| | | |
| | | |
| | | </hibernate-mapping> |
New file |
| | |
| | | <?xml version='1.0' encoding='UTF-8'?> |
| | | <!DOCTYPE hibernate-mapping PUBLIC |
| | | "-//Hibernate/Hibernate Mapping DTD 3.0//EN" |
| | | "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> |
| | | <hibernate-mapping package="com.yeshi.buwan.domain.vip"> |
| | | |
| | | <class name="VIPOrderRecord" table="wk_vip_order_record"> |
| | | <id name="id" column="id"> |
| | | <generator class="native"></generator> |
| | | </id> |
| | | |
| | | <property name="uid" column="uid" type="string"></property> |
| | | <property name="state" column="state" type="integer"></property> |
| | | <property name="type" column="type"> |
| | | <type name="org.hibernate.type.EnumType"> |
| | | <param name="enumClass">com.yeshi.buwan.domain.vip.VIPPriceType</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="payTime" column="pay_time" type="timestamp"></property> |
| | | <property name="createTime" column="create_time" type="timestamp"></property> |
| | | <property name="updateTime" column="update_time" type="timestamp"></property> |
| | | <property name="vipStartTime" column="vip_start_time" type="timestamp"></property> |
| | | <property name="vipEndTime" column="vip_end_time" type="timestamp"></property> |
| | | |
| | | </class> |
| | | |
| | | |
| | | </hibernate-mapping> |
| | |
| | | |
| | | <session-factory> |
| | | <property name="hibernate.hbm2ddl.auto">none</property> |
| | | <property name="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</property> |
| | | <property name="hibernate.current_session_context_class"> |
| | | org.springframework.orm.hibernate4.SpringSessionContext |
| | | </property> |
| | | <!-- 打印sql语句 --> |
| | | <property name="show_sql">true</property> |
| | | <!-- 映射文件配置 --> |
| | |
| | | resource="domain/recommend/CategoryRecommendCacheVideoNumber.hbm.xml" /> |
| | | |
| | | |
| | | |
| | | <!-- 评论 --> |
| | | <mapping resource="domain/CommentReply.hbm.xml" /> |
| | | |
| | |
| | | <mapping resource="domain/news/SuperFoundNrews.hbm.xml" /> |
| | | |
| | | |
| | | |
| | | <mapping resource="domain/video/JuHeFilterKey.hbm.xml" /> |
| | | |
| | | <!-- 爱奇艺 --> |
| | |
| | | <mapping resource="domain/shop/ShopItemCollect.hbm.xml" /> |
| | | <mapping resource="domain/shop/ShopItemComment.hbm.xml" /> |
| | | |
| | | <!-- VIP --> |
| | | <mapping resource="domain/vip/UserVIPInfo.hbm.xml"/> |
| | | <mapping resource="domain/vip/VIPOrderRecord.hbm.xml"/> |
| | | |
| | | <mapping class="com.yeshi.buwan.domain.AcFunTemporary"/> |
| | | <mapping class="com.yeshi.buwan.acFun.AcFunVideo"/> |
| | | <mapping class="com.yeshi.buwan.acFun.AcFunType"/> |
| | | <mapping class="com.yeshi.buwan.acFun.AcTypeEqVideoType"/> |
| | | <mapping class="com.yeshi.buwan.domain.Holmes"/> |
| | | |
| | | |
| | | </session-factory> |
| | | |
| | | </hibernate-configuration> |
| | |
| | | app_id=1400246689 |
| | | app_key=7f3dfd82f3ff0326127a21009464bfd9 |
| | | sign=板栗快省 |
| | | app_id=1400483517 |
| | | app_key=f7933d53b41d9a0bdfaf7f837c4a5b31 |
| | | sign=影视大全 |
| | | content_bind=【[签名]】验证码:[验证码],2分钟内有效。为了保护您的账号安全,验证短信请勿转发他人。 |
New file |
| | |
| | | -----BEGIN PRIVATE KEY----- |
| | | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDAy5UF6702led7 |
| | | 2WrytnQVdHCwH83WAPArEdayXCCc1DId/UvgMVdpxO52elambEhJyU6NSgv4N+Vp |
| | | QZ/ewQI7Jz9E90NmsPz/DaV+OfolS5VgMzCUXbVKtPX83oALZMNVqmtgAkhqjBFC |
| | | XyblhYWjzVgqOXLYHxIJEqIZzSeWvTGKGFwQclw3fT4rto2hX90xJVq4RlCw+/fe |
| | | oO9PnWWilwTE59hiw/V9Q2YlO0sDlzOoCiSPNcfeHhwywbLAKKzz62xLGoMCcquK |
| | | Xg80YuOL8nR486FcskwR3osePUSd6tv0MfMuVCwhhv7uDGzBjpNAmsvMXNXwXau1 |
| | | 6RgU93cZAgMBAAECggEAa5VvPFWXSY2PFip2Jqiv0IUgmPe2ahQt8SrMLs2AGWPD |
| | | 7744CAwgplIRa6XLEqVcFWizX96RHVs7tme7aZc0woOdJ8P/JZ/gHgekcPKzZvpt |
| | | ibgnBLPiBaVDm28h7rm00un9bx73ABXXT70/PFctAwIEj9NtBbMY4l02fcVgsRk7 |
| | | oRCNgL1eWMrjWTZpE6G1JQlWpeMsmfSeuDf/D7Z6ZWdbAglkb9lDo9e2eVPGQHRq |
| | | JH58fF7F1oDuXntaNimAXicZifOPMANvT0Y6iCx6ebapHmLwRCS2j0MYpJbq4URn |
| | | uKXsNLCAFaqEfYfvS6O+r9nzvLlelIB2YGMs1OvR8QKBgQDu6eDU27b71MQJC/64 |
| | | GZ17yMJBRF3HQbUlTMPnQoWgAGEAtRSqlAX1zC/14mKbUkMTM1EGKKyP0jX5u2df |
| | | RmVGMQnqVURVm7IoZxXU7XBajSzuDFCoXRtUl2Ut88DCa2yqwavq3M0rObQ9hq3R |
| | | 2YKr1DM6SPtYh0X3HMLoVX7X7QKBgQDOlVn8Tu1Zd+sGr0U9oNP+iIyR81pjx8Nc |
| | | /14gAB4wuMKPhY52exKB4q7b76RHlftMblzWOUPBcv3ZiyFI2I2sDOyq/pJxjqJV |
| | | KAR2Eatx28xYJ0scLFkvohxnTBqUxi+IRytXJ/aCabSgQ9rrt+ZPr30nDR0anL0p |
| | | Bk/D9cJeXQKBgQCkDcEvKPhLkNxUAgKU1DIJr9+EBbgHfR0wUbgr8sfjCJ+TZsSc |
| | | JSy6jc1ZIGzpjuE0LAa1HfTwhT4/D+p5x9L/EelnGcnkpxb9G1wobCq8Yzi49Yfl |
| | | NJnxykvV9A0m87EYyAiPK7NOvT8BCJwO/zb1Wq8alMbTEYB/oSZNd3e0OQKBgA00 |
| | | VK0g6mDmnlouB9H5nrNNTRbjJCrukNk35W9MMqHQnXcJBWMjWLp+n8ilF64PsyFe |
| | | iIaU4HTUAc/O6dC7LssJhHMllHy3rj6dMTPOy1OaxgP4dv+VAhpeVUxw+934kP83 |
| | | 9Vg70LDjSs1XqP2aIpmDUQ+W8f5KeHjP03dmFQdtAoGBAKPJjivKn5WsGWhMHEm/ |
| | | DX+X/RQGHx4KK7JexCAxS2aTt+/2gLZEA7MH56c5E92tkFFv9vZ6VEE3EzZKTEtn |
| | | EmxIXnpVdPiFJuES3m9XikfIbZjlZ8U9vI7i6YKP8/a9XO4NCCgzU4WtslmOJ+Nu |
| | | gcPoYuqLpfNU0D+aqXakLgN3 |
| | | -----END PRIVATE KEY----- |
New file |
| | |
| | | app_id=wxa99686bb65a9f466 |
| | | mch_id=1520950211 |
| | | mch_serial_no=454328C324C6CC21355D064B44D6524CD7506DD0 |
| | | api_v3_key=XYJkJ2018FAfaodCCx899mLl138rfGVd |
| | |
| | | </p> |
| | | </p> |
| | | |
| | | <div style="display: none;"> |
| | | <script type="text/javascript" src="https://s4.cnzz.com/z_stat.php?id=1279668448&web_id=1279668448"></script> |
| | | </div> |
| | | |
| | | </body> |
| | | |
| | | </html> |
| | |
| | | package com.hxh.spring.test; |
| | | |
| | | import com.yeshi.buwan.pptv.PPTVApiUtil; |
| | | import com.yeshi.buwan.pptv.PPTVUtil; |
| | | import com.yeshi.buwan.pptv.entity.PPTVSeries; |
| | | import com.yeshi.buwan.service.inter.juhe.PPTVService; |
| | | 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 javax.annotation.Resource; |
| | | import java.util.List; |
| | |
| | | @Test |
| | | public void save() { |
| | | List<PPTVSeries> list = PPTVApiUtil.getUpdateList(); |
| | | // pptvService.save(list); |
| | | pptvService.save(list); |
| | | } |
| | | |
| | | @Test |
| | |
| | | PPTVApiUtil.getOpenId("123"); |
| | | } |
| | | |
| | | @Test |
| | | public void getAll() { |
| | | PPTVApiUtil.getUpdateList(); |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void getApiDetail(){ |
| | |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void getOpenId() { |
| | | //CODE:XefbSM0H8BC9kaEGEjHF2U7wd6Sd9ec1oSUmG1gZDTg= |
| | | PPTVApiUtil.login("XefbSM0H8BC9kaEGEjHF2U7wd6Sd9ec1oSUmG1gZDTg="); |
| | | |
| | | PPTVApiUtil.getOpenId("buwan_766693"); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.hxh.spring.test.vip; |
| | | |
| | | 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.vip.VIPException; |
| | | import com.yeshi.buwan.service.inter.vip.VIPPriceService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | 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 javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 |
| | | @ContextConfiguration(locations = {"classpath:spring.xml"}) |
| | | @WebAppConfiguration |
| | | public class VIPTest { |
| | | |
| | | @Resource |
| | | private VIPPriceService vipPriceService; |
| | | |
| | | @Resource |
| | | private VIPService vipService; |
| | | |
| | | @Test |
| | | public void addVIPPrice() { |
| | | VIPPrice price = new VIPPrice(); |
| | | price.setPrice(new BigDecimal(8)); |
| | | price.setType(VIPPriceType.month); |
| | | price.setPptvGoodsNo("DA7559531560894"); |
| | | price.setShow(true); |
| | | try { |
| | | vipPriceService.addPrice(price); |
| | | } catch (VIPException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | price = new VIPPrice(); |
| | | price.setPrice(new BigDecimal(24)); |
| | | price.setType(VIPPriceType.season); |
| | | price.setPptvGoodsNo("DA7559574625089"); |
| | | price.setShow(true); |
| | | try { |
| | | vipPriceService.addPrice(price); |
| | | } catch (VIPException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | price = new VIPPrice(); |
| | | price.setPrice(new BigDecimal(45)); |
| | | price.setType(VIPPriceType.halfYear); |
| | | price.setPptvGoodsNo("DA6989580247516"); |
| | | price.setShow(true); |
| | | try { |
| | | vipPriceService.addPrice(price); |
| | | } catch (VIPException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | price = new VIPPrice(); |
| | | price.setPrice(new BigDecimal(88)); |
| | | 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"); |
| | | VIPOrderRecord record = new VIPOrderRecord(); |
| | | record.setMoney(price.getPrice()); |
| | | record.setType(price.getType()); |
| | | record.setUid(766693 + ""); |
| | | |
| | | try { |
| | | vipService.addVIPRecord(record); |
| | | } catch (VIPException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void listRecord() { |
| | | List<VIPOrderRecord> list = vipService.listOrderRecord(null, null, 1, 10); |
| | | long count = vipService.countOrderRecord(null, null); |
| | | |
| | | |
| | | list = vipService.listOrderRecord(766693 + "", null, 1, 10); |
| | | count = vipService.countOrderRecord(766693 + "", null); |
| | | |
| | | |
| | | list = vipService.listOrderRecord(766693 + "", VIPOrderRecord.STATE_NOT_PAY, 1, 10); |
| | | count = vipService.countOrderRecord(766693 + "", VIPOrderRecord.STATE_NOT_PAY); |
| | | |
| | | list = vipService.listOrderRecord(766693 + "", VIPOrderRecord.STATE_PAY, 1, 10); |
| | | count = vipService.countOrderRecord(766693 + "", VIPOrderRecord.STATE_PAY); |
| | | |
| | | System.out.println(list); |
| | | } |
| | | |
| | | @Test |
| | | public void paySuccess() { |
| | | try { |
| | | vipService.paySuccess("2", VIPOrderRecord.PAY_WAY_ALIPAY, new BigDecimal("2.99"), new Date()); |
| | | } catch (VIPException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |