com.sw.plugins.customer.organization.service.MemberOrganizationService.java Source code

Java tutorial

Introduction

Here is the source code for com.sw.plugins.customer.organization.service.MemberOrganizationService.java

Source

package com.sw.plugins.customer.organization.service;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import jxl.write.WritableWorkbook;

import org.apache.commons.lang.StringUtils;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.sw.core.initialize.InitData;
import com.sw.core.service.CommonService;
import com.sw.plugins.customer.member.entity.Member;
import com.sw.plugins.customer.member.entity.MemberApplication;
import com.sw.plugins.customer.member.entity.MemberTeamOrOrgHistory;
import com.sw.plugins.customer.member.service.MemberApplicationService;
import com.sw.plugins.customer.member.service.MemberService;
import com.sw.plugins.customer.member.service.MemberTeamOrOrgHistoryService;
import com.sw.plugins.customer.organization.entity.MemberOrganization;
import com.sw.plugins.customer.team.entity.Team;
import com.sw.plugins.customer.team.entity.TeamOrOrgApplication;
import com.sw.plugins.customer.team.service.TeamOrOrgApplicationService;
import com.sw.plugins.message.messageinterface.service.CommonMessageService;
import com.sw.plugins.message.task.entity.SendMessage;
import com.sw.plugins.message.task.entity.UserMessage;
import com.sw.plugins.statistics.memberStatistics.service.MemberStatisicsService;
import com.sw.plugins.system.user.entity.User;
import com.sw.util.ExportExcel;
import com.sw.util.FTPUtil;
import com.sw.util.SystemProperty;
import com.sw.util.Tool;

/**
 * Service -
 */

public class MemberOrganizationService extends CommonService<MemberOrganization> {

    public static final String PROJECT_FLAG_YCF_BRANCH = "ycf_branch";//branch

    @Resource
    private MemberService memberService;
    @Resource
    private TeamOrOrgApplicationService teamOrOrgApplicationService;
    @Resource
    private MemberTeamOrOrgHistoryService memberTeamOrOrgHistoryService;
    @Resource
    private MemberApplicationService memberApplicationService;
    @Resource
    private CommonMessageService commonMessageService;
    //add by lizheng for c4 mq start
    @Resource
    private MemberStatisicsService memberStatisicsService;

    //add by lizheng for c4 mq end
    //?
    @SuppressWarnings("unchecked")
    public List<MemberOrganization> getAllMemberOrganization(MemberOrganization entity) throws Exception {
        return (List<MemberOrganization>) super.getRelationDao()
                .selectList("memberOrganization.select_organization", entity);
    }

    //? ???
    @SuppressWarnings("unchecked")
    public List<MemberOrganization> getAllMemberOrganizationContract(MemberOrganization entity) throws Exception {
        return (List<MemberOrganization>) super.getRelationDao()
                .selectList("memberOrganization.select_organization_contract", entity);
    }

    //???
    public MemberOrganization getBankInfo(MemberOrganization entity) throws Exception {
        return (MemberOrganization) super.getRelationDao().selectOne("memberOrganization.select_one", entity);
    }

    /**
     * ??MAP?
     */
    public Map<String, Object> getGrid(MemberOrganization entity) throws Exception {
        List<MemberOrganization> resultList = null;
        Map<String, Object> map = new Hashtable<String, Object>();
        //
        resultList = getPaginatedList(entity);
        // 
        long record = this.getRecordCount(entity);
        // 
        int pageCount = (int) Math.ceil(record / (double) entity.getRows());

        map.put("rows", resultList);
        map.put("page", entity.getPage());
        map.put("total", pageCount);
        map.put("records", record);
        return map;
    }

    //?
    @SuppressWarnings("unchecked")
    @Override
    public List<MemberOrganization> getPaginatedList(MemberOrganization entity) throws Exception {
        return (List<MemberOrganization>) super.getRelationDao().selectList("memberOrganization.select_paginated",
                entity);
    }

    //?
    @Override
    public Long getRecordCount(MemberOrganization entity) throws Exception {
        return (Long) super.getRelationDao().selectOne("memberOrganization.count", entity);
    }

    public Long memberOrganizationCount(MemberOrganization entity) throws Exception {
        return (Long) super.getRelationDao().selectOne("memberOrganization.memberOrganizationCount", entity);
    }

    @SuppressWarnings("unchecked")
    public List<Long> getOrgIds(MemberOrganization entity) throws Exception {
        return (List<Long>) super.getRelationDao().selectList("memberOrganization.select_orgId", entity);
    }

    @Override
    public void save(MemberOrganization entity) throws Exception {

    }

    public MemberOrganization getContractImg(MemberOrganization entity) throws Exception {
        return (MemberOrganization) super.getRelationDao().selectOne("memberOrganization.select_contractImage",
                entity);
    }

    @Override
    public MemberOrganization getOne(MemberOrganization entity) throws Exception {
        return (MemberOrganization) super.getRelationDao().selectOne("memberOrganization.select_for_check", entity);
    }

    public MemberOrganization getOneForUpdate(MemberOrganization entity) throws Exception {
        return (MemberOrganization) super.getRelationDao().selectOne("memberOrganization.select_for_update",
                entity);
    }

    public MemberOrganization getOneForPromote(MemberOrganization entity) throws Exception {
        return (MemberOrganization) super.getRelationDao().selectOne("memberOrganization.select_for_promote",
                entity);
    }

    //?
    @Override
    public void update(MemberOrganization entity) throws Exception {
        super.getRelationDao().update("memberOrganization.update", entity);
    }

    public void updateMember(MemberOrganization entity) throws Exception {
        super.getRelationDao().update("memberOrganization.updateMember", entity);
    }

    //?
    public void update_for_promotionTtime(MemberOrganization entity) throws Exception {
        super.getRelationDao().update("memberOrganization.update_for_promotionTtime", entity);
    }

    public void updateforstatus(MemberOrganization entity) throws Exception {
        super.getRelationDao().update("memberOrganization.update_for_status", entity);
    }

    /**
     * ?
     * 
     * @param provider
     * @param request
     * @return
     */
    @Override
    public String upload(MemberOrganization entity, HttpServletRequest request) throws Exception {
        MultipartFile file = ((MultipartHttpServletRequest) request).getFile("Filedata");
        String path = "";
        //???
        ///////
        path = SystemProperty.getInstance("config").getProperty("team.licence.card.path") + "licenceImage";
        //???//
        Long newFileName = System.currentTimeMillis();
        String realFileName = newFileName + ".jpg";
        /////////
        return FTPUtil.uploadFile(file, path, realFileName);
    }

    /**
     *  ???,
     * 
     * @param provider
     * @param request
     * @return
     */
    public String uploadRar(MemberOrganization entity, HttpServletRequest request) throws Exception {
        MultipartFile file = ((MultipartHttpServletRequest) request).getFile("Filedata");
        String path = "";
        //???
        ///////
        path = SystemProperty.getInstance("config").getProperty("team.licence.card.path") + "licenceImage";
        //???//
        Long newFileName = System.currentTimeMillis();
        String realFileName = newFileName + ".rar";
        /////////
        return FTPUtil.uploadFile(file, path, realFileName);
    }

    /**
     * ???FTP??
     * 
     * @param provider
     * @return 
     */
    public String getPathName(MemberOrganization entity) throws Exception {
        return String.valueOf(getRelationDao().getCount("provider.selectMaxId", entity) + 1);
    }

    /**
     * ???
     * 
     * @param entity
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public List<MemberOrganization> getIncentiveList(MemberOrganization entity) throws Exception {
        return (List<MemberOrganization>) super.getRelationDao().selectList("memberOrganization.select_incentive",
                entity);
    }

    @Override
    public void init(InitData initData) throws Exception {
        Map<String, Object> bwoMap = initData.getBestwealthOrganization();
        String name = bwoMap.get("name") == null ? "" : bwoMap.get("name").toString();
        String licenceCode = bwoMap.get("code") == null ? "" : bwoMap.get("code").toString();
        MemberOrganization mo = new MemberOrganization();
        mo.setName(name);
        mo.setLicenceCode(licenceCode);
        //?mc_organization??
        List<MemberOrganization> moList = (List<MemberOrganization>) getRelationDao()
                .selectList("memberOrganization.select_onlyOne", mo);
        //?  
        if (moList.size() <= 0) {
            getRelationDao().insert("memberOrganization.insert_bestwealthOrg", mo);
            moList = (List<MemberOrganization>) getRelationDao().selectList("memberOrganization.select_onlyOne",
                    mo);
            //??ID 
            Long newId = moList.get(0).getId();
            validTeamOrg(initData, newId);
        } else {
            //???ID,?mc_teamororg???
            Long id = moList.get(0).getId();
            validTeamOrg(initData, id);
        }
    }

    private void validTeamOrg(InitData initData, Long id) throws Exception {
        Team team = new Team();
        team.setId(id);
        Long oldId = getRelationDao().getCount("team.select_TeamOrOrg", team);
        if (oldId <= 0) {
            Map<String, Object> bwtooMap = initData.getBestwealthTeamOrOrg();
            String delStatus = bwtooMap.get("delStatus") == null ? "" : bwtooMap.get("delStatus").toString();
            String status = bwtooMap.get("status") == null ? "" : bwtooMap.get("status").toString();
            String orgType = bwtooMap.get("orgType") == null ? "" : bwtooMap.get("orgType").toString();
            String isBestWealth = bwtooMap.get("isBestWealth") == null ? ""
                    : bwtooMap.get("isBestWealth").toString();
            team.setIsBestWealth(Integer.parseInt(isBestWealth));
            team.setDelStatus(Integer.parseInt(delStatus));
            team.setStatus(Integer.parseInt(status));
            team.setOrgType(Integer.parseInt(orgType));
            team.setOrgId(Integer.parseInt(id.toString()));
            getRelationDao().insert("team.insert_TeamOrOrg", team);
        }
    }

    @Override
    public void delete(MemberOrganization entity) throws Exception {

    }

    public void delete_for_organization(MemberOrganization entity) throws Exception {
        super.getRelationDao().delete("memberOrganization.delete_for_organization", entity);
    }

    public void delete_for_teamToOrg(MemberOrganization entity) throws Exception {
        super.getRelationDao().delete("memberOrganization.delete_for_teamToOrg", entity);
    }

    @Override
    public void deleteByArr(MemberOrganization entity) throws Exception {

    }

    public void updateCancel(MemberOrganization memberOrganization) throws Exception {
        //???
        Member member3 = new Member();
        member3.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
        member3.setStatus(2);
        memberService.updateStatus(member3);
        member3.setStatus(4);
        memberService.updateAccountStatus(member3);
        /////////////////
        MemberOrganization updateMemberOrganization = new MemberOrganization();
        updateMemberOrganization.setId(memberOrganization.getId());
        updateMemberOrganization.setStatus(3);
        //?
        updateforstatus(updateMemberOrganization);
        Member member2 = new Member();
        if (memberOrganization.getId() != null) {
            member2.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
        }
        List<Member> memberList = memberService.selectteamOrOrgmember(member2);
        //?teamid,?
        Member member = new Member();
        if (memberOrganization.getId() != null) {
            member.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
        }
        memberService.updateTeamId(member);
        //??
        MemberApplication MemberApplication = new MemberApplication();
        MemberApplication.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
        memberApplicationService.update(MemberApplication);
        //?
        TeamOrOrgApplication teamOrOrgApplication = new TeamOrOrgApplication();
        teamOrOrgApplication.setStatus(2);
        teamOrOrgApplication.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
        teamOrOrgApplicationService.updateForCancel(teamOrOrgApplication);
        //???
        MemberTeamOrOrgHistory memberTeamOrOrgHistory = new MemberTeamOrOrgHistory();
        memberTeamOrOrgHistory.setTeamOrOrgID(Integer.valueOf(memberOrganization.getId().toString()));
        memberTeamOrOrgHistory.setStatus(5);
        memberTeamOrOrgHistoryService.update(memberTeamOrOrgHistory);
        //? begin
        Map parameterMap = new HashMap();
        SendMessage sendMessage = new SendMessage();
        UserMessage us = new UserMessage();
        List<UserMessage> list = new ArrayList();
        User currentUser = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        sendMessage = new SendMessage();
        for (Member mem : memberList) {
            us = new UserMessage();
            us.setUserID(mem.getId());
            us.setUserType((short) 3);
            list.add(us);
        }
        sendMessage.setUserList(list);
        //???
        sendMessage.setSendWayStr("1");
        //??
        sendMessage.setTemplateParameters(parameterMap);
        //?code
        sendMessage.setTemplateCode("sys_manage_organization_htzjzxjg");
        //??ID
        if (currentUser.getId() != null) {
            sendMessage.setSendUserID(currentUser.getId());
        }
        //??
        sendMessage.setSendUserType((short) 1);
        //???
        try {
            commonMessageService.send(sendMessage);
        } catch (Exception e) {

        }
        //?end

    }

    public void savebackOrganizationCheck(MemberOrganization memberOrganization) throws Exception {
        MemberOrganization updateMemberOrganization = new MemberOrganization();
        MemberOrganization updateorgidentity = new MemberOrganization();
        TeamOrOrgApplication teamOrOrgApplication = new TeamOrOrgApplication();
        Member member2 = new Member();
        List<Member> memberList = null;
        Map parameterMap = new HashMap();
        SendMessage sendMessage = new SendMessage();
        UserMessage us = new UserMessage();
        List<UserMessage> list = new ArrayList();
        User currentUser = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        switch (memberOrganization.getCheckType()) {
        case 1://
            updateorgidentity.setId(memberOrganization.getId());
            updateorgidentity.setIdentity(memberOrganization.getIdentity());
            this.update(updateorgidentity);
            //??
            updateMemberOrganization.setId(memberOrganization.getId());
            updateMemberOrganization.setStatus(4);
            updateforstatus(updateMemberOrganization);
            Member member3 = new Member();
            member3.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
            member3.setStatus(5);
            memberService.updateAccountStatus(member3);
            //?

            teamOrOrgApplication.setId(memberOrganization.getCheckId());
            teamOrOrgApplication.setStatus(2);
            teamOrOrgApplication.setApplicantFeedback(memberOrganization.getApplicantFeedback());
            teamOrOrgApplicationService.update(teamOrOrgApplication);
            //???
            MemberTeamOrOrgHistory memberTeamOrOrgHistory = new MemberTeamOrOrgHistory();
            memberTeamOrOrgHistory.setTeamOrOrgID(Integer.valueOf(memberOrganization.getId().toString()));
            memberTeamOrOrgHistory.setStatus(3);
            memberTeamOrOrgHistoryService.updateForStatus(memberTeamOrOrgHistory);
            //? begin
            parameterMap = new HashMap();
            parameterMap.put("re", memberOrganization.getApplicantFeedback());
            sendMessage = new SendMessage();
            us = new UserMessage();
            us.setUserID((long) memberOrganization.getApplicationMember());
            us.setUserType((short) 3);
            list = new ArrayList();
            list.add(us);
            sendMessage.setUserList(list);
            //???
            sendMessage.setSendWayStr("1");
            //??
            sendMessage.setTemplateParameters(parameterMap);
            //?code
            sendMessage.setTemplateCode("sys_manage_organization_jgcjbtg");
            //??ID

            if (currentUser.getId() != null) {
                sendMessage.setSendUserID(currentUser.getId());
            }
            //??
            sendMessage.setSendUserType((short) 1);
            //???
            try {
                commonMessageService.send(sendMessage);
            } catch (Exception e) {

            }
            //?end
            break;
        case 2://??
               //?
            teamOrOrgApplication.setId(memberOrganization.getCheckId());
            teamOrOrgApplication.setStatus(2);
            teamOrOrgApplication.setApplicantFeedback(memberOrganization.getApplicantFeedback());
            teamOrOrgApplicationService.update(teamOrOrgApplication);
            //? begin
            parameterMap = new HashMap();
            sendMessage = new SendMessage();
            us = new UserMessage();
            us.setUserID((long) memberOrganization.getApplicationMember());
            us.setUserType((short) 3);
            list = new ArrayList();
            list.add(us);
            sendMessage.setUserList(list);
            //???
            sendMessage.setSendWayStr("1");
            //??
            sendMessage.setTemplateParameters(parameterMap);
            //?code
            sendMessage.setTemplateCode("sys_manage_organization_jgglrbgbtg");
            //??ID

            if (currentUser.getId() != null) {
                sendMessage.setSendUserID(currentUser.getId());
            }
            //??
            sendMessage.setSendUserType((short) 1);
            //???
            try {
                commonMessageService.send(sendMessage);
            } catch (Exception e) {

            }
            //?end
            break;
        case 3://
               //?
            teamOrOrgApplication.setId(memberOrganization.getCheckId());
            teamOrOrgApplication.setStatus(2);
            teamOrOrgApplication.setApplicantFeedback(memberOrganization.getApplicantFeedback());
            teamOrOrgApplicationService.update(teamOrOrgApplication);
            //???
            updateMemberOrganization.setId(memberOrganization.getId());
            updateMemberOrganization.setStatus(2);
            updateforstatus(updateMemberOrganization);
            //???
            Member member = new Member();
            member.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
            member.setStatus(0);
            memberService.updateAnnualBack(member);
            //? begin
            parameterMap = new HashMap();
            sendMessage = new SendMessage();
            us = new UserMessage();
            us.setUserID((long) memberOrganization.getApplicationMember());
            us.setUserType((short) 3);
            list = new ArrayList();
            list.add(us);
            sendMessage.setUserList(list);
            //???
            sendMessage.setSendWayStr("1");
            //??
            sendMessage.setTemplateParameters(parameterMap);
            //?code
            sendMessage.setTemplateCode("sys_manage_organization_jgnjbtg");
            //??ID

            if (currentUser.getId() != null) {
                sendMessage.setSendUserID(currentUser.getId());
            }
            //??
            sendMessage.setSendUserType((short) 1);
            //???
            try {
                commonMessageService.send(sendMessage);
            } catch (Exception e) {

            }
            //?end
            break;
        case 4://
               //????
            try {
                //?
                teamOrOrgApplication.setId(memberOrganization.getCheckId());
                teamOrOrgApplication.setStatus(2);
                teamOrOrgApplication.setApplicantFeedback(memberOrganization.getApplicantFeedback());
                teamOrOrgApplicationService.update(teamOrOrgApplication);
                //? begin
                parameterMap = new HashMap();
                sendMessage = new SendMessage();
                us = new UserMessage();
                us.setUserID((long) memberOrganization.getApplicationMember());
                us.setUserType((short) 3);
                list = new ArrayList();
                list.add(us);
                sendMessage.setUserList(list);
                //???
                sendMessage.setSendWayStr("1");
                //??
                sendMessage.setTemplateParameters(parameterMap);
                //?code
                sendMessage.setTemplateCode("sys_manage_organization_jgzxbtg");
                //??ID

                if (currentUser.getId() != null) {
                    sendMessage.setSendUserID(currentUser.getId());
                }
                //??
                sendMessage.setSendUserType((short) 1);
                //???

                commonMessageService.send(sendMessage);
            } catch (Exception e) {

            }
            //?end
            break;
        default:
            break;
        }

    }

    public void saveOrganizationCheck(MemberOrganization memberOrganization) throws Exception {
        MemberOrganization updateMemberOrganization = new MemberOrganization();
        MemberOrganization updateorgidentity = new MemberOrganization();
        TeamOrOrgApplication teamOrOrgApplication = new TeamOrOrgApplication();
        Member member2 = new Member();
        List<Member> memberList = null;
        Map parameterMap = new HashMap();
        SendMessage sendMessage = new SendMessage();
        UserMessage us = new UserMessage();
        List<UserMessage> list = new ArrayList();
        User currentUser = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        switch (memberOrganization.getCheckType()) {
        case 1://
            updateorgidentity.setId(memberOrganization.getId());
            updateorgidentity.setIdentity(memberOrganization.getIdentity());
            this.update(updateorgidentity);
            //??
            updateMemberOrganization.setId(memberOrganization.getId());
            updateMemberOrganization.setStatus(1);
            updateMemberOrganization.setIdentity(memberOrganization.getIdentity());
            updateforstatus(updateMemberOrganization);
            Member member4 = new Member();
            member4.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
            member4.setStatus(2);
            memberService.updateAccountStatus(member4);
            //?
            teamOrOrgApplication.setId(memberOrganization.getCheckId());
            teamOrOrgApplication.setStatus(1);
            teamOrOrgApplication.setApplicantFeedback(memberOrganization.getApplicantFeedback());
            teamOrOrgApplicationService.update(teamOrOrgApplication);
            //???
            MemberTeamOrOrgHistory memberTeamOrOrgHistory = new MemberTeamOrOrgHistory();
            memberTeamOrOrgHistory.setTeamOrOrgID(Integer.valueOf(memberOrganization.getId().toString()));
            memberTeamOrOrgHistory.setStatus(2);
            memberTeamOrOrgHistoryService.updateForStatus(memberTeamOrOrgHistory);
            //? begin
            parameterMap = new HashMap();
            sendMessage = new SendMessage();
            us = new UserMessage();
            us.setUserID((long) memberOrganization.getApplicationMember());
            us.setUserType((short) 3);
            list = new ArrayList();
            list.add(us);
            sendMessage.setUserList(list);
            //???
            sendMessage.setSendWayStr("1");
            //??
            sendMessage.setTemplateParameters(parameterMap);
            //?code
            sendMessage.setTemplateCode("sys_manage_organization_jgcjtg");
            //??ID

            if (currentUser.getId() != null) {
                sendMessage.setSendUserID(currentUser.getId());
            }
            //??
            sendMessage.setSendUserType((short) 1);
            //???
            try {
                commonMessageService.send(sendMessage);
            } catch (Exception e) {

            }
            //?end
            break;
        case 2://??
               //?? 
            Member member = new Member();
            member.setId(Long.valueOf(memberOrganization.getMemberID()));
            member.setType(2);
            //?
            memberService.update(member);
            member = new Member();
            member.setId(Long.valueOf(memberOrganization.getApplicationMember()));
            member.setType(1);
            memberService.update(member);
            //?

            teamOrOrgApplication.setId(memberOrganization.getCheckId());
            teamOrOrgApplication.setStatus(1);
            teamOrOrgApplication.setApplicantFeedback(memberOrganization.getApplicantFeedback());
            teamOrOrgApplicationService.update(teamOrOrgApplication);
            //? begin
            member2 = new Member();
            if (memberOrganization.getId() != null) {
                member2.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
            }
            memberList = memberService.selectteamOrOrgmember(member2);
            parameterMap = new HashMap();
            list = new ArrayList();
            sendMessage = new SendMessage();
            for (Member mem : memberList) {
                us = new UserMessage();
                us.setUserID(mem.getId());
                us.setUserType((short) 3);
                list.add(us);
            }
            sendMessage.setUserList(list);
            //???
            sendMessage.setSendWayStr("1");
            //??
            sendMessage.setTemplateParameters(parameterMap);
            //?code
            sendMessage.setTemplateCode("sys_manage_organization_jgglrbgtg");
            //??ID
            if (currentUser.getId() != null) {
                sendMessage.setSendUserID(currentUser.getId());
            }
            //??
            sendMessage.setSendUserType((short) 1);
            //???
            try {
                commonMessageService.send(sendMessage);
            } catch (Exception e) {

            }
            //?end
            break;
        case 3://
               //??   
            updateMemberOrganization.setId(memberOrganization.getId());
            updateMemberOrganization.setLicenceCode(memberOrganization.getCheckLicenceCode());
            updateMemberOrganization.setLicenceExpireTime(memberOrganization.getCheckLicenceExpireTime());
            updateMemberOrganization.setLicenceImage(memberOrganization.getCheckLicenceImage());
            updateMemberOrganization.setStatus(1);//?
            update(updateMemberOrganization);
            updateforstatus(updateMemberOrganization);
            //???
            Member member1 = new Member();
            member1.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
            member1.setStatus(2);
            memberService.updateStatus(member1);
            member1.setStatus(2);
            memberService.updateAccountStatus(member1);
            //?
            teamOrOrgApplication.setId(memberOrganization.getCheckId());
            teamOrOrgApplication.setStatus(1);
            teamOrOrgApplication.setApplicantFeedback(memberOrganization.getApplicantFeedback());
            teamOrOrgApplicationService.update(teamOrOrgApplication);
            //? begin
            parameterMap = new HashMap();
            sendMessage = new SendMessage();
            us = new UserMessage();
            us.setUserID((long) memberOrganization.getApplicationMember());
            us.setUserType((short) 3);
            list = new ArrayList();
            list.add(us);
            sendMessage.setUserList(list);
            //???
            sendMessage.setSendWayStr("1");
            //??
            sendMessage.setTemplateParameters(parameterMap);
            //?code
            sendMessage.setTemplateCode("sys_manage_organization_jgnjtg");
            //??ID

            if (currentUser.getId() != null) {
                sendMessage.setSendUserID(currentUser.getId());
            }
            //??
            sendMessage.setSendUserType((short) 1);
            //???
            try {
                commonMessageService.send(sendMessage);
            } catch (Exception e) {

            }
            //?end
            break;
        case 4:
            //????
            //???
            Member member3 = new Member();
            member3.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
            member3.setStatus(2);
            memberService.updateStatus(member3);
            member3.setStatus(4);
            memberService.updateAccountStatus(member3);
            //??
            updateMemberOrganization.setId(memberOrganization.getId());
            updateMemberOrganization.setStatus(3);
            updateforstatus(updateMemberOrganization);
            member2 = new Member();
            if (memberOrganization.getId() != null) {
                member2.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
            }
            memberList = memberService.selectteamOrOrgmember(member2);
            //???,??
            Member member11 = new Member();
            member11.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
            memberService.updateTeamId(member11);
            //?
            teamOrOrgApplication.setId(memberOrganization.getCheckId());
            teamOrOrgApplication.setStatus(1);
            teamOrOrgApplication.setApplicantFeedback(memberOrganization.getApplicantFeedback());
            teamOrOrgApplicationService.update(teamOrOrgApplication);
            //?
            teamOrOrgApplication = new TeamOrOrgApplication();
            teamOrOrgApplication.setStatus(2);
            teamOrOrgApplication.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
            teamOrOrgApplicationService.updateForCancel(teamOrOrgApplication);
            //??
            MemberApplication MemberApplication = new MemberApplication();
            MemberApplication.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
            memberApplicationService.update(MemberApplication);
            //???
            memberTeamOrOrgHistory = new MemberTeamOrOrgHistory();
            memberTeamOrOrgHistory.setTeamOrOrgID(Integer.valueOf(memberOrganization.getId().toString()));
            memberTeamOrOrgHistory.setStatus(5);
            memberTeamOrOrgHistoryService.update(memberTeamOrOrgHistory);
            //////////////
            //? begin

            parameterMap = new HashMap();
            list = new ArrayList();
            sendMessage = new SendMessage();
            for (Member mem : memberList) {
                us = new UserMessage();
                us.setUserID(mem.getId());
                us.setUserType((short) 3);
                list.add(us);
            }
            sendMessage.setUserList(list);
            //???
            sendMessage.setSendWayStr("1");
            //??
            sendMessage.setTemplateParameters(parameterMap);
            //?code
            sendMessage.setTemplateCode("sys_manage_organization_jgzxtg");
            //??ID
            if (currentUser.getId() != null) {
                sendMessage.setSendUserID(currentUser.getId());
            }
            //??
            sendMessage.setSendUserType((short) 1);
            //???
            try {
                commonMessageService.send(sendMessage);
            } catch (Exception e) {

            }
            //?end
            break;
        default:
            break;
        }
    }

    public void updateRecoveryOrganization(MemberOrganization memberOrganization) throws Exception {
        MemberOrganization updateMemberOrganization = new MemberOrganization();
        updateMemberOrganization.setId(memberOrganization.getId());
        updateMemberOrganization.setStatus(1);
        //??
        updateforstatus(updateMemberOrganization);
        //??
        Member member = new Member();
        member.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
        member.setStatus(2);
        memberService.updateStatus(member);
        //? begin
        Map parameterMap = new HashMap();
        SendMessage sendMessage = new SendMessage();
        UserMessage us = new UserMessage();
        List<UserMessage> list = new ArrayList();
        User currentUser = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        List<Member> memberList = memberService.selectteamOrOrgmember(member);
        sendMessage = new SendMessage();
        for (Member mem : memberList) {
            us = new UserMessage();
            us.setUserID(mem.getId());
            us.setUserType((short) 3);
            list.add(us);
        }
        sendMessage.setUserList(list);
        //???
        sendMessage.setSendWayStr("1");
        //??
        sendMessage.setTemplateParameters(parameterMap);
        //?code
        sendMessage.setTemplateCode("sys_manage_organization_jghfyw");
        //??ID
        if (currentUser.getId() != null) {
            sendMessage.setSendUserID(currentUser.getId());
        }
        //??
        sendMessage.setSendUserType((short) 1);
        //???
        try {
            commonMessageService.send(sendMessage);
        } catch (Exception e) {

        }
        //?end

    }

    public void updateSuspendOrganization(MemberOrganization memberOrganization) throws Exception {
        MemberOrganization updatememberOrganization = new MemberOrganization();
        updatememberOrganization.setId(memberOrganization.getId());
        updatememberOrganization.setStatus(2);
        //??
        updateforstatus(updatememberOrganization);
        //??
        Member member = new Member();
        member.setTeamID(Integer.valueOf(memberOrganization.getId().toString()));
        member.setStatus(0);
        memberService.updateStatusForOrg(member);
        //? begin
        Map parameterMap = new HashMap();
        SendMessage sendMessage = new SendMessage();
        UserMessage us = new UserMessage();
        List<UserMessage> list = new ArrayList();
        User currentUser = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        List<Member> memberList = memberService.selectteamOrOrgmember(member);
        sendMessage = new SendMessage();
        for (Member mem : memberList) {
            us = new UserMessage();
            us.setUserID(mem.getId());
            us.setUserType((short) 3);
            list.add(us);
        }
        sendMessage.setUserList(list);
        //???
        sendMessage.setSendWayStr("1");
        //??
        sendMessage.setTemplateParameters(parameterMap);
        //?code
        sendMessage.setTemplateCode("sys_manage_organization_jgztyw");
        //??ID
        if (currentUser.getId() != null) {
            sendMessage.setSendUserID(currentUser.getId());
        }
        //??
        sendMessage.setSendUserType((short) 1);
        //???
        try {
            commonMessageService.send(sendMessage);
        } catch (Exception e) {

        }
        //?end

    }

    @SuppressWarnings("unchecked")
    public WritableWorkbook exportExcel(MemberOrganization entity, String colName, String colModel,
            WritableWorkbook excel) throws Exception {
        List<Map<String, Object>> objList = (List<Map<String, Object>>) super.getRelationDao()
                .selectList("memberOrganization.select_for_export", entity);
        if (objList != null) {
            for (Map<String, Object> one : objList) {
                one.put("name", one.get("name"));
                one.put("shortName", one.get("shortName"));
                one.put("contactName", one.get("contactName"));
                one.put("contactPhone", one.get("contactPhone"));
                one.put("contactEmail", one.get("contactEmail"));
                one.put("checkCount",
                        Integer.parseInt(one.get("checkCount").toString()) > 0 ? "" : "");
            }
        }
        String[] colNames = colName.split(",");
        String[] colModels = colModel.split(",");

        String excelName = "?";
        int colNameNum = colNames.length;
        int colModelNum = colModels.length;
        ExportExcel exportExcel = new ExportExcel();
        excel = exportExcel.createExcel(excelName, colNames, colNameNum, colModels, colModelNum, objList, excel);
        return excel;
    }

    @Override
    public Object download(MemberOrganization entity, HttpServletRequest request) throws Exception {
        return null;
    }

    @Override
    public List<MemberOrganization> getList(MemberOrganization entity) throws Exception {
        return null;
    }

    public MemberOrganization selectCodeByTeamOrOrgID(MemberOrganization memberOrganization) throws Exception {
        return (MemberOrganization) super.getRelationDao()
                .selectOne("memberOrganization.select_orgcode_by_teamororgid", memberOrganization);

    }

    public Long memberCount(MemberOrganization entity) throws Exception {
        return (Long) super.getRelationDao().selectOne("memberOrganization.memberCount", entity);
    }

    public Map<String, Object> getOneForRegist(Map<String, Object> entity) throws Exception {
        Map<String, Object> map = (Map<String, Object>) super.getRelationDao()
                .selectOne("memberOrganization.getOneForRegist", entity);
        return map;
    }

    /**
     * ?ContractCod  
     * @param string
     * @return
     * @throws Exception 
     */
    public String saveContractCode(Map<String, Object> paramMap) throws Exception {
        // TODO Auto-generated method stub
        String codeStr = null;
        //
        String accountType = (String) paramMap.get("accountType");
        //1.??
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        Date curDate = new Date(System.currentTimeMillis());//??  
        String selectDate = formatter.format(curDate).substring(2);
        Map<String, Object> tempMap = new HashMap<String, Object>();
        //
        if ("1".equals(accountType)) {
            tempMap.put("selectDate", "GA-Q-M-" + selectDate);
        }
        if ("2".equals(accountType)) {
            tempMap.put("selectDate", "GA-Q-O-" + selectDate);
        }
        //2.??
        Map<String, Object> contractCodeShort = getMaxContractCodeShort(tempMap);
        //true??
        if (contractCodeShort == null || contractCodeShort.size() < 1) {
            //
            if ("1".equals(accountType)) {
                codeStr = "GA-Q-M-" + selectDate + "A001";
            }
            if ("2".equals(accountType)) {
                codeStr = "GA-Q-O-" + selectDate + "A001";
            }
        } else {
            //1:2
            if ("1".equals(accountType)) {
                codeStr = "GA-Q-M-" + selectDate;
            }
            if ("2".equals(accountType)) {
                codeStr = "GA-Q-O-" + selectDate;
            }
            codeStr = codeStr + Tool.getRandomStr((String) contractCodeShort.get("contractcode"));
        }
        return codeStr;
    }

    /**
     * code
     * @param tempMap
     * @return
     * @throws Exception
     */
    private Map<String, Object> getMaxContractCodeShort(Map<String, Object> tempMap) throws Exception {
        // TODO Auto-generated method stub
        return (Map<String, Object>) super.getRelationDao().selectOne("memberOrganization.select_max_code",
                tempMap);
    }

    @SuppressWarnings("unchecked")
    public Map<String, Object> getAgreementContent(Map<String, Object> paramMap) throws Exception {
        // TODO Auto-generated method stub
        return (Map<String, Object>) super.getRelationDao().selectOne("memberOrganization.select_agreement_content",
                paramMap);
    }

    /**
     * 
     * 
     * @param paramMap
     * @return
     * @throws Exception 
     */
    @SuppressWarnings("unchecked")
    public Map<String, Object> registerOrg(Object entity) throws Exception {
        Map<String, Object> map = (Map<String, Object>) entity;
        String account = map.get("account") == null ? "" : map.get("account").toString();
        String orgName = map.get("orgName") == null ? "" : map.get("orgName").toString();
        String channelCode = map.get("channelCode") == null ? "" : map.get("channelCode").toString();
        String activityChannelCode = map.get("activityChannelCode") == null ? ""
                : map.get("activityChannelCode").toString();
        map.put("account", "");
        Long orgID = saveOrg(map);// insert MC_Organization 
        map.put("orgID", orgID);
        Long teamID = (Long) saveTeamOrOrg(map);// insert MC_TeamOrOrg
        map.put("account", account);
        map.put("teamID", teamID);
        map.put("mobilePhone", "");
        map.put("name", orgName);
        map.put("channelCode", channelCode);
        map.put("activityChannelCode", activityChannelCode);
        map = saveMember(map);

        //????? insert MC_TeamOrOrgApplication

        // ? ??
        if (isNotEmpty(map.get("contractImage")) || isNotEmpty(map.get("licenceImage"))) {

            Map<String, Object> paramMap = new HashMap<String, Object>();
            //         paramMap.put("account", account);
            //         Map<String, Object> newparamMap =getMemberIdByMemeberMap(paramMap);
            //         paramMap.put("memberID", newparamMap.get("ID"));
            paramMap.put("memberID", map.get("id"));
            //         paramMap.put("id", newparamMap.get("TeamID"));
            paramMap.put("id", teamID);
            //         paramMap.put("teamID", newparamMap.get("TeamID"));
            paramMap.put("teamID", teamID);
            //         paramMap.put("orgName", newparamMap.get("TEAMORORGNAME"));
            paramMap.put("orgName", orgName);

            String licenceImage = map.get("licenceImage") == null ? "" : map.get("licenceImage").toString();
            String contractImage = map.get("contractImage") == null ? "" : map.get("contractImage").toString();
            paramMap.put("licenceImage", licenceImage);
            paramMap.put("contractImage", contractImage);

            saveTeamOrg(paramMap);//    

        }

        return map;
    }

    /**
     * ?  json?
     * 
     * @param request
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public Long saveOrg(Object entity) throws Exception {
        Map<String, Object> map = (Map<String, Object>) entity;
        super.getRelationDao().insert("memberOrganization.insert_org_save", map);
        return (Long) map.get("generatedKey");
    }

    /**
     * ?  json?
     * 
     * @param request
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public Long saveTeamOrOrg(Object entity) throws Exception {
        Map<String, Object> map = (Map<String, Object>) entity;
        super.getRelationDao().insert("memberOrganization.insert_teamOrOrg_save", entity);
        return (Long) map.get("generatedKey");
    }

    /**
     * ???
     * @param entity
     * @return
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public Map<String, Object> saveMember(Object entity) throws Exception {
        Map<String, Object> map = (Map<String, Object>) entity;
        // delete by anp 2014/10/24 begin
        //      String password=map.get("password").toString();
        //      if(!password.equals("")){
        //         password=Encrypt.getMD5(password);
        //      }
        //      map.put("password", password);
        // delete by anp 2014/10/24 end

        // add by maozhanlei 2014/12/16 start
        //???(??????vip?????ID?ID???)
        String referrerId = (String) map.get("referrerId");//??ID
        if (null != referrerId && !"".equals(referrerId)) {
            map.put("channelSource", (short) 1);//??????
            Map<String, Object> mapTem = new HashMap<String, Object>();
            mapTem.put("memberID", referrerId);
            Map<String, Object> resultMemberByReferrerID = getOneForRegist(mapTem);
            if (null != resultMemberByReferrerID) {
                String channelManagerID = resultMemberByReferrerID.get("ChannelManagerID") + "";
                String developmentOrgID = resultMemberByReferrerID.get("DevelopmentOrgID") + "";
                if (channelManagerID == null || "".equals(channelManagerID) || "null".equals(channelManagerID)) {
                    if (developmentOrgID == null || "".equals(developmentOrgID)
                            || "null".equals(developmentOrgID)) {
                        map.put("channelSource", (short) 6);//?????   
                    }
                }
                //            map.put("channelManagerID", channelManagerID);
                //            map.put("developmentOrgID", developmentOrgID);
                else {
                    //??ID???Code
                    map.get("regSourceCode");
                    map.put("developmentOrgID", developmentOrgID);
                    map.put("projectFlag", PROJECT_FLAG_YCF_BRANCH);
                    Map<String, Object> channelCodeMap = selectChannelCode(map);
                    if (channelCodeMap != null) {
                        map.put("channelCode", channelCodeMap.get("code"));
                    }
                }
                map.put("channelManagerID", channelManagerID);
                //add by chenlong 2015/3/16 ??????referralCodereferrerPhone?
                map.put("referrerPhone", (String) map.get("referralCode"));
            }
        }
        // add by maozhanlei 2014/12/16 end

        super.getRelationDao().insert("memberOrganization.insert", map);
        String lid = map.get("generatedKey").toString();
        //add by lizheng for c4 mq start
        memberStatisicsService.sendToMqAuto(lid, "?", "FD:MemberOrganizationService:saveMember");
        //add by lizheng for c4 mq end
        map.put("id", map.get("generatedKey").toString());
        map.put("password", "");
        //map.put("status", "1");
        map.put("memberID", map.get("generatedKey").toString());
        //???
        insertMemberAgreementMapping(map);
        //?MC_MemberExt
        if (null != referrerId && !"".equals(referrerId)) {
            /**
             * 1.???referrerPath
             * 2.
             * 3.?referrerPath
             */
            Map<String, Object> mapTem = new HashMap<String, Object>();
            mapTem.put("referrerId", referrerId);
            Map<String, Object> resultMember = selectReferrerPathById(mapTem);
            mapTem.put("memberID", map.get("generatedKey").toString());

            String parentReferrerPath = "";
            //true:???false??
            if (null != resultMember) {
                parentReferrerPath = (String) resultMember.get("ReferrerPath");
            } else {
                parentReferrerPath = ",";
            }
            mapTem.put("referrerPath", parentReferrerPath + map.get("generatedKey") + ",");
            if (map.get("spreadId") != null)
                mapTem.put("spreadId", map.get("spreadId"));
            // add by xuyang(2015/01/30) start
            // vip(??)
            String strUpperVIP = searchUpperVIP(parentReferrerPath);
            if (!StringUtils.isEmpty(strUpperVIP)) {
                mapTem.put("upperVIP", strUpperVIP);
            }

            // Add by chenlong 2015/4/17 start for 
            if (map.containsKey("promoteProjectCode")) {
                mapTem.put("promoteProjectCode", "'" + map.get("promoteProjectCode") + "'");
            }
            if (map.containsKey("promotePersonCode")) {
                mapTem.put("promotePersonCode", "'" + map.get("promotePersonCode") + "'");
            }
            // Add by chenlong 2015/4/17 end

            // add by xuyang(2015/01/30) end
            inserMemberExt(mapTem);
        } else {
            Map<String, Object> mapTem = new HashMap<String, Object>();
            mapTem.put("memberID", map.get("generatedKey").toString());
            mapTem.put("referrerPath", "," + map.get("generatedKey") + ",");

            // Add by chenlong 2015/4/17 start for 
            if (map.containsKey("promoteProjectCode")) {
                mapTem.put("promoteProjectCode", "'" + map.get("promoteProjectCode") + "'");
            }
            if (map.containsKey("promotePersonCode")) {
                mapTem.put("promotePersonCode", "'" + map.get("promotePersonCode") + "'");
            }
            // Add by chenlong 2015/4/17 end

            if (map.get("spreadId") != null)
                mapTem.put("spreadId", map.get("spreadId"));
            inserMemberExt(mapTem);
        }

        //? begin
        Map parameterMap = new HashMap();
        SendMessage sendMessage = new SendMessage();
        UserMessage us = new UserMessage();
        us.setUserID(Long.parseLong(map.get("generatedKey").toString()));
        us.setUserType((short) 3);
        List<UserMessage> list = new ArrayList();
        list.add(us);
        sendMessage.setUserList(list);
        //???
        sendMessage.setSendWayStr("1");
        //??
        sendMessage.setTemplateParameters(parameterMap);
        //?code
        sendMessage.setTemplateCode("sys_website_homepage_zccg");
        //??ID
        sendMessage.setSendUserID(-1L);
        //?
        sendMessage.setRelationType((short) 5);
        commonMessageService.send(sendMessage);
        //      messageService.send(sendMessage);   
        return map;
    }

    /**
     * ??ID?CODE 
     */
    public Map<String, Object> selectChannelCode(Object entity) throws Exception {
        Map<String, Object> map = (Map<String, Object>) super.getRelationDao()
                .selectOne("memberOrganization.select_channelCode_by_channelId", entity);
        return map;
    }

    /**
     * ???
     * @param paramMap
     * @throws Exception
     */
    public void insertMemberAgreementMapping(Map<String, Object> paramMap) throws Exception {
        // TODO Auto-generated method stub
        super.getRelationDao().insert("memberOrganization.insert_memberagreementmapping", paramMap);
    }

    /**
     * <!-- ???? -->
     * @param entity
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public Map<String, Object> selectReferrerPathById(Object entity) throws Exception {
        return (Map<String, Object>) this.getRelationDao().selectOne("memberOrganization.select_referrerPath_by_id",
                entity);
    }

    /** add by xuyang 2015/01/30 start */
    /**
     * VIP
     */
    private String searchUpperVIP(String refferPath) {

        String strUpperVIP = "";
        try {
            // ,X, 2
            if (StringUtils.isEmpty(refferPath) || refferPath.length() < 2) {
                return strUpperVIP;
            }
            // vip
            String vips = searchVIPs(refferPath);
            if (StringUtils.isEmpty(vips)) {
                return strUpperVIP;
            }
            String[] arrMemberID = refferPath.split(",");
            for (int i = arrMemberID.length - 1; i >= 0; i--) {
                if (StringUtils.isEmpty(arrMemberID[i])) {
                    continue;
                }
                if (vips.contains("," + arrMemberID[i] + ",")) {
                    strUpperVIP = arrMemberID[i];
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return strUpperVIP;
    }

    /**
     * VIP
     * @throws Exception 
     */
    @SuppressWarnings("unchecked")
    private String searchVIPs(String sbMemberID) throws Exception {

        if (sbMemberID == null || sbMemberID.length() == 0) {
            return "";
        }

        //  VIP
        MemberOrganization mapMemberExt = new MemberOrganization();
        // ???
        mapMemberExt.setReferrerPath(sbMemberID.toString().substring(1, sbMemberID.length() - 1));
        List<Map<String, Object>> lstVIPMemberExt = (List<Map<String, Object>>) super.getRelationDao()
                .selectList("memberOrganization.searchVIPs", mapMemberExt);
        if (lstVIPMemberExt == null || lstVIPMemberExt.size() == 0) {
            return "";
        }
        StringBuilder sbVIPMemberID = new StringBuilder("");
        for (Map<String, Object> me : lstVIPMemberExt) {
            String strTmpID = String.valueOf(me.get("ID"));
            if (StringUtils.isEmpty(strTmpID)) {
                continue;
            }
            // ??sbMemberID
            if (sbVIPMemberID.length() == 0)
                sbVIPMemberID.append(",");
            sbVIPMemberID.append(strTmpID);
            sbVIPMemberID.append(",");
        }

        return sbVIPMemberID.toString();
    }

    /**
     * <!-- ??? -->
     * @param entity
     * @throws Exception
     */
    public void inserMemberExt(Object entity) throws Exception {
        this.getRelationDao().insert("memberOrganization.inser_member_ext", entity);
    }

    /**
     * ?  json?
     * 
     * @param request
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public void saveTeamOrg(Object entity) throws Exception {
        Map<String, Object> map = (Map<String, Object>) entity;
        //map.put("nickname", map.get("orgShortName"));
        //map.put("name", map.get("orgName"));
        //update(map);
        //map.put("id", map.get("teamID"));
        orgUpdate(map);//?  update MC_Organization  set licenseImage contractImage
        map.put("type", "1");
        saveTeamOrOrgApplication(map);//? insert MC_TeamOrOrgApplication (licenseImage contractImage)
        super.getRelationDao().update("memberOrganization.teamOrOrgUpdate", map);// update MC_TeamOrOrg set Status=0
        //? begin
        Map parameterMap = new HashMap();
        SendMessage sendMessage = new SendMessage();
        parameterMap.put("orgID", String.valueOf(map.get("teamID")));
        parameterMap.put("memberName", map.get("orgName"));
        UserMessage us = new UserMessage();
        us.setUserType((short) 1);
        List<UserMessage> list = new ArrayList();
        list.add(us);
        sendMessage.setUserList(list);
        //???
        sendMessage.setSendWayStr("1");
        //??
        sendMessage.setTemplateParameters(parameterMap);
        //?code
        sendMessage.setTemplateCode("sys_website_customer_cjjg");
        //??ID
        sendMessage.setSendUserID(Long.parseLong(map.get("memberID").toString()));
        //??
        sendMessage.setSendUserType((short) 3);
        //?
        sendMessage.setRelationType((short) 5);
        commonMessageService.sendByConfigReceiver(sendMessage);
    }

    /**
     * 
     * 
     * @param entity
     * @throws Exception
     */
    public void orgUpdate(Object entity) throws Exception {
        super.getRelationDao().update("memberOrganization.orgUpdate", entity);
    }

    /**
     * ?  json?
     * 
     * @param request
     * @return
     * @throws Exception
     */
    public void saveTeamOrOrgApplication(Object entity) throws Exception {
        super.getRelationDao().insert("memberOrganization.insert_teamOrOrg_application_save", entity);
    }

    /**
     * ?
     * 
     * @param obj
     *            
     * @return ?true;false
     */
    @SuppressWarnings("unchecked")
    public static boolean isNotEmpty(Object obj) {
        if (obj == null)
            return false;
        if (obj instanceof String) {
            if ("".equals(obj))
                return false;
        } else if (obj instanceof List) {
            if (((List) obj).size() <= 0)
                return false;
        } else if (obj instanceof Object[]) {
            if (((Object[]) obj).length <= 0)
                return false;
        }
        return true;
    }
}