| | |
| | | package com.kidgrow.oprationcenter.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.kidgrow.common.utils.DateUtils; |
| | | import com.kidgrow.common.utils.QRCodeUtil; |
| | | import com.kidgrow.common.utils.StringUtils; |
| | | import com.kidgrow.oprationcenter.model.SaasClientPay; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | jsonObject.put("body",saasClientPay.getChildName());//商品描述 |
| | | jsonObject.put("out_trade_no", saasClientPay.getOutTradeNo());//商户订单号 |
| | | jsonObject.put("total_fee",saasClientPay.getPayPrice().toString());//标价金额 单位为分 |
| | | jsonObject.put("spbill_create_ip","192.168.2.240");//终端IP |
| | | jsonObject.put("spbill_create_ip",getIpAddress(request));//终端IP |
| | | jsonObject.put("notify_url",weiXinOfficPayProperties.getPayNotifyUrl());//通知地址 |
| | | jsonObject.put("trade_type","NATIVE");//交易类型 |
| | | MyConfig wxPayConfig= new MyConfig(weiXinOfficPayProperties); |
| | |
| | | String s = QRCodeUtil.creatRrCode(resultStr, 200, 200, 0).replaceAll("\n","").replaceAll("\r",""); |
| | | String prepay_id = result.get("prepay_id"); |
| | | Map<String,String> map = new HashMap<>(); |
| | | map.put("code_url",resultStr); |
| | | map.put("code_url",s); |
| | | map.put("prepay_id",prepay_id); |
| | | return map; |
| | | } |
| | | public static String getIpAddress(HttpServletRequest request) { |
| | | String ip = request.getHeader("x-forwarded-for"); |
| | | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("Proxy-Client-IP"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("WL-Proxy-Client-IP"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("HTTP_CLIENT_IP"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
| | | ip = request.getHeader("HTTP_X_FORWARDED_FOR"); |
| | | } |
| | | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
| | | ip = request.getRemoteAddr(); |
| | | } |
| | | return ip; |
| | | } |
| | | |
| | | @Override |
| | |
| | | List<SaasClientPay> list = iSaasClientPayService.list(queryWrapper); |
| | | if(!list.isEmpty()){ |
| | | SaasClientPay saasClientPay = list.get(0); |
| | | saasClientPay.setPayTime(DateUtils.parseDate(requestMap.get("time_end"))); |
| | | saasClientPay.setPayTime(new Date()); |
| | | saasClientPay.setPayStatus(2); |
| | | saasClientPay.setPayMethod(0); |
| | | saasClientPay.setTradeNo(requestMap.get("transaction_id")); |
| | | boolean b = iSaasClientPayService.saveOrUpdate(saasClientPay); |
| | | boolean b = iSaasClientPayService.updateById(saasClientPay); |
| | | map.put("return_code","SUCCESS"); |
| | | map.put("return_msg","OK"); |
| | | } |