Преглед на файлове

qxm-增加多经销商切换

qxm преди 3 години
родител
ревизия
d63c46b714

+ 152 - 0
suishenbang-system/src/main/java/com/dgtly/system/domain/AssRelcustomerinfo.java

@@ -0,0 +1,152 @@
+package com.dgtly.system.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.dgtly.common.annotation.Excel;
+import com.dgtly.common.core.domain.BaseEntity;
+import java.util.Date;
+
+/**
+ * 多经销商关联对象 ass_relcustomerinfo
+ * 
+ * @author dgtly
+ * @date 2021-04-08
+ */
+public class AssRelcustomerinfo extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    private Long id;
+
+    /** 是否删除 */
+    @Excel(name = "是否删除")
+    private Long isDelete;
+
+    private String mainkunnr;
+
+    private String mainname1;
+
+    private String kunnr;
+
+    private String name1;
+
+    private String glfs;
+
+    private Date glsj;
+
+    private Date enddate;
+
+    private Date etlCreatetime;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setIsDelete(Long isDelete) 
+    {
+        this.isDelete = isDelete;
+    }
+
+    public Long getIsDelete() 
+    {
+        return isDelete;
+    }
+    public void setMainkunnr(String mainkunnr) 
+    {
+        this.mainkunnr = mainkunnr;
+    }
+
+    public String getMainkunnr() 
+    {
+        return mainkunnr;
+    }
+    public void setMainname1(String mainname1) 
+    {
+        this.mainname1 = mainname1;
+    }
+
+    public String getMainname1() 
+    {
+        return mainname1;
+    }
+    public void setKunnr(String kunnr) 
+    {
+        this.kunnr = kunnr;
+    }
+
+    public String getKunnr() 
+    {
+        return kunnr;
+    }
+    public void setName1(String name1) 
+    {
+        this.name1 = name1;
+    }
+
+    public String getName1() 
+    {
+        return name1;
+    }
+    public void setGlfs(String glfs) 
+    {
+        this.glfs = glfs;
+    }
+
+    public String getGlfs() 
+    {
+        return glfs;
+    }
+    public void setGlsj(Date glsj) 
+    {
+        this.glsj = glsj;
+    }
+
+    public Date getGlsj() 
+    {
+        return glsj;
+    }
+    public void setEnddate(Date enddate) 
+    {
+        this.enddate = enddate;
+    }
+
+    public Date getEnddate() 
+    {
+        return enddate;
+    }
+    public void setEtlCreatetime(Date etlCreatetime) 
+    {
+        this.etlCreatetime = etlCreatetime;
+    }
+
+    public Date getEtlCreatetime() 
+    {
+        return etlCreatetime;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("isDelete", getIsDelete())
+            .append("mainkunnr", getMainkunnr())
+            .append("mainname1", getMainname1())
+            .append("kunnr", getKunnr())
+            .append("name1", getName1())
+            .append("glfs", getGlfs())
+            .append("glsj", getGlsj())
+            .append("enddate", getEnddate())
+            .append("etlCreatetime", getEtlCreatetime())
+            .toString();
+    }
+}

+ 10 - 0
suishenbang-system/src/main/java/com/dgtly/system/domain/SysUser.java

@@ -115,6 +115,8 @@ public class SysUser extends BaseEntity
     private String receiveUrlMobileNo;
     /** 用户销售信息扩展 */
     private SysUserExt  sysUserExt;
+    /** 用户销售信息扩展 */
+    private List<SysUserExt>  sysUserExtLsit;
     /** 是否收货人 */
     private String  isConsignee;
     /*企业认证状态0未认证1已认证*/
@@ -498,6 +500,14 @@ public class SysUser extends BaseEntity
         this.orgAttestationTime = orgAttestationTime;
     }
 
+    public List<SysUserExt> getSysUserExtLsit() {
+        return sysUserExtLsit;
+    }
+
+    public void setSysUserExtLsit(List<SysUserExt> sysUserExtLsit) {
+        this.sysUserExtLsit = sysUserExtLsit;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 63 - 0
suishenbang-system/src/main/java/com/dgtly/system/mapper/AssRelcustomerinfoMapper.java

@@ -0,0 +1,63 @@
+package com.dgtly.system.mapper;
+
+import com.dgtly.system.domain.AssRelcustomerinfo;
+import java.util.List;
+
+/**
+ * 多经销商关联Mapper接口
+ * 
+ * @author dgtly
+ * @date 2021-04-08
+ */
+public interface AssRelcustomerinfoMapper 
+{
+    /**
+     * 查询多经销商关联
+     * 
+     * @param id 多经销商关联ID
+     * @return 多经销商关联
+     */
+    public AssRelcustomerinfo selectAssRelcustomerinfoById(Long id);
+
+    /**
+     * 查询多经销商关联列表
+     * 
+     * @param assRelcustomerinfo 多经销商关联
+     * @return 多经销商关联集合
+     */
+    public List<AssRelcustomerinfo> selectAssRelcustomerinfoList(AssRelcustomerinfo assRelcustomerinfo);
+
+    /**
+     * 新增多经销商关联
+     * 
+     * @param assRelcustomerinfo 多经销商关联
+     * @return 结果
+     */
+    public int insertAssRelcustomerinfo(AssRelcustomerinfo assRelcustomerinfo);
+
+    /**
+     * 修改多经销商关联
+     * 
+     * @param assRelcustomerinfo 多经销商关联
+     * @return 结果
+     */
+    public int updateAssRelcustomerinfo(AssRelcustomerinfo assRelcustomerinfo);
+
+    /**
+     * 删除多经销商关联
+     * 
+     * @param id 多经销商关联ID
+     * @return 结果
+     */
+    public int deleteAssRelcustomerinfoById(Long id);
+
+    /**
+     * 批量删除多经销商关联
+     * 
+     * @param ids 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteAssRelcustomerinfoByIds(String[] ids);
+
+    List<AssRelcustomerinfo> selectRelcustomerinfoListByorgCode(String orgCode);
+}

+ 20 - 0
suishenbang-system/src/main/java/com/dgtly/system/mapper/SysUserExtMapper.java

@@ -1,6 +1,8 @@
 package com.dgtly.system.mapper;
 
 import com.dgtly.system.domain.SysUserExt;
+import org.apache.ibatis.annotations.Param;
+
 import java.util.List;
 
 /**
@@ -74,4 +76,22 @@ public interface SysUserExtMapper
      * @return 结果
      */
     public int insertOrUpSysUserExt(SysUserExt sysUserExt);
+
+    /**
+     * @description: 根据userid查询多经销商列表
+     * @param: [userId]
+     * @return: java.util.List<com.dgtly.system.domain.SysUserExt>
+     * @author: qxm
+     * @date: 2021/4/9 9:39
+     */
+    List<SysUserExt> selectSysUserExtListByUserId(Long userId);
+
+    /**
+     * @description: 切换经销商
+     * @param: [userId, customerCode, orgName]
+     * @return: com.dgtly.system.domain.SysUserExt
+     * @author: qxm
+     * @date: 2021/4/9 9:39
+     */
+    int switchCustomer(@Param("userId") String userId, @Param("orgCode") String orgCode, @Param("orgName") String orgName);
 }

+ 63 - 0
suishenbang-system/src/main/java/com/dgtly/system/service/IAssRelcustomerinfoService.java

@@ -0,0 +1,63 @@
+package com.dgtly.system.service;
+
+import com.dgtly.system.domain.AssRelcustomerinfo;
+import java.util.List;
+
+/**
+ * 多经销商关联Service接口
+ * 
+ * @author dgtly
+ * @date 2021-04-08
+ */
+public interface IAssRelcustomerinfoService 
+{
+    /**
+     * 查询多经销商关联
+     * 
+     * @param id 多经销商关联ID
+     * @return 多经销商关联
+     */
+    public AssRelcustomerinfo selectAssRelcustomerinfoById(Long id);
+
+    /**
+     * 查询多经销商关联列表
+     * 
+     * @param assRelcustomerinfo 多经销商关联
+     * @return 多经销商关联集合
+     */
+    public List<AssRelcustomerinfo> selectAssRelcustomerinfoList(AssRelcustomerinfo assRelcustomerinfo);
+
+    /**
+     * 新增多经销商关联
+     * 
+     * @param assRelcustomerinfo 多经销商关联
+     * @return 结果
+     */
+    public int insertAssRelcustomerinfo(AssRelcustomerinfo assRelcustomerinfo);
+
+    /**
+     * 修改多经销商关联
+     * 
+     * @param assRelcustomerinfo 多经销商关联
+     * @return 结果
+     */
+    public int updateAssRelcustomerinfo(AssRelcustomerinfo assRelcustomerinfo);
+
+    /**
+     * 批量删除多经销商关联
+     * 
+     * @param ids 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteAssRelcustomerinfoByIds(String ids);
+
+    /**
+     * 删除多经销商关联信息
+     * 
+     * @param id 多经销商关联ID
+     * @return 结果
+     */
+    public int deleteAssRelcustomerinfoById(Long id);
+
+    List<AssRelcustomerinfo> selectRelcustomerinfoListByorgCode(String orgCode);
+}

+ 19 - 0
suishenbang-system/src/main/java/com/dgtly/system/service/ISysUserExtService.java

@@ -82,4 +82,23 @@ public interface ISysUserExtService
      * @return 结果
      */
     public int delAndInsertSysUserExt(SysUserExt ext);
+
+    /**
+     * @description: 根据userid查询多经销商列表
+     * @param: [userId]
+     * @return: java.util.List<com.dgtly.system.domain.SysUserExt>
+     * @author: qxm
+     * @date: 2021/4/9 9:39
+     */
+    List<SysUserExt> selectSysUserExtListByUserId(Long userId);
+
+    /**
+     * @description: 切换经销商
+     * @param: [userId, orgCode, orgName]
+     * @return: com.dgtly.system.domain.SysUserExt
+     * @author: qxm
+     * @date: 2021/4/9 9:41
+     */
+    int switchCustomer(String userId, String orgCode, String orgName);
+
 }

+ 102 - 0
suishenbang-system/src/main/java/com/dgtly/system/service/impl/AssRelcustomerinfoServiceImpl.java

@@ -0,0 +1,102 @@
+package com.dgtly.system.service.impl;
+
+import java.util.List;
+import com.dgtly.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.dgtly.system.mapper.AssRelcustomerinfoMapper;
+import com.dgtly.system.domain.AssRelcustomerinfo;
+import com.dgtly.system.service.IAssRelcustomerinfoService;
+import com.dgtly.common.core.text.Convert;
+
+/**
+ * 多经销商关联Service业务层处理
+ * 
+ * @author dgtly
+ * @date 2021-04-08
+ */
+@Service
+public class AssRelcustomerinfoServiceImpl implements IAssRelcustomerinfoService 
+{
+    @Autowired
+    private AssRelcustomerinfoMapper assRelcustomerinfoMapper;
+
+    /**
+     * 查询多经销商关联
+     * 
+     * @param id 多经销商关联ID
+     * @return 多经销商关联
+     */
+    @Override
+    public AssRelcustomerinfo selectAssRelcustomerinfoById(Long id)
+    {
+        return assRelcustomerinfoMapper.selectAssRelcustomerinfoById(id);
+    }
+
+    /**
+     * 查询多经销商关联列表
+     * 
+     * @param assRelcustomerinfo 多经销商关联
+     * @return 多经销商关联
+     */
+    @Override
+    public List<AssRelcustomerinfo> selectAssRelcustomerinfoList(AssRelcustomerinfo assRelcustomerinfo)
+    {
+        return assRelcustomerinfoMapper.selectAssRelcustomerinfoList(assRelcustomerinfo);
+    }
+
+    /**
+     * 新增多经销商关联
+     * 
+     * @param assRelcustomerinfo 多经销商关联
+     * @return 结果
+     */
+    @Override
+    public int insertAssRelcustomerinfo(AssRelcustomerinfo assRelcustomerinfo)
+    {
+        assRelcustomerinfo.setCreateTime(DateUtils.getNowDate());
+        return assRelcustomerinfoMapper.insertAssRelcustomerinfo(assRelcustomerinfo);
+    }
+
+    /**
+     * 修改多经销商关联
+     * 
+     * @param assRelcustomerinfo 多经销商关联
+     * @return 结果
+     */
+    @Override
+    public int updateAssRelcustomerinfo(AssRelcustomerinfo assRelcustomerinfo)
+    {
+        assRelcustomerinfo.setUpdateTime(DateUtils.getNowDate());
+        return assRelcustomerinfoMapper.updateAssRelcustomerinfo(assRelcustomerinfo);
+    }
+
+    /**
+     * 删除多经销商关联对象
+     * 
+     * @param ids 需要删除的数据ID
+     * @return 结果
+     */
+    @Override
+    public int deleteAssRelcustomerinfoByIds(String ids)
+    {
+        return assRelcustomerinfoMapper.deleteAssRelcustomerinfoByIds(Convert.toStrArray(ids));
+    }
+
+    /**
+     * 删除多经销商关联信息
+     * 
+     * @param id 多经销商关联ID
+     * @return 结果
+     */
+    @Override
+    public int deleteAssRelcustomerinfoById(Long id)
+    {
+        return assRelcustomerinfoMapper.deleteAssRelcustomerinfoById(id);
+    }
+
+    @Override
+    public List<AssRelcustomerinfo> selectRelcustomerinfoListByorgCode(String orgCode) {
+        return assRelcustomerinfoMapper.selectRelcustomerinfoListByorgCode(orgCode);
+    }
+}

+ 25 - 0
suishenbang-system/src/main/java/com/dgtly/system/service/impl/SysUserExtServiceImpl.java

@@ -120,4 +120,29 @@ public class SysUserExtServiceImpl implements ISysUserExtService
         sysUserExtMapper.deleteSysUserExtById(ext.getUserId());
         return sysUserExtMapper.insertSysUserExt(ext);
     }
+
+    /**
+     * @description: 根据userid查询多经销商列表
+     * @param: [userId]
+     * @return: java.util.List<com.dgtly.system.domain.SysUserExt>
+     * @author: qxm
+     * @date: 2021/4/9 9:39
+     */
+    @Override
+    public List<SysUserExt> selectSysUserExtListByUserId(Long userId) {
+        return sysUserExtMapper.selectSysUserExtListByUserId(userId);
+    }
+
+    /**
+     * @description: 切换经销商
+     * @param: [userId, orgCode, orgName]
+     * @return: com.dgtly.system.domain.SysUserExt
+     * @author: qxm
+     * @date: 2021/4/9 9:39
+     */
+    @Override
+    public int switchCustomer(String userId, String orgCode, String orgName) {
+        return sysUserExtMapper.switchCustomer(userId,orgCode,orgName);
+    }
+
 }

+ 133 - 0
suishenbang-system/src/main/resources/mapper/system/AssRelcustomerinfoMapper.xml

@@ -0,0 +1,133 @@
+<?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.dgtly.system.mapper.AssRelcustomerinfoMapper">
+    
+    <resultMap type="AssRelcustomerinfo" id="AssRelcustomerinfoResult">
+        <result property="id"    column="id"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="isDelete"    column="is_delete"    />
+        <result property="mainkunnr"    column="mainkunnr"    />
+        <result property="mainname1"    column="mainname1"    />
+        <result property="kunnr"    column="kunnr"    />
+        <result property="name1"    column="name1"    />
+        <result property="glfs"    column="glfs"    />
+        <result property="glsj"    column="glsj"    />
+        <result property="enddate"    column="enddate"    />
+        <result property="etlCreatetime"    column="ETL_createtime"    />
+    </resultMap>
+
+    <sql id="selectAssRelcustomerinfoVo">
+        select id, create_by, create_time, update_by, update_time, is_delete, mainkunnr, mainname1, kunnr, name1, glfs, glsj, enddate, ETL_createtime from ass_relcustomerinfo
+    </sql>
+
+    <select id="selectAssRelcustomerinfoList" parameterType="AssRelcustomerinfo" resultMap="AssRelcustomerinfoResult">
+        <include refid="selectAssRelcustomerinfoVo"/>
+        <where>  
+            <if test="isDelete != null "> and is_delete = #{isDelete}</if>
+            <if test="mainkunnr != null  and mainkunnr != ''"> and mainkunnr = #{mainkunnr}</if>
+            <if test="mainname1 != null  and mainname1 != ''"> and mainname1 = #{mainname1}</if>
+            <if test="kunnr != null  and kunnr != ''"> and kunnr = #{kunnr}</if>
+            <if test="name1 != null  and name1 != ''"> and name1 = #{name1}</if>
+            <if test="glfs != null  and glfs != ''"> and glfs = #{glfs}</if>
+            <if test="glsj != null "> and glsj = #{glsj}</if>
+            <if test="enddate != null "> and enddate = #{enddate}</if>
+            <if test="etlCreatetime != null "> and ETL_createtime = #{etlCreatetime}</if>
+        </where>
+    </select>
+    
+    <select id="selectAssRelcustomerinfoById" parameterType="Long" resultMap="AssRelcustomerinfoResult">
+        <include refid="selectAssRelcustomerinfoVo"/>
+        where id = #{id}
+    </select>
+    <select id="selectRelcustomerinfoListByorgCode" resultMap="AssRelcustomerinfoResult">
+        <include refid="selectAssRelcustomerinfoVo"/>
+        where
+            glfs != '开票方关联'
+        AND (
+            SELECT
+                ar.mainkunnr
+            FROM
+                ass_relcustomerinfo ar
+            WHERE
+                1 = 1
+            AND (
+                #{orgCode} = ar.mainkunnr
+                OR #{orgCode} = ar.kunnr
+                )
+            GROUP BY
+            ar.mainkunnr
+        ) = mainkunnr
+
+    </select>
+
+    <insert id="insertAssRelcustomerinfo" parameterType="AssRelcustomerinfo" useGeneratedKeys="true" keyProperty="id">
+        insert into ass_relcustomerinfo
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="createBy != null  and createBy != ''">create_by,</if>
+            <if test="createTime != null ">create_time,</if>
+            <if test="updateBy != null  and updateBy != ''">update_by,</if>
+            <if test="updateTime != null ">update_time,</if>
+            <if test="isDelete != null ">is_delete,</if>
+            <if test="mainkunnr != null  and mainkunnr != ''">mainkunnr,</if>
+            <if test="mainname1 != null  and mainname1 != ''">mainname1,</if>
+            <if test="kunnr != null  and kunnr != ''">kunnr,</if>
+            <if test="name1 != null  and name1 != ''">name1,</if>
+            <if test="glfs != null  and glfs != ''">glfs,</if>
+            <if test="glsj != null ">glsj,</if>
+            <if test="enddate != null ">enddate,</if>
+            <if test="etlCreatetime != null ">ETL_createtime,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="createBy != null  and createBy != ''">#{createBy},</if>
+            <if test="createTime != null ">#{createTime},</if>
+            <if test="updateBy != null  and updateBy != ''">#{updateBy},</if>
+            <if test="updateTime != null ">#{updateTime},</if>
+            <if test="isDelete != null ">#{isDelete},</if>
+            <if test="mainkunnr != null  and mainkunnr != ''">#{mainkunnr},</if>
+            <if test="mainname1 != null  and mainname1 != ''">#{mainname1},</if>
+            <if test="kunnr != null  and kunnr != ''">#{kunnr},</if>
+            <if test="name1 != null  and name1 != ''">#{name1},</if>
+            <if test="glfs != null  and glfs != ''">#{glfs},</if>
+            <if test="glsj != null ">#{glsj},</if>
+            <if test="enddate != null ">#{enddate},</if>
+            <if test="etlCreatetime != null ">#{etlCreatetime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateAssRelcustomerinfo" parameterType="AssRelcustomerinfo">
+        update ass_relcustomerinfo
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="createBy != null  and createBy != ''">create_by = #{createBy},</if>
+            <if test="createTime != null ">create_time = #{createTime},</if>
+            <if test="updateBy != null  and updateBy != ''">update_by = #{updateBy},</if>
+            <if test="updateTime != null ">update_time = #{updateTime},</if>
+            <if test="isDelete != null ">is_delete = #{isDelete},</if>
+            <if test="mainkunnr != null  and mainkunnr != ''">mainkunnr = #{mainkunnr},</if>
+            <if test="mainname1 != null  and mainname1 != ''">mainname1 = #{mainname1},</if>
+            <if test="kunnr != null  and kunnr != ''">kunnr = #{kunnr},</if>
+            <if test="name1 != null  and name1 != ''">name1 = #{name1},</if>
+            <if test="glfs != null  and glfs != ''">glfs = #{glfs},</if>
+            <if test="glsj != null ">glsj = #{glsj},</if>
+            <if test="enddate != null ">enddate = #{enddate},</if>
+            <if test="etlCreatetime != null ">ETL_createtime = #{etlCreatetime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteAssRelcustomerinfoById" parameterType="Long">
+        delete from ass_relcustomerinfo where id = #{id}
+    </delete>
+
+    <delete id="deleteAssRelcustomerinfoByIds" parameterType="String">
+        delete from ass_relcustomerinfo where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+    
+</mapper>

+ 28 - 0
suishenbang-system/src/main/resources/mapper/system/SysUserSalesExtMapper.xml

@@ -89,6 +89,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </trim>
         where user_id = #{userId}
     </update>
+    <update id="switchCustomer">
+        update sys_user_ext
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="orgName != null  and orgName != ''">org_name = #{orgName},</if>
+            <if test="orgCode != null and orgCode != ''"> org_code =#{orgCode}, </if>
+        </trim>
+        where user_id = #{userId}
+    </update>
 
     <delete id="deleteSysUserExtById" parameterType="Long">
         delete from sys_user_ext where user_id = #{userId}
@@ -154,5 +162,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         from sys_user_ext
         where boss_employee_id = #{bossEmployeeId,}
     </select>
+    <select id="selectSysUserExtListByUserId" resultMap="SysUserExtResult">
+        SELECT
+            sue.user_id,
+            sue.org_code,
+            sue.sales_level,
+            ar.name1 org_name,
+            sue.sap_employee_id,
+            sue.boss_employee_id,
+            sue.boss_name,
+            ar.kunnr customer_code,
+            sue.is_customer_manager,
+            sue.post_code,
+            sue.post_name
+        FROM
+            sys_user_ext sue
+        LEFT JOIN ass_relcustomerinfo ar ON sue.customer_code = ar.mainkunnr
+        WHERE
+            ar.glfs != '开票方关联'
+        AND user_id = #{userId}
+    </select>
 
 </mapper>

+ 53 - 4
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/EsignController.java

@@ -8,8 +8,11 @@ import com.dgtly.common.constant.Constants;
 import com.dgtly.common.core.controller.ApiBaseController;
 import com.dgtly.common.core.domain.AjaxResult;
 import com.dgtly.common.core.domain.ParameterObject;
+import com.dgtly.system.domain.AssRelcustomerinfo;
 import com.dgtly.system.domain.CustomersExt;
 import com.dgtly.system.domain.SysUser;
+import com.dgtly.system.domain.SysUserExt;
+import com.dgtly.system.service.IAssRelcustomerinfoService;
 import com.dgtly.system.service.ICustomersExtService;
 import com.dgtly.system.service.ISysUserExtService;
 import com.dgtly.system.service.ISysUserService;
@@ -24,6 +27,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.apache.tomcat.util.digester.ArrayStack;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -33,6 +37,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.io.File;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -66,6 +71,8 @@ public class EsignController extends ApiBaseController {
     private ESignConfig eSignConfig;
     @Autowired
     private ServerConfig serverConfig;
+    @Autowired
+    private IAssRelcustomerinfoService assRelcustomerinfoService;
     /**
      * 经销商订单签收方法
      * 没有注册就注册,注册完就认证,然后再点击签署按钮,获取经销商用户id,对应主体id
@@ -480,15 +487,57 @@ public class EsignController extends ApiBaseController {
         String userId = obj.getString("userId");
         Map map = new HashMap(5);
         SysUser sysUser = userService.selectUserById(Long.parseLong(userId));
+        /*根据org_code查询多个经销商列表*/
+        List<SysUserExt> sysUserExtList = new ArrayStack<>();
+        List<AssRelcustomerinfo>  assRelcustomerinfoList= assRelcustomerinfoService.selectRelcustomerinfoListByorgCode(sysUser.getSysUserExt().getOrgCode());
+        if (assRelcustomerinfoList.size()>0){
+            for (AssRelcustomerinfo ar:assRelcustomerinfoList) {
+                SysUserExt sysUserExt = new SysUserExt();
+                sysUserExt.setUserId(sysUser.getSysUserExt().getUserId());
+                sysUserExt.setOrgCode(ar.getKunnr());
+                sysUserExt.setOrgName(ar.getName1());
+                sysUserExt.setSalesLevel(sysUser.getSysUserExt().getSalesLevel());
+                sysUserExt.setBossEmployeeId(sysUser.getSysUserExt().getBossEmployeeId());
+                sysUserExt.setBossName(sysUser.getSysUserExt().getBossName());
+                sysUserExt.setSapEmployeeId(sysUser.getSysUserExt().getSapEmployeeId());
+                sysUserExt.setCustomerCode(sysUser.getSysUserExt().getCustomerCode());
+                sysUserExt.setIsCustomerManager(sysUser.getSysUserExt().getIsCustomerManager());
+                sysUserExt.setPostCode(sysUser.getSysUserExt().getPostCode());
+                sysUserExt.setPostName(sysUser.getSysUserExt().getPostName());
+                sysUserExtList.add(sysUserExt);
+            }
+            SysUserExt sysUserExt = new SysUserExt();
+            sysUserExt.setUserId(sysUser.getSysUserExt().getUserId());
+            sysUserExt.setOrgCode(assRelcustomerinfoList.get(0).getMainkunnr());
+            sysUserExt.setOrgName(assRelcustomerinfoList.get(0).getMainname1());
+            sysUserExt.setSalesLevel(sysUser.getSysUserExt().getSalesLevel());
+            sysUserExt.setBossEmployeeId(sysUser.getSysUserExt().getBossEmployeeId());
+            sysUserExt.setBossName(sysUser.getSysUserExt().getBossName());
+            sysUserExt.setSapEmployeeId(sysUser.getSysUserExt().getSapEmployeeId());
+            sysUserExt.setCustomerCode(sysUser.getSysUserExt().getCustomerCode());
+            sysUserExt.setIsCustomerManager(sysUser.getSysUserExt().getIsCustomerManager());
+            sysUserExt.setPostCode(sysUser.getSysUserExt().getPostCode());
+            sysUserExt.setPostName(sysUser.getSysUserExt().getPostName());
+            sysUserExtList.add(sysUserExt);
+        }
+        sysUser.setSysUserExtLsit(sysUserExtList);
         if (sysUser!=null){
             map.put("user",sysUser);
-            CustomersExt customersExt = customersExtService.selectCustomersExtById(sysUser.getSysUserExt().getOrgCode());
-            if (customersExt!=null){
-                map.put("customers",customersExt);
+            List<CustomersExt> customersExtList = new ArrayStack<>();
+            for (SysUserExt sysUserExt:sysUserExtList) {
+                CustomersExt customersExt = customersExtService.selectCustomersExtById(sysUserExt.getOrgCode());
+                if (customersExt!=null){
+                    customersExtList.add(customersExt);
+                }
+            }
+            map.put("customersExtList",customersExtList);
+            return AjaxResult.success(map);
+            /*if (customersExtList.size()>0){
+                map.put("customersExtList",customersExtList);
                 return AjaxResult.success(map);
             }else{
                 return AjaxResult.success(map);
-            }
+            }*/
         }else{
             return AjaxResult.error("用户不存在");
         }

+ 22 - 0
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/WxPortalController.java

@@ -84,6 +84,28 @@ public class WxPortalController extends ApiBaseController {
         }
     }
 
+    @ApiOperation(value = "切换经销商", notes = "参数:{'userId':'XXXXXXX','orgCode':'XXXXXXX','orgName':'XXXXXXX'}" +
+            "\n(userId:用户id)" +
+            "\n(orgCode:经销商code)" +
+            "\n(orgName:经销商名称)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "params", paramType = "body")
+    })
+    @PostMapping("switchCustomer")
+    public Object switchCustomer() {
+        ParameterObject obj = getParameterObject();
+        obj.checkParameterNotNull("userId,orgCode,orgName");
+        String userId = obj.getString("userId");
+        String orgCode = obj.getString("orgCode");
+        String orgName = obj.getString("orgName");
+        int row = userExtService.switchCustomer(userId,orgCode,orgName);
+        if (row>0){
+            return AjaxResult.success();
+        }else{
+            return AjaxResult.error("经销商切换失败");
+        }
+    }
+
     @ApiOperation(value = "设置/取消是否为收货人", notes = "参数:{'userId':'XXXXXXX','IsConsignee':'1'}" +
             "\n(userId:用户id" +
             "\n IsConsignee:是否收货人(0否1是))")