| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.OrderCodeUtil; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | |
| | | import com.ruoyi.order.api.model.TVipOrder; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | | import com.ruoyi.other.mapper.TCouponMapper; |
| | | import com.ruoyi.other.mapper.TVipMapper; |
| | | import com.ruoyi.other.service.TVipService; |
| | |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Resource |
| | | private VipClient vipClient; |
| | | @Override |
| | | public Object vipInfoPay(TVip byId, BigDecimal payMoney, Integer payType,BigDecimal discountMoney,BigDecimal discount,Integer buyType, Long userId) { |
| | | TAppUser user = appUserClient.getUserById(userId).getData(); |
| | | |
| | | //生成会员购买订单 |
| | | |
| | | TVipOrder shopOrder = new TVipOrder(); |
| | | shopOrder.setCode(OrderCodeUtil.getOrderCode("HY")); |
| | | shopOrder.setType(1); |
| | | shopOrder.setAppUserId(userId); |
| | | shopOrder.setType(1); |
| | | shopOrder.setVipId(byId.getId()); |
| | | shopOrder.setTitle(byId.getName()); |
| | | if (buyType==1){ |
| | | shopOrder.setTitle(byId.getName()+"月卡"); |
| | | }else if (buyType==2){ |
| | | shopOrder.setTitle(byId.getName()+"季卡"); |
| | | }else { |
| | | shopOrder.setTitle(byId.getName()+"年卡"); |
| | | } |
| | | shopOrder.setVipType(buyType); |
| | | shopOrder.setOrderAmount(payMoney.add(discountMoney)); |
| | | shopOrder.setDiscount(discount); |
| | |
| | | shopOrder.setPaymentStatus(1); |
| | | shopOrder.setPaymentType(payType); |
| | | shopOrder.setPayTime(LocalDateTime.now()); |
| | | orderClient.addVipOrder(shopOrder).getData(); |
| | | |
| | | |
| | | shopOrder.setDelFlag(false); |
| | | R<Long> longR = orderClient.addVipOrder(shopOrder); |
| | | if(200 != longR.getCode()){ |
| | | return AjaxResult.error(longR.getMsg()); |
| | | } |
| | | |
| | | if (payType==1){ |
| | | //调起支付 |
| | | PaymentOrder paymentOrder = new PaymentOrder(); |
| | |
| | | paymentOrder.setAmount(shopOrder.getPaymentAmount()); |
| | | paymentOrder.setOpenId(user.getWxOpenid()); |
| | | paymentOrder.setDescription("购买会员"); |
| | | return wxPaymentClient.orderPay(paymentOrder).getData(); |
| | | return AjaxResult.success(wxPaymentClient.orderPay(paymentOrder).getData()); |
| | | }else { |
| | | AliPaymentReq req = new AliPaymentReq(); |
| | | req.setOutTradeNo(shopOrder.getCode()); |
| | |
| | | req.setSubject("充电充值"); |
| | | req.setBuyerOpenId(user.getAliOpenid()); |
| | | req.setBody("充电充值"); |
| | | req.setNotifyUrl("/payment/ali/callBack"); |
| | | AliPaymentResp data = aliPaymentClient.payment(req).getData(); |
| | | if(null != data){ |
| | | data.setNotifyUrl(data.getNotifyUrl() + "/callBack/ali/all"); |
| | | return AjaxResult.success(data); |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | } |