浏览代码

协销服务商合并

zhijiezhao 3 周之前
父节点
当前提交
a74194352a

+ 13 - 0
src/main/java/com/caimei365/manager/controller/caimei/providers/ProvidersApi.java

@@ -34,6 +34,14 @@ public class ProvidersApi {
     @Resource
     private CmProvidersContractService cmProvidersContractService;
 
+
+    @GetMapping("/task/products")
+    public ResponseJson<PaginationVo<Product>> productList(String name, String shopName, Integer productId,
+                                                           @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                           @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+        return cmProvidersService.productList(name, shopName, productId, pageNum, pageSize);
+    }
+
     /**
      * 编辑服务商任务
      *
@@ -70,6 +78,11 @@ public class ProvidersApi {
         return cmProvidersService.taskList(pageNum, pageSize);
     }
 
+    @GetMapping("/task/detail")
+    public ResponseJson<ProviderTask> taskDetail(Integer taskId) {
+        return cmProvidersService.taskDetail(taskId);
+    }
+
     /**
      * 任务选择服务商列表
      *

+ 4 - 0
src/main/java/com/caimei365/manager/dao/providers/CmProvidersMapper.java

@@ -129,4 +129,8 @@ public interface CmProvidersMapper {
     List<ServiceProviderModel> providerReceiveList(@Param("taskId") Integer taskId, @Param("name") String name, @Param("mobile") String mobile);
 
     void taskProviderDel(@Param("taskId") Integer taskId, @Param("serviceProviderId") Integer serviceProviderId);
+
+    ProviderTask getTaskDetail(Integer taskId);
+
+    List<Product> getTaskProducts(@Param("name") String name, @Param("shopName") String shopName, @Param("productId") Integer productId);
 }

+ 10 - 2
src/main/java/com/caimei365/manager/entity/caimei/providers/ProviderTask.java

@@ -12,13 +12,21 @@ public class ProviderTask {
 
     private Integer id;
     /**
-     * 内容库id
+     * 赏金
      */
-    private Integer archiveId;
+    private String reward;
+    /**
+     * 富文本内容
+     */
+    private String content;
     /**
      * 供应商Id
      */
     private Integer shopId;
+    /**
+     * 任务商品Id
+     */
+    private Integer productId;
     /**
      * 标题
      */

+ 4 - 0
src/main/java/com/caimei365/manager/service/caimei/providers/CmProvidersService.java

@@ -105,6 +105,10 @@ public interface CmProvidersService {
     ResponseJson<PaginationVo<ServiceProviderModel>> providerReceiveList(Integer taskId, String name, String mobile, int pageNum, int pageSize);
 
     ResponseJson taskProviderDel(Integer taskId, Integer serviceProviderId);
+
+    ResponseJson<ProviderTask> taskDetail(Integer taskId);
+
+    ResponseJson<PaginationVo<Product>> productList(String name, String shopName, Integer productId, int pageNum, int pageSize);
 }
 
 

+ 22 - 1
src/main/java/com/caimei365/manager/service/caimei/providers/impl/CmProvidersServiceImpl.java

@@ -196,7 +196,7 @@ public class CmProvidersServiceImpl implements CmProvidersService {
         log.info("【图片压缩包】,删除图片压缩包文件夹:" + ImageUtils.deleteFile(new File(tempPath)));
     }
 
-    @Transactional(rollbackFor = Exception.class)
+
     @Override
     public ResponseJson<PaginationVo<Product>> getProviderProducts(Integer providerId, String shopName, String productName, Integer productId, Integer shopId, int pageNum, int pageSize) {
         PageHelper.startPage(pageNum, pageSize);
@@ -377,6 +377,27 @@ public class CmProvidersServiceImpl implements CmProvidersService {
         return ResponseJson.success();
     }
 
+    @Override
+    public ResponseJson<ProviderTask> taskDetail(Integer taskId) {
+        return ResponseJson.success(cmProvidersMapper.getTaskDetail(taskId));
+    }
+
+    @Override
+    public ResponseJson<PaginationVo<Product>> productList(String name, String shopName, Integer productId, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<Product> products = cmProvidersMapper.getTaskProducts(name, shopName, productId);
+        products.forEach(product -> {
+            if (StringUtil.isNotBlank(product.getMainImage())) {
+                product.setMainImage(AppUtils.getImageURL("product", product.getMainImage(), 0, "wwwServer"));
+                if (!product.getMainImage().contains("https")) {
+                    product.setMainImage("https://admin.caimei365.com/" + product.getMainImage());
+                }
+            }
+        });
+        PaginationVo<Product> page = new PaginationVo<>(products);
+        return ResponseJson.success(page);
+    }
+
 }
 
 

+ 53 - 8
src/main/resources/mapper/providers/CmProvidersMapper.xml

@@ -411,8 +411,8 @@
     </insert>
 
     <insert id="addTask">
-        insert into cm_provider_task(archiveId, shopId, title, topPic, addTime, startTime, endTime)
-        values (#{archiveId}, #{shopId}, #{title}, #{topPic}, now(), #{startTime}, #{endTime});
+        insert into cm_provider_task(shopId,productId, title, topPic, reward, content, addTime, startTime, endTime)
+        values (#{shopId}, #{productId},#{title}, #{topPic}, #{reward}, #{content}, now(), #{startTime}, #{endTime});
     </insert>
 
     <insert id="assignTask">
@@ -438,16 +438,20 @@
 
     <select id="taskList" resultType="com.caimei365.manager.entity.caimei.providers.ProviderTask">
         select spt.id,
-               spt.archiveId,
                spt.shopId,
+               spt.productId,
                spt.title,
                spt.addTime,
                spt.startTime,
                spt.endTime,
-               s.name as shopName,
-               (CASE WHEN startTime > NOW() THEN '1'
-                     WHEN NOW() BETWEEN startTime AND endTime THEN '2'
-                     WHEN NOW() > endTime THEN '3' END )AS status
+               spt.reward,
+               spt.content,
+               s.name                                  as shopName,
+               spt.topPic,
+               (CASE
+                    WHEN startTime > NOW() THEN '1'
+                    WHEN NOW() BETWEEN startTime AND endTime THEN '2'
+                    WHEN NOW() > endTime THEN '3' END) AS status
         from cm_provider_task spt
         left join shop s on spt.shopId = s.shopId
         order by addTime desc
@@ -473,6 +477,45 @@
         <if test="name != null and name != ''">and sp.name like concat('%', #{name}, '%')</if>
     </select>
 
+    <select id="getTaskDetail" resultType="com.caimei365.manager.entity.caimei.providers.ProviderTask">
+        select id,
+               shopId,
+               productId,
+               title,
+               topPic,
+               content,
+               reward,
+               addTime,
+               startTime,
+               endTime
+        from cm_provider_task
+        where id = #{taskId}
+    </select>
+
+    <select id="getTaskProducts" resultType="com.caimei365.manager.entity.caimei.product.Product">
+        SELECT
+        p.productId,
+        p.name as productName,
+        p.mainImage,
+        s.shopId,
+        s.name AS shopName
+        FROM product p
+        LEFT JOIN cm_organize_product_info copi ON copi.productId = p.productId
+        LEFT JOIN shop s ON s.shopId = p.shopId
+        <where>
+            copi.organizeId = 0 AND copi.validFlag = 2
+            <if test="productId != null">
+                and p.productId = #{productId}
+            </if>
+            <if test="name != null and name != ''">
+                and p.name like concat('%', #{name},'%')
+            </if>
+            <if test="shopName != null and shopName != ''">
+                and s.name like concat('%', #{shopName},'%')
+            </if>
+        </where>
+    </select>
+
     <update id="updateCmProviders" parameterType="com.caimei365.manager.entity.caimei.providers.ServiceProviderModel">
         update serviceprovider
         <trim prefix="SET" suffixOverrides=",">
@@ -520,10 +563,12 @@
     <update id="updateTask">
         update cm_provider_task
         <trim prefix="SET" suffixOverrides=",">
-            <if test="archiveId != null and archiveId != ''">archiveId = #{archiveId},</if>
             <if test="shopId != null and shopId != ''">shopId = #{shopId},</if>
+            <if test="productId != null and productId != ''">productId = #{productId},</if>
             <if test="title != null and title != ''">title = #{title},</if>
             <if test="topPic != null and topPic != ''">topPic = #{topPic},</if>
+            <if test="reward != null and reward != ''">reward = #{reward},</if>
+            <if test="content != null and content != ''">content = #{content},</if>
             <if test="startTime != null">startTime = STR_TO_DATE(#{startTime}, '%Y-%m-%d%H:%i:%s'),</if>
             <if test="endTime != null">endTime = STR_TO_DATE(#{endTime}, '%Y-%m-%d %H:%i:%s'),</if>
         </trim>