Explorar el Código

增加积分功能

MS-QJVSRANLTYEO\Administrator hace 4 años
padre
commit
c47c594f2d

+ 1 - 1
Yijia-SaaS/yijia-integral/src/main/java/com/yijia/integral/controller/IntegralShopPicController.java

@@ -24,7 +24,7 @@ import com.yijia.common.core.page.TableDataInfo;
  * 积分商城图片信息Controller
  * 
  * @author yijia
- * @date 2021-03-11
+ * @date 2021-03-18
  */
 @RestController
 @RequestMapping("/integral/pic")

+ 19 - 0
Yijia-SaaS/yijia-integral/src/main/java/com/yijia/integral/domain/IntegralRule.java

@@ -64,11 +64,30 @@ public class IntegralRule extends BaseEntity
     @Excel(name = "积分比例")
     private String integralProportion;
 
+
     /** 积分抵扣油品规则 */
     @Excel(name = "积分抵扣油品规则")
     private String integralDeductionOil;
 
     private List<IntegralRuleDetail> itemsDetail;
+    private List<IntegralRuleDetail> notOilList;
+    private List<IntegralShopPic> imgFileList;
+
+    public List<IntegralRuleDetail> getNotOilList() {
+        return notOilList;
+    }
+
+    public void setNotOilList(List<IntegralRuleDetail> notOilList) {
+        this.notOilList = notOilList;
+    }
+
+    public List<IntegralShopPic> getImgFileList() {
+        return imgFileList;
+    }
+
+    public void setImgFileList(List<IntegralShopPic> imgFileList) {
+        this.imgFileList = imgFileList;
+    }
 
     public List<IntegralRuleDetail> getItemsDetail() {
         return itemsDetail;

+ 11 - 1
Yijia-SaaS/yijia-integral/src/main/java/com/yijia/integral/domain/IntegralRuleDetail.java

@@ -50,8 +50,18 @@ public class IntegralRuleDetail extends BaseEntity
     /** 规则类型 */
     @Excel(name = "规则类型")
     private String ruleType;
+    /** 油品类型 1.油品。2.非油品*/
+    private String oilType;
 
-    public void setId(Long id) 
+    public String getOilType() {
+        return oilType;
+    }
+
+    public void setOilType(String oilType) {
+        this.oilType = oilType;
+    }
+
+    public void setId(Long id)
     {
         this.id = id;
     }

+ 13 - 13
Yijia-SaaS/yijia-integral/src/main/java/com/yijia/integral/domain/IntegralShopPic.java

@@ -9,7 +9,7 @@ import com.yijia.common.core.domain.BaseEntity;
  * 积分商城图片信息对象 integral_shop_pic
  * 
  * @author yijia
- * @date 2021-03-11
+ * @date 2021-03-18
  */
 public class IntegralShopPic extends BaseEntity
 {
@@ -20,11 +20,11 @@ public class IntegralShopPic extends BaseEntity
 
     /** 图片名称 */
     @Excel(name = "图片名称")
-    private String imgName;
+    private String name;
 
     /** 图片地址 */
     @Excel(name = "图片地址")
-    private String imgUrl;
+    private String url;
 
     /** 图片状态:0,禁用;1,启用 */
     @Excel(name = "图片状态:0,禁用;1,启用")
@@ -51,23 +51,23 @@ public class IntegralShopPic extends BaseEntity
     {
         return id;
     }
-    public void setImgName(String imgName) 
+    public void setName(String name) 
     {
-        this.imgName = imgName;
+        this.name = name;
     }
 
-    public String getImgName() 
+    public String getName() 
     {
-        return imgName;
+        return name;
     }
-    public void setImgUrl(String imgUrl) 
+    public void setUrl(String url) 
     {
-        this.imgUrl = imgUrl;
+        this.url = url;
     }
 
-    public String getImgUrl() 
+    public String getUrl() 
     {
-        return imgUrl;
+        return url;
     }
     public void setImgStatus(String imgStatus) 
     {
@@ -110,8 +110,8 @@ public class IntegralShopPic extends BaseEntity
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
             .append("id", getId())
-            .append("imgName", getImgName())
-            .append("imgUrl", getImgUrl())
+            .append("name", getName())
+            .append("url", getUrl())
             .append("imgStatus", getImgStatus())
             .append("stationId", getStationId())
             .append("stationName", getStationName())

+ 8 - 1
Yijia-SaaS/yijia-integral/src/main/java/com/yijia/integral/mapper/IntegralShopPicMapper.java

@@ -7,7 +7,7 @@ import com.yijia.integral.domain.IntegralShopPic;
  * 积分商城图片信息Mapper接口
  * 
  * @author yijia
- * @date 2021-03-11
+ * @date 2021-03-18
  */
 public interface IntegralShopPicMapper 
 {
@@ -58,4 +58,11 @@ public interface IntegralShopPicMapper
      * @return 结果
      */
     public int deleteIntegralShopPicByIds(Long[] ids);
+    /**
+     * 删除积分商城图片信息
+     *
+     * @param
+     * @return 结果
+     */
+    public void deleteIntegralShopPic(IntegralShopPic integralShopPic);
 }

+ 1 - 1
Yijia-SaaS/yijia-integral/src/main/java/com/yijia/integral/service/IIntegralShopPicService.java

@@ -7,7 +7,7 @@ import com.yijia.integral.domain.IntegralShopPic;
  * 积分商城图片信息Service接口
  * 
  * @author yijia
- * @date 2021-03-11
+ * @date 2021-03-18
  */
 public interface IIntegralShopPicService 
 {

+ 66 - 3
Yijia-SaaS/yijia-integral/src/main/java/com/yijia/integral/service/impl/IntegralRuleServiceImpl.java

@@ -3,7 +3,9 @@ package com.yijia.integral.service.impl;
 import java.util.List;
 
 import com.yijia.integral.domain.IntegralRuleDetail;
+import com.yijia.integral.domain.IntegralShopPic;
 import com.yijia.integral.mapper.IntegralRuleDetailMapper;
+import com.yijia.integral.mapper.IntegralShopPicMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.yijia.integral.mapper.IntegralRuleMapper;
@@ -23,6 +25,8 @@ public class IntegralRuleServiceImpl implements IIntegralRuleService
     private IntegralRuleMapper integralRuleMapper;
     @Autowired
     private IntegralRuleDetailMapper integralRuleDetailMapper;
+    @Autowired
+    private IntegralShopPicMapper integralShopPicMapper;
     /**
      * 查询积分规则
      * 
@@ -32,11 +36,24 @@ public class IntegralRuleServiceImpl implements IIntegralRuleService
     @Override
     public IntegralRule selectIntegralRuleById(Long id)
     {
+        //查询油品数据
         IntegralRule integralRule =integralRuleMapper.selectIntegralRuleById(id);
         IntegralRuleDetail  detail  = new  IntegralRuleDetail();
         detail.setParentId(id);
+        detail.setOilType("1");
         List<IntegralRuleDetail> list =  integralRuleDetailMapper.selectIntegralRuleDetailList(detail);
         integralRule.setItemsDetail(list);
+        //查询非油品数据
+        IntegralRuleDetail  itemdetail  = new  IntegralRuleDetail();
+        itemdetail.setParentId(id);
+        itemdetail.setOilType("2");
+        List<IntegralRuleDetail> notOillist =  integralRuleDetailMapper.selectIntegralRuleDetailList(itemdetail);
+        integralRule.setNotOilList(notOillist);
+        //查询图片信息
+        IntegralShopPic shopPic =new IntegralShopPic();
+        shopPic.setParentId(id);
+        List<IntegralShopPic> shopPicList = integralShopPicMapper.selectIntegralShopPicList(shopPic);
+        integralRule.setImgFileList(shopPicList);
         return integralRule;
     }
 
@@ -69,9 +86,29 @@ public class IntegralRuleServiceImpl implements IIntegralRuleService
             List<IntegralRuleDetail> list =integralRule.getItemsDetail();
             for (IntegralRuleDetail detail : list){
                 detail.setParentId(integralRule.getId().longValue());
+                detail.setOilType("1");
                 i = integralRuleDetailMapper.insertIntegralRuleDetail(detail);
             }
         }
+        if(integralRule.getNotOilList()!=null &&  integralRule.getNotOilList().size()>0){
+            List<IntegralRuleDetail> notOilList =integralRule.getNotOilList();
+            for (IntegralRuleDetail itemdetail : notOilList){
+                if(itemdetail.getSaleAmt()!=null && itemdetail.getIntegral()!=null){
+                    itemdetail.setParentId(integralRule.getId().longValue());
+                    itemdetail.setOilType("2");
+                    integralRuleDetailMapper.insertIntegralRuleDetail(itemdetail);
+                }
+            }
+        }
+        if(integralRule.getImgFileList()!=null &&  integralRule.getImgFileList().size()>0){
+            List<IntegralShopPic> imgFileList =integralRule.getImgFileList();
+            for (IntegralShopPic img : imgFileList){
+                img.setParentId(integralRule.getId().longValue());
+                img.setStationId(integralRule.getStationId());
+                img.setStationName(integralRule.getStationName());
+                integralShopPicMapper.insertIntegralShopPic(img);
+            }
+        }
         return i;
     }
 
@@ -88,11 +125,37 @@ public class IntegralRuleServiceImpl implements IIntegralRuleService
         IntegralRuleDetail ruleDetail = new IntegralRuleDetail();
         ruleDetail.setParentId(integralRule.getId());
         integralRuleDetailMapper.deleteIntegralRuleDetail(ruleDetail);
+        //从新保存数据
         if(integralRule.getItemsDetail()!=null &&  integralRule.getItemsDetail().size()>0){
             List<IntegralRuleDetail> list =integralRule.getItemsDetail();
             for (IntegralRuleDetail detail : list){
-                detail.setParentId(integralRule.getId().longValue());
-                 integralRuleDetailMapper.insertIntegralRuleDetail(detail);
+                if(detail.getSaleAmt()!=null && detail.getIntegral()!=null){
+                    detail.setParentId(integralRule.getId().longValue());
+                    detail.setOilType("1");
+                    integralRuleDetailMapper.insertIntegralRuleDetail(detail);
+                }
+            }
+        }
+        if(integralRule.getNotOilList()!=null &&  integralRule.getNotOilList().size()>0){
+            List<IntegralRuleDetail> notOilList =integralRule.getNotOilList();
+            for (IntegralRuleDetail itemdetail : notOilList){
+               if(itemdetail.getSaleAmt()!=null && itemdetail.getIntegral()!=null){
+                   itemdetail.setParentId(integralRule.getId().longValue());
+                   itemdetail.setOilType("2");
+                   integralRuleDetailMapper.insertIntegralRuleDetail(itemdetail);
+               }
+            }
+        }
+        IntegralShopPic integralShopPic =new IntegralShopPic();
+        integralShopPic.setParentId(integralRule.getId().longValue());
+        integralShopPicMapper.deleteIntegralShopPic(integralShopPic);
+        if(integralRule.getImgFileList()!=null &&  integralRule.getImgFileList().size()>0){
+            List<IntegralShopPic> imgFileList =integralRule.getImgFileList();
+            for (IntegralShopPic img : imgFileList){
+                img.setParentId(integralRule.getId().longValue());
+                img.setStationId(integralRule.getStationId());
+                img.setStationName(integralRule.getStationName());
+                integralShopPicMapper.insertIntegralShopPic(img);
             }
         }
         return  integralRuleMapper.updateIntegralRule(integralRule);
@@ -100,7 +163,7 @@ public class IntegralRuleServiceImpl implements IIntegralRuleService
 
     /**
      * 批量删除积分规则
-     * 
+     * insertIntegralRule
      * @param ids 需要删除的积分规则ID
      * @return 结果
      */

+ 1 - 1
Yijia-SaaS/yijia-integral/src/main/java/com/yijia/integral/service/impl/IntegralShopPicServiceImpl.java

@@ -11,7 +11,7 @@ import com.yijia.integral.service.IIntegralShopPicService;
  * 积分商城图片信息Service业务层处理
  * 
  * @author yijia
- * @date 2021-03-11
+ * @date 2021-03-18
  */
 @Service
 public class IntegralShopPicServiceImpl implements IIntegralShopPicService 

+ 18 - 2
Yijia-SaaS/yijia-integral/src/main/resources/mapper/integral/IntegralRuleDetailMapper.xml

@@ -14,10 +14,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="saleAmt"    column="sale_amt"    />
         <result property="integral"    column="integral"    />
         <result property="ruleType"    column="rule_type"    />
+        <result property="oilType"    column="oil_type"    />
     </resultMap>
 
     <sql id="selectIntegralRuleDetailVo">
-        select id, parent_id, rule_terms, gread_id, gread, oil_name, sale_amt, integral, rule_type from integral_rule_detail
+        select id, parent_id, rule_terms, gread_id, gread, oil_name, sale_amt, integral, rule_type,oil_type from integral_rule_detail
     </sql>
 
     <select id="selectIntegralRuleDetailList" parameterType="IntegralRuleDetail" resultMap="IntegralRuleDetailResult">
@@ -31,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="saleAmt != null "> and sale_amt = #{saleAmt}</if>
             <if test="integral != null "> and integral = #{integral}</if>
             <if test="ruleType != null  and ruleType != ''"> and rule_type = #{ruleType}</if>
+            <if test="oilType != null  and oilType != ''"> and oil_type = #{oilType}</if>
         </where>
     </select>
     
@@ -50,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="saleAmt != null">sale_amt,</if>
             <if test="integral != null">integral,</if>
             <if test="ruleType != null">rule_type,</if>
+            <if test="oilType != null">oil_type,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="parentId != null">#{parentId},</if>
@@ -60,6 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="saleAmt != null">#{saleAmt},</if>
             <if test="integral != null">#{integral},</if>
             <if test="ruleType != null">#{ruleType},</if>
+            <if test="oilType != null">#{oilType},</if>
          </trim>
     </insert>
 
@@ -74,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="saleAmt != null">sale_amt = #{saleAmt},</if>
             <if test="integral != null">integral = #{integral},</if>
             <if test="ruleType != null">rule_type = #{ruleType},</if>
+            <if test="oilType != null">oil_type = #{oilType},</if>
         </trim>
         where id = #{id}
     </update>
@@ -89,6 +94,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </delete>
     <delete id="deleteIntegralRuleDetail" parameterType="Long">
-        delete from integral_rule_detail where parent_id = #{parentId}
+        delete from integral_rule_detail
+        <where>
+            <if test="parentId != null "> and parent_id = #{parentId}</if>
+            <if test="ruleTerms != null "> and rule_terms = #{ruleTerms}</if>
+            <if test="greadId != null "> and gread_id = #{greadId}</if>
+            <if test="gread != null  and gread != ''"> and gread = #{gread}</if>
+            <if test="oilName != null  and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
+            <if test="saleAmt != null "> and sale_amt = #{saleAmt}</if>
+            <if test="integral != null "> and integral = #{integral}</if>
+            <if test="ruleType != null  and ruleType != ''"> and rule_type = #{ruleType}</if>
+            <if test="oilType != null  and oilType != ''"> and oil_type = #{oilType}</if>
+        </where>
     </delete>
 </mapper>

+ 22 - 12
Yijia-SaaS/yijia-integral/src/main/resources/mapper/integral/IntegralShopPicMapper.xml

@@ -6,8 +6,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     
     <resultMap type="IntegralShopPic" id="IntegralShopPicResult">
         <result property="id"    column="id"    />
-        <result property="imgName"    column="img_name"    />
-        <result property="imgUrl"    column="img_url"    />
+        <result property="name"    column="name"    />
+        <result property="url"    column="url"    />
         <result property="imgStatus"    column="img_status"    />
         <result property="stationId"    column="station_id"    />
         <result property="stationName"    column="station_name"    />
@@ -15,14 +15,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectIntegralShopPicVo">
-        select id, img_name, img_url, img_status, station_id, station_name, parent_id from integral_shop_pic
+        select id, name, url, img_status, station_id, station_name, parent_id from integral_shop_pic
     </sql>
 
     <select id="selectIntegralShopPicList" parameterType="IntegralShopPic" resultMap="IntegralShopPicResult">
         <include refid="selectIntegralShopPicVo"/>
         <where>  
-            <if test="imgName != null  and imgName != ''"> and img_name like concat('%', #{imgName}, '%')</if>
-            <if test="imgUrl != null  and imgUrl != ''"> and img_url = #{imgUrl}</if>
+            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
+            <if test="url != null  and url != ''"> and url = #{url}</if>
             <if test="imgStatus != null  and imgStatus != ''"> and img_status = #{imgStatus}</if>
             <if test="stationId != null "> and station_id = #{stationId}</if>
             <if test="stationName != null  and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
@@ -38,16 +38,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="insertIntegralShopPic" parameterType="IntegralShopPic" useGeneratedKeys="true" keyProperty="id">
         insert into integral_shop_pic
         <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="imgName != null">img_name,</if>
-            <if test="imgUrl != null">img_url,</if>
+            <if test="name != null">name,</if>
+            <if test="url != null">url,</if>
             <if test="imgStatus != null">img_status,</if>
             <if test="stationId != null">station_id,</if>
             <if test="stationName != null">station_name,</if>
             <if test="parentId != null">parent_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="imgName != null">#{imgName},</if>
-            <if test="imgUrl != null">#{imgUrl},</if>
+            <if test="name != null">#{name},</if>
+            <if test="url != null">#{url},</if>
             <if test="imgStatus != null">#{imgStatus},</if>
             <if test="stationId != null">#{stationId},</if>
             <if test="stationName != null">#{stationName},</if>
@@ -58,8 +58,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updateIntegralShopPic" parameterType="IntegralShopPic">
         update integral_shop_pic
         <trim prefix="SET" suffixOverrides=",">
-            <if test="imgName != null">img_name = #{imgName},</if>
-            <if test="imgUrl != null">img_url = #{imgUrl},</if>
+            <if test="name != null">name = #{name},</if>
+            <if test="url != null">url = #{url},</if>
             <if test="imgStatus != null">img_status = #{imgStatus},</if>
             <if test="stationId != null">station_id = #{stationId},</if>
             <if test="stationName != null">station_name = #{stationName},</if>
@@ -78,5 +78,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
-    
+    <delete id="deleteIntegralShopPic" parameterType="IntegralShopPic">
+        delete from integral_shop_pic
+        <where>
+            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
+            <if test="url != null  and url != ''"> and url = #{url}</if>
+            <if test="imgStatus != null  and imgStatus != ''"> and img_status = #{imgStatus}</if>
+            <if test="stationId != null "> and station_id = #{stationId}</if>
+            <if test="stationName != null  and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
+            <if test="parentId != null "> and parent_id = #{parentId}</if>
+        </where>
+    </delete>
 </mapper>