From 10ceb8fd7972048310188cc4d4646ab86cd69cb9 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 05 六月 2021 17:19:03 +0800 Subject: [PATCH] maven远程部署配置 --- service-vip/src/main/java/com/ks/vip/service/remote/VipOrderPayServiceImpl.java | 55 +++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 43 insertions(+), 12 deletions(-) diff --git a/service-vip/src/main/java/com/ks/vip/service/remote/VipOrderPayServiceImpl.java b/service-vip/src/main/java/com/ks/vip/service/remote/VipOrderPayServiceImpl.java index 0f61df1..bd8b3f1 100644 --- a/service-vip/src/main/java/com/ks/vip/service/remote/VipOrderPayServiceImpl.java +++ b/service-vip/src/main/java/com/ks/vip/service/remote/VipOrderPayServiceImpl.java @@ -14,19 +14,24 @@ import com.ks.vip.service.VipCenterService; import com.ks.vip.service.VipComboService; import com.ks.vip.service.VipOrederPayService; -import com.ks.vip.service.manager.RedisManager; import com.ks.vip.util.Constant; import com.ks.vip.util.PayUtil; import org.apache.dubbo.config.annotation.Service; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.transaction.annotation.Transactional; import org.yeshi.utils.StringUtil; import org.yeshi.utils.alipay.AlipayH5PayUtil; import org.yeshi.utils.entity.wx.WXPayOrderInfoV3; import org.yeshi.utils.wx.WXPayV3Util; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; import javax.annotation.Resource; import java.util.Date; +import java.util.Map; import java.util.UUID; +import java.util.concurrent.TimeUnit; @Service(version = "1.0") public class VipOrderPayServiceImpl implements VipOrederPayService { @@ -41,12 +46,12 @@ private VipCenterService vipCenterService; @Resource - private RedisManager redisManager; + private JedisPool jedisPool; @Override @Transactional(rollbackFor = Exception.class) - public PayWayInfoDTO addOrderWithPay(VipOrderDTO t, String notifyUrl, String returnUrl) throws VipOrderException { + public PayWayInfoDTO addOrderWithPay(VipOrderDTO t, String notifyUrl, String returnUrl, String ip) throws VipOrderException { if (t.getComboId() == null || t.getComboId() <= 0) { throw new VipOrderException(1, "濂楅ID涓嶈兘涓虹┖"); } @@ -75,17 +80,22 @@ // 鎻掑叆璁㈠崟淇℃伅 VipOrder newOrder = new VipOrder(); + newOrder.setState(VipOrder.STATE_INIT); newOrder.setComboId(t.getComboId()); newOrder.setUid(t.getUid()); newOrder.setThreeOrderId(t.getThreeOrderId()); newOrder.setPayWay(t.getPayWay().name()); newOrder.setType(orderType); + newOrder.setPayMoney(t.getPayMoney()); newOrder.setCreateTime(new Date()); vipOrderMapper.insertSelective(newOrder); + if (returnUrl != null) { + returnUrl += "?id=" + newOrder.getId(); + } // 鏀粯鏂瑰紡 try { - return payOrder(newOrder, notifyUrl, returnUrl); + return payOrder(newOrder, notifyUrl, returnUrl, ip); } catch (OrderPayException e) { e.printStackTrace(); throw new VipOrderException(VipOrderException.CODE_CREATE_PAY_ORDER_FAIL, e.getMsg()); @@ -95,27 +105,33 @@ @Override @Transactional(rollbackFor = Exception.class) - public PayWayInfoDTO payOrder(VipOrder order, String notifyUrl, String returnUrl) throws OrderPayException { + public PayWayInfoDTO payOrder(VipOrder order, String notifyUrl, String returnUrl, String ip) throws OrderPayException { if (order.getState() == VipOrder.STATE_PAY) { throw new OrderPayException(OrderPayException.CODE_ALREADY_PAY, "宸茬粡瀹屾垚鏀粯"); } String goodsTitle = Constant.ORDER_PAY_TITLE; - String orderId = order.getId() + ""; + String orderId = order.getThreeOrderId() + ""; switch (order.getPayWay()) { //鐢熸垚鏀粯瀹濇敮浠樿鍗� case "alipay": - String form = PayUtil.getVipChargeAlipayForm(orderId, goodsTitle, orderId, order.getPayMoney(), notifyUrl, returnUrl); + String form = PayUtil.getVipChargeAlipayForm(goodsTitle, orderId, order.getPayMoney(), notifyUrl, returnUrl); if (StringUtil.isNullOrEmpty(form)) { throw new OrderPayException(OrderPayException.CODE_CREATE_PAY_ORDER_FAIL, "鍒涘缓鏀粯瀹濇敮浠樿鍗曞け璐�"); } //鏆傚瓨2鍒嗛挓 String id = StringUtil.Md5(UUID.randomUUID().toString() + "#" + System.currentTimeMillis()); - redisManager.cacheCommonString(id, form, 120); - return new PayWayInfoDTO(PayWayEnum.alipay.getWay(), null, id); + Jedis jedis = jedisPool.getResource(); + try { + jedis.set(id, form); + jedis.expire(id, 120); + } finally { + jedis.close(); + } + return new PayWayInfoDTO(PayWayEnum.alipay, null, id); case "weChat": try { - String payUrl = PayUtil.createWXOrder(null, orderId, order.getPayMoney(), goodsTitle, notifyUrl, returnUrl); - return new PayWayInfoDTO(PayWayEnum.weChat.getWay(), payUrl, null); + String payUrl = PayUtil.createWXOrder(ip, orderId, order.getPayMoney(), goodsTitle, notifyUrl, returnUrl); + return new PayWayInfoDTO(PayWayEnum.weChat, payUrl, null); } catch (Exception e) { throw new OrderPayException(OrderPayException.CODE_CREATE_PAY_ORDER_FAIL, e.getMessage()); } @@ -125,7 +141,12 @@ @Override public String getAlipayForm(String formId) { - return redisManager.getCommonString(formId); + Jedis jedis = jedisPool.getResource(); + try { + return jedis.get(formId); + } finally { + jedis.close(); + } } @@ -168,6 +189,16 @@ return null; } + @Override + public String getWXPaySuccessOutOrderNo(String notifyContent) throws Exception { + return WXPayV3Util.getPaySuccessOutOrderNo(notifyContent, PayUtil.getWXAPP()); + } + + @Override + public String getAlipayPaySuccessOutOrderNo(Map<String, String> params) throws Exception { + return AlipayH5PayUtil.getPaySuccessNotifyOutOrderNo(params, PayUtil.getAlipayApp()); + } + /** * 鏀粯鎴愬姛鏇存柊澶勭悊 -- Gitblit v1.8.0