Commit a6184545 authored by hezhen's avatar hezhen

Merge branch 'dev' of http://113.105.137.151:22280/youjj/cloud-platform into dev

parents 2c532d49 bbe73255
...@@ -118,6 +118,8 @@ public interface UserFeign { ...@@ -118,6 +118,8 @@ public interface UserFeign {
@GetMapping("/app/user/one") @GetMapping("/app/user/one")
public AppUserLogin one(@RequestParam(value = "username")String username); public AppUserLogin one(@RequestParam(value = "username")String username);
@GetMapping("/app/user/getOne")
public List<AppUserLogin> getOne(@RequestParam(value = "username")String username,@RequestParam(value = "realName")String realName);
@GetMapping("/api/app/imi/{imiId}") @GetMapping("/api/app/imi/{imiId}")
ImiVo findUserInfoByImiId(@PathVariable(value = "imiId") Integer imiId); ImiVo findUserInfoByImiId(@PathVariable(value = "imiId") Integer imiId);
......
...@@ -2,16 +2,21 @@ package com.github.wxiaoqi.security.admin.biz; ...@@ -2,16 +2,21 @@ package com.github.wxiaoqi.security.admin.biz;
import com.ace.cache.annotation.Cache; import com.ace.cache.annotation.Cache;
import com.ace.cache.annotation.CacheClear; import com.ace.cache.annotation.CacheClear;
import com.alibaba.druid.sql.visitor.functions.If;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin; import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.mapper.AppUserLoginMapper; import com.github.wxiaoqi.security.admin.mapper.AppUserLoginMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant; import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import com.github.wxiaoqi.security.common.constant.UserConstant; import com.github.wxiaoqi.security.common.constant.UserConstant;
import com.google.common.collect.Lists;
import com.xxfc.platform.im.utils.StringUtil;
import com.xxfc.platform.universal.entity.IdInformation; import com.xxfc.platform.universal.entity.IdInformation;
import com.xxfc.platform.universal.feign.MQSenderFeign; import com.xxfc.platform.universal.feign.MQSenderFeign;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -38,15 +43,18 @@ import java.util.stream.Collectors; ...@@ -38,15 +43,18 @@ import java.util.stream.Collectors;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
private static final String WX_TYPE="wx"; private static final String WX_TYPE = "wx";
private static final String QQ_TYPE="q"; private static final String QQ_TYPE = "q";
@Autowired @Autowired
ThirdFeign thirdFeign; ThirdFeign thirdFeign;
@Autowired @Autowired
MQSenderFeign mqSenderFeign; MQSenderFeign mqSenderFeign;
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED) @Autowired
AppUserDetailBiz appUserDetailBiz;
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
@Override @Override
public void insertSelective(AppUserLogin entity) { public void insertSelective(AppUserLogin entity) {
String password = new BCryptPasswordEncoder(UserConstant.PW_ENCORDER_SALT).encode(entity.getPassword()); String password = new BCryptPasswordEncoder(UserConstant.PW_ENCORDER_SALT).encode(entity.getPassword());
...@@ -62,7 +70,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -62,7 +70,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
@CacheClear(pre = "user{1.username}") @CacheClear(pre = "user{1.username}")
public int bindOpenid(AppUserLogin entity) { public int bindOpenid(AppUserLogin entity) {
return mapper.bindOpenId(entity); return mapper.bindOpenId(entity);
} }
@CacheClear(pre = "user{1.username}") @CacheClear(pre = "user{1.username}")
...@@ -81,33 +89,35 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -81,33 +89,35 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
List<AppUserLogin> list = mapper.selectAll(); List<AppUserLogin> list = mapper.selectAll();
ExecutorService executorService = Executors.newCachedThreadPool(); ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(new Runnable() { executorService.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
if(list != null && list.size() > 0) { if (list != null && list.size() > 0) {
for(AppUserLogin appUserLogin : list) { for (AppUserLogin appUserLogin : list) {
try { try {
Thread.sleep(3000); Thread.sleep(3000);
} catch (Exception e){} } catch (Exception e) {
IdInformation idInformation = thirdFeign.getOneByUserId(appUserLogin.getId()); }
if(idInformation != null) { //实名认证 IdInformation idInformation = thirdFeign.getOneByUserId(appUserLogin.getId());
JSONObject jsonObject = new JSONObject(); if (idInformation != null) { //实名认证
jsonObject.put("userId", appUserLogin.getId()); JSONObject jsonObject = new JSONObject();
jsonObject.put("integralRuleCode", "CRETIFICATION"); jsonObject.put("userId", appUserLogin.getId());
jsonObject.put("channelId", idInformation.getId()); jsonObject.put("integralRuleCode", "CRETIFICATION");
mqSenderFeign.sendMessage(RabbitConstant.INTEGRAL_TOPIC, RabbitConstant.INTEGRAL_ROUTING_KEY, jsonObject.toJSONString()); jsonObject.put("channelId", idInformation.getId());
} mqSenderFeign.sendMessage(RabbitConstant.INTEGRAL_TOPIC, RabbitConstant.INTEGRAL_ROUTING_KEY, jsonObject.toJSONString());
try { }
Thread.sleep(3000); try {
} catch (Exception e){} Thread.sleep(3000);
JSONObject jsonObject = new JSONObject(); } catch (Exception e) {
jsonObject.put("userId", appUserLogin.getId()); }
jsonObject.put("integralRuleCode", "REGISTER"); JSONObject jsonObject = new JSONObject();
jsonObject.put("channelId", appUserLogin.getId()); jsonObject.put("userId", appUserLogin.getId());
mqSenderFeign.sendMessage(RabbitConstant.INTEGRAL_TOPIC, RabbitConstant.INTEGRAL_ROUTING_KEY, jsonObject.toJSONString()); jsonObject.put("integralRuleCode", "REGISTER");
jsonObject.put("channelId", appUserLogin.getId());
} mqSenderFeign.sendMessage(RabbitConstant.INTEGRAL_TOPIC, RabbitConstant.INTEGRAL_ROUTING_KEY, jsonObject.toJSONString());
}
} }
}
}
}); });
} }
...@@ -228,10 +238,10 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -228,10 +238,10 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
} }
public Map<Integer, AppUserLogin> findUserIdAndUserLoginMapByMemberIds(List<Integer> memberIds) { public Map<Integer, AppUserLogin> findUserIdAndUserLoginMapByMemberIds(List<Integer> memberIds) {
Map<Integer,AppUserLogin> userIdAndAppUserLoginMap = new HashMap<>(); Map<Integer, AppUserLogin> userIdAndAppUserLoginMap = new HashMap<>();
List<AppUserLogin> appUserLogins = mapper.selectByIdList(memberIds); List<AppUserLogin> appUserLogins = mapper.selectByIdList(memberIds);
if (CollectionUtils.isNotEmpty(appUserLogins)){ if (CollectionUtils.isNotEmpty(appUserLogins)) {
userIdAndAppUserLoginMap = appUserLogins.stream().collect(Collectors.toMap(AppUserLogin::getId, Function.identity())); userIdAndAppUserLoginMap = appUserLogins.stream().collect(Collectors.toMap(AppUserLogin::getId, Function.identity()));
} }
return userIdAndAppUserLoginMap; return userIdAndAppUserLoginMap;
} }
...@@ -239,9 +249,9 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -239,9 +249,9 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
public AppUserLogin findUserByImiId(Integer imiId) { public AppUserLogin findUserByImiId(Integer imiId) {
Example example = new Example(AppUserLogin.class); Example example = new Example(AppUserLogin.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("imUserid",imiId); criteria.andEqualTo("imUserid", imiId);
List<AppUserLogin> appUserLogins = mapper.selectByExample(example); List<AppUserLogin> appUserLogins = mapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(appUserLogins)){ if (CollectionUtils.isNotEmpty(appUserLogins)) {
return appUserLogins.get(0); return appUserLogins.get(0);
} }
return null; return null;
...@@ -249,7 +259,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -249,7 +259,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
@CacheClear(pre = "user{1.id}") @CacheClear(pre = "user{1.id}")
public void disable(AppUserLogin appUserLogin) { public void disable(AppUserLogin appUserLogin) {
mapper.updateByPrimaryKeySelective(appUserLogin); mapper.updateByPrimaryKeySelective(appUserLogin);
} }
@CacheClear(pre = "user{1.id}") @CacheClear(pre = "user{1.id}")
...@@ -260,7 +270,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -260,7 +270,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
public void deleteByPhones(List<String> phons) { public void deleteByPhones(List<String> phons) {
Example example = new Example(AppUserLogin.class); Example example = new Example(AppUserLogin.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
criteria.andIn("username",phons); criteria.andIn("username", phons);
mapper.deleteByExample(example); mapper.deleteByExample(example);
} }
...@@ -273,39 +283,47 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -273,39 +283,47 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
mapper.updateByPrimaryKeySelective(appUserLogin); mapper.updateByPrimaryKeySelective(appUserLogin);
} }
public List<Integer> findAllExistUserIds(){ public List<Integer> findAllExistUserIds() {
return mapper.selectAllExistUserIds(); return mapper.selectAllExistUserIds();
} }
/** /**
* 检查第三方是否绑定 * 检查第三方是否绑定
*
* @param wxOpenId * @param wxOpenId
* @param wxUnionId * @param wxUnionId
* @param openId * @param openId
* @return * @return
*/ */
public boolean checkThirdPartyBindingState(String wxOpenId, String wxUnionId, String openId) { public boolean checkThirdPartyBindingState(String wxOpenId, String wxUnionId, String openId) {
AppUserLogin appUserLogin = new AppUserLogin(); AppUserLogin appUserLogin = new AppUserLogin();
appUserLogin.setWxOpenid(wxOpenId); appUserLogin.setWxOpenid(wxOpenId);
appUserLogin.setUnionid(wxUnionId); appUserLogin.setUnionid(wxUnionId);
appUserLogin.setOpenid(openId); appUserLogin.setOpenid(openId);
return mapper.selectOne(appUserLogin) != null; return mapper.selectOne(appUserLogin) != null;
} }
@CacheClear(pre = "user{2}") @CacheClear(pre = "user{2}")
public void unBindThirdPartyByType(String type,String username,Integer userId) { public void unBindThirdPartyByType(String type, String username, Integer userId) {
AppUserLogin appUserLogin = new AppUserLogin(); AppUserLogin appUserLogin = new AppUserLogin();
appUserLogin.setId(userId); appUserLogin.setId(userId);
//微信解绑 //微信解绑
if (WX_TYPE.equals(type)){ if (WX_TYPE.equals(type)) {
appUserLogin.setWxOpenid(""); appUserLogin.setWxOpenid("");
appUserLogin.setUnionid(""); appUserLogin.setUnionid("");
mapper.updateByPrimaryKeySelective(appUserLogin); mapper.updateByPrimaryKeySelective(appUserLogin);
} }
//qq解绑 //qq解绑
if (QQ_TYPE.equals(type)){ if (QQ_TYPE.equals(type)) {
appUserLogin.setOpenid(""); appUserLogin.setOpenid("");
mapper.updateByPrimaryKeySelective(appUserLogin); mapper.updateByPrimaryKeySelective(appUserLogin);
} }
} }
public List<AppUserLogin> getUserByUsernameAndRealName(String username, String realName) {
return mapper.getUserByUsernameAndRealName(username,realName);
}
} }
...@@ -28,4 +28,7 @@ public interface AppUserLoginMapper extends Mapper<AppUserLogin>, SelectByIdList ...@@ -28,4 +28,7 @@ public interface AppUserLoginMapper extends Mapper<AppUserLogin>, SelectByIdList
List<Integer> selectAllExistUserIds(); List<Integer> selectAllExistUserIds();
List<AppUserLogin> getUserByUsernameAndRealName(@Param("username") String username, @Param("realName")String realName);
} }
\ No newline at end of file
...@@ -262,6 +262,15 @@ public class AppUserController extends CommonBaseController{ ...@@ -262,6 +262,15 @@ public class AppUserController extends CommonBaseController{
return appUserLoginBiz.getUserByUsername(username); return appUserLoginBiz.getUserByUsername(username);
} }
/**
* 根据用户真实姓名和手机号模糊查询寻用户
* @param username
* @return
*/
@GetMapping("/getOne")
public List<AppUserLogin> getOne(@RequestParam(value = "username",required = false)String username, @RequestParam(value = "realName",required = false)String realName){
return appUserLoginBiz.getUserByUsernameAndRealName(username,realName);
}
@GetMapping("/findusersByIds") @GetMapping("/findusersByIds")
public Map<Integer,AppUserLogin> findAppUsersByUserIds(@RequestParam(value = "userIds") List<Integer> userIds){ public Map<Integer,AppUserLogin> findAppUsersByUserIds(@RequestParam(value = "userIds") List<Integer> userIds){
return appUserLoginBiz.findUserIdAndUserLoginMapByMemberIds(userIds); return appUserLoginBiz.findUserIdAndUserLoginMapByMemberIds(userIds);
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
<select id="selectbyPhones" resultType="com.github.wxiaoqi.security.admin.entity.AppUserLogin"> <select id="selectbyPhones" resultType="com.github.wxiaoqi.security.admin.entity.AppUserLogin">
select `id`,`username` from `app_user_login` where `username` in select `id`,`username` from `app_user_login` where `username` in
<foreach collection="phones" item="phone" open="(" close=")" separator=","> <foreach collection="phones" item="phone" open="(" close=")" separator=",">
#{phone} #{phone}
</foreach> </foreach>
</select> </select>
<update id="bindOpenId" parameterType="com.github.wxiaoqi.security.admin.entity.AppUserLogin"> <update id="bindOpenId" parameterType="com.github.wxiaoqi.security.admin.entity.AppUserLogin">
UPDATE app_user_login SET wx_openid=#{wxOpenid},unionid=#{unionid},openid=#{openid} where id=#{id} UPDATE app_user_login SET wx_openid=#{wxOpenid},unionid=#{unionid},openid=#{openid} where id=#{id}
</update> </update>
...@@ -16,4 +16,15 @@ ...@@ -16,4 +16,15 @@
<select id="selectAllExistUserIds" resultType="integer"> <select id="selectAllExistUserIds" resultType="integer">
SELECT `id` FROM `app_user_login` WHERE `isdel`=0; SELECT `id` FROM `app_user_login` WHERE `isdel`=0;
</select> </select>
<select id="getUserByUsernameAndRealName" resultType="com.github.wxiaoqi.security.admin.entity.AppUserLogin">
select l.* from app_user_login l left join app_user_detail d on l.id=d.userid where 1=1
<if test="username!=null ">
and l.username like concat('%',#{username},'%')
</if>
<if test="realName !=null">
and d.realname like concat('%',#{realName},'%')
</if>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
and `city`=#{cityCode} and `city`=#{cityCode}
</if> </if>
GROUP BY cs.id GROUP BY cs.id
order by `hot`DESC,`crt_time` DESC order by cs.hot DESC,cs.crt_time DESC
</select> </select>
<!--首页查询全部--> <!--首页查询全部-->
......
...@@ -4,12 +4,17 @@ import java.util.HashMap; ...@@ -4,12 +4,17 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
public enum OrderCostEnum { public enum OrderCostEnum {
RentVehicle(1, "租车费用明细"), RENT_VEHICLE("01", "租车费用明细"),
TOUR("02", "旅游费用明细"),
CANCEL_NO_START("03", "取消违约金明细"),
CANCEL_STARTED("04", "取消费用明细"),
FINLISH_ADVANCE("05", "租车费用明细"),
FINLISH_DELAY("06", "租车费用明细"),
; ;
/** /**
* 编码 * 编码
*/ */
private Integer code; private String code;
/** /**
* 类型描述 * 类型描述
*/ */
...@@ -17,16 +22,16 @@ public enum OrderCostEnum { ...@@ -17,16 +22,16 @@ public enum OrderCostEnum {
private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>(); private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>();
OrderCostEnum(Integer code, String desc){ OrderCostEnum(String code, String desc){
this.code=code; this.code=code;
this.desc=desc; this.desc=desc;
} }
public Integer getCode() { public String getCode() {
return code; return code;
} }
public void setCode(Integer code) { public void setCode(String code) {
this.code = code; this.code = code;
} }
......
...@@ -78,10 +78,10 @@ public class BaseOrder implements Serializable { ...@@ -78,10 +78,10 @@ public class BaseOrder implements Serializable {
private BigDecimal goodsAmount; private BigDecimal goodsAmount;
/** /**
* 订单价格 * 订单总金额
*/ */
@Column(name = "order_amount") @Column(name = "order_amount")
@ApiModelProperty(value = "订单价格") @ApiModelProperty(value = "订单总金额")
private BigDecimal orderAmount; private BigDecimal orderAmount;
/** /**
......
...@@ -7,6 +7,7 @@ import org.springframework.format.annotation.DateTimeFormat; ...@@ -7,6 +7,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
...@@ -15,7 +16,9 @@ import java.util.Date; ...@@ -15,7 +16,9 @@ import java.util.Date;
* @author Administrator * @author Administrator
*/ */
@Data @Data
public class DailyOrderStatistics { public class DailyOrderStatistics implements Serializable {
private static final long serialVersionUID = 1L;
@Id @Id
@GeneratedValue(generator = "JDBC") @GeneratedValue(generator = "JDBC")
private Integer id; private Integer id;
......
...@@ -13,9 +13,15 @@ import java.math.BigDecimal; ...@@ -13,9 +13,15 @@ import java.math.BigDecimal;
@Data @Data
@Table(name = "daily_travel_order_statistics") @Table(name = "daily_travel_order_statistics")
public class DailyTravelOrderStatistics extends DailyOrderStatistics { public class DailyTravelOrderStatistics extends DailyOrderStatistics {
/**
* 违约总额
*/
@Column(name = "default_money ")
private BigDecimal defaultMoney ;
/** /**
* 取消订单总 * 退还订单金
*/ */
@Column(name = "penal_sum") @Column(name = "return_gmv")
private BigDecimal penalSum; private BigDecimal returnGmv;
} }
...@@ -17,27 +17,28 @@ import java.util.Date; ...@@ -17,27 +17,28 @@ import java.util.Date;
/** /**
* 每日租车订单统计 * 每日租车订单统计
*
* @author Administrator * @author Administrator
*/ */
@Data @Data
@Table(name = "daily_vehicle_order_statistics") @Table(name = "daily_vehicle_order_statistics")
public class DailyVehicleOrderStatistics extends DailyOrderStatistics{ public class DailyVehicleOrderStatistics extends DailyOrderStatistics {
/** /**
* 预交押金总额 * 预交押金总额
*/ */
@Column(name = "security_deposit") @Column(name = "security_deposit")
private BigDecimal securityDeposit; private BigDecimal securityDeposit;
/** /**
* 退还押金总额 * 退还押金总额
*/ */
@Column(name = "refund_security_deposit") @Column(name = "refund_security_deposit")
private BigDecimal refundSecurityDeposit; private BigDecimal refundSecurityDeposit;
/** /**
* 赔偿总额 * 损坏赔偿总额
*/ */
@Column(name = "compensation") @Column(name = "compensation")
private BigDecimal compensation; private BigDecimal compensation;
...@@ -46,19 +47,25 @@ public class DailyVehicleOrderStatistics extends DailyOrderStatistics{ ...@@ -46,19 +47,25 @@ public class DailyVehicleOrderStatistics extends DailyOrderStatistics{
* 违章总额 * 违章总额
*/ */
@Column(name = "forfeit") @Column(name = "forfeit")
private BigDecimal violationMoney; private BigDecimal violationMoney;
/** /**
* 延期总 * 退还订单金
*/ */
@Column(name = "postpone") @Column(name = "return_gmv")
private BigDecimal postpone; private BigDecimal returnGmv;
/** /**
* 取消订单扣款总额 * 违约总额
*/ */
@Column(name = "penal_sum") @Column(name = "default_money ")
private BigDecimal penalSum; private BigDecimal defaultMoney ;
/**
* 消费金总额
*/
@Column(name = "total_expenditure")
private BigDecimal totalExpenditure;
} }
...@@ -323,4 +323,8 @@ public class OrderRentVehicleDetail implements Serializable { ...@@ -323,4 +323,8 @@ public class OrderRentVehicleDetail implements Serializable {
@Column(name = "used_day") @Column(name = "used_day")
Integer usedDay; Integer usedDay;
@Column(name = "cost_detail_extend")
@ApiModelProperty(value = "费用其他明细 type:1--取消违约金;2--取消费用明细;3--提前还车费用明细;4--延期还车费用明细")
private String costDetailExtend;
} }
...@@ -12,48 +12,58 @@ import java.math.BigDecimal; ...@@ -12,48 +12,58 @@ import java.math.BigDecimal;
*/ */
@Data @Data
@ApiModel(value = "订单统计实体") @ApiModel(value = "历史订单统计实体")
public class OrderStatistics { public class OrderStatistics {
/** /**
* 月成交总金额 * 历史交总金额
*/ */
@ApiModelProperty(value = "月成交总金额") @ApiModelProperty(value = "历史交总金额")
private BigDecimal totalGmv; private BigDecimal totalGmv;
/** /**
* 押金总额 * 历史押金总额
*/ */
@ApiModelProperty(value = "押金总额") @ApiModelProperty(value = "历史押金总额")
private BigDecimal totalSecurityDeposit; private BigDecimal totalSecurityDeposit;
/** /**
* 退还押金总额 * 历史退还押金总额
*/ */
@ApiModelProperty(value = "退还押金总额") @ApiModelProperty(value = "历史退还押金总额")
private BigDecimal totalRefundSecurityDeposit; private BigDecimal totalRefundSecurityDeposit;
/** /**
* 赔偿总额 * 历史赔偿总额
*/ */
@ApiModelProperty(value = "赔偿总额") @ApiModelProperty(value = "历史赔偿总额")
private BigDecimal totalCompensation; private BigDecimal totalCompensation;
/** /**
* 违章总额 * 历史违章总额
*/ */
@ApiModelProperty(value = "违章总额") @ApiModelProperty(value = "历史违章总额")
private BigDecimal totalForfeit; private BigDecimal totalForfeit;
/**
* 历史订单退款
*/
@ApiModelProperty(value = "历史订单退款")
private BigDecimal totalReturnGmv;
/** /**
* 月取消订单扣款总额 * 历史延期扣款总额
*/ */
@ApiModelProperty(value = "月取消订单扣款总额") @ApiModelProperty(value = "历史延期扣款总额")
private BigDecimal totalPenalSum; private BigDecimal totalDefaultMoney;
/** /**
* 月延期扣款总额 * 历史实际消费总额
*/ */
@ApiModelProperty(value = "月延期扣款总额") @ApiModelProperty(value = "实际消费总额")
private BigDecimal totalPostpone; private BigDecimal totalExpenditure;
} }
...@@ -245,6 +245,10 @@ public class OrderTourDetail implements Serializable { ...@@ -245,6 +245,10 @@ public class OrderTourDetail implements Serializable {
@ApiModelProperty(value = "是否省外 1--省外;0--省内") @ApiModelProperty(value = "是否省外 1--省外;0--省内")
private Integer isOutside; private Integer isOutside;
@Column(name = "cost_detail_extend")
@ApiModelProperty(value = "费用其他明细 type:1--取消违约金;2--取消费用明细;3--提前还车费用明细;4--延期还车费用明细")
private String costDetailExtend;
@Transient @Transient
private List<TourUser> userVoList; private List<TourUser> userVoList;
} }
package com.xxfc.platform.order.pojo;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class HomePageOrderData {
/**
* 订单总额
*/
private BigDecimal totalOrders;
/**
* 为退还押金总额
*/
private BigDecimal totalOutstandingDeposit;
/**
* 额外赔款
*/
private BigDecimal additionalIndemnity;
}
package com.xxfc.platform.order.pojo.account;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xxfc.platform.order.entity.OrderAccount;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column;
@Data
public class OrderAccountDTO extends OrderAccount {
@Column(name = "companyId")
private Integer companyId;
@Column(name = "oneDay")
private String oneDay;
}
...@@ -9,7 +9,7 @@ import java.util.List; ...@@ -9,7 +9,7 @@ import java.util.List;
@Data @Data
public class OrderAccountDetail { public class OrderAccountDetail {
/** /**
* 实际返回订单款 * 实际返回订单款 账单的的orderAmount 对应的是 订单的商品金额
*/ */
BigDecimal orderAmount; BigDecimal orderAmount;
/** /**
...@@ -17,7 +17,7 @@ public class OrderAccountDetail { ...@@ -17,7 +17,7 @@ public class OrderAccountDetail {
*/ */
BigDecimal depositAmount; BigDecimal depositAmount;
/** /**
* 原来要返回的订单款 * 原来要返回的订单款 账单的的orderAmount 对应的是 订单的商品金额
*/ */
BigDecimal originOrderAmount; BigDecimal originOrderAmount;
/** /**
......
...@@ -23,6 +23,11 @@ public class InProgressVO { ...@@ -23,6 +23,11 @@ public class InProgressVO {
*/ */
BigDecimal extraAmount = BigDecimal.ZERO; BigDecimal extraAmount = BigDecimal.ZERO;
/**
* 实际消费金额
*/
BigDecimal consumeAmount = BigDecimal.ZERO;
/** /**
* 已使用天数 * 已使用天数
*/ */
......
...@@ -30,6 +30,7 @@ public class OrderListVo extends BaseOrder { ...@@ -30,6 +30,7 @@ public class OrderListVo extends BaseOrder {
private String endCompanyName; private String endCompanyName;
private String realName;
/** /**
* 是否是用户匹配公司 * 是否是用户匹配公司
*/ */
......
package com.xxfc.platform.order.pojo.price;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class CancelNoStartVO extends CostDetailExtend{
/**
* 违约金描述
*/
private String violateDesc;
/**
* 违约金额
*/
private BigDecimal violateAmount = BigDecimal.ZERO;
public CancelNoStartVO() {
this.type = CANCEL_NO_START;
}
}
package com.xxfc.platform.order.pojo.price;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class CancelStartedVO extends CostDetailExtend {
/**
* 消费金额(实际计费)
*/
private BigDecimal consumeAmount;
/**
* 租车单价
*/
private BigDecimal modelAmount;
/**
* 使用天数
*/
private Integer usedDayNum;
/**
* 使用金额
*/
private BigDecimal usedAmount;
/**
* 使用免费天数
*/
private Integer usedfreeDayNum;
/**
* 使用免费金额
*/
private BigDecimal usedFreeAmount;
/**
* 违约金描述
*/
private String violateDesc;
/**
* 违约金金额
*/
private BigDecimal violateAmount;
}
package com.xxfc.platform.order.pojo.price;
import lombok.Data;
@Data
public class CostDetailExtend {
public static final int CANCEL_NO_START = 1;
public static final int CANCEL_STARTED = 2;
public static final int FINLISH_ADVANCE = 3;
public static final int FINLISH_DELAY = 4;
private String costDetail;
/**
* type:1--取消违约金;2--取消费用明细;3--提前还车费用明细;4--延期还车费用明细
*/
protected Integer type;
}
...@@ -7,7 +7,7 @@ import java.math.BigDecimal; ...@@ -7,7 +7,7 @@ import java.math.BigDecimal;
@Data @Data
public class OrderPriceVO { public class OrderPriceVO {
@ApiModelProperty(value = "订单价格") @ApiModelProperty(value = "订单总金额")
public BigDecimal orderAmount; public BigDecimal orderAmount;
@ApiModelProperty(value = "商品价格") @ApiModelProperty(value = "商品价格")
public BigDecimal goodsAmount; public BigDecimal goodsAmount;
......
...@@ -180,7 +180,6 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -180,7 +180,6 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
getDriverInfo(orderPageVo); getDriverInfo(orderPageVo);
} else if (orderPageVo.getStatus() >= 5 || orderPageVo.getStatus() == -1) {//出行中 已交车 } else if (orderPageVo.getStatus() >= 5 || orderPageVo.getStatus() == -1) {//出行中 已交车
//设置违约金金额 //设置违约金金额
updateCrossRefund(orderPageVo);
getDriverInfo(orderPageVo); getDriverInfo(orderPageVo);
getUserLicense(orderPageVo); getUserLicense(orderPageVo);
} }
...@@ -261,10 +260,10 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -261,10 +260,10 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
//提前的天数, 当天就算使用一天 //提前的天数, 当天就算使用一天
int noUsedDay = getDaysBetweenDateTime(nowTime, endTime) - 1; int noUsedDay = getDaysBetweenDateTime(nowTime, endTime) - 1;
//退还未使用的天数,或者金额,扣除违约金,实际未使用天数的金额,最多3000元 //退还未使用的天数,或者金额,扣除违约金,实际未使用天数的金额,最多3000元
InProgressVO inProgressVO = new InProgressVO(); // InProgressVO inProgressVO = new InProgressVO();
inProgressVO.setViolateAmount(new BigDecimal(200)); // inProgressVO.setViolateAmount(new BigDecimal(200));
inProgressVO.setExtraAmount(new BigDecimal(200)); // inProgressVO.setExtraAmount(new BigDecimal(200));
//InProgressVO inProgressVO = orderCalculateBiz.inProgressCalculate(orderPageVO, actualDay - noUsedDay); InProgressVO inProgressVO = orderCalculateBiz.inProgressCalculate(orderPageVO, actualDay - noUsedDay);
if (inProgressVO != null) { if (inProgressVO != null) {
//消费超额金 //消费超额金
if(inProgressVO.getExtraAmount() != null) { if(inProgressVO.getExtraAmount() != null) {
...@@ -330,7 +329,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -330,7 +329,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
orderVehicleCrosstownDto.setLicenseName(orderUserLicenses.get(0).getLicenseName()); orderVehicleCrosstownDto.setLicenseName(orderUserLicenses.get(0).getLicenseName());
orderVehicleCrosstownDto.setLicensePhone(orderUserLicenses.get(0).getLicensePhone()); orderVehicleCrosstownDto.setLicensePhone(orderUserLicenses.get(0).getLicensePhone());
} }
//设置保留金 //设置违约明细
for (OrderVehicleCrosstownDto a : orderVehicleCrosstown) { for (OrderVehicleCrosstownDto a : orderVehicleCrosstown) {
if(a.getType() != CrosstownTypeEnum.DEPARTURE.getCode()) { if(a.getType() != CrosstownTypeEnum.DEPARTURE.getCode()) {
if(StringUtils.isNotBlank(a.getViolateDetail())) { if(StringUtils.isNotBlank(a.getViolateDetail())) {
...@@ -339,6 +338,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -339,6 +338,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
} }
} }
} }
if (StringUtils.isBlank(orderPageVo.getDedDetailDTO())) {
updateCrossRefund(orderPageVo);
}
orderPageVo.setOrderVehicleCrosstownDto(orderVehicleCrosstownDto); orderPageVo.setOrderVehicleCrosstownDto(orderVehicleCrosstownDto);
} }
...@@ -433,8 +435,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -433,8 +435,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
//订单账款类 //订单账款类
OrderAccountDetail oad = new OrderAccountDetail(); OrderAccountDetail oad = new OrderAccountDetail();
oad.setOriginOrderAmount(baseOrder.getRealAmount()); oad.setOriginOrderAmount(baseOrder.getGoodsAmount());
oad.setOrderAmount(baseOrder.getRealAmount()); //账单的的orderAmount 对应 的是商品金额
oad.setOrderAmount(baseOrder.getGoodsAmount());
//如果是会员订单,则触发会员效益 //如果是会员订单,则触发会员效益
if (OrderTypeEnum.MEMBER.getCode().equals(baseOrder.getType())) { if (OrderTypeEnum.MEMBER.getCode().equals(baseOrder.getType())) {
......
package com.xxfc.platform.order.biz; package com.xxfc.platform.order.biz;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.google.common.collect.Lists;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.DailyMembersOrderStatistics; import com.xxfc.platform.order.entity.DailyMembersOrderStatistics;
import com.xxfc.platform.order.entity.OrderAccount;
import com.xxfc.platform.order.entity.OrderStatistics; import com.xxfc.platform.order.entity.OrderStatistics;
import com.xxfc.platform.order.mapper.DailyMembersOrderStatisticsMapper; import com.xxfc.platform.order.mapper.DailyMembersOrderStatisticsMapper;
import com.xxfc.platform.order.pojo.account.OrderAccountDTO;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.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.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -33,31 +42,31 @@ public class DailyMembersOrderStatisticsBiz extends BaseBiz<DailyMembersOrderSta ...@@ -33,31 +42,31 @@ public class DailyMembersOrderStatisticsBiz extends BaseBiz<DailyMembersOrderSta
@Value("${order.day}") @Value("${order.day}")
private Integer day; private Integer day;
/**
* 总公司id默认为1
*/
private final Integer OMPANY_ID=1;
@Autowired
private OrderAccountBiz accountBiz;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean memberOrderStatistics() { public boolean saveDailyMembersOrderRecord() {
try { try {
List<OrderAccountDTO> accountList = accountBiz.getOrderAccountByOrderType(OrderTypeEnum.MEMBER.getCode(), day);
Map<String, Object> travelGmv = mapper.getTravelGmv(day); if (CollectionUtils.isNotEmpty(accountList)) {
if (travelGmv.isEmpty()) { DailyMembersOrderStatistics orderStatistics = new DailyMembersOrderStatistics();
return true; ArrayList<OrderAccountDetail> orderAccountDetails = getOrderAccountDetail(accountList);
} if (CollectionUtils.isNotEmpty(orderAccountDetails)) {
//获取订单总额
BigDecimal gmv = getOrderAmountTotal(orderAccountDetails);
DailyMembersOrderStatistics MembersStatistics = new DailyMembersOrderStatistics(); orderStatistics.setGmv(gmv);
BeanUtils.copyProperties(MembersStatistics, travelGmv); orderStatistics.setBranchCompanyId(OMPANY_ID);
orderStatistics.setOneDay(accountList.get(0).getOneDay());
String oneDay = MembersStatistics.getOneDay(); }
insertSelectiveRe(orderStatistics);
if (StringUtils.isBlank(oneDay)) {
throw new BaseException();
} }
Example exa = new Example(DailyMembersOrderStatistics.class);
exa.createCriteria().andEqualTo("oneDay", oneDay);
List<DailyMembersOrderStatistics> statistics = selectByExample(exa);
if (CollectionUtils.isEmpty(statistics)) {
insertSelective(MembersStatistics);
}
return true; return true;
} catch (Exception e) { } catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
...@@ -66,6 +75,37 @@ public class DailyMembersOrderStatisticsBiz extends BaseBiz<DailyMembersOrderSta ...@@ -66,6 +75,37 @@ public class DailyMembersOrderStatisticsBiz extends BaseBiz<DailyMembersOrderSta
} }
} }
/**
* 获取押金和
*
* @param orderAccountDetails
* @return
*/
private BigDecimal getOrderAmountTotal(ArrayList<OrderAccountDetail> orderAccountDetails) {
return orderAccountDetails.stream()
.map(OrderAccountDetail::getOrderAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
}
/**
* 获取所有订单详情数据
*
* @param orderAccountDTOS
* @return
*/
private ArrayList<OrderAccountDetail> getOrderAccountDetail(List<OrderAccountDTO> orderAccountDTOS) {
ArrayList<OrderAccountDetail> arrayList = Lists.newArrayList();
orderAccountDTOS.parallelStream()
.map(OrderAccount::getAccountDetail)
.forEach(detail -> {
if (StringUtils.isNotBlank(detail)) {
arrayList.add(JSONUtil.toBean(detail, OrderAccountDetail.class));
}
});
return arrayList;
}
@Override @Override
public int insertSelectiveRe(DailyMembersOrderStatistics entity) { public int insertSelectiveRe(DailyMembersOrderStatistics entity) {
Date date = new Date(); Date date = new Date();
......
...@@ -27,9 +27,9 @@ public class DailyOrderStatisticsBiz extends BaseBiz<DailyOrderStatisticsMapper, ...@@ -27,9 +27,9 @@ public class DailyOrderStatisticsBiz extends BaseBiz<DailyOrderStatisticsMapper,
@Scheduled(cron = "0 0 2 * * ?") @Scheduled(cron = "0 0 2 * * ?")
public boolean statisticalOrder(){ public boolean statisticalOrder(){
boolean vehicleFlag = vehicleStatisticsBiz.StatisticsOfCarRentalOrders(); boolean vehicleFlag = vehicleStatisticsBiz.saveDailyVehicleOrderRecord();
boolean travelFlag = travelStatisticsBiz.StatisticsOfTravelOrders(); boolean travelFlag = travelStatisticsBiz.saveDailyTravelOrderRecord();
boolean membersFlag= membersStatisticsBiz.memberOrderStatistics(); boolean membersFlag= membersStatisticsBiz.saveDailyMembersOrderRecord();
if (vehicleFlag&&travelFlag&&membersFlag){ if (vehicleFlag&&travelFlag&&membersFlag){
log.info("----statisticalOrder:成功-----"); log.info("----statisticalOrder:成功-----");
return true; return true;
......
...@@ -2,20 +2,33 @@ package com.xxfc.platform.order.biz; ...@@ -2,20 +2,33 @@ package com.xxfc.platform.order.biz;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xxfc.platform.order.contant.enumerate.DeductionTypeEnum;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.contant.enumerate.RefundTypeEnum;
import com.xxfc.platform.order.entity.DailyTravelOrderStatistics; import com.xxfc.platform.order.entity.DailyTravelOrderStatistics;
import com.xxfc.platform.order.entity.OrderAccount;
import com.xxfc.platform.order.entity.OrderStatistics; import com.xxfc.platform.order.entity.OrderStatistics;
import com.xxfc.platform.order.mapper.DailyTravelOrderStatisticsMapper; import com.xxfc.platform.order.mapper.DailyTravelOrderStatisticsMapper;
import com.xxfc.platform.order.pojo.account.OrderAccountDTO;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
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.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -30,64 +43,258 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati ...@@ -30,64 +43,258 @@ public class DailyTravelOrderStatisticsBiz extends BaseBiz<DailyTravelOrderStati
@Value("${order.day}") @Value("${order.day}")
private Integer day; private Integer day;
@Transactional(rollbackFor = Exception.class)
public boolean StatisticsOfTravelOrders() {
try {
ArrayList<DailyTravelOrderStatistics> objects = new ArrayList<>(); @Autowired
List<DailyTravelOrderStatistics> travelGmv = mapper.getTravelGmv(day); private OrderAccountBiz accountBiz;
objects.addAll(travelGmv); // @Transactional(rollbackFor = Exception.class)
List<DailyTravelOrderStatistics> travelPenalSum = mapper.getTravelPenalSum(day); // public boolean StatisticsOfTravelOrders() {
objects.addAll(travelPenalSum); // try {
insertByList(objects); //
// ArrayList<DailyTravelOrderStatistics> objects = new ArrayList<>();
// List<DailyTravelOrderStatistics> travelGmv = mapper.getTravelGmv(day);
// objects.addAll(travelGmv);
// List<DailyTravelOrderStatistics> travelPenalSum = mapper.getTravelPenalSum(day);
// objects.addAll(travelPenalSum);
// insertByList(objects);
//
// return true;
// } catch (Exception e) {
// e.printStackTrace();
// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
// return false;
// }
// }
//
// private void insertByList(ArrayList<DailyTravelOrderStatistics> objects) throws Exception {
//
// if (CollectionUtils.isNotEmpty(objects)) {
// HashMap<Integer, DailyTravelOrderStatistics> map = new HashMap<>();
// for (DailyTravelOrderStatistics object : objects) {
//
// DailyTravelOrderStatistics statistics = map.get(object.getBranchCompanyId());
// if (statistics == null) {
// statistics = new DailyTravelOrderStatistics();
// map.put(object.getBranchCompanyId(), statistics);
// }
//
// BeanUtil.copyProperties(object, statistics, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
//
// }
// String oneDay = map.entrySet().parallelStream().map(Map.Entry::getValue).collect(Collectors.toList()).get(0).getOneDay();
//
// if (StringUtils.isBlank(oneDay)) {
// throw new BaseException();
// }
// Example exa= new Example(DailyTravelOrderStatistics.class);
// exa.createCriteria().andEqualTo("oneDay",oneDay);
// List<DailyTravelOrderStatistics> statistics= selectByExample(exa);
// if (CollectionUtils.isEmpty(statistics)){
// for (Map.Entry<Integer, DailyTravelOrderStatistics> entry : map.entrySet()) {
// insertSelectiveRe(entry.getValue());
// }
// }else {
// log.error("今日已统计车辆订单,请不要重复统计!");
// }
//
////
//// for (Map.Entry<Integer, DailyTravelOrderStatistics> e : map.entrySet()) {
//// insertSelectiveRe(e.getValue());
//// }
// }
// }
/******************************************************************************************************************************/
/**
* 统计订单并保存到数据库当中
* @return
*/
@Transactional(rollbackFor = Exception.class)
public boolean saveDailyTravelOrderRecord() {
try {
//获取每日订单统计
List<DailyTravelOrderStatistics> orderStatistics = getDailyTravelOrderStatistics();
if (CollectionUtils.isNotEmpty(orderStatistics)) {
for (DailyTravelOrderStatistics orderStatistic : orderStatistics) {
//保存统计
insertSelectiveRe(orderStatistic);
}
}
return true; return true;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error(e.getMessage());
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return false; return false;
} }
} }
private void insertByList(ArrayList<DailyTravelOrderStatistics> objects) throws Exception { private List<DailyTravelOrderStatistics> getDailyTravelOrderStatistics() {
//获取当天所有订单账目
List<OrderAccountDTO> accountList = accountBiz.getOrderAccountByOrderType(OrderTypeEnum.TOUR.getCode(), day);
if (CollectionUtils.isEmpty(accountList)) {
return null;
}
//获取每个分公司,当天所有的订单帐目
HashMap<Integer, List<OrderAccountDTO>> companyIdmap = new HashMap<>();
for (OrderAccountDTO orderAccountDTO : accountList) {
List<OrderAccountDTO> list = companyIdmap.get(orderAccountDTO.getCompanyId());
if (list == null) {
list = new ArrayList<>();
companyIdmap.put(orderAccountDTO.getCompanyId(), list);
}
list.add(orderAccountDTO);
}
if (CollectionUtils.isNotEmpty(objects)) { //获取每个公司当天订单的总数据
HashMap<Integer, DailyTravelOrderStatistics> map = new HashMap<>(); ArrayList<DailyTravelOrderStatistics> statistics = new ArrayList<>();
for (DailyTravelOrderStatistics object : objects) { for (Map.Entry<Integer, List<OrderAccountDTO>> integerListEntry : companyIdmap.entrySet()) {
//获取不同类型的账单详情
List<OrderAccountDTO> orderAccountDTOS = integerListEntry.getValue();
if (CollectionUtils.isNotEmpty(orderAccountDTOS)) {
Map<Integer, List<OrderAccountDTO>> typeMap = Maps.newHashMap();
for (OrderAccountDTO orderAccountDTO : orderAccountDTOS) {
List<OrderAccountDTO> list = typeMap.get(orderAccountDTO.getAccountType());
if (list == null) {
list = new ArrayList<>();
companyIdmap.put(orderAccountDTO.getAccountType(), list);
}
list.add(orderAccountDTO);
}
DailyTravelOrderStatistics statistics = map.get(object.getBranchCompanyId()); if (MapUtils.isNotEmpty(typeMap)) {
if (statistics == null) { //获取该公司当天的账单数据
statistics = new DailyTravelOrderStatistics(); if (CollectionUtils.isNotEmpty(orderAccountDTOS)) {
map.put(object.getBranchCompanyId(), statistics); DailyTravelOrderStatistics dvos = getStatisticsByOrderAccountDetail(typeMap);
if (dvos != null) {
statistics.add(dvos);
dvos.setBranchCompanyId(integerListEntry.getKey());
dvos.setOneDay(orderAccountDTOS.get(0).getOneDay());
}
}
} }
}
}
return statistics;
}
BeanUtil.copyProperties(object, statistics, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true)); private DailyTravelOrderStatistics getStatisticsByOrderAccountDetail(Map<Integer, List<OrderAccountDTO>> map) {
//获取收入金额
DailyTravelOrderStatistics orderStatistics = getGmvAndSecurityDeposit(map);
//获取扣款和退还金额
refundAndDeductions(map, orderStatistics);
return orderStatistics;
}
/**
* 获取扣款和退款金额
*
* @param map
* @param orderStatistics
*/
private void refundAndDeductions(Map<Integer, List<OrderAccountDTO>> map, DailyTravelOrderStatistics orderStatistics) {
ArrayList<OrderAccountDTO> arrayList = Lists.newArrayList();
for (Integer key : map.keySet()) {
if (!key.equals(RefundTypeEnum.ORDER_FUND.getCode())) {
arrayList.addAll(map.get(key));
} }
String oneDay = map.entrySet().parallelStream().map(Map.Entry::getValue).collect(Collectors.toList()).get(0).getOneDay(); }
if (CollectionUtils.isNotEmpty(arrayList)) {
ArrayList<OrderAccountDetail> orderAccountDetail = getOrderAccountDetail(arrayList);
if (CollectionUtils.isNotEmpty(orderAccountDetail)) {
List<OrderAccountDeduction> OrderAccountDeductions = gettDeductions(orderAccountDetail);
//获取违约总额
BigDecimal bigDecimal = get(OrderAccountDeductions, new ArrayList<Integer>() {{
add(DeductionTypeEnum.VIOLATE_CANCEL.getCode());
}});
orderStatistics.setDefaultMoney(bigDecimal);
//订单退还总额
orderStatistics.setReturnGmv(orderStatistics.getGmv().subtract(bigDecimal));
if (StringUtils.isBlank(oneDay)) {
throw new BaseException();
} }
Example exa= new Example(DailyTravelOrderStatistics.class); }
exa.createCriteria().andEqualTo("oneDay",oneDay); }
List<DailyTravelOrderStatistics> statistics= selectByExample(exa);
if (CollectionUtils.isEmpty(statistics)){
for (Map.Entry<Integer, DailyTravelOrderStatistics> entry : map.entrySet()) {
insertSelectiveRe(entry.getValue()); private DailyTravelOrderStatistics getGmvAndSecurityDeposit(Map<Integer, List<OrderAccountDTO>> map) {
} DailyTravelOrderStatistics orderStatistics = new DailyTravelOrderStatistics();
}else { List<OrderAccountDTO> orderAccountDTOS = map.get(RefundTypeEnum.ORDER_FUND.getCode());
log.error("今日已统计车辆订单,请不要重复统计!");
if (CollectionUtils.isNotEmpty(orderAccountDTOS)) {
ArrayList<OrderAccountDetail> orderAccountDetails = getOrderAccountDetail(orderAccountDTOS);
if (CollectionUtils.isNotEmpty(orderAccountDetails)) {
//获取订单总额
BigDecimal gmv = getOrderAmountTotal(orderAccountDetails);
orderStatistics.setGmv(gmv);
} }
}
return orderStatistics;
}
// /**
// for (Map.Entry<Integer, DailyTravelOrderStatistics> e : map.entrySet()) { * 获取金额详情
// insertSelectiveRe(e.getValue()); *
// } * @param orderAccountDTOS
* @return
*/
private ArrayList<OrderAccountDetail> getOrderAccountDetail(List<OrderAccountDTO> orderAccountDTOS) {
ArrayList<OrderAccountDetail> arrayList = Lists.newArrayList();
orderAccountDTOS.parallelStream()
.map(OrderAccount::getAccountDetail)
.forEach(detail -> {
if (StringUtils.isNotBlank(detail)) {
arrayList.add(JSONUtil.toBean(detail, OrderAccountDetail.class));
}
});
return arrayList;
}
/**
* 获取订单和
*
* @param orderAccountDetails
* @return
*/
private BigDecimal getOrderAmountTotal(ArrayList<OrderAccountDetail> orderAccountDetails) {
return orderAccountDetails.stream()
.map(OrderAccountDetail::getOrderAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
}
/**
* 获取赔款数据
*
* @param orderAccountDetails
* @return
*/
private List<OrderAccountDeduction> gettDeductions(ArrayList<OrderAccountDetail> orderAccountDetails) {
ArrayList<OrderAccountDeduction> arrayList = Lists.newArrayList();
for (OrderAccountDetail orderAccountDetail : orderAccountDetails) {
arrayList.addAll(orderAccountDetail.getDeductions());
} }
return arrayList;
} }
/**
* 根据type获取对应的金额总和
*
* @param OrderAccountDeduction
* @param type 金额类型
* @return
*/
private BigDecimal get(List<OrderAccountDeduction> OrderAccountDeduction, List<Integer> type) {
return OrderAccountDeduction.parallelStream()
.filter(el -> el.getType().equals(type))
.map(com.xxfc.platform.order.pojo.account.OrderAccountDeduction::getAmount)
.reduce(BigDecimal.ZERO,BigDecimal::add);
}
@Override @Override
public int insertSelectiveRe(DailyTravelOrderStatistics entity) { public int insertSelectiveRe(DailyTravelOrderStatistics entity) {
entity.setCrtTime(new Date()); entity.setCrtTime(new Date());
......
...@@ -2,29 +2,35 @@ package com.xxfc.platform.order.biz; ...@@ -2,29 +2,35 @@ package com.xxfc.platform.order.biz;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.db.sql.Order;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.xxfc.platform.order.entity.DailyOrderStatistics; import com.github.wxiaoqi.security.common.util.JsonUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xxfc.platform.order.contant.enumerate.DeductionTypeEnum;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.contant.enumerate.RefundTypeEnum;
import com.xxfc.platform.order.entity.DailyVehicleOrderStatistics; import com.xxfc.platform.order.entity.DailyVehicleOrderStatistics;
import com.xxfc.platform.order.entity.OrderAccount;
import com.xxfc.platform.order.entity.OrderStatistics; import com.xxfc.platform.order.entity.OrderStatistics;
import com.xxfc.platform.order.mapper.DailyVehicleOrderStatisticsMapper; import com.xxfc.platform.order.mapper.DailyVehicleOrderStatisticsMapper;
import com.xxfc.platform.order.pojo.DedDetailDTO; import com.xxfc.platform.order.pojo.account.OrderAccountDTO;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
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.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import sun.rmi.runtime.Log;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls;
import javax.print.attribute.standard.MediaSize;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 每日租车订单统计 * 每日租车订单统计
...@@ -34,185 +40,430 @@ import java.util.stream.Collectors; ...@@ -34,185 +40,430 @@ import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderStatisticsMapper, DailyVehicleOrderStatistics> { public class DailyVehicleOrderStatisticsBiz extends BaseBiz<DailyVehicleOrderStatisticsMapper, DailyVehicleOrderStatistics> {
/**
* 延期
*/
private final Integer TYPE_DEFERRED = 1; private final Integer TYPE_DEFERRED = 1;
/**
* 损坏
*/
private final Integer TYPE_DAMAGE = 2; private final Integer TYPE_DAMAGE = 2;
/**
* 其他
*/
private final Integer TYPE_OTHER = 3; private final Integer TYPE_OTHER = 3;
/**
* 统计几天前的数据
*/
@Value("${order.day}") @Value("${order.day}")
private Integer day; private Integer day;
@Transactional(rollbackFor = Exception.class)
public boolean StatisticsOfCarRentalOrders() {
try {
ArrayList<DailyVehicleOrderStatistics> result = new ArrayList<>();
// 获取每日租车订单成交金和押金总额 @Autowired
List<DailyVehicleOrderStatistics> gmvAndMarginTotal = mapper.getGmvAndMarginTotal(day); private OrderAccountBiz accountBiz;
result.addAll(gmvAndMarginTotal);
// @Transactional(rollbackFor = Exception.class)
// public boolean StatisticsOfCarRentalOrders() {
//
// try {
//
// ArrayList<DailyVehicleOrderStatistics> result = new ArrayList<>();
//
//// 获取每日租车订单成交金和押金总额
// List<DailyVehicleOrderStatistics> gmvAndMarginTotal = mapper.getGmvAndMarginTotal(day);
// result.addAll(gmvAndMarginTotal);
//
//// 获取取消订单扣款总额
// List<DailyVehicleOrderStatistics> penalSum = mapper.getPenalSum(day);
// result.addAll(penalSum);
//
//// 获取订单退还押金总额
// List<DailyVehicleOrderStatistics> refundSecurityDeposit = mapper.getRefundSecurityDeposit(day);
// result.addAll(refundSecurityDeposit);
//
//// 获取违章查询总和
// List<DailyVehicleOrderStatistics> violationMoney = mapper.getViolationMoney(day);
// result.addAll(violationMoney);
//
//// 获取赔偿和延期JSON字符串
// List<Map> compensationAndPostpone = mapper.getCompensationAndPostpone(day);
//// 获取赔偿和延期JSON字符串转换为map
// List<DailyVehicleOrderStatistics> compensationAndPostpones = getCompensationAndPostpones(compensationAndPostpone);
// result.addAll(compensationAndPostpones);
//
// InsertByList(result);
// return true;
// } catch (Exception e) {
// e.printStackTrace();
// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
// return false;
// }
//
// }
//
// private void InsertByList(ArrayList<DailyVehicleOrderStatistics> result) throws Exception {
// if (CollectionUtils.isNotEmpty(result)) {
//
// Map<Integer, DailyVehicleOrderStatistics> map = new HashMap<>();
//
// for (DailyVehicleOrderStatistics value : result) {
// Integer branchCompanyId = value.getBranchCompanyId();
// DailyVehicleOrderStatistics statistics = map.get(branchCompanyId);
//
// if (statistics == null) {
// statistics = new DailyVehicleOrderStatistics();
// map.put(branchCompanyId, statistics);
// }
// BeanUtil.copyProperties(
// value,
// statistics,
// CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
// }
//
// String oneDay = map.entrySet().parallelStream().map(Map.Entry::getValue).collect(Collectors.toList()).get(0).getOneDay();
// if (StringUtils.isBlank(oneDay)) {
// throw new BaseException();
// }
// Example exa = new Example(DailyVehicleOrderStatistics.class);
// exa.createCriteria().andEqualTo("oneDay", oneDay);
// List<DailyVehicleOrderStatistics> statistics = selectByExample(exa);
//
// if (CollectionUtils.isEmpty(statistics)) {
// for (Map.Entry<Integer, DailyVehicleOrderStatistics> entry : map.entrySet()) {
// insertSelectiveRe(entry.getValue());
// }
// } else {
// log.error("今日已统计车辆订单,请不要重复统计!");
// }
// }
//
// }
//
//
// /**
// * 获取赔偿总额和延期总额
// */
// private List<DailyVehicleOrderStatistics> getCompensationAndPostpones(List<Map> list) {
//
// if (CollectionUtils.isNotEmpty(list)) {
// //获取分公全部赔偿和延期DedDetailDTO
// HashMap<Integer, List<DedDetailDTO>> map = new HashMap<>();
//
// for (Map value : list) {
// if (value != null) {
//
// //获取分公司id
// Integer branchCompanyId = (Integer) value.get("branchCompanyId");
// List<DedDetailDTO> strings = map.get(branchCompanyId);
// if (strings == null) {
// strings = new ArrayList<DedDetailDTO>();
// map.put(branchCompanyId, strings);
// }
//
// String str = (String) value.get("dedDetail");
//
// if (StringUtils.isNotBlank(str)) {
// List<DedDetailDTO> dedDetailDTOS = JSON.parseArray(str, DedDetailDTO.class);
// if (CollectionUtils.isNotEmpty(dedDetailDTOS)) {
// strings.addAll(dedDetailDTOS);
// }
// }
// }
//
// }
//
//
// List<DailyVehicleOrderStatistics> result = new ArrayList<>();
//
// if (!map.isEmpty()) {
//
// //获取分工对象集合
// for (Map.Entry<Integer, List<DedDetailDTO>> entry : map.entrySet()) {
// DailyVehicleOrderStatistics statistics = new DailyVehicleOrderStatistics();
// //公司id添加到对象当中
// statistics.setBranchCompanyId(entry.getKey());
//
// //获取公司的JSON字符串
// List<DedDetailDTO> sumDedDetailDTOs = entry.getValue();
//
//// 获取赔偿金额总和
// BigDecimal compensation = get(sumDedDetailDTOs, TYPE_DAMAGE);
// statistics.setCompensation(compensation);
//// 获取延期金额总和
// BigDecimal postpone = get(sumDedDetailDTOs, TYPE_DEFERRED);
// statistics.setPostpone(postpone);
////// 其他款项总金额
//// BigDecimal other = get(sumDedDetailDTOs, TYPE_OTHER);
//
// result.add(statistics);
// }
//
// }
//
//
// return result;
// }
// return new ArrayList<>();
// }
/****************************************************************************************************************************/
// 获取取消订单扣款总额
List<DailyVehicleOrderStatistics> penalSum = mapper.getPenalSum(day);
result.addAll(penalSum);
// 获取订单退还押金总额 /**
List<DailyVehicleOrderStatistics> refundSecurityDeposit = mapper.getRefundSecurityDeposit(day); * 根据type获取对应的金额总和
result.addAll(refundSecurityDeposit); *
* @param OrderAccountDeduction
// 获取违章查询总和 * @param types 金额类型
List<DailyVehicleOrderStatistics> violationMoney = mapper.getViolationMoney(day); * @return
result.addAll(violationMoney); */
private BigDecimal get(List<OrderAccountDeduction> OrderAccountDeduction, List<Integer> types) {
// 获取赔偿和延期JSON字符串 return OrderAccountDeduction.parallelStream()
List<Map> compensationAndPostpone = mapper.getCompensationAndPostpone(day); .filter(el -> types.contains(el))
// 获取赔偿和延期JSON字符串转换为map .map(com.xxfc.platform.order.pojo.account.OrderAccountDeduction::getAmount)
List<DailyVehicleOrderStatistics> compensationAndPostpones = getCompensationAndPostpones(compensationAndPostpone); .reduce(BigDecimal.ZERO,BigDecimal::add);
result.addAll(compensationAndPostpones);
InsertByList(result); }
return true;
} catch (Exception e) {
e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return false;
}
/***
* 添加每日记录
* @param entity
* @return
*/
@Override
public int insertSelectiveRe(DailyVehicleOrderStatistics entity) {
entity.setCrtTime(new Date());
return mapper.insertSelective(entity);
} }
private void InsertByList(ArrayList<DailyVehicleOrderStatistics> result) throws Exception {
if (CollectionUtils.isNotEmpty(result)) {
Map<Integer, DailyVehicleOrderStatistics> map = new HashMap<>(); public OrderStatistics findAll(Integer companyId) {
return mapper.monthOrderTotal(companyId);
}
for (DailyVehicleOrderStatistics value : result) { /**
Integer branchCompanyId = value.getBranchCompanyId(); * 统计订单并保存到数据库当中
DailyVehicleOrderStatistics statistics = map.get(branchCompanyId); * @return
*/
@Transactional(rollbackFor = Exception.class)
public boolean saveDailyVehicleOrderRecord() {
if (statistics == null) { try {
statistics = new DailyVehicleOrderStatistics(); //获取每日订单统计
map.put(branchCompanyId, statistics); List<DailyVehicleOrderStatistics> orderStatistics = getDailyVehicleOrderRecord();
if (CollectionUtils.isNotEmpty(orderStatistics)) {
for (DailyVehicleOrderStatistics orderStatistic : orderStatistics) {
//保存统计
insertSelectiveRe(orderStatistic);
} }
BeanUtil.copyProperties(
value,
statistics,
CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
} }
String oneDay = map.entrySet().parallelStream().map(Map.Entry::getValue).collect(Collectors.toList()).get(0).getOneDay(); return true;
if (StringUtils.isBlank(oneDay)) { } catch (Exception e) {
throw new BaseException(); log.error(e.getMessage());
} return false;
Example exa= new Example(DailyVehicleOrderStatistics.class);
exa.createCriteria().andEqualTo("oneDay",oneDay);
List<DailyVehicleOrderStatistics> statistics= selectByExample(exa);
if (CollectionUtils.isEmpty(statistics)){
for (Map.Entry<Integer, DailyVehicleOrderStatistics> entry : map.entrySet()) {
insertSelectiveRe(entry.getValue());
}
}else {
log.error("今日已统计车辆订单,请不要重复统计!");
}
} }
} }
/** /**
* 获取赔偿总额和延期总额 * 获取所有分公司每日统计记录
* @return
*/ */
private List<DailyVehicleOrderStatistics> getCompensationAndPostpones(List<Map> list) { private List<DailyVehicleOrderStatistics> getDailyVehicleOrderRecord() {
//获取当天所有订单账目
List<OrderAccountDTO> accountList = accountBiz.getOrderAccountByOrderType(OrderTypeEnum.RENT_VEHICLE.getCode(), day);
if (CollectionUtils.isEmpty(accountList)) {
return null;
}
//获取每个分公司当天所有的订单帐目
HashMap<Integer, List<OrderAccountDTO>> companyIdmap = new HashMap<>();
for (OrderAccountDTO orderAccountDTO : accountList) {
List<OrderAccountDTO> list = companyIdmap.get(orderAccountDTO.getCompanyId());
if (list == null) {
list = new ArrayList<>();
companyIdmap.put(orderAccountDTO.getCompanyId(), list);
}
list.add(orderAccountDTO);
}
if (CollectionUtils.isNotEmpty(list)) { //获取每个公司当天订单的总数据
//获取分公全部赔偿和延期DedDetailDTO ArrayList<DailyVehicleOrderStatistics> statistics = new ArrayList<>();
HashMap<Integer, List<DedDetailDTO>> map = new HashMap<>(); for (Map.Entry<Integer, List<OrderAccountDTO>> integerListEntry : companyIdmap.entrySet()) {
//获取不同类型的账单详情
List<OrderAccountDTO> orderAccountDTOS = integerListEntry.getValue();
if (CollectionUtils.isNotEmpty(orderAccountDTOS)) {
Map<Integer, List<OrderAccountDTO>> typeMap = Maps.newHashMap();
for (OrderAccountDTO orderAccountDTO : orderAccountDTOS) {
for (Map value : list) { List<OrderAccountDTO> list = typeMap.get(orderAccountDTO.getAccountType());
if (value != null) { if (list == null) {
list = new ArrayList<>();
companyIdmap.put(orderAccountDTO.getAccountType(), list);
//获取分公司id
Integer branchCompanyId = (Integer) value.get("branchCompanyId");
List<DedDetailDTO> strings = map.get(branchCompanyId);
if (strings == null) {
strings = new ArrayList<DedDetailDTO>();
map.put(branchCompanyId, strings);
} }
list.add(orderAccountDTO);
}
String str = (String) value.get("dedDetail"); if (MapUtils.isNotEmpty(typeMap)) {
//获取该公司当天的账单数据
if (StringUtils.isNotBlank(str)) { if (CollectionUtils.isNotEmpty(orderAccountDTOS)) {
List<DedDetailDTO> dedDetailDTOS = JSON.parseArray(str, DedDetailDTO.class); DailyVehicleOrderStatistics dvos = getStatisticsByOrderAccountDetail(typeMap);
if (CollectionUtils.isNotEmpty(dedDetailDTOS)) { if (dvos != null) {
strings.addAll(dedDetailDTOS); statistics.add(dvos);
dvos.setBranchCompanyId(integerListEntry.getKey());
dvos.setOneDay(orderAccountDTOS.get(0).getOneDay());
} }
} }
} }
} }
}
return statistics;
}
List<DailyVehicleOrderStatistics> result = new ArrayList<>();
if (!map.isEmpty()) {
//获取分工对象集合 /**
for (Map.Entry<Integer, List<DedDetailDTO>> entry : map.entrySet()) { * 获取该分公司的统计数据
DailyVehicleOrderStatistics statistics = new DailyVehicleOrderStatistics(); * @param map
//公司id添加到对象当中 * @return
statistics.setBranchCompanyId(entry.getKey()); */
private DailyVehicleOrderStatistics getStatisticsByOrderAccountDetail(Map<Integer, List<OrderAccountDTO>> map) {
//获取收入金额
DailyVehicleOrderStatistics orderStatistics = getGmvAndSecurityDeposit(map);
//获取扣款和退还金额
refundAndDeductions(map, orderStatistics);
return orderStatistics;
//获取公司的JSON字符串 }
List<DedDetailDTO> sumDedDetailDTOs = entry.getValue();
// 获取赔偿金额总和 /**
BigDecimal compensation = get(sumDedDetailDTOs, TYPE_DAMAGE); * 获取扣款和退款金额
statistics.setCompensation(compensation); *
// 获取延期金额总和 * @param map
BigDecimal postpone = get(sumDedDetailDTOs, TYPE_DEFERRED); * @param orderStatistics
statistics.setPostpone(postpone); */
//// 其他款项总金额 private void refundAndDeductions(Map<Integer, List<OrderAccountDTO>> map, DailyVehicleOrderStatistics orderStatistics) {
// BigDecimal other = get(sumDedDetailDTOs, TYPE_OTHER); ArrayList<OrderAccountDTO> arrayList = Lists.newArrayList();
for (Integer key : map.keySet()) {
if (!key.equals(RefundTypeEnum.ORDER_FUND.getCode())) {
arrayList.addAll(map.get(key));
}
}
if (CollectionUtils.isNotEmpty(arrayList)) {
ArrayList<OrderAccountDetail> orderAccountDetail = getOrderAccountDetail(arrayList);
if (CollectionUtils.isNotEmpty(orderAccountDetail)) {
//获取退还订总额
BigDecimal returnGmv = getOrderAmountTotal(orderAccountDetail);
orderStatistics.setReturnGmv(returnGmv);
//获取退还押金总额
BigDecimal refundSecurityDeposit = getDepositAmountTotal(orderAccountDetail);
orderStatistics.setRefundSecurityDeposit(refundSecurityDeposit);
List<OrderAccountDeduction> OrderAccountDeductions = gettDeductions(orderAccountDetail);
//获取违章总额
orderStatistics.setViolationMoney(get(OrderAccountDeductions, new ArrayList<Integer>(){{
add(DeductionTypeEnum.VIOLATE_TRAFFIC_DEDUCT.getCode());
}}));
//获取损坏赔偿总额
orderStatistics.setCompensation(get(OrderAccountDeductions,new ArrayList<Integer>(){{
add(DeductionTypeEnum.DAMAGES.getCode());
}} ));
//获取违约总额
ArrayList<Integer> types = Lists.newArrayList();
types.add(DeductionTypeEnum.VIOLATE_ADVANCE.getCode());
types.add(DeductionTypeEnum.VIOLATE_CANCEL.getCode());
types.add(DeductionTypeEnum.VIOLATE_DELAY.getCode());
orderStatistics.setDefaultMoney(get(OrderAccountDeductions,types));
//消费金额
orderStatistics.setTotalExpenditure(get(OrderAccountDeductions,new ArrayList<Integer>(){{
add(DeductionTypeEnum.EXTRA.getCode());
}}));
}
}
}
result.add(statistics); /**
} * 获取订单总额和预交押金总额
*
* @param map
* @return
*/
private DailyVehicleOrderStatistics getGmvAndSecurityDeposit(Map<Integer, List<OrderAccountDTO>> map) {
DailyVehicleOrderStatistics orderStatistics = new DailyVehicleOrderStatistics();
List<OrderAccountDTO> orderAccountDTOS = map.get(RefundTypeEnum.ORDER_FUND.getCode());
} if (CollectionUtils.isNotEmpty(orderAccountDTOS)) {
ArrayList<OrderAccountDetail> orderAccountDetails = getOrderAccountDetail(orderAccountDTOS);
if (CollectionUtils.isNotEmpty(orderAccountDetails)) {
//获取订单总额
BigDecimal gmv = getOrderAmountTotal(orderAccountDetails);
orderStatistics.setGmv(gmv);
//获取押金总额
BigDecimal securityDeposit = getDepositAmountTotal(orderAccountDetails);
orderStatistics.setSecurityDeposit(securityDeposit);
return result; }
} }
return new ArrayList<>(); return orderStatistics;
} }
/**
* 获取订单和
*
* @param orderAccountDetails
* @return
*/
private BigDecimal getDepositAmountTotal(ArrayList<OrderAccountDetail> orderAccountDetails) {
return orderAccountDetails.stream()
.map(OrderAccountDetail::getDepositAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
}
/** /**
* 根据type获取对应的金额总 * 获取押金
* *
* @param sumDedDetailDTOs * @param orderAccountDetails
* @param type 金额类型
* @return * @return
*/ */
private BigDecimal get(List<DedDetailDTO> sumDedDetailDTOs, Integer type) { private BigDecimal getOrderAmountTotal(ArrayList<OrderAccountDetail> orderAccountDetails) {
if (CollectionUtils.isNotEmpty(sumDedDetailDTOs)) { return orderAccountDetails.stream()
BigDecimal aggregateAmount = sumDedDetailDTOs.stream() .map(OrderAccountDetail::getOrderAmount)
.filter(d -> type.equals(d.getType())) .reduce(BigDecimal.ZERO, BigDecimal::add);
.map(DedDetailDTO::getCost) }
.reduce(BigDecimal.ZERO, BigDecimal::add);
return aggregateAmount; /**
* 获取赔款数据
*
* @param orderAccountDetails
* @return
*/
private List<OrderAccountDeduction> gettDeductions(ArrayList<OrderAccountDetail> orderAccountDetails) {
ArrayList<OrderAccountDeduction> arrayList = Lists.newArrayList();
for (OrderAccountDetail orderAccountDetail : orderAccountDetails) {
arrayList.addAll(orderAccountDetail.getDeductions());
} }
return BigDecimal.ZERO; return arrayList;
} }
/**
* 获取金额详情
*
* @param orderAccountDTOS
* @return
*/
private ArrayList<OrderAccountDetail> getOrderAccountDetail(List<OrderAccountDTO> orderAccountDTOS) {
ArrayList<OrderAccountDetail> arrayList = Lists.newArrayList();
orderAccountDTOS.parallelStream()
.map(OrderAccount::getAccountDetail)
.forEach(detail -> {
if (StringUtils.isNotBlank(detail)) {
arrayList.add(JSONUtil.toBean(detail, OrderAccountDetail.class));
}
});
@Override return arrayList;
public int insertSelectiveRe(DailyVehicleOrderStatistics entity) {
entity.setCrtTime(new Date());
return mapper.insertSelective(entity);
} }
public OrderStatistics findAll(Integer companyId) {
return mapper.monthOrderTotal(companyId);
}
} }
...@@ -13,6 +13,7 @@ import com.xxfc.platform.order.biz.inner.OrderMsgBiz; ...@@ -13,6 +13,7 @@ import com.xxfc.platform.order.biz.inner.OrderMsgBiz;
import com.xxfc.platform.order.contant.enumerate.*; import com.xxfc.platform.order.contant.enumerate.*;
import com.xxfc.platform.order.entity.*; import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.pojo.DedDetailDTO; import com.xxfc.platform.order.pojo.DedDetailDTO;
import com.xxfc.platform.order.pojo.account.OrderAccountDTO;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction; import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail; import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO; import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
...@@ -85,17 +86,19 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -85,17 +86,19 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
* @param timeLag 与开始时间的时间差 * @param timeLag 与开始时间的时间差
* @param dicParentKey * @param dicParentKey
*/ */
public BigDecimal rentRefundProcessCancel(BaseOrder baseOrder, BigDecimal mainItemRealAmount, Long timeLag, String dicParentKey, BigDecimal depositAmount, BigDecimal originalDeductAmount) { public BigDecimal rentRefundProcessCancel(BaseOrder baseOrder, BigDecimal mainItemRealAmount, Long timeLag, String dicParentKey, BigDecimal depositAmount, BigDecimal originalDeductAmount, OrderAccountDetail oad) {
//计算退款金额 //计算退款金额
//商品价格 - 优惠券减免的价格 //商品价格 - 优惠券减免的价格
BigDecimal originalRefundAmount = BigDecimal.ZERO.add(mainItemRealAmount); BigDecimal originalRefundAmount = BigDecimal.ZERO.add(mainItemRealAmount);
StringBuilder refundDescBuilder = new StringBuilder("取消订单退款:"); StringBuilder refundDescBuilder = new StringBuilder("取消订单退款:");
OrderAccountDetail oad = new OrderAccountDetail(); if(null == oad) {
oad = new OrderAccountDetail();
}
BigDecimal refundMainGoodsAmount = calculateRefund(originalRefundAmount, timeLag, dicParentKey, refundDescBuilder, oad); BigDecimal refundMainGoodsAmount = calculateRefund(originalRefundAmount, timeLag, dicParentKey, refundDescBuilder, oad);
refundMainGoodsAmount = refundMainGoodsAmount.setScale(2, RoundingMode.HALF_UP); refundMainGoodsAmount = refundMainGoodsAmount.setScale(2, RoundingMode.HALF_UP);
//退款金额 = 主要商品退款 + (其他商品退款) 即--> 主要商品退款 + (订单总商品款 - 主要商品款) //退款金额 = 主要商品退款 + (其他商品退款) 即--> 主要商品退款 + (总商品款 - 主要商品款)
oad.setOrderAmount(refundMainGoodsAmount.add(baseOrder.getOrderAmount().subtract(mainItemRealAmount))); oad.setOrderAmount(refundMainGoodsAmount.add(baseOrder.getGoodsAmount().subtract(mainItemRealAmount)));
BigDecimal refundAmount = oad.getOrderAmount(); BigDecimal refundAmount = oad.getOrderAmount();
// 押金 // 押金
...@@ -187,7 +190,9 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -187,7 +190,9 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
set("ga", goodsAmount); set("ga", goodsAmount);
}})).toString()); }})).toString());
refundDescBuilder = refundDescBuilder.insert(0, names[1]+ ","); refundDescBuilder = refundDescBuilder.insert(0, names[1]+ ",");
orderAccountDetail.getDeductions().add(initDeduction(goodsAmount.subtract(refundGoodsAmount), names[1], DeductionTypeEnum.VIOLATE_CANCEL, OrderAccountDeduction.ORIGIN_DEPOSIT)); if(goodsAmount.subtract(refundGoodsAmount).compareTo(BigDecimal.ZERO) > 0) {
orderAccountDetail.getDeductions().add(initDeduction(goodsAmount.subtract(refundGoodsAmount), names[1], DeductionTypeEnum.VIOLATE_CANCEL, OrderAccountDeduction.ORIGIN_DEPOSIT));
}
break; break;
} }
} }
...@@ -353,4 +358,24 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> { ...@@ -353,4 +358,24 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
log.error("crosstown.getViolateDetail() crosstown id :"+crosstown.getId() +" 转换失败"); log.error("crosstown.getViolateDetail() crosstown id :"+crosstown.getId() +" 转换失败");
} }
} }
/**
* 获取每日订单账目,用于统计
* @param code
* @param day
* @return
*/
public List<OrderAccountDTO> getOrderAccountByOrderType(Integer code, Integer day) {
return mapper.getOrderAccountByOrderType(code,day);
}
} }
\ No newline at end of file
package com.xxfc.platform.order.biz; package com.xxfc.platform.order.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.xxfc.platform.order.entity.OrderStatistics; import com.xxfc.platform.order.entity.OrderStatistics;
import com.xxfc.platform.order.mapper.OrderStatisticsMapper; import com.xxfc.platform.order.mapper.OrderStatisticsMapper;
import com.xxfc.platform.order.pojo.HomePageOrderData;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -26,37 +28,48 @@ public class OrderStatisticsBiz extends BaseBiz<OrderStatisticsMapper, OrderStat ...@@ -26,37 +28,48 @@ public class OrderStatisticsBiz extends BaseBiz<OrderStatisticsMapper, OrderStat
@Autowired @Autowired
private DailyMembersOrderStatisticsBiz membersBiz; private DailyMembersOrderStatisticsBiz membersBiz;
public OrderStatistics getTotalOrder(Integer companyId) { public HomePageOrderData getTotalOrder(Integer companyId) {
OrderStatistics result = new OrderStatistics(); HomePageOrderData result = new HomePageOrderData();
ArrayList<OrderStatistics> orderStatistics = new ArrayList<>(); ArrayList<HomePageOrderData> orderStatistics = new ArrayList<>();
OrderStatistics vehicle = vehicleBiz.findAll(companyId); OrderStatistics vehicle = vehicleBiz.findAll(companyId);
if (vehicle != null) { if (vehicle != null) {
orderStatistics.add(vehicle); HomePageOrderData data = new HomePageOrderData() {{
setTotalOrders(vehicle.getTotalGmv().subtract(vehicle.getTotalReturnGmv()));
setAdditionalIndemnity(vehicle.getTotalCompensation()
.add(vehicle.getTotalForfeit())
.add(vehicle.getTotalDefaultMoney())
.add(vehicle.getTotalExpenditure().subtract(vehicle.getTotalGmv().subtract(vehicle.getTotalReturnGmv())))
);
}};
orderStatistics.add(data);
} }
OrderStatistics tour = TravelBiz.findAll(companyId); OrderStatistics tour = TravelBiz.findAll(companyId);
if (vehicle != null) { if (vehicle != null) {
orderStatistics.add(tour); HomePageOrderData data = new HomePageOrderData() {{
setTotalOrders(tour.getTotalGmv().subtract(tour.getTotalReturnGmv()));
setAdditionalIndemnity(tour.getTotalDefaultMoney());
}};
orderStatistics.add(data);
} }
OrderStatistics member = membersBiz.findAll(companyId); OrderStatistics member = membersBiz.findAll(companyId);
if (vehicle != null) { if (vehicle != null) {
orderStatistics.add(member); HomePageOrderData data = new HomePageOrderData() {{
} setTotalOrders(member.getTotalGmv().subtract(member.getTotalReturnGmv()));
result.setTotalGmv(orderStatistics.stream().map(OrderStatistics::getTotalGmv).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add)); }};
orderStatistics.add(data);
}
result.setTotalForfeit(orderStatistics.stream().map(OrderStatistics::getTotalForfeit).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setTotalCompensation(orderStatistics.stream().map(OrderStatistics::getTotalCompensation).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setTotalRefundSecurityDeposit(orderStatistics.stream().map(OrderStatistics::getTotalRefundSecurityDeposit).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setTotalSecurityDeposit(orderStatistics.stream().map(OrderStatistics::getTotalSecurityDeposit).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add)); result.setTotalOrders(orderStatistics.stream().map(HomePageOrderData::getTotalOrders).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setTotalPenalSum(orderStatistics.stream().map(OrderStatistics::getTotalPenalSum).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add)); result.setTotalOutstandingDeposit(orderStatistics.stream().map(HomePageOrderData::getTotalOutstandingDeposit).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
result.setTotalPostpone(orderStatistics.stream().map(OrderStatistics::getTotalPostpone).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add)); result.setAdditionalIndemnity(orderStatistics.stream().map(HomePageOrderData::getAdditionalIndemnity).filter(o-> Objects.nonNull(o)).reduce(BigDecimal.ZERO, BigDecimal::add));
return result; return result;
} }
......
...@@ -6,11 +6,16 @@ import cn.hutool.extra.template.TemplateEngine; ...@@ -6,11 +6,16 @@ import cn.hutool.extra.template.TemplateEngine;
import cn.hutool.extra.template.TemplateUtil; import cn.hutool.extra.template.TemplateUtil;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.xxfc.platform.order.contant.enumerate.OrderCostEnum;
import com.xxfc.platform.order.entity.OrderTemplate; import com.xxfc.platform.order.entity.OrderTemplate;
import com.xxfc.platform.order.mapper.OrderTemplateMapper; import com.xxfc.platform.order.mapper.OrderTemplateMapper;
import com.xxfc.platform.order.pojo.price.CancelNoStartVO;
import com.xxfc.platform.order.pojo.price.CancelStartedVO;
import com.xxfc.platform.order.pojo.price.CostDetailExtend;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -58,6 +63,32 @@ public class OrderTemplateBiz extends BaseBiz<OrderTemplateMapper,OrderTemplate> ...@@ -58,6 +63,32 @@ public class OrderTemplateBiz extends BaseBiz<OrderTemplateMapper,OrderTemplate>
return template.render(map); return template.render(map);
} }
public OrderTemplate selectByCode(String code) {
return selectOne(new OrderTemplate(){{
setCode(code);
}});
}
/**
* 计算费用明细
* @param vo
* @return
*/
public void handleCostDetailExtend(CancelNoStartVO vo) {
OrderTemplate template = selectByCode(OrderCostEnum.CANCEL_NO_START.getCode());
vo.setCostDetail(result(template.getTemplate(), Dict.parse(vo)));
}
/**
* 取消费用明细
* @param vo
* @return
*/
public void handleCostDetailExtend(CancelStartedVO vo) {
OrderTemplate template = selectByCode(OrderCostEnum.CANCEL_STARTED.getCode());
vo.setCostDetail(result(template.getTemplate(), Dict.parse(vo)));
}
public static void main(String[] args) { public static void main(String[] args) {
String tempStr = "{\"key\":\"费用明细\", \"val\":\"\", \"consumeAmount\":\"${consumeAmount}\",\"children\":[${children}]}"; String tempStr = "{\"key\":\"费用明细\", \"val\":\"\", \"consumeAmount\":\"${consumeAmount}\",\"children\":[${children}]}";
Map map = Maps.newHashMap(); Map map = Maps.newHashMap();
......
...@@ -68,7 +68,7 @@ public class OrderTourVerificationBiz{ ...@@ -68,7 +68,7 @@ public class OrderTourVerificationBiz{
if(baseOrder==null){ if(baseOrder==null){
return ObjectRestResponse.createFailedResult(ResCode.ORDER_IS_NOT_EXIST.getCode(), ResCode.ORDER_IS_NOT_EXIST.getDesc()); return ObjectRestResponse.createFailedResult(ResCode.ORDER_IS_NOT_EXIST.getCode(), ResCode.ORDER_IS_NOT_EXIST.getDesc());
} }
if(baseOrder.getStatus()!=OrderStatusEnum.ORDER_TOSTART.getCode()){ if(baseOrder.getHasPay()==0){
return ObjectRestResponse.createFailedResult(ResCode.ORDER_IS_NOT_PAY.getCode(), ResCode.ORDER_IS_NOT_PAY.getDesc()); return ObjectRestResponse.createFailedResult(ResCode.ORDER_IS_NOT_PAY.getCode(), ResCode.ORDER_IS_NOT_PAY.getDesc());
} }
Integer orderId=baseOrder.getId(); Integer orderId=baseOrder.getId();
......
...@@ -250,24 +250,28 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -250,24 +250,28 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
//定损扣除费用 //定损扣除费用
if (StringUtils.isNotBlank(orderVehicleCrosstownDto.getDedDetail())) { if (StringUtils.isNotBlank(orderVehicleCrosstownDto.getDedDetail())) {
JSONArray jsonArray = JSONArray.parseArray(orderVehicleCrosstownDto.getDedDetail()); JSONArray jsonArray = JSONArray.parseArray(orderVehicleCrosstownDto.getDedDetail());
for (int i = 0; i < jsonArray.size(); i++) { if(jsonArray != null && jsonArray.size() > 0) {
JSONObject jsonObject = JSONObject.parseObject(jsonArray.get(i).toString()); for (int i = 0; i < jsonArray.size(); i++) {
if (jsonObject != null) { JSONObject jsonObject = JSONObject.parseObject(jsonArray.get(i).toString());
cost += Double.parseDouble(jsonObject.getString("cost")); if (jsonObject != null) {
cost += Double.parseDouble(jsonObject.getString("cost"));
}
} }
} }
} }
//延期扣除费用 //延期扣除费用
if (StringUtils.isNotBlank(orderVehicleCrosstownDto.getViolateDetail())) { if (StringUtils.isNotBlank(orderVehicleCrosstownDto.getViolateDetail())) {
JSONArray jsonArray = JSONArray.parseArray(orderVehicleCrosstownDto.getDedDetail()); JSONArray jsonArray = JSONArray.parseArray(orderVehicleCrosstownDto.getDedDetail());
for (int i = 0; i < jsonArray.size(); i++) { if(jsonArray != null && jsonArray.size() > 0) {
JSONObject jsonObject = JSONObject.parseObject(jsonArray.get(i).toString()); for (int i = 0; i < jsonArray.size(); i++) {
if (jsonObject != null) { JSONObject jsonObject = JSONObject.parseObject(jsonArray.get(i).toString());
if (jsonObject.getString("cost") != null) { if (jsonObject != null) {
cost += Double.parseDouble(jsonObject.getString("cost")); if (jsonObject.getString("cost") != null) {
} cost += Double.parseDouble(jsonObject.getString("cost"));
if (jsonObject.getString("excessCost") != null) { }
cost += Double.parseDouble(jsonObject.getString("excessCost")); if (jsonObject.getString("excessCost") != null) {
cost += Double.parseDouble(jsonObject.getString("excessCost"));
}
} }
} }
} }
......
package com.xxfc.platform.order.biz.inner; package com.xxfc.platform.order.biz.inner;
import cn.hutool.core.lang.Dict;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.xxfc.platform.activity.entity.Coupon; import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.activity.feign.ActivityFeign; import com.xxfc.platform.activity.feign.ActivityFeign;
...@@ -12,6 +13,7 @@ import com.xxfc.platform.order.entity.*; ...@@ -12,6 +13,7 @@ import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction; import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail; import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO; import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.price.RentVehiclePriceVO;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -20,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -20,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
...@@ -59,6 +62,7 @@ public class OrderCalculateBiz { ...@@ -59,6 +62,7 @@ public class OrderCalculateBiz {
public InProgressVO inProgressCalculate(BaseOrder baseOrder, OrderItem orderItem, Integer freeDays, Integer useDays, OrderAccountDetail oad) { public InProgressVO inProgressCalculate(BaseOrder baseOrder, OrderItem orderItem, Integer freeDays, Integer useDays, OrderAccountDetail oad) {
BigDecimal refundAmount = BigDecimal.ZERO; BigDecimal refundAmount = BigDecimal.ZERO;
BigDecimal consumeAmount = BigDecimal.ZERO;
InProgressVO inProgressVO = new InProgressVO(); InProgressVO inProgressVO = new InProgressVO();
inProgressVO.setUsedDays(useDays); inProgressVO.setUsedDays(useDays);
inProgressVO.setUsedfreeDays(freeDays); inProgressVO.setUsedfreeDays(freeDays);
...@@ -80,7 +84,7 @@ public class OrderCalculateBiz { ...@@ -80,7 +84,7 @@ public class OrderCalculateBiz {
//消费天数 //消费天数
Integer consumeDays = 0 - backFreeDays; Integer consumeDays = 0 - backFreeDays;
//计算使用天数的费用 //计算使用天数的费用
BigDecimal consumeAmount = orderItem.getUnitPrice().multiply(new BigDecimal(consumeDays+"")); consumeAmount = orderItem.getUnitPrice().multiply(new BigDecimal(consumeDays+""));
List<BigDecimal> couponAmounts = Lists.newArrayList(); List<BigDecimal> couponAmounts = Lists.newArrayList();
for(String tickerNo : baseOrder.getCouponTickerNos().split(",")) { for(String tickerNo : baseOrder.getCouponTickerNos().split(",")) {
BigDecimal couponAmount = activityFeign.use(baseOrder.getUserId(), Lists.newArrayList(tickerNo), baseOrder.getNo(), Coupon.CHANNEL_RENT, consumeAmount, ActivityFeign.TYPE_CHECK); BigDecimal couponAmount = activityFeign.use(baseOrder.getUserId(), Lists.newArrayList(tickerNo), baseOrder.getNo(), Coupon.CHANNEL_RENT, consumeAmount, ActivityFeign.TYPE_CHECK);
......
...@@ -11,9 +11,12 @@ import com.xxfc.platform.activity.feign.ActivityFeign; ...@@ -11,9 +11,12 @@ import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.order.biz.*; import com.xxfc.platform.order.biz.*;
import com.xxfc.platform.order.contant.enumerate.*; import com.xxfc.platform.order.contant.enumerate.*;
import com.xxfc.platform.order.entity.*; import com.xxfc.platform.order.entity.*;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail; import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO; import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO; import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.price.CancelNoStartVO;
import com.xxfc.platform.order.pojo.price.CancelStartedVO;
import com.xxfc.platform.tour.feign.TourFeign; import com.xxfc.platform.tour.feign.TourFeign;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
...@@ -67,6 +70,9 @@ public class OrderCancelBiz { ...@@ -67,6 +70,9 @@ public class OrderCancelBiz {
@Autowired @Autowired
OrderAccountBiz orderAccountBiz; OrderAccountBiz orderAccountBiz;
@Autowired
OrderTemplateBiz orderTemplateBiz;
@Autowired @Autowired
UserFeign userFeign; UserFeign userFeign;
...@@ -152,6 +158,25 @@ public class OrderCancelBiz { ...@@ -152,6 +158,25 @@ public class OrderCancelBiz {
//退款子流程: 订单基础,退款描述,退款金额 //退款子流程: 订单基础,退款描述,退款金额
orderAccountBiz.refundSubProcess(baseOrder, "", baseOrder.getRealAmount().subtract(orvd.getDeposit()), oad.getDepositAmount().add(oad.getOrderAmount()), AccountTypeEnum.OUT_ORDER_FUND.getCode(), RefundStatusEnum.ALL.getCode(), oad); orderAccountBiz.refundSubProcess(baseOrder, "", baseOrder.getRealAmount().subtract(orvd.getDeposit()), oad.getDepositAmount().add(oad.getOrderAmount()), AccountTypeEnum.OUT_ORDER_FUND.getCode(), RefundStatusEnum.ALL.getCode(), oad);
//如果有扣款项,则生成额外的费用明细
CancelStartedVO csv = new CancelStartedVO();
csv.setConsumeAmount(inProgressVO.getConsumeAmount());
csv.setModelAmount(orderItem.getUnitPrice());
csv.setUsedAmount(inProgressVO.getUsedAmount());
csv.setUsedDayNum(inProgressVO.getUsedDays());
csv.setUsedFreeAmount(inProgressVO.getUsedFreeDaysAmount());
if(oad.getDeductions().size() > 0) {
for(OrderAccountDeduction deduction : oad.getDeductions()) {
if(DeductionTypeEnum.VIOLATE_CANCEL.getCode().equals(deduction.getType())) {
csv.setViolateAmount(deduction.getAmount());
csv.setViolateDesc(deduction.getName());
}
}
}
orderTemplateBiz.handleCostDetailExtend(csv);
orvd.setCostDetailExtend(csv.getCostDetail());
orderRentVehicleBiz.updateSelectiveByIdRe(orvd);
}else { }else {
//没到出车时间 //没到出车时间
//判断是否使用免费天数,并且进行扣款 //判断是否使用免费天数,并且进行扣款
...@@ -165,7 +190,22 @@ public class OrderCancelBiz { ...@@ -165,7 +190,22 @@ public class OrderCancelBiz {
} }
} }
//退款流程 //退款流程
orderAccountBiz.rentRefundProcessCancel(hasUpdateOrder, orderItem.getRealAmount(), timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), freeDayAmount); orderAccountBiz.rentRefundProcessCancel(hasUpdateOrder, orderItem.getRealAmount(), timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), freeDayAmount, null);
//如果有扣款项,则生成额外的费用明细
if(oad.getDeductions().size() > 0) {
for(OrderAccountDeduction deduction : oad.getDeductions()) {
if(DeductionTypeEnum.VIOLATE_CANCEL.getCode().equals(deduction.getType())) {
CancelNoStartVO cnsv = new CancelNoStartVO(){{
setViolateAmount(deduction.getAmount());
setViolateDesc(deduction.getName());
}};
orderTemplateBiz.handleCostDetailExtend(cnsv);
orvd.setCostDetailExtend(cnsv.getCostDetail());
orderRentVehicleBiz.updateSelectiveByIdRe(orvd);
}
}
}
} }
//已付款的取消订单发送消息 //已付款的取消订单发送消息
...@@ -199,8 +239,24 @@ public class OrderCancelBiz { ...@@ -199,8 +239,24 @@ public class OrderCancelBiz {
if(SYS_TRUE.equals(otd.getIsOutside())) { if(SYS_TRUE.equals(otd.getIsOutside())) {
key = TOUR_REFUND; key = TOUR_REFUND;
} }
//退款流程 //退款流程
orderAccountBiz.rentRefundProcessCancel(hasUpdateOrder, adultItem.getRealAmount().add(childItem.getRealAmount()), timeLag, APP_ORDER+ "_"+ key, BigDecimal.ZERO, BigDecimal.ZERO); orderAccountBiz.rentRefundProcessCancel(hasUpdateOrder, adultItem.getRealAmount().add(childItem.getRealAmount()), timeLag, APP_ORDER+ "_"+ key, BigDecimal.ZERO, BigDecimal.ZERO, oad);
//如果有扣款项,则生成额外的费用明细
if(oad.getDeductions().size() > 0) {
for(OrderAccountDeduction deduction : oad.getDeductions()) {
if(DeductionTypeEnum.VIOLATE_CANCEL.getCode().equals(deduction.getType())) {
CancelNoStartVO cnsv = new CancelNoStartVO(){{
setViolateAmount(deduction.getAmount());
setViolateDesc(deduction.getName());
}};
orderTemplateBiz.handleCostDetailExtend(cnsv);
otd.setCostDetailExtend(cnsv.getCostDetail());
orderTourDetailBiz.updateSelectiveByIdRe(otd);
}
}
}
//站点总人数减少 //站点总人数减少
tourFeign.updateTourGoodPersonNum(otd.getVerificationId(), TourFeign.TOTAL_PERSON, (otd.getTotalNumber() * -1)); tourFeign.updateTourGoodPersonNum(otd.getVerificationId(), TourFeign.TOTAL_PERSON, (otd.getTotalNumber() * -1));
...@@ -213,10 +269,11 @@ public class OrderCancelBiz { ...@@ -213,10 +269,11 @@ public class OrderCancelBiz {
setOrderId(baseOrder.getId()); setOrderId(baseOrder.getId());
}}); }});
//取消租车预定 //取消租车预定 和 记录生成额外的费用明细
//已支付,并且是待出行状态,取消预约 //已支付,并且是待出行状态,取消预约
if(OrderStatusEnum.ORDER_TOSTART.getCode().equals(baseOrder.getStatus()) && SYS_TRUE.equals(baseOrder.getHasPay())){ if(OrderStatusEnum.ORDER_TOSTART.getCode().equals(baseOrder.getStatus()) && SYS_TRUE.equals(baseOrder.getHasPay())){
vehicleFeign.rentUnbookVehicle(orvd.getBookRecordId()); vehicleFeign.rentUnbookVehicle(orvd.getBookRecordId());
}else { }else {
//未支付,拒绝之前的预约 //未支付,拒绝之前的预约
RestResponse<Integer> restResponse = vehicleFeign.rentRejectVehicleBooking(orvd.getBookRecordId()); RestResponse<Integer> restResponse = vehicleFeign.rentRejectVehicleBooking(orvd.getBookRecordId());
......
package com.xxfc.platform.order.mapper; package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.OrderAccount; import com.xxfc.platform.order.entity.OrderAccount;
import com.xxfc.platform.order.pojo.account.OrderAccountDTO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** /**
* 订单帐目 * 订单帐目
* *
...@@ -11,5 +16,6 @@ import tk.mybatis.mapper.common.Mapper; ...@@ -11,5 +16,6 @@ import tk.mybatis.mapper.common.Mapper;
* @date 2019-09-09 15:51:16 * @date 2019-09-09 15:51:16
*/ */
public interface OrderAccountMapper extends Mapper<OrderAccount> { public interface OrderAccountMapper extends Mapper<OrderAccount> {
List<OrderAccountDTO> getOrderAccountByOrderType(@Param("type") Integer type, @Param("day") Integer day);
} }
package com.xxfc.platform.order.rest; package com.xxfc.platform.order.rest;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin; import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
...@@ -48,6 +49,7 @@ import org.springframework.stereotype.Controller; ...@@ -48,6 +49,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.lang.reflect.Array;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneOffset; import java.time.ZoneOffset;
...@@ -103,10 +105,11 @@ public class BackStageOrderController extends CommonBaseController implements Us ...@@ -103,10 +105,11 @@ public class BackStageOrderController extends CommonBaseController implements Us
dto.setEndTime(new Date().getTime()); dto.setEndTime(new Date().getTime());
} }
} }
if (StringUtils.isNotBlank(dto.getPhone())) { if (StringUtils.isNotBlank(dto.getPhone())||StringUtils.isNotBlank(dto.getRealName())) {
AppUserLogin appUserLogin = userFeign.one(dto.getPhone()); List<AppUserLogin> appUserLoins = userFeign.getOne(dto.getPhone(),dto.getRealName());
if (appUserLogin != null) { if (CollectionUtil.isNotEmpty(appUserLoins)) {
dto.setUserId(appUserLogin.getId()); List<Integer> collect = appUserLoins.parallelStream().map(AppUserLogin::getId).collect(Collectors.toList());
dto.setUserIds(collect);
}else { }else {
return ObjectRestResponse.succ(new PageDataVO<>()); return ObjectRestResponse.succ(new PageDataVO<>());
} }
...@@ -121,8 +124,8 @@ public class BackStageOrderController extends CommonBaseController implements Us ...@@ -121,8 +124,8 @@ public class BackStageOrderController extends CommonBaseController implements Us
dto.setCompanyIds(companyIds); dto.setCompanyIds(companyIds);
} }
if (StringUtils.isNotEmpty(dto.getPlateNumber())){ if (StringUtils.isNotEmpty(dto.getPlateNumber())||StringUtils.isNotEmpty(dto.getVehicleCode())){
List<String> vehicleIds = vehicleFeign.findbyPlateNumber(dto.getPlateNumber().trim()); List<String> vehicleIds = vehicleFeign.findbyPlateNumberAndVehicleCod(dto.getPlateNumber(),dto.getVehicleCode());
dto.setVehicleIds(vehicleIds); dto.setVehicleIds(vehicleIds);
} }
...@@ -148,6 +151,7 @@ public class BackStageOrderController extends CommonBaseController implements Us ...@@ -148,6 +151,7 @@ public class BackStageOrderController extends CommonBaseController implements Us
if(appUserVo != null) { if(appUserVo != null) {
orderPageVO.setTelephone(appUserVo.getUsername()); orderPageVO.setTelephone(appUserVo.getUsername());
orderPageVO.setUsername(appUserVo.getNickname()); orderPageVO.setUsername(appUserVo.getNickname());
orderPageVO.setRealName(appUserVo.getRealname());
} }
if (orderPageVO.getOrderRentVehicleDetail() != null && orderPageVO.getOrderRentVehicleDetail().getVehicleId() != null) { if (orderPageVO.getOrderRentVehicleDetail() != null && orderPageVO.getOrderRentVehicleDetail().getVehicleId() != null) {
RestResponse<Vehicle> restResponse = vehicleFeign.findById(orderPageVO.getOrderRentVehicleDetail().getVehicleId()); RestResponse<Vehicle> restResponse = vehicleFeign.findById(orderPageVO.getOrderRentVehicleDetail().getVehicleId());
......
...@@ -309,8 +309,19 @@ public class BaseOrderController extends CommonBaseController implements UserRes ...@@ -309,8 +309,19 @@ public class BaseOrderController extends CommonBaseController implements UserRes
private String phone; private String phone;
/**
* 后台搜索条件:真实姓名
*/
private String realName;
/**
* 后台搜索条件:车辆编号
*/
private String vehicleCode;
private List<String> vehicleIds; private List<String> vehicleIds;
//订单用户ID列表 //订单用户ID列表
private List<Integer> userIds; private List<Integer> userIds;
//订单用户手机号或订单用户真实姓名 //订单用户手机号或订单用户真实姓名
......
...@@ -12,6 +12,7 @@ import com.xxfc.platform.order.biz.DailyTravelOrderStatisticsBiz; ...@@ -12,6 +12,7 @@ import com.xxfc.platform.order.biz.DailyTravelOrderStatisticsBiz;
import com.xxfc.platform.order.biz.DailyVehicleOrderStatisticsBiz; import com.xxfc.platform.order.biz.DailyVehicleOrderStatisticsBiz;
import com.xxfc.platform.order.biz.OrderStatisticsBiz; import com.xxfc.platform.order.biz.OrderStatisticsBiz;
import com.xxfc.platform.order.entity.OrderStatistics; import com.xxfc.platform.order.entity.OrderStatistics;
import com.xxfc.platform.order.pojo.HomePageOrderData;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -88,15 +89,28 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz ...@@ -88,15 +89,28 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz
if (TYPE_VEHICLE.equals(type)) { if (TYPE_VEHICLE.equals(type)) {
OrderStatistics vehicle = vehicleBiz.findAll(companyId); OrderStatistics vehicle = vehicleBiz.findAll(companyId);
return ObjectRestResponse.succ(vehicle); return ObjectRestResponse.succ(new HomePageOrderData(){{
setTotalOrders(vehicle.getTotalGmv().subtract(vehicle.getTotalReturnGmv()));
setAdditionalIndemnity(vehicle.getTotalCompensation()
.add(vehicle.getTotalForfeit())
.add(vehicle.getTotalDefaultMoney())
.add(vehicle.getTotalExpenditure().subtract(vehicle.getTotalGmv().subtract(vehicle.getTotalReturnGmv())))
);
}});
} }
if (TYPE_TOUR.equals(type)) { if (TYPE_TOUR.equals(type)) {
OrderStatistics tour = TravelBiz.findAll(companyId); OrderStatistics tour = TravelBiz.findAll(companyId);
return ObjectRestResponse.succ(tour); return ObjectRestResponse.succ(new HomePageOrderData(){{
setTotalOrders(tour.getTotalGmv().subtract(tour.getTotalReturnGmv()));
setAdditionalIndemnity(tour.getTotalDefaultMoney());
}});
} }
if (TYPE_MEMBER.equals(type)) { if (TYPE_MEMBER.equals(type)) {
OrderStatistics member = membersBiz.findAll(companyId); OrderStatistics member = membersBiz.findAll(companyId);
return ObjectRestResponse.succ(member); return ObjectRestResponse.succ(new HomePageOrderData(){{
setTotalOrders(member.getTotalGmv().subtract(member.getTotalReturnGmv()));
}});
} }
if (TYPE_TOTAL.equals(type)) { if (TYPE_TOTAL.equals(type)) {
...@@ -110,4 +124,6 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz ...@@ -110,4 +124,6 @@ public class OrderStatisticsController extends BaseController<OrderStatisticsBiz
} }
} }
} }
...@@ -15,7 +15,6 @@ import com.github.wxiaoqi.security.common.util.process.ResultCode; ...@@ -15,7 +15,6 @@ import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.activity.entity.Coupon; import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.activity.feign.ActivityFeign; import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.order.biz.OrderCostDetailBiz; import com.xxfc.platform.order.biz.OrderCostDetailBiz;
import com.xxfc.platform.order.biz.OrderItemBiz;
import com.xxfc.platform.order.biz.OrderRentVehicleBiz; import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.OrderTemplateBiz; import com.xxfc.platform.order.biz.OrderTemplateBiz;
import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum; import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum;
...@@ -25,18 +24,15 @@ import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum; ...@@ -25,18 +24,15 @@ import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.OrderItem; import com.xxfc.platform.order.entity.OrderItem;
import com.xxfc.platform.order.entity.OrderTemplate; import com.xxfc.platform.order.entity.OrderTemplate;
import com.xxfc.platform.order.pojo.OrderAccompanyDTO; import com.xxfc.platform.order.pojo.OrderAccompanyDTO;
import com.xxfc.platform.order.pojo.order.OrderItemDTO;
import com.xxfc.platform.order.pojo.order.RentVehicleBO; import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.price.RentVehiclePriceVO; import com.xxfc.platform.order.pojo.price.RentVehiclePriceVO;
import com.xxfc.platform.universal.constant.DictionaryKey; import com.xxfc.platform.universal.constant.DictionaryKey;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.vehicle.constant.AccompanyingItemType; import com.xxfc.platform.vehicle.constant.AccompanyingItemType;
import com.xxfc.platform.vehicle.entity.AccompanyingItem;
import com.xxfc.platform.vehicle.entity.BranchCompany; import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.entity.VehicleBookRecord; import com.xxfc.platform.vehicle.entity.VehicleBookRecord;
import com.xxfc.platform.vehicle.entity.VehicleModel; import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.CompanyDetail;
import com.xxfc.platform.vehicle.pojo.RentVehicleBookDTO; import com.xxfc.platform.vehicle.pojo.RentVehicleBookDTO;
import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo; import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo;
import lombok.Data; import lombok.Data;
...@@ -386,9 +382,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -386,9 +382,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
private String handleChildren(RentVehicleBO detail, Integer vehicleDayNum) { private String handleChildren(RentVehicleBO detail, Integer vehicleDayNum) {
StringBuffer childrenStr = new StringBuffer(""); StringBuffer childrenStr = new StringBuffer("");
if(vehicleDayNum > 0) { // if(vehicleDayNum > 0) {
childrenStr.append(",${tem_0101}"); childrenStr.append(",${tem_0101}");
} // }
if(DRIVER_TYPE_COMPANY.equals(detail.getDriverType())) { if(DRIVER_TYPE_COMPANY.equals(detail.getDriverType())) {
childrenStr.append(",${tem_0102}"); childrenStr.append(",${tem_0102}");
} }
...@@ -414,9 +410,11 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -414,9 +410,11 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
* @return * @return
*/ */
private void costDetail(RentVehiclePriceVO vo, String children) { private void costDetail(RentVehiclePriceVO vo, String children) {
OrderTemplate template = orderTemplateBiz.selectById(OrderCostEnum.RentVehicle.getCode()); OrderTemplate template = orderTemplateBiz.selectById(OrderCostEnum.RENT_VEHICLE.getCode());
template.setTemplate(orderTemplateBiz.result(template.getTemplate(), new HashMap(){{ template.setTemplate(orderTemplateBiz.result(template.getTemplate(), new HashMap(){{
put("children", children); put("children", children);
put("vehicleAmount", vo.getVehicleAmount());
put("realAmount", vo.getRealAmount());
}})); }}));
String result = orderTemplateBiz.result(template, Dict.parse(vo)); String result = orderTemplateBiz.result(template, Dict.parse(vo));
vo.setCostDetail(result); vo.setCostDetail(result);
......
...@@ -3,7 +3,6 @@ package com.xxfc.platform.order.service; ...@@ -3,7 +3,6 @@ package com.xxfc.platform.order.service;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Dict; import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
...@@ -12,7 +11,6 @@ import com.github.wxiaoqi.security.common.util.process.ResultCode; ...@@ -12,7 +11,6 @@ import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.activity.entity.Coupon; import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.activity.feign.ActivityFeign; import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.order.biz.OrderCostDetailBiz; import com.xxfc.platform.order.biz.OrderCostDetailBiz;
import com.xxfc.platform.order.biz.OrderItemBiz;
import com.xxfc.platform.order.biz.OrderTemplateBiz; import com.xxfc.platform.order.biz.OrderTemplateBiz;
import com.xxfc.platform.order.biz.OrderTourDetailBiz; import com.xxfc.platform.order.biz.OrderTourDetailBiz;
import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum; import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum;
...@@ -312,7 +310,7 @@ public class OrderTourService extends AbstractOrderHandle<OrderTourDetailBiz, To ...@@ -312,7 +310,7 @@ public class OrderTourService extends AbstractOrderHandle<OrderTourDetailBiz, To
* @return * @return
*/ */
private void costDetail(TourPriceVO vo, String children) { private void costDetail(TourPriceVO vo, String children) {
OrderTemplate template = orderTemplateBiz.selectById(OrderCostEnum.RentVehicle.getCode()); OrderTemplate template = orderTemplateBiz.selectById(OrderCostEnum.RENT_VEHICLE.getCode());
template.setTemplate(orderTemplateBiz.result(template.getTemplate(), new HashMap(){{ template.setTemplate(orderTemplateBiz.result(template.getTemplate(), new HashMap(){{
put("children", children); put("children", children);
}})); }}));
......
...@@ -120,8 +120,12 @@ ...@@ -120,8 +120,12 @@
<if test="crtUser != null"> <if test="crtUser != null">
and b.crt_user = #{crtUser} and b.crt_user = #{crtUser}
</if> </if>
<if test="userId != null"> <if test="userIds != null and userIds.size() > 0">
and b.user_id = #{userId} and b.user_id in
<foreach collection="userIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if> </if>
<if test="status != null"> <if test="status != null">
and b.status = #{status} and b.status = #{status}
...@@ -178,8 +182,11 @@ ...@@ -178,8 +182,11 @@
from base_order b from base_order b
LEFT JOIN order_rent_vehicle_detail r on r.order_id = b.id LEFT JOIN order_rent_vehicle_detail r on r.order_id = b.id
where b.type = 1 where b.type = 1
<if test="userId != null"> <if test="userIds != null and userIds.size > 0">
and b.user_id = #{userId} and b.user_id in
<foreach collection="userIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if> </if>
<if test="status != null and status == -1"> <if test="status != null and status == -1">
AND b.status = -1 AND b.status = -1
......
...@@ -17,24 +17,13 @@ ...@@ -17,24 +17,13 @@
<select id="monthOrderTotal" resultType="com.xxfc.platform.order.entity.OrderStatistics"> <select id="monthOrderTotal" resultType="com.xxfc.platform.order.entity.OrderStatistics">
SELECT SELECT
IFNULL(sum(gmv),0) as totalGmv IFNULL( sum( gmv ), 0 ) AS totalGmv
FROM FROM
( daily_vehicle_order_statistics
SELECT
ANY_VALUE(id) AS id ,
ANY_VALUE(branch_company_id) AS branch_company_id,
ANY_VALUE(one_day) AS one_day,
ANY_VALUE(gmv) AS gmv,
ANY_VALUE(crt_time) AS crt_time
FROM
daily_members_order_statistics
GROUP BY
one_day,branch_company_id
) m
WHERE WHERE
1=1 1=1
<if test="companyId != null"> <if test="companyId != null">
and branch_company_id =#{companyId} and branch_company_id = #{companyId}
</if> </if>
</select> </select>
......
...@@ -51,26 +51,15 @@ ...@@ -51,26 +51,15 @@
<select id="monthOrderTotal" resultType="com.xxfc.platform.order.entity.OrderStatistics"> <select id="monthOrderTotal" resultType="com.xxfc.platform.order.entity.OrderStatistics">
SELECT SELECT
IFNULL(sum(gmv),0) as totalGmv, IFNULL( sum( gmv ), 0 ) AS totalGmv,
IFNULL(sum(penal_sum) ,0) as totalPenalSum IFNULL( sum( default_money ), 0 ) AS totalDefaultMoney,
IFNULL( sum( return_gmv ), 0 ) AS totalReturnGmv
FROM FROM
( daily_vehicle_order_statistics
SELECT
ANY_VALUE(id) AS id,
ANY_VALUE(branch_company_id) AS branch_company_id,
ANY_VALUE(one_day) AS one_day,
ANY_VALUE(gmv) AS gmv,
ANY_VALUE(penal_sum) AS penal_sum,
ANY_VALUE(crt_time) AS crt_time
FROM
daily_travel_order_statistics
GROUP BY
one_day,branch_company_id
) o
WHERE WHERE
1=1 1=1
<if test="companyId != null"> <if test="companyId != null">
and branch_company_id =#{companyId} and branch_company_id = #{companyId}
</if> </if>
</select> </select>
......
...@@ -79,33 +79,19 @@ ...@@ -79,33 +79,19 @@
v.start_company_id v.start_company_id
</select> </select>
<!-- 获取赔偿和延期JSON字符串--> <!-- -->
<select id="monthOrderTotal" resultType="com.xxfc.platform.order.entity.OrderStatistics"> <select id="monthOrderTotal" resultType="com.xxfc.platform.order.entity.OrderStatistics">
SELECT SELECT
IFNULL(sum(gmv),0) as totalGmv, IFNULL( sum( gmv ), 0 ) AS totalGmv,
(IFNULL(sum(security_deposit),0)-IFNULL(sum(refund_security_deposit) ,0)) as totalSecurityDeposit, IFNULL( sum( security_deposit ), 0 ) AS totalSecurityDeposit,
IFNULL(sum(refund_security_deposit) ,0) as totalRefundSecurityDeposit, IFNULL( sum( refund_security_deposit ), 0 ) AS totalRefundSecurityDeposit,
IFNULL(sum(compensation) ,0) as totalCompensation, IFNULL( sum( forfeit ), 0 ) AS totalForfeit,
IFNULL(sum(forfeit) ,0) as totalForfeit, IFNULL( sum( compensation ), 0 ) AS totalCompensation,
IFNULL(sum(penal_sum) ,0) as totalPenalSum, IFNULL( sum( return_gmv ), 0 ) AS totalReturnGmv,
IFNULL(sum(postpone) ,0) as totalPostpone IFNULL( sum( default_money ), 0 ) AS totalDefaultMoney,
FROM IFNULL( sum( total_expenditure ), 0 ) AS totalExpenditure
(
SELECT
ANY_VALUE(id) as id,
one_day,
branch_company_id,
ANY_VALUE(gmv) AS gmv,
ANY_VALUE(security_deposit) AS security_deposit,
ANY_VALUE(refund_security_deposit) AS refund_security_deposit,
ANY_VALUE(forfeit) AS forfeit,ANY_VALUE(penal_sum) AS penal_sum,
ANY_VALUE(postpone) AS postpone,ANY_VALUE(crt_time) AS crt_time,
ANY_VALUE(compensation) AS compensation
FROM FROM
daily_vehicle_order_statistics daily_vehicle_order_statistics
GROUP BY
one_day,branch_company_id
) a
WHERE WHERE
1=1 1=1
<if test="companyId != null"> <if test="companyId != null">
......
<?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.OrderAccountMapper">
<select id="getOrderAccountByOrderType" resultType="com.xxfc.platform.order.pojo.account.OrderAccountDTO">
SELECT
date(DATE_SUB(now(),interval #{day} day)) as oneDay,
a.*
<if test="type != null and type == 1">
, v.start_company_id as companyId
</if>
<if test="type != null and type == 2">
, t.start_company_id as companyId
</if>
FROM
order_account a
LEFT JOIN base_order b ON a.order_id = b.id
<if test="type != null and type==1">
LEFT JOIN order_rent_vehicle_detail v ON b.id = v.order_id
</if>
<if test="type != null and type==2">
LEFT JOIN order_tour_detail t ON b.id = t.order_id
</if>
WHERE
a.account_status=1
AND
b.type = #{type}
AND date( FROM_UNIXTIME( a.crt_time / 1000 ) ) = date( DATE_SUB( now( ), INTERVAL #{day} DAY ) )
</select>
</mapper>
\ No newline at end of file
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
<result column="deduction_cost" jdbcType="INTEGER" property="deductionCost"/> <result column="deduction_cost" jdbcType="INTEGER" property="deductionCost"/>
<result column="rest_deposit" jdbcType="INTEGER" property="restDeposit"/> <result column="rest_deposit" jdbcType="INTEGER" property="restDeposit"/>
<result column="user_license_id" jdbcType="VARCHAR" property="userLicenseId"/> <result column="user_license_id" jdbcType="VARCHAR" property="userLicenseId"/>
<result column="violate_amount_detail" jdbcType="VARCHAR" property="violateDetail"/>
</resultMap> </resultMap>
<resultMap id="orderMap" type="com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto"> <resultMap id="orderMap" type="com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto">
<result column="id" javaType="java.lang.Integer" property="id"/> <result column="id" javaType="java.lang.Integer" property="id"/>
...@@ -34,20 +35,20 @@ ...@@ -34,20 +35,20 @@
javaType="com.xxfc.platform.order.entity.DepositRefundRecord"/> javaType="com.xxfc.platform.order.entity.DepositRefundRecord"/>
</resultMap> </resultMap>
<select id="selectByOrderId" parameterType="com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto" resultType="com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto"> <select id="selectByOrderId" parameterType="com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto" resultType="com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto">
select * select o.*, o.violate_amount_detail violateDetail
from order_vehicle_crosstown from order_vehicle_crosstown o
<where> <where>
<if test="status != null"> <if test="status != null">
and status = #{status} and o.status = #{status}
</if> </if>
<if test="type != null"> <if test="type != null">
and type = #{type} and o.type = #{type}
</if> </if>
<if test="orderId != null"> <if test="orderId != null">
and order_id = #{orderId} and o.order_id = #{orderId}
</if> </if>
<if test="orderNo != null"> <if test="orderNo != null">
and order_no = #{orderNo} and o.order_no = #{orderNo}
</if> </if>
</where> </where>
</select> </select>
......
...@@ -152,4 +152,7 @@ public interface VehicleFeign { ...@@ -152,4 +152,7 @@ public interface VehicleFeign {
@GetMapping("/vehicleInfo/findwith_plate_number") @GetMapping("/vehicleInfo/findwith_plate_number")
List<String> findbyPlateNumber(@RequestParam(value = "plateNumber") String plateNumber); List<String> findbyPlateNumber(@RequestParam(value = "plateNumber") String plateNumber);
@GetMapping("/vehicleInfo/findVehicleIds")
List<String> findbyPlateNumberAndVehicleCod(@RequestParam(value = "plateNumber") String plateNumber,@RequestParam(value = "vehicleCode") String vehicleCode);
} }
...@@ -164,21 +164,21 @@ public class VehicleActiveService { ...@@ -164,21 +164,21 @@ public class VehicleActiveService {
} }
List<VehicleBookRecordVo> vehicleBookRecordVos = vehicleBookRecordBiz.selectByVehicleId(vehicleId); List<VehicleBookRecordVo> vehicleBookRecordVos = vehicleBookRecordBiz.selectByVehicleId(vehicleId);
if (vehicleBookRecordVos != null && vehicleBookRecordVos.size() > 0) { if (vehicleBookRecordVos != null && vehicleBookRecordVos.size() > 0) {
Iterator<VehicleBookRecordVo> iterator = vehicleBookRecordVos.iterator(); Iterator<VehicleBookRecordVo> iterator = vehicleBookRecordVos.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
VehicleBookRecordVo vehicleBookRecordVo = iterator.next(); VehicleBookRecordVo vehicleBookRecordVo = iterator.next();
if (vehicleBookRecordVo.getVehicleDepartureLogVo() != null && vehicleBookRecordVo.getVehicleDepartureLogVo().getState() != 1) { //已经出车 if (vehicleBookRecordVo.getVehicleDepartureLogVo() != null && vehicleBookRecordVo.getVehicleDepartureLogVo().getState() != 1) { //已经出车
stringBuilder.append("中,使用人:"); stringBuilder.append("中,使用人:");
stringBuilder.append(vehicleBookRecordVo.getVehicleUsername()); stringBuilder.append(vehicleBookRecordVo.getVehicleUsername());
stringBuilder.append(" 使用人电话:"); stringBuilder.append(" 使用人电话:");
stringBuilder.append(vehicleBookRecordVo.getVehicleUserPhone()); stringBuilder.append(vehicleBookRecordVo.getVehicleUserPhone());
return stringBuilder.toString(); return stringBuilder.toString();
}
} }
} }
}
stringBuilder.append(", 请联系管理员修改车辆状态为正常状态"); stringBuilder.append(", 请联系管理员修改车辆状态为正常状态");
return stringBuilder.toString(); return stringBuilder.toString();
} }
public void arrival(VehicleArrivalVo arrivalVo) { public void arrival(VehicleArrivalVo arrivalVo) {
Vehicle vehicle = vehicleMapper.selectByPrimaryKey(arrivalVo.getVehicleId()); Vehicle vehicle = vehicleMapper.selectByPrimaryKey(arrivalVo.getVehicleId());
...@@ -214,9 +214,6 @@ public class VehicleActiveService { ...@@ -214,9 +214,6 @@ public class VehicleActiveService {
} }
vehicle.setExpectDestinationBranchCompanyId(0); vehicle.setExpectDestinationBranchCompanyId(0);
vehicleMapper.updateByPrimaryKeySelective(vehicle); vehicleMapper.updateByPrimaryKeySelective(vehicle);
// 出车记录 // 出车记录
VehicleDepartureLogVo departureLogVo = vehicleDepartureLogMapper.selectByBookRecordId(arrivalVo.getBookRecordId()); VehicleDepartureLogVo departureLogVo = vehicleDepartureLogMapper.selectByBookRecordId(arrivalVo.getBookRecordId());
...@@ -229,12 +226,12 @@ public class VehicleActiveService { ...@@ -229,12 +226,12 @@ public class VehicleActiveService {
boolean flag = true; boolean flag = true;
VehicleDepartureLog departureLog = departureLogVo.getVehicleDeparture(departureLogVo); VehicleDepartureLog departureLog = departureLogVo.getVehicleDeparture(departureLogVo);
List<VehicleDepartureLog> list = vehicleDepartureLogMapper.selectByVehicle(arrivalVo.getVehicleId()); List<VehicleDepartureLog> list = vehicleDepartureLogMapper.selectByVehicle(arrivalVo.getVehicleId());
for(VehicleDepartureLog vehicleDepartureLogVo : list) { for (VehicleDepartureLog vehicleDepartureLogVo : list) {
if(vehicleDepartureLogVo.getState() != 1 && vehicleDepartureLogVo.getId() > departureLog.getId()) { //后面还有未收车的记录 if (vehicleDepartureLogVo.getState() != 1 && vehicleDepartureLogVo.getId() > departureLog.getId()) { //后面还有未收车的记录
flag = false; flag = false;
} }
} }
if(flag) { //如果此条记录后面还有未收车记录,就不修改车辆状态 if (flag) { //如果此条记录后面还有未收车记录,就不修改车辆状态
int result = vehicleMapper.updateStatus(arrivalVo.getVehicleId(), VehicleStatus.NORMAL.getCode()); int result = vehicleMapper.updateStatus(arrivalVo.getVehicleId(), VehicleStatus.NORMAL.getCode());
// if (result == 0) { // if (result == 0) {
// throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc(), // throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc(),
...@@ -330,7 +327,7 @@ public class VehicleActiveService { ...@@ -330,7 +327,7 @@ public class VehicleActiveService {
} }
} }
} }
if(!(startDate.minusDays(1).compareTo(DateTime.now()) <= 0 && DateTime.now().compareTo(endDate) <= 0 && vehicleBookRecord.getStatus() == VehicleBookRecordStatus.APPROVE.getCode() && (list == null || list.size() <= 0))) { if (!(startDate.minusDays(1).compareTo(DateTime.now()) <= 0 && DateTime.now().compareTo(endDate) <= 0 && vehicleBookRecord.getStatus() == VehicleBookRecordStatus.APPROVE.getCode() && (list == null || list.size() <= 0))) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED.getDesc(), throw new BaseException(ResCode.VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED.getDesc(),
ResCode.VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED.getCode()); ResCode.VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED.getCode());
} }
...@@ -340,7 +337,6 @@ public class VehicleActiveService { ...@@ -340,7 +337,6 @@ public class VehicleActiveService {
public void updateBookRecordStatus(VehicleBookRecord vehicleBookRecord, Integer type) { public void updateBookRecordStatus(VehicleBookRecord vehicleBookRecord, Integer type) {
if (vehicleBookRecord != null) { if (vehicleBookRecord != null) {
if (type == 1) { if (type == 1) {
vehicleBookRecord.setActualStartDate(new Date()); vehicleBookRecord.setActualStartDate(new Date());
...@@ -355,9 +351,9 @@ public class VehicleActiveService { ...@@ -355,9 +351,9 @@ public class VehicleActiveService {
} }
/** /**
* 车辆保养 * 车辆保养
*
* @param vehicleUpkeepVo * @param vehicleUpkeepVo
*/ */
@Transactional @Transactional
...@@ -411,6 +407,7 @@ public class VehicleActiveService { ...@@ -411,6 +407,7 @@ public class VehicleActiveService {
/** /**
* 保养结束 * 保养结束
*
* @param vehicleUpkeepEndVo * @param vehicleUpkeepEndVo
*/ */
@Transactional @Transactional
......
...@@ -1467,10 +1467,31 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -1467,10 +1467,31 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Example example = new Example(Vehicle.class); Example example = new Example(Vehicle.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("code", code); criteria.andEqualTo("code", code);
criteria.andEqualTo("isDel",0);
if (StringUtils.isNotEmpty(id)) { if (StringUtils.isNotEmpty(id)) {
criteria.andNotEqualTo("id", id); criteria.andNotEqualTo("id", id);
} }
int count = mapper.selectCountByExample(example); int count = mapper.selectCountByExample(example);
return count > 0; return count > 0;
} }
public List<String> findbyPlateNumberAndVehicleCod(String plateNumber,String vehicleCode) {
List<String> vehicleIds = Lists.newArrayList();
Example example = new Example(Vehicle.class);
Example.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(plateNumber)) {
criteria.andLike("numberPlate", String.format("%%%s%%", plateNumber.trim()));
}
if (StringUtils.isNotBlank(vehicleCode)) {
criteria.andLike("code", String.format("%%%s%%", vehicleCode.trim()));
}
List<Vehicle> vehicles = mapper.selectByExample(example);
if (CollectionUtils.isEmpty(vehicles)){
return vehicleIds;
}
return vehicles.stream().map(Vehicle::getId).collect(Collectors.toList());
}
} }
...@@ -519,7 +519,7 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use ...@@ -519,7 +519,7 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
} }
@GetMapping("/findwith_plate_number") @GetMapping("/findwith_plate_number")
public List<String> findbyPlateNumber(@RequestParam(value = "plateNumber") String plateNumber){ List<String> findbyPlateNumber(@RequestParam(value = "plateNumber") String plateNumber){
return vehicleBiz.findVehicleIdsByPlateNumber(plateNumber); return vehicleBiz.findVehicleIdsByPlateNumber(plateNumber);
} }
...@@ -529,4 +529,9 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use ...@@ -529,4 +529,9 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
return ObjectRestResponse.succ(exist); return ObjectRestResponse.succ(exist);
} }
@GetMapping("/findVehicleIds")
public List<String> findbyPlateNumberAndVehicleCod(@RequestParam(value = "plateNumber",required = false) String plateNumber,@RequestParam(value = "vehicleCode",required = false) String vehicleCode){
return vehicleBiz.findbyPlateNumberAndVehicleCod(plateNumber,vehicleCode);
}
} }
...@@ -475,6 +475,9 @@ ...@@ -475,6 +475,9 @@
<if test="numberPlate != null"> <if test="numberPlate != null">
and v3.number_plate = #{numberPlate} and v3.number_plate = #{numberPlate}
</if> </if>
<if test="keywords != null and keywords != ''">
and (v3.number_plate like concat('%', #{keywords}, '%') or v3.code like concat('%', #{keywords}, '%'))
</if>
<if test="bookType != null"> <if test="bookType != null">
and v1.book_type = #{bookType} and v1.book_type = #{bookType}
</if> </if>
......
...@@ -383,6 +383,9 @@ ...@@ -383,6 +383,9 @@
<if test="numberPlate != null"> <if test="numberPlate != null">
and v1.number_plate = #{numberPlate} and v1.number_plate = #{numberPlate}
</if> </if>
<if test="keywords != null and keywords != ''">
and (v1.number_plate like concat('%', #{keywords}, '%') or v1.code like concat('%', #{keywords}, '%'))
</if>
<if test="status != null"> <if test="status != null">
and v1.status = #{status} and v1.status = #{status}
</if> </if>
......
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