update 使占桩订单免费/修改订单金额

This commit is contained in:
Lemon
2023-09-08 15:51:16 +08:00
parent 43364537d3
commit a89d7e7ec0
6 changed files with 99 additions and 6 deletions

View File

@@ -0,0 +1,31 @@
package com.jsowell.pile.dto;
import lombok.Data;
import java.math.BigDecimal;
/**
* 修改占桩订单免费/修改金额DTO
*
* @author Lemon
* @Date 2023/9/8 15:04
*/
@Data
public class MakeOrderFreeDTO {
private Long id;
/**
* 修改类型1-直接免费2-修改金额)
*/
private String type;
/**
* 占桩订单
*/
private String occupyCode;
/**
* 订单金额
*/
private BigDecimal orderAmount;
}

View File

@@ -122,4 +122,11 @@ public interface OrderPileOccupyMapper {
* @return 占桩订单集合
*/
public List<OrderPileOccupy> selectOrderPileOccupyList(OrderPileOccupy orderPileOccupy);
/**
* 使该笔订单免费
* @param occupyCode
* @return
*/
int makeOrderFree(String occupyCode);
}

View File

@@ -2,10 +2,7 @@ package com.jsowell.pile.service;
import com.jsowell.common.core.page.PageResponse;
import com.jsowell.pile.domain.OrderPileOccupy;
import com.jsowell.pile.dto.PayOrderDTO;
import com.jsowell.pile.dto.GenerateOccupyOrderDTO;
import com.jsowell.pile.dto.QueryOccupyOrderDTO;
import com.jsowell.pile.dto.RemoteGroundLockDTO;
import com.jsowell.pile.dto.*;
import com.jsowell.pile.vo.uniapp.OccupyOrderDetailVO;
import com.jsowell.pile.vo.uniapp.OrderPileOccupyVO;
@@ -101,4 +98,11 @@ public interface OrderPileOccupyService{
* @param occupyCode
*/
OccupyOrderDetailVO getOccupyOrderDetail(String occupyCode);
/**
* 使该笔订单免费/修改订单金额(后管用)
* @param dto
* @return
*/
int updateOrderInfoForWeb(MakeOrderFreeDTO dto);
}

View File

@@ -191,7 +191,7 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
* 占桩订单停止计费/停止占桩订单计费
* 收到地锁升起指令,调用这个方法,停止计时
*
* @param pileSn 充电站编号
* @param pileSn 充电站编号
* @param connectorCode 枪口号
*/
@Override
@@ -311,6 +311,7 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
/**
* 通过memberId查询未支付状态订单
*
* @param memberId
* @return
*/
@@ -354,6 +355,7 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
/**
* 根据桩编号、枪口号查询最近一条占桩订单
* draft
*
* @param pileSn
* @param connectorCode
* @return
@@ -373,6 +375,7 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
/**
* 查询占桩中的订单
*
* @param pileSn
* @param connectorCode
* @return
@@ -413,6 +416,7 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
/**
* 获取占桩订单详情
*
* @param occupyCode
*/
@Override
@@ -429,6 +433,33 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
return vo;
}
/**
* 使该笔订单免费/修改订单金额(后管用)
*
* @param dto
* @return
*/
@Override
public int updateOrderInfoForWeb(MakeOrderFreeDTO dto) {
// 先取type
String type = dto.getType();
if (StringUtils.equals("1", type)) {
// 直接免费
return orderPileOccupyMapper.makeOrderFree(dto.getOccupyCode());
} else {
// 修改订单金额
OrderPileOccupy occupy = selectByPrimaryKey(dto.getId().intValue());
BigDecimal orderAmount = occupy.getOrderAmount();
if (orderAmount.subtract(dto.getOrderAmount()).compareTo(BigDecimal.ZERO) < 0 ) {
// 说明改的金额要比实际订单金额大,不予修改
return 0;
}
occupy.setOrderAmount(dto.getOrderAmount());
return orderPileOccupyMapper.updateByPrimaryKeySelective(occupy);
}
}
/*
* 支付占桩订单
*

View File

@@ -926,4 +926,12 @@
<if test="pileConnectorCode != null and pileConnectorCode != ''"> and pile_connector_code = #{pileConnectorCode}</if>
</where>
</select>
<update id="makeOrderFree">
update
order_pile_occupy
set
status = '1', pay_status = '2'
where occupy_code = #{occupyCode,jdbcType=VARCHAR}
</update>
</mapper>