123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- package com.pj.api.service;
- import cn.hutool.core.bean.BeanUtil;
- import cn.hutool.core.util.StrUtil;
- import com.pj.api.bo.InOutRecordBO;
- import com.pj.project.tb_business.TbBusiness;
- import com.pj.project.tb_business.TbBusinessService;
- import com.pj.project.tb_business_car.TbBusinessCar;
- import com.pj.project.tb_business_car.TbBusinessCarService;
- import com.pj.project.tb_costomer.TbCostomer;
- import com.pj.project.tb_costomer.TbCostomerService;
- import com.pj.project.tb_pass_record.TbPassRecord;
- import com.pj.project.tb_pass_record.TbPassRecordService;
- import com.pj.utils.cache.RedisUtil;
- import com.pj.utils.so.SoMap;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.context.annotation.Lazy;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import javax.annotation.Resource;
- import java.math.BigDecimal;
- import java.util.*;
- /**
- *
- */
- @Service
- @Transactional(rollbackFor = Exception.class)
- @Slf4j
- public class ApiService {
- @Resource
- TbCostomerService tbCostomerService;
- @Resource
- @Lazy
- TbBusinessService tbBusinessService;
- @Resource
- TbPassRecordService tbPassRecordService;
- @Resource
- @Lazy
- TbBusinessCarService tbBusinessCarService;
- public List<InOutRecordBO> getInOutRecord(SoMap so) {
- List<TbPassRecord> passRecords = tbPassRecordService.getList(so);
- List<InOutRecordBO> recordList = new ArrayList<>();
- for (TbPassRecord passRecord : passRecords) {
- InOutRecordBO record = new InOutRecordBO();
- BeanUtil.copyProperties(passRecord, record);
- TbCostomer costomer = tbCostomerService.getById(passRecord.getCustomerId());
- record.setCustomerContact(costomer.getPhone()).setDutyPeople(costomer.getDutyPeople());
- recordList.add(record);
- }
- return recordList;
- }
- public List<TbCostomer> getCustomerList(SoMap so) {
- List<TbCostomer> list = tbCostomerService.getList(so);
- return list;
- }
- public void confirmCustomer(Long customerId, String judgeContent) {
- TbCostomer costomer = tbCostomerService.getById(customerId);
- if (costomer != null && costomer.getJudgeStatus() == 1) {
- tbCostomerService.judge(customerId + "", 2, judgeContent);
- }
- }
- public List<TbBusinessCar> searchPartCar(String carNo) {
- return tbBusinessCarService.searchPartCar(carNo);
- }
- public void confirm(List<String> ids) {
- tbBusinessService.confirm(ids);
- }
- public Map<String, Object> getBusinessMoney(String businessId, String state) {
- return tbBusinessService.getBusinessMoney(businessId, state);
- }
- public Map<String, Object> getPartCarByChannel(String channel) {
- Map<String, Object> result = new HashMap<>();
- String carNo = RedisUtil.get(channel);
- if (StrUtil.isEmpty(carNo)) {
- return result;
- }
- TbBusinessCar tbBusinessCar = tbBusinessCarService.findInBuNoOutAndNotPay(carNo);
- Date now=new Date();
- BigDecimal price = tbBusinessService.calculationPartMoney(tbBusinessCar.getRealInTime(), now, tbBusinessCar.getCarSize());
- BigDecimal dif = price.subtract(tbBusinessCar.getMoney());
- Map<String, Object> car = new HashMap<>();
- car.put("id",tbBusinessCar.getId());
- car.put("carNo",tbBusinessCar.getCarNo());
- car.put("price",dif);
- result.put("total",dif);
- result.put("cars",Collections.singleton(car));
- return result;
- }
- }
|