Commit 08fe9a06 authored by 周健威's avatar 周健威

Merge branch 'feature_chw_zjw' into master-chw

parents c466ca77 2473a36d
package com.github.wxiaoqi.security.common.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.msg.TableResultResponse;
import com.github.wxiaoqi.security.common.util.Query;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
/**
* ${DESCRIPTION}
......@@ -28,6 +38,13 @@ public class CommonBaseController {
return request;
}
@Autowired
public HttpServletResponse response;
public HttpServletResponse getResponse() {
return response;
}
public String getCurrentUserName(){
return BaseContextHandler.getUsername();
}
......@@ -44,4 +61,48 @@ public class CommonBaseController {
}
}
public void export(Logger log, Map<String, Object> headerAlias, Supplier<List<Map>> function, String fileName) throws Exception {
HttpServletResponse httpServletResponse = getResponse();
ExcelWriter writer = ExcelUtil.getWriter(true);
if(StrUtil.isBlank(fileName)) {
fileName = System.currentTimeMillis()+ "";
}
try {
//封装表头
headerAlias.keySet().forEach(key -> {
writer.addHeaderAlias(key, headerAlias.get(key).toString());
});
log.info("======export==== ");
//处理数据
List<Map> list = function.get();
if (list.size() == 0) {
Map<String, Object> map = CollUtil.newHashMap();
headerAlias.keySet().forEach(key -> {
writer.addHeaderAlias(key, "");
});
list.add(map);
}
log.info("list: {} ", JSONUtil.toJsonStr(list));
writer.write(list);
httpServletResponse.setContentType("application/octet-stream;charset=utf-8");
httpServletResponse.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode(fileName+ ".xlsx","utf-8"));
writer.flush(httpServletResponse.getOutputStream());
}catch (Exception ex) {
log.error(ex.getMessage(), ex);
throw ex;
}finally {
writer.close();
}
}
public <T>void exportBean(Logger log, T headerAlias, Supplier<List<Map>> function, String fileName) throws Exception {
export(log, BeanUtil.beanToMap(headerAlias), ()->
function.get()
, fileName);
}
}
package com.github.wxiaoqi.security.admin.feign.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
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.UserDTO;
......@@ -10,12 +15,17 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.DataInter;
import com.github.wxiaoqi.security.common.vo.DataInterBean;
import org.slf4j.Logger;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
public interface UserRestInterface {
public UserFeign getUserFeign();
......
......@@ -10,6 +10,7 @@ import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.entity.inter.OrderDetail;
import com.xxfc.platform.order.feign.OrderFeign;
import com.xxfc.platform.order.pojo.dto.OrderDetailDTO;
import lombok.extern.slf4j.Slf4j;
......@@ -210,7 +211,34 @@ public class BaseOrderAcceptDetailedBiz extends BaseBiz<BaseOrderAcceptDetailedM
acceptDetailed.setStatus(0);
insertSelective(acceptDetailed);
//添加保险
addInsure(orderDetailDTO,0);
}
public void addInsure(OrderDetailDTO orderDetailDTO,Integer status){
BigDecimal insureAmount = orderDetailDTO.getInsureAmount() == null ? BigDecimal.ZERO : orderDetailDTO.getInsureAmount();
log.info("-----保险分账---insureAmount===="+insureAmount);
if (insureAmount.compareTo(BigDecimal.ZERO) > 0){
Long time = System.currentTimeMillis();
Integer type = status == 1 ? 2 : 1;
BaseOrderAcceptDetailed acceptDetailed=new BaseOrderAcceptDetailed();
acceptDetailed.setMchId(0);
acceptDetailed.setUserId(orderDetailDTO.getUserId());
acceptDetailed.setOrderNo(orderDetailDTO.getOrderNo());
acceptDetailed.setOrderId(orderDetailDTO.getOrderId());
acceptDetailed.setOrderAmount(orderDetailDTO.getOrderAmount());
acceptDetailed.setDivisionAmount(insureAmount);
acceptDetailed.setDivisionType(9);
acceptDetailed.setAddTime(time);
if (status == 1)
acceptDetailed.setStatusTime(time);
acceptDetailed.setStatus(status);
acceptDetailed.setType(type);
insertSelective(acceptDetailed);
}
}
public void payOrderFAccept(OrderWaterDTO orderWaterDTO,OrderDetailDTO orderDetailDTO) {
......@@ -237,6 +265,7 @@ public class BaseOrderAcceptDetailedBiz extends BaseBiz<BaseOrderAcceptDetailedM
acceptDetailed1.setType(2);
acceptDetailed1.setId(null);
acceptDetailed1.setOrderAmount(orderAmount);
BigDecimal dAmount = BigDecimal.ZERO;
if (num.equals(acceptDetaileds.size())){
acceptDetailed1.setDivisionAmount(amount);
insertSelective(acceptDetailed1);
......@@ -244,6 +273,7 @@ public class BaseOrderAcceptDetailedBiz extends BaseBiz<BaseOrderAcceptDetailedM
if (acceptDetailed1.getDivisionType() == 5) {
acceptDetailed1.setDivisionAmount(companyDivisionAmount);
insertSelective(acceptDetailed1);
dAmount = acceptDetailed1.getDivisionAmount();
} else if (acceptDetailed1.getDivisionType() == 2 || acceptDetailed1.getDivisionType() == 3 || acceptDetailed1.getDivisionType() == 4) {
if (otherDivisionAmount.compareTo(BigDecimal.ZERO) > 0) {
if (!orderDetailDTO.getOrderStatus().equals(OrderDetailDTO.CANEL)) {
......@@ -251,6 +281,7 @@ public class BaseOrderAcceptDetailedBiz extends BaseBiz<BaseOrderAcceptDetailedM
acceptDetailed1.setDivisionAmount(divisionAmount);
}
insertSelective(acceptDetailed1);
dAmount = acceptDetailed1.getDivisionAmount();
orderWaterDTO.setAcceptId(acceptDetailed1.getId());
orderWaterDTO.setZAcceptId(zAcceptId);
orderWaterDTO.setOrderAmount(orderAmount);
......@@ -258,7 +289,7 @@ public class BaseOrderAcceptDetailedBiz extends BaseBiz<BaseOrderAcceptDetailedM
}
}
}
amount=amount.subtract(acceptDetailed1.getDivisionAmount());
amount=amount.subtract(dAmount);
}
}
}
......@@ -296,6 +327,8 @@ public class BaseOrderAcceptDetailedBiz extends BaseBiz<BaseOrderAcceptDetailedM
payOrderFAccept(orderWaterDTO,orderDetailDTO);
}
othderAccept(orderDetailDTO);
//保险
addInsure(orderDetailDTO,1);
log.info("订单完成分账----finishOrderWater--------orderId===" + orderId + "----amount====" + amount + "--orderType===" + orderType);
}
......
......@@ -47,6 +47,11 @@ public class WaterMQHandler {
@RabbitListener(queues = ORDER_WATER_QUEUE)
public void integralHandler(Message message, @Headers Map<String, Object> headers, Channel channel) {
log.info("分账队列 messageJson:"+ JSONUtil.parse(message));
try {
Thread.sleep(2000L);
}catch (Exception e) {
log.error(e.getMessage(), e);
}
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(new Runnable() {
@Override
......
......@@ -23,6 +23,11 @@
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.11.0</version>
</dependency>
</dependencies>
<build>
......
......@@ -30,6 +30,10 @@ public class BaseOrder implements Serializable {
public static final int ORDER_SIGN_APPLY = 2;
public static final int ORDER_SIGN_SPECIAL = 3;
public static final int INSURE_STATUS_NOT = 0;
public static final int INSURE_STATUS_BUY = 1;
public static final int INSURE_STATUS_CNL = 2;
/**
* 主键
*/
......@@ -366,4 +370,13 @@ public class BaseOrder implements Serializable {
@Column(name = "is_appraise")
private Integer isAppraise;
@Column(name = "insure_pic")
private String insurePic;
@Column(name = "insure_status")
private Integer insureStatus;
@Column(name = "person_insure_amount")
private BigDecimal personInsureAmount;
}
package com.xxfc.platform.order.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 保险人信息表
*
* @author libin
* @email 18178966185@163.com
* @date 2020-11-30 17:44:50
*/
@Data
@Table(name = "insure_user")
public class InsureUser implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键id")
private Integer id;
/**
* 用户id
*/
@Column(name = "userid")
@ApiModelProperty(value = "用户id")
private Integer userid;
/**
* 姓名
*/
@Column(name = "name")
@ApiModelProperty(value = "姓名")
private String name;
/**
* 身份证
*/
@Column(name = "id_card")
@ApiModelProperty(value = "身份证")
private String idCard;
//手机号
@Column(name = "phone")
@ApiModelProperty(value = "手机号")
private String phone;
/**
* 创建时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
/**
* 更新时间
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "更新时间", hidden = true )
private Long updTime;
/**
* 是否删除:0-正常;1-删除
*/
@Column(name = "isdel")
@ApiModelProperty(value = "是否删除:0-正常;1-删除")
private Integer isdel;
}
......@@ -126,6 +126,10 @@ public class OrderItem implements Serializable {
@ApiModelProperty(value = "真实的总价")
private BigDecimal realAmount;
public void setRealAmount(BigDecimal realAmount) {
this.realAmount = realAmount;
}
/**
* 订单id
*/
......
......@@ -19,6 +19,10 @@ import lombok.Data;
@Table(name = "order_person_insurance")
public class OrderPersonInsurance implements Serializable {
private static final long serialVersionUID = 1L;
public static final int STATUS_PAY = 1;
public static final int STATUS_CNL = 2;
public static final int STATUS_TOPAY = 3;
/**
* 主键
......@@ -34,7 +38,18 @@ public class OrderPersonInsurance implements Serializable {
@Column(name = "order_id")
@ApiModelProperty(value = "基础订单id")
private Integer orderId;
public void setOrderId(Integer orderId) {
this.orderId = orderId;
}
/**
* 基础订单编号
*/
@Column(name = "order_no")
@ApiModelProperty(value = "基础订单编号")
private String orderNo;
/**
* 姓名
*/
......@@ -48,6 +63,55 @@ public class OrderPersonInsurance implements Serializable {
@Column(name = "id_card")
@ApiModelProperty(value = "身份证号码")
private String idCard;
/**
* 投保人姓名
*/
@Column(name = "buy_insure_name")
@ApiModelProperty(value = "投保人姓名")
private String buyInsureName;
/**
* 投保人身份证号码
*/
@Column(name = "buy_insure_id_card")
@ApiModelProperty(value = "投保人身份证号码")
private String buyInsureIdCard;
/**
* 投保人手机号码
*/
@Column(name = "buy_insure_phone")
@ApiModelProperty(value = "投保人手机号码")
private String buyInsurePhone;
/**
* 开始时间
*/
@Column(name = "start_time")
@ApiModelProperty(value = "开始时间")
private Long startTime;
/**
* 结束时间
*/
@Column(name = "end_time")
@ApiModelProperty(value = "结束时间")
private Long endTime;
/**
* 支付时间
*/
@Column(name = "pay_time")
@ApiModelProperty(value = "支付时间")
private Long payTime;
/**
* 退款时间
*/
@Column(name = "refund_time")
@ApiModelProperty(value = "退款时间")
private Long refundTime;
/**
* 订单的天数
......@@ -71,10 +135,10 @@ public class OrderPersonInsurance implements Serializable {
private BigDecimal amount;
/**
* 状态 1--已支付;2--已退款
* 状态 1--已支付;2--已退款; 3--待支付;
*/
@Column(name = "status")
@ApiModelProperty(value = "状态 1--已支付;2--已退款")
@ApiModelProperty(value = "状态 1--已支付;2--已退款; 3--待支付;")
private Integer status;
/**
......
package com.xxfc.platform.order.entity.inter;
import cn.hutool.core.collection.CollUtil;
import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderItem;
......@@ -20,4 +21,14 @@ public interface OrderItemInter {
return null;
}
default List<OrderItem> getItemsByTypeEnum(ItemTypeEnum itemTypeEnum) {
List<OrderItem> returnItems = CollUtil.newArrayList();
for(OrderItem item: getItems()) {
if(itemTypeEnum.getCode().equals(item.getType())) {
returnItems.add(item);
}
}
return returnItems;
}
}
......@@ -99,6 +99,10 @@ public class OrderDetailDTO {
private BigDecimal chageAmount =BigDecimal.ZERO;
@ApiModelProperty("保险金额")
private BigDecimal insureAmount =BigDecimal.ZERO;
@ApiModelProperty("分账金额")
private BigDecimal acceptAmount;
......
package com.xxfc.platform.order.pojo.order;
import com.xxfc.platform.universal.entity.Dictionary;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Data
public class OrderAboutParamDTO {
......@@ -25,6 +29,8 @@ public class OrderAboutParamDTO {
@ApiModelProperty(value = "免赔费用")
private BigDecimal damageSafe;
List<Dictionary> personInsurances;
// @ApiModelProperty(value = "违章保留金")
// private BigDecimal ;
}
\ No newline at end of file
......@@ -76,6 +76,8 @@ public class OrderPageVO extends BaseOrder {
private List<OrderItem> items;
private List<OrderPersonInsurance> insurances;
public void setQrcodeStr(String prefix) {
this.qrcodeStr = prefix+ "?"+ TYPE+ getType()+ "&"+ NO+ getNo();
}
......
package com.xxfc.platform.order.pojo.order;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderItem;
import com.xxfc.platform.order.entity.OrderPersonInsurance;
import com.xxfc.platform.order.entity.inter.OrderDetail;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.pojo.OrderAccompanyDTO;
......@@ -18,6 +20,8 @@ import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
@Data
public class RentVehicleBO extends OrderRentVehicleDetail implements OrderDetail {
private BaseOrder order;
......@@ -110,6 +114,10 @@ public class RentVehicleBO extends OrderRentVehicleDetail implements OrderDetail
*/
private String endDateTimeStr;
private Integer needPersonInsurance;
private List<OrderPersonInsurance> insurances = CollUtil.newArrayList();
private List<OrderPersonInsurance> confirmInsurances = CollUtil.newArrayList();
public void initDate() {
this.startDate = DateUtil.date(getStartTime());
this.endDate = DateUtil.date(getEndTime());
......
package com.xxfc.platform.order.pojo.order.add;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.xxfc.platform.order.entity.OrderPersonInsurance;
import com.xxfc.platform.order.pojo.OrderAccompanyDTO;
import io.swagger.annotations.ApiModelProperty;
......@@ -138,7 +139,8 @@ public class AddRentVehicleDTO extends AddOrderCommonDTO{
public static final int GOODS_DEPOSIT_TYPE_DOWN = 2;
private Integer needPersonInsurance = SYS_FALSE;
private List<OrderPersonInsurance> insurances;
private String insureUserIds;
private AppUserDTO appUserDTO;
public void setStartTime(Long startTime) {
this.startTime = startTime;
......
package com.xxfc.platform.order.pojo.personinsurance;
import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.order.entity.OrderPersonInsurance;
import lombok.Data;
import java.util.List;
@Data
public class BgPageDTO extends PageParam {
private String keyWord;
private String price;
private Integer status;
private Long orderStartTime;
private Long orderEndTime;
private Long refundStartTime;
private Long refundEndTime;
private String no;
private String insurePic;
private List<OrderPersonInsurance> insuranceList;
}
package com.xxfc.platform.order.pojo.personinsurance;
import com.xxfc.platform.order.entity.OrderPersonInsurance;
import lombok.Data;
import javax.persistence.Column;
import java.util.List;
@Data
public class BgPageVO {
private String no;
private String insurePic;
private List<OrderPersonInsurance> insuranceList;
}
......@@ -95,4 +95,16 @@ public class RentVehiclePriceVO extends OrderPriceVO{
//标记是否单价一样
private Integer sameUnitPrice = 1;
//是否买人身保险
private Integer needPersonInsurance = 0;
//保险个数
private Integer personInsureNum = 0;
//保险单价
private BigDecimal personInsurePrice = BigDecimal.ZERO;
//保险总价
private BigDecimal personInsureAmount = BigDecimal.ZERO;
}
......@@ -83,6 +83,7 @@ import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant.*;
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.order.entity.OrderPersonInsurance.STATUS_PAY;
import static com.xxfc.platform.order.pojo.mq.OrderMQDTO.*;
import static com.xxfc.platform.universal.constant.DictionaryKey.ILLEGAL_TYPE;
......@@ -116,6 +117,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
@Autowired
OrderAccountBiz orderAccountBiz;
@Autowired
OrderPersonInsuranceBiz orderPersonInsuranceBiz;
@Autowired
VehicleFeign vehicleFeign;
......@@ -843,6 +847,20 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
}});
}
}
if(BaseOrder.INSURE_STATUS_BUY == baseOrder.getInsureStatus()) {
List<OrderPersonInsurance> insuranceList = orderPersonInsuranceBiz.selectList(new OrderPersonInsurance(){{
setOrderId(baseOrder.getId());
}});
//更新 申请状态
insuranceList.forEach( insurance -> {
orderPersonInsuranceBiz.updateSelectiveById(new OrderPersonInsurance(){{
setId(insurance.getId());
setStatus(STATUS_PAY);
setPayTime(DateUtil.date().getTime());
}});
});
}
} finally {
AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData();
......
package com.xxfc.platform.order.biz;
import org.springframework.stereotype.Service;
import com.xxfc.platform.order.entity.InsureUser;
import com.xxfc.platform.order.mapper.InsureUserMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
/**
* 保险人信息表
*
* @author libin
* @email 18178966185@163.com
* @date 2020-11-30 17:44:50
*/
@Service
public class InsureUserBiz extends BaseBiz<InsureUserMapper, InsureUser> {
}
\ No newline at end of file
......@@ -2,6 +2,9 @@ package com.xxfc.platform.order.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
......@@ -32,6 +35,7 @@ import com.xxfc.platform.order.pojo.price.CostDetailExtend;
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.utils.DateUtil;
import com.xxfc.platform.universal.vo.OrderRefundVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
......@@ -47,6 +51,8 @@ import java.util.*;
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.order.entity.BaseOrder.INSURE_STATUS_CNL;
import static com.xxfc.platform.order.entity.OrderPersonInsurance.*;
import static com.xxfc.platform.order.contant.enumerate.AccountTypeEnum.OUT_RESIDUE_ORDER;
import static com.xxfc.platform.order.pojo.account.OrderAccountDeduction.ORIGIN_DEPOSIT;
import static com.xxfc.platform.order.pojo.account.OrderAccountDeduction.ORIGIN_ORDER_DEPOSIT;
......@@ -132,6 +138,14 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
if(null != orderDeductSource && BigDecimal.ZERO.compareTo(orderDeductSource) < 0) {
BigDecimal orderDeductAmount = calculateDeduction(orderDeductSource, timeLag, dicParentKey, orderRefundDescBuilder);
Integer dayLag = Long.valueOf(timeLag/(1000L * 60L * 60L * 24L)).intValue();
if(dayLag <= 0 && baseOrder.getPersonInsureAmount().compareTo(BigDecimal.ZERO) > 0) {
//扣钱
orderDeductAmount = orderDeductAmount.add(baseOrder.getPersonInsureAmount());
orderRefundDescBuilder = orderRefundDescBuilder.insert(0, "小于24小时扣除保险费");
}
//如果属于免扣费情况
if(noDeduct) {
orderDeductAmount = BigDecimal.ZERO;
......@@ -167,33 +181,33 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
BigDecimal originalDepositRefundAmount = BigDecimal.ZERO.add(depositAmount);
BigDecimal depositRefundAmount = BigDecimal.ZERO.add(depositAmount);
if(null != depositDeductSource && BigDecimal.ZERO.compareTo(depositDeductSource) < 0) {
//通过原扣除款 计算剩余款
BigDecimal depositDeductAmount = calculateDeduction(depositDeductSource, timeLag, dicParentKey, depositRefundDescBuilder);
//如果属于免扣费情况
if(noDeduct) {
depositDeductAmount = BigDecimal.ZERO;
depositRefundDescBuilder = new StringBuilder("");
}
depositDeductAmount = depositDeductAmount.setScale(2, RoundingMode.HALF_UP);
if(null != orderViolateCoverAmount) {
depositDeductAmount = orderViolateCoverAmount;
}
if (null != depositViolateCoverAmount) {
depositDeductAmount = depositViolateCoverAmount;
}
if(topAmount.compareTo(depositDeductAmount) > 0) {
totalDeductAmount = totalDeductAmount.add(depositDeductAmount);
topAmount = topAmount.subtract(depositDeductAmount);
}else {
totalDeductAmount = totalDeductAmount.add(topAmount);
depositDeductAmount = topAmount;
topAmount = BigDecimal.ZERO;
}
//返回押金
depositRefundAmount = originalDepositRefundAmount.subtract(depositDeductAmount);
}
// if(null != depositDeductSource && BigDecimal.ZERO.compareTo(depositDeductSource) < 0) {
// //通过原扣除款 计算剩余款
// BigDecimal depositDeductAmount = calculateDeduction(depositDeductSource, timeLag, dicParentKey, depositRefundDescBuilder);
// //如果属于免扣费情况
// if(noDeduct) {
// depositDeductAmount = BigDecimal.ZERO;
// depositRefundDescBuilder = new StringBuilder("");
// }
// depositDeductAmount = depositDeductAmount.setScale(2, RoundingMode.HALF_UP);
// if(null != orderViolateCoverAmount) {
// depositDeductAmount = orderViolateCoverAmount;
// }
// if (null != depositViolateCoverAmount) {
// depositDeductAmount = depositViolateCoverAmount;
// }
// if(topAmount.compareTo(depositDeductAmount) > 0) {
// totalDeductAmount = totalDeductAmount.add(depositDeductAmount);
// topAmount = topAmount.subtract(depositDeductAmount);
// }else {
// totalDeductAmount = totalDeductAmount.add(topAmount);
// depositDeductAmount = topAmount;
// topAmount = BigDecimal.ZERO;
// }
//
// //返回押金
// depositRefundAmount = originalDepositRefundAmount.subtract(depositDeductAmount);
// }
//设置违章款账单
StringBuilder stringBuilder = new StringBuilder("");
......@@ -343,29 +357,45 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
return deductGoodsAmount;
}
public BigDecimal calculatePersonInsurance(Long timeLag) {
BigDecimal amount = BigDecimal.ZERO;
public void calculatePersonInsurance(Long startLong, Long endLong, OrderPersonInsurance opi) {
DateTime startDateBegin = DateUtil.beginOfDay(DateUtil.date(startLong));
DateTime endDateEnd = DateUtil.endOfDay(DateUtil.date(endLong));
opi.setAmount(BigDecimal.ZERO);
opi.setStatus(-1);
//获取天
Integer remainder = Long.valueOf(timeLag%(1000L * 60L * 60L * 24L)).intValue();
Integer dayLag = Long.valueOf(timeLag/(1000L * 60L * 60L * 24L)).intValue() + remainder > 0? 1: 0;
// Integer remainder = Long.valueOf(timeLag%(1000L * 60L * 60L * 24L)).intValue();
// Integer dayLag = Long.valueOf(timeLag/(1000L * 60L * 60L * 24L)).intValue() + remainder > 0? 1: 0;
Long dayLag = DateUtil.between(startDateBegin, endDateEnd, DateUnit.DAY);
if(!DateUtil.beginOfDay(DateUtil.date()).equals(startDateBegin)) {
dayLag += 1L;
}else {
startDateBegin = DateUtil.offsetDay(startDateBegin, 1);
}
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
Set<Dictionary> personInsurances = dictionaryMap.get(RENT_PERSON_INSURANCE).getChildrens();
Set<Dictionary> personInsurances = dictionaryMap.get(DictionaryKey.APP_ORDER+ "_"+ RENT_PERSON_INSURANCE).getChildrens();
for(com.xxfc.platform.universal.entity.Dictionary dic : personInsurances) {
if(StrUtil.isBlank(dic.getName())) {
continue;
}
String[] names = dic.getName().split("\\|");
if(names.length < 2) {
continue;
}
//符合范围
if(IntervalUtil.staticIsInTheInterval(dayLag.toString(), dic.getName())){
amount = new BigDecimal(dic.getDetail());
if(IntervalUtil.staticIsInTheInterval(dayLag.toString(), names[0])){
opi.setAmount(new BigDecimal(dic.getDetail()));
opi.setStatus(STATUS_TOPAY);
opi.setInsuranceDay(Integer.valueOf(names[1]));
opi.setStartTime(startDateBegin.getTime());
opi.setEndTime(endDateEnd.getTime());
break;
}
}
return amount;
}
/**
......@@ -885,4 +915,19 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}
return amount;
}
public static void main(String[] args) {
// IntervalUtil.staticIsInTheInterval("1", "[1,2]");
// System.out.println("123");
String dateStr1 = "2017-03-01 22:33:23";
Date date1 = DateUtil.beginOfDay(DateUtil.parse(dateStr1));
String dateStr2 = "2017-04-01 23:33:23";
Date date2 = DateUtil.endOfDay(DateUtil.parse(dateStr2));
//相差一个月,31天
long betweenDay = DateUtil.between(date1, date2, DateUnit.DAY);
System.out.println(betweenDay);
}
}
\ No newline at end of file
......@@ -89,6 +89,14 @@ public class OrderDetailBiz{
List<OrderItem> orderItems = orderItemBiz.selectList(orderItem);
//不计免赔
BigDecimal damageSafeAmount = orderItems.stream().filter(x->x.getType()==102).map(OrderItem::getRealAmount).reduce(BigDecimal.ZERO, (x, y) -> x.add(y));
Integer insureStatus = baseOrder.getInsureStatus() == null ? 0 : baseOrder.getInsureStatus();
BigDecimal insureAmount = BigDecimal.ZERO;
if ((insureStatus == 1 && baseOrder.getStatus() .equals(OrderStatusEnum.ORDER_TOSTART.getCode())) ||insureStatus == 2 )
insureAmount = orderItems.stream().filter(x->x.getType()==104).map(OrderItem::getRealAmount).reduce(BigDecimal.ZERO, (x, y) -> x.add(y));
goodsAmount = goodsAmount.subtract(insureAmount);
OrderRentVehicleDetail vehicleDetail=orderRentVehicleDetails.get(0);
//获取营收明细dto
OrderDetailDTO orderDetailDTO = new OrderDetailDTO();
......@@ -99,6 +107,7 @@ public class OrderDetailBiz{
orderDetailDTO.setOrderId(baseOrder.getId());
orderDetailDTO.setUserId(baseOrder.getUserId());
orderDetailDTO.setOrderNo(baseOrder.getNo());
orderDetailDTO.setInsureAmount(insureAmount);
orderDetailDTO.setGoodsDepositType(vehicleDetail.getGoodsDepositType());
if (accountDetail != null){
List<OrderAccountDeduction> deductions = accountDetail.getDeductions();
......
package com.xxfc.platform.order.biz;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.order.pojo.personinsurance.BgPageDTO;
import com.xxfc.platform.order.pojo.personinsurance.BgPageVO;
import org.springframework.stereotype.Service;
import com.xxfc.platform.order.entity.OrderPersonInsurance;
import com.xxfc.platform.order.mapper.OrderPersonInsuranceMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.util.List;
/**
* 订单人身保险
*
......@@ -15,4 +20,20 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
*/
@Service
public class OrderPersonInsuranceBiz extends BaseBiz<OrderPersonInsuranceMapper, OrderPersonInsurance> {
public PageDataVO<BgPageVO> selectOrderInfo(BgPageDTO dto) {
PageDataVO<BgPageVO> pageList = PageDataVO.pageInfo(dto.initQuery(), ()-> mapper.selectOrderInfo(dto));
pageList.getData().forEach(vo -> {
vo.setInsuranceList(selectList(new OrderPersonInsurance(){{
setOrderNo(vo.getNo());
}}));
});
return pageList;
}
public List<OrderPersonInsurance> selectInsuranceInfo(BgPageDTO dto) {
return mapper.selectInsuranceInfo(dto);
}
}
\ No newline at end of file
package com.xxfc.platform.order.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
......@@ -8,12 +9,16 @@ import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.entity.InsureUser;
import com.xxfc.platform.order.entity.OrderPersonInsurance;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.mapper.OrderRentVehicleDetailMapper;
import com.xxfc.platform.order.pojo.order.OrderFullDTO;
import com.xxfc.platform.order.pojo.order.OrderFullVO;
import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO;
import com.xxfc.platform.universal.entity.IdInformation;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.BookVehicleVO;
......@@ -22,12 +27,14 @@ import lombok.extern.slf4j.Slf4j;
import org.mockito.internal.util.collections.Sets;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
import java.util.Map;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
/**
* 租车订单详情
*
......@@ -43,10 +50,15 @@ public class OrderRentVehicleBiz extends BaseBiz<OrderRentVehicleDetailMapper, O
BaseOrderBiz baseOrderBiz;
@Autowired
VehicleFeign vehicleFeign;
@Autowired
ThirdFeign thirdFeign;
@Autowired
OrderCalculateBiz orderCalculateBiz;
@Autowired
InsureUserBiz insureUserBiz;
public List<OrderRentVehicleDetail> listByOrderId(Integer orderId) {
return mapper.listByOrderId(orderId);
......@@ -145,6 +157,53 @@ public class OrderRentVehicleBiz extends BaseBiz<OrderRentVehicleDetailMapper, O
bo.setTickerNo(StrUtil.isNotBlank(vo.getTickerNos())?
StrUtil.splitTrim(vo.getTickerNos(), ","):null);
bo.setAccompanyItems(vo.getAccompanyItems());
if(SYS_TRUE == vo.getNeedPersonInsurance() && StrUtil.isNotBlank(vo.getInsureUserIds())){
String buyInsureIdCard = "";
String buyInsureName = "";
String buyInsurePhone = vo.getAppUserDTO().getUsername();
IdInformation idInformation = thirdFeign.getOneByUserId(vo.getAppUserDTO().getUserid());
if(null == idInformation) {
String[] insureUserIds = vo.getInsureUserIds().split(",");
for(int i = 0; i < insureUserIds.length; i++) {
InsureUser insureUser = insureUserBiz.selectById(Integer.valueOf(vo.getInsureUserIds().split(",")[i]));
if(buyInsurePhone.equals(insureUser.getPhone())) {
buyInsureIdCard = insureUser.getIdCard();
buyInsureName = insureUser.getName();
break;
}
if(i == (insureUserIds.length - 1)) {
if(StrUtil.isNotBlank(insureUser.getPhone())) {
buyInsurePhone = insureUser.getPhone();
}
buyInsureIdCard = insureUser.getIdCard();
buyInsureName = insureUser.getName();
}
}
}else {
buyInsureIdCard = idInformation.getIdNumber();
buyInsureName = idInformation.getName();
}
for(String insureUserId: vo.getInsureUserIds().split(",")) {
InsureUser insureUser = insureUserBiz.selectById(Integer.valueOf(insureUserId));
if(null == insureUser) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE, Sets.newSet("保险人不存在"));
}else {
String finalBuyInsureIdCard = buyInsureIdCard;
String finalBuyInsureName = buyInsureName;
String finalBuyInsurePhone1 = buyInsurePhone;
bo.getInsurances().add(new OrderPersonInsurance(){{
setBuyInsureIdCard(finalBuyInsureIdCard);
setBuyInsureName(finalBuyInsureName);
setBuyInsurePhone(finalBuyInsurePhone1);
setIdCard(insureUser.getIdCard());
setName(insureUser.getName());
}});
}
}
}
return bo;
}
......
......@@ -123,6 +123,10 @@ public class OrderCalculateBiz implements CalculateInterface {
//其他消费金额 = 商品真实价格 - 主要商品真实价格 = (商品价格 - 优惠价格)- 主要商品真实价格
BigDecimal otherItemRealAmount = goodsRealAmount.subtract(vehicleItemDTO.getRealAmount());
// //人身保险费用处理
// Long dayLong = 1000L * 60L * 60L * 24L;
// if()
InProgressVO inProgressVO = new InProgressVO();
inProgressVO.setUsedDays(useDays);
......
......@@ -3,6 +3,7 @@ package com.xxfc.platform.order.biz.inner;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
......@@ -44,6 +45,8 @@ import java.util.List;
import java.util.Map;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.xxfc.platform.order.entity.OrderPersonInsurance.STATUS_CNL;
import static com.xxfc.platform.order.entity.OrderPersonInsurance.STATUS_PAY;
import static com.xxfc.platform.universal.constant.DictionaryKey.*;
/**
......@@ -93,6 +96,9 @@ public class OrderCancelBiz {
@Autowired
SpecialRentBiz specialRentBiz;
@Autowired
OrderPersonInsuranceBiz orderPersonInsuranceBiz;
@Autowired
RabbitProduct rabbitProduct;
......@@ -264,7 +270,8 @@ public class OrderCancelBiz {
//退款流程
//违约金封顶 租车身份价 * 2天
orderAccountBiz.rentRefundProcessCancel(baseOrder, BigDecimal.ZERO, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), vehicleItemDTO.getBuyAmount(), oad, vehicleItemDTO.getTopAmount(0), null, changeViolateAmount, (!overCancelBuffer));
orderAccountBiz.rentRefundProcessCancel(baseOrder, vehicleItemDTO.getBuyAmount(), timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), BigDecimal.ZERO, oad, vehicleItemDTO.getTopAmount(0), null, changeViolateAmount, (!overCancelBuffer));
//设置订单数据
//baseOrder.setDamagesAmount(csv.getDamagesAmount());
......@@ -295,6 +302,28 @@ public class OrderCancelBiz {
}
}
}
//设置人身保险状态
if(BaseOrder.INSURE_STATUS_BUY == baseOrder.getInsureStatus() ) {
List<OrderPersonInsurance> insuranceList = orderPersonInsuranceBiz.selectList(new OrderPersonInsurance(){{
setOrderId(baseOrder.getId());
}});
Integer dayLag = Long.valueOf(timeLag/(1000L * 60L * 60L * 24L)).intValue();
//没超过缓冲时间 或者 相隔大于一天,可以取消
if((!overCancelBuffer) || dayLag > 0) {
baseOrder.setInsureStatus(BaseOrder.INSURE_STATUS_CNL);
//更新 申请状态
insuranceList.forEach( insurance -> {
orderPersonInsuranceBiz.updateSelectiveById(new OrderPersonInsurance(){{
setId(insurance.getId());
setStatus(STATUS_CNL);
setRefundTime(DateUtil.date().getTime());
}});
});
}
}
}
//已付款的取消订单发送消息
......
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.InsureUser;
import tk.mybatis.mapper.common.Mapper;
/**
* 保险人信息表
*
* @author libin
* @email 18178966185@163.com
* @date 2020-11-30 17:44:50
*/
public interface InsureUserMapper extends Mapper<InsureUser> {
}
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderPersonInsurance;
import com.xxfc.platform.order.pojo.personinsurance.BgPageDTO;
import com.xxfc.platform.order.pojo.personinsurance.BgPageVO;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* 订单人身保险
*
......@@ -11,5 +15,7 @@ import tk.mybatis.mapper.common.Mapper;
* @date 2020-11-26 18:56:21
*/
public interface OrderPersonInsuranceMapper extends Mapper<OrderPersonInsurance> {
public List<BgPageVO> selectOrderInfo(BgPageDTO dto);
public List<OrderPersonInsurance> selectInsuranceInfo(BgPageDTO dto);
}
......@@ -54,13 +54,16 @@ import tk.mybatis.mapper.weekend.WeekendSqls;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.xxfc.platform.order.entity.BaseOrder.INSURE_STATUS_NOT;
import static com.xxfc.platform.order.entity.BaseOrder.ORDER_TYPE_VEHICLE;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
import static com.xxfc.platform.universal.constant.DictionaryKey.RENT_PERSON_INSURANCE;
@Controller
@RequestMapping("baseOrder")
......@@ -111,6 +114,9 @@ public class BaseOrderController extends CommonBaseController implements UserRes
@Autowired
OrderDepositRefundRecordBiz orderDepositRefundRecordBiz;
@Autowired
OrderPersonInsuranceBiz orderPersonInsuranceBiz;
@Override
public UserFeign getUserFeign() {
return userFeign;
......@@ -155,6 +161,8 @@ public class BaseOrderController extends CommonBaseController implements UserRes
setActMember(new Long(dictionaryMap.get(APP_ORDER + "_" + DictionaryKey.ACT_MEMBER).getDetail()));
setDamageSafe(new BigDecimal(dictionaryMap.get(APP_ORDER + "_" + DictionaryKey.DAMAGE_SAFE).getDetail()));
setDriverPrice(new BigDecimal(dictionaryMap.get(APP_ORDER + "_" + DictionaryKey.DRIVER_PRICE).getDetail()));
setPersonInsurances(dictionaryMap.get(DictionaryKey.APP_ORDER+ "_"+ RENT_PERSON_INSURANCE).getChildrens()
.parallelStream().sorted(Comparator.comparing(Dictionary::getId)).collect(Collectors.toList()));
}});
}
......@@ -256,6 +264,11 @@ public class BaseOrderController extends CommonBaseController implements UserRes
}
log.info("no:" + no + ",时间戳:" + System.currentTimeMillis());
OrderPageVO orderPageVO = page.getData().get(0);
if(INSURE_STATUS_NOT != orderPageVO.getInsureStatus()) {
orderPageVO.setInsurances(orderPersonInsuranceBiz.selectList(new OrderPersonInsurance(){{
setOrderId(orderPageVO.getId());
}}));
}
orderPageVO.setQrcodeStr(qrcodePrefix);
orderPageVO.setItems(orderItemBiz.selectList(new OrderItem(){{
setOrderId(orderPageVO.getId());
......
package com.xxfc.platform.order.rest;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.order.biz.InsureUserBiz;
import com.xxfc.platform.order.entity.InsureUser;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
@RestController
@RequestMapping("/chw/insureUser")
@Slf4j
public class InsureUserController extends BaseController<InsureUserBiz, InsureUser> implements UserRestInterface {
@Autowired
UserFeign userFeign;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
/**
* 添加和更新
* @param insureUser
* @return
*/
@ApiOperation("插入和更新")
@PostMapping(value = "/app/addAndUpdate")
@Transactional
public ObjectRestResponse<InsureUser> addAndUpdate(@RequestBody InsureUser insureUser){
try {
if (insureUser.getId()==null||insureUser.getId()==0) {
AppUserDTO userInfo = getAppUser();
if (userInfo==null||userInfo.getUserid()==null||userInfo.getUserid()==0) {
return ObjectRestResponse.createDefaultFail();
}
Integer userid = userInfo.getUserid();
InsureUser insureUser1=new InsureUser();
insureUser1.setUserid(userid);
insureUser1.setIdCard(insureUser.getIdCard());
insureUser1.setIsdel(0);
insureUser1=baseBiz.selectOne(insureUser1);
if(insureUser1!=null){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"保险人证件号一样");
}
insureUser.setUserid(userid);
insureUser.setCrtTime(System.currentTimeMillis());
insureUser.setIsdel(0);
baseBiz.insertSelective(insureUser);
}else {
insureUser.setUpdTime(System.currentTimeMillis());
baseBiz.updateSelectiveById(insureUser);
}
return new ObjectRestResponse<InsureUser>();
} catch (Exception e) {
log.error(e.getMessage(), e);;
throw new BaseException(ResultCode.FAILED_CODE);
}
}
/**
* 删除
* @param
* @return
*/
@ApiOperation("删除")
@PostMapping(value = "/app/del")
@Transactional(rollbackFor = Exception.class)
public ObjectRestResponse<InsureUser> del(@RequestBody InsureUser insureUser){
try {
baseBiz.updateSelectiveById(new InsureUser() {{
setId(insureUser.getId());
setIsdel(SYS_TRUE);
}});
return ObjectRestResponse.succ();
} catch (Exception e) {
log.error(e.getMessage(), e);;
throw new BaseException(ResultCode.FAILED_CODE);
}
}
@ApiOperation("通过id查询")
@GetMapping(value = "/app/findById/{id}")
public ObjectRestResponse<InsureUser> findById(@PathVariable Integer id){
AppUserDTO userInfo = getAppUser();
if (userInfo==null||userInfo.getUserid()==null||userInfo.getUserid()==0) {
ObjectRestResponse.createDefaultFail();
}
Integer userid = userInfo.getUserid();
InsureUser user = new InsureUser();
user.setUserid(userid);
user.setId(id);
if (id==null||id==0) {
ObjectRestResponse.createDefaultFail();
}
return ObjectRestResponse.succ(baseBiz.selectList(user));
}
/**
* 获取全部出游人信息
* @return
*/
@GetMapping("/app/getInsureUserAll")
public ObjectRestResponse getInsureUser(){
AppUserDTO userInfo = getAppUser();
if (userInfo==null||userInfo.getUserid()==null||userInfo.getUserid()==0) {
ObjectRestResponse.createDefaultFail();
}
Integer id = userInfo.getUserid();
List<InsureUser> insureUsers= baseBiz.selectByWeekend(w -> {
w.andEqualTo(InsureUser::getIsdel, SYS_FALSE);
w.andEqualTo(InsureUser::getUserid, id);
return w;
}, " crt_time desc ");
return ObjectRestResponse.succ(insureUsers);
}
}
\ No newline at end of file
......@@ -70,9 +70,9 @@ public class OrderRentVehicleController extends CommonBaseController {
@ResponseBody
@ApiOperation(value = "确认租车订单")
public ObjectRestResponse<BaseOrder> add(@RequestBody AddRentVehicleDTO vo){
vo.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData());
RentVehicleBO bo = orderRentVehicleBiz.initRentVehicleBO(vo);
// vo.setDayNum(orderCalculateBiz.getIncludeDays(vo.getStartTime(), vo.getEndTime()));
bo.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData());
orderRentVehicleService.createOrder(bo);
return ObjectRestResponse.succ(bo.getOrder());
// return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "系统维护,请联系客服线下租车: 4000-369-369!");
......@@ -82,9 +82,9 @@ public class OrderRentVehicleController extends CommonBaseController {
@ResponseBody
@ApiOperation(value = "后台人员为客户下租车订单")
public ObjectRestResponse<BaseOrder> backStagedd(@RequestBody BgAddRentDTO dto){
dto.setAppUserDTO(userFeign.userDetailById(dto.getAppUserId()).getData());
RentVehicleBO bo = orderRentVehicleBiz.initRentVehicleBO(dto);
// bo.setDayNum(orderCalculateBiz.getIncludeDays(dto.getStartTime(), dto.getEndTime()));
bo.setAppUserDTO(userFeign.userDetailById(dto.getAppUserId()).getData());
bo.setCrtUser("-1"+ BaseContextHandler.getUserID());
//设置-1表示查询所有的车
//bo.setUseType(-1);
......
......@@ -221,10 +221,10 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
dto.setEndTime(shuntApply.getEndTime());
dto.setStartCompanyId(shuntApply.getStartCompanyId());
dto.setEndCompanyId(shuntApply.getEndCompanyId());
dto.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData());
RentVehicleBO bo = orderRentVehicleBiz.initRentVehicleBO(dto);
bo.setOrderSign(BaseOrder.ORDER_SIGN_APPLY);
bo.setBookRecordId(shuntApply.getBookRecordId());
bo.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData());
orderRentVehicleService.applyCreateOrder(bo, shuntApply.getOrderNo());
baseBiz.updateSelectiveById(new ShuntApply(){{
setId(shuntApply.getId());
......
......@@ -198,9 +198,9 @@ public class SpecialRentController extends BaseController<SpecialRentBiz, Specia
dto.setVehicleId(specialRent.getVehicleId());
dto.setStartCompanyId(specialRent.getStartCompanyId());
dto.setEndCompanyId(specialRent.getEndCompanyId());
dto.setAppUserDTO(getAppUser());
RentVehicleBO bo = orderRentVehicleBiz.initRentVehicleBO(dto);
bo.setOrderSign(BaseOrder.ORDER_SIGN_SPECIAL);
bo.setAppUserDTO(getAppUser());
bo.setSpecialUnitPrice(specialRent.getUnitPrice());
bo.setBookRecordId(specialRent.getBookRecordId());
orderRentVehicleService.specialCreateOrder(bo, specialRent.getOrderNo());
......
package com.xxfc.platform.order.rest.background;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.msg.TableResultResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.order.biz.BaseOrderBiz;
import com.xxfc.platform.order.biz.OrderPersonInsuranceBiz;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderPersonInsurance;
import com.xxfc.platform.order.pojo.personinsurance.BgPageDTO;
import com.xxfc.platform.order.pojo.personinsurance.BgPageVO;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zipkin2.Call;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/background/orderPersonInsurance")
@Slf4j
public class BgOrderPersonInsuranceController extends BaseController<OrderPersonInsuranceBiz, OrderPersonInsurance> {
@Autowired
BaseOrderBiz baseOrderBiz;
@ApiOperation("查询分页")
@RequestMapping(value = "/pageList",method = RequestMethod.GET)
@ResponseBody
public ObjectRestResponse<PageDataVO<BgPageVO>> pageList(BgPageDTO dto){
return ObjectRestResponse.succ(baseBiz.selectOrderInfo(dto));
}
@ApiOperation("修改图片")
@RequestMapping(value = "/editPic",method = RequestMethod.POST)
@ResponseBody
public ObjectRestResponse editPic(@RequestBody BgPageDTO dto){
baseOrderBiz.updateByWeekendSelective(new BaseOrder(){{
setInsurePic(dto.getInsurePic());
}}, w -> {
w.andEqualTo(BaseOrder::getNo, dto.getNo());
return w;
});
return ObjectRestResponse.succ();
}
@RequestMapping(value="/pageExport", method = RequestMethod.GET)
public void bgPageExport(BgPageDTO dto) throws Exception{
PageExportDTO head = new PageExportDTO(){{
setOrderNo("订单编号");
setName("姓名");
setIdCard("身份证号");
setRentDateStr("租期");
setAmountStr("保险档次");
setPayTimeStr("下单时间");
setRefundTimeStr("退保时间");
setStatusStr("状态");
setBuyInsureIdCard("投保人身份证");
setBuyInsurePhone("投保人手机号");
setBuyInsureName("投保人名称");
}};
exportBean(log, head, () -> {
List<OrderPersonInsurance> bgList = baseBiz.selectInsuranceInfo(dto);
List<Map> list = CollUtil.newArrayList();
bgList.forEach(vo -> {
//OrderNo Name IdCard
PageExportDTO ped = BeanUtil.toBean(vo, PageExportDTO.class);
if(StrUtil.isBlank(vo.getBuyInsureIdCard())) {
ped.setBuyInsureIdCard("");
}
if(StrUtil.isBlank(vo.getBuyInsureName())) {
ped.setBuyInsureName("");
}
if(StrUtil.isBlank(vo.getBuyInsurePhone())) {
ped.setBuyInsurePhone("");
}
switch (vo.getStatus()) {
case OrderPersonInsurance.STATUS_PAY:
ped.setStatusStr("已购买");
ped.setRefundTimeStr("");
break;
case OrderPersonInsurance.STATUS_CNL:
ped.setStatusStr("已退保");
ped.setRefundTimeStr(DateUtil.date(vo.getRefundTime()).toString());
break;
default:
ped.setStatusStr("");
ped.setRefundTimeStr("");
break;
}
ped.setAmountStr(vo.getAmount()+ "元");
String startStr = DateUtil.date(vo.getStartTime()).toDateStr();
String endStr = DateUtil.date(vo.getEndTime()).toDateStr();
ped.setRentDateStr(startStr+ "-"+ endStr);
ped.setPayTimeStr(DateUtil.date(vo.getPayTime()).toString());
list.add(BeanUtil.beanToMap(ped,false, true));
});
return list;
},"保险导出");
}
@Data
static class PageExportDTO {
private String orderNo;
private String name;
private String idCard;
private String rentDateStr;
private String amountStr;
private String payTimeStr;
private String refundTimeStr;
private String statusStr;
private String buyInsureName;
private String buyInsureIdCard;
private String buyInsurePhone;
}
}
\ No newline at end of file
......@@ -205,7 +205,7 @@
// @RequestMapping(value = "/steward/myApplyList", method = RequestMethod.GET)
// @ResponseBody
// @ApiOperation(value = "我的申请")
// public ObjectRestResponse myApplyList(PageDTO dto) {
// public ObjectRestResponse myApplyList(BgPageDTO dto) {
// UserDTO userDTO = getAdminUserInfo();
// PageDataVO<ShuntApplyController.ShuntApplyVO> pages = PageDataVO.pageInfo(dto.initQuery(), () -> baseBiz.selectByWeekend(w -> {
// w.andEqualTo(ShuntApply::getConfirmUserId, userDTO.getId());
......@@ -244,7 +244,7 @@
// }
//
// @Data
// public static class PageDTO extends PageParam {
// public static class BgPageDTO extends PageParam {
// String multiStatus;
// }
//
......
......@@ -142,6 +142,9 @@ public abstract class AbstractOrderHandle<Biz extends BaseBiz, Detail extends Or
/**
* 处理订单详情
* 1、补充baseorder 信息 update
* 2、插入item
* 3、判断是否支付
* @param detail
*/
public void handleDetail(Detail detail){
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxfc.platform.order.mapper.InsureUserMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.order.entity.InsureUser" id="insureUserMap">
<result property="id" column="id"/>
<result property="userid" column="userid"/>
<result property="name" column="name"/>
<result property="idCard" column="id_card"/>
<result property="crtTime" column="crt_time"/>
<result property="updTime" column="upd_time"/>
<result property="isdel" column="isdel"/>
</resultMap>
</mapper>
\ No newline at end of file
......@@ -19,4 +19,53 @@
<result property="updUser" column="upd_user"/>
</resultMap>
<select id="selectOrderInfo" resultType="com.xxfc.platform.order.pojo.personinsurance.BgPageVO">
select distinct bo.no, bo.insure_pic
<include refid="commonFromWhere"></include>
order by
bo.no desc
</select>
<select id="selectInsuranceInfo" resultType="com.xxfc.platform.order.entity.OrderPersonInsurance">
select opi.*
<include refid="commonFromWhere"></include>
order by
bo.no desc
</select>
<sql id="commonFromWhere">
from order_person_insurance opi
left join base_order bo on opi.order_id = bo.id
<where>
and bo.has_pay = 1
<if test="keyWord != null">
and (
opi.id_card like concat('%',#{keyWord},'%') or opi.name like concat('%',#{keyWord},'%')
)
</if>
<if test="price != null">
and opi.amount = #{price}
</if>
<if test="status != null">
and opi.status = #{status}
</if>
<if test="orderStartTime != null">
and opi.pay_time &gt;= #{orderStartTime}
</if>
<if test="orderEndTime != null">
and bo.pay_time &lt;= #{orderEndTime}
</if>
<if test="refundStartTime != null">
and opi.refund_time &gt;= #{refundStartTime}
</if>
<if test="refundEndTime != null">
and bo.refund_time &lt;= #{refundEndTime}
</if>
</where>
</sql>
</mapper>
\ No newline at end of file
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