| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- package com.izouma.awesomeadmin.service.impl;
- import java.util.*;
- import com.izouma.awesomeadmin.dao.StoreInfoMapper;
- import com.izouma.awesomeadmin.dao.UserInfoMapper;
- import com.izouma.awesomeadmin.model.StoreInfo;
- import com.izouma.awesomeadmin.model.UserInfo;
- import org.apache.log4j.Logger;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.izouma.awesomeadmin.constant.AppConstant;
- import com.izouma.awesomeadmin.dto.Page;
- import com.izouma.awesomeadmin.model.PersonalAuthentication;
- import com.izouma.awesomeadmin.service.PersonalAuthenticationService;
- import com.izouma.awesomeadmin.dao.PersonalAuthenticationMapper;
- /**
- * service接口实现类
- */
- @Service
- public class PersonalAuthenticationServiceImpl implements PersonalAuthenticationService {
- private static Logger logger = Logger.getLogger(PersonalAuthenticationServiceImpl.class);
- @Autowired
- private PersonalAuthenticationMapper personalAuthenticationMapper;
- @Autowired
- private UserInfoMapper userInfoMapper;
- @Autowired
- private StoreInfoMapper storeInfoMapper;
- @Override
- public List<PersonalAuthentication> getPersonalAuthenticationList(PersonalAuthentication record) {
- logger.info("getPersonalAuthenticationList");
- try {
- return personalAuthenticationMapper.queryAllPersonalAuthentication(record);
- } catch (Exception e) {
- logger.error("getPersonalAuthenticationList", e);
- }
- return null;
- }
- @Override
- public List<PersonalAuthentication> getPersonalAuthenticationByPage(Page page, PersonalAuthentication record) {
- logger.info("getPersonalAuthenticationByPage");
- try {
- Map<String, Object> parameter = new HashMap<String, Object>();
- parameter.put("record", record);
- parameter.put(AppConstant.PAGE, page);
- return personalAuthenticationMapper.queryPersonalAuthenticationByPage(parameter);
- } catch (Exception e) {
- logger.error("getPersonalAuthenticationByPage", e);
- }
- return null;
- }
- @Override
- public PersonalAuthentication getPersonalAuthenticationById(String id) {
- logger.info("getPersonalAuthenticationyId");
- try {
- return personalAuthenticationMapper.selectByPrimaryKey(Integer.valueOf(id));
- } catch (Exception e) {
- logger.error("getPersonalAuthenticationById", e);
- }
- return null;
- }
- @Override
- public PersonalAuthentication getPersonalAuthentication(PersonalAuthentication record) {
- logger.info("getPersonalAuthentication");
- try {
- return personalAuthenticationMapper.queryPersonalAuthentication(record);
- } catch (Exception e) {
- logger.error("getPersonalAuthentication", e);
- }
- return null;
- }
- @Override
- public boolean createPersonalAuthentication(PersonalAuthentication record) {
- logger.info("createPersonalAuthentication");
- try {
- int updates = personalAuthenticationMapper.insertSelective(record);
- if (updates > 0) {
- return true;
- }
- } catch (Exception e) {
- logger.error("createPersonalAuthentication", e);
- }
- return false;
- }
- @Override
- public boolean deletePersonalAuthentication(String id) {
- logger.info("deletePersonalAuthentication");
- try {
- int updates = personalAuthenticationMapper.delete(id);
- if (updates > 0) {
- return true;
- }
- } catch (Exception e) {
- logger.error("deletePersonalAuthentication", e);
- }
- return false;
- }
- @Override
- public boolean updatePersonalAuthentication(PersonalAuthentication record) {
- logger.info("updatePersonalAuthentication");
- try {
- int updates = personalAuthenticationMapper.updateByPrimaryKeySelective(record);
- if (updates > 0) {
- return true;
- }
- } catch (Exception e) {
- logger.error("updatePersonalAuthentication", e);
- }
- return false;
- }
- @Override
- public boolean pass(PersonalAuthentication record) {
- logger.info("passPersonalAuthentication,通过开店申请");
- try {
- PersonalAuthentication personalAuthentication = personalAuthenticationMapper.selectByPrimaryKey(record.getId());
- if (personalAuthentication != null) {
- if (personalAuthentication.getStatusFlag() == 1) {
- return true;
- }
- UserInfo userInfo = new UserInfo();
- userInfo.setId(personalAuthentication.getUserId());
- userInfo.setApproveFlag("Y");
- userInfo.setStoreFlag("Y");
- userInfo.setApproveStep(5);
- userInfoMapper.updateByPrimaryKeySelective(userInfo);//更新用户状态。
- Map<String, Object> parameter = new HashMap<String, Object>();
- parameter.put("userId", personalAuthentication.getUserId());
- parameter.put("useFlag", "Y");
- parameter.put("typeFlag", 2);//个人店铺
- storeInfoMapper.updateUseFlagByUserId(parameter);//更新店铺为可用
- record.setStatusFlag(1);//通过
- int updates = personalAuthenticationMapper.updateByPrimaryKeySelective(record);
- if (updates > 0) {
- return true;
- }
- }
- } catch (Exception e) {
- logger.error("passPersonalAuthentication,通过开店申请异常", e);
- }
- return false;
- }
- @Override
- public boolean fail(PersonalAuthentication record) {
- logger.info("failPersonalAuthentication,失败开店申请");
- try {
- PersonalAuthentication personalAuthentication = personalAuthenticationMapper.selectByPrimaryKey(record.getId());
- if (personalAuthentication != null) {
- if (personalAuthentication.getStatusFlag() == 0) {//审核中才能失败
- UserInfo userInfo = new UserInfo();
- userInfo.setId(personalAuthentication.getUserId());
- userInfo.setApproveFlag("N");
- userInfo.setStoreFlag("N");
- userInfo.setApproveStep(1);
- userInfoMapper.updateByPrimaryKeySelective(userInfo);//更新用户状态。
- Map<String, Object> parameter = new HashMap<String, Object>();
- parameter.put("userId", personalAuthentication.getUserId());
- parameter.put("useFlag", "N");
- parameter.put("typeFlag", 2);//个人店铺
- storeInfoMapper.updateUseFlagByUserId(parameter);//更新店铺为不可用
- record.setStatusFlag(2);//失败
- int updates = personalAuthenticationMapper.updateByPrimaryKeySelective(record);
- if (updates > 0) {
- return true;
- }
- }
- }
- } catch (Exception e) {
- logger.error("failPersonalAuthentication,失败开店申请异常", e);
- }
- return false;
- }
- }
|