Commit af2e0357 by zhanghj

V1.6.0--提交生成对账单详情功能

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@25788 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 0c7e0600
...@@ -35,5 +35,13 @@ public interface SysReconciliationDetailMapper { ...@@ -35,5 +35,13 @@ public interface SysReconciliationDetailMapper {
int deleteByPrimaryKey(Integer id); int deleteByPrimaryKey(Integer id);
int insert(SysReconciliationDetail record);
int insertSelective(SysReconciliationDetail record);
int updateByPrimaryKeySelective(SysReconciliationDetail record);
int updateByPrimaryKey(SysReconciliationDetail record);
void addSysReconciliationDetail(List<OrderForReconciliationDto> list); void addSysReconciliationDetail(List<OrderForReconciliationDto> list);
} }
...@@ -10,7 +10,7 @@ public class SysOperationAdvance { ...@@ -10,7 +10,7 @@ public class SysOperationAdvance {
private String orderSn; private String orderSn;
private Byte orderType; private Integer orderType;
private String carOwner; private String carOwner;
...@@ -52,11 +52,11 @@ public class SysOperationAdvance { ...@@ -52,11 +52,11 @@ public class SysOperationAdvance {
this.orderSn = orderSn == null ? null : orderSn.trim(); this.orderSn = orderSn == null ? null : orderSn.trim();
} }
public Byte getOrderType() { public Integer getOrderType() {
return orderType; return orderType;
} }
public void setOrderType(Byte orderType) { public void setOrderType(Integer orderType) {
this.orderType = orderType; this.orderType = orderType;
} }
......
package com.glsx.ordercenter.service.impl; package com.glsx.ordercenter.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
import com.glsx.ordercenter.constants.OrderTypeEnum; import com.glsx.ordercenter.constants.OrderTypeEnum;
import com.glsx.ordercenter.constants.ReconciliationStatusEnum; import com.glsx.ordercenter.constants.ReconciliationStatusEnum;
import com.glsx.ordercenter.dto.*; import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.ReconciliationDetailQuery;
import com.glsx.ordercenter.dto.ReconciliationDetailRemove;
import com.glsx.ordercenter.dto.ReconciliationDetailVO;
import com.glsx.ordercenter.dto.ReconciliationQuery;
import com.glsx.ordercenter.dto.ThreeValues;
import com.glsx.ordercenter.dto.req.GenerateReconciliationDetailReq; import com.glsx.ordercenter.dto.req.GenerateReconciliationDetailReq;
import com.glsx.ordercenter.exception.BusinessException; import com.glsx.ordercenter.exception.BusinessException;
import com.glsx.ordercenter.mapper.SysReconciliationDetailMapper; import com.glsx.ordercenter.mapper.SysReconciliationDetailMapper;
import com.glsx.ordercenter.mapper.SysReconciliationMapper; import com.glsx.ordercenter.mapper.SysReconciliationMapper;
import com.glsx.ordercenter.mapper.SysReconciliationMonthlyMapper; import com.glsx.ordercenter.mapper.SysReconciliationMonthlyMapper;
import com.glsx.ordercenter.pojo.*; import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.ordercenter.pojo.SysReconciliation;
import com.glsx.ordercenter.pojo.SysReconciliationDetail;
import com.glsx.ordercenter.pojo.SysReconciliationMonthly;
import com.glsx.ordercenter.pojo.SysServiceItem;
import com.glsx.ordercenter.pojo.user.SysMerchant; import com.glsx.ordercenter.pojo.user.SysMerchant;
import com.glsx.ordercenter.service.OrderSubsidyService; import com.glsx.ordercenter.service.OrderSubsidyService;
import com.glsx.ordercenter.service.ReconciliationBaseService; import com.glsx.ordercenter.service.ReconciliationBaseService;
...@@ -19,17 +41,6 @@ import com.glsx.ordercenter.service.ReconciliationDetailService; ...@@ -19,17 +41,6 @@ import com.glsx.ordercenter.service.ReconciliationDetailService;
import com.glsx.ordercenter.utils.PageInfoUtil; import com.glsx.ordercenter.utils.PageInfoUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
...@@ -179,13 +190,21 @@ public class ReconciliationDetailServiceImpl implements ReconciliationDetailServ ...@@ -179,13 +190,21 @@ public class ReconciliationDetailServiceImpl implements ReconciliationDetailServ
public ResultObject generate(GenerateReconciliationDetailReq req) { public ResultObject generate(GenerateReconciliationDetailReq req) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
List<SysReconciliationDetail> reconciliationDetailList = reconciliationDetailMapper.getPendingSettlementOrderList(req); List<SysReconciliationDetail> reconciliationDetailList = reconciliationDetailMapper.getPendingSettlementOrderList(req);
reconciliationDetailList.forEach(reconciliationDetail -> { reconciliationDetailList.forEach(reconciliationDetail ->{
Integer orderId = reconciliationDetail.getOrderId(); Integer orderId = reconciliationDetail.getOrderId();
BigDecimal standardAmount = reconciliationDetail.getStandardAmount();
BigDecimal advanceAmount = reconciliationDetail.getAdvanceAmount();
//获取订单的补贴总额
BigDecimal subsidies = orderSubsidyService.getOrderSubsidiesSum(orderId); BigDecimal subsidies = orderSubsidyService.getOrderSubsidiesSum(orderId);
reconciliationDetail.setSubsidyAmount(subsidies); reconciliationDetail.setSubsidyAmount(subsidies);
//BigDecimal advanceAmount = //拟结算金额:单个对账方的对账单包含所有订单服务费用之和,即所有订单标准费用+所有订单补贴之和
//reconciliationDetail.set BigDecimal quasiSettlementAmount = standardAmount.add(subsidies);
//结算金额:拟结算金额 - 运营已垫付金额
BigDecimal settlementAmount = quasiSettlementAmount.subtract(advanceAmount);
reconciliationDetail.setSettlementAmount(settlementAmount);
reconciliationDetail.setCreateTime(new Date());
reconciliationDetailMapper.insertSelective(reconciliationDetail);
}); });
return null; return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
} }
} }
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<select id="getOrderSubsidiesSum" parameterType="java.lang.Integer"> <select id="getOrderSubsidiesSum" parameterType="java.lang.Integer" resultType="java.math.BigDecimal">
select IFNULL(SUM(subsidies),0) select IFNULL(SUM(subsidies),0)
FROM sys_order_subsidy FROM sys_order_subsidy
WHERE order_id = #{orderId} WHERE order_id = #{orderId}
......
...@@ -25,7 +25,232 @@ ...@@ -25,7 +25,232 @@
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, reconciliation_sn, order_sn, order_type, car_owner, vin_no, quasi_settlement_amount, settlement_amount, user_id, user_type, user_name, standard_amount, advance_amount, subsidy_amount, remark, create_by, create_time, update_by, update_time id, reconciliation_sn, order_sn, order_type, car_owner, vin_no, quasi_settlement_amount, settlement_amount, user_id, user_type, user_name, standard_amount, advance_amount, subsidy_amount, remark, create_by, create_time, update_by, update_time
</sql> </sql>
<insert id="insert" parameterType="com.glsx.ordercenter.pojo.SysReconciliationDetail">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_reconciliation_detail (reconciliation_sn, order_sn, order_type,
car_owner, vin_no, quasi_settlement_amount,
settlement_amount, user_id, user_type,
user_name, standard_amount, advance_amount,
subsidy_amount, remark, create_by,
create_time, update_by, update_time
)
values (#{reconciliationSn,jdbcType=VARCHAR}, #{orderSn,jdbcType=VARCHAR}, #{orderType,jdbcType=TINYINT},
#{carOwner,jdbcType=VARCHAR}, #{vinNo,jdbcType=VARCHAR}, #{quasiSettlementAmount,jdbcType=DECIMAL},
#{settlementAmount,jdbcType=DECIMAL}, #{userId,jdbcType=INTEGER}, #{userType,jdbcType=TINYINT},
#{userName,jdbcType=VARCHAR}, #{standardAmount,jdbcType=DECIMAL}, #{advanceAmount,jdbcType=DECIMAL},
#{subsidyAmount,jdbcType=DECIMAL}, #{remark,jdbcType=VARCHAR}, #{createBy,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.glsx.ordercenter.pojo.SysReconciliationDetail">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_reconciliation_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="reconciliationSn != null">
reconciliation_sn,
</if>
<if test="orderSn != null">
order_sn,
</if>
<if test="orderType != null">
order_type,
</if>
<if test="carOwner != null">
car_owner,
</if>
<if test="vinNo != null">
vin_no,
</if>
<if test="quasiSettlementAmount != null">
quasi_settlement_amount,
</if>
<if test="settlementAmount != null">
settlement_amount,
</if>
<if test="userId != null">
user_id,
</if>
<if test="userType != null">
user_type,
</if>
<if test="userName != null">
user_name,
</if>
<if test="standardAmount != null">
standard_amount,
</if>
<if test="advanceAmount != null">
advance_amount,
</if>
<if test="subsidyAmount != null">
subsidy_amount,
</if>
<if test="remark != null">
remark,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="reconciliationSn != null">
#{reconciliationSn,jdbcType=VARCHAR},
</if>
<if test="orderSn != null">
#{orderSn,jdbcType=VARCHAR},
</if>
<if test="orderType != null">
#{orderType,jdbcType=TINYINT},
</if>
<if test="carOwner != null">
#{carOwner,jdbcType=VARCHAR},
</if>
<if test="vinNo != null">
#{vinNo,jdbcType=VARCHAR},
</if>
<if test="quasiSettlementAmount != null">
#{quasiSettlementAmount,jdbcType=DECIMAL},
</if>
<if test="settlementAmount != null">
#{settlementAmount,jdbcType=DECIMAL},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="userType != null">
#{userType,jdbcType=TINYINT},
</if>
<if test="userName != null">
#{userName,jdbcType=VARCHAR},
</if>
<if test="standardAmount != null">
#{standardAmount,jdbcType=DECIMAL},
</if>
<if test="advanceAmount != null">
#{advanceAmount,jdbcType=DECIMAL},
</if>
<if test="subsidyAmount != null">
#{subsidyAmount,jdbcType=DECIMAL},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.glsx.ordercenter.pojo.SysReconciliationDetail">
update sys_reconciliation_detail
<set>
<if test="reconciliationSn != null">
reconciliation_sn = #{reconciliationSn,jdbcType=VARCHAR},
</if>
<if test="orderSn != null">
order_sn = #{orderSn,jdbcType=VARCHAR},
</if>
<if test="orderType != null">
order_type = #{orderType,jdbcType=TINYINT},
</if>
<if test="carOwner != null">
car_owner = #{carOwner,jdbcType=VARCHAR},
</if>
<if test="vinNo != null">
vin_no = #{vinNo,jdbcType=VARCHAR},
</if>
<if test="quasiSettlementAmount != null">
quasi_settlement_amount = #{quasiSettlementAmount,jdbcType=DECIMAL},
</if>
<if test="settlementAmount != null">
settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="userType != null">
user_type = #{userType,jdbcType=TINYINT},
</if>
<if test="userName != null">
user_name = #{userName,jdbcType=VARCHAR},
</if>
<if test="standardAmount != null">
standard_amount = #{standardAmount,jdbcType=DECIMAL},
</if>
<if test="advanceAmount != null">
advance_amount = #{advanceAmount,jdbcType=DECIMAL},
</if>
<if test="subsidyAmount != null">
subsidy_amount = #{subsidyAmount,jdbcType=DECIMAL},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
<where>
<if test="id != null">
and id = #{id,jdbcType=INTEGER}
</if>
<if test="order_sn != null and order_sn !=''">
and order_sn = #{orderSn}
</if>
</where>
</update>
<update id="updateByPrimaryKey" parameterType="com.glsx.ordercenter.pojo.SysReconciliationDetail">
update sys_reconciliation_detail
set reconciliation_sn = #{reconciliationSn,jdbcType=VARCHAR},
order_sn = #{orderSn,jdbcType=VARCHAR},
order_type = #{orderType,jdbcType=TINYINT},
car_owner = #{carOwner,jdbcType=VARCHAR},
vin_no = #{vinNo,jdbcType=VARCHAR},
quasi_settlement_amount = #{quasiSettlementAmount,jdbcType=DECIMAL},
settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
user_id = #{userId,jdbcType=INTEGER},
user_type = #{userType,jdbcType=TINYINT},
user_name = #{userName,jdbcType=VARCHAR},
standard_amount = #{standardAmount,jdbcType=DECIMAL},
advance_amount = #{advanceAmount,jdbcType=DECIMAL},
subsidy_amount = #{subsidyAmount,jdbcType=DECIMAL},
remark = #{remark,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectList" parameterType="com.glsx.ordercenter.dto.ReconciliationDetailQuery" <select id="selectList" parameterType="com.glsx.ordercenter.dto.ReconciliationDetailQuery"
resultMap="BaseResultMap"> resultMap="BaseResultMap">
<if test="keyWord != null and keyWord != ''"> <if test="keyWord != null and keyWord != ''">
...@@ -128,7 +353,8 @@ ...@@ -128,7 +353,8 @@
ELSE ELSE
sma.provider_name sma.provider_name
END END
) AS userName ) AS userName,
IFNULL(soa.amount,0) AS advanceAmount
FROM FROM
sys_order so sys_order so
LEFT JOIN sys_user su ON so.mechanic_id = su.id LEFT JOIN sys_user su ON so.mechanic_id = su.id
...@@ -137,6 +363,7 @@ ...@@ -137,6 +363,7 @@
LEFT JOIN sys_user su2 ON so.merchant_id = su2.id LEFT JOIN sys_user su2 ON so.merchant_id = su2.id
LEFT JOIN sys_manager sma ON so.merchant_id = sma.user_id LEFT JOIN sys_manager sma ON so.merchant_id = sma.user_id
LEFT JOIN sys_user_service_fee susf2 ON sma.user_id = susf2.user_id AND so.service_code = susf2.service_code AND so.order_type = susf2.fee_type LEFT JOIN sys_user_service_fee susf2 ON sma.user_id = susf2.user_id AND so.service_code = susf2.service_code AND so.order_type = susf2.fee_type
LEFT JOIN sys_operation_advance soa ON so.order_sn = soa.order_sn
WHERE so.active_status = 8 AND so.settlement_status = 0 AND DATE_FORMAT(so.complete_time,'%Y-%m') = #{reconciliationCycle}; WHERE so.active_status = 8 AND so.settlement_status = 0 AND DATE_FORMAT(so.complete_time,'%Y-%m') = #{reconciliationCycle};
</select> </select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!