Quellcode durchsuchen

授权委托,自主下单,收货人

njs vor 9 Monaten
Ursprung
Commit
da1c229c5b

+ 112 - 0
suishenbang-system/src/main/java/com/dgtly/system/domain/SysUserCustomerAuthorization.java

@@ -0,0 +1,112 @@
+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;
+
+/**
+ * 经销商用户授权对象 sys_user_customer_authorization
+ * 
+ * @author njs
+ * @date 2024-05-24
+ */
+public class SysUserCustomerAuthorization extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 经销商编码 */
+    @Excel(name = "经销商编码")
+    private String customerCode;
+
+    /** 用户id */
+    @Excel(name = "用户id")
+    private Long userId;
+
+    /** 是否收货人(0否1是) */
+    @Excel(name = "是否收货人", readConverterExp = "0=否1是")
+    private String isConsignee;
+
+    /** 自主下单是否授权(0否1是) */
+    @Excel(name = "自主下单是否授权(0否1是)")
+    private String isIndependently;
+
+    /** 自提是否授权(0否1是) */
+    @Excel(name = "自提是否授权(0否1是)")
+    private String isSelfDelivery;
+
+    /** 是否删除 */
+    @Excel(name = "是否删除")
+    private Long isDelete;
+
+    public void setCustomerCode(String customerCode) 
+    {
+        this.customerCode = customerCode;
+    }
+
+    public String getCustomerCode() 
+    {
+        return customerCode;
+    }
+    public void setUserId(Long userId) 
+    {
+        this.userId = userId;
+    }
+
+    public Long getUserId() 
+    {
+        return userId;
+    }
+    public void setIsConsignee(String isConsignee) 
+    {
+        this.isConsignee = isConsignee;
+    }
+
+    public String getIsConsignee() 
+    {
+        return isConsignee;
+    }
+    public void setIsIndependently(String isIndependently) 
+    {
+        this.isIndependently = isIndependently;
+    }
+
+    public String getIsIndependently() 
+    {
+        return isIndependently;
+    }
+    public void setIsSelfDelivery(String isSelfDelivery) 
+    {
+        this.isSelfDelivery = isSelfDelivery;
+    }
+
+    public String getIsSelfDelivery() 
+    {
+        return isSelfDelivery;
+    }
+    public void setIsDelete(Long isDelete) 
+    {
+        this.isDelete = isDelete;
+    }
+
+    public Long getIsDelete() 
+    {
+        return isDelete;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("customerCode", getCustomerCode())
+            .append("userId", getUserId())
+            .append("isConsignee", getIsConsignee())
+            .append("isIndependently", getIsIndependently())
+            .append("isSelfDelivery", getIsSelfDelivery())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("isDelete", getIsDelete())
+            .toString();
+    }
+}

+ 81 - 0
suishenbang-system/src/main/java/com/dgtly/system/mapper/SysUserCustomerAuthorizationMapper.java

@@ -0,0 +1,81 @@
+package com.dgtly.system.mapper;
+
+import com.dgtly.system.domain.SysUserCustomerAuthorization;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 经销商用户授权Mapper接口
+ *
+ * @author njs
+ * @date 2024-05-24
+ */
+public interface SysUserCustomerAuthorizationMapper
+{
+    /**
+     * 查询经销商用户授权
+     *
+     * @param customerCode 经销商用户授权ID
+     * @return 经销商用户授权
+     */
+    public SysUserCustomerAuthorization selectSysUserCustomerAuthorizationById(String customerCode);
+
+    /**
+     * @description: 查询根据经销商用户查询授权
+     * @param: [customerCode, userId]
+     * @return: com.dgtly.system.domain.SysUserCustomerAuthorization
+     * @author: njs
+     * @date: 2024/5/24 14:15
+     */
+    public SysUserCustomerAuthorization selectAuthorizationByUserIdAndCustomerCode(@Param("customerCode") String customerCode,@Param("userId")  String userId);
+
+    /**
+     * 查询经销商用户授权列表
+     *
+     * @param sysUserCustomerAuthorization 经销商用户授权
+     * @return 经销商用户授权集合
+     */
+    public List<SysUserCustomerAuthorization> selectSysUserCustomerAuthorizationList(SysUserCustomerAuthorization sysUserCustomerAuthorization);
+
+    /**
+     * 新增经销商用户授权
+     *
+     * @param sysUserCustomerAuthorization 经销商用户授权
+     * @return 结果
+     */
+    public int insertSysUserCustomerAuthorization(SysUserCustomerAuthorization sysUserCustomerAuthorization);
+
+    /**
+     * 修改经销商用户授权
+     *
+     * @param sysUserCustomerAuthorization 经销商用户授权
+     * @return 结果
+     */
+    public int updateSysUserCustomerAuthorization(SysUserCustomerAuthorization sysUserCustomerAuthorization);
+
+    /**
+     * @description: 根据经销商编号和用户id修改授权标记
+     * @param: [sysUserCustomerAuthorization]
+     * @return: int
+     * @author: njs
+     * @date: 2024/5/24 13:58
+     */
+    public int  updateAuthorizationByCustomerCodeAndUserId(SysUserCustomerAuthorization sysUserCustomerAuthorization);
+
+    /**
+     * 删除经销商用户授权
+     *
+     * @param customerCode 经销商用户授权ID
+     * @return 结果
+     */
+    public int deleteSysUserCustomerAuthorizationById(String customerCode);
+
+    /**
+     * 批量删除经销商用户授权
+     *
+     * @param customerCodes 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteSysUserCustomerAuthorizationByIds(String[] customerCodes);
+}

+ 84 - 0
suishenbang-system/src/main/java/com/dgtly/system/service/ISysUserCustomerAuthorizationService.java

@@ -0,0 +1,84 @@
+package com.dgtly.system.service;
+
+import com.dgtly.system.domain.SysUserCustomerAuthorization;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 经销商用户授权Service接口
+ *
+ * @author njs
+ * @date 2024-05-24
+ */
+public interface ISysUserCustomerAuthorizationService
+{
+    /**
+     * 查询经销商用户授权
+     *
+     * @param customerCode 经销商用户授权ID
+     * @return 经销商用户授权
+     */
+    public SysUserCustomerAuthorization selectSysUserCustomerAuthorizationById(String customerCode);
+
+    /**
+     * 查询经销商用户授权列表
+     *
+     * @param sysUserCustomerAuthorization 经销商用户授权
+     * @return 经销商用户授权集合
+     */
+    public List<SysUserCustomerAuthorization> selectSysUserCustomerAuthorizationList(SysUserCustomerAuthorization sysUserCustomerAuthorization);
+
+    /**
+     * 新增经销商用户授权
+     *
+     * @param sysUserCustomerAuthorization 经销商用户授权
+     * @return 结果
+     */
+    public int insertSysUserCustomerAuthorization(SysUserCustomerAuthorization sysUserCustomerAuthorization);
+
+    /**
+     * 修改经销商用户授权
+     *
+     * @param sysUserCustomerAuthorization 经销商用户授权
+     * @return 结果
+     */
+    public int updateSysUserCustomerAuthorization(SysUserCustomerAuthorization sysUserCustomerAuthorization);
+
+    /**
+     * 批量删除经销商用户授权
+     *
+     * @param ids 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteSysUserCustomerAuthorizationByIds(String ids);
+
+    /**
+     * 删除经销商用户授权信息
+     *
+     * @param customerCode 经销商用户授权ID
+     * @return 结果
+     */
+    public int deleteSysUserCustomerAuthorizationById(String customerCode);
+
+
+    /**
+     * @description: 查询根据经销商用户查询授权
+     * @param: [customerCode, userId]
+     * @return: com.dgtly.system.domain.SysUserCustomerAuthorization
+     * @author: njs
+     * @date: 2024/5/24 14:15
+     */
+    public SysUserCustomerAuthorization selectAuthorizationByUserIdAndCustomerCode( String customerCode, String userId);
+
+
+    /**
+     * @description: 根据经销商编号和用户id修改授权标记
+     * @param: [sysUserCustomerAuthorization]
+     * @return: int
+     * @author: njs
+     * @date: 2024/5/24 13:58
+     */
+    public int  updateAuthorizationByCustomerCodeAndUserId(SysUserCustomerAuthorization sysUserCustomerAuthorization);
+
+}

+ 124 - 0
suishenbang-system/src/main/java/com/dgtly/system/service/impl/SysUserCustomerAuthorizationServiceImpl.java

@@ -0,0 +1,124 @@
+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.SysUserCustomerAuthorizationMapper;
+import com.dgtly.system.domain.SysUserCustomerAuthorization;
+import com.dgtly.system.service.ISysUserCustomerAuthorizationService;
+import com.dgtly.common.core.text.Convert;
+
+/**
+ * 经销商用户授权Service业务层处理
+ *
+ * @author njs
+ * @date 2024-05-24
+ */
+@Service
+public class SysUserCustomerAuthorizationServiceImpl implements ISysUserCustomerAuthorizationService
+{
+    @Autowired
+    private SysUserCustomerAuthorizationMapper sysUserCustomerAuthorizationMapper;
+
+    /**
+     * 查询经销商用户授权
+     *
+     * @param customerCode 经销商用户授权ID
+     * @return 经销商用户授权
+     */
+    @Override
+    public SysUserCustomerAuthorization selectSysUserCustomerAuthorizationById(String customerCode)
+    {
+        return sysUserCustomerAuthorizationMapper.selectSysUserCustomerAuthorizationById(customerCode);
+    }
+
+    /**
+     * 查询经销商用户授权列表
+     *
+     * @param sysUserCustomerAuthorization 经销商用户授权
+     * @return 经销商用户授权
+     */
+    @Override
+    public List<SysUserCustomerAuthorization> selectSysUserCustomerAuthorizationList(SysUserCustomerAuthorization sysUserCustomerAuthorization)
+    {
+        return sysUserCustomerAuthorizationMapper.selectSysUserCustomerAuthorizationList(sysUserCustomerAuthorization);
+    }
+
+    /**
+     * 新增经销商用户授权
+     *
+     * @param sysUserCustomerAuthorization 经销商用户授权
+     * @return 结果
+     */
+    @Override
+    public int insertSysUserCustomerAuthorization(SysUserCustomerAuthorization sysUserCustomerAuthorization)
+    {
+        sysUserCustomerAuthorization.setCreateTime(DateUtils.getNowDate());
+        return sysUserCustomerAuthorizationMapper.insertSysUserCustomerAuthorization(sysUserCustomerAuthorization);
+    }
+
+    /**
+     * 修改经销商用户授权
+     *
+     * @param sysUserCustomerAuthorization 经销商用户授权
+     * @return 结果
+     */
+    @Override
+    public int updateSysUserCustomerAuthorization(SysUserCustomerAuthorization sysUserCustomerAuthorization)
+    {
+        sysUserCustomerAuthorization.setUpdateTime(DateUtils.getNowDate());
+        return sysUserCustomerAuthorizationMapper.updateSysUserCustomerAuthorization(sysUserCustomerAuthorization);
+    }
+
+    /**
+     * 删除经销商用户授权对象
+     *
+     * @param ids 需要删除的数据ID
+     * @return 结果
+     */
+    @Override
+    public int deleteSysUserCustomerAuthorizationByIds(String ids)
+    {
+        return sysUserCustomerAuthorizationMapper.deleteSysUserCustomerAuthorizationByIds(Convert.toStrArray(ids));
+    }
+
+    /**
+     * 删除经销商用户授权信息
+     *
+     * @param customerCode 经销商用户授权ID
+     * @return 结果
+     */
+    @Override
+    public int deleteSysUserCustomerAuthorizationById(String customerCode)
+    {
+        return sysUserCustomerAuthorizationMapper.deleteSysUserCustomerAuthorizationById(customerCode);
+    }
+
+    /**
+     * @param customerCode
+     * @param userId
+     * @description: 查询根据经销商用户查询授权
+     * @param: [customerCode, userId]
+     * @return: com.dgtly.system.domain.SysUserCustomerAuthorization
+     * @author: njs
+     * @date: 2024/5/24 14:15
+     */
+    @Override
+    public SysUserCustomerAuthorization selectAuthorizationByUserIdAndCustomerCode(String customerCode, String userId) {
+        return sysUserCustomerAuthorizationMapper.selectAuthorizationByUserIdAndCustomerCode(customerCode, userId);
+    }
+
+    /**
+     * @param sysUserCustomerAuthorization
+     * @description: 根据经销商编号和用户id修改授权标记
+     * @param: [sysUserCustomerAuthorization]
+     * @return: int
+     * @author: njs
+     * @date: 2024/5/24 13:58
+     */
+    @Override
+    public int updateAuthorizationByCustomerCodeAndUserId(SysUserCustomerAuthorization sysUserCustomerAuthorization) {
+        return sysUserCustomerAuthorizationMapper.updateAuthorizationByCustomerCodeAndUserId(sysUserCustomerAuthorization);
+    }
+}

+ 116 - 0
suishenbang-system/src/main/resources/mapper/system/SysUserCustomerAuthorizationMapper.xml

@@ -0,0 +1,116 @@
+<?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.SysUserCustomerAuthorizationMapper">
+
+    <resultMap type="SysUserCustomerAuthorization" id="SysUserCustomerAuthorizationResult">
+        <result property="customerCode"    column="customer_code"    />
+        <result property="userId"    column="user_id"    />
+        <result property="isConsignee"    column="is_consignee"    />
+        <result property="isIndependently"    column="is_independently"    />
+        <result property="isSelfDelivery"    column="is_self_delivery"    />
+        <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"    />
+    </resultMap>
+
+    <sql id="selectSysUserCustomerAuthorizationVo">
+        select customer_code, user_id, is_consignee, is_independently, is_self_delivery, create_by, create_time, update_by, update_time, is_delete from sys_user_customer_authorization
+    </sql>
+
+    <select id="selectSysUserCustomerAuthorizationList" parameterType="SysUserCustomerAuthorization" resultMap="SysUserCustomerAuthorizationResult">
+        <include refid="selectSysUserCustomerAuthorizationVo"/>
+        <where>
+            <if test="customerCode != null  and customerCode != ''"> and customer_code = #{customerCode}</if>
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="isConsignee != null  and isConsignee != ''"> and is_consignee = #{isConsignee}</if>
+            <if test="isIndependently != null  and isIndependently != ''"> and is_independently = #{isIndependently}</if>
+            <if test="isSelfDelivery != null  and isSelfDelivery != ''"> and is_self_delivery = #{isSelfDelivery}</if>
+            <if test="isDelete != null "> and is_delete = #{isDelete}</if>
+        </where>
+    </select>
+
+    <select id="selectSysUserCustomerAuthorizationById" parameterType="String" resultMap="SysUserCustomerAuthorizationResult">
+        <include refid="selectSysUserCustomerAuthorizationVo"/>
+        where customer_code = #{customerCode}
+    </select>
+
+    <insert id="insertSysUserCustomerAuthorization" parameterType="SysUserCustomerAuthorization">
+        insert into sys_user_customer_authorization
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="customerCode != null  and customerCode != ''">customer_code,</if>
+            <if test="userId != null ">user_id,</if>
+            <if test="isConsignee != null  and isConsignee != ''">is_consignee,</if>
+            <if test="isIndependently != null  and isIndependently != ''">is_independently,</if>
+            <if test="isSelfDelivery != null  and isSelfDelivery != ''">is_self_delivery,</if>
+            <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>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="customerCode != null  and customerCode != ''">#{customerCode},</if>
+            <if test="userId != null ">#{userId},</if>
+            <if test="isConsignee != null  and isConsignee != ''">#{isConsignee},</if>
+            <if test="isIndependently != null  and isIndependently != ''">#{isIndependently},</if>
+            <if test="isSelfDelivery != null  and isSelfDelivery != ''">#{isSelfDelivery},</if>
+            <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>
+         </trim>
+    </insert>
+
+    <update id="updateSysUserCustomerAuthorization" parameterType="SysUserCustomerAuthorization">
+        update sys_user_customer_authorization
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userId != null ">user_id = #{userId},</if>
+            <if test="isConsignee != null  and isConsignee != ''">is_consignee = #{isConsignee},</if>
+            <if test="isIndependently != null  and isIndependently != ''">is_independently = #{isIndependently},</if>
+            <if test="isSelfDelivery != null  and isSelfDelivery != ''">is_self_delivery = #{isSelfDelivery},</if>
+            <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>
+        </trim>
+        where customer_code = #{customerCode}
+    </update>
+
+    <delete id="deleteSysUserCustomerAuthorizationById" parameterType="String">
+        delete from sys_user_customer_authorization where customer_code = #{customerCode}
+    </delete>
+
+    <delete id="deleteSysUserCustomerAuthorizationByIds" parameterType="String">
+        delete from sys_user_customer_authorization where customer_code in
+        <foreach item="customerCode" collection="array" open="(" separator="," close=")">
+            #{customerCode}
+        </foreach>
+    </delete>
+
+    <update id="updateAuthorizationByCustomerCodeAndUserId" parameterType="SysUserCustomerAuthorization">
+        update sys_user_customer_authorization
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="isConsignee != null  and isConsignee != ''">is_consignee = #{isConsignee},</if>
+            <if test="isIndependently != null  and isIndependently != ''">is_independently = #{isIndependently},</if>
+            <if test="isSelfDelivery != null  and isSelfDelivery != ''">is_self_delivery = #{isSelfDelivery},</if>
+            <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>
+        </trim>
+        where customer_code = #{customerCode} and user_id = #{userId}
+    </update>
+
+    <select id="selectAuthorizationByUserIdAndCustomerCode" parameterType="String" resultMap="SysUserCustomerAuthorizationResult">
+        <include refid="selectSysUserCustomerAuthorizationVo"/>
+        where customer_code = #{customerCode} and user_id = #{userId}
+    </select>
+
+</mapper>

+ 43 - 14
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/WxPortalController.java

@@ -57,7 +57,8 @@ public class WxPortalController extends ApiBaseController {
     private ISysRidingLanternService sysRidingLanternService;
     @Autowired
     private ISysUserOrderAuthorService sysUserOrderAuthorService;
-
+    @Autowired
+    private ISysUserCustomerAuthorizationService authorizationService;
 
     @ApiOperation(value = "微信门户首页",notes = "参数:{userId:1}")
     @ApiImplicitParams({
@@ -274,10 +275,19 @@ public class WxPortalController extends ApiBaseController {
         obj.checkParameterNotNull("userId,IsConsignee");
         String userId = obj.getString("userId");
         String IsConsignee = obj.getString("IsConsignee");
-        SysUser user = new SysUser();
-        user.setUserId(Long.parseLong(userId));
-        user.setIsConsignee(IsConsignee);
-        int i = userService.updateUserInfo(user);
+        String customerCode = obj.getString("customerCode");
+        int i=0;
+        SysUserCustomerAuthorization authorization = authorizationService.selectAuthorizationByUserIdAndCustomerCode(customerCode,userId);
+        if(authorization !=null){
+            authorization.setIsConsignee(IsConsignee);
+            i= authorizationService.updateAuthorizationByCustomerCodeAndUserId(authorization);
+        }else{
+            SysUserCustomerAuthorization author = new SysUserCustomerAuthorization();
+            author.setUserId(Long.valueOf(userId));
+            author.setCustomerCode(customerCode);
+            author.setIsConsignee(IsConsignee);
+            i =authorizationService.insertSysUserCustomerAuthorization(author);
+        }
         if (i>0){
             return AjaxResult.success();
         }else {
@@ -294,13 +304,22 @@ public class WxPortalController extends ApiBaseController {
     @PostMapping("updateUserByIsIndependently")
     public Object updateUserByIsIndependently() {
         ParameterObject obj = getParameterObject();
-        obj.checkParameterNotNull("userId,isIndependently");
+        obj.checkParameterNotNull("userId,isIndependently,customerCode");
         String userId = obj.getString("userId");
         String IsIndependently = obj.getString("isIndependently");
-        SysUser user = new SysUser();
-        user.setUserId(Long.parseLong(userId));
-        user.setIsIndependently(IsIndependently);
-        int i = userService.updateUserInfo(user);
+        String customerCode = obj.getString("customerCode");
+        int i=0;
+        SysUserCustomerAuthorization authorization = authorizationService.selectAuthorizationByUserIdAndCustomerCode(customerCode,userId);
+        if(authorization !=null){
+            authorization.setIsIndependently(IsIndependently);
+             i= authorizationService.updateAuthorizationByCustomerCodeAndUserId(authorization);
+        }else{
+            SysUserCustomerAuthorization author = new SysUserCustomerAuthorization();
+            author.setUserId(Long.valueOf(userId));
+            author.setCustomerCode(customerCode);
+            author.setIsIndependently(IsIndependently);
+             i =authorizationService.insertSysUserCustomerAuthorization(author);
+        }
         if (i>0){
             return AjaxResult.success();
         }else {
@@ -321,10 +340,20 @@ public class WxPortalController extends ApiBaseController {
         obj.checkParameterNotNull("userId,isSelfDelivery");
         String userId = obj.getString("userId");
         String IsSelfDelivery = obj.getString("isSelfDelivery");
-        SysUser user = new SysUser();
-        user.setUserId(Long.parseLong(userId));
-        user.setIsSelfDelivery(IsSelfDelivery);
-        int i = userService.updateUserInfo(user);
+        String customerCode = obj.getString("customerCode");
+        int i=0;
+        SysUserCustomerAuthorization authorization = authorizationService.selectAuthorizationByUserIdAndCustomerCode(customerCode,userId);
+        if(authorization !=null){
+            authorization.setIsSelfDelivery(IsSelfDelivery);
+            i= authorizationService.updateAuthorizationByCustomerCodeAndUserId(authorization);
+        }else{
+            SysUserCustomerAuthorization author = new SysUserCustomerAuthorization();
+            author.setUserId(Long.valueOf(userId));
+            author.setCustomerCode(customerCode);
+            author.setIsSelfDelivery(IsSelfDelivery);
+            i =authorizationService.insertSysUserCustomerAuthorization(author);
+        }
+
         if (i>0){
             return AjaxResult.success();
         }else {