CustomerCommonServiceImpl.java 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. package com.iamberry.rst.service.cm;
  2. import com.iamberry.rst.core.cm.*;
  3. import com.iamberry.rst.faces.cm.CustomerCommonService;
  4. import com.iamberry.rst.service.cm.mapper.*;
  5. import com.iamberry.rst.util.CustomerCommonUtil;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Service;
  8. import org.springframework.transaction.annotation.Transactional;
  9. import java.beans.Transient;
  10. import java.util.ArrayList;
  11. import java.util.List;
  12. @Service
  13. public class CustomerCommonServiceImpl implements CustomerCommonService {
  14. @Autowired
  15. private CustomerCommonService customerCommonService;
  16. @Autowired
  17. private RepairMapper repairMapper;
  18. @Autowired
  19. private BackGoodsMapper backGoodsMapper;
  20. @Autowired
  21. private NoreasonBackMapper noreasonBackMapper;
  22. @Autowired
  23. private ReissueMapper reissueMapper;
  24. @Autowired
  25. private RenewedMapper renewedMapper;
  26. @Autowired
  27. private ClosedFittingMapper closedFittingMapper;
  28. @Autowired
  29. private ClosedProdcueMapper closedProdcueMapper;
  30. @Autowired
  31. private SendProdcueMapper sendProdcueMapper;
  32. @Autowired
  33. private SendFittingMapper sendFittingMapper;
  34. @Autowired
  35. private CustomerCommonMapper customerCommonMapper;
  36. @Autowired
  37. private CustomerInfoMapper customerInfoMapper;
  38. @Autowired
  39. private PostageMapper postageMapper;
  40. @Autowired
  41. private RelationOrderMapper relationOrderMapper;
  42. @Autowired
  43. private SalesOrderMapper salesOrderMapper;
  44. @Override
  45. public CustomerCommon getListProduceAndFitting(CustomerCommon customerCommon) {
  46. ClosedProdcue closedProdcue = new ClosedProdcue();
  47. closedProdcue.setClosedProdcueType(customerCommon.getCustomerIsSolve());
  48. closedProdcue.setRelationId(customerCommon.getRelationId());
  49. customerCommon.setClosedProdcues(closedProdcueMapper.listclosedProdcue(closedProdcue));
  50. SendProdcue sendProdcue = new SendProdcue();
  51. sendProdcue.setSendProduceType(customerCommon.getCustomerIsSolve());
  52. sendProdcue.setRelationId(customerCommon.getRelationId());
  53. customerCommon.setSendProdcues(sendProdcueMapper.listSendProdcue(sendProdcue));
  54. return customerCommon;
  55. }
  56. @Override
  57. public List<CustomerCommon> listCustomerCommon(CustomerCommon customerCommon) {
  58. List<CustomerCommon> customerCommonList = customerCommonMapper.listCustomerCommon(customerCommon);
  59. for (CustomerCommon c : customerCommonList) {
  60. RelationOrder relationOrder = new RelationOrder();
  61. relationOrder.setRelationId(c.getRelationId());
  62. relationOrder.setRelationType(c.getCustomerIsSolve());
  63. List<RelationOrder> relationOrderList = relationOrderMapper.getRelationOrderList(relationOrder);
  64. List<SalesOrder> orderList = new ArrayList<>();
  65. for (RelationOrder ro : relationOrderList) {
  66. SalesOrder salesOrder = salesOrderMapper.getSalesOrderById(ro.getSalesId());
  67. if(salesOrder != null ){
  68. SalesOrderItem salesOrderItem = new SalesOrderItem();
  69. salesOrderItem.setItemOrderId(salesOrder.getSalesId());
  70. salesOrder.setSalesOrderItemList(salesOrderMapper.listSalesOrderItem(salesOrderItem));
  71. orderList.add(salesOrder);
  72. }
  73. }
  74. c.setSalesOrderList(orderList);
  75. SendProdcue sendProdcue = new SendProdcue();
  76. sendProdcue.setRelationId(c.getRelationId());
  77. sendProdcue.setSendProduceType(c.getCustomerIsSolve()); //sendProduceType
  78. List<SendProdcue> sendProdcueList = sendProdcueMapper.listSendProdcue(sendProdcue);
  79. c.setSendProdcues(sendProdcueList);
  80. ClosedProdcue closedProdcue = new ClosedProdcue();
  81. closedProdcue.setRelationId(c.getRelationId());
  82. closedProdcue.setClosedProdcueType(c.getCustomerIsSolve());
  83. List<ClosedProdcue> closedProdcueList = closedProdcueMapper.listclosedProdcue(closedProdcue);
  84. c.setClosedProdcues(closedProdcueList);
  85. }
  86. // List<CustomerCommon> customerCommonList = new ArrayList<>();
  87. // /*换新*/
  88. // Renewed renewed = (Renewed)CustomerCommonUtil.getRelation(3,customerCommon);
  89. // List<Renewed> renewedList = renewedMapper.listRenewed(renewed);
  90. // customerCommonList.addAll(CustomerCommonUtil.listToCustomerCommon(3,renewedList));
  91. //
  92. // /*维修*/
  93. // Repair repair = (Repair)CustomerCommonUtil.getRelation(4,customerCommon);
  94. // List<Repair> repairList = repairMapper.listRepair(repair);
  95. // customerCommonList.addAll(CustomerCommonUtil.listToCustomerCommon(4,repairList));
  96. //
  97. // /*补发*/
  98. // Reissue reissue = (Reissue)CustomerCommonUtil.getRelation(5,customerCommon);
  99. // List<Reissue> reissueList = reissueMapper.listReissue(reissue);
  100. // customerCommonList.addAll(CustomerCommonUtil.listToCustomerCommon(5,reissueList));
  101. //
  102. // /*退货*/
  103. // BackGoods backGoods = (BackGoods)CustomerCommonUtil.getRelation(6,customerCommon);
  104. // List<BackGoods> backGoodsList = backGoodsMapper.listBackGoods(backGoods);
  105. // customerCommonList.addAll(CustomerCommonUtil.listToCustomerCommon(6,backGoodsList));
  106. //
  107. // /*无理由退货*/
  108. // NoreasonBack noreasonBack = (NoreasonBack)CustomerCommonUtil.getRelation(7,customerCommon);
  109. // List<NoreasonBack> noreasonBackList = noreasonBackMapper.listNoreasonBack(noreasonBack);
  110. // customerCommonList.addAll(CustomerCommonUtil.listToCustomerCommon(7,noreasonBackList));
  111. return customerCommonList;
  112. }
  113. @Override
  114. public Integer listCustomerCommonByStatus(CustomerCommon customerCommon) {
  115. return customerCommonMapper.listCustomerCommonByStatus(customerCommon);
  116. }
  117. @Override
  118. @Transactional
  119. public Integer updateCustomerCommon(CustomerCommon customerCommon) {
  120. Integer flag = 0;
  121. // switch (customerCommon.getCustomerIsSolve()){
  122. // case 3:
  123. // Renewed renewed = (Renewed)CustomerCommonUtil.getRelation(3,customerCommon);
  124. // flag = renewedMapper.updateRenewedInfo(renewed);
  125. // break;
  126. // case 4:
  127. // Repair repair = (Repair)CustomerCommonUtil.getRelation(4,customerCommon);
  128. // flag = repairMapper.updateRepairInfo(repair);
  129. // break;
  130. // case 5:
  131. // Reissue reissue = (Reissue)CustomerCommonUtil.getRelation(5,customerCommon);
  132. // flag = reissueMapper.updateReissueInfo(reissue);
  133. // break;
  134. // case 6:
  135. // BackGoods backGoods = (BackGoods)CustomerCommonUtil.getRelation(6,customerCommon);
  136. // flag = backGoodsMapper.updateBackGoods(backGoods);
  137. // break;
  138. // case 7:
  139. // NoreasonBack noreasonBack = (NoreasonBack)CustomerCommonUtil.getRelation(7,customerCommon);
  140. // flag = noreasonBackMapper.updateNoreasonBack(noreasonBack);
  141. // break;
  142. // default:
  143. // flag = 0;
  144. // break;
  145. // }
  146. return flag;
  147. }
  148. @Override
  149. @Transactional
  150. public Integer updateCommonAndAddPostage(CustomerCommon customerCommon) {
  151. CustomerCommon newCc = new CustomerCommon();
  152. newCc.setRelationId(customerCommon.getRelationId());
  153. newCc.setRelationBackStatus(4); //已签收
  154. newCc.setCustomerIsSolve(customerCommon.getCustomerIsSolve());
  155. Integer flag = customerCommonService.updateCustomerCommon(newCc);
  156. if(flag < 1){
  157. throw new RuntimeException("修改状态失败");
  158. }
  159. // CustomerInfo customerInfo = customerInfoMapper.getCustomerInfo(customerCommon.getCustomerId());
  160. // if(customerInfo == null){
  161. // throw new RuntimeException("查询客诉失败");
  162. // }
  163. //1:已解决 2:未解决 3:换新 4:维修 5:补发 6:退货 7:无理由退货
  164. // if(customerCommon.getCustomerIsSolve() == 3 || customerCommon.getCustomerIsSolve() == 4
  165. // || customerCommon.getCustomerIsSolve() == 6|| customerCommon.getCustomerIsSolve() == 7){
  166. // if(customerCommon.getRelationIsTransfer() != 0){ //需要转邮费
  167. // Postage postage = new Postage();
  168. // postage.setAdminId(customerInfo.getAdminId()); //客服
  169. // postage.setPostageCustomerStatus(1); //待申请
  170. // postage.setPostageOrderSource(customerInfo.getStoreId()); //店铺id
  171. // postage.setPostageTreatmentMethod(customerCommon.getCustomerIsSolve()); //处理方式
  172. // postage.setSalesOrderId(customerCommon.getSalesOrderId()); //efast订单号
  173. // postage.setPostageClientName(customerCommon.getRelationBackName());
  174. // postage.setPostageClientTel(customerCommon.getRelationBackTel());
  175. // postage.setPostageClientAddress(customerCommon.getRelationSendAddress());
  176. // postage.setPostageLogisticsCompany(customerCommon.getRelationBackLogisticsCompany());
  177. // postage.setPostageLogisticsNo(customerCommon.getRelationBackLogisticsNo());
  178. // postage.setPostageAmount(customerCommon.getRelationBackPostage()); //寄回邮费
  179. // postage.setPostageAlipay(customerCommon.getRelationAlipay()); //支付宝账户
  180. // postage.setPostageAlipayName(customerCommon.getRelationAlipayName()); //支付宝账号名称
  181. // flag = postageMapper.savePostage(postage);
  182. // if(flag < 1){
  183. // throw new RuntimeException("添加邮费转账失败");
  184. // }
  185. // }
  186. // }
  187. return flag;
  188. }
  189. }