| package com.matrix.biz.service.impl; | 
|   | 
| import com.matrix.biz.bean.BizUser; | 
| import com.matrix.biz.dao.BizUserDao; | 
| import com.matrix.biz.service.BizUserService; | 
| import com.matrix.core.constance.MatrixConstance; | 
| import com.matrix.core.constance.SystemErrorCode; | 
| import com.matrix.core.exception.GlobleException; | 
| import com.matrix.core.pojo.PaginationVO; | 
| import com.matrix.core.tools.ModelUtils; | 
| import com.matrix.core.tools.UUIDUtil; | 
| import com.matrix.system.common.constance.AppConstance; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Service; | 
|   | 
| import java.util.Date; | 
| import java.util.List; | 
| import java.util.Map; | 
|   | 
| /** | 
|  * @description service接口实现类(用户表) | 
|  * @author jyy | 
|  * @date 2019-05-31 10:03 | 
|  */ | 
| @Service | 
| public class BizUserServiceImpl implements BizUserService { | 
|   | 
|      | 
|     @Autowired | 
|     private BizUserDao bizUserDao; | 
|   | 
|      | 
|     @Override | 
|     public int add(BizUser bizUser){ | 
|         // 设置基本字段信息,临时字段 | 
|         bizUser.setUserIsAuthorize(AppConstance.IS_NOT_AUTHORIZE); | 
|         bizUser.setCreateBy(AppConstance.USER_TYPE_ADMIN); | 
|         bizUser.setUpdateBy(AppConstance.USER_TYPE_ADMIN); | 
|         bizUser.setUserId(UUIDUtil.getRandomID()); | 
|         return bizUserDao.insert(bizUser); | 
|          | 
|     } | 
|      | 
|     @Override | 
|     public int batchAdd(List<BizUser>  bizUserList) { | 
|         //这里没有做基本字段的设置,如有需要请自己实现     | 
|         int num = 0; | 
|         int c = 10000; | 
|         int size = bizUserList.size()/c + 1; | 
|         for(int i=0; i<size; i++) { | 
|             int begin = i*c; | 
|             int end = (i+1)*c; | 
|             end = end >= bizUserList.size() ? bizUserList.size() : end; | 
|             List<BizUser> insertList = bizUserList.subList(begin, end); | 
|             num += bizUserDao.batchInsert(insertList); | 
|         } | 
|         return num; | 
|          | 
|     } | 
|      | 
|      | 
|         | 
|     @Override | 
|     public int modifyByMap(BizUser oldBizUser | 
|     ,BizUser newBizUser){ | 
|      | 
|         Map<String, Object> modifyMap = null; | 
|         try { | 
|             if (!ModelUtils.isModified(oldBizUser, newBizUser)) { | 
|                 return MatrixConstance.DML_SUCCESSS; | 
|             } | 
|             modifyMap = ModelUtils.comparePojo2Map(oldBizUser, newBizUser); | 
|         } catch (Exception e) { | 
|             throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL, e, newBizUser); | 
|         } | 
|         if (modifyMap.size() > 0) { | 
|             modifyMap.put("userId", oldBizUser.getUserId()); | 
|             bizUserDao.updateByMap(modifyMap); | 
|         } | 
|         return MatrixConstance.DML_SUCCESSS; | 
|     } | 
|      | 
|     @Override | 
|     public int modifyByModel(BizUser bizUser){ | 
|      | 
|         return bizUserDao.updateByModel(bizUser); | 
|      | 
|     } | 
|      | 
|      | 
|      | 
|     @Override | 
|     public int remove(List<String> list){ | 
|      | 
|         return bizUserDao.deleteByIds(list); | 
|      | 
|     } | 
|   | 
|     @Override | 
|     public int removeById(String userId){ | 
|      | 
|         return bizUserDao.deleteById(userId); | 
|      | 
|     } | 
|      | 
|     @Override | 
|     public int removeByModel(BizUser bizUser){ | 
|      | 
|         return bizUserDao.deleteByModel(bizUser); | 
|      | 
|     } | 
|      | 
|      | 
|     @Override | 
|     public List<BizUser> findInPage(BizUser bizUser,  PaginationVO pageVo){ | 
|      | 
|         return bizUserDao.selectInPage(bizUser , pageVo); | 
|      | 
|     } | 
|      | 
|     @Override | 
|     public List<BizUser> findByModel(BizUser bizUser){ | 
|      | 
|         return bizUserDao.selectByModel(bizUser); | 
|      | 
|     } | 
|      | 
|     @Override | 
|     public int  findTotal(BizUser bizUser){ | 
|      | 
|         return bizUserDao.selectTotalRecord(bizUser); | 
|      | 
|     } | 
|      | 
|     @Override | 
|     public BizUser  findById(String userId){ | 
|      | 
|         return bizUserDao.selectById(userId); | 
|      | 
|     } | 
|   | 
|      | 
|     @Override | 
|     public BizUser findByOpenId(String openId) { | 
|         return bizUserDao.findByOpenId(openId); | 
|     } | 
|      | 
|     /** | 
|      * 保存用户信息 | 
|      */ | 
|     @Override | 
|     public int saveUserInfo(BizUser bizUser) { | 
|              | 
|         return bizUserDao.updateByModel(bizUser); | 
|     } | 
|   | 
|     /** | 
|      * 设置成为推广员 | 
|      * @param invitationId | 
|      */ | 
|     @Override | 
|     public int setToBeAnSalesman(String openId,String invitationId) { | 
|         BizUser bizUser=bizUserDao.findByOpenId(openId); | 
|         bizUser.setIsSales(BizUser.IS_SALES); | 
|         bizUser.setParentOpenId(invitationId); | 
|         bizUser.setBindingParentTime(new Date()); | 
|         return bizUserDao.updateByModel(bizUser); | 
|     } | 
| } |