RepairCustomerService.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package com.fdkankan.sale.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.fdkankan.sale.common.ResultCode;
  4. import com.fdkankan.sale.entity.*;
  5. import com.fdkankan.sale.exception.BusinessException;
  6. import com.fdkankan.sale.service.*;
  7. import com.fdkankan.sale.vo.request.RepairParam;
  8. import org.apache.commons.lang3.StringUtils;
  9. import org.springframework.beans.BeanUtils;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Service;
  12. import java.util.List;
  13. import java.util.stream.Collectors;
  14. @Service
  15. public class RepairCustomerService {
  16. @Autowired
  17. ICustomerService customerService;
  18. @Autowired
  19. ICustomerAddressService customerAddressService;
  20. @Autowired
  21. IRepairService repairService;
  22. @Autowired
  23. IRepairLogService repairLogService;
  24. @Autowired
  25. IRepairCommentService repairCommentService;
  26. @Autowired
  27. IRepairInvoiceService repairInvoiceService;
  28. @Autowired
  29. IRepairPayService repairPayService;
  30. @Autowired
  31. IPriceListService priceListService;
  32. public Object getRepairByOpenId(String openId) {
  33. List<Customer> list = customerService.getByOpenId(openId);
  34. if(list!= null && list.size() >0){
  35. List<String> repairIds = list.stream().map(Customer::getRepairId).collect(Collectors.toList());
  36. if(repairIds.size() >0){
  37. LambdaQueryWrapper<Repair> wrapper = new LambdaQueryWrapper<>();
  38. wrapper.in(Repair::getRepairId,repairIds);
  39. wrapper.orderByDesc(Repair::getCreateTime);
  40. return repairService.list(wrapper);
  41. }
  42. }
  43. return null;
  44. }
  45. /**
  46. * * status 0待接单,1待检测,2待报价,3待确认,4已取消,5待备料,6待回收,7维修中,8待测试,
  47. * * 9待支付(已完结),10待收货,11已发货,12已评价
  48. */
  49. public void confirmRepair(RepairParam param) {
  50. if(StringUtils.isBlank(param.getRepairId()) ){
  51. throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
  52. }
  53. Repair repair = repairService.getById(param.getRepairId());
  54. if(repair == null){
  55. throw new BusinessException(ResultCode.ORDER_PAY_NOT_EXITS);
  56. }
  57. if(repair.getStatus() != 3){
  58. throw new BusinessException(ResultCode.REPAIR_STATUS_NOT_EXITS);
  59. }
  60. if(param.getConfirm() == 0){
  61. priceListService.updateStatusByRepairId(repair.getRepairId());
  62. repairLogService.saveBySysUser(param.getUserId(),repair.getRepairId(),5,"确认维修");
  63. }
  64. if(param.getConfirm() == 1) {
  65. repairLogService.saveBySysUser(param.getUserId(),repair.getRepairId(),4,"拒绝报价");
  66. //存在确认过的报价单,返回维修中
  67. List<PriceList> priceLists = priceListService.getByRepairIdAndStatus(repair.getRepairId(),1);
  68. if(priceLists !=null && priceLists.size() >0){
  69. repairService.updateRepairStatus(repair.getRepairId(),6);
  70. }
  71. }
  72. }
  73. public void comment(RepairParam param) {
  74. if(StringUtils.isBlank(param.getRepairId()) ){
  75. throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
  76. }
  77. RepairComment repairComment = repairCommentService.getByRepairId(param.getRepairId());
  78. if(repairComment !=null){
  79. throw new BusinessException(ResultCode.ORDER_COMMENT_EXITS);
  80. }
  81. repairComment = new RepairComment();
  82. BeanUtils.copyProperties(param,repairComment);
  83. repairCommentService.save(repairComment);
  84. repairService.updateCommentStatus(param.getRepairId());
  85. }
  86. public void invoiceApply(RepairInvoice param) {
  87. if(StringUtils.isBlank(param.getRepairId()) ){
  88. throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
  89. }
  90. Repair repair = repairService.getById(param.getRepairId());
  91. if(repair == null){
  92. throw new BusinessException(ResultCode.ORDER_PAY_NOT_EXITS);
  93. }
  94. RepairInvoice repairInvoice = repairInvoiceService.getByRepairId(param.getRepairId());
  95. if(repairInvoice !=null){
  96. throw new BusinessException(ResultCode.ORDER_INVOICE_EXITS);
  97. }
  98. RepairPay repairPay = repairPayService.getByRepairId(param.getRepairId(), 1);
  99. if(repairPay == null){
  100. throw new BusinessException(ResultCode.ORDER_NOt_PAY);
  101. }
  102. repairInvoice = new RepairInvoice();
  103. BeanUtils.copyProperties(param,repairInvoice);
  104. repairInvoiceService.save(repairInvoice);
  105. }
  106. public Object getInvoiceAddress(String repairId) {
  107. CustomerAddress customerAddress = customerAddressService.getByRepairId(repairId);
  108. RepairPay repairPay = repairPayService.getByRepairId(repairId, 1);
  109. if(repairPay == null){
  110. throw new BusinessException(ResultCode.ORDER_NOt_PAY);
  111. }
  112. customerAddress.setPayAmount(repairPay.getPayAmount());
  113. return customerAddress;
  114. }
  115. }