Commit e193425d authored by hezhen's avatar hezhen

Merge branch 'dev' into hz_dev

parents 2ce801ac 52c211ae
package com.xxfc.platform.im.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/9/5 10:35
*/
@Data
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class CustomerServiceDTO {
private static final long serialVersionUID = 1L;
private String id;
/**
* 客服名称
*/
private String name;
/**
* 帐号
*/
private String account;
/**
* 密码
*/
private String password;
/**
* 客服头像
*/
private String icon;
/**
* App id
*/
private Integer appUserId;
/**
* im id
*/
private String imUserId;
/**
* 区域id
*/
private Integer areaId;
/**
* 区域名称
*/
private String areaName;
/**
* 问候语句
*/
private String greeting;
/**
* 客服类型
*/
private Integer type;
/**
* 客服电话
*/
private String telphone;
}
package com.xxfc.platform.im.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.mongodb.morphia.annotations.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
/**
* @author libin
* @version 1.0
* @description 客服
* @data 2019/9/5 9:27
*/
@Data
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
@Document(collection = "customer_service")
public class CustomerService {
private static final long serialVersionUID = 1L;
@Id
private String id;
/**
* 客服名称
*/
private String name;
/**
* 客服头像
*/
private String icon;
/**
* App id
*/
@Field("app_user_id")
private Integer appUserId;
/**
* im id
*/
@Field("im_user_id")
private Integer imUserId;
/**
* 区域id
*/
@Field("area_id")
private Integer areaId;
/**
* 区域名称
*/
@Field("area_name")
private String areaName;
/**
* 问候语句
*/
private String greeting;
/**
* 客服类型
*/
private Integer type;
/**
* 客服电话
*/
private String telphone;
/**
* 是事删除 true:删除状态 1:正常
*/
@Field("is_del")
private Boolean isDel;
@Field("create_time")
private Long createTime;
@Field("update_time")
private Long updateTime;
}
package com.xxfc.platform.im.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/9/5 10:37
*/
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
public class CustomerServiceVO implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
/**
* 客服名称
*/
private String name;
/**
* 密码
*/
private String password;
/**
* 客服头像
*/
private String icon;
/**
* App id
*/
private Integer appUserId;
/**
* im id
*/
private Integer imUserId;
/**
* 区域id
*/
private Integer areaId;
/**
* 区域名称
*/
private String areaName;
/**
* 问候语句
*/
private String greeting;
/**
* 客服类型
*/
private Integer type;
/**
* 客服电话
*/
private String telphone;
private Long createTime;
private Long updateTime;
}
package com.xxfc.platform.im.biz;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.constant.UserConstant;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.mongodb.client.result.UpdateResult;
import com.xxfc.platform.im.dto.CustomerServiceDTO;
import com.xxfc.platform.im.model.CustomerService;
import com.xxfc.platform.im.model.User;
import com.xxfc.platform.im.repos.CustomerServiceRepository;
import com.xxfc.platform.im.vo.CustomerServiceVO;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
import static org.springframework.data.mongodb.core.query.Query.query;
import static org.springframework.data.mongodb.core.query.Update.update;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/9/5 9:49
*/
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CustomerServiceBiz {
private final static String INIT_PASSWORD="12345678";
private final static String NICK_PRE_NAME="XXKF";
private final CustomerServiceRepository customerServiceRepository;
private final MongoTemplate mongoTemplate;
private final UserBiz userBiz;
public CustomerServiceVO findById(String id){
CustomerServiceVO customerServiceVO = new CustomerServiceVO();
customerServiceRepository.findById(id).ifPresent(customerService -> {
BeanUtils.copyProperties(customerService,customerServiceVO);
});
Map<Integer, User> imMap = userBiz.findAllByImUserIds(Arrays.asList(customerServiceVO.getImUserId()));
User user = imMap.get(customerServiceVO.getImUserId());
customerServiceVO.setPassword(user.getPassword());
return customerServiceVO;
}
/**
* 添加客服
* @param customerServiceDTO
*/
public void addCustomerService(CustomerServiceDTO customerServiceDTO){
CustomerService customerService = new CustomerService();
BeanUtils.copyProperties(customerServiceDTO,customerService);
customerService.setCreateTime(Instant.now().toEpochMilli());
customerService.setName(String.format("%s%s",NICK_PRE_NAME,customerServiceDTO.getTelphone()));
customerService.setIsDel(false);
Map<String,Object> imMap = new HashMap<>(2);
imMap.put("telephone",customerServiceDTO.getTelphone());
imMap.put("password",INIT_PASSWORD);
imMap.put("nickname",customerService.getName());
BaseResponse imResponse = userBiz.register(imMap);
String imResult = imResponse.getMessage();
JSONObject jsonObject = JSON.parseObject(imResult);
Map<String,Object> data = (Map<String, Object>) jsonObject.get("data");
Object userId = data.get("userId");
if (Objects.isNull(userId)){
throw new BaseException("注册失败");
}
customerService.setImUserId((Integer)userId);
customerServiceRepository.save(customerService);
}
/**
* 1: mongoTemplate.find(Query.query(Criteria.where("isDel").is(false)), CustomerService.class);
*
* 2. customerServiceRepository.findByIsDelEquals(false);
* @return
*/
public List<CustomerServiceVO> findAll() {
List<CustomerServiceVO> customerServiceVOS = new ArrayList<>();
CustomerService customer_service = new CustomerService();
Example<CustomerService> customerServiceExample = Example.of(customer_service, ExampleMatcher.matchingAll());
List<CustomerService> customerServices = customerServiceRepository.findAll(customerServiceExample);
CustomerServiceVO customerServiceVO;
if (CollectionUtils.isNotEmpty(customerServices)){
List<Integer> imUserIds = customerServices.stream().map(CustomerService::getImUserId).collect(Collectors.toList());
Map<Integer, User> imMap = userBiz.findAllByImUserIds(imUserIds);
for (CustomerService customerService : customerServices) {
customerServiceVO = new CustomerServiceVO();
BeanUtils.copyProperties(customerService,customerServiceVO);
User user = imMap.get(customerService.getImUserId());
if (Objects.nonNull(user)){
customerServiceVO.setPassword(user.getPassword());
}
customerServiceVOS.add(customerServiceVO);
}
}
return customerServiceVOS;
}
/**
* 删除客服
* @param id
* @param imUserId
*/
public void updateCustomerServiceIsDelToTrue(String id,Integer imUserId){
Query query = query(Criteria.where("_id").is(id));
Update update = update("is_del", true).set("update_time",Instant.now().toEpochMilli());
mongoTemplate.updateFirst(query, update, Map.class, "customer_service");
userBiz.deleteById(imUserId);
}
}
...@@ -8,8 +8,10 @@ import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; ...@@ -8,8 +8,10 @@ import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.vo.ImiVo; import com.github.wxiaoqi.security.admin.vo.ImiVo;
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.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.im.dto.CommentVo; import com.xxfc.platform.im.dto.CommentVo;
import com.xxfc.platform.im.dto.PraiseVo; import com.xxfc.platform.im.dto.PraiseVo;
import com.xxfc.platform.im.dto.QuestionParamDto;
import com.xxfc.platform.im.model.Comment; import com.xxfc.platform.im.model.Comment;
import com.xxfc.platform.im.model.Msg; import com.xxfc.platform.im.model.Msg;
import com.xxfc.platform.im.model.Praise; import com.xxfc.platform.im.model.Praise;
...@@ -38,6 +40,9 @@ public class MsgBiz { ...@@ -38,6 +40,9 @@ public class MsgBiz {
@Autowired @Autowired
UserBiz userBiz; UserBiz userBiz;
@Autowired
ImQuestionBiz imQuestionBiz;
/** /**
* 获取消息列表 * 获取消息列表
* *
...@@ -123,7 +128,7 @@ public class MsgBiz { ...@@ -123,7 +128,7 @@ public class MsgBiz {
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
public ObjectRestResponse getMsgListByUserId(Integer page, Integer limit) { public ObjectRestResponse getMsgListByUserId(Integer page, Integer limit, Integer type) {
//获取所有朋友圈 //获取所有朋友圈
page = page == null ? 1 : page; page = page == null ? 1 : page;
limit = limit == null ? 10 : limit; limit = limit == null ? 10 : limit;
...@@ -136,8 +141,14 @@ public class MsgBiz { ...@@ -136,8 +141,14 @@ public class MsgBiz {
} }
Pageable pageable = PageRequest.of(--page, limit); Pageable pageable = PageRequest.of(--page, limit);
List<Integer> ids = new ArrayList<>(); List<Integer> ids = new ArrayList<>();
ids.add(2); if(type != null) {
ids.add(4); 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 query = new Query(Criteria.where("body.type").in(ids));
query.addCriteria(Criteria.where("userId").is(userId)); query.addCriteria(Criteria.where("userId").is(userId));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size(); int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
...@@ -147,7 +158,7 @@ public class MsgBiz { ...@@ -147,7 +158,7 @@ public class MsgBiz {
List<MsgVo> msgVoList = replaceMsgResult(msgList); List<MsgVo> msgVoList = replaceMsgResult(msgList);
PageInfo<MsgVo> goodPageInfo = new PageInfo<>(msgVoList); PageInfo<MsgVo> goodPageInfo = new PageInfo<>(msgVoList);
goodPageInfo.setPageSize(totalSize%limit == 0 ?totalSize/limit : totalSize/limit + 1); goodPageInfo.setPageSize(totalSize%limit == 0 ?totalSize/limit : totalSize/limit + 1);
return ObjectRestResponse.succ(goodPageInfo); return ObjectRestResponse.succ(PageDataVO.pageInfo(goodPageInfo));
} }
...@@ -246,7 +257,7 @@ public class MsgBiz { ...@@ -246,7 +257,7 @@ public class MsgBiz {
return praiseVoArrayList; return praiseVoArrayList;
} }
public List<CommentVo> replaceCommentResult(List<Comment> list) { public List<CommentVo> replaceCommentResult(List<Comment> list) {
List<CommentVo> commentVoList = new ArrayList<>(); List<CommentVo> commentVoList = new ArrayList<>();
for(Comment comment : list) { for(Comment comment : list) {
CommentVo commentVo = new CommentVo(); CommentVo commentVo = new CommentVo();
......
...@@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSONObject;
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;
import com.github.wxiaoqi.security.admin.vo.ImiVo; import com.github.wxiaoqi.security.admin.vo.ImiVo;
import com.github.wxiaoqi.security.common.constant.UserConstant;
import com.github.wxiaoqi.security.common.msg.BaseResponse; import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.mongodb.client.result.UpdateResult; import com.mongodb.client.result.UpdateResult;
import com.xxfc.platform.im.model.User; import com.xxfc.platform.im.model.User;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -17,6 +19,7 @@ import org.springframework.data.mongodb.core.MongoTemplate; ...@@ -17,6 +19,7 @@ import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update; import org.springframework.data.mongodb.core.query.Update;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
...@@ -27,7 +30,10 @@ import java.net.HttpURLConnection; ...@@ -27,7 +30,10 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Component @Component
@Slf4j @Slf4j
...@@ -229,4 +235,37 @@ public class UserBiz { ...@@ -229,4 +235,37 @@ public class UserBiz {
return imiVo; return imiVo;
} }
/**
*根据 id 批量查询
* @param imUserIds
* @return
*/
public Map<Integer,User> findAllByImUserIds(List<Integer> imUserIds) {
Map<Integer,User> imUserMap = new HashMap<>(imUserIds.size());
List<User> users = mongoTemplate.find(Query.query(Criteria.where("id").in(imUserIds)), User.class);
if (CollectionUtils.isEmpty(users)){
return imUserMap;
}
imUserMap = users.stream().collect(Collectors.toMap(User::getId, Function.identity()));
return imUserMap;
}
/**
* 更新Im 密码
* @param telphone
* @param password
*/
public void updatePasswordByPhone(String telphone,String password){
Query query = Query.query(Criteria.where("phone").is(telphone));
Update update = Update.update("password", password);
mongoTemplate.updateFirst(query,update,Map.class,"user");
}
/**
* 删除 im
* @param imUserId
*/
public void deleteById(Integer imUserId) {
mongoTemplate.remove(Query.query(Criteria.where("id").is(imUserId)),User.class);
}
} }
package com.xxfc.platform.im.repos;
import com.xxfc.platform.im.model.CustomerService;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/9/5 10:55
*/
@Repository
public interface CustomerServiceRepository extends MongoRepository<CustomerService,String> {
/**
* 查询客服
* * @param isDel 删除状态
* @return
*/
List<CustomerService> findByIsDelEquals(Boolean isDel);
List<CustomerService> findByIsDel(Boolean isDel);
// @Query(value = "{'is_del':?0}",fields ="{'telphone':1}",sort = "{'create_time':-1}")
@Query(value = "{'is_del':?#{[0]}}",fields ="{'name':1}",sort = "{'create_time':-1}")
List<CustomerService> findByIsDelState(Boolean isDel);
}
package com.xxfc.platform.im.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.im.biz.CustomerServiceBiz;
import com.xxfc.platform.im.vo.CustomerServiceVO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/9/5 10:31
*/
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping("/app/unauth/customer_service")
public class CustomerServiceController {
private final CustomerServiceBiz customerServiceBiz;
@GetMapping("/list")
public ObjectRestResponse<List<CustomerServiceVO>> findAll(){
List<CustomerServiceVO> customerServiceVOS = customerServiceBiz.findAll();
return ObjectRestResponse.succ(customerServiceVOS);
}
@GetMapping("/{id}")
public ObjectRestResponse<CustomerServiceVO> findById(@PathVariable(value = "id") String id){
CustomerServiceVO customerServiceVO = customerServiceBiz.findById(id);
return ObjectRestResponse.succ(customerServiceVO);
}
}
...@@ -32,7 +32,7 @@ public class MsgController { ...@@ -32,7 +32,7 @@ public class MsgController {
} }
@GetMapping(value = "/getByUserId") @GetMapping(value = "/getByUserId")
public ObjectRestResponse getByUserId(Integer page, Integer limit) { public ObjectRestResponse getByUserId(Integer page, Integer limit, Integer type) {
return msgBiz.getMsgListByUserId(page, limit); return msgBiz.getMsgListByUserId(page, limit, type);
} }
} }
package com.xxfc.platform.im.rest.admin;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.im.biz.CustomerServiceBiz;
import com.xxfc.platform.im.biz.UserBiz;
import com.xxfc.platform.im.dto.CustomerServiceDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/9/5 10:32
*/
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping("/admin/customer_service")
public class CustomerServiceAdminController {
private final CustomerServiceBiz customerServiceBiz;
private final UserBiz userBiz;
@PostMapping("/add")
public ObjectRestResponse<Void> addCustomerService(@RequestBody CustomerServiceDTO customerServiceDTO){
customerServiceBiz.addCustomerService(customerServiceDTO);
return ObjectRestResponse.succ();
}
@PutMapping("/update_password/{telphone}/{password}")
public ObjectRestResponse<Void> updateCustomerService(@PathVariable(value = "telphone") String telphone,
@PathVariable(value = "password") String password){
userBiz.updatePasswordByPhone(telphone,password);
return ObjectRestResponse.succ();
}
@DeleteMapping("/delete/{id}/{imUserId}")
public ObjectRestResponse<Void> deleteCustomerService(@PathVariable(value = "id") String id,
@PathVariable(value = "imUserId") Integer imUserId){
customerServiceBiz.updateCustomerServiceIsDelToTrue(id,imUserId);
return ObjectRestResponse.succ();
}
}
...@@ -8,7 +8,7 @@ import java.util.List; ...@@ -8,7 +8,7 @@ import java.util.List;
@Data @Data
public class DedDetailDTO { public class DedDetailDTO {
/** /**
* : 扣除项 * : 扣除项名称
*/ */
String deductions; String deductions;
...@@ -34,4 +34,6 @@ public class DedDetailDTO { ...@@ -34,4 +34,6 @@ public class DedDetailDTO {
//type对应的中文 //type对应的中文
String statusName; String statusName;
} }
...@@ -145,7 +145,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> { ...@@ -145,7 +145,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
* @param timeLag 与开始时间的时间差 * @param timeLag 与开始时间的时间差
* @param dicParentKey * @param dicParentKey
*/ */
public void rentRefundProcess(BaseOrder baseOrder, Long timeLag, String dicParentKey) { public BigDecimal rentRefundProcess(BaseOrder baseOrder, Long timeLag, String dicParentKey) {
//计算退款金额 //计算退款金额
//商品价格 - 优惠券减免的价格 //商品价格 - 优惠券减免的价格
BigDecimal originalRefundAmount = BigDecimal.ZERO.add(baseOrder.getGoodsAmount().subtract(baseOrder.getCouponAmount())); BigDecimal originalRefundAmount = BigDecimal.ZERO.add(baseOrder.getGoodsAmount().subtract(baseOrder.getCouponAmount()));
...@@ -158,6 +158,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> { ...@@ -158,6 +158,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
//退款子流程: 订单基础,退款描述,退款金额 //退款子流程: 订单基础,退款描述,退款金额
refundSubProcess(baseOrder, refundDescBuilder.toString(), originalRefundAmount, refundAmount, RefundTypeEnum.ORDER_FUND.getCode(), RefundStatusEnum.ALL.getCode()); refundSubProcess(baseOrder, refundDescBuilder.toString(), originalRefundAmount, refundAmount, RefundTypeEnum.ORDER_FUND.getCode(), RefundStatusEnum.ALL.getCode());
return refundAmount;
} }
/** /**
...@@ -168,7 +169,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> { ...@@ -168,7 +169,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
* @param dicParentKey * @param dicParentKey
* @param originalDeductAmount * @param originalDeductAmount
*/ */
public void rentRefundDepositProcess(BaseOrder baseOrder, BigDecimal depositAmount, Long timeLag, String dicParentKey, BigDecimal originalDeductAmount) { public BigDecimal rentRefundDepositProcess(BaseOrder baseOrder, BigDecimal depositAmount, Long timeLag, String dicParentKey, BigDecimal originalDeductAmount) {
// 1、押金 + 租金(规则扣除) // 1、押金 + 租金(规则扣除)
BigDecimal originalRefundAmount = BigDecimal.ZERO.add(depositAmount); BigDecimal originalRefundAmount = BigDecimal.ZERO.add(depositAmount);
BigDecimal refundAmount = BigDecimal.ZERO.add(depositAmount); BigDecimal refundAmount = BigDecimal.ZERO.add(depositAmount);
...@@ -178,12 +179,13 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> { ...@@ -178,12 +179,13 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
BigDecimal residueAmount = calculateRefund(originalDeductAmount, timeLag, dicParentKey, refundDescBuilder); BigDecimal residueAmount = calculateRefund(originalDeductAmount, timeLag, dicParentKey, refundDescBuilder);
residueAmount = residueAmount.setScale(2, RoundingMode.HALF_UP); residueAmount = residueAmount.setScale(2, RoundingMode.HALF_UP);
//退款金额 :押金 - (原扣除款 - 剩余款) //退款金额 :押金 - (原扣除款 - 剩余款) 即: 押金 - (免费天数对应的钱 - 剩余款)
refundAmount = originalRefundAmount.subtract(originalDeductAmount.subtract(residueAmount)); refundAmount = originalRefundAmount.subtract(originalDeductAmount.subtract(residueAmount));
} }
//触发押金退款 //触发押金退款
refundSubProcess(baseOrder, refundDescBuilder.toString(), originalRefundAmount, refundAmount, RefundTypeEnum.DEPOSIT.getCode(), RefundStatusEnum.ALL.getCode()); refundSubProcess(baseOrder, refundDescBuilder.toString(), originalRefundAmount, refundAmount, RefundTypeEnum.DEPOSIT.getCode(), RefundStatusEnum.ALL.getCode());
return refundAmount;
} }
public BigDecimal calculateRefund(BigDecimal goodsAmount, Long timeLag, String dicParentKey, StringBuilder refundDescBuilder) { public BigDecimal calculateRefund(BigDecimal goodsAmount, Long timeLag, String dicParentKey, StringBuilder refundDescBuilder) {
......
...@@ -134,11 +134,12 @@ public class OrderCancelBiz { ...@@ -134,11 +134,12 @@ public class OrderCancelBiz {
// } // }
//退款流程 //退款流程
//退押金
orderRefundBiz.rentRefundDepositProcess(hasUpdateOrder, orvd.getDeposit(), timeLag, APP_ORDER+ "_"+ RENT_REFUND, freeDayAmount);
//退订单款 //退订单款
orderRefundBiz.rentRefundProcess(hasUpdateOrder, timeLag, APP_ORDER+ "_"+ RENT_REFUND); orderRefundBiz.rentRefundProcess(hasUpdateOrder, timeLag, APP_ORDER+ "_"+ RENT_REFUND);
//退押金
orderRefundBiz.rentRefundDepositProcess(hasUpdateOrder, orvd.getDeposit(), timeLag, APP_ORDER+ "_"+ RENT_REFUND, freeDayAmount);
//已付款的取消订单发送消息 //已付款的取消订单发送消息
try { try {
AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData(); AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData();
......
...@@ -131,6 +131,10 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -131,6 +131,10 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
if (article.getType() == null) { if (article.getType() == null) {
article.setType(0); article.setType(0);
} }
if (article.getStatus()==1){
article.setAddTime(new Date());
}
article.setCreTime(new Date()); article.setCreTime(new Date());
mapper.insertSelective(article); mapper.insertSelective(article);
......
...@@ -64,6 +64,7 @@ public class VehicleModelController extends CommonBaseController { ...@@ -64,6 +64,7 @@ public class VehicleModelController extends CommonBaseController {
@GetMapping(value = "/findVehicleModelPage") @GetMapping(value = "/findVehicleModelPage")
@IgnoreUserToken @IgnoreUserToken
public ObjectRestResponse<PageDataVO<VehicleModelVo>> findVehicleModelPageUnauthfind(VehicleModelQueryCondition vmqc) { public ObjectRestResponse<PageDataVO<VehicleModelVo>> findVehicleModelPageUnauthfind(VehicleModelQueryCondition vmqc) {
vmqc.setNotInIds("67");
ObjectRestResponse<PageDataVO<VehicleModelVo>> objectRestResponse = vehicleFeign.findVehicleModelPageUnauthfind(vmqc); ObjectRestResponse<PageDataVO<VehicleModelVo>> objectRestResponse = vehicleFeign.findVehicleModelPageUnauthfind(vmqc);
PageDataVO<VehicleModelVo> pageDataVOs = objectRestResponse.getData(); PageDataVO<VehicleModelVo> pageDataVOs = objectRestResponse.getData();
pageDataVOs.getData().forEach( v -> { pageDataVOs.getData().forEach( v -> {
......
...@@ -30,6 +30,8 @@ public class VehicleModelQueryCondition { ...@@ -30,6 +30,8 @@ public class VehicleModelQueryCondition {
private Integer status; private Integer status;
@ApiModelProperty("分类逗号分割") @ApiModelProperty("分类逗号分割")
String catasStr; String catasStr;
@ApiModelProperty("排除的车型id")
String notInIds;
@ApiModelProperty(value = "分类列表", hidden = true) @ApiModelProperty(value = "分类列表", hidden = true)
Map<Integer, List<VehiclePlatCata>> catas; Map<Integer, List<VehiclePlatCata>> catas;
} }
...@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.biz; ...@@ -3,6 +3,7 @@ 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.github.wxiaoqi.security.common.util.RandomUtil;
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.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
...@@ -10,6 +11,7 @@ import com.xxfc.platform.vehicle.entity.*; ...@@ -10,6 +11,7 @@ import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.mapper.BranchCompanyStockInfoMapper; import com.xxfc.platform.vehicle.mapper.BranchCompanyStockInfoMapper;
import com.xxfc.platform.vehicle.mapper.CompanyBaseMapper; import com.xxfc.platform.vehicle.mapper.CompanyBaseMapper;
import com.xxfc.platform.vehicle.mapper.SysRegionMapper; import com.xxfc.platform.vehicle.mapper.SysRegionMapper;
import com.xxfc.platform.vehicle.pojo.AddOrUpdateVehicleVo;
import com.xxfc.platform.vehicle.pojo.dto.CompanyBaseDetailDTO; import com.xxfc.platform.vehicle.pojo.dto.CompanyBaseDetailDTO;
import com.xxfc.platform.vehicle.pojo.vo.CompanyBaseVo; import com.xxfc.platform.vehicle.pojo.vo.CompanyBaseVo;
import com.xxfc.platform.vehicle.pojo.vo.CompanyVo; import com.xxfc.platform.vehicle.pojo.vo.CompanyVo;
...@@ -26,6 +28,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -26,6 +28,7 @@ import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Scanner;
@Service @Service
@Slf4j @Slf4j
...@@ -47,6 +50,9 @@ public class CompanyBaseBiz extends BaseBiz<CompanyBaseMapper, CompanyBase> { ...@@ -47,6 +50,9 @@ public class CompanyBaseBiz extends BaseBiz<CompanyBaseMapper, CompanyBase> {
@Autowired @Autowired
AreaBiz areaBiz; AreaBiz areaBiz;
@Autowired
VehicleBiz vehicleBiz;
@Value("${branchCompanyPic.url}") @Value("${branchCompanyPic.url}")
private String companyUrl; private String companyUrl;
...@@ -85,6 +91,47 @@ public class CompanyBaseBiz extends BaseBiz<CompanyBaseMapper, CompanyBase> { ...@@ -85,6 +91,47 @@ public class CompanyBaseBiz extends BaseBiz<CompanyBaseMapper, CompanyBase> {
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
//临时数据同步4(添加车辆)
public ObjectRestResponse synchro4() throws Exception{
List<BranchCompany> list= branchCompanyBiz.selectListAll();
if (list.size()>0){
int num=1;
for (BranchCompany branchCompany:list){
List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList=new ArrayList<>();
for (int i=1;i<6;i++){
String numberPlate="测试"+getNumberPlate(num);
AddOrUpdateVehicleVo vehicleVo=new AddOrUpdateVehicleVo();
vehicleVo.setCode(Integer.parseInt(RandomUtil.getRandomStr(4)));
vehicleVo.setNumberPlate(numberPlate);
vehicleVo.setStatus(1);
vehicleVo.setBrand(5);
vehicleVo.setUseType(1);
vehicleVo.setModelId(67);
vehicleVo.setSubordinateBranch(branchCompany.getId());
vehicleVo.setMaintenanceMileage(3000);
vehicleVo.setParkBranchCompanyId(branchCompany.getId());
vehicleVo.setTravelStatus(3);
addOrUpdateVehicleVoList.add(vehicleVo);
num++;
log.info("----成功---num=="+num+"---numberPlate==="+numberPlate);
}
vehicleBiz.add(addOrUpdateVehicleVoList);
}
}
return ObjectRestResponse.succ();
}
public String getNumberPlate(int number){
String str=number+"";
char[] ary1 = str.toCharArray();
char[] ary2 = {'0','0','0','0'};
System.arraycopy(ary1, 0, ary2, ary2.length-ary1.length, ary1.length);
String result = new String(ary2);
return result;
}
//临时数据同步2 //临时数据同步2
public ObjectRestResponse synchro2(){ public ObjectRestResponse synchro2(){
List<BranchCompany> list= branchCompanyBiz.selectListAll(); List<BranchCompany> list= branchCompanyBiz.selectListAll();
......
...@@ -21,8 +21,8 @@ public class CompanyController extends BaseController<CompanyBaseBiz> { ...@@ -21,8 +21,8 @@ public class CompanyController extends BaseController<CompanyBaseBiz> {
@ApiOperation("同步分公司信息") @ApiOperation("同步分公司信息")
@PostMapping("synchro") @PostMapping("synchro")
public ObjectRestResponse<String> synchro() { public ObjectRestResponse synchro()throws Exception {
return baseBiz.synchro(); return baseBiz.synchro4();
} }
@ApiOperation("同步分公司地址") @ApiOperation("同步分公司地址")
......
...@@ -46,6 +46,13 @@ ...@@ -46,6 +46,13 @@
</foreach> </foreach>
) > 0 ) > 0
</if> </if>
<if test="notInIds != null">
and vmqc.id not in (
<foreach collection="notInIds.split(',')" item="noIdItem" index="noIdIndex">
#{noIdItem}
</foreach>
)
</if>
ORDER BY vmqc.id ASC ORDER BY vmqc.id ASC
</select> </select>
......
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