Pārlūkot izejas kodu

update:金牛商城套餐限制仅销售分享下单

ct 4 dienas atpakaļ
vecāks
revīzija
a34824b16a

+ 39 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsUserCompanyPackageScrm.java

@@ -0,0 +1,39 @@
+package com.fs.hisStore.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 销售套餐用户绑定对象 fs_user_company_package_scrm
+ *
+ * @author fs
+ * @date 2025-12-04
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class FsUserCompanyPackageScrm extends BaseEntity{
+
+    @TableId
+    private Long id;
+
+    /** 销售公司id */
+    @Excel(name = "销售公司id")
+    private Long companyId;
+
+    /** 销售id */
+    @Excel(name = "销售id")
+    private Long companyUserId;
+
+    /** 套餐id */
+    @Excel(name = "套餐id")
+    private Long packageId;
+
+    /** 用户id */
+    @Excel(name = "用户id")
+    private Long userId;
+
+
+}

+ 61 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsUserCompanyPackageScrmMapper.java

@@ -0,0 +1,61 @@
+package com.fs.hisStore.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.hisStore.domain.FsUserCompanyPackageScrm;
+
+/**
+ * 销售套餐用户绑定Mapper接口
+ * 
+ * @author fs
+ * @date 2025-12-04
+ */
+public interface FsUserCompanyPackageScrmMapper extends BaseMapper<FsUserCompanyPackageScrm>{
+    /**
+     * 查询销售套餐用户绑定
+     * 
+     * @param id 销售套餐用户绑定主键
+     * @return 销售套餐用户绑定
+     */
+    FsUserCompanyPackageScrm selectFsUserCompanyPackageScrmById(Long id);
+
+    /**
+     * 查询销售套餐用户绑定列表
+     * 
+     * @param fsUserCompanyPackageScrm 销售套餐用户绑定
+     * @return 销售套餐用户绑定集合
+     */
+    List<FsUserCompanyPackageScrm> selectFsUserCompanyPackageScrmList(FsUserCompanyPackageScrm fsUserCompanyPackageScrm);
+
+    /**
+     * 新增销售套餐用户绑定
+     * 
+     * @param fsUserCompanyPackageScrm 销售套餐用户绑定
+     * @return 结果
+     */
+    int insertFsUserCompanyPackageScrm(FsUserCompanyPackageScrm fsUserCompanyPackageScrm);
+
+    /**
+     * 修改销售套餐用户绑定
+     * 
+     * @param fsUserCompanyPackageScrm 销售套餐用户绑定
+     * @return 结果
+     */
+    int updateFsUserCompanyPackageScrm(FsUserCompanyPackageScrm fsUserCompanyPackageScrm);
+
+    /**
+     * 删除销售套餐用户绑定
+     * 
+     * @param id 销售套餐用户绑定主键
+     * @return 结果
+     */
+    int deleteFsUserCompanyPackageScrmById(Long id);
+
+    /**
+     * 批量删除销售套餐用户绑定
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteFsUserCompanyPackageScrmByIds(Long[] ids);
+}

+ 21 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsUsePackageScrmSendParam.java

@@ -0,0 +1,21 @@
+package com.fs.hisStore.param;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class FsUsePackageScrmSendParam {
+
+    /** 优惠劵id */
+    @Excel(name = "套餐id")
+    private Long packageId;
+
+    @Excel(name = "会员ID")
+    private Long userId;
+
+    //发送销售id
+    private Long companyUserId;
+
+    //发送销售公司id
+    private Long companyId;
+}

+ 5 - 1
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreProductPackageScrmService.java

@@ -1,8 +1,11 @@
 package com.fs.hisStore.service;
 
 import java.util.List;
+
+import com.fs.common.core.domain.R;
 import com.fs.hisStore.domain.FsStoreProductPackageScrm;
 import com.fs.hisStore.param.FsStoreProductPackageQueryParam;
+import com.fs.hisStore.param.FsUsePackageScrmSendParam;
 import com.fs.hisStore.vo.FsStoreProductPacketVO;
 
 /**
@@ -68,9 +71,10 @@ public interface IFsStoreProductPackageScrmService
     /**
      * 批量修改商品组合套餐
      *
-     * @param packageIds 需要修改的数据ID
+     * @param orderIds 需要修改的数据ID
      * @return 结果
      */
     public int updateFsStoreProductPackages(Long[] orderIds,Long status,Long companyId);
 
+    R sendPackage(FsUsePackageScrmSendParam param);
 }

+ 12 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -390,6 +390,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     private IFsUserIntegralLogsService userIntegralLogsService;
     @Autowired
     private FsStoreProductPackageScrmMapper fsStoreProductPackageMapper;
+    @Autowired
+    private FsUserCompanyPackageScrmMapper fsUserCompanyPackageScrmMapper;
 
     @PostConstruct
     public void initErpServiceMap() {
@@ -1606,6 +1608,16 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             if (storeProductPackage.getStatus().equals(0)) {
                 return R.error("此套餐已下架");
             }
+            //只允许销售分享下单
+            if (CloudHostUtils.hasCloudHostName("康年堂")){
+                FsUserCompanyPackageScrm fsUserCompanyPackageScrm = new FsUserCompanyPackageScrm();
+                fsUserCompanyPackageScrm.setUserId(uid);
+                fsUserCompanyPackageScrm.setPackageId(param.getPackageId());
+                List<FsUserCompanyPackageScrm> fsUserCompanyPackageList = fsUserCompanyPackageScrmMapper.selectFsUserCompanyPackageScrmList(fsUserCompanyPackageScrm);
+                if (fsUserCompanyPackageList == null || fsUserCompanyPackageList.isEmpty()) {
+                    return R.error("商品链接无效");
+                }
+            }
             //限购处理
             if (storeProductPackage.getLimitCount() != null && storeProductPackage.getLimitCount() > 0) {
                 //查看是否已购买

+ 32 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductPackageScrmServiceImpl.java

@@ -1,17 +1,24 @@
 package com.fs.hisStore.service.impl;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
+import com.fs.common.core.domain.R;
+import com.fs.company.domain.CompanyUser;
+import com.fs.company.mapper.CompanyUserMapper;
 import com.fs.hisStore.domain.FsStoreProductScrm;
 import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
+import com.fs.hisStore.domain.FsUserCompanyPackageScrm;
 import com.fs.hisStore.dto.StoreOrderProductDTO;
 import com.fs.hisStore.dto.StorePackageProductDTO;
 import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
 import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
+import com.fs.hisStore.mapper.FsUserCompanyPackageScrmMapper;
 import com.fs.hisStore.param.FsStoreProductPackageQueryParam;
+import com.fs.hisStore.param.FsUsePackageScrmSendParam;
 import com.fs.hisStore.vo.FsStoreProductPacketVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -34,6 +41,10 @@ public class FsStoreProductPackageScrmServiceImpl implements IFsStoreProductPack
     private FsStoreProductAttrValueScrmMapper fsStoreProductAttrValueMapper;
     @Autowired
     private FsStoreProductScrmMapper fsStoreProductMapper;
+    @Autowired
+    private CompanyUserMapper companyUserMapper;
+    @Autowired
+    private FsUserCompanyPackageScrmMapper fsUserCompanyPackageScrmMapper;
     /**
      * 查询商品组合套餐
      *
@@ -152,4 +163,25 @@ public class FsStoreProductPackageScrmServiceImpl implements IFsStoreProductPack
         return fsStoreProductPackageMapper.updateFsStoreProductPackages(orderIds,status,companyId);
     }
 
+    @Override
+    public R sendPackage(FsUsePackageScrmSendParam param) {
+        Long companyUserId = param.getCompanyUserId();
+        CompanyUser companyUser = companyUserMapper.selectCompanyUserById(companyUserId);
+        if (companyUser.getCompanyId()==null){
+            return R.error("销售信息错误");
+        }
+        FsUserCompanyPackageScrm fsUserCompanyPackageScrm = new FsUserCompanyPackageScrm();
+        fsUserCompanyPackageScrm.setCompanyId(companyUser.getCompanyId());
+        fsUserCompanyPackageScrm.setCompanyUserId(param.getCompanyUserId());
+        fsUserCompanyPackageScrm.setUserId(param.getUserId());
+        fsUserCompanyPackageScrm.setPackageId(param.getPackageId());
+        List<FsUserCompanyPackageScrm> fsUserCompanyPackageScrms = fsUserCompanyPackageScrmMapper.selectFsUserCompanyPackageScrmList(fsUserCompanyPackageScrm);
+        if (fsUserCompanyPackageScrms == null || fsUserCompanyPackageScrms.isEmpty()){
+            fsUserCompanyPackageScrm.setCreateTime(new Date());
+            fsUserCompanyPackageScrmMapper.insertFsUserCompanyPackageScrm(fsUserCompanyPackageScrm);
+        }
+        return R.ok();
+
+    }
+
 }

+ 79 - 0
fs-service/src/main/resources/mapper/hisStore/FsUserCompanyPackageScrmMapper.xml

@@ -0,0 +1,79 @@
+<?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.fs.hisStore.mapper.FsUserCompanyPackageScrmMapper">
+    
+    <resultMap type="FsUserCompanyPackageScrm" id="FsUserCompanyPackageScrmResult">
+        <result property="id"    column="id"    />
+        <result property="companyId"    column="company_id"    />
+        <result property="companyUserId"    column="company_user_id"    />
+        <result property="packageId"    column="package_id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+    <sql id="selectFsUserCompanyPackageScrmVo">
+        select id, company_id, company_user_id, package_id, user_id, create_time, update_time from fs_user_company_package_scrm
+    </sql>
+
+    <select id="selectFsUserCompanyPackageScrmList" parameterType="FsUserCompanyPackageScrm" resultMap="FsUserCompanyPackageScrmResult">
+        <include refid="selectFsUserCompanyPackageScrmVo"/>
+        <where>  
+            <if test="companyId != null "> and company_id = #{companyId}</if>
+            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
+            <if test="packageId != null "> and package_id = #{packageId}</if>
+            <if test="userId != null "> and user_id = #{userId}</if>
+        </where>
+    </select>
+    
+    <select id="selectFsUserCompanyPackageScrmById" parameterType="Long" resultMap="FsUserCompanyPackageScrmResult">
+        <include refid="selectFsUserCompanyPackageScrmVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertFsUserCompanyPackageScrm" parameterType="FsUserCompanyPackageScrm" useGeneratedKeys="true" keyProperty="id">
+        insert into fs_user_company_package_scrm
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="companyId != null">company_id,</if>
+            <if test="companyUserId != null">company_user_id,</if>
+            <if test="packageId != null">package_id,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="companyId != null">#{companyId},</if>
+            <if test="companyUserId != null">#{companyUserId},</if>
+            <if test="packageId != null">#{packageId},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateFsUserCompanyPackageScrm" parameterType="FsUserCompanyPackageScrm">
+        update fs_user_company_package_scrm
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="companyId != null">company_id = #{companyId},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
+            <if test="packageId != null">package_id = #{packageId},</if>
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteFsUserCompanyPackageScrmById" parameterType="Long">
+        delete from fs_user_company_package_scrm where id = #{id}
+    </delete>
+
+    <delete id="deleteFsUserCompanyPackageScrmByIds" parameterType="String">
+        delete from fs_user_company_package_scrm where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 23 - 4
fs-user-app/src/main/java/com/fs/app/controller/store/StoreProductPackageScrmController.java

@@ -12,6 +12,7 @@ import com.fs.hisStore.domain.FsStoreProductScrm;
 import com.fs.hisStore.dto.StoreOrderProductDTO;
 import com.fs.hisStore.dto.StorePackageProductDTO;
 import com.fs.hisStore.param.FsStoreProductPackageQueryParam;
+import com.fs.hisStore.param.FsUsePackageScrmSendParam;
 import com.fs.hisStore.service.IFsStoreProductAttrValueScrmService;
 import com.fs.hisStore.service.IFsStoreProductPackageScrmService;
 import com.fs.hisStore.service.IFsStoreProductScrmService;
@@ -21,10 +22,7 @@ import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
@@ -83,4 +81,25 @@ public class StoreProductPackageScrmController extends AppBaseController {
         return R.ok().put("data",storeProductPackage);
     }
 
+    /**
+     * 销售分享套餐
+     */
+    @Login
+    @ApiOperation("销售分享套餐")
+    @PostMapping("/sendPackage")
+    public R sendPackage(@RequestBody FsUsePackageScrmSendParam param)
+    {
+        Long companyUserId = getCompanyUserId();
+        if(companyUserId==null){
+            return R.error("销售未登录!");
+        }
+        Long userId = param.getUserId();
+        if (userId == null) {
+            return R.error("未选择分享用户!");
+        }
+        param.setCompanyUserId(companyUserId);
+        return productPackageService.sendPackage(param);
+    }
+
+
 }