Commit 147831dc authored by 周健威's avatar 周健威

Merge branch 'master-modify-cutAmount' into dev

parents 5ff67cbe 5d951dc2
......@@ -1024,8 +1024,10 @@ public class AppPermissionService {
}
Map<Integer, AppUserDetail> userIdAndAppUserDetail = appUserDetailBiz.findUserIdAndUserDetailMapByMemberIds(Arrays.asList(appUserLogin.getId()));
AppUserDetail appUserDetail = userIdAndAppUserDetail.get(appUserLogin.getId());
imiVo.setNickname(appUserDetail.getNickname());
imiVo.setHeadimgurl(appUserDetail.getHeadimgurl());
if (appUserDetail != null) {
imiVo.setNickname(appUserDetail.getNickname());
imiVo.setHeadimgurl(appUserDetail.getHeadimgurl());
}
return imiVo;
}
......
......@@ -17,8 +17,12 @@ import com.xxfc.platform.im.model.Comment;
import com.xxfc.platform.im.model.Msg;
import com.xxfc.platform.im.model.Praise;
import com.xxfc.platform.im.vo.MsgVo;
import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.constant.ResCode;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.feign.ThirdFeign;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -30,8 +34,12 @@ import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
import static com.xxfc.platform.universal.constant.DictionaryKey.IM_TYPE;
@Service
@Slf4j
public class MsgBiz {
......@@ -44,6 +52,9 @@ public class MsgBiz {
@Autowired
ImQuestionBiz imQuestionBiz;
@Autowired
ThirdFeign thirdFeign;
/**
* 获取消息列表
*
......@@ -54,11 +65,11 @@ public class MsgBiz {
//获取所有朋友圈
AppUserDTO appUserDTO = userBiz.getUserInfo();
Integer userId = null;
if(appUserDTO != null) {
if (appUserDTO != null) {
userId = appUserDTO.getImUserid();
}
page = page == null ? 1 : page;
limit = limit == null ? 10 : limit;
page = page == null ? 1 : page;
limit = limit == null ? 10 : limit;
Pageable pageable = PageRequest.of(--page, limit);
Query query = null;
List<Msg> msgList = null;
......@@ -69,7 +80,7 @@ public class MsgBiz {
query.with(new Sort(Sort.Direction.DESC, "time"));
msgList = fetchAndAttach(mongoTemplate.find(query, Msg.class, "s_msg"), userId);
PageInfo<MsgVo> goodPageInfo = new PageInfo<>(replaceMsgResult(msgList));
goodPageInfo.setPageSize(totalSize%limit == 0 ?totalSize/limit : totalSize/limit + 1);
goodPageInfo.setPageSize(totalSize % limit == 0 ? totalSize / limit : totalSize / limit + 1);
return ObjectRestResponse.succ(goodPageInfo);
} else {
List<Integer> ids = new ArrayList<>();
......@@ -82,7 +93,7 @@ public class MsgBiz {
msgList = fetchAndAttach(mongoTemplate.find(query, Msg.class, "s_msg"), userId);
PageInfo<MsgVo> goodPageInfo = new PageInfo<>(replaceMsgResult(msgList));
goodPageInfo.setPageSize(totalSize%limit == 0 ?totalSize/limit : totalSize/limit + 1);
goodPageInfo.setPageSize(totalSize % limit == 0 ? totalSize / limit : totalSize / limit + 1);
return ObjectRestResponse.succ(goodPageInfo);
}
......@@ -91,7 +102,7 @@ public class MsgBiz {
public ObjectRestResponse getHotMsgList(Integer page, Integer limit) {
AppUserDTO appUserDTO = userBiz.getUserInfo();
Integer userId = null;
if(appUserDTO != null) {
if (appUserDTO != null) {
userId = appUserDTO.getImUserid();
}
page = page == null ? 1 : page;
......@@ -100,78 +111,79 @@ public class MsgBiz {
List<Integer> ids = new ArrayList<>();
ids.add(2);
ids.add(4);
Query query = new Query(Criteria.where("body.type").in(ids).and("count.praise").gt(1000));
Query query = new Query(Criteria.where("body.type").in(ids).and("count.praise").gt(getNumber()));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "count.praise"));
List<Msg> msgList = fetchAndAttach(mongoTemplate.find(query, Msg.class, "s_msg"), userId);
PageInfo<MsgVo> goodPageInfo = new PageInfo<>(replaceMsgResult(msgList));
goodPageInfo.setPageSize(totalSize%limit == 0 ?totalSize/limit : totalSize/limit + 1);
goodPageInfo.setPageSize(totalSize % limit == 0 ? totalSize / limit : totalSize / limit + 1);
return ObjectRestResponse.succ(goodPageInfo);
}
public ObjectRestResponse get(String id){
public ObjectRestResponse get(String id) {
//获取所有朋友圈
AppUserDTO appUserDTO = userBiz.getUserInfo();
Integer userId = null;
if(appUserDTO != null) {
if (appUserDTO != null) {
userId = appUserDTO.getImUserid();
}
if(id == null) {
if (id == null) {
return ObjectRestResponse.paramIsEmpty();
}
Query query = new Query(Criteria.where("id").is(new ObjectId(id)));
List<Msg> msgList = fetchAndAttach(mongoTemplate.find(query, Msg.class, "s_msg"), userId);
List<MsgVo> msgVoList = replaceMsgResult(msgList);
if(msgVoList.size() > 0) {
if (msgVoList.size() > 0) {
return ObjectRestResponse.succ(msgVoList.get(0));
}
return ObjectRestResponse.succ();
}
}
public ObjectRestResponse getMsgListByUserId(Integer page, Integer limit, Integer type) {
//获取所有朋友圈
page = page == null ? 1 : page;
limit = limit == null ? 10 : limit;
AppUserDTO appUserDTO = userBiz.getUserInfo();
Integer userId = null;
if(appUserDTO != null) {
userId = appUserDTO.getImUserid();
} else {
return ObjectRestResponse.createFailedResult(ResultCode.RSTOKEN_EXPIRED_CODE, "token失效");
}
Pageable pageable = PageRequest.of(--page, limit);
List<Integer> ids = new ArrayList<>();
if(type != null) {
ids.add(type);
}
if(type != null && type == 5) {
QuestionParamDto questionParamDto = new QuestionParamDto();
questionParamDto.setUserId(Long.parseLong(userId + ""));
return imQuestionBiz.getList(questionParamDto);
}
Query query = new Query(Criteria.where("body.type").in(ids));
query.addCriteria(Criteria.where("userId").is(userId));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "time"));
List<Msg> msgList = fetchAndAttach(mongoTemplate.find(query, Msg.class, "s_msg"), userId);
List<MsgVo> msgVoList = replaceMsgResult(msgList);
PageInfo<MsgVo> goodPageInfo = new PageInfo<>(msgVoList);
goodPageInfo.setPageSize(totalSize%limit == 0 ?totalSize/limit : totalSize/limit + 1);
return ObjectRestResponse.succ(PageDataVO.pageInfo(goodPageInfo));
page = page == null ? 1 : page;
limit = limit == null ? 10 : limit;
AppUserDTO appUserDTO = userBiz.getUserInfo();
Integer userId = null;
if (appUserDTO != null) {
userId = appUserDTO.getImUserid();
} else {
return ObjectRestResponse.createFailedResult(ResultCode.RSTOKEN_EXPIRED_CODE, "token失效");
}
Pageable pageable = PageRequest.of(--page, limit);
List<Integer> ids = new ArrayList<>();
if (type != null) {
ids.add(type);
}
if (type != null && type == 5) {
QuestionParamDto questionParamDto = new QuestionParamDto();
questionParamDto.setUserId(Long.parseLong(userId + ""));
return imQuestionBiz.getList(questionParamDto);
}
Query query = new Query(Criteria.where("body.type").in(ids));
query.addCriteria(Criteria.where("userId").is(userId));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "time"));
List<Msg> msgList = fetchAndAttach(mongoTemplate.find(query, Msg.class, "s_msg"), userId);
List<MsgVo> msgVoList = replaceMsgResult(msgList);
PageInfo<MsgVo> goodPageInfo = new PageInfo<>(msgVoList);
goodPageInfo.setPageSize(totalSize % limit == 0 ? totalSize / limit : totalSize / limit + 1);
return ObjectRestResponse.succ(PageDataVO.pageInfo(goodPageInfo));
}
/**
* 删除消息
*
* @param ids id字符串,用逗号隔开
* @return
*/
public ObjectRestResponse deleteByList(String ids) {
Integer userId = 0;
AppUserDTO appUserDTO = userBiz.getUserInfo();
if(appUserDTO == null) {
if (appUserDTO == null) {
return ObjectRestResponse.createFailedResult(ResultCode.RSTOKEN_EXPIRED_CODE, ResultCode.getMsg(ResultCode.RSTOKEN_EXPIRED_CODE));
}
if (StringUtils.isBlank(ids)) {
......@@ -184,7 +196,7 @@ public class MsgBiz {
Query query = new Query(Criteria.where("id").in(set));
query.addCriteria(Criteria.where("userId").is(userId));
List<Msg> msgList = mongoTemplate.find(query, Msg.class, "s_msg");
if(msgList.size() != set.size()) { //查询到的消息条数不等于查询的Id数
if (msgList.size() != set.size()) { //查询到的消息条数不等于查询的Id数
return ObjectRestResponse.createFailedResult(ResultCode.IM_DELETE_FAIL_CODE, ResultCode.getMsg(ResultCode.IM_DELETE_FAIL_CODE));
}
DeleteResult deleteResult = mongoTemplate.remove(query, Msg.class, "s_msg");
......@@ -211,7 +223,7 @@ public class MsgBiz {
//添加点赞
List<Praise> praise = mongoTemplate.find(query, Praise.class, "s_praise");
msg.setPraises(replacePraiseResult(praise));
if(userId != null) {
if (userId != null) {
msg.setIsPraise(this.exists(userId, msg.getId()) ? 1 : 0);
msg.setIsCollect(this.existsCollect(userId, msg.getId()) ? 1 : 0);
} else {
......@@ -237,7 +249,7 @@ public class MsgBiz {
public boolean exists(int userId, ObjectId msgId) {
Query query = new Query(Criteria.where("msgId").is(msgId).and("userId").is(userId));
List<Praise> praise = mongoTemplate.find(query, Praise.class, "s_praise");
return praise.size() > 0 ? true :false;
return praise.size() > 0 ? true : false;
}
/**
......@@ -250,23 +262,25 @@ public class MsgBiz {
public boolean existsCollect(int userId, ObjectId msgId) {
Query query = new Query(Criteria.where("msgId").is(msgId).and("userId").is(userId));
List<Comment> comments = mongoTemplate.find(query, Comment.class, "s_comment");
return comments.size() > 0 ? true :false;
return comments.size() > 0 ? true : false;
}
public List<MsgVo> replaceMsgResult(List<Msg> list) {
List<MsgVo> msgVoList = new ArrayList<>();
for(Msg msg : list) {
for (Msg msg : list) {
MsgVo msgVo = new MsgVo();
BeanUtil.copyProperties(msg, msgVo, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
//添加用户昵称和头像
ImiVo imiVo = userBiz.getUserInfo(msg.getUserId());
if(imiVo != null) {
msgVo.setNickname(imiVo.getNickname());
msgVo.setPicUrl(imiVo.getHeadimgurl());
if(msg != null) {
BeanUtil.copyProperties(msg, msgVo, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
//添加用户昵称和头像
ImiVo imiVo = userBiz.getUserInfo(msg.getUserId());
if (imiVo != null) {
msgVo.setNickname(imiVo.getNickname());
msgVo.setPicUrl(imiVo.getHeadimgurl());
}
//String address = AddressUtils.getMapaddress(msg.getLatitude().toString(), msg.getLongitude().toString());
msgVo.setAddress(msg.getLocation());
msgVo.setMsgId(msg.getId().toString());
}
//String address = AddressUtils.getMapaddress(msg.getLatitude().toString(), msg.getLongitude().toString());
msgVo.setAddress(msg.getLocation());
msgVo.setMsgId(msg.getId().toString());
msgVoList.add(msgVo);
}
return msgVoList;
......@@ -274,34 +288,49 @@ public class MsgBiz {
public List<PraiseVo> replacePraiseResult(List<Praise> list) {
List<PraiseVo> praiseVoArrayList = new ArrayList<>();
for(Praise praise : list) {
for (Praise praise : list) {
PraiseVo praiseVo = new PraiseVo();
BeanUtil.copyProperties(praise, praiseVo, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
//添加用户昵称和头像
ImiVo imiVo = userBiz.getUserInfo(praise.getUserId());
if(imiVo != null) {
praiseVo.setNickname(imiVo.getNickname());
praiseVo.setPicUrl(imiVo.getHeadimgurl());
if (praise != null) {
BeanUtil.copyProperties(praise, praiseVo, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
//添加用户昵称和头像
ImiVo imiVo = userBiz.getUserInfo(praise.getUserId());
if (imiVo != null) {
praiseVo.setNickname(imiVo.getNickname());
praiseVo.setPicUrl(imiVo.getHeadimgurl());
}
}
praiseVoArrayList.add(praiseVo);
}
return praiseVoArrayList;
}
public List<CommentVo> replaceCommentResult(List<Comment> list) {
public List<CommentVo> replaceCommentResult(List<Comment> list) {
List<CommentVo> commentVoList = new ArrayList<>();
for(Comment comment : list) {
for (Comment comment : list) {
CommentVo commentVo = new CommentVo();
BeanUtil.copyProperties(comment, commentVo, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
//添加用户昵称和头像
ImiVo imiVo = userBiz.getUserInfo(comment.getUserId());
if(imiVo != null) {
commentVo.setNickname(imiVo.getNickname());
commentVo.setPicUrl(imiVo.getHeadimgurl());
if (comment != null) {
BeanUtil.copyProperties(comment, commentVo, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
//添加用户昵称和头像
ImiVo imiVo = userBiz.getUserInfo(comment.getUserId());
if (imiVo != null) {
commentVo.setNickname(imiVo.getNickname());
commentVo.setPicUrl(imiVo.getHeadimgurl());
}
}
commentVoList.add(commentVo);
}
return commentVoList;
}
public Integer getNumber() {
Integer number = 0;
Dictionary dictionary = thirdFeign.findDictionaryByTypeAndCode(IM_TYPE, DictionaryKey.MSG_LIMIT_NUMBER);
if (dictionary != null && StringUtils.isNotBlank(dictionary.getDetail())) {
log.info("查询IM限制数为字典表的结果为: dictionary = {}", dictionary.toString());
number = Integer.parseInt(dictionary.getDetail());
}
log.info("IM消息数限制为: number = {}", number);
return number;
}
}
......@@ -371,7 +371,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
//剩余押金 = 押金 - 违章保证金 - 定损金额
oad.setDepositAmount(oad.getDepositAmount().subtract(illegalReserve).subtract(csv.getDamagesAmount()));
handleCrosstownDetail(crosstown, oad);
handleCrosstownDetail(crosstown, oad, csv);
//退款
BigDecimal refundAmont = oad.getDepositAmount().add(oad.getOrderAmount());
......@@ -437,15 +437,15 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
return refundDesc;
}
private void handleCrosstownDetail(OrderVehicleCrosstown crosstown, OrderAccountDetail oad) {
private void handleCrosstownDetail(OrderVehicleCrosstown crosstown, OrderAccountDetail oad, CancelStartedVO csv) {
try{
if(null != crosstown.getViolateDetail()) {
DedDetailDTO vio = JSONUtil.toBean(crosstown.getViolateDetail(), DedDetailDTO.class);
if(OrderViolateEnum.BEFORE.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_ADVANCE, oad, vio);
handleViolateDetail(DeductionTypeEnum.VIOLATE_ADVANCE, oad, vio, csv);
}else if(OrderViolateEnum.AFTER.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_DELAY, oad, vio);
handleViolateDetail(DeductionTypeEnum.VIOLATE_DELAY, oad, vio, csv);
}
}
}catch (Exception e) {
......@@ -453,7 +453,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}
}
private void handleViolateDetail(DeductionTypeEnum dte, OrderAccountDetail oad, DedDetailDTO vio) {
private void handleViolateDetail(DeductionTypeEnum dte, OrderAccountDetail oad, DedDetailDTO vio, CancelStartedVO csv) {
for(OrderAccountDeduction deduction : oad.getDeductions()) {
if(dte.getCode().equals(deduction.getType())) {
deduction.setName(vio.getDeductions());
......@@ -461,6 +461,10 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
//修改归还押金金额
oad.setDepositAmount(oad.getDepositAmount().subtract(diff));
deduction.setAmount(vio.getCost());
//设置订单明细参数
csv.setViolateAmount(deduction.getAmount());
csv.setViolateDesc(deduction.getName());
}
}
}
......
......@@ -193,7 +193,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
}
if (vehicle.getMileageLastUpdate() != null) {
//判断车辆公里数
if (orderVehicleCrosstownDto.getMileage() == null || orderVehicleCrosstownDto.getMileage() <= vehicle.getMileageLastUpdate()) {
if (orderVehicleCrosstownDto.getMileage() == null || orderVehicleCrosstownDto.getMileage() < vehicle.getMileageLastUpdate()) {
return ObjectRestResponse.createFailedResult(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode(), ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc());
}
}
......
......@@ -144,15 +144,6 @@ public class OrderCancelBiz {
setOrderId(baseOrder.getId());
}});
// List<OrderItem> otherOrderItems = orderItemBiz.selectByExample(new Example.Builder(OrderItem.class)
// .where(WeekendSqls.<OrderItem>custom().andNotEqualTo(OrderItem::getType, ItemTypeEnum.VEHICLE_MODEL.getCode())).build()
// );
//原退还押金
Integer freeDays = (null == orderItem.getCutNum())?0 :orderItem.getCutNum();
// BigDecimal freeDayAmount = BigDecimal.ZERO;
//如果超过出发时间,不能取消订单
//根据时间处理goodsAmount
//获取出发时间 到现在 距离时间
......@@ -205,9 +196,6 @@ public class OrderCancelBiz {
}else {
// //没到出车时间
// //判断是否使用免费天数,并且进行扣款
// if(freeDays > 0) {
// freeDayAmount = orderItem.getUnitPrice().multiply(new BigDecimal(orvd.getFreeDays()+ ""));
// }
//违约金封顶 租车身份价 * 2天
BigDecimal topAmount = orderItem.getUnitPrice().multiply(new BigDecimal(2+ ""));
......
......@@ -217,7 +217,6 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
BigDecimal vehicleAmount = BigDecimal.ZERO;
BigDecimal driverAmount = BigDecimal.ZERO;
BigDecimal damageSafeAmount = BigDecimal.ZERO;
// BigDecimal modelAmount = BigDecimal.ZERO;
BigDecimal couponAmount = BigDecimal.ZERO;
String couponDesc = "";
Integer vehicleDayNum = 0;
......
......@@ -7,6 +7,15 @@ public class DictionaryKey {
*/
public static final String APP_ORDER ="APP_ORDER";
/**
* IM类型
*/
public static final String IM_TYPE ="IM_TYPE";
/**
* IM限制条数
*/
public static final String MSG_LIMIT_NUMBER ="MSG_LIMIT_NUMBER";
/**
* 支付
*/
......
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