123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- package com.fdkankan.sale.service.impl;
- import java.math.BigDecimal;
- import java.util.Date;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.fdkankan.sale.common.PageInfo;
- import com.fdkankan.sale.common.ResultCode;
- import com.fdkankan.sale.entity.*;
- import com.fdkankan.sale.exception.BusinessException;
- import com.fdkankan.sale.service.*;
- import com.fdkankan.sale.util.DateUtil;
- import com.fdkankan.sale.util.StatusUtil;
- import com.fdkankan.sale.vo.request.*;
- import com.fdkankan.sale.vo.response.PriceListVo;
- import com.fdkankan.sale.vo.response.RepairerVo;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.stream.Collectors;
- @Service
- public class RepairSaleService {
- @Autowired
- IRepairService repairService;
- @Autowired
- IRepairLogService repairLogService;
- @Autowired
- IOrderReceivingService orderReceivingService;
- @Autowired
- ICustomerService customerService;
- @Autowired
- ICustomerAddressService customerAddressService;
- @Autowired
- ICameraService cameraService;
- @Autowired
- ISysUserService sysUserService;
- @Autowired
- IRepairRegisterService repairRegisterService;
- @Autowired
- IRepairRegisterPartService repairRegisterPartService;
- @Autowired
- IPriceListService priceListService;
- @Autowired
- IRepairPayService repairPayService;
- /**
- * 售后工程师
- * statusParam 0 待接单,1待跟进,2已完结
- * status 0待接单,1待检测,2待报价,3待确认,4已取消,5待备料,6待回收,7维修中,8待测试,
- * 9待支付(已完结),10待发货,11已发货,12已评价
- */
- public PageInfo saleOrderList(RepairParam param) {
- List<Integer> repairStatus = StatusUtil.getSaleStatus(param.getStatusParam());
- param.setStatusList(repairStatus);
- Page<RepairerVo> voPage = repairService.saleOrderList(param);
- for (RepairerVo record : voPage.getRecords()) {
- BigDecimal payAmount = priceListService.getAmountByRepairId(record.getRepairId());
- record.setPayAmount(payAmount);
- }
- return PageInfo.PageInfo(voPage);
- }
- public void orderReceiving(OrderReceivingParam param, Long sysUserId ) {
- if(param.getRepairId() == null){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- param.setSysUserId(sysUserId);
- orderReceivingService.save(param);
- repairLogService.saveBySysUser(sysUserId,param.getRepairId(),1,"接单");
- }
- public void recording(RecordingParam param, Long userId,Integer receiverType) {
- if(StringUtils.isBlank(param.getCameraSnCode())){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- Camera camera = cameraService.getBySnCode(param.getCameraSnCode());
- if(camera == null){
- throw new BusinessException(ResultCode.CAMERA_SN_NOT_EXITS);
- }
- Integer cameraType = cameraService.getCameraTypeByCameraId(camera.getId());
- Repair repair = new Repair();
- BeanUtils.copyProperties(param,repair);
- repair.setRepairId(DateUtil.getDate(DateUtil.repairIdFmt));
- repair.setCameraType(cameraType);
- repair.setSysUserId(userId);
- Customer customer = new Customer();
- BeanUtils.copyProperties(param,customer);
- customer.setRepairId(repair.getRepairId());
- customerService.save(customer);
- CustomerAddress customerAddress = new CustomerAddress();
- BeanUtils.copyProperties(param,customerAddress);
- customerAddress.setCustomerId(customer.getCustomerId());
- customerAddress.setRepairId(repair.getRepairId());
- customerAddressService.save(customerAddress);
- repairService.save(repair);
- repairLogService.saveBySysUser(userId,repair.getRepairId(),0,"录单");
- //自动接单
- if(receiverType == 0){
- OrderReceiving orderReceiving = new OrderReceiving();
- BeanUtils.copyProperties(param,orderReceiving);
- orderReceiving.setOrderFaultImg(param.getFaultImg());
- orderReceiving.setOrderFaultMsg(param.getFaultMsg());
- orderReceiving.setSysUserId(userId);
- orderReceiving.setRepairId(repair.getRepairId());
- orderReceivingService.save(orderReceiving);
- repairLogService.saveBySysUser(userId,repair.getRepairId(),1,"接单");
- }
- }
- public void addOrUpdatePriceList(PriceListParam param, Long userId) {
- if(StringUtils.isBlank(param.getRepairId()) ||
- param.getPriceLists() == null || param.getPriceLists().size() <=0){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- Repair repair = repairService.getById(param.getRepairId());
- if(repair == null){
- throw new BusinessException(ResultCode.REPAIR_NOT_EXITS);
- }
- List<PriceList> priceLists = param.getPriceLists();
- for (PriceList priceList : priceLists) {
- priceList.setRepairId(param.getRepairId());
- }
- priceListService.saveOrUpdateBatch(priceLists);
- repairLogService.saveBySysUser(userId,param.getRepairId(),3,"维修报价");
- }
- public PriceListVo getPriceList(String repairId) {
- if(StringUtils.isBlank(repairId)){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- List<PriceList> priceLists = priceListService.getByRepairId(repairId);
- List<RepairLog> repairLogs = repairLogService.getByRepairIdAndStatus(repairId, 3);
- PriceListVo priceListVo = new PriceListVo();
- priceListVo.setPriceLists(priceLists);
- priceListVo.setCount(repairLogs.size() +1);
- return priceListVo;
- }
- public void payRegister(PayRegisterParam param,Long userId) {
- if(StringUtils.isBlank(param.getRepairId())
- || param.getPayType() == null || StringUtils.isBlank(param.getPayImg())){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- Repair repair = repairService.getById(param.getRepairId());
- if(repair == null){
- throw new BusinessException(ResultCode.REPAIR_NOT_EXITS);
- }
- RepairPay repairPay = new RepairPay();
- repairPay.setRepairId(repair.getRepairId());
- repairPay.setPayType(param.getPayType());
- repairPay.setPayImg(param.getPayImg());
- repairPay.setSysUserId(userId);
- repairPayService.save(repairPay);
- repairLogService.saveBySysUser(userId,param.getRepairId(),10,"付款登记");
- }
- public void sendRegister(PayRegisterParam param,Long userId) {
- if(StringUtils.isBlank(param.getRepairId()) || StringUtils.isBlank(param.getTrackingNum())){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- Repair repair = repairService.getById(param.getRepairId());
- if(repair == null){
- throw new BusinessException(ResultCode.REPAIR_NOT_EXITS);
- }
- customerAddressService.setTrackingNumByRepairId(repair.getRepairId(),param.getTrackingNum());
- repairLogService.saveBySysUser(userId,param.getRepairId(),11,"发货登记");
- }
- }
|