| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- package com.izouma.awesomeadmin.service.impl;
- import com.izouma.awesomeadmin.constant.AppConstant;
- import com.izouma.awesomeadmin.dao.CompanyAuthenticationMapper;
- import com.izouma.awesomeadmin.dao.StoreInfoMapper;
- import com.izouma.awesomeadmin.dao.UserInfoMapper;
- import com.izouma.awesomeadmin.dto.Page;
- import com.izouma.awesomeadmin.model.CompanyAuthentication;
- import com.izouma.awesomeadmin.model.UserInfo;
- import com.izouma.awesomeadmin.service.CompanyAuthenticationService;
- import org.apache.log4j.Logger;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * service接口实现类
- */
- @Service
- public class CompanyAuthenticationServiceImpl implements CompanyAuthenticationService {
- private static Logger logger = Logger.getLogger(CompanyAuthenticationServiceImpl.class);
- @Autowired
- private CompanyAuthenticationMapper companyAuthenticationMapper;
- @Autowired
- private UserInfoMapper userInfoMapper;
- @Autowired
- private StoreInfoMapper storeInfoMapper;
- @Override
- public List<CompanyAuthentication> getCompanyAuthenticationList(CompanyAuthentication record) {
- logger.info("getCompanyAuthenticationList");
- try {
- return companyAuthenticationMapper.queryAllCompanyAuthentication(record);
- } catch (Exception e) {
- logger.error("getCompanyAuthenticationList", e);
- }
- return null;
- }
- @Override
- public List<CompanyAuthentication> getCompanyAuthenticationByPage(Page page, CompanyAuthentication record) {
- logger.info("getCompanyAuthenticationByPage");
- try {
- Map<String, Object> parameter = new HashMap<String, Object>();
- parameter.put("record", record);
- parameter.put(AppConstant.PAGE, page);
- return companyAuthenticationMapper.queryCompanyAuthenticationByPage(parameter);
- } catch (Exception e) {
- logger.error("getCompanyAuthenticationByPage", e);
- }
- return null;
- }
- @Override
- public CompanyAuthentication getCompanyAuthenticationById(String id) {
- logger.info("getCompanyAuthenticationyId");
- try {
- return companyAuthenticationMapper.selectByPrimaryKey(Integer.valueOf(id));
- } catch (Exception e) {
- logger.error("getCompanyAuthenticationById", e);
- }
- return null;
- }
- @Override
- public CompanyAuthentication getCompanyAuthentication(CompanyAuthentication record) {
- logger.info("getCompanyAuthentication");
- try {
- return companyAuthenticationMapper.queryCompanyAuthentication(record);
- } catch (Exception e) {
- logger.error("getCompanyAuthentication", e);
- }
- return null;
- }
- @Override
- public boolean createCompanyAuthentication(CompanyAuthentication record) {
- logger.info("createCompanyAuthentication");
- try {
- int updates = companyAuthenticationMapper.insertSelective(record);
- if (updates > 0) {
- return true;
- }
- } catch (Exception e) {
- logger.error("createCompanyAuthentication", e);
- }
- return false;
- }
- @Override
- public boolean deleteCompanyAuthentication(String id) {
- logger.info("deleteCompanyAuthentication");
- try {
- int updates = companyAuthenticationMapper.delete(id);
- if (updates > 0) {
- return true;
- }
- } catch (Exception e) {
- logger.error("deleteCompanyAuthentication", e);
- }
- return false;
- }
- @Override
- public boolean updateCompanyAuthentication(CompanyAuthentication record) {
- logger.info("updateCompanyAuthentication");
- try {
- int updates = companyAuthenticationMapper.updateByPrimaryKeySelective(record);
- if (updates > 0) {
- return true;
- }
- } catch (Exception e) {
- logger.error("updateCompanyAuthentication", e);
- }
- return false;
- }
- @Override
- public boolean pass(CompanyAuthentication record) {
- logger.info("passCompanyAuthentication,通过开店申请");
- try {
- CompanyAuthentication companyAuthentication = companyAuthenticationMapper.selectByPrimaryKey(record.getId());
- if (companyAuthentication != null) {
- if (companyAuthentication.getStatusFlag() == 1) {
- return true;
- }
- UserInfo userInfo = new UserInfo();
- userInfo.setId(companyAuthentication.getUserId());
- userInfo.setApproveFlag("Y");
- userInfo.setStoreFlag("Y");
- userInfo.setCompanyFlag("Y");
- userInfo.setApproveStep(5);
- userInfoMapper.updateByPrimaryKeySelective(userInfo);//更新用户状态。
- Map<String, Object> parameter = new HashMap<String, Object>();
- parameter.put("userId", companyAuthentication.getUserId());
- parameter.put("useFlag", "Y");
- parameter.put("typeFlag", 1);//企业店铺
- storeInfoMapper.updateUseFlagByUserId(parameter);//更新店铺为可用
- record.setStatusFlag(1);//通过
- int updates = companyAuthenticationMapper.updateByPrimaryKeySelective(record);
- if (updates > 0) {
- return true;
- }
- }
- } catch (Exception e) {
- logger.error("passCompanyAuthentication,通过开店申请异常", e);
- }
- return false;
- }
- @Override
- public boolean fail(CompanyAuthentication record) {
- logger.info("failCompanyAuthentication,失败开店申请");
- try {
- CompanyAuthentication companyAuthentication = companyAuthenticationMapper.selectByPrimaryKey(record.getId());
- if (companyAuthentication != null) {
- if (companyAuthentication.getStatusFlag() == 0) {//审核中才能失败
- UserInfo userInfo = new UserInfo();
- userInfo.setId(companyAuthentication.getUserId());
- userInfo.setApproveFlag("N");
- userInfo.setStoreFlag("N");
- userInfo.setCompanyFlag("N");
- userInfo.setApproveStep(1);
- userInfoMapper.updateByPrimaryKeySelective(userInfo);//更新用户状态。
- Map<String, Object> parameter = new HashMap<String, Object>();
- parameter.put("userId", companyAuthentication.getUserId());
- parameter.put("useFlag", "N");
- parameter.put("typeFlag", 1);//企业店铺
- storeInfoMapper.updateUseFlagByUserId(parameter);//更新店铺为不可用
- record.setStatusFlag(2);//失败
- int updates = companyAuthenticationMapper.updateByPrimaryKeySelective(record);
- if (updates > 0) {
- return true;
- }
- }
- }
- } catch (Exception e) {
- logger.error("failCompanyAuthentication,失败开店申请异常", e);
- }
- return false;
- }
- }
|