Browse Source

上传花型显示状态接口以及查询优惠码折扣接口

soobin 2 years ago
parent
commit
996ad19f0d

+ 48 - 20
src/main/java/com/szwl/controller/IndexController.java

@@ -6,10 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.szwl.constant.ResponseCodesEnum;
-import com.szwl.model.bean.CommonParamVo;
-import com.szwl.model.bean.EquipmentDTO;
-import com.szwl.model.bean.EquipmentVo;
-import com.szwl.model.bean.ProductVo;
+import com.szwl.model.bean.*;
 import com.szwl.model.bo.JsonMessage;
 import com.szwl.model.bo.JsonUtils;
 import com.szwl.model.bo.R;
@@ -1068,14 +1065,6 @@ public class IndexController { ;
         if (equipment == null) {
             return "404";
         }
-        //TODO
-//        TAdmin admin = adminService.find(equipment.getAdminId());
-//        String qrCodeImgUrl = admin.getQrCodeImgUrl();
-//        if(!StringUtils.isEmpty(qrCodeImgUrl)){
-//            return qrCodeImgUrl;
-//        }else {
-//            return "400";
-//        }
         return "400";
     }
     /**
@@ -1786,15 +1775,17 @@ public class IndexController { ;
             LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
             query.eq(TEquipment::getClientId,clientId);
             List<TEquipment> list = equipmentService.list(query);
-            TEquipment equipment = list.get(0);
-            Long adminId = equipment.getAdminId();
-            if(adminId!=null){
-                String managerId = AdminUtils.encrypt(false, adminId);
-                if(StringUtils.isEmpty(equipment.getManagerId())||!equipment.getManagerId().equals(managerId)){
-                    equipment.setManagerId(managerId);
-                    equipmentService.save(equipment);
+            if (list.size()>0) {
+                TEquipment equipment = list.get(0);
+                Long adminId = equipment.getAdminId();
+                if(adminId!=null){
+                    String managerId = AdminUtils.encrypt(false, adminId);
+                    if(StringUtils.isEmpty(equipment.getManagerId())||!equipment.getManagerId().equals(managerId)){
+                        equipment.setManagerId(managerId);
+                        equipmentService.save(equipment);
+                    }
+                    return managerId;
                 }
-                return managerId;
             }
             return "error";
         }
@@ -1930,5 +1921,42 @@ public class IndexController { ;
         return R.fail(ResponseCodesEnum.A0002);
     }
 
+    /**
+     * 上传花型显示状态
+     * @param clientId 设备编号
+     * @param tProductBean 包含花型编号和状态
+     * @return
+     */
+    @RequestMapping(value = "/updateShowGoods", method = RequestMethod.POST)
+    @ResponseBody
+    public String updateShowGoods(@RequestParam String clientId, @RequestBody List<TProductBean> tProductBean) {
+        if(StringUtils.isEmpty(clientId)||tProductBean == null) {
+            return "参数为空";
+        }
+        LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
+        query.eq(TEquipment::getClientId,clientId);
+        TEquipment equipment = equipmentService.getOnly(query);
+        if (equipment==null) {
+            return "找不到设备信息";
+        }
+        Long equipmentId = equipment.getId();
+        ArrayList<TProduct> tProducts = new ArrayList<>();
+        for (TProductBean productBean : tProductBean) {
+            String no = productBean.getNo();
+            String showType = productBean.getShowType();
+            LambdaQueryWrapper<TProduct> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(TProduct::getEquipmentId,equipmentId);
+            wrapper.eq(TProduct::getNo,no);
+            TProduct product = productService.getOnly(wrapper);
+            product.setShowType(showType);
+            tProducts.add(product);
+        }
+        boolean res = productService.updateBatchById(tProducts);
+        if (!res) {
+            return "error";
+        }
+        return "success";
+    }
+
 }
 

+ 21 - 5
src/main/java/com/szwl/controller/TPromoCodeController.java

@@ -23,11 +23,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang.StringUtils;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -575,5 +571,25 @@ public class TPromoCodeController {
         }
         return JsonMessage.success("导出成功");
     }
+
+    @ApiOperation(value = "查询优惠码几折")
+    @RequestMapping(value = "/getCodeDiscount", method = RequestMethod.GET)
+    @ResponseBody
+    public Object getCodeDiscount(String code) {
+        if(!StringUtils.isEmpty(code)){
+            LambdaQueryWrapper<TPromoCode> wrapper = new LambdaQueryWrapper<>();
+            wrapper.in(TPromoCode::getCode,code);
+            wrapper.in(TPromoCode::getIsUse,"0");
+            TPromoCode promoCode = promoCodeService.getOne(wrapper);
+            if(promoCode == null) {
+                return null;
+            }
+            Float discount = promoCode.getDiscount();
+            return JsonMessage.success(discount);
+        }else{
+            return null;
+        }
+
+    }
 }