Commit 94cb9fda authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/master'

parents 7a6296d1 0d146e7c
......@@ -112,7 +112,11 @@
<artifactId>hutool-all</artifactId>
<version>4.5.10</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
<!-- swagger注解 -->
<dependency>
<groupId>io.swagger</groupId>
......
......@@ -3,11 +3,16 @@ package com.github.wxiaoqi.security.common.filter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class AcceptFilter extends Filter<ILoggingEvent> {
// @Autowired
// MailServiceImpl mailService;
@Override
public FilterReply decide(ILoggingEvent event) {
if(event.getLoggerName().startsWith("com.xxfc.platform") || event.getLoggerName().startsWith("com.github.wxiaoqi") || event.getLoggerName().contains("Exception")) {
if(event.getLoggerName().contains("Exception") || event.getLoggerName().contains("ERROR") || event.getLoggerName().startsWith("com.xxfc.platform") || event.getLoggerName().startsWith("com.github.wxiaoqi") || event.getLoggerName().contains("Exception")) {
return FilterReply.ACCEPT;
} else {
return FilterReply.DENY;
......
......@@ -6,22 +6,42 @@ import com.github.wxiaoqi.security.common.exception.auth.ClientTokenException;
import com.github.wxiaoqi.security.common.exception.auth.UserInvalidException;
import com.github.wxiaoqi.security.common.exception.auth.UserTokenException;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.util.HttpRequestUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.io.StringWriter;
import static org.springframework.http.HttpStatus.NOT_EXTENDED;
/**
* Created by ace on 2017/9/8.
*/
@ControllerAdvice("com.github.wxiaoqi.security")
@ResponseBody
public class GlobalExceptionHandler {
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
private Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
/**
* 在controller里面内容执行之前,校验一些参数不匹配啊,Get post方法不对啊之类的
*/
@Override
protected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object body, HttpHeaders headers, HttpStatus status, WebRequest request) {
logger.error(ex.getMessage(),ex);
return new ResponseEntity<>("出错了", NOT_EXTENDED);
}
@ExceptionHandler(ClientTokenException.class)
public BaseResponse clientTokenExceptionHandler(HttpServletResponse response, ClientTokenException ex) {
response.setStatus(403);
......@@ -49,6 +69,7 @@ public class GlobalExceptionHandler {
if(0 == ex.getStatus()) {
response.setStatus(500);
}
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + ex.getStackTrace().toString());
return new BaseResponse(ex.getStatus(), ex.getMessage());
}
......@@ -56,7 +77,15 @@ public class GlobalExceptionHandler {
public BaseResponse otherExceptionHandler(HttpServletResponse response, Exception ex) {
response.setStatus(500);
logger.error(ex.getMessage(),ex);
Throwable cause = ex.getCause();
if(cause != null && cause.toString().contains("Exception")) {
StringWriter stringWriter = new StringWriter();
cause.printStackTrace(new PrintWriter(stringWriter));
logger.error(cause.getMessage(), ex);
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + stringWriter.toString());
return new BaseResponse(5000, "Server exception: " + ex.getMessage());
}
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + ex.getStackTrace().toString());
return new BaseResponse(CommonConstants.EX_OTHER_CODE, ex.getMessage());
}
}
......@@ -4,10 +4,14 @@ package com.github.wxiaoqi.security.common.handler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.HttpRequestUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.io.PrintWriter;
import java.io.StringWriter;
@RestControllerAdvice("com.xxfc.platform")
@Slf4j
public class PlatformExceptionHandler {
......@@ -24,12 +28,17 @@ public class PlatformExceptionHandler {
//服务器异常
@ExceptionHandler(Exception.class)
public ObjectRestResponse<?> exceptionHandler(Exception e){
Throwable cause = e.getCause();
if(cause != null && cause.toString().contains("Exception")) {
StringWriter stringWriter = new StringWriter();
cause.printStackTrace(new PrintWriter(stringWriter));
log.error(cause.getMessage(), e);
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + stringWriter.toString());
return assembleResult(ObjectRestResponse.createFailedResult(5000, "服务器开小差了,请稍后重试!"), "Server exception: " + e.getMessage());
}
log.error("Server exception: ", e);
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + e.getStackTrace().toString());
return assembleResult(ObjectRestResponse.createFailedResult(5000, "服务器开小差了,请稍后重试!"), "Server exception: " + e.getMessage());
}
......
package com.github.wxiaoqi.security.common.util;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.net.URLDecoder;
@Slf4j
public class HttpRequestUtil {
/**
* post请求
* @param url url地址
* @return
*/
public static String httpPost(String url){
//post请求返回结果
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost method = new HttpPost(url);
String str = "";
try {
HttpResponse result = httpClient.execute(method);
url = URLDecoder.decode(url, "UTF-8");
/**请求发送成功,并得到响应**/
if (result.getStatusLine().getStatusCode() == 200) {
try {
/**读取服务器返回过来的json字符串数据**/
str = EntityUtils.toString(result.getEntity(),"UTF-8");
} catch (Exception e) {
log.error("post请求提交失败:" + url, e);
}
}
} catch (IOException e) {
log.error("post请求提交失败:" + url, e);
}
return str;
}
/**
* 发送get请求
* @param url 路径
* @return
*/
public static String httpGet(String url){
//get请求返回结果
String strResult = null;
try {
DefaultHttpClient client = new DefaultHttpClient();
//发送get请求
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
/**请求发送成功,并得到响应**/
if (response.getStatusLine().getStatusCode() == org.apache.http.HttpStatus.SC_OK) {
/**读取服务器返回过来的json字符串数据**/
strResult = EntityUtils.toString(response.getEntity(),"UTF-8");
} else {
log.error("get请求提交失败:" + url);
}
} catch (IOException e) {
log.error("get请求提交失败:" + url, e);
}
return strResult;
}
}
......@@ -92,4 +92,12 @@ public class SystemConfig {
public static final String ALIPAY = "alipay";
public static final String WXPAY = "wxpay";
/**
* 邮件服务配置
*/
public static String EMAILADDRESS = SystemProperty.getConfig("mail.fromMail.addr");
}
......@@ -21,6 +21,15 @@ SIGNNAME=滴房车
WINXIN_AppID=wx425608b69a34736f
WINXIN_PARTNER_KEY=xxfcXXDfangche74upyuns3AD4334533
WINXIN_PARTNER=1539689201
#邮件配置
mail.fromMail.addr=1367272022@qq.com
spring.mail.host=smtp.qq.com
spring.mail.password=ykfopfvlfpbyhccc // 授权密码,非登录密码
spring.mail.properties.smtp.auth=true
spring.mail.properties.smtp.timeout=25000
spring.mail.username=1367272022@qq.com
#ios
APP_ID_IOS=wx3f51779d49171d63
APP_PARTNER_IOS=1492557632
......
......@@ -3,29 +3,22 @@ package com.github.wxiaoqi.security.admin.rest;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.biz.*;
import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.entity.AppUserPosition;
import com.github.wxiaoqi.security.admin.entity.User;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.rpc.service.PermissionService;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.admin.vo.FrontUser;
import com.github.wxiaoqi.security.admin.vo.MenuTree;
import com.github.wxiaoqi.security.admin.vo.UserMemberVo;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import io.swagger.models.auth.In;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
/**
* ${DESCRIPTION}
......@@ -60,11 +53,11 @@ public class PublicController {
ObjectRestResponse userinfoByToken(String token) throws Exception {
String username = userAuthUtil.getInfoFromToken(token).getUniqueName();
if (username == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE);
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
User user = userBiz.getUserByUsername(username);
if (user == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE);
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
return new ObjectRestResponse<User>().rel(true).data(user);
}
......@@ -74,8 +67,7 @@ public class PublicController {
ObjectRestResponse userDetailByToken(String token) throws Exception {
String username = userAuthUtil.getInfoFromToken(token).getId();
if (username == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
Integer userid = Integer.parseInt(username);
return ObjectRestResponse.succ(getAppUserInfoById(userid));
......@@ -85,8 +77,7 @@ public class PublicController {
public @ResponseBody
ObjectRestResponse<AppUserDTO> userDetailById(Integer id) throws Exception {
if (id == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
return ObjectRestResponse.paramIsEmpty();
}
return ObjectRestResponse.succ(getAppUserInfoById(id));
}
......@@ -96,13 +87,11 @@ public class PublicController {
ObjectRestResponse<AppUserDTO> userDetailByUsername(String name) throws Exception {
AppUserLogin appUserLogin;
if (StrUtil.isBlank(name)) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
return ObjectRestResponse.paramIsEmpty();
}else {
appUserLogin = appUserLoginBiz.selectOne(new AppUserLogin(){{setUsername(name);}});
if(null == appUserLogin) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
}
return ObjectRestResponse.succ(getAppUserInfoById(appUserLogin.getId()));
......@@ -113,8 +102,7 @@ public class PublicController {
//获取用户基础信息
AppUserVo userVo = detailBiz.getUserInfoById(userid);
if (userVo == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户不存在!");}});
return null;
}
Integer id= userVo.getId();
Integer positionId=userVo.getPositionId();
......@@ -136,15 +124,15 @@ public class PublicController {
@RequestMapping(value = "/userinfo-by-uid", method = RequestMethod.GET)
public @ResponseBody
ObjectRestResponse userinfoByUid(Integer uid) throws Exception {
ObjectRestResponse<User> userinfoByUid(Integer uid) throws Exception {
if (uid == null||uid==0) {
throw new BaseException();
return ObjectRestResponse.paramIsEmpty();
}
User user = userBiz.getUserByUid(uid);
if (user == null) {
throw new BaseException();
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
return new ObjectRestResponse<User>().rel(true).data(user);
return ObjectRestResponse.succ(user);
}
@GetMapping("/getByUserIds")
......@@ -174,5 +162,4 @@ public class PublicController {
return ObjectRestResponse.succ(appUserVos);
}
}
package com.xxfc.platform.im.dto;
import lombok.Data;
@Data
public class MsgQueryDto {
private Integer page;
private Integer limit;
private Integer source;
private Long startTime;
private Long endTime;
private Integer praise;
private Integer comment;
private String username;
private Integer type;
}
......@@ -53,4 +53,16 @@ public class QuestionParamDto extends PageParam {
* 是否删除
*/
private Boolean isDel = false;
private String username;
private Integer source;
private Long startTime;
private Long endTime;
private Integer commentCount;
private Integer praiseCount;
}
\ No newline at end of file
......@@ -79,4 +79,11 @@ public class ImQuestion {
private String picUrl;
/**
* 来源 1、后台创建, 2、APP创建
*/
private Integer source;
private String address;
}
\ No newline at end of file
package com.xxfc.platform.im.model;
import lombok.Data;
import java.util.List;
@Data
public class AddMsgParam extends BaseExample {
private String address;//地理位置
private String audios;// 语音地址
......@@ -19,199 +22,15 @@ public class AddMsgParam extends BaseExample {
private int visible=1;// 默认 1 公开 2 私密 3 部分好友可见 4 不给谁看
private String lable;// 标签(目前用于短视频标签)
private String musicId;// 短视频的音乐Id
private String nickname;
private String sdkUrl;// sdk分享url
private String sdkIcon;// sdk分享icon
private String sdkTitle;// sdk分享title
private Integer userId;
private List<Integer> userLook;//谁可以看的玩家id
private List<Integer> userNotLook;//谁不能看的玩家id
private List<Integer> userRemindLook;//提醒谁看的玩家id
private int isAllowComment;// 是否允许评论 0:允许 1:禁止评论
public String getAddress() {
return address;
}
public String getAudios() {
return audios;
}
public int getFlag() {
return flag;
}
public String getImages() {
return images;
}
public String getMessageId() {
return messageId;
}
public String getRemark() {
return remark;
}
public int getSource() {
return source;
}
public String getText() {
return text;
}
public long getTime() {
return time;
}
public String getTitle() {
return title;
}
public int getType() {
return type;
}
public String getVideos() {
return videos;
}
public int getVisible() {
return visible;
}
public void setAddress(String address) {
this.address = address;
}
public void setAudios(String audios) {
this.audios = audios;
}
public void setFlag(int flag) {
this.flag = flag;
}
public void setImages(String images) {
this.images = images;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}
public void setRemark(String remark) {
this.remark = remark;
}
public void setSource(int source) {
this.source = source;
}
public void setText(String text) {
this.text = text;
}
public void setTime(long time) {
this.time = time;
}
private int isAllowComment;// 是否允许评论 0:允许 1:禁止评论
public void setTitle(String title) {
this.title = title;
}
public void setType(int type) {
this.type = type;
}
public void setVideos(String videos) {
this.videos = videos;
}
public void setVisible(int visible) {
this.visible = visible;
}
public List<Integer> getUserLook() {
return userLook;
}
public void setUserLook(List<Integer> userLook) {
this.userLook = userLook;
}
public List<Integer> getUserNotLook() {
return userNotLook;
}
public void setUserNotLook(List<Integer> userNotLook) {
this.userNotLook = userNotLook;
}
public List<Integer> getUserRemindLook() {
return userRemindLook;
}
public void setUserRemindLook(List<Integer> userRemindLook) {
this.userRemindLook = userRemindLook;
}
public String getFiles() {
return files;
}
public void setFiles(String files) {
this.files = files;
}
public String getSdkUrl() {
return sdkUrl;
}
public void setSdkUrl(String sdkUrl) {
this.sdkUrl = sdkUrl;
}
public String getSdkIcon() {
return sdkIcon;
}
public void setSdkIcon(String sdkIcon) {
this.sdkIcon = sdkIcon;
}
public String getSdkTitle() {
return sdkTitle;
}
public void setSdkTitle(String sdkTitle) {
this.sdkTitle = sdkTitle;
}
public String getLable() {
return lable;
}
public void setLable(String lable) {
this.lable = lable;
}
public String getMusicId() {
return musicId;
}
public void setMusicId(String musicId) {
this.musicId = musicId;
}
public int getIsAllowComment() {
return isAllowComment;
}
public void setIsAllowComment(int isAllowComment) {
this.isAllowComment = isAllowComment;
}
}
......@@ -41,7 +41,7 @@ public class Msg {
private List<Integer> userLook;//选中可见的朋友列表
private List<Integer> userNotLook;//选中不可见的朋友列表
private List<Integer> userRemindLook;//@提醒朋友列表
private Integer source; //来源,1、后台创建, 2、APP用户上传
private @Reference List<CommentVo> comments;// 评论列表
private @Reference List<Givegift> gifts;// 礼物列表
private @Reference List<PraiseVo> praises;// 赞列表
......@@ -53,8 +53,23 @@ public class Msg {
private Integer userStatus;// 该用户 状态:1=正常, -1=禁用
private String fileName;// 原文件名称
public String getPic() {
return pic;
}
public void setPic(String pic) {
this.pic = pic;
}
public Integer getSource() {
return source;
}
public void setSource(Integer source) {
this.source = source;
}
public int getIsCollect() {
return isCollect;
}
......@@ -530,7 +545,7 @@ public class Msg {
}
public static Msg build(User user, AddMsgParam param) {
public static Msg build(Integer userId, String nickname, AddMsgParam param) {
Body body = new Body();
body.title = param.getTitle();// 标题
body.text = param.getText();// 文字内容
......@@ -568,11 +583,11 @@ public class Msg {
Msg entity = new Msg();
entity.id = ObjectId.get();
entity.userId = user.getId();
if("10000" ==user.getId().toString())
entity.userId = userId;
if("10000" ==userId.toString())
entity.nickname ="客服公众号";
else
entity.nickname = user.getNickname();
entity.nickname = nickname;
entity.flag = param.getFlag();// 1=求职消息、2=招聘消息、3=普通消息
if(0==param.getVisible())
param.setVisible(1);
......
package com.xxfc.platform.im.model;
import lombok.Data;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
@Data
@Entity(value="musicInfo",noClassnameStored=true)
public class MusicInfo {
@Id
private ObjectId id;
public String cover; // 封面图地址
public long length; // 音乐长度
public String name; // 音乐名称
public String nikeName; // 创作人
public String path; // 音乐地址
private int useCount;//使用 数量
}
package com.xxfc.platform.im.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.im.dto.MsgTypeEnum;
import com.xxfc.platform.im.dto.QuestionParamDto;
......@@ -15,6 +20,7 @@ import com.xxfc.platform.im.mapper.ImQuestionMapper;
import com.xxfc.platform.im.vo.QuestionListVo;
import com.xxfc.platform.universal.feign.MQSenderFeign;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -31,6 +37,9 @@ public class ImQuestionBiz extends BaseBiz<ImQuestionMapper, ImQuestion> {
@Autowired
ImPraiseBiz imPraiseBiz;
@Autowired
UserFeign userFeign;
/**
* 获取列表
*
......@@ -38,6 +47,18 @@ public class ImQuestionBiz extends BaseBiz<ImQuestionMapper, ImQuestion> {
* @return
*/
public ObjectRestResponse getList(QuestionParamDto questionParamDto) {
if(StringUtils.isNotBlank(questionParamDto.getUsername())) {
AppUserLogin appUserLogin = userFeign.one(questionParamDto.getUsername());
if(appUserLogin != null) {
questionParamDto.setUserId(Long.parseLong(appUserLogin.getId() + ""));
}
}
if (questionParamDto.getStartTime() != null) {
if(questionParamDto.getEndTime() == null) {
questionParamDto.setEndTime(System.currentTimeMillis());
}
}
Query query = new Query(questionParamDto);
PageDataVO<QuestionListVo> pageDataVO = PageDataVO.pageInfo(query, () -> mapper.getQuestionList(query.getSuper()));
AppUserDTO appUserDTO = userBiz.getUserInfo();
......@@ -50,7 +71,6 @@ public class ImQuestionBiz extends BaseBiz<ImQuestionMapper, ImQuestion> {
public ObjectRestResponse one(Integer id) {
return ObjectRestResponse.succ(mapper.getOne(id));
}
......@@ -66,6 +86,7 @@ public class ImQuestionBiz extends BaseBiz<ImQuestionMapper, ImQuestion> {
if (appUserDTO == null) {
return ObjectRestResponse.createFailedResult(508, "token is null or invalid");
}
imQuestion.setSource(2);
imQuestion.setUserId(Long.parseLong(appUserDTO.getImUserid() + ""));
imQuestion.setNickname(appUserDTO.getNickname());
imQuestion.setPicUrl(appUserDTO.getHeadimgurl());
......@@ -82,6 +103,33 @@ public class ImQuestionBiz extends BaseBiz<ImQuestionMapper, ImQuestion> {
return ObjectRestResponse.succ();
}
public ObjectRestResponse update(ImQuestion imQuestion) {
if (imQuestion == null || imQuestion.getId() == null) {
return ObjectRestResponse.paramIsEmpty();
}
ImQuestion oldValue = mapper.selectByPrimaryKey(imQuestion.getId());
if (oldValue == null) {
return ObjectRestResponse.createFailedResult(ResultCode.IM_MSG_NOT_EXIST_CODE, ResultCode.getMsg(ResultCode.IM_MSG_NOT_EXIST_CODE));
}
BeanUtil.copyProperties(imQuestion, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
updateSelectiveByIdRe(oldValue);
return ObjectRestResponse.succ();
}
/**
* 后台创建
* @return
*/
public ObjectRestResponse bgAdd(ImQuestion imQuestion) {
if(imQuestion == null) {
return ObjectRestResponse.paramIsEmpty();
}
imQuestion.setSource(1);
insertSelectiveRe(imQuestion);
return ObjectRestResponse.succ();
}
/**
* 删除消息,修改isDel为true
*
......@@ -105,6 +153,18 @@ public class ImQuestionBiz extends BaseBiz<ImQuestionMapper, ImQuestion> {
return ObjectRestResponse.succ();
}
public ObjectRestResponse deleteById(Long id) {
if (id == null) {
return ObjectRestResponse.paramIsEmpty();
}
ImQuestion imQuestion = mapper.selectByPrimaryKey(id);
if (imQuestion == null) {
return ObjectRestResponse.createDefaultFail();
}
imQuestion.setIsDel(true);
updateSelectiveByIdRe(imQuestion);
return ObjectRestResponse.succ();
}
public ObjectRestResponse update(Long id, MsgTypeEnum type, UpdateTypeEnum updateType) {
if (id == null || type == null) {
......
......@@ -41,4 +41,23 @@ public class ImQuestionController {
public ObjectRestResponse delete(Long id) {
return imQuestionBiz.delete(id);
}
@GetMapping(value = "/bg/app/unauth/delete")
@ApiOperation(value = "删除问答信息")
public ObjectRestResponse deleteById(Long id) {
return imQuestionBiz.deleteById(id);
}
@PostMapping(value = "/bg/app/unauth/update")
@ApiOperation(value = "修改问答信息")
public ObjectRestResponse update(@RequestBody ImQuestion imQuestion) {
return imQuestionBiz.update(imQuestion);
}
@PostMapping(value = "/bg/app/unauth/add")
@ApiOperation(value = "添加问答信息")
public ObjectRestResponse bgAdd(@RequestBody ImQuestion imQuestion) {
return imQuestionBiz.bgAdd(imQuestion);
}
}
......@@ -2,11 +2,11 @@ package com.xxfc.platform.im.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.im.biz.MsgBiz;
import com.xxfc.platform.im.dto.MsgQueryDto;
import com.xxfc.platform.im.model.AddMsgParam;
import com.xxfc.platform.im.model.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("msg")
......@@ -40,4 +40,26 @@ public class MsgController {
public ObjectRestResponse deleteByIds(String ids) {
return msgBiz.deleteByList(ids);
}
@GetMapping(value = "/bg/app/unauth/delete")
public ObjectRestResponse deleteById(String id) {
return msgBiz.deleteById(id);
}
@PostMapping(value = "/bg/app/unauth/addMsg")
public ObjectRestResponse addMsg(@RequestBody AddMsgParam param) {
return ObjectRestResponse.succ(msgBiz.add(param));
}
@PostMapping(value = "/bg/app/unauth/update")
public ObjectRestResponse updateMsg(@RequestBody Msg msg) {
return msgBiz.update(msg);
}
@PostMapping(value = "/bg/app/unauth/list")
public ObjectRestResponse getMsgList(@RequestBody MsgQueryDto msgQueryDto) {
return msgBiz.getMsgList(msgQueryDto);
}
}
......@@ -2,19 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxfc.platform.im.mapper.ImQuestionMapper">
<resultMap id="BaseResultMap" type="com.xxfc.platform.im.entity.ImQuestion">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="title" jdbcType="VARCHAR" property="title"/>
<result column="latitude" jdbcType="VARCHAR" property="latitude"/>
<result column="longitude" jdbcType="VARCHAR" property="longitude"/>
<result column="model" jdbcType="VARCHAR" property="model"/>
<result column="time" jdbcType="BIGINT" property="time"/>
<result column="user_id" jdbcType="BIGINT" property="userId"/>
<result column="visible" jdbcType="INTEGER" property="visible"/>
<result column="state" jdbcType="VARCHAR" property="state"/>
<result column="is_del" jdbcType="BIT" property="isDel"/>
<result column="content" jdbcType="LONGVARCHAR" property="content"/>
</resultMap>
<resultMap id="listResultMap" type="com.xxfc.platform.im.vo.QuestionListVo">
<id column="id" jdbcType="BIGINT" property="id"/>
......@@ -33,15 +20,25 @@
<if test="userId != null">
and user_id = #{userId}
</if>
<if test="source != null">
and source = #{source}
</if>
<if test="praiseCount != null">
and praise_count &gt;= #{source}
</if>
<if test="commentCount != null">
and comment_count &gt;= #{commentCount}
</if>
<if test="visible != null">
and visible = #{visible}
</if>
<if test="startTime != null">
and time &gt;= #{startTime} and time &lt;= #{endTime}
</if>
<if test="state != null">
and state = #{state}
</if>
<if test="isDel != null">
and is_del = #{isDel}
</if>
and is_del = 0
</where>
order by upd_time DESC
</select>
......
......@@ -51,11 +51,13 @@ public class OrderDepositRefundRecordBiz extends BaseBiz<DepositRefundRecordMapp
*/
@Transactional
public void saveNormalRecord(DepositRefundRecord depositRefundRecord) {
log.info("正常还车,添加押金记录: depositRefundRecord = {}", depositRefundRecord.toString());
depositRefundRecord.setStatus(DepositRefundStatus.INITIATEREFUND.getCode());
depositRefundRecord.setIscomplete(true);
insertSelectiveRe(depositRefundRecord);
depositRefundRecord.setStatus(DepositRefundStatus.REFUNDARRIVAL.getCode());
depositRefundRecord.setIscomplete(false);
depositRefundRecord.setRestAmount(depositRefundRecord.getTotalAmount().subtract(depositRefundRecord.getAmount()));
insertSelectiveRe(depositRefundRecord);
depositRefundRecord.setStatus(DepositRefundStatus.VIOLATIONARRIVAL.getCode());
depositRefundRecord.setRestAmount(getAmount());
......@@ -68,6 +70,7 @@ public class OrderDepositRefundRecordBiz extends BaseBiz<DepositRefundRecordMapp
*/
@Transactional
public void saveFixLossRecord(DepositRefundRecord depositRefundRecord) {
log.info("定损还车,添加押金记录: depositRefundRecord = {}", depositRefundRecord.toString());
depositRefundRecord.setStatus(DepositRefundStatus.FIXLOSS.getCode());
depositRefundRecord.setIscomplete(true);
insertSelectiveRe(depositRefundRecord);
......@@ -159,8 +162,13 @@ public class OrderDepositRefundRecordBiz extends BaseBiz<DepositRefundRecordMapp
if(depositRefundRecord != null) {
DepositRefundRecord newValue = new DepositRefundRecord();
BeanUtil.copyProperties(depositRefundRecord, newValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
newValue.setAmount(orderViolation.getPrice());
newValue.setRestAmount(depositRefundRecord.getTotalAmount().subtract(orderViolation.getPrice()));//减去违章金之后的押金
if (orderViolation.getPrice().doubleValue() > 0) {
newValue.setAmount(orderViolation.getPrice());
newValue.setRestAmount(depositRefundRecord.getRestAmount().subtract(orderViolation.getPrice()));//减去违章金之后的押金
} else {
newValue.setAmount(new BigDecimal(0));
newValue.setRestAmount(depositRefundRecord.getRestAmount());//减去违章金之后的押金
}
newValue.setIscomplete(false);
newValue.setId(null);
mapper.insert(newValue);
......
......@@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.druid.sql.visitor.functions.If;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
......@@ -24,7 +23,6 @@ import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mapper.OrderVehicaleCrosstownMapper;
import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.order.CheckUserInfoDto;
......@@ -40,9 +38,7 @@ import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.pojo.VehicleArrivalVo;
import com.xxfc.platform.vehicle.pojo.VehicleDepartureVo;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.util.Lists;
......@@ -255,16 +251,12 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
}
Vehicle vehicle = null;
RestResponse<Vehicle> vehicleRestResponse = vehicleFeign.findById(orderRentVehicleDetail.getVehicleId());
log.info("获取车辆信息返回消息:{}", vehicleRestResponse.getMessage());
if (vehicleRestResponse.getData() != null) {
vehicle = vehicleRestResponse.getData();
}
if (vehicle == null) {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode(), ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc());
}
// if (vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode())) {
// return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode(), ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc());
// }
if (baseOrder.getStatus() != -1) {
if (vehicle.getMileageLastUpdate() != null) {
//判断车辆公里数
......@@ -272,7 +264,6 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode(), ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc());
}
}
}
//添加验车人信息
JSONArray list = new JSONArray();
......@@ -300,6 +291,9 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
try {
RestResponse restResponse = vehicleFeign.departureBySmall(vehicleDepartureVo);
if (restResponse.getStatus() != 200) {
return ObjectRestResponse.createFailedResult(1001, restResponse.getMessage());
}
log.error("返回信息: " + restResponse.toString());
} catch (Exception e) {
return ObjectRestResponse.createFailedResult(1001, e.getMessage());
......@@ -317,6 +311,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
try {
RestResponse restResponse = vehicleFeign.arrivalBySmall(vehicleArrivalVo);
log.info("返回信息: " + restResponse.toString());
return ObjectRestResponse.createFailedResult(restResponse.getStatus(), restResponse.getMessage());
} catch (Exception e) {
return ObjectRestResponse.createFailedResult(500, e.getMessage());
}
......@@ -384,7 +379,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
return ObjectRestResponse.succ(oldValue.get(0));
} else if (oldValue.size() <= 0) {
orderVehicleCrosstownDto.setDeductionCost(amount);
//扣除费用
//剩余押金 = 总押金 - 扣除费用
orderVehicleCrosstownDto.setRestDeposit(orderRentVehicleDetail.getDeposit().subtract(orderVehicleCrosstownDto.getDeductionCost()));
if (orderVehicleCrosstownDto.getRestDeposit().compareTo(getAmount()) == -1) { //剩余金额小于保证金
return ObjectRestResponse.createFailedResult(500, "押金不足,不能交车,请联系客服!");
......@@ -424,6 +419,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
OrderVehicleCrosstownDto orderVehicleCrosstownDto = list.get(0);
OrderVehicleCrosstown orderVehicleCrosstown1 = new OrderVehicleCrosstown();
BeanUtil.copyProperties(orderVehicleCrosstownDto, orderVehicleCrosstown1, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
//添加押金记录
DepositRefundRecord depositRefundRecord = new DepositRefundRecord();
depositRefundRecord.setAmount(orderVehicleCrosstown.getDeductionCost());
depositRefundRecord.setRestAmount(totalAmount.subtract(getAmount()).subtract(orderVehicleCrosstown1.getDeductionCost()));
......
......@@ -36,6 +36,10 @@
</exclusions>
<version>4.4.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
......
package com.xxfc.platform.universal.biz;
import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Slf4j
@Service
public class MailServiceBiz {
@Autowired
JavaMailSender mailSender;
public void sendSimpleMail(String to, String subject, String content) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(SystemConfig.EMAILADDRESS);
message.setTo(to);
message.setSubject(subject);
message.setText(content);
try {
mailSender.send(message);
log.info("简单邮件已经发送。{}", message);
}catch (Exception e) {
log.error("发送简单邮件时发生异常!", e);
}
}
public void run(String to, String subject, String content) {
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.submit(new Task(to, subject, content));
}
@Data
class Task implements Runnable{
private String toUser;
private String subject;
private String content;
public Task(String toUser, String subject, String content) {
this.toUser = toUser;
this.subject = subject;
this.content = content;
}
@Override
public void run() {
sendSimpleMail(toUser, subject, content);
}
}
}
\ No newline at end of file
......@@ -258,7 +258,6 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
}
return ObjectRestResponse.createDefaultFail().getMessage();
}
/**
* 支付宝生成支付信息
*
......@@ -316,7 +315,6 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
//这里和普通的接口调用不同,使用的是sdkExecute
AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
log.info(response.getBody());//就是orderString 可以直接给客户端请求,无需再做处理。
return response.getBody();
} catch (AlipayApiException e) {
log.error(e.getMessage(), e);;
......@@ -338,12 +336,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
"\"amount\": \"" + realAmount.toString() + "\" }");
request.setNotifyUrl(notifyUrl);//异步通知地址,必填,该接口只通过该参数进行异步通知
AlipayFundAuthOrderAppFreezeResponse response = alipayClient.sdkExecute(request);//注意这里是sdkExecute,可以获取签名参数
log.info("response: {}" + response.getBody());//签名后的参数,直接入参到
if (response.isSuccess()) {
log.info("调用成功");
log.info("response: {}" + response.getBody());//签名后的参数,直接入参到
log.info("预授权冻结调用成功");
return response.getBody();
} else {
log.info("调用失败");
log.info("预授权冻结调用失败");
return null;
}
}
......@@ -360,6 +358,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
request.setGrantType("authorization_code");
request.setCode(code);
AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
log.info("获取用户token调用成功,获取用户信息 {}", response.getBody());
if(response.isSuccess()){
log.info("获取用户token调用成功,获取用户信息 {}", response.getBody());
if(response.getAccessToken() != null) {
......@@ -415,10 +414,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
"\"is_mobile\":\"true\"" +
" }");
AlipayUserInfoAuthResponse response = alipayClient.execute(request);
log.info("解冻预授权response: {}" + response.getBody());
log.info(response.toString());
if(response.isSuccess()){
System.out.println("调用成功");
log.info("用户授权调用成功");
} else {
System.out.println("调用失败");
log.info("用户授权调用失败");
}
return response.getBody();
}
......@@ -438,15 +439,14 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
//选填字段,信用授权订单,针对信用全免订单,传入该值完结信用订单,形成芝麻履约记录
// model.setExtraParam("{\"unfreezeBizInfo\":\"{\\\"bizComplete\\\":\\\"true\\\"}\"}");
request.setBizModel(model);
request.setNotifyUrl(notifyUrl);//异步通知地址,必填,该接口只通过该参数进行异步通知
// request.setNotifyUrl(notifyUrl);//异步通知地址,必填,该接口只通过该参数进行异步通知
AlipayFundAuthOrderUnfreezeResponse response = alipayClient.execute(request);
log.info("response: {}" + response.getBody());
log.info("解冻预授权response: {}" + response.getBody());
if (response.isSuccess()) {
log.info("调用成功");
log.info("response: {}" + response.getBody());//签名后的参数,直接入参到
log.info("解冻预授权调用成功");
return true;
} else {
log.info("调用失败");
log.info("解冻预授权调用失败");
return false;
}
}
......@@ -463,16 +463,15 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
model.setOutRequestNo(serialNumber);//与支付宝的授权资金操作流水号不能同时为空,与冻结流水号相同
model.setRemark(refundReason); // 商户对本次撤销操作的附言描述,长度不超过100个字母或50个汉字
request.setBizModel(model);
request.setNotifyUrl(notifyUrl);//异步通知地址,必填,该接口只通过该参数进行异步通知
// request.setNotifyUrl(notifyUrl);//异步通知地址,必填,该接口只通过该参数进行异步通知
AlipayFundAuthOperationCancelResponse response = alipayClient.execute(request);
log.info("response: {}" + response.getBody());
log.info("取消预授权response: {}" + response.getBody());
if (response.isSuccess()) {
log.info("调用成功");
log.info("response: {}" + response.getBody());//签名后的参数,直接入参到
log.info("取消预授权调用成功");
return response.getBody();
} else {
log.info("调用失败");
log.info("取消预授权调用失败");
return null;
}
}
......@@ -503,14 +502,14 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
//如果需要从一笔授权中完成多笔订单支付,保持auth_no不变,不同订单根据outTradeNo进行标识,此时auth_confirm_mode不传或者传入NOT_COMPLETE;进行到最后一笔转支付时,auth_confirm_mode传入COMPLETE由支付宝完成剩余金额自动解冻,或者商户自行调用解冻接口将剩余金额解冻。
model.setAuthConfirmMode("NOT_COMPLETE");//传入该值用户剩余金额不会自动解冻
request.setBizModel(model);
request.setNotifyUrl(notifyUrl);//异步通知地址,必填,该接口只通过该参数进行异步通知
// request.setNotifyUrl(notifyUrl);//异步通知地址,必填,该接口只通过该参数进行异步通知
AlipayTradePayResponse response = alipayClient.execute(request);
log.info("预授权转支付response: {}" + response.getBody());
if (response.isSuccess()) {
log.info("response: {}" + response.getBody());
return true;
} else {
log.info("调用失败");
log.info("预授权转支付调用失败");
return false;
}
}
......@@ -540,6 +539,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
try {
log.info("支付宝退款中:outTradeNo = {}, tradNo = {}, refundAmount = {}, refundReason = {}", outTradeNo, tradNo, refundAmount, refundReason);
AlipayTradeRefundResponse response = alipayClient.execute(request);
log.info("APP支付退款response: {}" + response.getBody());
if (response.isSuccess()) {
return true;
} else {
......@@ -553,6 +553,30 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
return false;
}
/**
* 查询预授权订单
* @param tradNo
* @throws AlipayApiException
*/
public ObjectRestResponse fundAuthQuery(String tradNo){
AlipayClient alipayClient = getAlipayClient();
AlipayFundAuthOperationDetailQueryRequest request = new AlipayFundAuthOperationDetailQueryRequest();
AlipayFundAuthOperationDetailQueryModel model = new AlipayFundAuthOperationDetailQueryModel();
//model.setAuthNo("2017120110002001390206804295"); // 支付宝资金授权订单号,在授权冻结成功时返回参数中获得
model.setOutOrderNo(tradNo); //商户的授权资金订单号,与支付宝的授权资金订单号不能同时为空
//model.setOperationId("20171201317348823902"); //支付宝的授权资金操作流水号,冻结成功同步返回
model.setOutRequestNo(tradNo);//商户的授权资金操作流水号,与支付宝的授权资金操作流水号不能同时为空,该值为冻结或解冻是的outRequestNo
request.setBizModel(model);
AlipayFundAuthOperationDetailQueryResponse response = null;
try {
response = alipayClient.execute(request);
log.info("response: {}"+response.getBody());
} catch (AlipayApiException e) {
e.printStackTrace();
}
return ObjectRestResponse.succ(response.getBody());
}
public static void main(String[] args) throws AlipayApiException {
OrderPayBiz orderPayBiz = new OrderPayBiz();
OrderPayVo orderPayVo = new OrderPayVo();
......@@ -562,9 +586,11 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
orderPayVo.setAmount(3);
orderPayVo.setBody("扣除租车订单费用");
orderPayVo.setSubject("租车订单交易费用");
//orderPayBiz.fundAuthOrderUnFreeze(orderPayVo, "");
orderPayBiz.fundAuthOrderUnFreeze("2019111410002001530505959461", "2019111410002001530505959461", 7, "退还押金");
//orderPayBiz.alipayOrderRefund("20191024153859000003","2019102422001421530513773694", 2, "xxxx", "");
//orderPayBiz.tradePay(orderPayVo, "");
//orderPayBiz.tradePay("20191108195202000020", "2019110810002001710518149012", 120000,"退还押金", "退还押金");
//orderPayBiz.fundAuthCancel(orderPayVo, "");
//orderPayBiz.tradePay("20191114182254000019", "2019111410002001530505959461", 1,"扣除违约金", "扣除违约金");
}
}
......@@ -86,16 +86,39 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper, OrderRefund> {
boolean flag = false;
if (orderPay.getPayWay() == 2 && orderPay.getPayType() == 1) {
log.info("======支付宝APP支付退款中===========");
flag = payBiz.alipayOrderRefund(out_trade_no, orderPay.getSerialNumber(), refundAmount, refundDesc, out_trade_no + System.currentTimeMillis());
flag = payBiz.alipayOrderRefund(out_trade_no, orderPay.getSerialNumber(), refundAmount, refundDesc,
out_trade_no + System.currentTimeMillis());
} else if (orderPay.getPayWay() == 2 && orderPay.getPayType() == 2) {
log.info("======支付宝预授权支付退款中===========");
//需要根据实际传过来的参数类型来进行解冻或者预授权转支付
if (orderRefundVo.getRefundAmount() != 0) { //解冻金额
flag = payBiz.fundAuthOrderUnFreeze(orderPay.getTradeNo() + System.currentTimeMillis(), orderPay.getSerialNumber(), orderRefundVo.getRefundAmount(), orderRefundVo.getRefundDesc());
flag = payBiz.fundAuthOrderUnFreeze(out_refund_no,
orderPay.getSerialNumber(), orderRefundVo.getRefundAmount(), orderRefundVo.getRefundDesc());
}
//预授权转支付
if(orderRefundVo.getFreeze2PayAmount() != 0) {
flag = payBiz.tradePay(orderPay.getTradeNo() + System.currentTimeMillis(), orderPay.getSerialNumber(), orderRefundVo.getFreeze2PayAmount(), orderRefundVo.getFreeze2PayDesc(), orderRefundVo.getFreeze2PayDesc());
if(orderRefundVo.getFreeze2PayAmount() != null && orderRefundVo.getFreeze2PayAmount() != 0) {
log.info("======预授权转支付===========");
String refundTradeNo = Snowflake.build() + "";
boolean isComplete = payBiz.tradePay(refundTradeNo,
orderPay.getSerialNumber(), orderRefundVo.getFreeze2PayAmount(),
orderRefundVo.getFreeze2PayDesc(), orderRefundVo.getFreeze2PayDesc());
if (isComplete) {
OrderRefund orderRefund = new OrderRefund();
BeanUtils.copyProperties(orderRefund, orderRefundVo);
if (StringUtils.isNotBlank(orderRefundVo.getFreeze2PayDesc())) {
orderRefund.setRefundDesc("预授权转支付:" + orderRefundVo.getFreeze2PayDesc());
} else {
orderRefund.setRefundDesc("预授权转支付");
}
orderRefund.setRefundAmount(orderRefundVo.getFreeze2PayAmount());
orderRefund.setUserId(orderPay.getUserId());
orderRefund.setStatus(2);
orderRefund.setFinishTime(System.currentTimeMillis());
orderRefund.setRefundTradeNo(refundTradeNo);
orderRefund.setOutRefundNo(out_trade_no);
orderRefund.setSerialNumber(orderPay.getSerialNumber());
insertSelective(orderRefund);
}
}
} else if(orderPay.getPayWay() == 1){
log.info("======微信退款中===========");
......
package com.xxfc.platform.universal.controller;
import com.xxfc.platform.universal.biz.MailServiceBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("mail")
public class EmailSendController {
@Autowired
MailServiceBiz mailServiceBiz;
@GetMapping(value = "/app/unauth/send")
public void senEmail(String toUser, String subject, String content) {
mailServiceBiz.run(toUser, subject, content);
}
}
......@@ -2,6 +2,7 @@ package com.xxfc.platform.universal.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.universal.biz.OrderPayBiz;
import com.xxfc.platform.universal.entity.OrderPay;
......@@ -101,5 +102,10 @@ public class OrderPayController extends BaseController<OrderPayBiz,OrderPay> {
return baseBiz.alipayNotify();
}
@PostMapping(value = "/app/unauth/notify/fundAuthQuery")
@IgnoreUserToken
public ObjectRestResponse fundAuthQuery(String tradNo){
return baseBiz.fundAuthQuery(tradNo);
}
}
\ No newline at end of file
......@@ -316,7 +316,7 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);;
e.printStackTrace();
return RestResponse.codeAndMessage(10001, "网络异常!");
}
return RestResponse.suc();
......
......@@ -59,7 +59,7 @@ public class SysRegionBiz extends BaseBiz<SysRegionMapper, SysRegion> {
}
}
if(!hasCache){//从db读
if(!hasCache && ids != null){//从db读
rs = mapper.getByIdList(ids);
}
return rs;
......
......@@ -256,7 +256,7 @@ public class VehicleActiveService {
bookVehicleVo.setBookEndDate(null);
bookVehicleVo.setUnbookStartDate(actualArrivalDate.toString(DATE_TIME_FORMATTER));
bookVehicleVo.setUnbookEndDate(arrivalDate.toString(DATE_TIME_FORMATTER));
bookVehicleVo.setRemark(bookVehicleVo.getRemark() + " 用户提前还车,取消剩余天数, 初始预定结束时间是," + new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
bookVehicleVo.setRemark(bookVehicleVo.getRemark()==null?"": bookVehicleVo.getRemark()+ " 用户提前还车,取消剩余天数, 初始预定结束时间是," + new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
try {
Boolean hasSuc = vehicleBiz.unbookVehicle(bookVehicleVo);
......@@ -268,7 +268,7 @@ public class VehicleActiveService {
log.error(e.getMessage(), e);;
}
} else if (actualArrivalDate.compareTo(arrivalDate) > 0) {//实际还车时间大于预计还车时间
vehicleBookRecord.setRemark(vehicleBookRecord.getRemark() + " 用户延期还车,实际占用日期");
vehicleBookRecord.setRemark(vehicleBookRecord.getRemark()==null?"": vehicleBookRecord.getRemark() + " 用户延期还车,实际占用日期");
}
updateBookRecordStatus(vehicleBookRecord, 2);
departureLog.setMileageEnd(arrivalVo.getMileage());
......
......@@ -703,7 +703,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
DateTime startDay = DateTime.parse(bookVehicleVo.getBookStartDate(), DATE_TIME_FORMATTER);
DateTime endDay = DateTime.parse(bookVehicleVo.getBookEndDate(), DATE_TIME_FORMATTER);
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate, startDay, endDay);
fillDateList4DatePeriod(yearMonthAndDate, DateTime.parse(startDay.toString(DEFAULT_DATE_TIME_FORMATTER), DEFAULT_DATE_TIME_FORMATTER), DateTime.parse(endDay.toString(DEFAULT_DATE_TIME_FORMATTER), DEFAULT_DATE_TIME_FORMATTER));
if (yearMonthAndDate.size() > 3) {//连续的日期最多夸3个月
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
......
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