| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.enums.SystemDataNoEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import javax.annotation.Resource; |
| | | |
| | |
| | | import com.ruoyi.tms.domain.TmsDispatchOrder; |
| | | import com.ruoyi.tms.domain.TmsFinance; |
| | | import com.ruoyi.tms.domain.vo.FinanceDetailItem; |
| | | import com.ruoyi.tms.domain.vo.FinanceDetailRow; |
| | | import com.ruoyi.tms.mapper.TmsDispatchOrderMapper; |
| | | import com.ruoyi.tms.mapper.TmsFinanceMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Override |
| | | public int insertTmsFinanceDetail(TmsFinanceDetail tmsFinanceDetail) |
| | | { |
| | | TmsFinance tmsFinance = tmsFinanceMapper.selectOne(new LambdaQueryWrapper<TmsFinance>() |
| | | .eq(TmsFinance::getType, tmsFinanceDetail.getFinanceType()) |
| | | .eq(TmsFinance::getDispatchId, tmsFinanceDetail.getDispatchOrderId()) |
| | | .ne(TmsFinance::getStatus, 2) |
| | | .last("limit 1") |
| | | ); |
| | | // TmsFinance tmsFinance = tmsFinanceMapper.selectOne(new LambdaQueryWrapper<TmsFinance>() |
| | | // .eq(TmsFinance::getType, tmsFinanceDetail.getFinanceType()) |
| | | // .eq(TmsFinance::getDispatchId, tmsFinanceDetail.getDispatchOrderId()) |
| | | // .ne(TmsFinance::getStatus, 2) |
| | | // .last("limit 1") |
| | | // ); |
| | | |
| | | |
| | | if (StringUtils.isNotEmpty(tmsFinanceDetail.getFeeType())){ |
| | | addItem(tmsFinance, tmsFinanceDetail); |
| | | } |
| | | //if (StringUtils.isNotEmpty(tmsFinanceDetail.getFeeType())){ |
| | | addItem(tmsFinanceDetail); |
| | | // } |
| | | |
| | | // 1、查询当前调度单对应的费用 |
| | | List<FinanceDetailItem> items = tmsFinanceDetail.getItems(); |
| | | |
| | | if (items != null && !items.isEmpty()){ |
| | | items.forEach(item->{ |
| | | TmsFinanceDetail tmsFinanceDetailNew = BeanUtil.copyProperties(tmsFinanceDetail, TmsFinanceDetail.class); |
| | | BeanUtil.copyProperties(item, tmsFinanceDetailNew); |
| | | tmsFinanceDetailNew.setActualFeeAmount(item.getPrice().multiply(BigDecimal.valueOf(item.getCount()))); |
| | | addItem(tmsFinance, tmsFinanceDetailNew); |
| | | }); |
| | | } |
| | | // List<FinanceDetailItem> items = tmsFinanceDetail.getItems(); |
| | | // |
| | | // if (items != null && !items.isEmpty()){ |
| | | // items.forEach(item->{ |
| | | // TmsFinanceDetail tmsFinanceDetailNew = BeanUtil.copyProperties(tmsFinanceDetail, TmsFinanceDetail.class); |
| | | // BeanUtil.copyProperties(item, tmsFinanceDetailNew); |
| | | // tmsFinanceDetailNew.setActualFeeAmount(item.getPrice().multiply(BigDecimal.valueOf(item.getCount()))); |
| | | // addItem(tmsFinance, tmsFinanceDetailNew); |
| | | // }); |
| | | // } |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | public void addItem (TmsFinance tmsFinance, TmsFinanceDetail tmsFinanceDetail){ |
| | | if (tmsFinance == null){ |
| | | |
| | | TmsDispatchOrder tmsDispatchOrder = tmsDispatchOrderMapper.selectTmsDispatchOrderById(tmsFinanceDetail.getDispatchOrderId()); |
| | | if (tmsDispatchOrder == null){ |
| | | throw new RuntimeException("未找到对应的调度单"); |
| | | } |
| | | tmsFinance = BeanUtil.copyProperties(tmsDispatchOrder,TmsFinance.class); |
| | | SystemDataNoEnum systemDataNoEnum = tmsFinanceDetail.getFinanceType() == 0 ? SystemDataNoEnum.YFD : |
| | | tmsFinanceDetail.getFinanceType() == 1 ? SystemDataNoEnum.YSD : SystemDataNoEnum.OF; |
| | | tmsFinance.setSystemCode(systemDataNoService.getNoByKey(systemDataNoEnum)); |
| | | tmsFinance.setDispatchId(tmsFinanceDetail.getDispatchOrderId()); |
| | | tmsFinance.setType(tmsFinanceDetail.getFinanceType()); |
| | | tmsFinance.setStatus(0); |
| | | tmsFinance.setTotalAmount(tmsFinanceDetail.getActualFeeAmount()); |
| | | tmsFinance.setCreateBy(SecurityUtils.getUsername()); |
| | | tmsFinance.setUpdateBy(SecurityUtils.getUsername()); |
| | | tmsFinance.setCreateTime(DateUtils.getNowDate()); |
| | | tmsFinance.setUpdateTime(DateUtils.getNowDate()); |
| | | // 添加费用主表 |
| | | tmsFinanceMapper.insertTmsFinance(tmsFinance); |
| | | }else{ |
| | | tmsFinance.setTotalAmount(tmsFinance. |
| | | getTotalAmount().add(tmsFinanceDetail.getActualFeeAmount())); |
| | | tmsFinanceMapper.updateTmsFinance(tmsFinance); |
| | | @Override |
| | | public int saveTmsFinanceDetail(TmsFinanceDetail tmsFinanceDetail) { |
| | | if (StringUtils.isNotEmpty(tmsFinanceDetail.getFeeType() ) && |
| | | tmsFinanceDetail.getActualFeeAmount() != null){ |
| | | insertTmsFinanceDetail(tmsFinanceDetail); |
| | | } |
| | | tmsFinanceDetail.setFinanceId(tmsFinance.getId()); |
| | | List<FinanceDetailRow> rowItems = tmsFinanceDetail.getRowItems(); |
| | | if (rowItems != null && !rowItems.isEmpty()){ |
| | | |
| | | for (FinanceDetailRow rowItem : rowItems){ |
| | | if (rowItem.getIsYF() != null && rowItem.getIsYF() == 0){ |
| | | rowItem.setYfPrice(null); |
| | | rowItem.setYfCurrency(null); |
| | | rowItem.setYfServiceProviderId(null); |
| | | rowItem.setYfServiceProviderType(null); |
| | | rowItem.setYfServiceProviderIdType(null); |
| | | rowItem.setYfServiceProviderName(null); |
| | | } |
| | | TmsFinanceDetail tmsFinanceDetailNew = BeanUtil.copyProperties(rowItem, TmsFinanceDetail.class); |
| | | tmsFinanceDetailMapper.updateTmsFinanceDetail(tmsFinanceDetailNew); |
| | | } |
| | | } |
| | | return 1; |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public int saveTmsFinanceDetail2(List<TmsFinanceDetail> tmsFinanceDetails) { |
| | | String username = SecurityUtils.getUsername(); |
| | | Long userId = SecurityUtils.getUserId(); |
| | | Date nowDate = DateUtils.getNowDate(); |
| | | for (TmsFinanceDetail tmsFinanceDetail : tmsFinanceDetails) { |
| | | if (StringUtils.isNotEmpty(tmsFinanceDetail.getFeeType() ) && |
| | | tmsFinanceDetail.getActualFeeAmount() != null) { |
| | | tmsFinanceDetail.setCreateBy(username); |
| | | tmsFinanceDetail.setInitialFeeAmount(tmsFinanceDetail.getActualFeeAmount()); |
| | | tmsFinanceDetail.setCreateId(userId); |
| | | tmsFinanceDetail.setFeeCreateTime(nowDate); |
| | | tmsFinanceDetail.setCreateTime(nowDate); |
| | | }else { |
| | | throw new ServiceException("金额或者费用类型不能为空"); |
| | | } |
| | | } |
| | | |
| | | return tmsFinanceDetailMapper.insertTmsFinanceDetailBatch(tmsFinanceDetails); |
| | | |
| | | } |
| | | |
| | | public void addItem (TmsFinanceDetail tmsFinanceDetail){ |
| | | // if (tmsFinance == null){ |
| | | // |
| | | // TmsDispatchOrder tmsDispatchOrder = tmsDispatchOrderMapper.selectTmsDispatchOrderById(tmsFinanceDetail.getDispatchOrderId()); |
| | | // if (tmsDispatchOrder == null){ |
| | | // throw new RuntimeException("未找到对应的调度单"); |
| | | // } |
| | | // tmsFinance = BeanUtil.copyProperties(tmsDispatchOrder,TmsFinance.class); |
| | | // SystemDataNoEnum systemDataNoEnum = tmsFinanceDetail.getFinanceType() == 0 ? SystemDataNoEnum.YFD : |
| | | // tmsFinanceDetail.getFinanceType() == 1 ? SystemDataNoEnum.YSD : SystemDataNoEnum.OF; |
| | | // tmsFinance.setSystemCode(systemDataNoService.getNoByKey(systemDataNoEnum)); |
| | | // tmsFinance.setDispatchId(tmsFinanceDetail.getDispatchOrderId()); |
| | | // tmsFinance.setType(tmsFinanceDetail.getFinanceType()); |
| | | // tmsFinance.setStatus(0); |
| | | // tmsFinance.setTotalAmount(tmsFinanceDetail.getActualFeeAmount()); |
| | | // tmsFinance.setCreateBy(SecurityUtils.getUsername()); |
| | | // tmsFinance.setUpdateBy(SecurityUtils.getUsername()); |
| | | // tmsFinance.setCreateTime(DateUtils.getNowDate()); |
| | | // tmsFinance.setUpdateTime(DateUtils.getNowDate()); |
| | | // // 添加费用主表 |
| | | // tmsFinanceMapper.insertTmsFinance(tmsFinance); |
| | | // }else{ |
| | | // tmsFinance.setTotalAmount(tmsFinance. |
| | | // getTotalAmount().add(tmsFinanceDetail.getActualFeeAmount())); |
| | | // tmsFinanceMapper.updateTmsFinance(tmsFinance); |
| | | // } |
| | | // tmsFinanceDetail.setFinanceId(tmsFinance.getId()); |
| | | tmsFinanceDetail.setCreateBy(SecurityUtils.getUsername()); |
| | | tmsFinanceDetail.setInitialFeeAmount(tmsFinanceDetail.getActualFeeAmount()); |
| | | tmsFinanceDetail.setCreateId(SecurityUtils.getUserId()); |