瀏覽代碼

积分赠送规则设置-级联删除
规则适用时间

zyh 3 年之前
父節點
當前提交
3ba521c074

+ 7 - 0
kmall-admin/src/main/java/com/kmall/admin/entity/vip/Mall2PointsRulesEntity.java

@@ -1,5 +1,8 @@
 package com.kmall.admin.entity.vip;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
@@ -30,10 +33,14 @@ public class Mall2PointsRulesEntity implements Serializable, Comparable<Mall2Poi
     /**
      * 积分规则适用开始时间
      */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date pointsBeginTime;
     /**
      * 积分规则适用结束时间
      */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date pointsEndTime;
     /**
      * 积分规则是否有效

+ 13 - 0
kmall-admin/src/main/java/com/kmall/admin/service/impl/vip/Mall2PointsRulesServiceImpl.java

@@ -72,6 +72,7 @@ public class Mall2PointsRulesServiceImpl implements Mall2PointsRulesService {
         if ((!mall2PointsRulesEntities.isEmpty()) && Dict.isValid.item_0.getItem().equals(mall2PointsRules.getIsValid())){
             return R.error("已存在该积分类型有效数据,请确认再进行操作");
         }
+        log.debug("积分规则添加数据:{}",JacksonUtil.toJson(mall2PointsRules));
         mall2PointsRulesDao.save(mall2PointsRules);
 
         return R.ok("添加成功");
@@ -96,6 +97,18 @@ public class Mall2PointsRulesServiceImpl implements Mall2PointsRulesService {
 
     @Override
     public int deleteBatch(Integer[]mprIds) {
+        log.debug("积分规则删除参数:{}",JacksonUtil.toJson(mprIds));
+        for (int i = 0; i < mprIds.length; i++) {
+            Integer mprId=mprIds[i];
+            HashMap<String, Object> map = new HashMap<>();
+            map.put("fatherId", mprId);
+            List<Mall2PointsRulesDetilEntity> mall2PointsRulesDetilEntities = mall2PointsRulesDetilService.queryList(map);
+            log.debug("需要删除积分规则明细数据:{}",JacksonUtil.toJson(mall2PointsRulesDetilEntities));
+            if (!mall2PointsRulesDetilEntities.isEmpty()){
+                mall2PointsRulesDetilService.deleteByFatherId(mprId);
+            }
+        }
+
         return mall2PointsRulesDao.deleteBatch(mprIds);
     }
 

+ 1 - 1
kmall-admin/src/main/resources/mybatis/mapper/vip/Mall2PointsRulesDetilDao.xml

@@ -107,7 +107,7 @@
 		delete from mall2_points_rules_detil where id = #{value}
 	</delete>
 
-	<delete id="deleteByFatherId">
+	<delete id="deleteByFatherId" parameterType="java.lang.Integer">
 		delete from mall2_points_rules_detil where father_id = #{fatherId}
 	</delete>
 	

+ 2 - 3
kmall-admin/src/main/webapp/WEB-INF/page/vip/mall2pointsrules.html

@@ -34,7 +34,6 @@
 	    <table id="jqGrid"></table>
 	    <div id="jqGridPager"></div>
     </div>
-
     <Card v-show="!showList">
         <p slot="title">{{title}}</p>
 		<i-form ref="formValidate" :model="mall2PointsRules" :rules="ruleValidate" :label-width="80">
@@ -52,10 +51,10 @@
 <!--                <i-input v-model="mall2PointsRules.pointsRulesNum" placeholder="对应积分数"/>-->
 <!--            </Form-item>-->
             <Form-item label="适用开始时间" prop="pointsBeginTime">
-                <i-input type="date"  v-model="mall2PointsRules.pointsBeginTime" placeholder="积分规则适用开始时间"/>
+                <i-input type="datetime-local"  v-model="mall2PointsRules.pointsBeginTime" placeholder="积分规则适用开始时间"/>
             </Form-item>
             <Form-item label="适用结束时间" prop="pointsEndTime">
-                <i-input type="date"  v-model="mall2PointsRules.pointsEndTime" placeholder="积分规则适用结束时间"/>
+                <i-input type="datetime-local"  v-model="mall2PointsRules.pointsEndTime" placeholder="积分规则适用结束时间"/>
             </Form-item>
             <Form-item label="积分比例(小数)" prop="ratio">
                 <i-input v-model="mall2PointsRules.ratio" placeholder="积分比例小数,保留两位" />

+ 6 - 6
kmall-admin/src/main/webapp/js/vip/mall2pointsrules.js

@@ -22,14 +22,10 @@ $(function () {
 			// {label: '对应积分数', name: 'pointsRulesNum', index: 'points_rules_num', width: 80},
 			{label: '对应积分生成比例', name: 'ratio', index: 'ratio', width: 80},
 			{
-				label: '规则适用开始时间', name: 'pointsBeginTime', index: 'points_begin_time',align:"center", width: 200, formatter: function (value) {
-					return transDate(value, 'yyyy-MM-dd HH:mm:ss');
-				}
+				label: '规则适用开始时间', name: 'pointsBeginTime', index: 'points_begin_time',align:"center", width: 200
 			},
 			{
-				label: '规则适用结束时间', name: 'pointsEndTime', index: 'points_end_time',align:"center", width: 200, formatter: function (value) {
-					return transDate(value, 'yyyy-MM-dd HH:mm:ss');
-				}
+				label: '规则适用结束时间', name: 'pointsEndTime', index: 'points_end_time',align:"center", width: 200
 			},
 			{
 				label: '是否有效', name: 'isValid', index: 'is_valid', width: 80, formatter: function (value) {
@@ -138,6 +134,10 @@ let vm = new Vue({
 		},
 		saveOrUpdate: function (event) {
             let url = vm.mall2PointsRules.mprId == null ? "../mall2pointsrules/save" : "../mall2pointsrules/update";
+			vm.mall2PointsRules.pointsBeginTime=vm.mall2PointsRules.pointsBeginTime.replaceAll("T"," ")+":00";
+			vm.mall2PointsRules.pointsEndTime=vm.mall2PointsRules.pointsEndTime.replaceAll("T"," ")+":00";
+			console.log(vm.mall2PointsRules.pointsBeginTime)
+			console.log(vm.mall2PointsRules.pointsEndTime)
 			$.ajax({
 				type: "POST",
 			    url: url,