CompanyAuthenticationServiceImpl.java 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. package com.izouma.awesomeadmin.service.impl;
  2. import com.izouma.awesomeadmin.constant.AppConstant;
  3. import com.izouma.awesomeadmin.dao.CompanyAuthenticationMapper;
  4. import com.izouma.awesomeadmin.dao.StoreInfoMapper;
  5. import com.izouma.awesomeadmin.dao.UserInfoMapper;
  6. import com.izouma.awesomeadmin.dto.Page;
  7. import com.izouma.awesomeadmin.model.CompanyAuthentication;
  8. import com.izouma.awesomeadmin.model.UserInfo;
  9. import com.izouma.awesomeadmin.service.CompanyAuthenticationService;
  10. import org.apache.log4j.Logger;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Service;
  13. import java.util.HashMap;
  14. import java.util.List;
  15. import java.util.Map;
  16. /**
  17. * service接口实现类
  18. */
  19. @Service
  20. public class CompanyAuthenticationServiceImpl implements CompanyAuthenticationService {
  21. private static Logger logger = Logger.getLogger(CompanyAuthenticationServiceImpl.class);
  22. @Autowired
  23. private CompanyAuthenticationMapper companyAuthenticationMapper;
  24. @Autowired
  25. private UserInfoMapper userInfoMapper;
  26. @Autowired
  27. private StoreInfoMapper storeInfoMapper;
  28. @Override
  29. public List<CompanyAuthentication> getCompanyAuthenticationList(CompanyAuthentication record) {
  30. logger.info("getCompanyAuthenticationList");
  31. try {
  32. return companyAuthenticationMapper.queryAllCompanyAuthentication(record);
  33. } catch (Exception e) {
  34. logger.error("getCompanyAuthenticationList", e);
  35. }
  36. return null;
  37. }
  38. @Override
  39. public List<CompanyAuthentication> getCompanyAuthenticationByPage(Page page, CompanyAuthentication record) {
  40. logger.info("getCompanyAuthenticationByPage");
  41. try {
  42. Map<String, Object> parameter = new HashMap<String, Object>();
  43. parameter.put("record", record);
  44. parameter.put(AppConstant.PAGE, page);
  45. return companyAuthenticationMapper.queryCompanyAuthenticationByPage(parameter);
  46. } catch (Exception e) {
  47. logger.error("getCompanyAuthenticationByPage", e);
  48. }
  49. return null;
  50. }
  51. @Override
  52. public CompanyAuthentication getCompanyAuthenticationById(String id) {
  53. logger.info("getCompanyAuthenticationyId");
  54. try {
  55. return companyAuthenticationMapper.selectByPrimaryKey(Integer.valueOf(id));
  56. } catch (Exception e) {
  57. logger.error("getCompanyAuthenticationById", e);
  58. }
  59. return null;
  60. }
  61. @Override
  62. public CompanyAuthentication getCompanyAuthentication(CompanyAuthentication record) {
  63. logger.info("getCompanyAuthentication");
  64. try {
  65. return companyAuthenticationMapper.queryCompanyAuthentication(record);
  66. } catch (Exception e) {
  67. logger.error("getCompanyAuthentication", e);
  68. }
  69. return null;
  70. }
  71. @Override
  72. public boolean createCompanyAuthentication(CompanyAuthentication record) {
  73. logger.info("createCompanyAuthentication");
  74. try {
  75. int updates = companyAuthenticationMapper.insertSelective(record);
  76. if (updates > 0) {
  77. return true;
  78. }
  79. } catch (Exception e) {
  80. logger.error("createCompanyAuthentication", e);
  81. }
  82. return false;
  83. }
  84. @Override
  85. public boolean deleteCompanyAuthentication(String id) {
  86. logger.info("deleteCompanyAuthentication");
  87. try {
  88. int updates = companyAuthenticationMapper.delete(id);
  89. if (updates > 0) {
  90. return true;
  91. }
  92. } catch (Exception e) {
  93. logger.error("deleteCompanyAuthentication", e);
  94. }
  95. return false;
  96. }
  97. @Override
  98. public boolean updateCompanyAuthentication(CompanyAuthentication record) {
  99. logger.info("updateCompanyAuthentication");
  100. try {
  101. int updates = companyAuthenticationMapper.updateByPrimaryKeySelective(record);
  102. if (updates > 0) {
  103. return true;
  104. }
  105. } catch (Exception e) {
  106. logger.error("updateCompanyAuthentication", e);
  107. }
  108. return false;
  109. }
  110. @Override
  111. public boolean pass(CompanyAuthentication record) {
  112. logger.info("passCompanyAuthentication,通过开店申请");
  113. try {
  114. CompanyAuthentication companyAuthentication = companyAuthenticationMapper.selectByPrimaryKey(record.getId());
  115. if (companyAuthentication != null) {
  116. if (companyAuthentication.getStatusFlag() == 1) {
  117. return true;
  118. }
  119. UserInfo userInfo = new UserInfo();
  120. userInfo.setId(companyAuthentication.getUserId());
  121. userInfo.setApproveFlag("Y");
  122. userInfo.setStoreFlag("Y");
  123. userInfo.setCompanyFlag("Y");
  124. userInfo.setApproveStep(5);
  125. userInfoMapper.updateByPrimaryKeySelective(userInfo);//更新用户状态。
  126. Map<String, Object> parameter = new HashMap<String, Object>();
  127. parameter.put("userId", companyAuthentication.getUserId());
  128. parameter.put("useFlag", "Y");
  129. parameter.put("typeFlag", 1);//企业店铺
  130. storeInfoMapper.updateUseFlagByUserId(parameter);//更新店铺为可用
  131. record.setStatusFlag(1);//通过
  132. int updates = companyAuthenticationMapper.updateByPrimaryKeySelective(record);
  133. if (updates > 0) {
  134. return true;
  135. }
  136. }
  137. } catch (Exception e) {
  138. logger.error("passCompanyAuthentication,通过开店申请异常", e);
  139. }
  140. return false;
  141. }
  142. @Override
  143. public boolean fail(CompanyAuthentication record) {
  144. logger.info("failCompanyAuthentication,失败开店申请");
  145. try {
  146. CompanyAuthentication companyAuthentication = companyAuthenticationMapper.selectByPrimaryKey(record.getId());
  147. if (companyAuthentication != null) {
  148. if (companyAuthentication.getStatusFlag() == 0) {//审核中才能失败
  149. UserInfo userInfo = new UserInfo();
  150. userInfo.setId(companyAuthentication.getUserId());
  151. userInfo.setApproveFlag("N");
  152. userInfo.setStoreFlag("N");
  153. userInfo.setCompanyFlag("N");
  154. userInfo.setApproveStep(1);
  155. userInfoMapper.updateByPrimaryKeySelective(userInfo);//更新用户状态。
  156. Map<String, Object> parameter = new HashMap<String, Object>();
  157. parameter.put("userId", companyAuthentication.getUserId());
  158. parameter.put("useFlag", "N");
  159. parameter.put("typeFlag", 1);//企业店铺
  160. storeInfoMapper.updateUseFlagByUserId(parameter);//更新店铺为不可用
  161. record.setStatusFlag(2);//失败
  162. int updates = companyAuthenticationMapper.updateByPrimaryKeySelective(record);
  163. if (updates > 0) {
  164. return true;
  165. }
  166. }
  167. }
  168. } catch (Exception e) {
  169. logger.error("failCompanyAuthentication,失败开店申请异常", e);
  170. }
  171. return false;
  172. }
  173. }