Commit 6e0b4a2b authored by cy's avatar cy

方案查询

parent 15d19821
......@@ -17,6 +17,7 @@
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="is_vip" property="isVip"/>
<result column="openid" property="openid"/>
</resultMap>
<sql id="table">
......@@ -29,12 +30,12 @@
</sql>
<sql id="cols_exclude_id">
user_name,password, phone,uuid,head_image,sex,school, exam_type,source,is_delete,create_time,update_time,is_vip
user_name,password, phone,uuid,head_image,sex,school, exam_type,source,is_delete,create_time,update_time,is_vip,openid
</sql>
<sql id="vals">
#{userName},#{password},#{phone},#{uuid},#{headImage},#{sex},#{school},#{examType}, #{source},
#{isDelete},now(),now(),#{isVip}
#{isDelete},now(),now(),#{isVip},#{openid}
</sql>
<sql id="updateCondition">
......@@ -49,7 +50,8 @@
<if test="source != null">source = #{source},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
update_time =now(),
<if test="isVip != null">is_vip = #{isVip}</if>
<if test="isVip != null">is_vip = #{isVip},</if>
<if test="openid != null">openid =#{openid}</if>
</sql>
<sql id="criteria">
......@@ -66,7 +68,8 @@
<if test="isDelete != null">and is_delete = #{isDelete}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
<if test="isVip != null">and is_vip = #{isVip}</if>
<if test="isVip != null">and is_vip = #{isVip},</if>
<if test="openid != null">and openid =#{openid}</if>
</sql>
<insert id="add" parameterType="cn.wisenergy.model.app.User" keyProperty="id" useGeneratedKeys="true">
......
......@@ -102,4 +102,10 @@ public class User implements Serializable {
@ApiModelProperty(name = "isVip",value = "用户是否为vip 1:是 2:不是")
private Integer isVip;
/**
* 微信用户openid
*/
@ApiModelProperty(name = "微信用户openid", value = "openid")
private String openid;
}
......@@ -32,6 +32,6 @@ public class PayPageDto {
@ApiModelProperty(value = "支付类型 1:支付宝 2:微信 3:充值卡", name = "payType")
private Integer payType;
@ApiModelProperty(value = "微信用户的openid",name="openid")
private String openid;
@ApiModelProperty(value = "微信用户的临时code",name="code")
private String code;
}
......@@ -6,7 +6,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
import java.util.SortedMap;
......@@ -17,44 +16,40 @@ import java.util.SortedMap;
public interface TestWxPayService {
/**
* pc端微信支付
* @Param
* @return
* @Param 支付信息
* @return 返回的信息
*/
R<Map<String, String>> wxPay(PayPageDto payPageDto, HttpServletResponse response);
/***
* h5微信支付
* @param payPageDto
* @param request
* @param response
* @return
* @throws JsonProcessingException
* @param payPageDto 支付信息
* @param request 接收的数据
* @param response 返回的信息
* @return h5调支付的数据
*/
R<String> h5WxPay(PayPageDto payPageDto,HttpServletRequest request, HttpServletResponse response) throws JsonProcessingException;
/***
* 小程序微信支付
* @param payPageDto
* @param request
* @param response
* @return
* @throws JsonProcessingException
* @param payPageDto 支付信息
* @param request 接收的数据
* @param response 返回的信息
* @return 小程序调支付的数据
*/
R<SortedMap<String, String>> WxPayApplets(PayPageDto payPageDto, HttpServletRequest request, HttpServletResponse response) throws JsonProcessingException;
/***
*支付成功回调
* @param request
* @param response
* @return
* @param request 回调获取的数据
* @param response 回调返回的数据
*/
void wxPayCallBack(HttpServletRequest request, HttpServletResponse response) throws Exception;
/***
* 订单状态查询
* @param out_trade_no
* @return
* @throws Exception
* @param out_trade_no 订单号
* @return 订单状态
*/
R<Map<String,String>> wxQuery(String out_trade_no) throws Exception;
......
......@@ -6,6 +6,8 @@ import cn.wisenergy.model.vo.UserInfoVo;
import cn.wisenergy.model.vo.UserLoginVo;
import cn.wisenergy.model.vo.UserRegisterVo;
import javax.servlet.http.HttpServletRequest;
/**
* @author 86187
* @ Description: 用户登录
......@@ -35,7 +37,7 @@ public interface UserLoginService {
* @param userLoginVo 登录信息
* @return true 成功 false 失败
*/
R<UserInfoVo> login(UserLoginVo userLoginVo);
R<UserInfoVo> login(UserLoginVo userLoginVo, HttpServletRequest request);
/**
* 退出登录
......
......@@ -71,7 +71,6 @@ public interface UserService {
/**
* 导出excel
* @param queryVo 用户
* @param response
* @return Excel数据
*/
R<Boolean> createExcel(UserQueryVo queryVo, HttpServletResponse response);
......@@ -85,4 +84,25 @@ public interface UserService {
*/
R<UserInfoVo> commitUserVipInfo(UserVipCommitVo userInfo);
/**
* 用户登录小程序授权
* @param code 微信用户临时code
* @return 授权状态
*/
R<String> appletBinding(String code,Integer userId);
/**
* 通过openid获取用户信息
* @param code 微信用户临时code
* @return 用户信息
*/
R<UserInfoVo> getByOpenid(String code);
/**
* 退出小程序,解绑
* @param userId 用户id
* @return 解绑状态
*/
R<String> quitApplet(Integer userId);
}
......@@ -65,7 +65,8 @@ public class AliPayServiceImpl implements AliPayService {
AlipayClient alipayClient = new DefaultAlipayClient(Common.PAY_URL, APP_ID, PRIVATE_KEY, "json", CHARSET, ALIPAY_PUBLIC_KEY, "RSA2");
AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
String tradeNo = "21" + System.currentTimeMillis();
double amount = 0.01;
int random=(int)(Math.random()*10+1);
double amount = random/100;
//支付成功跳转地址
alipayRequest.setReturnUrl(Common.RETURN_URL_PC);
//支付回调地址
......@@ -73,6 +74,7 @@ public class AliPayServiceImpl implements AliPayService {
//alipayRequest.setNotifyUrl("http://bga7hc.natappfree.cc/pay/aliPayCallBack.do");
alipayRequest.setBizContent("{" +
"\"out_trade_no\":\"" + tradeNo + "\"," +
//"\"total_amount\":" + payPageDto.getTotal() + "," +
"\"total_amount\":" + amount + "," +
"\"subject\":\"充值\"," +
"\"body\":\"充值\"," +
......@@ -118,7 +120,8 @@ public class AliPayServiceImpl implements AliPayService {
AlipayClient alipayClient = new DefaultAlipayClient(Common.PAY_URL, APP_ID, PRIVATE_KEY, "json", CHARSET, ALIPAY_PUBLIC_KEY, "RSA2");
AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest();
String tradeNo = "21" + System.currentTimeMillis();
double amount = 0.01;
int random=(int)(Math.random()*10+1);
double amount = random/100;
//支付成功跳转地址
alipayRequest.setReturnUrl(Common.RETURN_URL_WAP);
//支付后回调地址
......@@ -126,6 +129,7 @@ public class AliPayServiceImpl implements AliPayService {
alipayRequest.setBizContent("{" +
"\"out_trade_no\":\"" + tradeNo + "\"," +
//"\"total_amount\":" + payPageDto.getTotal() + "," +
"\"total_amount\":" + amount + "," +
"\"subject\":\"充值\"," +
"\"body\":\"充值\"," +
......
......@@ -243,6 +243,7 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
volunteerVo.setUserId(user.getId());
//设置查询时间
SetQueryTime(result);
result.sort(Comparator.comparing(Volunteer::getLowestMark).reversed());
volunteerVo.setVolunteers(result);
return R.ok(volunteerVo);
}
......
......@@ -55,8 +55,9 @@ public class TestWxPayServiceImpl implements TestWxPayService {
//小程序appid
@Value("${wxPay.Applets_ID}")
private String Applets_ID;
//小程序密钥
@Value("${wxPay.SECRT_KEY}")
private String secrt_key;
/***
......@@ -73,7 +74,7 @@ public class TestWxPayServiceImpl implements TestWxPayService {
//生成预支付订单,充值结果设为失败(result=1)
try {
//生成【统一下单API】所需参数的接口
String orderInfo = WxPayUtil.createOrderInfo(tradeNo, product_id,time_expire, appid, mchid, key);
String orderInfo = WxPayUtil.createOrderInfo(payPageDto,tradeNo, product_id,time_expire, appid, mchid, key);
System.out.println(orderInfo);
//调用统一下单接口
Map<String, String> map = unifiedOrder(unifiedOrderUrl,orderInfo);
......@@ -112,7 +113,7 @@ public class TestWxPayServiceImpl implements TestWxPayService {
//生成预支付订单,充值结果设为失败(result=1)
try {
//生成【统一下单API】所需参数的接口
String orderInfo = WxPayUtil.createOrderInfoH5(tradeNo, request, appid, mchid, key);
String orderInfo = WxPayUtil.createOrderInfoH5(payPageDto,tradeNo, request, appid, mchid, key);
System.out.println(orderInfo);
//调用统一下单接口
Map<String, String> map = unifiedOrder(unifiedOrderUrl,orderInfo);
......@@ -141,7 +142,7 @@ public class TestWxPayServiceImpl implements TestWxPayService {
*/
@Override
public R<SortedMap<String, String>> WxPayApplets(PayPageDto payPageDto, HttpServletRequest request, HttpServletResponse response) {
if (null == payPageDto || null == payPageDto.getTotal() || null == payPageDto.getOpenid()) {
if (null == payPageDto || null == payPageDto.getTotal() || null == payPageDto.getCode()) {
return R.error("入参不能为空");
}
SortedMap<String, String> mapParams = new TreeMap<>();
......@@ -151,7 +152,7 @@ public class TestWxPayServiceImpl implements TestWxPayService {
//生成预支付订单,充值结果设为失败(result=1)
try {
//生成【统一下单API】所需参数的接口
String orderInfo = WxPayUtil.createOrderInfoWx(payPageDto, tradeNo, nonce_str, Applets_ID, mchid, key);
String orderInfo = WxPayUtil.createOrderInfoWx(payPageDto, tradeNo, nonce_str, Applets_ID,secrt_key, mchid, key);
System.out.println(orderInfo);
//调用统一下单接口
Map<String, String> map = unifiedOrder(unifiedOrderUrl,orderInfo);
......
......@@ -26,6 +26,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* @author 86187
* @ Description: 用户登录相关接口实现
......@@ -128,7 +131,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, User> impleme
}
@Override
public R<UserInfoVo> login(UserLoginVo userVo) {
public R<UserInfoVo> login(UserLoginVo userVo, HttpServletRequest request) {
log.info("volunteer-service[]UserLoginServiceImpl[]login[]input.param.userVo:" + userVo);
if (null == userVo || StringUtils.isBlank(userVo.getPhone()) || StringUtils.isBlank(userVo.getPassword())) {
return R.error("入参为空!");
......@@ -150,7 +153,8 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, User> impleme
if (!user.getPassword().equals(secret)) {
return R.error("密码错误,请您输入正确密码!");
}
HttpSession session = request.getSession();
String seeionId = session.getId();
//3、构造返回参数
UserInfoVo userInfoVo = new UserInfoVo();
userInfoVo.setUserId(user.getId());
......@@ -321,4 +325,6 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, User> impleme
return true;
}
}
package cn.wisenergy.service.app.impl;
import cn.hutool.system.UserInfo;
import cn.wisenergy.common.constant.CommonAttributes;
import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.Md5Util;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.common.utils.StringUtil;
import cn.wisenergy.mapper.*;
import cn.wisenergy.model.app.*;
import cn.wisenergy.model.dto.UserCommitDto;
......@@ -17,16 +13,19 @@ import cn.wisenergy.model.vo.UserShowVo;
import cn.wisenergy.model.vo.UserVipCommitVo;
import cn.wisenergy.service.app.UserService;
import cn.wisenergy.service.common.VolunteerManager;
import cn.wisenergy.service.util.WxUtil;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
......@@ -59,6 +58,12 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
@Autowired
protected VolunteerManager volunteerManager;
@Value("${wxPay.Applets_ID}")
private String appid;
@Value("${wxPay.SECRT_KEY}")
private String key;
private static final int ERROR_CODE = 1;
@Override
......@@ -106,23 +111,23 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
List<PayRecord> byId = payRecordMapper.getById(user.getId());
//计算充值卡充值次数
Integer rechargeTimes = 0;
int rechargeTimes = 0;
//支付宝充值总金额
Integer alipayMoney = 0;
int alipayMoney = 0;
//微信充值总金额
Integer weChatMoney = 0;
int weChatMoney = 0;
if (!CollectionUtils.isEmpty(byId)) {
for (PayRecord payRecord : byId) {
if (payRecord.getType() == 1) {
alipayMoney += Integer.valueOf(null == payRecord.getMoney() ? 0 : payRecord.getMoney());
alipayMoney += null == payRecord.getMoney() ? 0 : payRecord.getMoney();
}
if (payRecord.getType() == 2) {
weChatMoney += Integer.valueOf(null == payRecord.getMoney() ? 0 : payRecord.getMoney());
weChatMoney += null == payRecord.getMoney() ? 0 : payRecord.getMoney();
}
if (payRecord.getType() == 3) {
......@@ -312,8 +317,7 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
// 使用java8新特性的stream流去处理数据,把空的数据过滤掉
List<UserDto> resultBo = list.stream().filter(Objects::nonNull)
.map(t -> {
return UserDto.builder()
.map(t -> UserDto.builder()
.registerTime(t.getRegisterTime())
.source(t.getSource()==1?"PC":"APP")
.userName(t.getUserName())
......@@ -329,16 +333,15 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
.cultureGrade(t.getCultureGrade())
.majorGrade(t.getMajorGrade())
.queryLimit(t.getQueryLimit())
.build();
}).collect(Collectors.toList());
.build()).collect(Collectors.toList());
//创建文件名称
Long lon = System.currentTimeMillis();
long lon = System.currentTimeMillis();
response.setHeader("Content-disposition", "attachment;filename=" + lon + ".xlsx");
// sheet名称
EasyExcel.write(response.getOutputStream(), UserDto.class).sheet(lon.toString()).doWrite(resultBo);
EasyExcel.write(response.getOutputStream(), UserDto.class).sheet(Long.toString(lon)).doWrite(resultBo);
return R.ok(0,true);
} catch (Exception e) {
return R.ok(1,false);
......@@ -424,5 +427,68 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
userInfoVo.setUserName(userInfo.getUserName());
return R.ok(userInfoVo);
}
@Override
public R<String> appletBinding(String code,Integer userId) {
if (StringUtils.isBlank(code)||userId==null) {
return R.error("入参为空!");
}
Map<String, Object> map = WxUtil.getInfoByCode(code, appid, key);
log.info("code解析数据:"+map);
if(null == map.get("openid")){
return R.error(map.get("errmsg").toString());
}
User user = new User();
user.setOpenid(map.get("openid").toString());
user.setId(userId);
user.setUpdateTime(new Date());
int update = baseMapper.updateById(user);
if(update>0){
return R.ok("授权成功");
}
return R.error("授权失败");
}
@Override
public R<UserInfoVo> getByOpenid(String code) {
if (StringUtils.isBlank(code)) {
return R.error("入参为空!");
}
Map<String, Object> map = WxUtil.getInfoByCode(code, appid, key);
log.info("code解析数据:"+map);
if(null == map.get("openid")){
return R.error(map.get("errmsg").toString());
}
QueryWrapper<User> objectQueryWrapper = new QueryWrapper<>();
objectQueryWrapper.eq("openid",map.get("openid").toString());
User user = baseMapper.selectOne(objectQueryWrapper);
if(null == user){
return R.error("该用户还没有授权");
}
UserInfoVo userInfoVo = new UserInfoVo();
userInfoVo.setUserId(user.getId());
userInfoVo.setUserName(user.getUserName());
userInfoVo.setPhone(user.getPhone());
userInfoVo.setSex(user.getSex());
userInfoVo.setStudentType(user.getExamType());
return R.ok(userInfoVo);
}
@Override
public R<String> quitApplet(Integer userId) {
if (userId == null) {
return R.error("入参为空!");
}
User user = new User();
user.setId(userId);
user.setOpenid("");
user.setUpdateTime(new Date());
int update = baseMapper.updateById(user);
if(update>0){
return R.ok("退出成功");
}
return R.error("退出失败");
}
}
......@@ -30,26 +30,34 @@ public class Common {
public static final long SMS_TIMEOUT = 1200;
/**
* 支付宝--app_id
* 支付宝--PAY_URL
*/
public static final String PAY_URL = "https://openapi.alipay.com/gateway.do";
/***
* 支付宝--回调地址
* 支付宝--回调地址(测试服务器)
*/
public static final String NOTIFY_URL = "http://111.203.232.171:8997/pay/aliPayCallBack.do";
//测试服务器
//public static final String NOTIFY_URL = "http://111.203.232.171:8997/pay/aliPayCallBack.do";
//线上
public static final String NOTIFY_URL = "https://jygkzy.com/api/pay/aliPayCallBack.do";
/***
* 支付宝--pc端支付成功跳转地址
*/
public static final String RETURN_URL_PC = "http://111.203.232.171:8999/wallet";
//测试服务器
//public static final String RETURN_URL_PC = "http://111.203.232.171:8999/wallet";
//线上
public static final String RETURN_URL_PC = "https://jygkzy.com/wallet";
/***
* 支付宝--手机网页支付成功跳转地址
*/
public static final String RETURN_URL_WAP = "http://111.203.232.171:8999/#/history";
//测试服务器
//public static final String RETURN_URL_WAP = "http://111.203.232.171:8999/#/history";
//线上
public static final String RETURN_URL_WAP = "https://jygkzy.com/#/history";
......
......@@ -56,7 +56,9 @@ public class VolunteerListener extends AnalysisEventListener<Volunteer> {
if (StringUtils.isEmpty(volunteer.getAcademy())) {
throw new RuntimeException("院校不能为空!");
}
if (StringUtils.isEmpty(volunteer.getLowestRank())) {
volunteer.setLowestRank("--");
}
if (StringUtils.isEmpty(volunteer.getCourseDemand())) {
throw new RuntimeException("选考科目要求不能为空!");
......
......@@ -177,19 +177,18 @@ public class WxPayUtil {
/***
* pc端生成统一下单格式的订单,生成一个XML格式的字符串
*/
public static String createOrderInfo(String tradeNo,String product_id,String time_expire,String appid,String mchid,String key) throws UnsupportedEncodingException {
public static String createOrderInfo(PayPageDto payPageDto,String tradeNo,String product_id,String time_expire,String appid,String mchid,String key) throws UnsupportedEncodingException {
int random=(int)(Math.random()*10+1);
String nonce_str = RandomStringUtils.randomAlphanumeric(16);
SortedMap<String,String> parameters = new TreeMap<>();
parameters.put("appid", appid);
parameters.put("mch_id",mchid);
parameters.put("body", "充值");
parameters.put("out_trade_no",tradeNo);
//parameters.put("notify_url", "http://raux9u.natappfree.cc/pay/wxPayCallBack.do");
parameters.put("notify_url",WxCommon.NOTIFY_URL);
DecimalFormat df = new DecimalFormat("#");
//parameters.put("total_fee", df.format(payPageDto.getTotal()*100));
parameters.put("total_fee", df.format(1));
parameters.put("total_fee", df.format(random));
parameters.put("nonce_str", nonce_str);
parameters.put("trade_type","NATIVE");
parameters.put("product_id", product_id);
......@@ -212,12 +211,11 @@ public class WxPayUtil {
/***
* h5生成统一下单格式的订单,生成一个XML格式的字符串
*/
public static String createOrderInfoH5(String tradeNo, HttpServletRequest request, String appid, String mchid, String key) {
public static String createOrderInfoH5(PayPageDto payPageDto,String tradeNo, HttpServletRequest request, String appid, String mchid, String key) {
int random=(int)(Math.random()*10+1);
String nonce_str = RandomStringUtils.randomAlphanumeric(16);
String sceneInfo="{'h5_info':{'type':'WAP','wap_url': 'http://111.203.232.171:8999/','wap_name': '充值'}}";
String sceneInfo="{'h5_info':{'type':'WAP','wap_url': 'https://jygkzy.com','wap_name': '充值'}}";
String spbill_create_ip = getRealIp(request);
SortedMap<String,String> parameters = new TreeMap<>();
parameters.put("appid", appid);
parameters.put("mch_id", mchid);
......@@ -226,7 +224,7 @@ public class WxPayUtil {
parameters.put("nonce_str", nonce_str);
DecimalFormat df = new DecimalFormat("#");
//parameters.put("total_fee", df.format(payPageDto.getTotal()*100));
parameters.put("total_fee", df.format(1));
parameters.put("total_fee", df.format(random));
parameters.put("notify_url",WxCommon.NOTIFY_URL);
parameters.put("trade_type","MWEB");
parameters.put("scene_info",sceneInfo);
......@@ -248,7 +246,9 @@ public class WxPayUtil {
/***
* 小程序生成统一下单格式的订单,生成一个XML格式的字符串
*/
public static String createOrderInfoWx(PayPageDto payPageDto,String tradeNo,String nonce_str,String Applets_ID,String mchid,String key) {
public static String createOrderInfoWx(PayPageDto payPageDto,String tradeNo,String nonce_str,String Applets_ID,String secrt_key,String mchid,String key) {
int random=(int)(Math.random()*10+1);
Map<String, Object> infoByCode = WxUtil.getInfoByCode(payPageDto.getCode(), Applets_ID, secrt_key);
SortedMap<String,String> parameters = new TreeMap<>();
parameters.put("appid", Applets_ID);
parameters.put("mch_id", mchid);
......@@ -258,9 +258,9 @@ public class WxPayUtil {
parameters.put("nonce_str", nonce_str);
DecimalFormat df = new DecimalFormat("#");
//parameters.put("total_fee", df.format(payPageDto.getTotal()*100));
parameters.put("total_fee", df.format(1));
parameters.put("total_fee", df.format(random));
parameters.put("trade_type","JSAPI");
parameters.put("openid", payPageDto.getOpenid());
parameters.put("openid", infoByCode.get("openid").toString());
parameters.put("spbill_create_ip","0.0.0.0");
String sign = createSign(parameters,key);
parameters.put("sign", sign);//签名
......
package cn.wisenergy.service.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import java.util.*;
public class WxUtil {
public static Map<String,Object> getInfoByCode(String code,String appid,String key) {
StringBuilder url = new StringBuilder("https://api.weixin.qq.com/sns/jscode2session?");
url.append("appid=").append(appid);//appid设置
url.append("&secret=").append(key);//secret设置
url.append("&js_code=").append(code);//code设置
url.append("&grant_type=authorization_code");
Map<String, Object> map = null;
try {
HttpClient client = HttpClientBuilder.create().build();//构建一个Client
HttpGet get = new HttpGet(url.toString()); //构建一个GET请求
HttpResponse response = client.execute(get);//提交GET请求
HttpEntity result = response.getEntity();//拿到返回的HttpResponse的"实体"
String content = EntityUtils.toString(result);
JSONObject res = JSONObject.parseObject(content);
map=parseJSON2Map(res);
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
//JSONObject转map
public static Map<String, Object> parseJSON2Map(JSONObject json) {
Map<String, Object> map = new HashMap<>();
// 最外层解析
for (Object k :json.keySet()) {
Object v = json.get(k);
// 如果内层还是数组的话,继续解析
if (v instanceof JSONArray) {
List<Map<String, Object>> list = new ArrayList<>();
for (Object o : (JSONArray) v) {
JSONObject json2 = (JSONObject) o;
list.add(parseJSON2Map(json2));
}
map.put(k.toString(), list);
} else {
map.put(k.toString(), v);
}
}
return map;
}
}
......@@ -12,7 +12,8 @@ public class WxCommon {
public static final String MCHID = "1606042985";
public static final String NOTIFY_URL = "http://111.203.232.171:8997/pay/wxPayCallBack.do";
//public static final String NOTIFY_URL = "http://111.203.232.171:8997/pay/wxPayCallBack.do";
public static final String NOTIFY_URL = "https://jygkzy.com/api/pay/wxPayCallBack.do";
public static final String WX_PAY_URL_pc = "https://api.mch.weixin.qq.com/v3/pay/transactions/native";
......
......@@ -172,8 +172,35 @@ public class UserController {
@PostMapping("/add")
public R<UserInfoVo> addUserVip(@RequestBody UserVipCommitVo userVipCommitVo){
log.info("UserController[].addUserVip[].input.param:"+userVipCommitVo);
return userService.commitUserVipInfo(userVipCommitVo);
}
@ApiOperation(value = "用户登录小程序授权",notes = "用户登录小程序授权",httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "code",value = "用户临时code",dataType="string"),
@ApiImplicitParam(name = "userId",value = "用户userId",dataType="Integer"),
})
@GetMapping("/appletBinding")
public R<String> appletBinding(String code,Integer userId){
log.info("UserController[]appletBinding[]input.param:queryV0:" + code);
return userService.appletBinding(code,userId);
}
@ApiOperation(value = "查看用户是否授权",notes = "查看用户是否授权",httpMethod = "GET")
@ApiImplicitParam(name = "code",value = "用户临时code",dataType="string")
@GetMapping("/getByOpenid")
public R<UserInfoVo> getByOpenid(String code){
log.info("UserController[]getByUnionid[]input.param:queryV0:" + code);
return userService.getByOpenid(code);
}
@ApiOperation(value = "退出小程序",notes = "退出小程序",httpMethod = "GET")
@ApiImplicitParam(name = "userId",value = "用户userId",dataType="Integer")
@GetMapping("/quitApplet")
public R<String> quitApplet(Integer userId){
log.info("UserController[]quitApplet[]input.param:queryV0:" + userId);
return userService.quitApplet(userId);
}
}
......@@ -13,6 +13,8 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
/**
* @author 86187
* @ Description: PC-用户登录
......@@ -60,13 +62,13 @@ public class UserLoginController extends BaseController {
@ApiOperation(value = "用户账号密码登录", notes = "用户账号密码登录", httpMethod = "POST")
@ApiImplicitParam(name = "userVo", value = "登录用户信息", dataType = "UserLoginVo")
@PostMapping("/login")
public R<UserInfoVo> login(@RequestBody UserLoginVo userVo) {
public R<UserInfoVo> login(@RequestBody UserLoginVo userVo, HttpServletRequest request) {
log.info("volunteer-service[]UserLongController[]login[]input.param.userVo:" + userVo);
if (null == userVo || StringUtils.isBlank(userVo.getPhone()) || StringUtils.isBlank(userVo.getPassword())) {
return R.error("入参不能为空!");
}
return userLoginService.login(userVo);
return userLoginService.login(userVo,request);
}
......
......@@ -53,20 +53,19 @@ public class ShiroConfig {
// 设置拦截器集合
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
// filterChainDefinitionMap.put("/authInformation/save", "anon");//存储设备IMEI号和手机SIM卡ID号
// filterChainDefinitionMap.put("/sys/login", "anon"); // 登录页面-身份认证
// filterChainDefinitionMap.put("/sys/registered", "anon"); // 注册页面
// filterChainDefinitionMap.put("/swagger-ui.html", "anon"); // swagger接口-匿名访问
// filterChainDefinitionMap.put("/swagger/**", "anon");
// filterChainDefinitionMap.put("/admin/anon/**", "anon");
// filterChainDefinitionMap.put("/webjars/springfox-swagger-ui/**", "anon");
// filterChainDefinitionMap.put("/swagger-resources/**", "anon");
// filterChainDefinitionMap.put("/v2/api-docs", "anon");
// filterChainDefinitionMap.put("/upload_flowChart/**", "anon");//图片地址
// filterChainDefinitionMap.put("/webSocket/**", "anon");//socket
// filterChainDefinitionMap.put("/message/**", "anon");//消息推送接口
// filterChainDefinitionMap.put("/**", "oauth2"); // 其他路径均需要身份认证,一般位于最下面,优先级最低
/*filterChainDefinitionMap.put("/authInformation/save", "anon");//存储设备IMEI号和手机SIM卡ID号
filterChainDefinitionMap.put("/user/login/*", "anon"); // 登录页面-身份认证
filterChainDefinitionMap.put("/swagger-ui.html", "anon"); // swagger接口-匿名访问
filterChainDefinitionMap.put("/swagger/**", "anon");
filterChainDefinitionMap.put("/admin/anon/**", "anon");
filterChainDefinitionMap.put("/webjars/springfox-swagger-ui/**", "anon");
filterChainDefinitionMap.put("/swagger-resources/**", "anon");
filterChainDefinitionMap.put("/v2/api-docs", "anon");
filterChainDefinitionMap.put("/upload_flowChart/**", "anon");//图片地址
filterChainDefinitionMap.put("/webSocket/**", "anon");//socket
filterChainDefinitionMap.put("/message/**", "anon");//消息推送接口
filterChainDefinitionMap.put("/**", "oauth2"); // 其他路径均需要身份认证,一般位于最下面,优先级最低
*/
// 设置拦截器
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
......
......@@ -74,10 +74,11 @@ aliPay:
APP_ID: 2021002126609937
ALIPAY_PUBLIC_KEY: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2cUDFyw7sLpTpICDURNefRfzr7I7qO5Spq6HwdyFbVv5m6wVzt3fXYTcDrVUuzfbV7+rrXqnvk7LNOp10qPtUyHyZKO2jTBBcUK5H0RPNzs1XInKaSTAznGH8dEAk6yQiwhSDpQzwoOq1Ool2MQocdkcBWwAMEcEUByIbJ4ABsrwXdmkgu2hDHR/GgLvarUp1zOXfZkaTK//L1GUI5uCI+/omcqMPDIOwd8DfcNr0TKlXfAEixp9eVuU/b09b7vW7O9Vh+w0gmy5FN+BWX/JaRRL1DhRqbHl7Sl4/oGu1yjfQA5U8jXBgd+QjwdUiAXVwPdESS/AUbPWE517eH5FtQIDAQAB
PRIVATE_KEY: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCA9/p6UJH2kpTumbyRt/gdAOUnRJQ0VRQj/o0GtJ9ECweSIk6+8K81CAGcfmdeB6ZfteXZlKr9SGf3hkwuOz5oOJb5GAmKgv60T6zrBm5/MSVYhDY935eCYjFSj59w2120kvtWvq94Km3TkvAstrbSwBgpS4eutZ2qg1U4h5j6H3v+PB6RxyOsugarEYQ6TxCTr/CWHWU9G28yXSaQ66S3rsxl5aSpUCY+lUwIEVmZ9SyAa+g4FV3EfRitssiKMdCuli46YQ0/uxc59igCdgd4uxygswYgUGfP4HLQ5wEGPn7H4Q5IxSlxPvc60fYxgkRo9NMZgAljRohGdKP2u6jjAgMBAAECggEAGRakbljwHCRlvoi/qyU7qgC7k0j+/7MxSNNDAfPvK6Btp5ru8KwHmWxmS9g3KY6ZafMLtKj8HmuQdhF1DmVN/Z5MmEZ5zK0w+UiqncnRgwK/fhmyJ5Uwdxe8+o+f96dk8jTJmhVcMycl2Eu0Vy5wIE1oJdhgm7cO5dXIpUeTlcx09F3v2xx4lvmJTQvzPxgFYMbB7M8ijEQvkeXdBw7fAlA+izl8Paovgv6tu/dikImZZZgoHKZugZbz3orxpZWiIXzoB9SymBo+lWkeGMj55hlKV9sXTrf5pM6vd5JYmzfYoF/bcO7k4NJ0Elddz3EHe/0IX8M90rAH9WFSdLGseQKBgQDMkEPUfrWP/Z6nE76muUQE4y3OH0ckLacbCEI+RseVNqSKIs+TrzhQllvb/V/foeiv6SLBvmyWbO3AX+Gh9GuedLyRTct/K9o1J3Q4GAa8jGJeoi1uYPPAfqt3BMv05/i1jIvTePUrxp1NV7u0/i9QmV4R1it0+abs2Ro8Q3XqZwKBgQChZa3UBe4FbaTBWVToU4lW5KdEv93gm6iKQiHWI4yTXaJJlPOo8Hx9+/REeaxOIsaW6XZLyarNuh+cThTv4GLJKjogjcq9B1oNWgS6Z41CJZIkW/IFgjZvHh3n+SD3pTijA9y7usgu/R0OsVwrlAMyMvl7JdIMRYXFckRhb1v4JQKBgQC3+Ao4gZfRnjpfcd9k23rzlkfsdq6pN7FwGzZQAaGebNz/Kh1aaRuRRhfouW7OlTLJeTZ73UCU6/PJrbEi0Mk0YTHwz3DytsJwSUI47EqqqOoSx3FqMiEk/gZAbHzsjO5cf8CEd+St8Noo43z5Yhu1NainC+BbO+ZGXV0900GpgwKBgEEx2nK/5nLo5Fl55VNnkx23hV2/BzhYiE85AYQHnhxVAV4pvfcrFY6qfPRAFfsGDyQcsD1S/BzYJzazT7/J6v2JgituO0v6MUUdbLWDaMskdBEd1vikrapbBweSWd/PLL6kq8BlZcGdWuR5flrYEiZv8tjs4Rk16CBm1PpqykLFAoGASgkWQocPk0PYnEr1anXeiabc+/hMj4cZv3ynGv7NU9hUkZszMDKutG63y3nZ1QJPtfcF7xgTKpABfdIMCbAzKzDpd2znFg/bTxCV23GV6SNSWU+R8WC+30jw5o3W++wcILmd83L4IWLXUo6+GI0wqDBNOYG+nDLs1gWfBvX4UbI=
#微信支付appid、mchid、密钥、小程序appid
#微信支付appid、mchid、密钥、小程序appid、小程序密钥
wxPay:
APP_ID: wx7d8f4502a2bfa865
MCH_ID: 1606042985
PRIVATE_KEY: a72e174a8c7f903bc4e5ae3c021eb552
Applets_ID: wx9390a17892607f6c
SECRT_KEY: 9af0c20d6d88063aecd0adaea2f9af6d
......@@ -4,6 +4,7 @@ server:
max-threads: 1000
min-spare-threads: 30
port: 8997
#port: 8080
connection-timeout: 5000ms
spring:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment