Browse Source

行情\行情产品配置审核

刘浩男 1 year ago
parent
commit
f8510f0e1c

+ 2 - 6
ruoyi-admin/src/main/java/com/ruoyi/web/controller/quotations/JnbQuotationsConfigController.java

@@ -77,12 +77,8 @@ public class JnbQuotationsConfigController extends BaseController {
     @Log(title = "行情产品配置", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody JnbQuotationsConfig jnbQuotationsConfig) {
-        int i =jnbQuotationsConfigService.updateJnbQuotationsConfig(jnbQuotationsConfig);
-        if (i > 0){
-            return toAjax(i);
-        }else {
-            return AjaxResult.error("同级已存在相同名称产品");
-        }
+        return AjaxResult.success(jnbQuotationsConfigService.updateJnbQuotationsConfig(jnbQuotationsConfig));
+
     }
 
     /**

+ 14 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/quotations/JnbQuotationsController.java

@@ -54,7 +54,7 @@ public class JnbQuotationsController extends BaseController
      * 新增行情
      */
 //    @PreAuthorize("@ss.hasPermi('jnb:quotations:add')")
-    @Log(title = "行情", businessType = BusinessType.INSERT)
+    @Log(title = "新增行情", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody JnbQuotations jnbQuotations)
     {
@@ -70,7 +70,7 @@ public class JnbQuotationsController extends BaseController
      * 修改行情
      */
 //    @PreAuthorize("@ss.hasPermi('jnb:quotations:edit')")
-    @Log(title = "行情", businessType = BusinessType.UPDATE)
+    @Log(title = "修改行情", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody JnbQuotations jnbQuotations)
     {
@@ -82,10 +82,21 @@ public class JnbQuotationsController extends BaseController
      * 删除行情
      */
 //    @PreAuthorize("@ss.hasPermi('jnb:quotations:remove')")
-    @Log(title = "行情", businessType = BusinessType.DELETE)
+    @Log(title = "删除行情", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable("ids") Long[] ids)
     {
         return toAjax(jnbQuotationsService.deleteJnbQuotationsByIds(ids));
     }
+
+    /**
+     * 审核
+     */
+//    @PreAuthorize("@ss.hasPermi('jnb:quotations:remove')")
+    @Log(title = "审核", businessType = BusinessType.DELETE)
+    @PostMapping("/status")
+    public AjaxResult remove(@RequestBody JnbQuotations jnbQuotations)
+    {
+        return toAjax(jnbQuotationsService.updateByStatusAndId(jnbQuotations));
+    }
 }

+ 8 - 1
sooka-jnb/src/main/java/com/sooka/jnb/quotations/domain/JnbQuotations.java

@@ -1,12 +1,12 @@
 package com.sooka.jnb.quotations.domain;
 
-import com.baomidou.mybatisplus.annotation.TableField;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 import lombok.Data;
 
 import javax.validation.constraints.NotBlank;
 import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * 行情对象 jnb_quotations
@@ -55,6 +55,13 @@ public class JnbQuotations extends BaseEntity
     /** 删除状态 */
     private String delFlag;
 
+    /** 图片 */
     private String url;
 
+    /** 图片数组 */
+    private List<String> urlArray;
+
+    /** 审核状态 */
+    private String status;
+
 }

+ 5 - 0
sooka-jnb/src/main/java/com/sooka/jnb/quotations/mapper/JnbQuotationsMapper.java

@@ -58,4 +58,9 @@ public interface JnbQuotationsMapper
      * @return 结果
      */
     public int deleteJnbQuotationsByIds(Long[] ids);
+
+    /**
+     * 修改审核状态
+     */
+    public int updateByStatusAndId(JnbQuotations jnbQuotations);
 }

+ 1 - 0
sooka-jnb/src/main/java/com/sooka/jnb/quotations/service/IJnbQuotationsService.java

@@ -52,4 +52,5 @@ public interface IJnbQuotationsService
      */
     public int deleteJnbQuotationsByIds(Long[] ids);
 
+   public int updateByStatusAndId(JnbQuotations jnbQuotations);
 }

+ 1 - 5
sooka-jnb/src/main/java/com/sooka/jnb/quotations/service/impl/JnbQuotationsConfigServiceImpl.java

@@ -172,10 +172,6 @@ public class JnbQuotationsConfigServiceImpl implements IJnbQuotationsConfigServi
      */
     @Override
     public int updateJnbQuotationsConfig(JnbQuotationsConfig jnbQuotationsConfig) {
-        int i = jnbQuotationsConfigMapper.selectCount(jnbQuotationsConfig);
-        if (i > 0) {
-            return -1;
-        }
         jnbQuotationsConfig.setUpdateBy(SecurityUtils.getUsername());
         jnbQuotationsConfig.setUpdateTime(DateUtils.getNowDate());
         return jnbQuotationsConfigMapper.updateJnbQuotationsConfig(jnbQuotationsConfig);
@@ -185,7 +181,7 @@ public class JnbQuotationsConfigServiceImpl implements IJnbQuotationsConfigServi
     /**
      * 批量删除行情产品配置
      *
-     * @param ids 需要删除的行情产品配置主键
+     * @param id 需要删除的行情产品配置主键
      * @return 结果
      */
     @Override

+ 47 - 5
sooka-jnb/src/main/java/com/sooka/jnb/quotations/service/impl/JnbQuotationsServiceImpl.java

@@ -2,20 +2,22 @@ package com.sooka.jnb.quotations.service.impl;
 
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
-import com.sooka.jnb.highServer.domain.JnbHighServerImg;
 import com.sooka.jnb.highServer.mapper.JnbHighServerImgMapper;
+import com.sooka.jnb.my.domain.Announcement;
+import com.sooka.jnb.my.service.IAnnouncementService;
 import com.sooka.jnb.quotations.domain.JnbQuotations;
 import com.sooka.jnb.quotations.mapper.JnbQuotationsMapper;
 import com.sooka.jnb.quotations.service.IJnbQuotationsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.ObjectUtils;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
+import java.time.LocalDateTime;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 
 
 /**
@@ -31,7 +33,8 @@ public class JnbQuotationsServiceImpl implements IJnbQuotationsService {
     private JnbQuotationsMapper jnbQuotationsMapper;
 
     @Resource
-    private JnbHighServerImgMapper jnbHighServerImgMapper;
+    private IAnnouncementService announcementService;
+
 
     /**
      * 查询行情
@@ -53,7 +56,15 @@ public class JnbQuotationsServiceImpl implements IJnbQuotationsService {
      */
     @Override
     public List<JnbQuotations> selectJnbQuotationsList(JnbQuotations jnbQuotations) {
-        return jnbQuotationsMapper.selectJnbQuotationsList(jnbQuotations);
+        List<JnbQuotations> list = jnbQuotationsMapper.selectJnbQuotationsList(jnbQuotations);
+        for (JnbQuotations quotations : list) {
+            //如果url不为空,则将url转换为List,并且储存在list中返回
+            if (!Objects.isNull(quotations.getUrl())) {
+                List<String> list1 = Arrays.asList(quotations.getUrl().split(","));
+                jnbQuotations.setUrlArray(list1);
+            }
+        }
+        return list;
     }
 
     /**
@@ -100,4 +111,35 @@ public class JnbQuotationsServiceImpl implements IJnbQuotationsService {
         return i;
     }
 
+    /**
+     * 修改审核状态
+     */
+    @Override
+    public int updateByStatusAndId(JnbQuotations jnbQuotations) {
+        int i = jnbQuotationsMapper.updateByStatusAndId(jnbQuotations);
+        if (i>0) {
+            announcementService.insertAnnouncement(fromate(jnbQuotations.getStatus(), jnbQuotations.getProductName(), jnbQuotations.getCreateBy()));
+        }
+        return i;
+
+    }
+
+    public Announcement fromate(String status,String title,String id) {
+        Announcement announcement = new Announcement();
+        if (Objects.equals(status, "1")) {
+            announcement.setAnnouncementTitle("审核通过:" + title);
+            announcement.setAnnouncementBody("您在" + LocalDateTime.now() + "发起的行情信息已审核通过,请查看");
+            announcement.setValidityStartTime(new Date());
+            announcement.setUserId(id);
+            announcement.setCreateBy(SecurityUtils.getUserId().toString());
+            return announcement;
+        } else {
+            announcement.setAnnouncementTitle("审核拒绝:" + title);
+            announcement.setAnnouncementBody("您在" + new Date() + "发起的行情信息已审核被拒绝,请查看");
+            announcement.setValidityStartTime(new Date());
+            announcement.setUserId(String.valueOf(id));
+            announcement.setCreateBy(SecurityUtils.getUserId().toString());
+            return announcement;
+        }
+    }
 }

+ 62 - 11
sooka-jnb/src/main/resources/mapper/quotations/JnbQuotationsMapper.xml

@@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="type"    column="type"    />
         <result property="price"    column="price"    />
         <result property="phone"    column="phone"    />
+        <result property="status"    column="status"    />
         <result property="address"    column="address"    />
         <result property="createBy"    column="create_by"    />
         <result property="createTime"    column="create_time"    />
@@ -19,16 +20,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectJnbQuotationsVo">
-        select id, product_name, area, type, price, phone, address,url, create_by, create_time, del_flag from jnb_quotations
+        select a.id as id,
+               a.product_name as product_name,
+               a.area as area,
+               a.type as type,
+               a.price as price,
+               a.phone as phone,
+               a.address as address,
+               a.url as url,
+               a.create_by as create_by,
+               a.create_time as create_time,
+               a.del_flag as del_flag,
+               d.dict_label as status
+        from jnb_quotations a
+                 LEFT JOIN sys_dict_data d on d.dict_code = a.status
     </sql>
 
     <select id="selectJnbQuotationsList" parameterType="JnbQuotations" resultMap="JnbQuotationsResult">
-        <include refid="selectJnbQuotationsVo"/>
-        <where>  
-            <if test="productName != null  and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
-            <if test="area != null  and area != ''"> and area = #{area}</if>
-            <if test="type != null  and type != ''"> and type = #{type}</if>
-             and del_flag = 0
+        select a.id as id,
+        a.product_name as product_name,
+        a.area as area,
+        a.type as type,
+        a.price as price,
+        a.phone as phone,
+        a.address as address,
+        a.url as url,
+        a.create_by as create_by,
+        a.create_time as create_time,
+        a.del_flag as del_flag,
+        d.dict_label as status
+        from jnb_quotations a
+        LEFT JOIN sys_dict_data d on d.dict_value = a.status
+        <where>
+            d.dict_type = 'examine_state'
+            <if test="productName != null  and productName != ''">and a.product_name like concat('%', #{productName},
+                '%')
+            </if>
+            <if test="area != null  and area != ''">and a.area = #{area}</if>
+            <if test="type != null  and type != ''">and a.type = #{type}</if>
+            and a.del_flag = 0
         </where>
     </select>
 
@@ -40,10 +70,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectJnbQuotationsById" parameterType="Long" resultMap="JnbQuotationsResult">
-        <include refid="selectJnbQuotationsVo"/>
-        where
-        id = #{id}
-        and del_flag = 0
+        select a.id as id,
+        a.product_name as product_name,
+        a.area as area,
+        a.type as type,
+        a.price as price,
+        a.phone as phone,
+        a.address as address,
+        a.url as url,
+        a.create_by as create_by,
+        a.create_time as create_time,
+        a.del_flag as del_flag,
+        d.dict_label as status
+        from jnb_quotations a
+        LEFT JOIN sys_dict_data d on d.dict_value = a.status
+        <where>d.dict_type = 'examine_state'
+            and
+            id = #{id}
+            and del_flag = 0
+        </where>
     </select>
         
     <insert id="insertJnbQuotations" parameterType="JnbQuotations" useGeneratedKeys="true" keyProperty="id">
@@ -88,6 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="phone != null">phone = #{phone},</if>
             <if test="address != null">address = #{address},</if>
             <if test="url != null">address = #{url},</if>
+            <if test="status != null">status = #{status},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
@@ -106,4 +152,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </update>
 
+    <update id="updateByStatusAndId" parameterType="Long">
+        update jnb_quotations
+        set status = ${status}
+        where id = #{id}
+    </update>
 </mapper>