RepairCustomerService.java 4.3 KB

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