| | |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.http.HttpEntity; |
| | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class OrderTaxiServiceImpl extends ServiceImpl<OrderTaxiMapper, OrderTaxi> implements IOrderTaxiService { |
| | | |
| | |
| | | |
| | | @Override |
| | | public ResultUtil confirmFees1(Integer orderId, Integer type, Double travelFee, String additionalFee) throws Exception { |
| | | log.info("出租车费用确认并结束:订单【{}】类型【{}】里程费【{}】附加费【{}】",orderId, type, travelFee, additionalFee); |
| | | OrderTaxi orderTaxi = this.selectById(orderId); |
| | | log.info("查询出的订单数据为:{}", JSON.toJSONString(orderTaxi)); |
| | | orderTaxi.setPayManner(type); |
| | | if(type == 2){//其他支付,不需要操作,直接完成订单 |
| | | orderTaxi.setOrderMoney(0D); |
| | |
| | | } |
| | | } |
| | | this.updateById(orderTaxi); |
| | | |
| | | log.info("更新后订单数据为:{}", JSON.toJSONString(orderTaxi)); |
| | | Driver driver = driverService.selectById(orderTaxi.getDriverId()); |
| | | |
| | | //回滚司机状态为空闲 |
| | |
| | | return orderTaxi; |
| | | } |
| | | |
| | | |
| | | public OrderTaxi setMoney1(OrderTaxi orderTaxi, Double travelFee, String additionalFee) throws Exception{ |
| | | if (travelFee!=null){ |
| | | String s = travelFee.toString(); |
| | |
| | | orderTaxi.setParkMoney(0D); |
| | | orderTaxi.setRoadTollMoney(0D); |
| | | Company company = companyService.selectById(orderTaxi.getCompanyId()); |
| | | BigDecimal t = new BigDecimal(0); |
| | | BigDecimal t = new BigDecimal("0"); |
| | | if(ToolUtil.isNotEmpty(additionalFee)){//附加费 |
| | | JSONArray jsonArray = JSON.parseArray(additionalFee); |
| | | for(int i = 0; i < jsonArray.size(); i++){ |
| | |
| | | orderAdditionalFee.setAdditionalFeeId(id); |
| | | orderAdditionalFee.setAmount(amount); |
| | | orderAdditionalFeeService.insert(orderAdditionalFee); |
| | | t = t.add(new BigDecimal(amount)); |
| | | if(Objects.nonNull(amount)) { |
| | | t = t.add(new BigDecimal(amount.toString())); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | orderTaxi.setHolidayFee(null == company.getHolidayFee() ? 0D : company.getHolidayFee()); |
| | | BigDecimal sum = new BigDecimal(null == travelFee ? 0 : travelFee).add(new BigDecimal(0)) |
| | | .add(new BigDecimal(0)).add(new BigDecimal(orderTaxi.getHolidayFee())) |
| | | .add(new BigDecimal(null == orderTaxi.getTipMoney() ? 0 : orderTaxi.getTipMoney())).add(t); |
| | | BigDecimal sum = new BigDecimal(String.valueOf(null == travelFee ? "0" : travelFee)).add(new BigDecimal("0")) |
| | | .add(new BigDecimal("0")).add(new BigDecimal(Optional.ofNullable(orderTaxi.getHolidayFee()).map(String::valueOf).orElse("0"))) |
| | | .add(new BigDecimal(String.valueOf(null == orderTaxi.getTipMoney() ? "0" : orderTaxi.getTipMoney()))).add(t); |
| | | orderTaxi.setOrderMoney(sum.setScale(2, BigDecimal.ROUND_DOWN).doubleValue()); |
| | | return orderTaxi; |
| | | } |