Commit be2ccdb2 authored by jiaorz's avatar jiaorz

Merge branch 'master-vehicle-bg' into base-modify

# Conflicts:
#	xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/biz/OrderPayBiz.java
parents c79eab37 5deb634e
......@@ -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,11 +4,15 @@ 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.apache.commons.lang3.StringUtils;
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 {
......@@ -25,12 +29,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;
}
}
......@@ -96,4 +96,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");
}
......@@ -25,6 +25,15 @@ SIGNNAME=\u6EF4\u623F\u8F66
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;// 语音地址
......@@ -30,204 +33,4 @@ public class AddMsgParam extends BaseExample {
private int isAllowComment;// 是否允许评论 0:允许 1:禁止评论
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
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;
}
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 Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public void setMusicId(String musicId) {
this.musicId = musicId;
}
public int getIsAllowComment() {
return isAllowComment;
}
public void setIsAllowComment(int isAllowComment) {
this.isAllowComment = isAllowComment;
}
}
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) {
......
......@@ -5,6 +5,8 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
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.admin.vo.ImiVo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
......@@ -13,6 +15,7 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult;
import com.xxfc.platform.im.dto.CommentVo;
import com.xxfc.platform.im.dto.MsgQueryDto;
import com.xxfc.platform.im.dto.PraiseVo;
import com.xxfc.platform.im.dto.QuestionParamDto;
import com.xxfc.platform.im.model.*;
......@@ -53,6 +56,8 @@ public class MsgBiz {
@Autowired
ThirdFeign thirdFeign;
@Autowired
UserFeign userFeign;
/**
* 获取消息列表
*
......@@ -72,7 +77,7 @@ public class MsgBiz {
Query query = null;
List<Msg> msgList = null;
if (type != null) {
query = new Query(Criteria.where("body.type").is(type));
query = new Query(Criteria.where("body.type").is(type).and("visible").is(1));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "time"));
......@@ -84,7 +89,7 @@ public class MsgBiz {
List<Integer> ids = new ArrayList<>();
ids.add(2);
ids.add(4);
query = new Query(Criteria.where("body.type").in(ids));
query = new Query(Criteria.where("body.type").in(ids).and("visible").is(1));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "time"));
......@@ -109,7 +114,7 @@ public class MsgBiz {
List<Integer> ids = new ArrayList<>();
ids.add(2);
ids.add(4);
Query query = new Query(Criteria.where("body.type").in(ids).and("count.praise").gt(getNumber()));
Query query = new Query(Criteria.where("body.type").in(ids).and("count.praise").gt(getNumber()).and("visible").is(1));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "count.praise"));
......@@ -129,7 +134,7 @@ public class MsgBiz {
if (id == null) {
return ObjectRestResponse.paramIsEmpty();
}
Query query = new Query(Criteria.where("id").is(new ObjectId(id)));
Query query = new Query(Criteria.where("id").is(new ObjectId(id)).and("visible").is(1));
List<Msg> msgList = fetchAndAttach(mongoTemplate.find(query, Msg.class, "s_msg"), userId);
List<MsgVo> msgVoList = replaceMsgResult(msgList);
if (msgVoList.size() > 0) {
......@@ -339,6 +344,76 @@ public class MsgBiz {
* 后台管理接口
*/
public ObjectRestResponse getMsgList(MsgQueryDto msgQueryDto){
//获取所有朋友圈
Integer page = msgQueryDto.getPage() == null ? 1 : msgQueryDto.getPage();
Integer limit = msgQueryDto.getLimit() == null ? 10 : msgQueryDto.getLimit();
Pageable pageable = PageRequest.of(--page, limit);
Query query = null;
List<Msg> msgList = null;
if (msgQueryDto.getType() != null) {
query = new Query(Criteria.where("body.type").is(msgQueryDto.getType()));
//评论数
if (msgQueryDto.getComment() != null) {
query.addCriteria(Criteria.where("count.comment").gte(msgQueryDto.getComment()));
}
//点赞数
if (msgQueryDto.getPraise() != null) {
query.addCriteria(Criteria.where("count.praise").gte(msgQueryDto.getPraise()));
}
//来源
if (msgQueryDto.getSource() != null) {
if (msgQueryDto.getSource() == 1) {
query.addCriteria(Criteria.where("source").is(msgQueryDto.getSource()));
} else {
query.addCriteria(Criteria.where("source").is(2));
}
}
//下单时间
if (msgQueryDto.getStartTime() != null ) {
if (msgQueryDto.getEndTime() == null) {
query.addCriteria(Criteria.where("body.time").gte(msgQueryDto.getStartTime()).lte(System.currentTimeMillis()));
} else {
query.addCriteria(Criteria.where("body.time").gte(msgQueryDto.getStartTime()).lte(msgQueryDto.getEndTime()));
}
} else {
if (msgQueryDto.getEndTime() != null) {
query.addCriteria(Criteria.where("body.time").gte(57600000).lte(msgQueryDto.getEndTime()));
}
}
//用户名
if (StringUtils.isNotBlank(msgQueryDto.getUsername())) {
AppUserLogin appUserLogin = userFeign.one(msgQueryDto.getUsername());
if (appUserLogin != null) {
query.addCriteria(Criteria.where("userId").is(appUserLogin.getImUserid()));
}
}
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "time"));
msgList = fetchAndAttach(mongoTemplate.find(query, Msg.class, "s_msg"), null);
PageInfo<MsgVo> goodPageInfo = new PageInfo<>(replaceMsgResult(msgList));
goodPageInfo.setPageSize(totalSize % limit == 0 ? totalSize / limit : totalSize / limit + 1);
goodPageInfo.setTotal(totalSize);
return ObjectRestResponse.succ(goodPageInfo);
} else {
List<Integer> ids = new ArrayList<>();
ids.add(2);
ids.add(4);
query = new Query(Criteria.where("body.type").in(ids));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "time"));
msgList = fetchAndAttach(mongoTemplate.find(query, Msg.class, "s_msg"), null);
PageInfo<MsgVo> goodPageInfo = new PageInfo<>(replaceMsgResult(msgList));
goodPageInfo.setPageSize(totalSize % limit == 0 ? totalSize / limit : totalSize / limit + 1);
return ObjectRestResponse.succ(goodPageInfo);
}
}
/**
* 新增消息接口
* @param param
......@@ -347,13 +422,18 @@ public class MsgBiz {
public Msg add(AddMsgParam param) {
//去redis根据userId是否有数据
//设置一些列参数
log.info("后台添加消息: param = {}", param);
Msg entity = Msg.build(param.getUserId(), param.getNickname(), param);
// 保存商务圈消息
mongoTemplate.save(entity);
Msg msg = mongoTemplate.save(entity, "s_msg");
if(msg == null) {
return null;
}
// 如果musicId不为空维护音乐使用次数
if(!StringUtils.isEmpty(param.getMusicId())){
updateUseCount(new ObjectId(param.getMusicId()));
}
entity.setSource(1);
if(null != param.getUserRemindLook()){
if(null != param.getUserNotLook()){
List<Integer> collect = param.getUserRemindLook().stream().filter(item -> param.getUserNotLook().contains(item)).collect(Collectors.toList());
......@@ -379,8 +459,40 @@ public class MsgBiz {
UpdateResult updateResult = mongoTemplate.updateFirst(query, update, MusicInfo.class, "musicInfo");
log.info("修改音乐使用次数: updateResult = {}", updateResult);
}
}
//修改消息信息
public ObjectRestResponse update(Msg msg) {
if (msg == null || msg.getId() == null) {
return ObjectRestResponse.paramIsEmpty();
}
Query query = new Query(Criteria.where("_id").is(msg.getId()));
Msg oldValue = mongoTemplate.findOne(query, Msg.class, "s_msg");
if (oldValue == null) {
return ObjectRestResponse.createFailedResult(ResultCode.IM_MSG_NOT_EXIST_CODE, ResultCode.getMsg(ResultCode.IM_MSG_NOT_EXIST_CODE));
}
BeanUtil.copyProperties(msg, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
Msg newValue = mongoTemplate.save(oldValue, "s_msg");
if(newValue == null) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "更新失败");
}
return ObjectRestResponse.succ(newValue);
}
public ObjectRestResponse deleteById(String id) {
if (StringUtils.isBlank(id)) {
return ObjectRestResponse.paramIsEmpty();
}
Query query = new Query(Criteria.where("_id").is(id));
Msg oldValue = mongoTemplate.findOne(query, Msg.class, "s_msg");
if (oldValue == null) {
return ObjectRestResponse.createFailedResult(ResultCode.IM_MSG_NOT_EXIST_CODE, ResultCode.getMsg(ResultCode.IM_MSG_NOT_EXIST_CODE));
}
DeleteResult deleteResult = mongoTemplate.remove(query, Msg.class, "s_msg");
if (deleteResult != null && deleteResult.getDeletedCount() == 1) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createFailedResult(ResultCode.IM_DELETE_FAIL_CODE, ResultCode.getMsg(ResultCode.IM_DELETE_FAIL_CODE));
}
}
......@@ -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,7 +2,9 @@ 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.*;
......@@ -39,9 +41,25 @@ public class MsgController {
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());
......@@ -316,7 +310,10 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
vehicleArrivalVo.setBookRecordId(orderRentVehicleDetail.getBookRecordId());
try {
RestResponse restResponse = vehicleFeign.arrivalBySmall(vehicleArrivalVo);
log.info("返回信息: " + restResponse.toString());
if (restResponse.getStatus() != 200) {
return ObjectRestResponse.createFailedResult(1001, restResponse.getMessage());
}
log.error("返回信息: " + restResponse.toString());
} catch (Exception e) {
return ObjectRestResponse.createFailedResult(500, e.getMessage());
}
......@@ -384,7 +381,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 +421,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()));
......
......@@ -401,7 +401,7 @@ public class BaseOrderController extends CommonBaseController implements UserRes
}});
orv.setAmount(baseOrder.getRealAmount().multiply(new BigDecimal("100")).intValue());
orv.setOrderNo(baseOrder.getNo());
orv.setRefundDesc("");
orv.setRefundDesc("退款");
orv.setRefundAmount(refundAmount.multiply(new BigDecimal("100")).intValue());
ObjectRestResponse<String> result = thirdFeign.refund(orv);
return ObjectRestResponse.succ(result);
......
......@@ -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
......@@ -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);
}
}
......@@ -105,6 +105,11 @@ 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);
}
@PostMapping("/app/unauth/transfer_account")
@IgnoreUserToken
......
package com.xxfc.platform.vehicle.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* 分公司停靠车辆统计
*/
@Table(name = "branch_company_vehicle_count")
@Data
public class BranchCompanyVehicleCount {
@Id
private Long id;
/**
* 公司名称
*/
@Column(name = "company_name")
private String companyName;
/**
* 当前停靠车辆数量
*/
@Column(name = "vehicle_num")
private Integer vehicleNum;
/**
* 统计日期
*/
@Column(name = "count_date")
private Date countDate;
/**
* 公司ID
*/
@Column(name = "company_id")
private Integer companyId;
}
\ No newline at end of file
package com.xxfc.platform.vehicle.pojo;
import lombok.Data;
@Data
public class BranchCompanyVehicleCountVo {
private String parkBranchCompanyName;
private Integer count;
private Integer companyId;
}
package com.xxfc.platform.vehicle.pojo.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
@Data
public class BranchCompanyVehicleCountDTO extends PageParam {
//开始时间 yyyy-MM-dd
private String startTime;
//结束时间
private String endTime;
private String companyName;
}
......@@ -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();
......
package com.xxfc.platform.vehicle.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.mapper.BranchCompanyVehicleCountMapper;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Iterator;
import java.util.List;
@Service
@Slf4j
public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCountMapper, BranchCompanyVehicleCount> {
public ObjectRestResponse add(List<BranchCompanyVehicleCount> branchCompanyVehicleCounts) {
if (branchCompanyVehicleCounts == null) {
return ObjectRestResponse.paramIsEmpty();
}
Iterator<BranchCompanyVehicleCount> iterator = branchCompanyVehicleCounts.iterator();
while (iterator.hasNext()) {
BranchCompanyVehicleCount newValue = iterator.next();
BranchCompanyVehicleCount oldValue = selectOne(newValue);
if (oldValue != null) {
iterator.remove();
}
}
insertMultiSelective(branchCompanyVehicleCounts);
return ObjectRestResponse.succ();
}
public ObjectRestResponse<PageDataVO<BranchCompanyVehicleCount>> findAll(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) {
Integer pageNo = branchCompanyVehicleCountDTO.getPage() == null ? 1 : branchCompanyVehicleCountDTO.getPage();
Integer pageSize = branchCompanyVehicleCountDTO.getLimit() == null ? 10 : branchCompanyVehicleCountDTO.getLimit();
branchCompanyVehicleCountDTO.setPage(pageNo);
branchCompanyVehicleCountDTO.setLimit(pageSize);
Query query = new Query(branchCompanyVehicleCountDTO);
PageDataVO<BranchCompanyVehicleCount> pageDataVO = PageDataVO.pageInfo(query, () -> mapper.getAllByParam(query.getSuper()));
return ObjectRestResponse.succ(pageDataVO);
}
}
package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.vehicle.entity.Constant;
......@@ -15,7 +14,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List;
/**
......@@ -138,8 +136,8 @@ public class ImportVehicleDataBiz extends BaseBiz<VehicleMapper, Vehicle> {
}
}
System.out.println("stringBuffer:"+stringBuffer);
System.out.println("stringBuffer2:"+stringBuffer2);
log.info("stringBuffer:"+stringBuffer);
log.info("stringBuffer2:"+stringBuffer2);
} catch (Exception e) {
log.error(e.getMessage());
log.error(e.getMessage(), e);
......
......@@ -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);
}
......@@ -1514,4 +1514,8 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return vehicles.stream().map(Vehicle::getId).collect(Collectors.toList());
}
public List<BranchCompanyVehicleCountVo> getAllVehicleInfo() {
return mapper.getAllVehicleInfo();
}
}
......@@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSON;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.mapper.VehicleMapper;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo;
import com.xxfc.platform.vehicle.pojo.ResultVehicleVo;
import com.xxfc.platform.vehicle.pojo.VehicleExcelVo;
import com.xxfc.platform.vehicle.pojo.VehiclePageQueryVo;
......@@ -13,7 +15,11 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
......@@ -28,7 +34,10 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl
@Autowired
private VehicleBiz vehicleBiz;
@Autowired
private BranchCompanyVehicleCountBiz branchCompanyVehicleCountBiz;
public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd");
public List getByPageNotAllData(VehiclePageQueryVo vehiclePageQueryVo, List<Integer> companyList) throws Exception {
......@@ -92,4 +101,31 @@ public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicl
return arrayList;
}
public List<BranchCompanyVehicleCountVo> getAllVehicleInfo() {
return vehicleBiz.getAllVehicleInfo();
}
@Scheduled(cron = "0 0 */2 * * *")
public void add() {
ArrayList<BranchCompanyVehicleCount> arrayList = Lists.newArrayList();
List<BranchCompanyVehicleCountVo> branchCompanyVehicleCountVos = vehicleBiz.getAllVehicleInfo();
branchCompanyVehicleCountVos.parallelStream().forEach(result->{
try {
BranchCompanyVehicleCount branchCompanyVehicleCount = new BranchCompanyVehicleCount();
branchCompanyVehicleCount.setCompanyId(result.getCompanyId());
branchCompanyVehicleCount.setCompanyName(result.getParkBranchCompanyName());
branchCompanyVehicleCount.setVehicleNum(result.getCount());
DateTime dateTime = DateTime.now();
String dateStr = dateTime.toString(DATE_TIME_FORMATTER);
branchCompanyVehicleCount.setCountDate(DateTime.parse(dateStr).toDate());
arrayList.add(branchCompanyVehicleCount);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
});
branchCompanyVehicleCountBiz.add(arrayList);
}
}
package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
import java.util.Map;
public interface BranchCompanyVehicleCountMapper extends Mapper<BranchCompanyVehicleCount> {
List<BranchCompanyVehicleCount> getAllByParam(Map<String, Object> param);
}
\ No newline at end of file
......@@ -53,4 +53,6 @@ public interface VehicleMapper extends Mapper<Vehicle> {
@Select("select `id` from `vehicle` where `is_del`=0")
List<String> findExistVehicleIds();
List<BranchCompanyVehicleCountVo> getAllVehicleInfo();
}
\ No newline at end of file
package com.xxfc.platform.vehicle.rest.admin;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping(value = "/bg-vehicle/count")
public class BranchCompanyVehicleCountController extends BaseController<BranchCompanyVehicleCountBiz> {
@GetMapping(value = "/getAll")
@ResponseBody
public ObjectRestResponse getAll(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) {
return baseBiz.findAll(branchCompanyVehicleCountDTO);
}
}
......@@ -7,10 +7,15 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz;
import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.biz.VehicleInformationDownloadBiz;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount;
import com.xxfc.platform.vehicle.pojo.VehicleExcelVo;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyVehicleCountDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -29,7 +34,7 @@ import java.util.List;
public class VehicleInformationDownloadController extends BaseController<VehicleInformationDownloadBiz> {
@Autowired
UserFeign userFeign;
private UserFeign userFeign;
@Autowired
private UserAuthConfig userAuthConfig;
......@@ -38,13 +43,16 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle
private VehicleBiz vehicleBiz;
@Autowired
HttpServletResponse response;
private BranchCompanyVehicleCountBiz branchCompanyVehicleCountBiz;
@Autowired
private HttpServletResponse response;
@GetMapping("/excel")
public void downloadExcel(@RequestParam(value = "vehiclePageQueryVoJson",required = false) String vehiclePageQueryVoJson) throws Exception {
public void downloadExcel(@RequestParam(value = "vehiclePageQueryVoJson", required = false) String vehiclePageQueryVoJson) throws Exception {
UserDTO userDTO = userFeign.userinfoByToken(userAuthConfig.getToken(request)).getData();
if (userDTO==null) {
throw new BaseException("token已失效");
if (userDTO == null) {
throw new BaseException("token已失效");
}
List<VehicleExcelVo> rows = baseBiz.getList(vehiclePageQueryVoJson, userDTO);
ExcelWriter writer = ExcelUtil.getWriter(true);
......@@ -67,4 +75,32 @@ public class VehicleInformationDownloadController extends BaseController<Vehicle
//此处记得关闭输出Servlet流
IoUtil.close(out);
}
@GetMapping("/app/unauth/export")
public void exportVehicleInfo(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) throws Exception {
PageDataVO<BranchCompanyVehicleCount> pageDataVO = branchCompanyVehicleCountBiz.findAll(branchCompanyVehicleCountDTO).getData();
if (pageDataVO == null || pageDataVO.getData() == null) {
throw new BaseException(ResultCode.getMsg(ResultCode.NOTEXIST_CODE), ResultCode.NOTEXIST_CODE);
}
List<BranchCompanyVehicleCount> rows = pageDataVO.getData();
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.merge(2,"导出车辆数据");
writer.addHeaderAlias("countDate", "日期");
writer.addHeaderAlias("companyName", "停靠分公司");
writer.addHeaderAlias("vehicleNum", "车辆数量");
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(rows, true);
//response为HttpServletResponse对象
response.setContentType("application/vnd.ms-excel;charset=utf-8");
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
response.setHeader("Content-Disposition", "attachment;filename=vehicleInfo.xlsx");
//out为OutputStream,需要写出到的目标流
ServletOutputStream out = response.getOutputStream();
writer.flush(out, true);
// 关闭writer,释放内存
writer.close();
//此处记得关闭输出Servlet流
IoUtil.close(out);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.xxfc.platform.vehicle.mapper.BranchCompanyVehicleCountMapper" >
<resultMap id="BaseResultMap" type="com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="BIGINT" />
<result column="company_name" property="companyName" jdbcType="VARCHAR" />
<result column="vehicle_num" property="vehicleNum" jdbcType="INTEGER" />
<result column="count_date" property="countDate" jdbcType="TIMESTAMP" />
<result column="company_id" property="companyId" jdbcType="INTEGER" />
</resultMap>
<select id="getAllByParam" parameterType="Map" resultType="com.xxfc.platform.vehicle.entity.BranchCompanyVehicleCount">
select * from branch_company_vehicle_count
<where>
<if test="companyName != null and companyName != ''">
and company_name like concat('%', #{companyName}, '%')
</if>
<if test="startTime != null and startTime != ''">
and count_date &gt; #{startTime} and count_date &lt; #{endTime}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
......@@ -585,7 +585,21 @@
) r ORDER BY r.parkBranchCompanyName
</select>
<!--导出分公司停靠所有车辆-->
<select id="getAllVehicleInfo" resultType="com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo">
SELECT
b1. NAME AS parkBranchCompanyName,
count(v1.id) as count,
b1.id as companyId
FROM
branch_company b1
LEFT JOIN vehicle v1 ON v1.park_branch_company_id = b1.id
WHERE
b1.is_del = 0
AND v1.is_del = 0
GROUP BY b1.`name`
order by b1.`name`
</select>
<select id="lockByCode" resultType="com.xxfc.platform.vehicle.entity.Vehicle"
parameterType="com.xxfc.platform.vehicle.pojo.AddOrUpdateVehicleVo">
......
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