java110 hace 5 años
padre
commit
e5895a3048

+ 2 - 2
service-fee/src/main/java/com/java110/fee/api/FeeDiscountApi.java

@@ -79,9 +79,9 @@ public class FeeDiscountApi {
         Assert.hasKeyAndValue(reqJson, "discountType", "请求报文中未包含discountType");
         Assert.hasKeyAndValue(reqJson, "discountType", "请求报文中未包含discountType");
         Assert.hasKeyAndValue(reqJson, "discountId", "discountId不能为空");
         Assert.hasKeyAndValue(reqJson, "discountId", "discountId不能为空");
 
 
-
+        JSONArray feeDiscountRuleSpecs = reqJson.getJSONArray("feeDiscountRuleSpecs");
         FeeDiscountPo feeDiscountPo = BeanConvertUtil.covertBean(reqJson, FeeDiscountPo.class);
         FeeDiscountPo feeDiscountPo = BeanConvertUtil.covertBean(reqJson, FeeDiscountPo.class);
-        return updateFeeDiscountBMOImpl.update(feeDiscountPo);
+        return updateFeeDiscountBMOImpl.update(feeDiscountPo,feeDiscountRuleSpecs);
     }
     }
 
 
     /**
     /**

+ 2 - 1
service-fee/src/main/java/com/java110/fee/bmo/feeDiscount/IUpdateFeeDiscountBMO.java

@@ -1,5 +1,6 @@
 package com.java110.fee.bmo.feeDiscount;
 package com.java110.fee.bmo.feeDiscount;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.java110.po.feeDiscount.FeeDiscountPo;
 import com.java110.po.feeDiscount.FeeDiscountPo;
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.ResponseEntity;
 
 
@@ -13,7 +14,7 @@ public interface IUpdateFeeDiscountBMO {
      * @param feeDiscountPo
      * @param feeDiscountPo
      * @return
      * @return
      */
      */
-    ResponseEntity<String> update(FeeDiscountPo feeDiscountPo);
+    ResponseEntity<String> update(FeeDiscountPo feeDiscountPo, JSONArray feeDiscountRuleSpecs);
 
 
 
 
 }
 }

+ 16 - 3
service-fee/src/main/java/com/java110/fee/bmo/feeDiscount/impl/DeleteFeeDiscountBMOImpl.java

@@ -3,7 +3,9 @@ package com.java110.fee.bmo.feeDiscount.impl;
 import com.java110.core.annotation.Java110Transactional;
 import com.java110.core.annotation.Java110Transactional;
 import com.java110.fee.bmo.feeDiscount.IDeleteFeeDiscountBMO;
 import com.java110.fee.bmo.feeDiscount.IDeleteFeeDiscountBMO;
 import com.java110.intf.fee.IFeeDiscountInnerServiceSMO;
 import com.java110.intf.fee.IFeeDiscountInnerServiceSMO;
+import com.java110.intf.fee.IFeeDiscountSpecInnerServiceSMO;
 import com.java110.po.feeDiscount.FeeDiscountPo;
 import com.java110.po.feeDiscount.FeeDiscountPo;
+import com.java110.po.feeDiscountSpec.FeeDiscountSpecPo;
 import com.java110.vo.ResultVo;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.ResponseEntity;
@@ -15,6 +17,9 @@ public class DeleteFeeDiscountBMOImpl implements IDeleteFeeDiscountBMO {
     @Autowired
     @Autowired
     private IFeeDiscountInnerServiceSMO feeDiscountInnerServiceSMOImpl;
     private IFeeDiscountInnerServiceSMO feeDiscountInnerServiceSMOImpl;
 
 
+    @Autowired
+    private IFeeDiscountSpecInnerServiceSMO feeDiscountSpecInnerServiceSMOImpl;
+
     /**
     /**
      * @param feeDiscountPo 数据
      * @param feeDiscountPo 数据
      * @return 订单服务能够接受的报文
      * @return 订单服务能够接受的报文
@@ -24,11 +29,19 @@ public class DeleteFeeDiscountBMOImpl implements IDeleteFeeDiscountBMO {
 
 
         int flag = feeDiscountInnerServiceSMOImpl.deleteFeeDiscount(feeDiscountPo);
         int flag = feeDiscountInnerServiceSMOImpl.deleteFeeDiscount(feeDiscountPo);
 
 
-        if (flag > 0) {
-            return ResultVo.createResponseEntity(ResultVo.CODE_OK, "保存成功");
+        if (flag < 1) {
+            return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "保存失败");
+
         }
         }
 
 
-        return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "保存失败");
+        FeeDiscountSpecPo feeDiscountSpecPo = null;
+        //删除所有
+        feeDiscountSpecPo = new FeeDiscountSpecPo();
+        feeDiscountSpecPo.setCommunityId(feeDiscountPo.getCommunityId());
+        feeDiscountSpecPo.setDiscountId(feeDiscountPo.getDiscountId());
+        feeDiscountSpecInnerServiceSMOImpl.deleteFeeDiscountSpec(feeDiscountSpecPo);
+
+        return ResultVo.createResponseEntity(ResultVo.CODE_OK, "保存成功");
     }
     }
 
 
 }
 }

+ 38 - 3
service-fee/src/main/java/com/java110/fee/bmo/feeDiscount/impl/UpdateFeeDiscountBMOImpl.java

@@ -1,9 +1,14 @@
 package com.java110.fee.bmo.feeDiscount.impl;
 package com.java110.fee.bmo.feeDiscount.impl;
 
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Transactional;
 import com.java110.core.annotation.Java110Transactional;
+import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.fee.bmo.feeDiscount.IUpdateFeeDiscountBMO;
 import com.java110.fee.bmo.feeDiscount.IUpdateFeeDiscountBMO;
 import com.java110.intf.fee.IFeeDiscountInnerServiceSMO;
 import com.java110.intf.fee.IFeeDiscountInnerServiceSMO;
+import com.java110.intf.fee.IFeeDiscountSpecInnerServiceSMO;
 import com.java110.po.feeDiscount.FeeDiscountPo;
 import com.java110.po.feeDiscount.FeeDiscountPo;
+import com.java110.po.feeDiscountSpec.FeeDiscountSpecPo;
 import com.java110.vo.ResultVo;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.ResponseEntity;
@@ -15,20 +20,50 @@ public class UpdateFeeDiscountBMOImpl implements IUpdateFeeDiscountBMO {
     @Autowired
     @Autowired
     private IFeeDiscountInnerServiceSMO feeDiscountInnerServiceSMOImpl;
     private IFeeDiscountInnerServiceSMO feeDiscountInnerServiceSMOImpl;
 
 
+    @Autowired
+    private IFeeDiscountSpecInnerServiceSMO feeDiscountSpecInnerServiceSMOImpl;
+
     /**
     /**
      * @param feeDiscountPo
      * @param feeDiscountPo
      * @return 订单服务能够接受的报文
      * @return 订单服务能够接受的报文
      */
      */
     @Java110Transactional
     @Java110Transactional
-    public ResponseEntity<String> update(FeeDiscountPo feeDiscountPo) {
+    public ResponseEntity<String> update(FeeDiscountPo feeDiscountPo, JSONArray feeDiscountRuleSpecs) {
 
 
         int flag = feeDiscountInnerServiceSMOImpl.updateFeeDiscount(feeDiscountPo);
         int flag = feeDiscountInnerServiceSMOImpl.updateFeeDiscount(feeDiscountPo);
 
 
-        if (flag > 0) {
+        if (flag < 1) {
+            return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "保存失败");
+        }
+
+        if (feeDiscountRuleSpecs == null || feeDiscountRuleSpecs.size() < 1) {
             return ResultVo.createResponseEntity(ResultVo.CODE_OK, "保存成功");
             return ResultVo.createResponseEntity(ResultVo.CODE_OK, "保存成功");
         }
         }
+        FeeDiscountSpecPo feeDiscountSpecPo = null;
+        //删除所有
+        feeDiscountSpecPo = new FeeDiscountSpecPo();
+        feeDiscountSpecPo.setCommunityId(feeDiscountPo.getCommunityId());
+        feeDiscountSpecPo.setDiscountId(feeDiscountPo.getDiscountId());
+        feeDiscountSpecInnerServiceSMOImpl.deleteFeeDiscountSpec(feeDiscountSpecPo);
+
+        JSONObject specObj = null;
+        for (int specIndex = 0; specIndex < feeDiscountRuleSpecs.size(); specIndex++) {
+            specObj = feeDiscountRuleSpecs.getJSONObject(specIndex);
+            feeDiscountSpecPo = new FeeDiscountSpecPo();
+            feeDiscountSpecPo.setCommunityId(feeDiscountPo.getCommunityId());
+            feeDiscountSpecPo.setDiscountId(feeDiscountPo.getDiscountId());
+            feeDiscountSpecPo.setSpecId(specObj.getString("specId"));
+            feeDiscountSpecPo.setSpecName(specObj.getString("specName"));
+            feeDiscountSpecPo.setSpecValue(specObj.getString("specValue"));
+            feeDiscountSpecPo.setDiscountSpecId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_specId));
+            flag = feeDiscountSpecInnerServiceSMOImpl.saveFeeDiscountSpec(feeDiscountSpecPo);
+            if (flag < 1) {
+                throw new IllegalArgumentException("保存 折扣规格失败");
+            }
+        }
+
 
 
-        return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "保存失败");
+        return ResultVo.createResponseEntity(ResultVo.CODE_OK, "保存成功");
     }
     }
 
 
 }
 }