| | |
| | | package com.yeshi.fanli.controller.client.lijin; |
| | | |
| | | import com.ks.vip.exception.OrderPayException; |
| | | import com.ks.vip.exception.VipOrderException; |
| | | import com.ks.vip.pojo.DO.VipCenter; |
| | | import com.ks.vip.pojo.DO.VipCenterRecord; |
| | | import com.ks.vip.pojo.DO.VipCombo; |
| | | import com.ks.vip.pojo.DO.VipOrder; |
| | | import com.ks.vip.pojo.DTO.PayWayInfoDTO; |
| | | import com.ks.vip.pojo.Enums.OrderTypeEnum; |
| | | import com.ks.vip.pojo.Enums.PayWayEnum; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | import com.ks.vip.service.VipComboService; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.MoneyBigDecimalUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import org.yeshi.utils.*; |
| | | import redis.clients.jedis.Jedis; |
| | | import redis.clients.jedis.JedisPool; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | |
| | | name += "-年卡"; |
| | | } else if (hour > 24 * 31) { |
| | | name += "-季卡"; |
| | | } else if (hour > 24) { |
| | | } else if (hour > 24 * 7) { |
| | | name += "-月卡"; |
| | | } else if (hour > 24) { |
| | | name += "-周卡"; |
| | | } else if (hour == 24) { |
| | | name += "-1天"; |
| | | } else { |
| | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 创建VIP订单 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param id |
| | | * @param payWay 1-支付宝 2-微信 |
| | | * @param out |
| | | */ |
| | | @RequestMapping("createVIPOrder") |
| | | public void createVIPOrder(AcceptData acceptData, Long uid, Long id, int payWay, HttpServletRequest request, PrintWriter out) { |
| | | try { |
| | | PayWayInfoDTO payWayInfoDTO = userLijinMnager.createVIPOrder(uid, id, payWay == 1 ? PayWayEnum.alipay : PayWayEnum.weChat, IPUtil.getRemotIP(request)); |
| | | JSONObject data = new JSONObject(); |
| | | if (payWayInfoDTO.getPayWay() == PayWayEnum.alipay) { |
| | | data.put("url", "http://api.tejia.yeshitv.com/fanli/alipay/printPayForm?formId=" + payWayInfoDTO.getAlipayFormId()); |
| | | } else { |
| | | data.put("url", payWayInfoDTO.getPayUrl()); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (VipOrderException e) { |
| | | e.printStackTrace(); |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), "创建订单出错")); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping("checkVIPOrderPay") |
| | | public void checkPayResult(AcceptData acceptData, String id, PrintWriter out) { |
| | | |
| | | if (id == null || !NumberUtil.isNumeric(id)) { |
| | | out.print(JsonUtil.loadFalseResult("id格式有误")); |
| | | return; |
| | | } |
| | | |
| | | VipOrder vipOrder = null; |
| | | try { |
| | | vipOrder = userLijinMnager.checkPay(Long.parseLong(id)); |
| | | } catch (OrderPayException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg())); |
| | | return; |
| | | } catch (VipOrderException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg())); |
| | | return; |
| | | } |
| | | |
| | | if (vipOrder.getState() == VipOrder.STATE_PAY) { |
| | | //支付成功 |
| | | JSONObject data = new JSONObject(); |
| | | data.put("money", vipOrder.getPayMoney()); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } else { |
| | | //支付失败 |
| | | out.print(JsonUtil.loadFalseResult("订单尚未支付成功")); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |