Commit 9229b4c6 authored by hanfeng's avatar hanfeng

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	xx-vehicle/xx-vehicle-api/src/main/java/com/xxfc/platform/vehicle/feign/VehicleFeign.java
parents 9abc88ff 25ea6021
package com.github.wxiaoqi.security.admin.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/10/25 14:42
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AccountBindDTO {
private String openId;
private String unionId;
private String nickName;
private String code;
private String type;
}
...@@ -2,10 +2,8 @@ package com.github.wxiaoqi.security.admin.entity; ...@@ -2,10 +2,8 @@ package com.github.wxiaoqi.security.admin.entity;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue; import javax.persistence.*;
import javax.persistence.Id;
import javax.persistence.Table;
/** /**
* 支付宝账号表 * 支付宝账号表
...@@ -37,7 +35,12 @@ public class AppUserAlipay { ...@@ -37,7 +35,12 @@ public class AppUserAlipay {
@Column(name = "is_del") @Column(name = "is_del")
private Integer isDel; private Integer isDel;
@ApiModelProperty("昵称")
private String nickname;
//类型 1、支付宝,2、微信
@Transient
private Integer type;
} }
\ No newline at end of file
package com.github.wxiaoqi.security.admin.entity; package com.github.wxiaoqi.security.admin.entity;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
...@@ -12,6 +14,8 @@ import javax.persistence.Table; ...@@ -12,6 +14,8 @@ import javax.persistence.Table;
* 用户详情信息表 * 用户详情信息表
*/ */
@Table(name = "app_user_detail") @Table(name = "app_user_detail")
@AllArgsConstructor
@NoArgsConstructor
@Data @Data
public class AppUserDetail { public class AppUserDetail {
@Id @Id
...@@ -20,6 +24,10 @@ public class AppUserDetail { ...@@ -20,6 +24,10 @@ public class AppUserDetail {
private Integer userid; private Integer userid;
@Column(name = "is_member") @Column(name = "is_member")
private Integer isMember; private Integer isMember;
@Column(name = "wx_nickname")
private String wxNickname;
@Column(name = "qq_nickname")
private String qqNickname;
private String nickname; private String nickname;
private String realname; private String realname;
private String headimgurl; private String headimgurl;
......
...@@ -19,7 +19,10 @@ public class AppUserDTO { ...@@ -19,7 +19,10 @@ public class AppUserDTO {
private Integer userid; private Integer userid;
private Integer isMember; private Integer isMember;
private String username; private String username;
private String wxNickname;
private String qqNickname;
private String nickname; private String nickname;
private String aliPayNickName;
private String realname; private String realname;
private String headimgurl; private String headimgurl;
private String email; private String email;
...@@ -87,6 +90,8 @@ public class AppUserDTO { ...@@ -87,6 +90,8 @@ public class AppUserDTO {
private String itemImg; private String itemImg;
private Integer memberNo; private Integer memberNo;
private Long cardLeave; private Long cardLeave;
private Integer isBind; private Boolean isBindWx;
private Boolean isBindAliPay;
private Boolean isBindQQ;
} }
...@@ -33,6 +33,9 @@ public class AppUserVo { ...@@ -33,6 +33,9 @@ public class AppUserVo {
private Integer isMember; private Integer isMember;
//昵称 //昵称
private String nickname; private String nickname;
private String wxNickname;
private String aliPayNickName;
private String qqNickname;
//真实姓名 //真实姓名
private String realname; private String realname;
//头像 //头像
...@@ -84,5 +87,6 @@ public class AppUserVo { ...@@ -84,5 +87,6 @@ public class AppUserVo {
@ApiModelProperty(value = "1-未激活;2-激活:") @ApiModelProperty(value = "1-未激活;2-激活:")
private Integer state; private Integer state;
@ApiModelProperty(value = "支付宝授权返回的code")
private String aliCode;
} }
package com.github.wxiaoqi.security.admin.biz; package com.github.wxiaoqi.security.admin.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.AppUserAlipay; import com.github.wxiaoqi.security.admin.entity.AppUserAlipay;
import com.github.wxiaoqi.security.admin.entity.AppUserRelationTemp;
import com.github.wxiaoqi.security.admin.mapper.AppUserAlipayMapper; import com.github.wxiaoqi.security.admin.mapper.AppUserAlipayMapper;
import com.github.wxiaoqi.security.admin.mapper.AppUserRelationTempMapper; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.universal.feign.ThirdFeign;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -18,7 +30,23 @@ import java.util.List; ...@@ -18,7 +30,23 @@ import java.util.List;
* @date 2019-07-03 16:36:44 * @date 2019-07-03 16:36:44
*/ */
@Service @Service
public class AppUserAlipayBiz extends BaseBiz<AppUserAlipayMapper, AppUserAlipay> { @Slf4j
public class AppUserAlipayBiz extends BaseBiz<AppUserAlipayMapper, AppUserAlipay>{
@Autowired
private UserAuthUtil userAuthUtil;
@Autowired
private UserAuthConfig userAuthConfig;
@Autowired
AppUserLoginBiz appUserLoginBiz;
@Autowired
AppUserDetailBiz appUserDetailBiz;
@Autowired
ThirdFeign thirdFeign;
//添加支付宝账号 //添加支付宝账号
public void addAlipay(Integer userId,String txAlipay){ public void addAlipay(Integer userId,String txAlipay){
...@@ -44,4 +72,100 @@ public class AppUserAlipayBiz extends BaseBiz<AppUserAlipayMapper, AppUserAlipay ...@@ -44,4 +72,100 @@ public class AppUserAlipayBiz extends BaseBiz<AppUserAlipayMapper, AppUserAlipay
} }
//获取支付宝用户信息
public List<AppUserAlipay> getByUserId(HttpServletRequest request){
Example example=new Example(AppUserAlipay.class);
Integer userId = null;
try {
String username = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId();
if (StringUtils.isNotBlank(username)) {
userId = Integer.parseInt(username);
example.createCriteria().andEqualTo("userId", userId).andEqualTo("isDel",0);
}
} catch (Exception e) {
e.printStackTrace();
}
example.setOrderByClause("is_default desc");
AppUserAlipay appUserAlipay = mapper.selectOneByExample(example);
List<AppUserAlipay> appUserAlipays = new ArrayList<>();
//支付宝
if(appUserAlipay != null) {
appUserAlipay.setType(1);
appUserAlipays.add(appUserAlipay);
}
//微信
// AppUserLogin appUserLogin = appUserLoginBiz.getUserById(userId);
// if(appUserLogin != null && StringUtils.isNotBlank(appUserLogin.getWxOpenid())) {
// AppUserDetail appUserDetail = appUserDetailBiz.getUserByUserid(userId);
// AppUserAlipay wxAppUser = new AppUserAlipay();
// wxAppUser.setType(2);
// wxAppUser.setUserId(userId);
// wxAppUser.setNickname(StringUtils.isEmpty(appUserDetail.getWxNickname())?appUserDetail.getNickname():appUserDetail.getWxNickname());
// wxAppUser.setTxAlipay(appUserLogin.getWxOpenid());
// appUserAlipays.add(wxAppUser);
// }
return appUserAlipays;
}
public void save(AppUserAlipay appUserAlipay) {
Example example=new Example(AppUserAlipay.class);
example.createCriteria().andEqualTo("userId", appUserAlipay.getUserId()).andEqualTo("isDel",0);
example.setOrderByClause("is_default desc");
AppUserAlipay oldValue = mapper.selectOneByExample(example);
if (oldValue != null) {
BeanUtil.copyProperties(appUserAlipay, oldValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
updateByIdRe(oldValue);
} else {
insertSelectiveRe(appUserAlipay);
}
}
/**
* 支付宝授权获取用户信息
* @param code
* @return
*/
public ObjectRestResponse getUserInfo(String code, HttpServletRequest request) {
String username = null;
AppUserAlipay appUserAlipay = new AppUserAlipay();
try {
username = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId();
if (StringUtils.isBlank(username)) {
return ObjectRestResponse.createFailedResult(ResultCode.RSTOKEN_EXPIRED_CODE, ResultCode.getMsg(ResultCode.RSTOKEN_EXPIRED_CODE));
} else {
appUserAlipay.setUserId(Integer.parseInt(username));
}
} catch (Exception e) {
e.printStackTrace();
}
if (StringUtils.isBlank(code)) {
return ObjectRestResponse.paramIsEmpty();
}
String result = thirdFeign.getAliPayUserInfo(code).getData();
if (StringUtils.isNotBlank(result)) {
log.info("【支付宝】用户授权获取用户token, {}", result);
JSONObject jsonObject = JSONObject.parseObject(result);
if (jsonObject.getJSONObject("error_response") == null && jsonObject.getJSONObject("alipay_user_info_share_response") != null) {
JSONObject responseObject = jsonObject.getJSONObject("alipay_user_info_share_response");
String account = responseObject.getString("user_id");
if (account != null) {
appUserAlipay.setTxAlipay(account);
appUserAlipay.setCrtTime(new Date().getTime());
appUserAlipay.setIsDel(0);
}
String nickname = responseObject.getString("nick_name");
if (nickname != null) {
appUserAlipay.setNickname(nickname);
}
log.info("用户支付宝信息: {}", appUserAlipay.toString());
save(appUserAlipay);
return ObjectRestResponse.succ(appUserAlipay.getNickname());
} else {
return ObjectRestResponse.createFailedResult(Integer.parseInt(jsonObject.getJSONObject("error_response").getString("code")), jsonObject.getJSONObject("error_response").getString("sub_msg"));
}
}
return ObjectRestResponse.createDefaultFail();
}
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.admin.biz; ...@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.admin.biz;
import com.ace.cache.annotation.Cache; import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear; import com.ace.cache.annotation.CacheClear;
import com.github.wxiaoqi.security.admin.dto.AccountBindDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail; import com.github.wxiaoqi.security.admin.entity.AppUserDetail;
import com.github.wxiaoqi.security.admin.mapper.AppUserDetailMapper; import com.github.wxiaoqi.security.admin.mapper.AppUserDetailMapper;
import com.github.wxiaoqi.security.admin.rpc.service.AppPermissionService; import com.github.wxiaoqi.security.admin.rpc.service.AppPermissionService;
...@@ -89,12 +90,15 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail ...@@ -89,12 +90,15 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail
@CacheClear(pre = "user{1.userid}") @CacheClear(pre = "user{1.userid}")
public void updUuserInfoById(AppUserVo userVo) { public void updUuserInfoById(AppUserVo userVo) {
AppUserDetail entity = new AppUserDetail(); AppUserDetail entity = new AppUserDetail();
Example example = new Example(AppUserDetail.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("userid",userVo.getUserid());
try { try {
BeanUtils.copyProperties(entity, userVo); BeanUtils.copyProperties(entity, userVo);
if (entity != null) { if (entity != null) {
entity.setUpdHost(AppPermissionService.getIp()); entity.setUpdHost(AppPermissionService.getIp());
entity.setUpdatetime(Instant.now().toEpochMilli() / 1000L); entity.setUpdatetime(Instant.now().toEpochMilli() / 1000L);
super.updateSelectiveById(entity); mapper.updateByExampleSelective(entity,example);
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -149,4 +153,18 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail ...@@ -149,4 +153,18 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail
return mapper.getUserIdByUsername(keywords); return mapper.getUserIdByUsername(keywords);
} }
public void updateByUserId(AccountBindDTO accountBindDTO,Integer userId) {
AppUserDetail appUserDetail = new AppUserDetail();
if (accountBindDTO.getType().equals("wx")){
appUserDetail.setWxNickname(accountBindDTO.getNickName());
}
if(accountBindDTO.getType().equals("q")){
appUserDetail.setQqNickname(accountBindDTO.getNickName());
}
Example example = new Example(AppUserDetail.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("userid",userId);
mapper.updateByExampleSelective(appUserDetail,example);
}
} }
...@@ -2,21 +2,19 @@ package com.github.wxiaoqi.security.admin.biz; ...@@ -2,21 +2,19 @@ package com.github.wxiaoqi.security.admin.biz;
import com.ace.cache.annotation.Cache; import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear; import com.ace.cache.annotation.CacheClear;
import com.alibaba.druid.sql.visitor.functions.If;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail; import com.github.wxiaoqi.security.admin.dto.AccountBindDTO;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin; import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.mapper.AppUserLoginMapper; import com.github.wxiaoqi.security.admin.mapper.AppUserLoginMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant; import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import com.github.wxiaoqi.security.common.constant.UserConstant; import com.github.wxiaoqi.security.common.constant.UserConstant;
import com.google.common.collect.Lists; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.xxfc.platform.im.utils.StringUtil; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.entity.IdInformation; import com.xxfc.platform.universal.entity.IdInformation;
import com.xxfc.platform.universal.feign.MQSenderFeign; import com.xxfc.platform.universal.feign.MQSenderFeign;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -24,6 +22,7 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -24,6 +22,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import javax.servlet.http.HttpServletRequest;
import java.time.Instant; import java.time.Instant;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -45,6 +44,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -45,6 +44,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
private static final String WX_TYPE = "wx"; private static final String WX_TYPE = "wx";
private static final String QQ_TYPE = "q"; private static final String QQ_TYPE = "q";
private static final String ALIPAY_TYPE = "aliPay";
@Autowired @Autowired
ThirdFeign thirdFeign; ThirdFeign thirdFeign;
...@@ -54,6 +54,9 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -54,6 +54,9 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
@Autowired @Autowired
AppUserDetailBiz appUserDetailBiz; AppUserDetailBiz appUserDetailBiz;
@Autowired
private AppUserAlipayBiz appUserAlipayBiz;
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
@Override @Override
public void insertSelective(AppUserLogin entity) { public void insertSelective(AppUserLogin entity) {
...@@ -321,9 +324,77 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -321,9 +324,77 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
} }
public List<AppUserLogin> getUserByUsernameAndRealName(String username, String realName) { public List<AppUserLogin> getUserByUsernameAndRealName(String username, String realName) {
return mapper.getUserByUsernameAndRealName(username,realName);
return mapper.getUserByUsernameAndRealName(username, realName);
}
@CacheClear(pre = "user{2}")
public ObjectRestResponse bindAccount(AccountBindDTO accountBindDTO, Integer userId, HttpServletRequest request) {
switch (accountBindDTO.getType()) {
case WX_TYPE:
wxBinding(accountBindDTO, userId);
break;
case QQ_TYPE:
qqBinding(accountBindDTO, userId);
break;
case ALIPAY_TYPE:
return appUserAlipayBiz.getUserInfo(accountBindDTO.getCode(), request);
default:
break;
}
return ObjectRestResponse.succ(accountBindDTO.getNickName());
}
/**
* 微信绑定
*
* @param accountBindDTO
*/
private void wxBinding(AccountBindDTO accountBindDTO, Integer userId) {
//检查微信是否绑定
/* Example example = new Example(AppUserLogin.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id", userId);
criteria.andEqualTo("wxOpenid", accountBindDTO.getOpendId());
List<AppUserLogin> appUserLogins = mapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(appUserLogins)) {
throw new BaseException("该微信已经绑定过了");
}*/
AppUserLogin appUserLogin = new AppUserLogin();
appUserLogin.setId(userId);
appUserLogin.setWxOpenid(accountBindDTO.getOpenId());
appUserLogin.setUnionid(accountBindDTO.getUnionId());
mapper.updateByPrimaryKeySelective(appUserLogin);
appUserDetailBiz.updateByUserId(accountBindDTO, userId);
}
/**
* QQ绑定
*
* @param accountBindDTO
*/
private void qqBinding(AccountBindDTO accountBindDTO, Integer userId) {
//检查qq是否绑定
/* Example example = new Example(AppUserLogin.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id", userId);
criteria.andEqualTo("openid", accountBindDTO.getOpendId());
List<AppUserLogin> appUserLogins = mapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(appUserLogins)) {
throw new BaseException("该qq已经绑定过了");
}*/
AppUserLogin appUserLogin = new AppUserLogin();
appUserLogin.setId(userId);
appUserLogin.setOpenid(accountBindDTO.getOpenId());
mapper.updateByPrimaryKeySelective(appUserLogin);
appUserDetailBiz.updateByUserId(accountBindDTO, userId);
}
public void updateAppuserLogin(AppUserLogin appUserLogin) {
appUserLogin.setUpdatetime(Instant.now().getEpochSecond());
mapper.updateByPrimaryKeySelective(appUserLogin);
} }
} }
package com.github.wxiaoqi.security.admin.rest; package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.*; import com.github.wxiaoqi.security.admin.biz.*;
import com.github.wxiaoqi.security.admin.dto.AccountBindDTO;
import com.github.wxiaoqi.security.admin.entity.*; import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.vo.AppUserGroups; import com.github.wxiaoqi.security.admin.vo.AppUserGroups;
...@@ -22,6 +23,8 @@ import com.xxfc.platform.order.feign.OrderFeign; ...@@ -22,6 +23,8 @@ import com.xxfc.platform.order.feign.OrderFeign;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -69,6 +72,9 @@ public class AppUserController extends CommonBaseController{ ...@@ -69,6 +72,9 @@ public class AppUserController extends CommonBaseController{
@Autowired @Autowired
private OrderFeign orderFeign; private OrderFeign orderFeign;
@Autowired
private AppUserAlipayBiz appUserAlipayBiz;
@GetMapping("page") @GetMapping("page")
...@@ -140,7 +146,7 @@ public class AppUserController extends CommonBaseController{ ...@@ -140,7 +146,7 @@ public class AppUserController extends CommonBaseController{
throw new Exception(); throw new Exception();
} }
Integer id= userVo.getId(); Integer id= userVo.getId();
Integer positionId=userVo.getPositionId(); Integer positionId=userVo.getPositionId();
BeanUtils.copyProperties(userDTO,userVo); BeanUtils.copyProperties(userDTO,userVo);
if(userVo.getIsMember()!=null&&userVo.getIsMember()>0){ if(userVo.getIsMember()!=null&&userVo.getIsMember()>0){
//获取用户会员信息 //获取用户会员信息
...@@ -154,7 +160,6 @@ public class AppUserController extends CommonBaseController{ ...@@ -154,7 +160,6 @@ public class AppUserController extends CommonBaseController{
String icon=memberLevel.getIcon(); String icon=memberLevel.getIcon();
userDTO.setIcon(icon); userDTO.setIcon(icon);
userDTO.setBigIcon(memberLevel.getBigIcon()); userDTO.setBigIcon(memberLevel.getBigIcon());
userDTO.setItemImg(memberLevel.getItemImg());
} }
} }
} }
...@@ -162,7 +167,14 @@ public class AppUserController extends CommonBaseController{ ...@@ -162,7 +167,14 @@ public class AppUserController extends CommonBaseController{
if (userPosition!=null&&userPosition.getLevel()>0){ if (userPosition!=null&&userPosition.getLevel()>0){
userDTO.setPositionName(userPosition.getName()); userDTO.setPositionName(userPosition.getName());
} }
List<AppUserAlipay> appUserAlipays = appUserAlipayBiz.getByUserId(request);
long count = appUserAlipays.stream().filter(appUserAlipay -> appUserAlipay.getType() == 1).count();
userDTO.setIsBindAliPay(count>0);
userDTO.setId(id); userDTO.setId(id);
userDTO.setAliPayNickName(userDTO.getIsBindAliPay()?appUserAlipays.get(0).getNickname():"");
AppUserLogin appUserLogin = appUserLoginBiz.selectById(userid);
userDTO.setIsBindWx(StringUtils.isNotEmpty(appUserLogin.getWxOpenid()));
userDTO.setIsBindQQ(StringUtils.isNotEmpty(appUserLogin.getOpenid()));
return ObjectRestResponse.succ(userDTO); return ObjectRestResponse.succ(userDTO);
} }
...@@ -200,10 +212,9 @@ public class AppUserController extends CommonBaseController{ ...@@ -200,10 +212,9 @@ public class AppUserController extends CommonBaseController{
* @throws Exception * @throws Exception
*/ */
@PostMapping("/edit") @PostMapping("/edit")
public ObjectRestResponse edit(@RequestBody AppUserVo userVo)throws Exception { public ObjectRestResponse edit(@RequestBody AppUserVo userVo,HttpServletRequest request)throws Exception {
if(userVo==null||userVo.getId()==null){ String id = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId();
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数为空"); userVo.setUserid(Integer.valueOf(id));
}
userDetailBiz.updUuserInfoById(userVo); userDetailBiz.updUuserInfoById(userVo);
Integer userid=userVo.getUserid(); Integer userid=userVo.getUserid();
if (userid!=null){ if (userid!=null){
...@@ -213,8 +224,13 @@ public class AppUserController extends CommonBaseController{ ...@@ -213,8 +224,13 @@ public class AppUserController extends CommonBaseController{
appUserLogin.setOpenid(userVo.getOpenid()); appUserLogin.setOpenid(userVo.getOpenid());
appUserLogin.setId(userid); appUserLogin.setId(userid);
appUserLogin.setUsername(userVo.getUsername()); appUserLogin.setUsername(userVo.getUsername());
appUserLoginBiz.bindOpenid(appUserLogin); appUserLoginBiz.updateAppuserLogin(appUserLogin);
//支付宝绑定
if (StringUtils.isNotEmpty(userVo.getAliCode()) && userVo.getAliCode().trim().length()>0){
appUserAlipayBiz.getUserInfo(userVo.getAliCode(),request);
}
} }
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
...@@ -291,7 +307,7 @@ public class AppUserController extends CommonBaseController{ ...@@ -291,7 +307,7 @@ public class AppUserController extends CommonBaseController{
} }
@GetMapping("/findusersByIds") @GetMapping("/findusersByIds")
public Map<Integer,AppUserLogin> findAppUsersByUserIds(@RequestParam(value = "userIds") List<Integer> userIds){ public Map<Integer,AppUserLogin> findAppUsersByUserIds(@RequestParam(value = "userIds") List<Integer> userIds){
return appUserLoginBiz.findUserIdAndUserLoginMapByMemberIds(userIds); return appUserLoginBiz.findUserIdAndUserLoginMapByMemberIds(userIds);
} }
@GetMapping("/finduserIdsByphones") @GetMapping("/finduserIdsByphones")
...@@ -303,8 +319,8 @@ public class AppUserController extends CommonBaseController{ ...@@ -303,8 +319,8 @@ public class AppUserController extends CommonBaseController{
@IgnoreUserToken @IgnoreUserToken
@IgnoreClientToken @IgnoreClientToken
public ObjectRestResponse<AppUserInfoVo> findUserInfoByCode(@PathVariable("code") String code){ public ObjectRestResponse<AppUserInfoVo> findUserInfoByCode(@PathVariable("code") String code){
AppUserInfoVo appUserInfoVo = userDetailBiz.findUserInfoByCode(code); AppUserInfoVo appUserInfoVo = userDetailBiz.findUserInfoByCode(code);
return ObjectRestResponse.succ(appUserInfoVo); return ObjectRestResponse.succ(appUserInfoVo);
} }
@GetMapping("/app/unauth/getUserIdByUsername") @GetMapping("/app/unauth/getUserIdByUsername")
...@@ -321,4 +337,14 @@ public class AppUserController extends CommonBaseController{ ...@@ -321,4 +337,14 @@ public class AppUserController extends CommonBaseController{
public Object test() { public Object test() {
return appUserLoginBiz.test(); return appUserLoginBiz.test();
} }
@PostMapping("/bind")
private ObjectRestResponse accountBinding(@RequestBody AccountBindDTO accountBindDTO,HttpServletRequest request){
try {
IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request));
return appUserLoginBiz.bindAccount(accountBindDTO, Integer.valueOf(infoFromToken.getId()), request);
}catch (Exception ex){
throw new BaseException(ex);
}
}
} }
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
<result column="certification_status" property="certificationStatus"/> <result column="certification_status" property="certificationStatus"/>
<result column="is_member" property="isMember"/> <result column="is_member" property="isMember"/>
<result column="nickname" property="nickname"/> <result column="nickname" property="nickname"/>
<result column="wx_nickname" property="wxNickname"/>
<result column="qq_nickname" property="qqNickname"/>
<result column="realname" property="realname"/> <result column="realname" property="realname"/>
<result column="headimgurl" property="headimgurl"/> <result column="headimgurl" property="headimgurl"/>
<result column="birthday" property="birthday"/> <result column="birthday" property="birthday"/>
......
...@@ -8,6 +8,7 @@ public enum DeductionTypeEnum { ...@@ -8,6 +8,7 @@ public enum DeductionTypeEnum {
VIOLATE_CANCEL(101, "提前取消违约金"), VIOLATE_CANCEL(101, "提前取消违约金"),
VIOLATE_ADVANCE(102, "提前还车违约金"), VIOLATE_ADVANCE(102, "提前还车违约金"),
VIOLATE_DELAY(103, "延迟还车违约金"), VIOLATE_DELAY(103, "延迟还车违约金"),
VIOLATE_CHANGE_C(104, "更换还车公司费用"),
CONSUME(201, "消费金额"), CONSUME(201, "消费金额"),
DAMAGES(301, "赔偿金(定损)"), DAMAGES(301, "赔偿金(定损)"),
VIOLATE_TRAFFIC_DEDUCT(401, "违章扣款"), VIOLATE_TRAFFIC_DEDUCT(401, "违章扣款"),
......
...@@ -7,6 +7,7 @@ import java.util.Map; ...@@ -7,6 +7,7 @@ import java.util.Map;
public enum OrderViolateEnum { public enum OrderViolateEnum {
BEFORE(1, "提前"), BEFORE(1, "提前"),
AFTER(2, "延期"), AFTER(2, "延期"),
CHANGE(3, "更换还车公司"),
; ;
/** /**
* 编码 * 编码
......
...@@ -32,7 +32,7 @@ public class DedDetailDTO { ...@@ -32,7 +32,7 @@ public class DedDetailDTO {
//作为:DedDetail :2、车辆损坏 3、其他 //作为:DedDetail :2、车辆损坏 3、其他
//作为:violate_amount_detail 1--提前还车 2--延期还车 3--消费超额 //作为:violate_amount_detail 1--提前还车 2--延期还车 3--更换还车公司费用
Integer type; Integer type;
//小雨都不知道什么东西 //小雨都不知道什么东西
......
...@@ -2,6 +2,7 @@ package com.xxfc.platform.order.pojo.order; ...@@ -2,6 +2,7 @@ package com.xxfc.platform.order.pojo.order;
import com.xxfc.platform.order.entity.*; import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.pojo.DedDetailDTO; import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog;
import com.xxfc.platform.vehicle.entity.VehicleUserLicense; import com.xxfc.platform.vehicle.entity.VehicleUserLicense;
import lombok.Data; import lombok.Data;
...@@ -21,6 +22,9 @@ public class OrderPageVO extends BaseOrder { ...@@ -21,6 +22,9 @@ public class OrderPageVO extends BaseOrder {
List<VehicleUserLicense> vehicleUserLicenses; List<VehicleUserLicense> vehicleUserLicenses;
//更换还车公司记录
List<BookRecordUpdateLog> bookRecordUpdateLogs;
/** /**
* 用户名 * 用户名
*/ */
......
...@@ -12,9 +12,12 @@ import java.time.format.DateTimeFormatter; ...@@ -12,9 +12,12 @@ import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.DATE_TIME_LINE_FORMATTER;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.YMR_SLASH_FORMATTER;
@Data @Data
public class AddRentVehicleDTO extends AddOrderCommonDTO{ public class AddRentVehicleDTO extends AddOrderCommonDTO{
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//开始时间 //开始时间
@ApiModelProperty(value = "开始时间") @ApiModelProperty(value = "开始时间")
...@@ -36,6 +39,18 @@ public class AddRentVehicleDTO extends AddOrderCommonDTO{ ...@@ -36,6 +39,18 @@ public class AddRentVehicleDTO extends AddOrderCommonDTO{
@ApiModelProperty(value = "预定目标日期(结束)", hidden = true) @ApiModelProperty(value = "预定目标日期(结束)", hidden = true)
private String bookEndDate; private String bookEndDate;
/**
* 预定目标日期(开始)
*/
@ApiModelProperty(value = "预定目标时间(开始)", hidden = true)
private String bookStartDateTime;
/**
* 预定目标日期(结束)
*/
@ApiModelProperty(value = "预定目标时间(结束)", hidden = true)
private String bookEndDateTime;
//天数 //天数
@ApiModelProperty(value = "天数") @ApiModelProperty(value = "天数")
private Integer dayNum; private Integer dayNum;
...@@ -111,12 +126,14 @@ public class AddRentVehicleDTO extends AddOrderCommonDTO{ ...@@ -111,12 +126,14 @@ public class AddRentVehicleDTO extends AddOrderCommonDTO{
public void setStartTime(Long startTime) { public void setStartTime(Long startTime) {
this.startTime = startTime; this.startTime = startTime;
this.bookStartDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneOffset.ofHours(8))); this.bookStartDate = YMR_SLASH_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneOffset.ofHours(8)));
this.bookStartDateTime = DATE_TIME_LINE_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneOffset.ofHours(8)));
} }
public void setEndTime(Long endTime) { public void setEndTime(Long endTime) {
this.endTime = endTime; this.endTime = endTime;
this.bookEndDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endTime), ZoneOffset.ofHours(8))); this.bookEndDate = YMR_SLASH_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endTime), ZoneOffset.ofHours(8)));
this.bookEndDateTime = DATE_TIME_LINE_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endTime), ZoneOffset.ofHours(8)));
} }
public void setAccompanyStrs(List<String> accompanyStrs) { public void setAccompanyStrs(List<String> accompanyStrs) {
......
...@@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil; ...@@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONArray;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO; import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
...@@ -16,17 +16,15 @@ import com.github.wxiaoqi.security.common.exception.BaseException; ...@@ -16,17 +16,15 @@ import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query; import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gson.JsonObject;
import com.xxfc.platform.activity.feign.ActivityFeign; import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz; import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.biz.inner.OrderMsgBiz; import com.xxfc.platform.order.biz.inner.OrderMsgBiz;
import com.xxfc.platform.order.contant.enumerate.*; import com.xxfc.platform.order.contant.enumerate.*;
import com.xxfc.platform.order.entity.*; import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.mapper.BaseOrderMapper; import com.xxfc.platform.order.mapper.BaseOrderMapper;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.DedDetailDTO; import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO; import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO; import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.order.OrderListVo; import com.xxfc.platform.order.pojo.order.OrderListVo;
...@@ -48,6 +46,7 @@ import com.xxfc.platform.vehicle.entity.Vehicle; ...@@ -48,6 +46,7 @@ import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleUserLicense; import com.xxfc.platform.vehicle.entity.VehicleUserLicense;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.CompanyDetail; import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.util.DistanceUtil;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -57,15 +56,16 @@ import org.joda.time.format.DateTimeFormatter; ...@@ -57,15 +56,16 @@ import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant.*; import static com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant.*;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.*; import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER; import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
import static com.xxfc.platform.universal.constant.DictionaryKey.ILLEGAL_TYPE;
/** /**
* @author zjw * @author zjw
...@@ -121,7 +121,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -121,7 +121,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
@Autowired @Autowired
OrderCalculateBiz orderCalculateBiz; OrderCalculateBiz orderCalculateBiz;
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd"); public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
public List<OrderPageVO> pageByParm(Map<String, Object> paramMap) { public List<OrderPageVO> pageByParm(Map<String, Object> paramMap) {
...@@ -226,34 +226,35 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -226,34 +226,35 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
//获取两个日期之间的天数(包含头尾) //获取两个日期之间的天数(包含头尾)
public int getDaysBetweenDateTimeHasStartEnd(DateTime startDay, DateTime endDay) { public int getDaysBetweenDateTimeHasStartEnd(DateTime startDay, DateTime endDay) {
int a = 0; int a = 0;
for (DateTime curDate = startDay; curDate.compareTo(endDay) <= 0; curDate = curDate.plusDays(1)) { for (DateTime curDate = startDay; curDate.compareTo(endDay) <= 0; curDate = curDate.plusHours(1)) {
a++; a++;
} }
return a; return a;
} }
public static void main(String[] args) { // public static void main(String[] args) {
DateTime dateTime = DateTime.parse("2019-09-20", DEFAULT_DATE_TIME_FORMATTER); // DateTime dateTime = DateTime.parse("2019-09-20 12:00:00", DEFAULT_DATE_TIME_FORMATTER);
DateTime dateTime1 = DateTime.parse("2019-09-22", DEFAULT_DATE_TIME_FORMATTER); // DateTime dateTime1 = DateTime.parse("2019-09-22 12:00:00", DEFAULT_DATE_TIME_FORMATTER);
BaseOrderBiz baseOrderBiz = new BaseOrderBiz(); // BaseOrderBiz baseOrderBiz = new BaseOrderBiz();
int a = baseOrderBiz.getDaysBetweenDateTimeHasStartEnd(dateTime,dateTime1) -1 ; // OrderCalculateBiz orderCalculateBiz = new OrderCalculateBiz();
System.out.println(a); // int a = orderCalculateBiz.getIncludeDays(1572246524350l,1572332924000l);
} // System.out.println(a);
// }
public void updateCrossRefund(OrderPageVO orderPageVO) { public void updateCrossRefund(OrderPageVO orderPageVO) {
//计算延期费用 //计算延期费用
DedDetailDTO dedDetailDTO = new DedDetailDTO(); DedDetailDTO dedDetailDTO = new DedDetailDTO();
//提前还车,结束时间大于当前时间 //提前还车,结束时间大于当前时间
DateTime nowTime = DateTime.parse(DateTime.now().toString(DEFAULT_DATE_TIME_FORMATTER), DEFAULT_DATE_TIME_FORMATTER); Long nowTime = System.currentTimeMillis();
DateTime endTime = DateTime.parse(new DateTime(orderPageVO.getOrderRentVehicleDetail().getEndTime()).toString(DEFAULT_DATE_TIME_FORMATTER), DEFAULT_DATE_TIME_FORMATTER); Long endTime = orderPageVO.getOrderRentVehicleDetail().getEndTime();
DateTime startTime = DateTime.parse(new DateTime(orderPageVO.getOrderRentVehicleDetail().getStartTime()).toString(DEFAULT_DATE_TIME_FORMATTER), DEFAULT_DATE_TIME_FORMATTER); Long startTime = orderPageVO.getOrderRentVehicleDetail().getStartTime();
//设置使用天数 //设置使用天数
int userUsedDay = getDaysBetweenDateTimeHasStartEnd(startTime, nowTime); int userUsedDay = orderCalculateBiz.getIncludeDays(startTime, nowTime);
orderPageVO.getOrderRentVehicleDetail().setUsedDay(userUsedDay); orderPageVO.getOrderRentVehicleDetail().setUsedDay(userUsedDay);
orderRentVehicleBiz.updateSelectiveById(orderPageVO.getOrderRentVehicleDetail()); orderRentVehicleBiz.updateSelectiveById(orderPageVO.getOrderRentVehicleDetail());
//实际预定的天数 //实际预定的天数
int actualDay = getDaysBetweenDateTimeHasStartEnd(startTime, endTime); int actualDay = orderCalculateBiz.getIncludeDays(startTime, endTime);
Integer orderId = orderPageVO.getId(); Integer orderId = orderPageVO.getId();
List<OrderItem> items = orderItemBiz.selectList(new OrderItem() {{ List<OrderItem> items = orderItemBiz.selectList(new OrderItem() {{
setOrderId(orderId); setOrderId(orderId);
...@@ -272,15 +273,15 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -272,15 +273,15 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
/** /**
* 提前还车 * 提前还车
*/ */
if (getDaysBetweenDateTimeHasStartEnd(endTime, nowTime) < 1) { if (userUsedDay - actualDay < 0) {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
//提前的天数, 当天就算使用一天 //提前的天数, 当天就算使用一天
int noUsedDay = getDaysBetweenDateTimeHasStartEnd(nowTime, endTime) - 1; int noUsedDay = actualDay - userUsedDay;
//退还未使用的天数,或者金额,扣除违约金,实际未使用天数的金额,最多3000元 //退还未使用的天数,或者金额,扣除违约金,实际未使用天数的金额,最多3000元
// InProgressVO inProgressVO = new InProgressVO(); // InProgressVO inProgressVO = new InProgressVO();
// inProgressVO.setViolateAmount(new BigDecimal(200)); // inProgressVO.setViolateAmount(new BigDecimal(200));
// inProgressVO.setExtraAmount(new BigDecimal(200)); // inProgressVO.setExtraAmount(new BigDecimal(200));
InProgressVO inProgressVO = orderCalculateBiz.inProgressCalculate(orderPageVO, actualDay - noUsedDay); InProgressVO inProgressVO = orderCalculateBiz.inProgressCalculate(orderPageVO, userUsedDay);
if (inProgressVO != null) { if (inProgressVO != null) {
//消费超额金 //消费超额金
if(inProgressVO.getExtraAmount() != null) { if(inProgressVO.getExtraAmount() != null) {
...@@ -297,11 +298,11 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -297,11 +298,11 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
/** /**
* 延期还车 * 延期还车
*/ */
} else if (getDaysBetweenDateTimeHasStartEnd(endTime, nowTime) > 1) { } else if (userUsedDay - actualDay > 0) {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("违约金( ¥"); stringBuilder.append("违约金( ¥");
//延期的天数, 延期违约金是延期天数*200% //延期的天数, 延期违约金是延期天数*200%
int extraUsedDay = getDaysBetweenDateTimeHasStartEnd(endTime, nowTime) - 1; int extraUsedDay = userUsedDay - actualDay;
if(extraUsedDay > 0) { if(extraUsedDay > 0) {
stringBuilder.append(amount); stringBuilder.append(amount);
stringBuilder.append(" x "); stringBuilder.append(" x ");
...@@ -315,8 +316,57 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -315,8 +316,57 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
initDedDetail(dedDetailDTO, OrderViolateEnum.AFTER.getCode(), cost, stringBuilder); initDedDetail(dedDetailDTO, OrderViolateEnum.AFTER.getCode(), cost, stringBuilder);
} }
} }
orderPageVO.setDedDetailDTO(JSONObject.toJSONString(dedDetailDTO)); JSONArray jsonArray = new JSONArray();
if ((dedDetailDTO.getCost() != null && dedDetailDTO.getCost().doubleValue() != 0) || (dedDetailDTO.getExcessCost()!=null && dedDetailDTO.getExcessCost().doubleValue() != 0)) {
jsonArray.add(dedDetailDTO);
}
DedDetailDTO dedDetailDTO1 = new DedDetailDTO();
//添加更改还车公司计算费用
if (orderPageVO.getOrderRentVehicleDetail() != null && orderPageVO.getOrderRentVehicleDetail().getBookRecordId() != null) {
//查询是否有更换还车记录
List<BookRecordUpdateLog> bookRecordUpdateLogs = vehicleFeign.get(orderPageVO.getOrderRentVehicleDetail().getBookRecordId()).getData();
if(bookRecordUpdateLogs != null && bookRecordUpdateLogs.size() > 0) {
orderPageVO.setBookRecordUpdateLogs(bookRecordUpdateLogs);
//有更换记录,则需要计算更换费用
//原始公司经纬度,列表中最后一个 bookRecordUpdateLogs.get(bookRecordUpdateLogs.size -1 ) 最后还车公司是列表中的第一条中的getNewRetCompanyId
BookRecordUpdateLog oldCompany = bookRecordUpdateLogs.get(bookRecordUpdateLogs.size() -1);
BookRecordUpdateLog newCompany = bookRecordUpdateLogs.get(0);
if (oldCompany != null && newCompany != null) {
CompanyDetail oldCompanyDetail = vehicleFeign.getCompanyDetail(oldCompany.getOldRetCompanyId()).getData();
CompanyDetail newCompanyDetail = vehicleFeign.getCompanyDetail(newCompany.getNewRetCompanyId()).getData();
if (oldCompanyDetail.getLatitude() != null && oldCompanyDetail.getLongitude() != null && newCompanyDetail.getLongitude() != null && newCompanyDetail.getLatitude() != null) {
//根据经纬度获取两个公司的距离
double distance = DistanceUtil.getDistance(oldCompanyDetail.getLongitude().doubleValue(), oldCompanyDetail.getLatitude().doubleValue(), newCompanyDetail.getLongitude().doubleValue(), newCompanyDetail.getLatitude().doubleValue());
log.info("两个公司的距离为(米): {}", distance);
BigDecimal distanceNum = new BigDecimal(distance + "").divide(new BigDecimal("1000"), 0, BigDecimal.ROUND_UP);
//取出费用计算的单价
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
BigDecimal illegalReserve = new BigDecimal(dictionaryMap.get(ILLEGAL_TYPE + "_" + DictionaryKey.ILLEGAL_FEE_PRICE).getDetail());
BigDecimal totalCost = distanceNum.multiply(illegalReserve);
log.info("更换两个公司的总费用为: {}", totalCost);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(illegalReserve);
stringBuilder.append(" x ");
stringBuilder.append(distanceNum);
stringBuilder.append("(KM)");
stringBuilder.append(" = ");
stringBuilder.append(totalCost);
stringBuilder.append("元");
dedDetailDTO1.setCost(totalCost);
initDedDetail(dedDetailDTO1, OrderViolateEnum.CHANGE.getCode(), totalCost, stringBuilder);
}
}
}
}
if (dedDetailDTO1.getCost() != null && dedDetailDTO1.getCost().doubleValue() != 0) {
jsonArray.add(dedDetailDTO1);
}
orderPageVO.setDedDetailDTO(jsonArray.toJSONString());
} }
public void initDedDetail(DedDetailDTO dedDetailDTO, Integer type, BigDecimal cost, StringBuilder stringBuilder) { public void initDedDetail(DedDetailDTO dedDetailDTO, Integer type, BigDecimal cost, StringBuilder stringBuilder) {
String detailName = null; String detailName = null;
if (type == OrderViolateEnum.BEFORE.getCode()) { if (type == OrderViolateEnum.BEFORE.getCode()) {
...@@ -325,6 +375,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -325,6 +375,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
} else if (type == OrderViolateEnum.AFTER.getCode()) { } else if (type == OrderViolateEnum.AFTER.getCode()) {
dedDetailDTO.setType(OrderViolateEnum.AFTER.getCode()); dedDetailDTO.setType(OrderViolateEnum.AFTER.getCode());
detailName = "延期还车违约金"; detailName = "延期还车违约金";
} else if (type == OrderViolateEnum.CHANGE.getCode()) {
dedDetailDTO.setType(OrderViolateEnum.CHANGE.getCode());
detailName = "更换还车公司";
} }
//900元+违约金(¥900x2天=)1800元 //900元+违约金(¥900x2天=)1800元
dedDetailDTO.setDeductions(stringBuilder.toString()); dedDetailDTO.setDeductions(stringBuilder.toString());
......
...@@ -482,12 +482,18 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -482,12 +482,18 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
private void handleCrosstownDetail(OrderVehicleCrosstown crosstown, OrderAccountDetail oad, CancelStartedVO csv) { private void handleCrosstownDetail(OrderVehicleCrosstown crosstown, OrderAccountDetail oad, CancelStartedVO csv) {
try{ try{
if(null != crosstown.getViolateDetail()) { if(null != crosstown.getViolateDetail()) {
DedDetailDTO vio = JSONUtil.toBean(crosstown.getViolateDetail(), DedDetailDTO.class); //修改代码
List<DedDetailDTO> vios = JSONUtil.toList(JSONUtil.parseArray(crosstown.getViolateDetail()), DedDetailDTO.class);
if(OrderViolateEnum.BEFORE.getCode().equals(vio.getType())) { //DedDetailDTO vio = JSONUtil.toBean(crosstown.getViolateDetail(), DedDetailDTO.class);
handleViolateDetail(DeductionTypeEnum.VIOLATE_ADVANCE, oad, vio, csv);
}else if(OrderViolateEnum.AFTER.getCode().equals(vio.getType())) { for(DedDetailDTO vio : vios) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_DELAY, oad, vio, csv); if(OrderViolateEnum.BEFORE.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_ADVANCE, oad, vio, csv);
}else if(OrderViolateEnum.AFTER.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_DELAY, oad, vio, csv);
}else if(OrderViolateEnum.CHANGE.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_CHANGE_C, oad, vio, csv);
}
} }
} }
}catch (Exception e) { }catch (Exception e) {
...@@ -496,6 +502,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -496,6 +502,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
} }
private void handleViolateDetail(DeductionTypeEnum dte, OrderAccountDetail oad, DedDetailDTO vio, CancelStartedVO csv) { private void handleViolateDetail(DeductionTypeEnum dte, OrderAccountDetail oad, DedDetailDTO vio, CancelStartedVO csv) {
Boolean flag = Boolean.FALSE;
for(OrderAccountDeduction deduction : oad.getDeductions()) { for(OrderAccountDeduction deduction : oad.getDeductions()) {
if(dte.getCode().equals(deduction.getType())) { if(dte.getCode().equals(deduction.getType())) {
deduction.setName(vio.getDeductions()); deduction.setName(vio.getDeductions());
...@@ -505,10 +512,24 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -505,10 +512,24 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
deduction.setAmount(vio.getCost()); deduction.setAmount(vio.getCost());
//设置订单明细参数 //设置订单明细参数
csv.setViolateAmount(deduction.getAmount()); csv.setViolateAmount(csv.getViolateAmount().add(diff));
csv.setViolateDesc(deduction.getName()); csv.setViolateDesc(csv.getViolateDesc()+ deduction.getName());
flag = Boolean.TRUE;
break;
} }
} }
//如果没有修改,则添加
if(Boolean.FALSE.equals(flag)) {
OrderAccountDeduction oadNew = initDeduction(vio.getCost(), vio.getDeductions(), dte, OrderAccountDeduction.ORIGIN_DEPOSIT);
oad.getDeductions().add(oadNew);
//修改归还押金金额
oad.setDepositAmount(oad.getDepositAmount().subtract(oadNew.getAmount()));
//设置订单明细参数
csv.setViolateAmount(csv.getViolateAmount().add(oadNew.getAmount()));
csv.setViolateDesc(csv.getViolateDesc()+ oadNew.getName());
}
} }
......
...@@ -12,7 +12,6 @@ import com.github.wxiaoqi.security.common.exception.BaseException; ...@@ -12,7 +12,6 @@ import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.activity.user.UserInfoBiz; import com.xxfc.platform.activity.user.UserInfoBiz;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.biz.inner.OrderMsgBiz; import com.xxfc.platform.order.biz.inner.OrderMsgBiz;
import com.xxfc.platform.order.contant.enumerate.CrosstownTypeEnum; import com.xxfc.platform.order.contant.enumerate.CrosstownTypeEnum;
import com.xxfc.platform.order.contant.enumerate.DepositRefundStatus; import com.xxfc.platform.order.contant.enumerate.DepositRefundStatus;
...@@ -35,7 +34,6 @@ import com.xxfc.platform.vehicle.pojo.VehicleDepartureVo; ...@@ -35,7 +34,6 @@ import com.xxfc.platform.vehicle.pojo.VehicleDepartureVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.map.HashedMap; import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -174,7 +172,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -174,7 +172,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
if (orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.DEPARTURE.getCode()) { if (orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.DEPARTURE.getCode()) {
boolean flag = getTodayTime(orderRentVehicleDetail.getStartTime()); boolean flag = getTodayTime(orderRentVehicleDetail.getStartTime());
if (!flag) { if (!flag) {
return ObjectRestResponse.createFailedResult(3502, "今日不是交车日期"); return ObjectRestResponse.createFailedResult(3502, "已超过预定还车时间,不能进行交车操作!");
} }
if (null == userDTO.getCompanyId() || !userDTO.getCompanyId().equals(orderRentVehicleDetail.getStartCompanyId())) { if (null == userDTO.getCompanyId() || !userDTO.getCompanyId().equals(orderRentVehicleDetail.getStartCompanyId())) {
return ObjectRestResponse.createFailedResult(3501, "无交车权限"); return ObjectRestResponse.createFailedResult(3501, "无交车权限");
...@@ -184,16 +182,19 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -184,16 +182,19 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
return ObjectRestResponse.createFailedResult(3503, "无收车权限"); return ObjectRestResponse.createFailedResult(3503, "无收车权限");
} }
} }
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 (baseOrder.getStatus() != -1) {
Vehicle vehicle = null;
RestResponse<Vehicle> restResponse = vehicleFeign.findById(orderRentVehicleDetail.getVehicleId());
log.info("获取车辆信息返回消息:{}", restResponse.getMessage());
if (restResponse.getData() != null) {
vehicle = restResponse.getData();
}
if (vehicle == null) {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode(), ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc());
}
if (vehicle.getMileageLastUpdate() != null) { if (vehicle.getMileageLastUpdate() != null) {
//判断车辆公里数 //判断车辆公里数
if (orderVehicleCrosstownDto.getMileage() == null || orderVehicleCrosstownDto.getMileage() < vehicle.getMileageLastUpdate()) { if (orderVehicleCrosstownDto.getMileage() == null || orderVehicleCrosstownDto.getMileage() < vehicle.getMileageLastUpdate()) {
...@@ -264,13 +265,16 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -264,13 +265,16 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
} }
//延期扣除费用 //延期扣除费用
if (StringUtils.isNotBlank(orderVehicleCrosstownDto.getViolateDetail())) { if (StringUtils.isNotBlank(orderVehicleCrosstownDto.getViolateDetail())) {
JSONObject jsonObject = JSONObject.parseObject(orderVehicleCrosstownDto.getViolateDetail()); JSONArray jsonArray = JSONArray.parseArray(orderVehicleCrosstownDto.getViolateDetail());
if (jsonObject != null) { if(jsonArray != null && jsonArray.size() > 0) {
if (jsonObject.getString("cost") != null) { for (int i = 0; i < jsonArray.size(); i++) {
cost += Double.parseDouble(jsonObject.getString("cost")); JSONObject jsonObject = JSONObject.parseObject(jsonArray.get(i).toString());
} if (jsonObject.getString("cost") != null) {
if (jsonObject.getString("excessCost") != null) { cost += Double.parseDouble(jsonObject.getString("cost"));
cost += Double.parseDouble(jsonObject.getString("excessCost")); }
if (jsonObject.getString("excessCost") != null) {
cost += Double.parseDouble(jsonObject.getString("excessCost"));
}
} }
} }
} }
......
...@@ -16,6 +16,8 @@ import com.xxfc.platform.order.entity.OrderRentVehicleDetail; ...@@ -16,6 +16,8 @@ import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction; import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail; import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO; import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -24,7 +26,11 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -24,7 +26,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List; import java.util.List;
import java.util.Map;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
/** /**
* 订单退款记录表 * 订单退款记录表
...@@ -217,4 +223,32 @@ public class OrderCalculateBiz { ...@@ -217,4 +223,32 @@ public class OrderCalculateBiz {
oad.setOriginOrderAmount(baseOrder.getGoodsAmount().subtract(baseOrder.getCouponAmount())); oad.setOriginOrderAmount(baseOrder.getGoodsAmount().subtract(baseOrder.getCouponAmount()));
return inProgressVO; return inProgressVO;
} }
/**
* 计算包含多少天
* @param startLong
* @param endLong
* @return
*/
public Integer getIncludeDays(Long startLong, Long endLong) {
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
Long hourLong = (60L * 60L * 1000L);
Long dayLong = hourLong * 24;
Long bufferLong = Long.valueOf(dictionaryMap.get(APP_ORDER+ "_"+ DictionaryKey.RENT_TIME_BUFFER).getDetail()) * hourLong;
//计算:使用天数 当前时间 - 开始时间的0时0分0秒
Long bookTimeLag = endLong - startLong;
log.info("bookTimeLag {}", new BigDecimal(bookTimeLag + ""));
log.info("divide {}", new BigDecimal((24 * 60 * 60 * 1000)+ ""));
Integer bookDays = new BigDecimal(bookTimeLag + "").divide(new BigDecimal(dayLong+ ""), 0, RoundingMode.DOWN).intValue();
Long excess = bookTimeLag%dayLong;
if(excess > bufferLong) {
bookDays += 1;
}
if(0 == bookDays) {
bookDays = 1;
}
return bookDays;
}
} }
\ No newline at end of file
...@@ -149,13 +149,7 @@ public class OrderCancelBiz { ...@@ -149,13 +149,7 @@ public class OrderCancelBiz {
//获取出发时间 到现在 距离时间 //获取出发时间 到现在 距离时间
Long timeLag = orvd.getStartTime() - System.currentTimeMillis(); Long timeLag = orvd.getStartTime() - System.currentTimeMillis();
if(timeLag < 0 ) { if(timeLag < 0 ) {
//开始时间当天时间戳 Integer useDays = orderCalculateBiz.getIncludeDays(orvd.getStartTime(), System.currentTimeMillis());
Long beginOfStartDay = DateUtil.beginOfDay(DateUtil.date(orvd.getStartTime())).getTime();
//计算:使用天数 当前时间 - 开始时间的0时0分0秒
Long useTimeLag = System.currentTimeMillis() - beginOfStartDay;
log.info("useTimeLag {}", new BigDecimal(useTimeLag + ""));
log.info("divide {}", new BigDecimal((24 * 60 * 60 * 1000)+ ""));
Integer useDays = new BigDecimal(useTimeLag + "").divide(new BigDecimal((24 * 60 * 60 * 1000)+ ""), 0, RoundingMode.UP).intValue();
inProgressVO = orderCalculateBiz.calculateOrderComplete(baseOrder, orvd, oad, orderItem, useDays, Boolean.TRUE); inProgressVO = orderCalculateBiz.calculateOrderComplete(baseOrder, orvd, oad, orderItem, useDays, Boolean.TRUE);
//结合 //结合
//退款子流程: 订单基础,退款描述,退款金额 //退款子流程: 订单基础,退款描述,退款金额
...@@ -289,6 +283,15 @@ public class OrderCancelBiz { ...@@ -289,6 +283,15 @@ public class OrderCancelBiz {
//站点总人数减少 //站点总人数减少
tourFeign.updateTourGoodPersonNum(otd.getVerificationId(), TourFeign.TOTAL_PERSON, (otd.getTotalNumber() * -1)); tourFeign.updateTourGoodPersonNum(otd.getVerificationId(), TourFeign.TOTAL_PERSON, (otd.getTotalNumber() * -1));
//已付款的取消订单发送消息
try {
AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData();
//处理后台用户提醒短信的发送
orderMsgBiz.handelMsgCancel(orvd, otd, omd, baseOrder, appUserDTO);
}catch (Exception e) {
log.error(e.getMessage(), e);
}
} }
} }
...@@ -315,6 +318,8 @@ public class OrderCancelBiz { ...@@ -315,6 +318,8 @@ public class OrderCancelBiz {
if(result < 0) { if(result < 0) {
throw new BaseException(ResultCode.FAILED_CODE); throw new BaseException(ResultCode.FAILED_CODE);
} }
orvd.setBackFreeDays(freeDays);
orderRentVehicleBiz.updateSelectiveById(orvd);
} }
}else if(OrderTypeEnum.TOUR.getCode().equals(baseOrder.getType())) { }else if(OrderTypeEnum.TOUR.getCode().equals(baseOrder.getType())) {
......
...@@ -326,7 +326,7 @@ public class OrderMsgBiz { ...@@ -326,7 +326,7 @@ public class OrderMsgBiz {
//后台发送消息(客服) //后台发送消息(客服)
Cofig cofig = configFeign.getAllByType(ConfigFeign.TYPE_CUS_SER+ "").getData().get(0); Cofig cofig = configFeign.getAllByType(ConfigFeign.TYPE_CUS_SER+ "").getData().get(0);
smsParams.clear(); smsParams.clear();
sms2BgUser(cofig.getValue(), startCompanyDetailTour, null, orvd, otd, baseOrder, appUserDTO, SmsTemplateDTO.PAY_C, smsParams); sms2BgUser(cofig.getValue(), startCompanyDetailTour, null, orvd, otd, baseOrder, appUserDTO, SmsTemplateDTO.CANCEL_F, smsParams);
break; break;
case MEMBER: case MEMBER:
break; break;
...@@ -577,10 +577,14 @@ public class OrderMsgBiz { ...@@ -577,10 +577,14 @@ public class OrderMsgBiz {
smsParams.add(startCompanyDetail.getAddrDetail()); smsParams.add(startCompanyDetail.getAddrDetail());
break; break;
case SmsTemplateDTO.PAY_J : case SmsTemplateDTO.PAY_J :
String realName = appUserDTO.getRealname();
if(StrUtil.isBlank(realName)){
realName = "";
}
if(SYS_TRUE.equals(appUserDTO.getIsMember()) && !NONE.getCode().equals(appUserDTO.getMemberLevel()) ) { if(SYS_TRUE.equals(appUserDTO.getIsMember()) && !NONE.getCode().equals(appUserDTO.getMemberLevel()) ) {
smsParams.add(USER_M+ appUserDTO.getRealname()); smsParams.add(USER_M+ realName);
}else { }else {
smsParams.add(USER_N+ appUserDTO.getRealname()); smsParams.add(USER_N+ realName);
} }
smsParams.add(baseOrder.getName()); smsParams.add(baseOrder.getName());
smsParams.add(HOUR_MINUTE_FORMATTE_HUTOOL.format(DateUtil.date(otd.getStartTime()))); smsParams.add(HOUR_MINUTE_FORMATTE_HUTOOL.format(DateUtil.date(otd.getStartTime())));
...@@ -684,7 +688,11 @@ public class OrderMsgBiz { ...@@ -684,7 +688,11 @@ public class OrderMsgBiz {
smsParams.add(orvd.getDayNum().toString()); smsParams.add(orvd.getDayNum().toString());
break; break;
case SmsTemplateDTO.PAY_H : case SmsTemplateDTO.PAY_H :
smsParams.add(appUserDTO.getRealname()); String realName = appUserDTO.getRealname();
if(StrUtil.isBlank(realName)){
realName = "匿名";
}
smsParams.add(realName);
smsParams.add(appUserDTO.getUsername()); smsParams.add(appUserDTO.getUsername());
smsParams.add(baseOrder.getName()); smsParams.add(baseOrder.getName());
smsParams.add(sCompany.getName()); smsParams.add(sCompany.getName());
...@@ -692,7 +700,11 @@ public class OrderMsgBiz { ...@@ -692,7 +700,11 @@ public class OrderMsgBiz {
smsParams.add(DateUtil.formatDateTime(DateUtil.date(otd.getStartTime()))); smsParams.add(DateUtil.formatDateTime(DateUtil.date(otd.getStartTime())));
break; break;
case SmsTemplateDTO.CANCEL_F : case SmsTemplateDTO.CANCEL_F :
smsParams.add(appUserDTO.getRealname()); String realName2 = appUserDTO.getRealname();
if(StrUtil.isBlank(realName2)){
realName2 = "匿名";
}
smsParams.add(realName2);
smsParams.add(appUserDTO.getUsername()); smsParams.add(appUserDTO.getUsername());
smsParams.add(baseOrder.getName()); smsParams.add(baseOrder.getName());
smsParams.add(sCompany.getName()); smsParams.add(sCompany.getName());
......
...@@ -54,7 +54,8 @@ import java.time.ZoneOffset; ...@@ -54,7 +54,8 @@ import java.time.ZoneOffset;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO.DEFAULT_DATE_TIME_FORMATTER; import static com.github.wxiaoqi.security.common.constant.CommonConstants.DATE_TIME_LINE_FORMATTER;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.YMR_SLASH_FORMATTER;
@Controller @Controller
@RequestMapping("baseOrder") @RequestMapping("baseOrder")
...@@ -338,8 +339,10 @@ public class BackStageOrderController extends CommonBaseController implements Us ...@@ -338,8 +339,10 @@ public class BackStageOrderController extends CommonBaseController implements Us
RentVehicleBO bo = BeanUtil.toBean(orderPageVO.getOrderRentVehicleDetail(), RentVehicleBO.class); RentVehicleBO bo = BeanUtil.toBean(orderPageVO.getOrderRentVehicleDetail(), RentVehicleBO.class);
bo.setOrder(orderPageVO); bo.setOrder(orderPageVO);
bo.setBookVehicleVO(new BookVehicleVO(){{ bo.setBookVehicleVO(new BookVehicleVO(){{
setBookStartDate(DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getStartTime()), ZoneOffset.ofHours(8)))); setBookStartDate(YMR_SLASH_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getStartTime()), ZoneOffset.ofHours(8))));
setBookEndDate(DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getEndTime()), ZoneOffset.ofHours(8)))); setBookEndDate(YMR_SLASH_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getEndTime()), ZoneOffset.ofHours(8))));
setBookStartDateTime(DATE_TIME_LINE_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getStartTime()), ZoneOffset.ofHours(8))));
setBookEndDateTime(DATE_TIME_LINE_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(bo.getEndTime()), ZoneOffset.ofHours(8))));
}}); }});
List<OrderAccompanyDTO> oads = JSONUtil.toList(JSONUtil.parseArray(orderItemBiz.selectOne(new OrderItem(){{ List<OrderAccompanyDTO> oads = JSONUtil.toList(JSONUtil.parseArray(orderItemBiz.selectOne(new OrderItem(){{
......
...@@ -109,12 +109,25 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe ...@@ -109,12 +109,25 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
String key = RENT_REFUND; String key = RENT_REFUND;
//违约金封顶 租车身份价 * 2天
BigDecimal topAmount = vehicleItem.getUnitPrice().multiply(new BigDecimal(2+ ""));
BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(vehicleItem.getBuyAmount() BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(vehicleItem.getBuyAmount()
, orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis() , orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis()
, DictionaryKey.APP_ORDER+ "_"+ key , DictionaryKey.APP_ORDER+ "_"+ key
, refundDescBuilder); , refundDescBuilder);
totalDeductAmount = deductionAmount; deductionAmount = deductionAmount.setScale(2, RoundingMode.HALF_UP);
if(topAmount.compareTo(deductionAmount) > 0) {
totalDeductAmount = totalDeductAmount.add(deductionAmount);
topAmount = topAmount.subtract(deductionAmount);
}else {
totalDeductAmount = totalDeductAmount.add(topAmount);
deductionAmount = topAmount;
topAmount = BigDecimal.ZERO;
}
// totalDeductAmount = deductionAmount;
totalRefundAmount = orderPageVO.getRealAmount().subtract(deductionAmount); totalRefundAmount = orderPageVO.getRealAmount().subtract(deductionAmount);
refundDesc = refundDescBuilder.toString(); refundDesc = refundDescBuilder.toString();
} }
......
package com.xxfc.platform.order.rest; package com.xxfc.platform.order.rest;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
...@@ -11,6 +12,7 @@ import com.github.wxiaoqi.security.common.rest.CommonBaseController; ...@@ -11,6 +12,7 @@ import com.github.wxiaoqi.security.common.rest.CommonBaseController;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.order.biz.BaseOrderBiz; import com.xxfc.platform.order.biz.BaseOrderBiz;
import com.xxfc.platform.order.biz.OrderRentVehicleBiz; import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.entity.BaseOrder; import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail; import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO; import com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO;
...@@ -18,6 +20,9 @@ import com.xxfc.platform.order.pojo.order.RentVehicleBO; ...@@ -18,6 +20,9 @@ import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.order.add.BgAddRentDTO; import com.xxfc.platform.order.pojo.order.add.BgAddRentDTO;
import com.xxfc.platform.order.pojo.price.RentVehiclePriceVO; import com.xxfc.platform.order.pojo.price.RentVehiclePriceVO;
import com.xxfc.platform.order.service.OrderRentVehicleService; import com.xxfc.platform.order.service.OrderRentVehicleService;
import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.entity.BranchCompany; import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.BookVehicleVO; import com.xxfc.platform.vehicle.pojo.BookVehicleVO;
...@@ -26,19 +31,25 @@ import io.swagger.annotations.Api; ...@@ -26,19 +31,25 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.mockito.internal.util.collections.Sets; import org.mockito.internal.util.collections.Sets;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
@Controller @Controller
@RequestMapping("orderRentVehicle") @RequestMapping("orderRentVehicle")
@Api(value="租车订单",tags={"租车订单"}) @Api(value="租车订单",tags={"租车订单"})
@IgnoreClientToken @IgnoreClientToken
@Slf4j
public class OrderRentVehicleController extends CommonBaseController { public class OrderRentVehicleController extends CommonBaseController {
@Autowired @Autowired
...@@ -56,6 +67,12 @@ public class OrderRentVehicleController extends CommonBaseController { ...@@ -56,6 +67,12 @@ public class OrderRentVehicleController extends CommonBaseController {
@Autowired @Autowired
VehicleFeign vehicleFeign; VehicleFeign vehicleFeign;
@Autowired
ThirdFeign thirdFeign;
@Autowired
OrderCalculateBiz orderCalculateBiz;
@RequestMapping(value = "add",method = RequestMethod.POST) @RequestMapping(value = "add",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "确认租车订单") @ApiOperation(value = "确认租车订单")
...@@ -81,6 +98,9 @@ public class OrderRentVehicleController extends CommonBaseController { ...@@ -81,6 +98,9 @@ public class OrderRentVehicleController extends CommonBaseController {
} }
private RentVehicleBO initRentVehicleBO(@RequestBody AddRentVehicleDTO vo) { private RentVehicleBO initRentVehicleBO(@RequestBody AddRentVehicleDTO vo) {
//计算天数
vo.setDayNum(orderCalculateBiz.getIncludeDays(vo.getStartTime(), vo.getEndTime()));
if(null == vo.getEndCompanyId() || vo.getEndCompanyId().equals(0)) { if(null == vo.getEndCompanyId() || vo.getEndCompanyId().equals(0)) {
if(StrUtil.isBlank(vo.getEndAddr())) { if(StrUtil.isBlank(vo.getEndAddr())) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE, Sets.newSet("公司参数不正确")); throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE, Sets.newSet("公司参数不正确"));
...@@ -113,6 +133,8 @@ public class OrderRentVehicleController extends CommonBaseController { ...@@ -113,6 +133,8 @@ public class OrderRentVehicleController extends CommonBaseController {
bo.setBookVehicleVO(new BookVehicleVO(){{ bo.setBookVehicleVO(new BookVehicleVO(){{
setBookStartDate(vo.getBookStartDate()); setBookStartDate(vo.getBookStartDate());
setBookEndDate(vo.getBookEndDate()); setBookEndDate(vo.getBookEndDate());
setBookStartDateTime(vo.getBookStartDateTime());
setBookEndDateTime(vo.getBookEndDateTime());
}}); }});
bo.setTickerNo(StrUtil.isNotBlank(vo.getTickerNos())? bo.setTickerNo(StrUtil.isNotBlank(vo.getTickerNos())?
StrUtil.splitTrim(vo.getTickerNos(), ","):null); StrUtil.splitTrim(vo.getTickerNos(), ","):null);
......
...@@ -7,7 +7,6 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign; ...@@ -7,7 +7,6 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface; import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.OrderUtil; import com.github.wxiaoqi.security.common.util.OrderUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
...@@ -19,7 +18,6 @@ import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum; ...@@ -19,7 +18,6 @@ import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.BaseOrder; import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.inter.OrderDetail; import com.xxfc.platform.order.entity.inter.OrderDetail;
import com.xxfc.platform.order.mqhandler.RabbitProduct; import com.xxfc.platform.order.mqhandler.RabbitProduct;
import com.xxfc.platform.order.pojo.pay.NotifyUrlDTO;
import com.xxfc.platform.order.pojo.price.OrderPriceVO; import com.xxfc.platform.order.pojo.price.OrderPriceVO;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
...@@ -456,6 +456,8 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -456,6 +456,8 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
rentVehicleBookDTO.setLiftCompany(detail.getStartCompanyId()); rentVehicleBookDTO.setLiftCompany(detail.getStartCompanyId());
rentVehicleBookDTO.setLiftAddr(detail.getStartAddr()); rentVehicleBookDTO.setLiftAddr(detail.getStartAddr());
rentVehicleBookDTO.setRetCompany(detail.getEndCompanyId()); rentVehicleBookDTO.setRetCompany(detail.getEndCompanyId());
rentVehicleBookDTO.setStartCompanyId(detail.getStartCompanyId());
rentVehicleBookDTO.setEndCompanyId(detail.getEndCompanyId());
rentVehicleBookDTO.setOrderNo(detail.getOrder().getNo()); rentVehicleBookDTO.setOrderNo(detail.getOrder().getNo());
rentVehicleBookDTO.setNumberPlate(numberPlate); rentVehicleBookDTO.setNumberPlate(numberPlate);
rentVehicleBookDTO.setStatus(status); rentVehicleBookDTO.setStatus(status);
......
package com.xxfc.platform.uccn.rest; package com.xxfc.platform.uccn.rest;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.campsite.vo.CampsiteShopPageVo;
import com.xxfc.platform.tour.entity.TourGood;
import com.xxfc.platform.uccn.biz.SearchBiz; import com.xxfc.platform.uccn.biz.SearchBiz;
import com.xxfc.platform.uccn.comstnt.ServiceConstant; import com.xxfc.platform.uccn.comstnt.ServiceConstant;
import com.xxfc.platform.uccn.entity.Article;
import com.xxfc.platform.uccn.vo.SearchResultVo; import com.xxfc.platform.uccn.vo.SearchResultVo;
import com.xxfc.platform.uccn.vo.ServiceResultVo;
import com.xxfc.platform.uccn.vo.SummitActivityVo;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.pojo.VehicleModelQueryCondition; import com.xxfc.platform.vehicle.pojo.VehicleModelQueryCondition;
import com.xxfc.platform.vehicle.pojo.VehicleModelVo;
import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO; import com.xxfc.platform.vehicle.pojo.dto.BranchCompanyFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyListVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* @author libin * @author libin
* @version 1.0 * @version 1.0
...@@ -48,24 +60,74 @@ public class SearchController { ...@@ -48,24 +60,74 @@ public class SearchController {
vehicleModelQueryCondition.setPage(page); vehicleModelQueryCondition.setPage(page);
vehicleModelQueryCondition.setLimit(limit); vehicleModelQueryCondition.setLimit(limit);
vehicleModelQueryCondition.setVehicleName(keyWord); vehicleModelQueryCondition.setVehicleName(keyWord);
return vehicleModelController.findVehicleModelPageUnauthfind(vehicleModelQueryCondition); ObjectRestResponse<PageDataVO<VehicleModelVo>> vehicleResult =vehicleModelController.findVehicleModelPageUnauthfind(vehicleModelQueryCondition);
List<VehicleModelVo> vehicleModelVoList = vehicleResult.getData().getData();
Long vehicleTotalCount = vehicleResult.getData().getTotalCount();
ServiceResultVo<VehicleModelVo> vehicleModelVoServiceResultVo = new ServiceResultVo<>();
vehicleModelVoServiceResultVo.setData(vehicleModelVoList);
vehicleModelVoServiceResultVo.setTotalCount(vehicleTotalCount);
SearchResultVo searchResultVo = new SearchResultVo();
searchResultVo.put(ServiceConstant.VEHICLE,vehicleModelVoServiceResultVo);
return ObjectRestResponse.succ(searchResultVo);
case ServiceConstant.BRANCH_COMPANY: case ServiceConstant.BRANCH_COMPANY:
BranchCompanyFindDTO branchCompanyFindDTO = new BranchCompanyFindDTO(); BranchCompanyFindDTO branchCompanyFindDTO = new BranchCompanyFindDTO();
branchCompanyFindDTO.setPage(page); branchCompanyFindDTO.setPage(page);
branchCompanyFindDTO.setLimit(limit); branchCompanyFindDTO.setLimit(limit);
branchCompanyFindDTO.setName(keyWord); branchCompanyFindDTO.setName(keyWord);
return branchCompanyController.listBranchCompanyWithPage(branchCompanyFindDTO); ObjectRestResponse<PageDataVO> branchResult = branchCompanyController.listBranchCompanyWithPage(branchCompanyFindDTO);
List branchCompanyList = branchResult.getData().getData();
Long branchCompanyTotalCount = branchResult.getData().getTotalCount();
ServiceResultVo<BranchCompanyListVO> companyServiceResultVo = new ServiceResultVo<>();
companyServiceResultVo.setData(branchCompanyList);
companyServiceResultVo.setTotalCount(branchCompanyTotalCount);
SearchResultVo branchCompanyResultVo = new SearchResultVo();
branchCompanyResultVo.put(ServiceConstant.BRANCH_COMPANY,companyServiceResultVo);
return ObjectRestResponse.succ(branchCompanyResultVo);
case ServiceConstant.TROUR: case ServiceConstant.TROUR:
return gwTourController.getGoodList(page, limit, null, keyWord); ObjectRestResponse goodresult = gwTourController.getGoodList(page, limit, null, keyWord);
PageDataVO<TourGood> data = (PageDataVO<TourGood>)goodresult.getData();
List<TourGood> tourGoodList = data.getData();
Long tourGoodTotalCount = data.getTotalCount();
ServiceResultVo<TourGood> tourGoodServiceResultVo = new ServiceResultVo<>();
tourGoodServiceResultVo.setData(tourGoodList);
tourGoodServiceResultVo.setTotalCount(tourGoodTotalCount);
SearchResultVo tourGoodSearchResult = new SearchResultVo();
tourGoodSearchResult.put(ServiceConstant.TROUR,tourGoodServiceResultVo);
return ObjectRestResponse.succ(tourGoodSearchResult);
case ServiceConstant.CAMPSITE: case ServiceConstant.CAMPSITE:
return campsiteUccnController.findCampsiteShopPageByType(null, page, limit, keyWord); ObjectRestResponse<PageDataVO<CampsiteShopPageVo>> campsiteResult = campsiteUccnController.findCampsiteShopPageByType(null, page, limit, keyWord);
List<CampsiteShopPageVo> campsiteShopPageVoList = campsiteResult.getData().getData();
Long campsiteTotalCount = campsiteResult.getData().getTotalCount();
ServiceResultVo<CampsiteShopPageVo> campsiteShopPageVoServiceResultVo = new ServiceResultVo<>();
campsiteShopPageVoServiceResultVo.setData(campsiteShopPageVoList);
campsiteShopPageVoServiceResultVo.setTotalCount(campsiteTotalCount);
SearchResultVo campsiteSearchResultVo = new SearchResultVo();
campsiteSearchResultVo.put(ServiceConstant.CAMPSITE,campsiteShopPageVoServiceResultVo);
return ObjectRestResponse.succ(campsiteSearchResultVo);
case ServiceConstant.NEWS: case ServiceConstant.NEWS:
return articleController.getArticleList(page, limit, null, keyWord); ObjectRestResponse articleresult = articleController.getArticleList(page, limit, 1, keyWord);
PageInfo<Article> articlePageDataVO = (PageInfo<Article>)articleresult.getData();
List<Article> articleList = articlePageDataVO.getList();
Long articleTotalCount = articlePageDataVO.getTotal();
ServiceResultVo<Article> articleServiceResultVo = new ServiceResultVo<>();
articleServiceResultVo.setTotalCount(articleTotalCount);
articleServiceResultVo.setData(articleList);
SearchResultVo articleSearchResult= new SearchResultVo();
articleSearchResult.put(ServiceConstant.NEWS,articleServiceResultVo);
return ObjectRestResponse.succ(articleSearchResult);
case ServiceConstant.ACTIVITY: case ServiceConstant.ACTIVITY:
return summitActivityController.findSummitActivityWithPage(page, limit, null, keyWord); ObjectRestResponse<PageDataVO<SummitActivityVo>> summitActivityWithPage = summitActivityController.findSummitActivityWithPage(page, limit, null, keyWord);
List<SummitActivityVo> summitActivityVos = summitActivityWithPage.getData().getData();
Long summitTotalCount = summitActivityWithPage.getData().getTotalCount();
ServiceResultVo<SummitActivityVo> summitActivityVoServiceResultVo = new ServiceResultVo<>();
summitActivityVoServiceResultVo.setData(summitActivityVos);
summitActivityVoServiceResultVo.setTotalCount(summitTotalCount);
SearchResultVo summitActivitySearchResult = new SearchResultVo();
summitActivitySearchResult.put(ServiceConstant.ACTIVITY,summitActivityVoServiceResultVo);
return ObjectRestResponse.succ(summitActivitySearchResult);
default: default:
SearchResultVo searchResultVo = searchBiz.searchWithKeyWords(keyWord); return ObjectRestResponse.succ(searchBiz.searchWithKeyWords(keyWord));
return ObjectRestResponse.succ(searchResultVo);
} }
} }
} }
...@@ -7,6 +7,17 @@ public class DictionaryKey { ...@@ -7,6 +7,17 @@ public class DictionaryKey {
*/ */
public static final String APP_ORDER ="APP_ORDER"; public static final String APP_ORDER ="APP_ORDER";
/**
* 违约类型
*/
public static final String ILLEGAL_TYPE = "ILLEGAL_TYPE";
/**
* 更换还车公司费用计算单价
*/
public static final String ILLEGAL_FEE_PRICE = "ILLEGAL_FEE_PRICE";
/** /**
* IM类型 * IM类型
*/ */
...@@ -34,6 +45,7 @@ public class DictionaryKey { ...@@ -34,6 +45,7 @@ public class DictionaryKey {
public static final String DRIVER_PRICE ="DRIVER_PRICE"; public static final String DRIVER_PRICE ="DRIVER_PRICE";
public static final String DAMAGE_SAFE ="DAMAGE_SAFE"; public static final String DAMAGE_SAFE ="DAMAGE_SAFE";
public static final String ILLEGAL_RESERVE = "ILLEGAL_RESERVE"; public static final String ILLEGAL_RESERVE = "ILLEGAL_RESERVE";
public static final String RENT_TIME_BUFFER = "RENT_TIME_BUFFER";
/** /**
* 旅游:保险费用 * 旅游:保险费用
......
...@@ -5,10 +5,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; ...@@ -5,10 +5,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.dto.SmsTemplateDTO; import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.IdInformation; import com.xxfc.platform.universal.entity.IdInformation;
import com.xxfc.platform.universal.vo.OrderPayVo; import com.xxfc.platform.universal.vo.*;
import com.xxfc.platform.universal.vo.OrderRefundVo;
import com.xxfc.platform.universal.vo.TrafficViolations;
import com.xxfc.platform.universal.vo.ViolationVO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -83,4 +80,8 @@ public interface ThirdFeign { ...@@ -83,4 +80,8 @@ public interface ThirdFeign {
public ObjectRestResponse<List<ViolationVO>> getRentViolation(@RequestParam(value = "rentViolationDTO") Map<String, Object> rentViolationDTO); public ObjectRestResponse<List<ViolationVO>> getRentViolation(@RequestParam(value = "rentViolationDTO") Map<String, Object> rentViolationDTO);
/*************************************支付***************************************/
@GetMapping("/info/app/unauth/getAliPayUserInfo")
public ObjectRestResponse<String> getAliPayUserInfo(@RequestParam(value = "code")String code);
} }
package com.xxfc.platform.universal.utils;
public final class Base64 {
private static final int BASELENGTH = 128;
private static final int LOOKUPLENGTH = 64;
private static final int TWENTYFOURBITGROUP = 24;
private static final int EIGHTBIT = 8;
private static final int SIXTEENBIT = 16;
private static final int FOURBYTE = 4;
private static final int SIGN = -128;
private static char PAD = '=';
private static byte[] base64Alphabet = new byte[BASELENGTH];
private static char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH];
static {
for (int i = 0; i < BASELENGTH; ++i) {
base64Alphabet[i] = -1;
}
for (int i = 'Z'; i >= 'A'; i--) {
base64Alphabet[i] = (byte) (i - 'A');
}
for (int i = 'z'; i >= 'a'; i--) {
base64Alphabet[i] = (byte) (i - 'a' + 26);
}
for (int i = '9'; i >= '0'; i--) {
base64Alphabet[i] = (byte) (i - '0' + 52);
}
base64Alphabet['+'] = 62;
base64Alphabet['/'] = 63;
for (int i = 0; i <= 25; i++) {
lookUpBase64Alphabet[i] = (char) ('A' + i);
}
for (int i = 26, j = 0; i <= 51; i++, j++) {
lookUpBase64Alphabet[i] = (char) ('a' + j);
}
for (int i = 52, j = 0; i <= 61; i++, j++) {
lookUpBase64Alphabet[i] = (char) ('0' + j);
}
lookUpBase64Alphabet[62] = (char) '+';
lookUpBase64Alphabet[63] = (char) '/';
}
private static boolean isWhiteSpace(char octect) {
return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9);
}
private static boolean isPad(char octect) {
return (octect == PAD);
}
private static boolean isData(char octect) {
return (octect < BASELENGTH && base64Alphabet[octect] != -1);
}
/**
* Encodes hex octects into Base64
*
* @param binaryData
* Array containing binaryData
* @return Encoded Base64 array
*/
public static String encode(byte[] binaryData) {
if (binaryData == null) {
return null;
}
int lengthDataBits = binaryData.length * EIGHTBIT;
if (lengthDataBits == 0) {
return "";
}
int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1
: numberTriplets;
char encodedData[] = null;
encodedData = new char[numberQuartet * 4];
byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0;
int encodedIndex = 0;
int dataIndex = 0;
for (int i = 0; i < numberTriplets; i++) {
b1 = binaryData[dataIndex++];
b2 = binaryData[dataIndex++];
b3 = binaryData[dataIndex++];
l = (byte) (b2 & 0x0f);
k = (byte) (b1 & 0x03);
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2)
: (byte) ((b1) >> 2 ^ 0xc0);
byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4)
: (byte) ((b2) >> 4 ^ 0xf0);
byte val3 = ((b3 & SIGN) == 0) ? (byte) (b3 >> 6)
: (byte) ((b3) >> 6 ^ 0xfc);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)];
encodedData[encodedIndex++] = lookUpBase64Alphabet[(l << 2) | val3];
encodedData[encodedIndex++] = lookUpBase64Alphabet[b3 & 0x3f];
}
// form integral number of 6-bit groups
if (fewerThan24bits == EIGHTBIT) {
b1 = binaryData[dataIndex];
k = (byte) (b1 & 0x03);
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2)
: (byte) ((b1) >> 2 ^ 0xc0);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4];
encodedData[encodedIndex++] = PAD;
encodedData[encodedIndex++] = PAD;
} else if (fewerThan24bits == SIXTEENBIT) {
b1 = binaryData[dataIndex];
b2 = binaryData[dataIndex + 1];
l = (byte) (b2 & 0x0f);
k = (byte) (b1 & 0x03);
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2)
: (byte) ((b1) >> 2 ^ 0xc0);
byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4)
: (byte) ((b2) >> 4 ^ 0xf0);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)];
encodedData[encodedIndex++] = lookUpBase64Alphabet[l << 2];
encodedData[encodedIndex++] = PAD;
}
return new String(encodedData);
}
/**
* Decodes Base64 data into octects
*
* @param encoded
* string containing Base64 data
* @return Array containind decoded data.
*/
public static byte[] decode(String encoded) {
if (encoded == null) {
return null;
}
char[] base64Data = encoded.toCharArray();
// remove white spaces
int len = removeWhiteSpace(base64Data);
if (len % FOURBYTE != 0) {
return null;// should be divisible by four
}
int numberQuadruple = (len / FOURBYTE);
if (numberQuadruple == 0) {
return new byte[0];
}
byte decodedData[] = null;
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
char d1 = 0, d2 = 0, d3 = 0, d4 = 0;
int i = 0;
int encodedIndex = 0;
int dataIndex = 0;
decodedData = new byte[(numberQuadruple) * 3];
for (; i < numberQuadruple - 1; i++) {
if (!isData((d1 = base64Data[dataIndex++]))
|| !isData((d2 = base64Data[dataIndex++]))
|| !isData((d3 = base64Data[dataIndex++]))
|| !isData((d4 = base64Data[dataIndex++]))) {
return null;
}// if found "no data" just return null
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
}
if (!isData((d1 = base64Data[dataIndex++]))
|| !isData((d2 = base64Data[dataIndex++]))) {
return null;// if found "no data" just return null
}
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
d3 = base64Data[dataIndex++];
d4 = base64Data[dataIndex++];
if (!isData((d3)) || !isData((d4))) {// Check if they are PAD characters
if (isPad(d3) && isPad(d4)) {
if ((b2 & 0xf) != 0)// last 4 bits should be zero
{
return null;
}
byte[] tmp = new byte[i * 3 + 1];
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
return tmp;
} else if (!isPad(d3) && isPad(d4)) {
b3 = base64Alphabet[d3];
if ((b3 & 0x3) != 0)// last 2 bits should be zero
{
return null;
}
byte[] tmp = new byte[i * 3 + 2];
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
return tmp;
} else {
return null;
}
} else { // No PAD e.g 3cQl
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
}
return decodedData;
}
/**
* remove WhiteSpace from MIME containing encoded Base64 data.
*
* @param data
* the byte array of base64 data (with WS)
* @return the new length
*/
private static int removeWhiteSpace(char[] data) {
if (data == null) {
return 0;
}
// count characters that's not whitespace
int newSize = 0;
int len = data.length;
for (int i = 0; i < len; i++) {
if (!isWhiteSpace(data[i])) {
data[newSize++] = data[i];
}
}
return newSize;
}
}
package com.xxfc.platform.universal.utils;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
public class SignUtils {
private static final String ALGORITHM = "RSA";
private static final String SIGN_ALGORITHMS = "SHA1WithRSA";
private static final String SIGN_SHA256RSA_ALGORITHMS = "SHA256WithRSA";
private static final String DEFAULT_CHARSET = "UTF-8";
private static String getAlgorithms(boolean rsa2) {
return rsa2 ? SIGN_SHA256RSA_ALGORITHMS : SIGN_ALGORITHMS;
}
public static String sign(String content, String privateKey, boolean rsa2) {
try {
PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(
Base64.decode(privateKey));
KeyFactory keyf = KeyFactory.getInstance(ALGORITHM);
PrivateKey priKey = keyf.generatePrivate(priPKCS8);
java.security.Signature signature = java.security.Signature
.getInstance(getAlgorithms(rsa2));
signature.initSign(priKey);
signature.update(content.getBytes(DEFAULT_CHARSET));
byte[] signed = signature.sign();
return Base64.encode(signed);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
...@@ -15,12 +15,14 @@ import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant; ...@@ -15,12 +15,14 @@ import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.HTTPSUtils; import com.github.wxiaoqi.security.common.util.HTTPSUtils;
import com.github.wxiaoqi.security.common.util.OrderUtil; import com.github.wxiaoqi.security.common.util.OrderUtil;
import com.github.wxiaoqi.security.common.util.UUIDUtils;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.process.SystemConfig; import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil; import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.OrderPay; import com.xxfc.platform.universal.entity.OrderPay;
import com.xxfc.platform.universal.mapper.OrderPayMapper; import com.xxfc.platform.universal.mapper.OrderPayMapper;
import com.xxfc.platform.universal.utils.SignUtils;
import com.xxfc.platform.universal.vo.OrderPayVo; import com.xxfc.platform.universal.vo.OrderPayVo;
import com.xxfc.platform.universal.weixin.api.WXPay; import com.xxfc.platform.universal.weixin.api.WXPay;
import com.xxfc.platform.universal.weixin.util.HTTPUtils; import com.xxfc.platform.universal.weixin.util.HTTPUtils;
...@@ -370,6 +372,82 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> { ...@@ -370,6 +372,82 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
} }
} }
/**
* 支付宝授权获取用户信息
* @param code
* @return
* @throws AlipayApiException
*/
public String getAlipayToken(String code) throws AlipayApiException{
AlipayClient alipayClient = getAlipayClient();
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
request.setGrantType("authorization_code");
request.setCode(code);
AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
if(response.isSuccess()){
log.info("获取用户token调用成功,获取用户信息 {}", response.getBody());
if(response.getAccessToken() != null) {
AlipayUserInfoShareRequest alipayUserInfoShareRequest = new AlipayUserInfoShareRequest();
AlipayUserInfoShareResponse alipayUserInfoShareResponse = alipayClient.execute(alipayUserInfoShareRequest,response.getAccessToken());
if(alipayUserInfoShareResponse.isSuccess()){
log.info("获取用户支付宝信息调用成功, {}", alipayUserInfoShareResponse.getBody());
return alipayUserInfoShareResponse.getBody();
} else {
log.info("获取用户支付宝信息调用失败, {}", alipayUserInfoShareResponse.getBody());
}
}
} else {
log.info("获取用户token调用失败, {}", response.getBody());
}
return response.getBody();
}
public String generateAliPayInfo(String apiName, String appName) {
//apiname=com.alipay.account.auth&app_id=xxxxx&app_name=mc&auth_type=AUTHACCOUNT&biz_type=openservice&method=alipay.open.auth.sdk.code.get&pid=xxxxx&product_id=APP_FAST_LOGIN&scope=kuaijie&sign_type=RSA2&target_id=20141225xxxx&sign=fMcp4GtiM6rxSIeFnJCVePJKV43eXrUP86CQgiLhDHH2u%2FdN75eEvmywc2ulkm7qKRetkU9fbVZtJIqFdMJcJ9Yp%2BJI%2FF%2FpESafFR6rB2fRjiQQLGXvxmDGVMjPSxHxVtIqpZy5FDoKUSjQ2%2FILDKpu3%2F%2BtAtm2jRw1rUoMhgt0%3D
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("apiname=");
stringBuilder.append(apiName);
stringBuilder.append("&app_id=");
stringBuilder.append(SystemConfig.ALIPAY_APPID);
stringBuilder.append("&app_name=");
stringBuilder.append(appName);
stringBuilder.append("&auth_type=AUTHACCOUNT");
stringBuilder.append("&biz_type=openservice");
stringBuilder.append("&method=alipay.open.auth.sdk.code.get");
stringBuilder.append("&pid=");
stringBuilder.append(SystemConfig.ALIPAY_PID);
stringBuilder.append("&product_id=APP_FAST_LOGIN");
stringBuilder.append("&scope=kuaijie");
stringBuilder.append("&sign_type=RSA2");
stringBuilder.append("&target_id=");
stringBuilder.append(UUIDUtils.generateShortUuid());
String sign = SignUtils.sign(stringBuilder.toString(), SystemConfig.ALIPAY_PRIVATE_KEY, true);
stringBuilder.append("&sign=");
stringBuilder.append(sign);
return stringBuilder.toString();
}
public String alipayUserAuth() throws AlipayApiException {
AlipayClient alipayClient = getAlipayClient();
AlipayUserInfoAuthRequest request = new AlipayUserInfoAuthRequest();
request.setBizContent("{" +
" \"scopes\":[" +
" \"auth_base\"" +
" ]," +
"\"state\":\"init\"," +
"\"is_mobile\":\"true\"" +
" }");
AlipayUserInfoAuthResponse response = alipayClient.execute(request);
if(response.isSuccess()){
System.out.println("调用成功");
} else {
System.out.println("调用失败");
}
return response.getBody();
}
//解冻预授权 //解冻预授权
public void fundAuthOrderUnFreeze(AlipayClient alipayClient) throws AlipayApiException { public void fundAuthOrderUnFreeze(AlipayClient alipayClient) throws AlipayApiException {
AlipayFundAuthOrderUnfreezeRequest request = new AlipayFundAuthOrderUnfreezeRequest(); AlipayFundAuthOrderUnfreezeRequest request = new AlipayFundAuthOrderUnfreezeRequest();
......
...@@ -4,9 +4,11 @@ package com.xxfc.platform.universal.controller; ...@@ -4,9 +4,11 @@ package com.xxfc.platform.universal.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.UserAgentUtil; import com.github.wxiaoqi.security.common.util.UserAgentUtil;
import com.xxfc.platform.universal.biz.OrderPayBiz;
import com.xxfc.platform.universal.biz.WeixinService; import com.xxfc.platform.universal.biz.WeixinService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -28,6 +30,9 @@ public class UserInfoController { ...@@ -28,6 +30,9 @@ public class UserInfoController {
@Autowired @Autowired
WeixinService weixinService; WeixinService weixinService;
@Autowired
OrderPayBiz orderPayBiz;
@Value("${wx.sendUrl}") @Value("${wx.sendUrl}")
private String sendUrl; private String sendUrl;
...@@ -51,5 +56,31 @@ public class UserInfoController { ...@@ -51,5 +56,31 @@ public class UserInfoController {
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
@GetMapping("/app/unauth/getAliPayUserInfo")
public ObjectRestResponse<String> getAliPayUserInfo(String code) {
try {
return ObjectRestResponse.succ(orderPayBiz.getAlipayToken(code));
} catch (AlipayApiException e) {
e.printStackTrace();
}
return ObjectRestResponse.createDefaultFail();
}
@GetMapping("/app/unauth/alipayUserAuth")
public ObjectRestResponse<String> alipayUserAuth() {
try {
JSONObject jsonObject = JSONObject.parseObject(orderPayBiz.alipayUserAuth());
return ObjectRestResponse.succ(jsonObject);
} catch (AlipayApiException e) {
e.printStackTrace();
}
return ObjectRestResponse.createDefaultFail();
}
@GetMapping("/app/unauth/getParam")
public ObjectRestResponse<String> getParam(String apiName, String appName) {
return ObjectRestResponse.succ(orderPayBiz.generateAliPayInfo(apiName, appName));
}
} }
...@@ -16,7 +16,8 @@ public enum BookType { ...@@ -16,7 +16,8 @@ public enum BookType {
BOOKING(7,"预约中"), BOOKING(7,"预约中"),
DISABLE(8,"禁用"), DISABLE(8,"禁用"),
CUSTOMER_APPLY(9, "客户用车"), CUSTOMER_APPLY(9, "客户用车"),
OTHER(10, "其他") OTHER(10, "其他"),
DISPATCH(11, "调度")
; ;
/** /**
* 编码 * 编码
......
...@@ -49,6 +49,8 @@ public enum ResCode { ...@@ -49,6 +49,8 @@ public enum ResCode {
VEHICLE_UPKEEP_VEHICLE_DISABLE(106002,"车辆不可用"), VEHICLE_UPKEEP_VEHICLE_DISABLE(106002,"车辆不可用"),
VEHICLE_UPKEEP_ITEM_UNEXIST(106003, "保养项目不存在"), VEHICLE_UPKEEP_ITEM_UNEXIST(106003, "保养项目不存在"),
VEHICLE_UPKEEP_VEHICLE_UNUPKEEP(106004, "车辆不在保养中"), VEHICLE_UPKEEP_VEHICLE_UNUPKEEP(106004, "车辆不在保养中"),
VEHICLE_STATUS_IS_NOT_NORMAL(106005, "上次的出行未做收车操作, 请先收车"),
VEHICLE_IS_BOOKED_TODAY(106006, "车辆当前时段已经被预定"), VEHICLE_IS_BOOKED_TODAY(106006, "车辆当前时段已经被预定"),
FIND_VEHICLE_PLAT_FAILE(106007, "获取车型列表失败"), FIND_VEHICLE_PLAT_FAILE(106007, "获取车型列表失败"),
......
...@@ -52,4 +52,10 @@ public class BookRecordUpdateLog { ...@@ -52,4 +52,10 @@ public class BookRecordUpdateLog {
*/ */
@Column(name = "create_time") @Column(name = "create_time")
private Date createTime; private Date createTime;
@Transient
private String oldCompanyName;
@Transient
private String newCompanyName;
} }
\ No newline at end of file
...@@ -173,4 +173,7 @@ public interface VehicleFeign { ...@@ -173,4 +173,7 @@ public interface VehicleFeign {
@RequestMapping(value ="/branchCompany/app/unauth/getCompanyIds",method = RequestMethod.GET) @RequestMapping(value ="/branchCompany/app/unauth/getCompanyIds",method = RequestMethod.GET)
RestResponse<List<Integer>> getCompanyIds(); RestResponse<List<Integer>> getCompanyIds();
@GetMapping(value = "/bookRecord/get")
public ObjectRestResponse<List<BookRecordUpdateLog>> get(@RequestParam(value = "bookRecordId")Long bookRecordId);
} }
...@@ -27,6 +27,18 @@ public class BookVehicleVO { ...@@ -27,6 +27,18 @@ public class BookVehicleVO {
@ApiModelProperty("预定目标日期(结束)") @ApiModelProperty("预定目标日期(结束)")
private String bookEndDate; private String bookEndDate;
/**
* 预定目标日期(开始)
*/
@ApiModelProperty("预定目标时间(开始)")
private String bookStartDateTime;
/**
* 预定目标日期(结束)
*/
@ApiModelProperty("预定目标时间(结束)")
private String bookEndDateTime;
/** /**
* 取消预定目标日期(开始) * 取消预定目标日期(开始)
*/ */
......
...@@ -31,6 +31,19 @@ public class RentVehicleBookDTO extends PageParam { ...@@ -31,6 +31,19 @@ public class RentVehicleBookDTO extends PageParam {
@ApiModelProperty("预定目标日期(结束)") @ApiModelProperty("预定目标日期(结束)")
private String bookEndDate; private String bookEndDate;
/**
* 预定目标日期(开始)
*/
@ApiModelProperty("预定目标时间(开始)")
private String bookStartDateTime;
/**
* 预定目标日期(结束)
*/
@ApiModelProperty("预定目标时间(结束)")
private String bookEndDateTime;
/** /**
* 提车地点 * 提车地点
*/ */
......
...@@ -54,8 +54,8 @@ public class UsableVeicleDTO extends PageParam { ...@@ -54,8 +54,8 @@ public class UsableVeicleDTO extends PageParam {
@ApiModelProperty(hidden = true) @ApiModelProperty(hidden = true)
Boolean yearNo4Where; Boolean yearNo4Where;
@ApiModelProperty(hidden = true) // @ApiModelProperty(hidden = true)
Integer withoutRecordWhere = 1; // Integer withoutRecordWhere = 1;
/** /**
* 用途 1 租车 * 用途 1 租车
......
package com.xxfc.platform.vehicle.util;
import java.awt.geom.Point2D;
import java.math.BigDecimal;
public class DistanceUtil {
private static final double EARTH_RADIUS = 6371393; // 平均半径,单位:m
/**
* 通过AB点经纬度获取距离
* @param pointA A点(经,纬)
* @param pointB B点(经,纬)
* @return 距离(单位:米)
*/
public static double getDistance(Point2D pointA, Point2D pointB) {
// 经纬度(角度)转弧度。弧度用作参数,以调用Math.cos和Math.sin
double radiansAX = Math.toRadians(pointA.getX()); // A经弧度
double radiansAY = Math.toRadians(pointA.getY()); // A纬弧度
double radiansBX = Math.toRadians(pointB.getX()); // B经弧度
double radiansBY = Math.toRadians(pointB.getY()); // B纬弧度
// 公式中“cosβ1cosβ2cos(α1-α2)+sinβ1sinβ2”的部分,得到∠AOB的cos值
double cos = Math.cos(radiansAY) * Math.cos(radiansBY) * Math.cos(radiansAX - radiansBX)
+ Math.sin(radiansAY) * Math.sin(radiansBY);
// System.out.println("cos = " + cos); // 值域[-1,1]
double acos = Math.acos(cos); // 反余弦值
// System.out.println("acos = " + acos); // 值域[0,π]
// System.out.println("∠AOB = " + Math.toDegrees(acos)); // 球心角 值域[0,180]
return EARTH_RADIUS * acos; // 最终结果
}
public static double getDistance(double longitude1, double latitude1, double longitude2, double latitude2) {
Point2D pointDD = new Point2D.Double(longitude1, latitude1);
// 北京 西单地铁站
Point2D pointXD = new Point2D.Double(longitude2, latitude2);
return getDistance(pointDD, pointXD);
}
public static void main(String[] args) {
// 北京 东单地铁站
Point2D pointDD = new Point2D.Double(113.906121, 22.985271);
// 北京 西单地铁站
Point2D pointXD = new Point2D.Double(114.42078, 23.05989);
System.out.println(getDistance(pointDD, pointXD));
BigDecimal distanceNum = new BigDecimal(getDistance(pointDD, pointXD) + "").divide(new BigDecimal("1000"), 0, BigDecimal.ROUND_UP);
BigDecimal bigDecimal = new BigDecimal(2);
System.out.println(distanceNum.multiply(bigDecimal));
}
}
...@@ -3,12 +3,20 @@ package com.xxfc.platform.vehicle.biz; ...@@ -3,12 +3,20 @@ package com.xxfc.platform.vehicle.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog; import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.mapper.BookRecordUpdateLogMapper; import com.xxfc.platform.vehicle.mapper.BookRecordUpdateLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
@Service @Service
public class BookRecordUpdateLogBiz extends BaseBiz<BookRecordUpdateLogMapper, BookRecordUpdateLog> { public class BookRecordUpdateLogBiz extends BaseBiz<BookRecordUpdateLogMapper, BookRecordUpdateLog> {
@Autowired
BranchCompanyBiz branchCompanyBiz;
public ObjectRestResponse save(BookRecordUpdateLog bookRecordUpdateLog) { public ObjectRestResponse save(BookRecordUpdateLog bookRecordUpdateLog) {
BookRecordUpdateLog oldValue = mapper.selectOne(bookRecordUpdateLog); BookRecordUpdateLog oldValue = mapper.selectOne(bookRecordUpdateLog);
if (oldValue != null) { if (oldValue != null) {
...@@ -18,4 +26,22 @@ public class BookRecordUpdateLogBiz extends BaseBiz<BookRecordUpdateLogMapper, B ...@@ -18,4 +26,22 @@ public class BookRecordUpdateLogBiz extends BaseBiz<BookRecordUpdateLogMapper, B
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
public ObjectRestResponse<List<BookRecordUpdateLog>> selectByBookRecordId(Long bookRecordId) {
Example example = new Example(BookRecordUpdateLog.class);
example.createCriteria().andEqualTo("bookRecordId", bookRecordId);
example.setOrderByClause("create_time desc");
List<BookRecordUpdateLog> bookRecordUpdateLogs = selectByExample(example);
for (BookRecordUpdateLog bookRecordUpdateLog : bookRecordUpdateLogs) {
BranchCompany oldCompany = branchCompanyBiz.getById(bookRecordUpdateLog.getOldRetCompanyId());
if (oldCompany != null) {
bookRecordUpdateLog.setOldCompanyName(oldCompany.getName());
}
BranchCompany newCompany = branchCompanyBiz.getById(bookRecordUpdateLog.getNewRetCompanyId());
if (newCompany != null) {
bookRecordUpdateLog.setNewCompanyName(newCompany.getName());
}
}
return ObjectRestResponse.succ(bookRecordUpdateLogs);
}
} }
...@@ -215,7 +215,9 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -215,7 +215,9 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
@Cache(key = RedisKey.BRANCH_COMPANY_CACHE_ALL) @Cache(key = RedisKey.BRANCH_COMPANY_CACHE_ALL)
public List<BranchCompany> getAll() { public List<BranchCompany> getAll() {
return mapper.selectAll(); Example example = new Example(BranchCompany.class);
example.createCriteria().andEqualTo("isDel", 0);
return mapper.selectByExample(example);
} }
/** /**
......
...@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.biz; ...@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.constant.*; import com.xxfc.platform.vehicle.constant.*;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.*; import com.xxfc.platform.vehicle.entity.*;
...@@ -59,7 +60,7 @@ public class VehicleActiveService { ...@@ -59,7 +60,7 @@ public class VehicleActiveService {
*/ */
public void departure(VehicleDepartureVo departureVo) { public void departure(VehicleDepartureVo departureVo) {
log.info("出车参数: departureVo = {}", departureVo.toString()); log.info("出车参数: departureVo = {}", departureVo.toString());
Vehicle vehicle = vehicleMapper.selectByPrimaryKey(departureVo.getVehicleId()); Vehicle vehicle = vehicleBiz.selectById(departureVo.getVehicleId());
if (vehicle == null) { if (vehicle == null) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(), throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(),
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode());
...@@ -68,9 +69,9 @@ public class VehicleActiveService { ...@@ -68,9 +69,9 @@ public class VehicleActiveService {
throw new BaseException(ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getDesc(), throw new BaseException(ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getDesc(),
ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getCode()); ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getCode());
} }
if (vehicle.getStatus().equals(VehicleStatus.DISCARD.getCode()) || vehicle.getIsDel() == 1) { if (vehicle.getStatus().equals(VehicleStatus.DISCARD.getCode()) || vehicle.getIsDel() == 1 || vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode())) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()), throw new BaseException(ResCode.VEHICLE_STATUS_IS_NOT_NORMAL.getDesc(),
ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode()); ResCode.VEHICLE_STATUS_IS_NOT_NORMAL.getCode());
} }
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态 //添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
checkDateInvalid(departureVo); checkDateInvalid(departureVo);
...@@ -309,6 +310,10 @@ public class VehicleActiveService { ...@@ -309,6 +310,10 @@ public class VehicleActiveService {
} }
} }
public void save(VehicleDepartureLog vehicleDepartureLog){
vehicleDepartureLogMapper.insertSelective(vehicleDepartureLog);
}
//添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态 //添加出车时间过滤 再出车开始时间前一天至结束时间内可以出车,并且预定记录为已审核状态
public void checkDateInvalid(VehicleDepartureVo arrivalVo) { public void checkDateInvalid(VehicleDepartureVo arrivalVo) {
if (arrivalVo.getBookRecordId() != null) { if (arrivalVo.getBookRecordId() != null) {
...@@ -452,6 +457,17 @@ public class VehicleActiveService { ...@@ -452,6 +457,17 @@ public class VehicleActiveService {
} }
public ObjectRestResponse selectDepartureLogByBookRecordId(Long bookRecordId) {
if (bookRecordId == null) {
return ObjectRestResponse.paramIsEmpty();
}
VehicleDepartureLogVo vehicleDepartureLog = vehicleDepartureLogMapper.selectByBookRecordId(bookRecordId);
if (vehicleDepartureLog == null) {
return ObjectRestResponse.createFailedResult(ResCode.FIND_DATA_NOT_EXIST.getCode(), ResCode.FIND_DATA_NOT_EXIST.getDesc());
}
return ObjectRestResponse.succ(vehicleDepartureLog);
}
public static void main(String[] args) { public static void main(String[] args) {
DateTime startDate = DateTime.parse("2019-08-21 17:00:00", DATE_TIME_FORMATTER); DateTime startDate = DateTime.parse("2019-08-21 17:00:00", DATE_TIME_FORMATTER);
......
...@@ -19,11 +19,8 @@ import com.google.common.collect.Lists; ...@@ -19,11 +19,8 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException; import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ConstantType; import com.xxfc.platform.vehicle.constant.*;
import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.constant.VehicleStatus;
import com.xxfc.platform.vehicle.entity.*; import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.mapper.BookRecordAccItemMapper; import com.xxfc.platform.vehicle.mapper.BookRecordAccItemMapper;
import com.xxfc.platform.vehicle.mapper.VehicleBookInfoMapper; import com.xxfc.platform.vehicle.mapper.VehicleBookInfoMapper;
...@@ -275,10 +272,13 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -275,10 +272,13 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
*/ */
@Transactional @Transactional
public RestResponse update(List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList) throws Exception { public RestResponse update(List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList) throws Exception {
if (addOrUpdateVehicleVoList.size() > MAX_BATCH_SIZE_VEHICLE) { if (addOrUpdateVehicleVoList != null && addOrUpdateVehicleVoList.size() > MAX_BATCH_SIZE_VEHICLE) {
throw new BaseException(ResultCode.ADD_VEHICLE_MORE); throw new BaseException(ResultCode.ADD_VEHICLE_MORE);
} }
UserDTO userDTO = getAdminUserInfo();
if (userDTO == null) {
throw new BaseException(ResultCode.RSTOKEN_EXPIRED_CODE);
}
for (AddOrUpdateVehicleVo addOrUpdateVehicleVo : addOrUpdateVehicleVoList) { for (AddOrUpdateVehicleVo addOrUpdateVehicleVo : addOrUpdateVehicleVoList) {
Vehicle vehicle = new Vehicle(); Vehicle vehicle = new Vehicle();
BeanUtilsBean.getInstance().copyProperties(vehicle, addOrUpdateVehicleVo); BeanUtilsBean.getInstance().copyProperties(vehicle, addOrUpdateVehicleVo);
...@@ -291,10 +291,40 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -291,10 +291,40 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
if (CollectionUtils.isNotEmpty(exitsVehicles)) { if (CollectionUtils.isNotEmpty(exitsVehicles)) {
for (Vehicle exitsVehicle : exitsVehicles) { for (Vehicle exitsVehicle : exitsVehicles) {
if (exitsVehicle.getId().equals(addOrUpdateVehicleVo.getId())) { if (exitsVehicle.getId().equals(addOrUpdateVehicleVo.getId())) {
continue; //如果修改的有停靠分公司,需要添加一条调度记录
Vehicle vehicle1 = selectById(exitsVehicle.getId());
if (vehicle1 != null) {
if (vehicle1.getParkBranchCompanyId() != addOrUpdateVehicleVo.getParkBranchCompanyId()) {
VehicleBookRecord vehicleBookRecord = new VehicleBookRecord();
vehicleBookRecord.setRetCompany(addOrUpdateVehicleVo.getParkBranchCompanyId());
vehicleBookRecord.setLiftCompany(vehicle1.getParkBranchCompanyId());
vehicleBookRecord.setRemark("后台修改停靠公司,调度车辆");
vehicleBookRecord.setBookStartDate(new Date());
vehicleBookRecord.setBookEndDate(new Date());
vehicleBookRecord.setActualEndDate(new Date());
vehicleBookRecord.setActualStartDate(new Date());
vehicleBookRecord.setBookUser(userDTO.getId());
vehicleBookRecord.setBookUserName(userDTO.getUsername());
vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPROVE.getCode());
vehicleBookRecord.setBookType(BookType.DISPATCH.getCode());
vehicleBookRecord.setVehicleId(vehicle1.getId());
vehicleBookRecord.setVehicleUsername(userDTO.getUsername());
vehicleBookRecord.setVehicleUserPhone(userDTO.getUsername());
ObjectRestResponse objectRestResponse = addVehicleBookRecord(vehicleBookRecord);
if(objectRestResponse.isRel()) {
continue;
} else {
return RestResponse.codeAndMessage(objectRestResponse.getStatus(), objectRestResponse.getMessage());
}
}
}
} else {
log.info("【修改车辆信息错误】》》》数据库车辆信息:{};前端传参车辆信息:{}", exitsVehicle.toString(), addOrUpdateVehicleVo.toString());
return RestResponse.codeAndMessage(ResCode.VEHICLE_INFO_SAME_NUM_PLATE_EXISTS.getCode(),
ResCode.VEHICLE_INFO_SAME_NUM_PLATE_EXISTS.getDesc());
} }
return RestResponse.codeAndMessage(ResCode.VEHICLE_INFO_SAME_NUM_PLATE_EXISTS.getCode(),
ResCode.VEHICLE_INFO_SAME_NUM_PLATE_EXISTS.getDesc());
// if(addOrUpdateVehicleVo.getCode()!= null && // if(addOrUpdateVehicleVo.getCode()!= null &&
// addOrUpdateVehicleVo.getCode().equals(exitsVehicles.get(0).getCode())){ // addOrUpdateVehicleVo.getCode().equals(exitsVehicles.get(0).getCode())){
...@@ -309,6 +339,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -309,6 +339,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return RestResponse.suc(); return RestResponse.suc();
} }
public ObjectRestResponse addVehicleBookRecord(VehicleBookRecord vehicleBookRecord) {
return vehicleBookRecordBiz.addBookRecord(vehicleBookRecord);
}
/** /**
* 废弃车辆(状态设置为废弃) * 废弃车辆(状态设置为废弃)
* *
...@@ -326,95 +360,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -326,95 +360,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return RestResponse.suc(); return RestResponse.suc();
} }
// /**
// * 申请汽车预定(内部)
// * 检查是否可预定,修改相关预定记录状态
// * @param userId
// * @param bookVehicleVo
// * @return
// */
// @Transactional
// public VehicleBookRecord applyVehicle4Employee(Integer userId, BookVehicleVO bookVehicleVo, String userName) throws Exception{
// //检查车辆信息是否合法
// checkIfVehicleExists(bookVehicleVo.getVehicleId());
// //提取日期和相应的预定目标日期
// Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
// //预定时间不能为空
// if(StringUtils.isBlank(bookVehicleVo.getBookStartDate()) || StringUtils.isBlank(bookVehicleVo.getBookEndDate())){
// throw new BaseException(ResultCode.DATE_TIME_IS_NULL);
// }
// String[] bookStartDateArray = bookVehicleVo.getBookStartDate().split(" ");
// String[] bookEndDateArray = bookVehicleVo.getBookEndDate().split(" ");
//
// DateTime startDay =DateTime.parse(bookStartDateArray[0],DEFAULT_DATE_TIME_FORMATTER);
// DateTime endDay =DateTime.parse(bookEndDateArray[0], DEFAULT_DATE_TIME_FORMATTER);
//
//
// //转换日期范围为列表,并检查是否合法
// fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
// if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
// throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
// }
// Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
// //检查车辆是否可以预定
// for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
// Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
// if(Boolean.FALSE.equals(rsEach)){
// throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
// }
// }
//
// //加入预定申请记录
// VehicleBookRecord vehicleBookRecord = new VehicleBookRecord();
// vehicleBookRecord.setVehicleId(bookVehicleVo.getVehicleId());
// vehicleBookRecord.setBookType(bookVehicleVo.getBookType());
// vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPLY.getCode());
// vehicleBookRecord.setBookUser(userId);
// vehicleBookRecord.setBookUserName(userName);
// vehicleBookRecord.setBookStartDate(DateTime.
// parse(bookStartDateArray[0],DEFAULT_DATE_TIME_FORMATTER).toDate());
// vehicleBookRecord.setBookEndDate(DateTime.
// parse(bookEndDateArray[0],DEFAULT_DATE_TIME_FORMATTER).toDate());
// vehicleBookRecord.setLiftAddr(bookVehicleVo.getLiftAddr());
// vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
// vehicleBookRecord.setDestination(bookVehicleVo.getDestination());
// vehicleBookRecord.setLiftCompany(bookVehicleVo.getLiftCompany());
// vehicleBookRecord.setRetCompany(bookVehicleVo.getRetCompany());
// vehicleBookRecord.setOrderNo(bookVehicleVo.getOrderNo());
// vehicleBookRecordBiz.save(vehicleBookRecord);
//// //添加预定时间记录
////
//// Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
//// for(Map.Entry<String, Integer> entry : map.entrySet()) {
//// VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
//// vehicleBookHourInfoDto.setVehicleId(bookVehicleVo.getVehicleId());
//// vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
//// vehicleBookHourInfoDto.setBookedHour(entry.getValue());
//// vehicleBookHourInfoBiz.save(vehicleBookHourInfoDto);
//// }
//
// //修改相关车辆预定记录
// Boolean hasSuc = bookedVehicle(bookVehicleVo);
// if(!hasSuc){
// throw new BaseException(ResultCode.BOOKED_FAILED_CODE);
// }
//
// //添加随车物品
// List<Map<String,Object>> params = Lists.newArrayList();
// if(MapUtils.isNotEmpty(bookVehicleVo.getSelectedAccItem())){
// for(Map.Entry<Integer,Integer> idAndAmount : bookVehicleVo.getSelectedAccItem().entrySet()){
// Map<String,Object> row = Maps.newHashMap();
// row.put("id",idAndAmount.getKey());
// row.put("amount",idAndAmount.getValue());
// row.put("bookRecordId",vehicleBookRecord.getId());
// params.add(row);
// }
// bookRecordAccItemMapper.batchAdd(params);
// }
//
// return vehicleBookRecord;
// }
/** /**
* 不需要审核 * 不需要审核
* *
...@@ -546,6 +491,25 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -546,6 +491,25 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return Boolean.TRUE; return Boolean.TRUE;
} }
/**
*
* @param vehicleId
* @return
*/
public ObjectRestResponse checkVehicleStatus(String vehicleId) {
if (StringUtils.isBlank(vehicleId)) {
return ObjectRestResponse.paramIsEmpty();
}
Vehicle vehicle = mapper.selectByPrimaryKey(vehicleId);
if (vehicle == null) {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_UPKEEP_VEHICLE_UNEXIST.getCode(), ResCode.VEHICLE_UPKEEP_VEHICLE_UNUPKEEP.getDesc());
}
if (vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode()) || vehicle.getStatus().equals(VehicleStatus.DISCARD.getCode()) || vehicle.getIsDel() != 0) {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_STATUS_IS_NOT_NORMAL.getCode(), ResCode.VEHICLE_STATUS_IS_NOT_NORMAL.getDesc());
}
return ObjectRestResponse.succ();
}
public boolean filterHourInfoBooked(String vehicleId, Map<String, Integer> hourInfo) { public boolean filterHourInfoBooked(String vehicleId, Map<String, Integer> hourInfo) {
if (MapUtils.isEmpty(hourInfo)) { if (MapUtils.isEmpty(hourInfo)) {
......
...@@ -80,6 +80,9 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -80,6 +80,9 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
@Autowired @Autowired
BookRecordUpdateLogBiz bookRecordUpdateLogBiz; BookRecordUpdateLogBiz bookRecordUpdateLogBiz;
@Autowired
VehicleActiveService vehicleActiveService;
@Override @Override
public UserFeign getUserFeign() { public UserFeign getUserFeign() {
return userFeign; return userFeign;
...@@ -302,6 +305,38 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -302,6 +305,38 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
return RestResponse.suc(); return RestResponse.suc();
} }
public ObjectRestResponse addBookRecord(VehicleBookRecord vehicleBookRecord) {
if (vehicleBookRecord == null) {
return ObjectRestResponse.paramIsEmpty();
}
save(vehicleBookRecord);
if (vehicleBookRecord != null) {
//添加交还车记录
VehicleDepartureLog vehicleDepartureLog = new VehicleDepartureLog();
vehicleDepartureLog.setBookRecordId(vehicleBookRecord.getId());
vehicleDepartureLog.setArrivalBranchCompanyId(vehicleBookRecord.getRetCompany());
vehicleDepartureLog.setArrivalRemark("后台修改停靠分公司,车辆调度");
vehicleDepartureLog.setArrivalTime(new Date());
vehicleDepartureLog.setCheckMan(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setCheckManTel(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setCreateTime(new Date());
vehicleDepartureLog.setDepartureBranchCompanyId(vehicleBookRecord.getLiftCompany());
vehicleDepartureLog.setDepartureRemark("后台修改停靠分公司,车辆调度");
vehicleDepartureLog.setDepartureTime(new Date());
vehicleDepartureLog.setRecycleMan(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setRecycleManTel(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setState(1);
vehicleDepartureLog.setVehicleId(vehicleBookRecord.getVehicleId());
vehicleDepartureLog.setUse("调度");
vehicleDepartureLog.setUser(vehicleBookRecord.getBookUserName());
vehicleDepartureLog.setUserTel(vehicleBookRecord.getBookUserName());
vehicleActiveService.save(vehicleDepartureLog);
}
return ObjectRestResponse.succ();
}
/** /**
* 按页查询 * 按页查询
* *
......
...@@ -6,6 +6,8 @@ import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog; ...@@ -6,6 +6,8 @@ import com.xxfc.platform.vehicle.entity.BookRecordUpdateLog;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController @RestController
@RequestMapping("/bookRecord") @RequestMapping("/bookRecord")
public class BookRecordUpdateLogController { public class BookRecordUpdateLogController {
...@@ -17,4 +19,10 @@ public class BookRecordUpdateLogController { ...@@ -17,4 +19,10 @@ public class BookRecordUpdateLogController {
public ObjectRestResponse save(@RequestBody BookRecordUpdateLog bookRecordUpdateLog) { public ObjectRestResponse save(@RequestBody BookRecordUpdateLog bookRecordUpdateLog) {
return bookRecordUpdateLogBiz.save(bookRecordUpdateLog); return bookRecordUpdateLogBiz.save(bookRecordUpdateLog);
} }
@GetMapping(value = "/get")
public ObjectRestResponse<List<BookRecordUpdateLog>> get(Long bookRecordId) {
return bookRecordUpdateLogBiz.selectByBookRecordId(bookRecordId);
}
} }
...@@ -195,14 +195,14 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements ...@@ -195,14 +195,14 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
} }
bookVehicleId = pageDataVO.getData().get(0).getId(); bookVehicleId = pageDataVO.getData().get(0).getId();
} }
//判断是否为今天,如果是则设置为一分钟后开始 //判断是否为今天,如果是则设置为30秒后开始 防止预约开始时间比当前时间 要 前
if(DateUtil.today().equals(dto.getBookStartDate())) { if(DateUtil.today().equals(dto.getBookStartDate())) {
LocalDateTime ldt = LocalDateTime.ofInstant(Instant.ofEpochMilli(System.currentTimeMillis()), ZoneOffset.ofHours(8)).plusSeconds(30L); LocalDateTime ldt = LocalDateTime.ofInstant(Instant.ofEpochMilli(System.currentTimeMillis()), ZoneOffset.ofHours(8)).plusSeconds(30L);
dto.setBookStartDate(DateTimeFormatter.ofPattern(DATE_TIME_LINE).format(ldt)); dto.setBookStartDate(DateTimeFormatter.ofPattern(DATE_TIME_LINE).format(ldt));
}else { }else {
dto.setBookStartDate(dto.getBookStartDate()+ " 00:00:00"); dto.setBookStartDate(dto.getBookEndDateTime());
} }
dto.setBookEndDate(dto.getBookEndDate()+ " 23:59:59"); dto.setBookEndDate(dto.getBookEndDateTime());
BookVehicleVO bookVehicleVo = BeanUtil.toBean(dto, BookVehicleVO.class); BookVehicleVO bookVehicleVo = BeanUtil.toBean(dto, BookVehicleVO.class);
bookVehicleVo.setBookType(BookType.USER_RENT.getCode()); bookVehicleVo.setBookType(BookType.USER_RENT.getCode());
bookVehicleVo.setVehicleId(bookVehicleId); bookVehicleVo.setVehicleId(bookVehicleId);
......
package com.xxfc.platform.vehicle.rest; package com.xxfc.platform.vehicle.rest;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.vehicle.biz.VehicleActiveService; import com.xxfc.platform.vehicle.biz.VehicleActiveService;
import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.pojo.*; import com.xxfc.platform.vehicle.pojo.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date; import java.util.Date;
...@@ -19,7 +18,8 @@ public class VehicleActiveController { ...@@ -19,7 +18,8 @@ public class VehicleActiveController {
@Autowired @Autowired
VehicleActiveService vehicleActiveService; VehicleActiveService vehicleActiveService;
@Autowired
VehicleBiz vehicleBiz;
/** /**
* 发车 * 发车
...@@ -34,6 +34,7 @@ public class VehicleActiveController { ...@@ -34,6 +34,7 @@ public class VehicleActiveController {
return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(), return RestResponse.codeAndMessage(ResCode.INVALID_REST_REQ_PARAM.getCode(),
ResCode.INVALID_REST_REQ_PARAM.getDesc()); ResCode.INVALID_REST_REQ_PARAM.getDesc());
} }
vehicleActiveService.departure(departureVo); vehicleActiveService.departure(departureVo);
return RestResponse.suc(); return RestResponse.suc();
} }
...@@ -91,6 +92,12 @@ public class VehicleActiveController { ...@@ -91,6 +92,12 @@ public class VehicleActiveController {
} }
@GetMapping("/getOne")
public ObjectRestResponse selectByRecordId(Long bookRecordId) {
return vehicleActiveService.selectDepartureLogByBookRecordId(bookRecordId);
}
/** /**
* 保养 * 保养
......
...@@ -126,6 +126,11 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use ...@@ -126,6 +126,11 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
return RestResponse.suc(vehicles); return RestResponse.suc(vehicles);
} }
@PostMapping(value = "/test")
public ObjectRestResponse test(@RequestBody VehicleBookRecord vehicleBookRecord) {
return vehicleBiz.addVehicleBookRecord(vehicleBookRecord);
}
@RequestMapping(value = "/page", method = RequestMethod.GET) @RequestMapping(value = "/page", method = RequestMethod.GET)
public RestResponse<PageDataVO<ResultVehicleVo>> getByPage(@RequestParam String vehiclePageQueryVoJson) throws Exception { public RestResponse<PageDataVO<ResultVehicleVo>> getByPage(@RequestParam String vehiclePageQueryVoJson) throws Exception {
VehiclePageQueryVo vehiclePageQueryVo = null; VehiclePageQueryVo vehiclePageQueryVo = null;
...@@ -480,6 +485,12 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use ...@@ -480,6 +485,12 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
return ObjectRestResponse.succ(map); return ObjectRestResponse.succ(map);
} }
@GetMapping(value = "/app/unauth/checkVehicleStatus")
@ApiOperation(value = "检车车辆状态是否是正常状态")
public ObjectRestResponse checkVehicleStatus(String vehicleId) {
return vehicleBiz.checkVehicleStatus(vehicleId);
}
/** /**
* 保存 * 保存
* *
......
...@@ -508,6 +508,15 @@ ...@@ -508,6 +508,15 @@
<if test="status != null and status == -1 "> <if test="status != null and status == -1 ">
and v4.state = 1 and v4.state = 1
</if> </if>
<if test="status != null and status == 3 ">
and v4.id is null and v1.status = 2
</if>
<if test="status != null and status == 5 ">
and v4.id is not null and v1.status = 2 and v4.state = 0
</if>
<if test="status != null and status == 7 ">
and v4.id is not null and v1.status = 2 and v4.state = 1
</if>
<if test="code != null"> <if test="code != null">
and v3.code = #{code} and v3.code = #{code}
</if> </if>
...@@ -517,7 +526,7 @@ ...@@ -517,7 +526,7 @@
</if> </if>
<!--增加时间限制,已审核的未出车小于当前时间的不显示, 已出车的结束时间延后两天小于当前时间的不显示--> <!--增加时间限制,已审核的未出车小于当前时间的不显示, 已出车的结束时间延后两天小于当前时间的不显示-->
<if test="flag == true and status == 2"> <if test="flag == true and status == 2">
and ( v4.id IS NOT NULL OR (v4.id IS NULL AND v1.book_end_date &gt;= now())) and ( (v4.id IS NOT NULL and DATE_ADD(v1.book_end_date,INTERVAL '2' DAY) >= now()) OR (v4.id IS NULL AND v1.book_end_date &gt;= now()))
</if> </if>
and v1.book_user != -2 and v1.book_user != -2
</where> </where>
......
...@@ -29,9 +29,11 @@ ...@@ -29,9 +29,11 @@
</select> </select>
<select id="selectByBookRecordId" parameterType="java.lang.Long" resultType="com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo"> <select id="selectByBookRecordId" parameterType="java.lang.Long" resultType="com.xxfc.platform.vehicle.pojo.VehicleDepartureLogVo">
select vehicle_departure_log.* select v.*, bc.name as departureName,bc1.name as arrivalName
from vehicle_departure_log from vehicle_departure_log v
where vehicle_departure_log.book_record_id = #{id} LEFT JOIN branch_company bc ON v.departure_branch_company_id = bc.id
LEFT JOIN branch_company bc1 ON v.arrival_branch_company_id = bc1.id
where v.book_record_id = #{id}
order by create_time desc order by create_time desc
</select> </select>
<select id="selectAllDepartureLog" resultType="java.lang.Integer" parameterType="Map"> <select id="selectAllDepartureLog" resultType="java.lang.Integer" parameterType="Map">
......
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