浏览代码

运营人员管理

chao 4 年之前
父节点
当前提交
a74fd1a4bb

+ 11 - 0
pom.xml

@@ -66,6 +66,17 @@
 			<artifactId>lombok</artifactId>
 			<optional>true</optional>
 		</dependency>
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
+            <version>1.2.5</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>mybatis-spring-boot-starter</artifactId>
+                    <groupId>org.mybatis.spring.boot</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
         <!-- redis依赖包 -->
         <dependency>
             <groupId>org.springframework.boot</groupId>

+ 2 - 2
src/main/java/com/caimei365/user/components/CommonService.java

@@ -140,7 +140,7 @@ public class CommonService {
      *
      * @param operationId 运营人员Id
      */
-    public void unbindOperation(Integer operationId) {
+    public int unbindOperation(Integer operationId) {
         OperationPo operation = new OperationPo();
         operation.setId(operationId);
         operation.setUnionId("");
@@ -151,6 +151,6 @@ public class CommonService {
         operation.setStatus(1);
         operation.setDelFlag(1);
         // 解绑运营人员
-        operationMapper.updateOperationByUnbind(operation);
+        return operationMapper.updateOperationByUnbind(operation);
     }
 }

+ 55 - 7
src/main/java/com/caimei365/user/controller/OperationApi.java

@@ -2,14 +2,13 @@ package com.caimei365.user.controller;
 
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.OperationDto;
+import com.caimei365.user.model.vo.OperationVo;
+import com.caimei365.user.model.vo.PaginationVo;
 import com.caimei365.user.service.OperationService;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * Description
@@ -35,13 +34,62 @@ public class OperationApi {
      *                         linkName  姓名
      *                         userId    用户Id(userID)
      *                         clubId    机构Id
+     *                         shopId    供应商Id
      *                         configFlag 确认标志
      *                     }
      */
-    @ApiOperation("添加运营人员(暂不启用)")
-    @PostMapping("/add")
-    public ResponseJson addOperation(OperationDto operationDto){
+    @ApiOperation("保存运营人员")
+    @PostMapping("/save")
+    public ResponseJson addOperation(OperationDto operationDto) {
         return operationService.addOperation(operationDto);
     }
 
+    /**
+     * 更新邀请码
+     *
+     * spi旧接口:/operation/updateInvitationCode
+     *
+     * @param operationDto {
+     *                         id        运营人员Id
+     *                     }
+     */
+    @ApiOperation("更新运营人员邀请码")
+    @PostMapping("/code/update")
+    public ResponseJson updateInvitationCode(OperationDto operationDto){
+        return operationService.updateInvitationCode(operationDto);
+    }
+
+    /**
+     * 删除运营人员(解绑)
+     *
+     * spi旧接口:/operation/delete
+     *
+     * @param operationDto {
+     *                         id        运营人员Id
+     *                     }
+     */
+    @PostMapping("/delete")
+    public ResponseJson deleteOperation(OperationDto operationDto) {
+        return operationService.unbindOperation(operationDto);
+    }
+
+    /**
+     * 获取运营人员列表
+     *
+     * spi旧接口:/operation/list
+     *
+     * @param operationDto {
+     *                         mobile    手机号
+     *                         linkName  姓名
+     *                         userId    用户Id(userID)
+     *                     }
+     */
+    @ApiOperation("获取运营人员列表")
+    @GetMapping("/list")
+    public ResponseJson<PaginationVo<OperationVo>> getOperationList(OperationDto operationDto,
+                                                                    @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                    @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+        return operationService.getOperationList(operationDto, pageNum, pageSize);
+    }
+
 }

+ 27 - 4
src/main/java/com/caimei365/user/mapper/OperationMapper.java

@@ -1,9 +1,13 @@
 package com.caimei365.user.mapper;
 
+import com.caimei365.user.model.dto.OperationDto;
 import com.caimei365.user.model.po.OperationPo;
+import com.caimei365.user.model.vo.OperationVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * Description
  *
@@ -42,16 +46,35 @@ public interface OperationMapper {
      * 解绑更新运营人员信息
      * @param operation 运营人员信息
      */
-    void updateOperationByUnbind(OperationPo operation);
+    int updateOperationByUnbind(OperationPo operation);
 
     /**
      * 统计生成随机码是否和数据库有重复
      */
     int countByInvitationCode(String invitationCode);
-
+    /**
+     * 查找机构名称
+     */
     String findClubNameById(Integer clubId);
-
+    /**
+     * 查找供应商名称
+     */
     String findShopNameById(Integer shopId);
-
+    /**
+     * 新增运营人员
+     */
     int insertOperation(OperationPo operation);
+    /**
+     * 更新运营人员
+     */
+    int updateOperation(OperationPo operation);
+    /**
+     * 根据id获取运营人员邀请码信息
+     */
+    OperationPo getOperationCodeInfoById(Integer id);
+
+    /**
+     * 获取运营人员列表
+     */
+    List<OperationVo> getOperationListByUserId(Integer userId, String mobile, String linkName);
 }

+ 2 - 0
src/main/java/com/caimei365/user/model/dto/OperationDto.java

@@ -15,6 +15,8 @@ import java.io.Serializable;
 @ApiModel("添加运营人员")
 @Data
 public class OperationDto implements Serializable {
+
+    private Integer id;
     /**
      * 手机号码
      */

+ 121 - 0
src/main/java/com/caimei365/user/model/vo/OperationVo.java

@@ -0,0 +1,121 @@
+package com.caimei365.user.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/3/8
+ */
+@Data
+public class OperationVo implements Serializable {
+    /**
+     * 运营人员Id
+     */
+    private Integer id;
+    /**
+     * 用户ID
+     */
+    private Integer userId;
+    /**
+     * 用户类型,1:机构类型,2供应商类型
+     */
+    private Integer userType;
+    /**
+     * 组织Id
+     */
+    private Integer organizeId;
+    /**
+     * 会所ID:隶属于哪个会所的运营人员
+     */
+    private Integer clubId;
+    /**
+     * 供应商ID:隶属于哪个供应商的运营人员[用户类型为供应商时有效数据]
+     */
+    private Integer shopId;
+    /**
+     * 运营人账号名【产品预留字段暂时不启用】
+     */
+    private String account;
+    /**
+     * 手机号码
+     */
+    private String mobile;
+    /**
+     * 邀请码
+     */
+    private String invitationCode;
+    /**
+     * 邀请码生成时间(此时间起48小时有效)
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date invitationCodeTime;
+    /**
+     * 微信昵称
+     */
+    private String nickName;
+    /**
+     * 微信头像(headimgurl)
+     */
+    private String avatarUrl;
+    /**
+     * 联系人,对应用户的userName
+     */
+    private String linkName;
+    /**
+     * 1未绑定,2已绑定
+     */
+    private Integer status;
+    /**
+     * token
+     */
+    private String token;
+    /**
+     * 微信unionId
+     */
+    private String unionId;
+    /**
+     * 微信openId
+     */
+    private String openId;
+    /**
+     * 微信openId(Pc)
+     */
+    private String pcOpenId;
+    /**
+     * 添加时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date addTime;
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+    /**
+     * 绑定时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date bindTime;
+    /**
+     * 用户状态,0 有效  其它无效
+     */
+    private Integer delFlag;
+    /**
+     * 邀请码是否有效 1有效,2已使用,3已失效
+     */
+    private Integer effectiveFlag;
+    /**
+     * 邀请码剩余天数
+     */
+    private Integer effectiveDays;
+    /**
+     * 确认标志
+     */
+    private String configFlag;
+}

+ 113 - 0
src/main/java/com/caimei365/user/model/vo/PaginationVo.java

@@ -0,0 +1,113 @@
+package com.caimei365.user.model.vo;
+
+import lombok.Builder;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/4/7
+ */
+@Data
+public class PaginationVo<T> implements Serializable {
+    /** 当前页码 */
+    @Builder.Default
+    private int pageNum = 1;
+    /** 每页大小 */
+    @Builder.Default
+    private int pageSize = 10;
+    /** 总记录数 */
+    private int totalRecord;
+    /** 总页数 */
+    private int totalPage;
+    /** 是否有后一页 */
+    private boolean hasNextPage;
+    /** 是否有前一页 */
+    private boolean hasPreviousPage;
+    /** 查询结果 */
+    List<T> results;
+
+    public PaginationVo(List<T> list) {
+        if (list instanceof com.github.pagehelper.Page) {
+            com.github.pagehelper.Page<T> page = (com.github.pagehelper.Page<T>) list;
+            this.pageNum = page.getPageNum();
+            this.pageSize = page.getPageSize();
+            this.totalRecord = (int) page.getTotal();
+            this.totalPage = page.getPages();
+            setHasPreviousAndNext();
+            this.results = page;
+        } else if (list != null) {
+            this.pageSize = list.size();
+            this.totalRecord = list.size();
+            this.totalPage = 1;
+            this.results = list;
+        }
+    }
+
+    public PaginationVo(int pageNum, int pageSize, int totalRecord, List<T> results) {
+        super();
+        this.pageNum = pageNum;
+        this.pageSize = pageSize;
+        this.totalRecord = totalRecord;
+        this.totalPage = totalRecord % pageSize == 0 ? totalRecord / pageSize : totalRecord / pageSize + 1;
+        this.results = results;
+        if (this.pageNum < 2) {
+            hasPreviousPage = false;
+        } else {
+            hasPreviousPage = true;
+        }
+        if (this.pageNum < totalPage) {
+            hasNextPage = true;
+        } else {
+            hasNextPage = false;
+        }
+    }
+
+    public PaginationVo(int pageNum, int maxSize, int totalRecord, int totalPage,
+                        List<T> results) {
+        super();
+        this.pageNum = pageNum;
+        this.pageSize = maxSize;
+        this.totalRecord = totalRecord;
+        this.totalPage = totalPage;
+        this.results = results;
+        if (this.pageNum < 2) {
+            hasPreviousPage = false;
+        } else {
+            hasPreviousPage = true;
+        }
+        if (this.pageNum < totalPage) {
+            hasNextPage = true;
+        } else {
+            hasNextPage = false;
+        }
+    }
+
+    public PaginationVo() {super();}
+
+    public void setHasPreviousAndNext() {
+        if (this.pageNum < 2) {
+            hasPreviousPage = false;
+        } else {
+            hasPreviousPage = true;
+        }
+        if (this.pageNum < totalPage) {
+            hasNextPage = true;
+        } else {
+            hasNextPage = false;
+        }
+    }
+
+    public int countTotalPage() {
+        int total = totalRecord % pageSize == 0 ? totalRecord / pageSize : totalRecord / pageSize + 1;
+        this.setTotalPage(total);
+        return total;
+    }
+
+    private static final long serialVersionUID = 1L;
+}
+

+ 26 - 0
src/main/java/com/caimei365/user/service/OperationService.java

@@ -2,6 +2,8 @@ package com.caimei365.user.service;
 
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.OperationDto;
+import com.caimei365.user.model.vo.OperationVo;
+import com.caimei365.user.model.vo.PaginationVo;
 
 /**
  * Description
@@ -17,8 +19,32 @@ public interface OperationService {
      *                         linkName  姓名
      *                         userId    用户Id(userID)
      *                         clubId    机构Id
+     *                         shopId    供应商Id
      *                         configFlag 确认标志
      *                     }
      */
     ResponseJson addOperation(OperationDto operationDto);
+    /**
+     * 更新邀请码
+     * @param operationDto {
+     *                         id        运营人员Id
+     *                     }
+     */
+    ResponseJson updateInvitationCode(OperationDto operationDto);
+    /**
+     * 删除运营人员(解绑)
+     * @param operationDto {
+     *                         id        运营人员Id
+     *                     }
+     */
+    ResponseJson unbindOperation(OperationDto operationDto);
+    /**
+     * 获取运营人员列表
+     * @param operationDto {
+     *                         mobile    手机号
+     *                         linkName  姓名
+     *                         userId    用户Id(userID)
+     *                     }
+     */
+    ResponseJson<PaginationVo<OperationVo>> getOperationList(OperationDto operationDto, int pageNum, int pageSize);
 }

+ 162 - 46
src/main/java/com/caimei365/user/service/impl/OperationServiceImpl.java

@@ -5,15 +5,21 @@ import com.caimei365.user.mapper.OperationMapper;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.OperationDto;
 import com.caimei365.user.model.po.OperationPo;
+import com.caimei365.user.model.vo.OperationVo;
+import com.caimei365.user.model.vo.PaginationVo;
 import com.caimei365.user.service.OperationService;
 import com.caimei365.user.utils.AliyunSmsUtil;
 import com.caimei365.user.utils.CodeUtil;
+import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.Calendar;
 import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
 
 /**
  * Description
@@ -37,58 +43,168 @@ public class OperationServiceImpl implements OperationService {
      *                     linkName  姓名
      *                     userId    用户Id(userID)
      *                     clubId    机构Id
+     *                     shopId    供应商Id
      *                     configFlag 确认标志
      *                     }
      */
     @Override
     public ResponseJson addOperation(OperationDto operationDto) {
         // 查询使用该手机号的运营人员或用户
-//        String checkRust = commonService.operationBindCheck(operationDto.getMobile(), null);
-//        if (checkRust != null) {
-//            return ResponseJson.error(checkRust, null);
-//        }
-//        OperationPo operation = new OperationPo();
-//        Date date = new Date();
-//        // 保存生成邀请码
-//        if (operationDto.getConfigFlag() == 2) {
-//            //生成随机码6位
-//            String invitationCode = generateInvitationCode();
-//            operation.setInvitationCode(invitationCode);
-//            operation.setInvitationCodeTime(date);
-//            operation.setStatus(1);
-//            //发送短信
-//            String name = null;
-//            if (operationDto.getClubId() != null) {
-//                name = operationMapper.findClubNameById(operationDto.getClubId());
-//            } else {
-//                name = operationMapper.findShopNameById(operationDto.getShopId());
-//            }
-//            String mobile = operationDto.getMobile();
-//            boolean sendFlag = false;
-//            if (StringUtils.isNotEmpty(mobile)) {
-//                sendFlag = AliyunSmsUtil.sendSms(mobile, 11, "{name:"+ name +",code:" + invitationCode + "}");
-//                log.info("欢迎成为"+ name +"的运营人员,您的邀请码为:" + invitationCode);
-//            }
-//        }
-//        if (operationDto.getShopId() == null) {
-//            operation.setUserType(1);
-//        } else {
-//            operation.setUserType(2);
-//        }
-//        operation.setAddTime(date);
-//        operation.setUpdateTime(date);
-//        operation.setDelFlag(0);
-//        operation.setOrganizeId(0);
-//        int flag = 0;
-//        if (operation.getId() == null) {
-//            operation.setAccount(operationDto.getMobile() + CodeUtil.generateAccount(2));
-//            operation.setStatus(1);
-//            flag = operationMapper.insertOperation(operation);
-//        } else {
-//            flag = operationMapper.updateOperation(operation);
-//        }
-//        return flag > 0 ? ResponseJson.success() : ResponseJson.error();
-        return null;
+        String checkRust = commonService.operationBindCheck(operationDto.getMobile(), null);
+        if (checkRust != null) {
+            return ResponseJson.error(checkRust, null);
+        }
+        OperationPo operation = new OperationPo();
+        operation.setId(operationDto.getId());
+        operation.setMobile(operationDto.getMobile());
+        operation.setLinkName(operationDto.getLinkName());
+        operation.setUserId(operationDto.getUserId());
+        operation.setClubId(operationDto.getClubId());
+        operation.setShopId(operationDto.getShopId());
+        Date date = new Date();
+        // 保存生成邀请码
+        if (operationDto.getConfigFlag() == 2) {
+            //生成随机码6位
+            String invitationCode = generateInvitationCode();
+            operation.setInvitationCode(invitationCode);
+            operation.setInvitationCodeTime(date);
+            operation.setStatus(1);
+            //发送短信
+            String name = null;
+            if (operationDto.getClubId() != null) {
+                name = operationMapper.findClubNameById(operationDto.getClubId());
+            } else {
+                name = operationMapper.findShopNameById(operationDto.getShopId());
+            }
+            String mobile = operationDto.getMobile();
+            if (StringUtils.isNotEmpty(mobile)) {
+                AliyunSmsUtil.sendSms(mobile, 11, "{name:"+ name +",code:" + invitationCode + "}");
+                log.info("欢迎成为"+ name +"的运营人员,您的邀请码为:" + invitationCode);
+            }
+        }
+        if (operationDto.getShopId() == null) {
+            operation.setUserType(1);
+        } else {
+            operation.setUserType(2);
+        }
+        operation.setAddTime(date);
+        operation.setUpdateTime(date);
+        operation.setDelFlag(0);
+        operation.setOrganizeId(0);
+        int flag = 0;
+        if (operation.getId() == null) {
+            operation.setAccount(operationDto.getMobile() + CodeUtil.generateAccount(2));
+            operation.setStatus(1);
+            flag = operationMapper.insertOperation(operation);
+        } else {
+            flag = operationMapper.updateOperation(operation);
+        }
+        return flag > 0 ? ResponseJson.success() : ResponseJson.error();
+    }
+
+    /**
+     * 更新邀请码
+     *
+     * @param operationDto {
+     *                     id        运营人员Id
+     *                     }
+     */
+    @Override
+    public ResponseJson updateInvitationCode(OperationDto operationDto) {
+        OperationPo operation = operationMapper.getOperationCodeInfoById(operationDto.getId());
+        int flag = 0;
+        if (operation.getStatus() == 2) {
+            return ResponseJson.error("该邀请码已绑定");
+        } else {
+            //生成随机码6位
+            String invitationCode = generateInvitationCode();
+            operation.setInvitationCode(invitationCode);
+            operation.setInvitationCodeTime(new Date());
+            operation.setStatus(1);
+            //发送短信
+            String name = null;
+            if (operation.getClubId() != null) {
+                name = operationMapper.findClubNameById(operation.getClubId());
+            } else {
+                name = operationMapper.findShopNameById(operation.getShopId());
+            }
+            String mobile = operation.getMobile();
+            if (StringUtils.isNotEmpty(mobile)) {
+                AliyunSmsUtil.sendSms(mobile, 11, "{name:"+ name +",code:" + invitationCode + "}");
+                log.info("欢迎成为"+ name +"的运营人员,您的邀请码为:" + invitationCode);
+            }
+            flag = operationMapper.updateOperation(operation);
+        }
+        return flag > 0 ? ResponseJson.success() : ResponseJson.error();
+    }
+
+    /**
+     * 删除运营人员(解绑)
+     *
+     * @param operationDto {
+     *                     id        运营人员Id
+     *                     }
+     */
+    @Override
+    public ResponseJson unbindOperation(OperationDto operationDto) {
+        int flag = commonService.unbindOperation(operationDto.getId());
+        return flag > 0 ? ResponseJson.success() : ResponseJson.error();
+    }
+
+    /**
+     * 获取运营人员列表
+     *
+     * @param operationDto {
+     *                     mobile    手机号
+     *                     linkName  姓名
+     *                     userId    用户Id(userID)
+     *                     }
+     * @param pageNum
+     * @param pageSize
+     */
+    @Override
+    public ResponseJson<PaginationVo<OperationVo>> getOperationList(OperationDto operationDto, int pageNum, int pageSize) {
+        Integer userId = operationDto.getUserId();
+        String mobile = operationDto.getMobile();
+        String linkName = operationDto.getLinkName();
+        if (userId == null) {
+            return ResponseJson.error("参数错误:userId不能为空!", null);
+        }
+        PageHelper.startPage(pageNum, pageSize);
+        List<OperationVo> operationList = operationMapper.getOperationListByUserId(userId, mobile, linkName);
+        if (null != operationList) {
+            // 判断邀请码是否有效
+            for (OperationVo operation : operationList) {
+                // 1未绑定,2已绑定
+                if (operation.getStatus() == 2) {
+                    // 邀请码是否有效 1有效,2已使用,3已失效
+                    operation.setEffectiveFlag(2);
+                } else {
+                    Date invitationCodeTime = operation.getInvitationCodeTime();
+                    if (null != invitationCodeTime) {
+                        Calendar calendar = new GregorianCalendar();
+                        calendar.setTime(invitationCodeTime);
+                        // num为增加的天数,可以改变的
+                        calendar.add(Calendar.DATE, 7);
+                        invitationCodeTime = calendar.getTime();
+                        boolean before = invitationCodeTime.before(new Date());
+                        if (before) {
+                            //如果验证码时间加上168小时小于当前时间则已过期
+                            operation.setEffectiveFlag(3);
+                        } else {
+                            operation.setEffectiveFlag(1);
+                            long time = operation.getInvitationCodeTime().getTime();
+                            long now = (new Date()).getTime();
+                            int days = (int) ((now - time) / (1000 * 60 * 60 * 24));
+                            int effectiveDays = 7 - days;
+                            operation.setEffectiveDays(effectiveDays);
+                        }
+                    }
+                }
+            }
+        }
+        PaginationVo<OperationVo> pageData = new PaginationVo<>(operationList);
+        return ResponseJson.success(pageData);
     }
 
 

+ 226 - 1
src/main/resources/mapper/OperationMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.user.mapper.OperationMapper">
-    <select id="getOperationByMobile" resultType="com.caimei365.user.model.po.OperationPo">
+<select id="getOperationByMobile" resultType="com.caimei365.user.model.po.OperationPo">
         select o.id as id,
                o.userID as userId,
                o.mobile as mobile,
@@ -24,6 +24,29 @@
         select name from shop
         where shopID = #{shopId}
     </select>
+    <select id="getOperationCodeInfoById" resultType="com.caimei365.user.model.po.OperationPo">
+        select o.id as id,
+               o.mobile as mobile,
+               o.clubID as clubId,
+               o.shopID as shopId,
+               o.status as status
+        from cm_mall_operation_user o
+        where o.id = #{id} and o.delFlag = '0'
+    </select>
+    <select id="getOperationListByUserId" resultType="com.caimei365.user.model.vo.OperationVo">
+        select id, userID as userId, userType, userOrganizeID as organizeId, clubID as clubId, shopID as shopId, account, mobile,
+            linkName, headimgurl as avatarUrl, invitationCode, status nickName, unionId, openid as openId, crmOpenid as crmOpenId, pcOpenid as pcOpenId,
+            invitationCodeTime, bindTime, updateTime, addTime, delFlag
+        from cm_mall_operation_user
+        where userID = #{userId} and delFlag = 0
+        <if test="mobile != null and mobile != ''">
+            and mobile like concat('%',#{mobile,jdbcType=VARCHAR},'%')
+        </if>
+        <if test="linkName != null and linkName != ''">
+            and linkName like concat('%',#{linkName,jdbcType=VARCHAR},'%')
+        </if>
+        order by addTime DESC
+    </select>
     <update id="updateOperationOpenId">
         update cm_mall_operation_user
         set openid = #{openId}
@@ -72,5 +95,207 @@
             delFlag = #{delFlag}
         where id = #{id}
     </update>
+    <insert id="insertOperation" keyColumn="id" keyProperty="id" parameterType="com.caimei365.user.model.po.OperationPo">
+        insert into cm_mall_operation_user
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userOrganizeID != null">
+                userOrganizeID,
+            </if>
+            <if test="userID != null">
+                userID,
+            </if>
+            <if test="userType != null">
+                userType,
+            </if>
+            <if test="shopID != null">
+                shopID,
+            </if>
+            <if test="clubID != null">
+                clubID,
+            </if>
+            <if test="account != null">
+                account,
+            </if>
+            <if test="mobile != null">
+                mobile,
+            </if>
+            <if test="linkName != null">
+                linkName,
+            </if>
+            <if test="headimgurl != null">
+                headimgurl,
+            </if>
+            <if test="invitationCode != null">
+                invitationCode,
+            </if>
+            <if test="status != null">
+                `status`,
+            </if>
+            <if test="nickName != null">
+                nickName,
+            </if>
+            <if test="unionId != null">
+                unionId,
+            </if>
+            <if test="openid != null">
+                openid,
+            </if>
+            <if test="crmOpenid != null">
+                crmOpenid,
+            </if>
+            <if test="pcOpenid != null">
+                pcOpenid,
+            </if>
+            <if test="invitationCodeTime != null">
+                invitationCodeTime,
+            </if>
+            <if test="bindTime != null">
+                bindTime,
+            </if>
+            <if test="updateTime != null">
+                updateTime,
+            </if>
+            <if test="addTime != null">
+                addTime,
+            </if>
+            <if test="delFlag != null">
+                delFlag,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="organizeId != null">
+                #{organizeId},
+            </if>
+            <if test="userId != null">
+                #{userId},
+            </if>
+            <if test="userType != null">
+                #{userType},
+            </if>
+            <if test="shopID != null">
+                #{shopId},
+            </if>
+            <if test="clubID != null">
+                #{clubId},
+            </if>
+            <if test="account != null">
+                #{account},
+            </if>
+            <if test="mobile != null">
+                #{mobile},
+            </if>
+            <if test="linkName != null">
+                #{linkName},
+            </if>
+            <if test="invitationCode != null">
+                #{invitationCode},
+            </if>
+            <if test="status != null">
+                #{status},
+            </if>
+            <if test="nickName != null">
+                #{nickName},
+            </if>
+            <if test="unionId != null">
+                #{unionId},
+            </if>
+            <if test="openId != null">
+                #{openId},
+            </if>
+            <if test="crmOpenId != null">
+                #{crmOpenId},
+            </if>
+            <if test="pcOpenId != null">
+                #{pcOpenId},
+            </if>
+            <if test="invitationCodeTime">
+                #{invitationCodeTime},
+            </if>
+            <if test="bindTime">
+                #{bindTime},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime},
+            </if>
+            <if test="addTime != null">
+                #{addTime},
+            </if>
+            <if test="delFlag != null">
+                #{delFlag},
+            </if>
+        </trim>
+        <selectKey resultType="java.lang.Integer" keyProperty="id">
+            SELECT LAST_INSERT_ID()
+        </selectKey>
+    </insert>
+    <update id="updateOperation" parameterType="com.caimei365.user.model.po.OperationPo">
+        update cm_mall_operation_user
+        <set>
+            <if test="organizeId != null">
+                userOrganizeID = #{organizeId},
+            </if>
+            <if test="userId != null">
+                userID = #{userId},
+            </if>
+            <if test="userType != null">
+                userType = #{userType},
+            </if>
+            <if test="shopId != null">
+                shopID = #{shopId},
+            </if>
+            <if test="clubId != null">
+                clubID = #{clubId},
+            </if>
+            <if test="account != null">
+                account = #{account},
+            </if>
+            <if test="mobile != null">
+                mobile = #{mobile},
+            </if>
+            <if test="linkName != null">
+                linkName = #{linkName},
+            </if>
+            <if test="avatarUrl != null">
+                headimgurl = #{avatarUrl},
+            </if>
+            <if test="invitationCode != null">
+                invitationCode = #{invitationCode},
+            </if>
+            <if test="status != null">
+                `status` = #{status},
+            </if>
+            <if test="nickName != null">
+                nickName = #{nickName},
+            </if>
+            <if test="unionId != null">
+                unionId = #{unionId},
+            </if>
+            <if test="openid != null">
+                openid = #{openId},
+            </if>
+            <if test="crmOpenid != null">
+                crmOpenid = #{crmOpenId},
+            </if>
+            <if test="pcOpenid != null">
+                pcOpenid = #{pcOpenId},
+            </if>
+            <if test="invitationCodeTime != null">
+                invitationCodeTime = #{invitationCodeTime},
+            </if>
+            <if test="bindTime != null">
+                bindTime = #{bindTime},
+            </if>
+            <if test="updateTime != null">
+                updateTime = #{updateTime},
+            </if>
+            <if test="addTime != null">
+                addTime = #{addTime},
+            </if>
+            <if test="delFlag != null">
+                delFlag = #{delFlag},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
 
 </mapper>