保存子订单的追加扣减记录
This commit is contained in:
parent
32a7dc96ea
commit
352a4323d0
|
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
|||
import com.ghy.common.enums.PayStatus;
|
||||
import com.ghy.common.enums.PayTypeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
|
|
@ -15,6 +16,7 @@ import java.time.LocalDateTime;
|
|||
* 订单追加扣减
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OrderAddSubtract {
|
||||
|
||||
private Long id;
|
||||
|
|
|
|||
|
|
@ -15,5 +15,7 @@ public interface OrderAddSubtractMapper {
|
|||
|
||||
List<OrderAddSubtract> select(OrderAddSubtract insert);
|
||||
|
||||
List<OrderAddSubtract> selectByOrderDetail(Long orderDetailId);
|
||||
|
||||
OrderAddSubtract selectById(Long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -797,8 +797,9 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
|||
FinancialDetail financialDetail = financialDetailService.selectByOrderDetailId(orderDetail.getId());
|
||||
Assert.notNull(financialDetail, "找不到财务单");
|
||||
|
||||
// 派单金额 = 财务单金额 - 已支付的加价记录
|
||||
// 可用派单金额 = 财务单金额 - 已支付的加价记录 - 已支付的追加记录
|
||||
BigDecimal paiDanMoney = financialDetail.getPayMoney();
|
||||
|
||||
// 已支付的加价记录
|
||||
List<FinancialChangeRecord> paidChangeRecords = financialChangeRecordService.selectByDetailIds(orderDetail.getId().toString())
|
||||
.stream().filter(x -> x.getPayStatus() == 1).collect(Collectors.toList());
|
||||
|
|
@ -806,6 +807,15 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
|||
paiDanMoney = paiDanMoney.subtract(record.getChangeMoney());
|
||||
}
|
||||
|
||||
// 已支付的追加记录
|
||||
List<OrderAddSubtract> orderAdds = orderAddSubtractMapper.select(new OrderAddSubtract()
|
||||
.setOrderDetailId(orderDetail.getId()).setPayStatus(PayStatus.PAID.getCode()));
|
||||
for (OrderAddSubtract oas : orderAdds) {
|
||||
if (MoneyUtil.gt0(oas.getMoney())) {
|
||||
paiDanMoney = paiDanMoney.subtract(oas.getMoney());
|
||||
}
|
||||
}
|
||||
|
||||
// 如果这是扣减操作
|
||||
if (MoneyUtil.lt0(body.getMoney())) {
|
||||
// 扣减金额不能超过派单金额
|
||||
|
|
|
|||
|
|
@ -56,6 +56,9 @@
|
|||
<if test="paymentId != null and paymentId != ''">
|
||||
AND payment_id = #{paymentId}
|
||||
</if>
|
||||
<if test="payStatus != null and payStatus != ''">
|
||||
AND pay_status = #{payStatus}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
|
@ -64,4 +67,9 @@
|
|||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectByOrderDetail" resultMap="ColumnMap">
|
||||
<include refid="selectColumns"/>
|
||||
WHERE order_detail_id = #{orderDetailId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue