Explorar el Código

feat:“添加删除优惠码接口,优化设备语言上传接口、商品调价接口”

soobin hace 1 año
padre
commit
00752feb91

+ 58 - 14
src/main/java/com/szwl/controller/IndexController.java

@@ -92,6 +92,9 @@ public class IndexController {
     TDiyFlowerService diyFlowerService;
 
     @Autowired
+    TNameDictionaryService nameDictionaryService;
+
+    @Autowired
     private AmqpAdmin amqpAdmin;
 
     @Resource
@@ -971,11 +974,11 @@ public class IndexController {
     @RequestMapping(value = "/updateProduct.htm", method = RequestMethod.POST, produces = "text/html;charset=utf-8")
     @ResponseBody
     public String updateProduct(@RequestBody List<ProductVo> productVos) {
-        Double f = 0.00;
-        int num = 0;
-        int n = 0;
-        HashSet<Double> price = new HashSet<Double>();
-        HashSet<Double> minprice = new HashSet<Double>();
+//        Double f = 0.00;
+//        int num = 0;
+//        int n = 0;
+//        HashSet<Double> price = new HashSet<Double>();
+//        HashSet<Double> minprice = new HashSet<Double>();
         for (ProductVo product : productVos) {
             String clientId = product.getClientId();
             LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
@@ -984,22 +987,43 @@ public class IndexController {
             Long id = equipment.getId();
             if (StringUtils.isNotEmpty(product.getShowType())) {
                 LambdaQueryWrapper<TProduct> queryProduct = Wrappers.lambdaQuery();
-                queryProduct.eq(TProduct::getEquipmentId, equipment.getId());
+                queryProduct.eq(TProduct::getEquipmentId, id);
                 queryProduct.eq(TProduct::getProductName, product.getProductName());
-                List<TProduct> productList = productService.list(queryProduct);
-                TProduct tProduct = productList.get(0);
+//                List<TProduct> productList = productService.list(queryProduct);
+//                TProduct tProduct = productList.get(0);
+                TProduct tProduct = productService.getOnly(queryProduct);
+                if (tProduct == null) {
+                    LambdaQueryWrapper<TNameDictionary> wrapper = Wrappers.lambdaQuery();
+                    wrapper.eq(TNameDictionary::getLanguage, "zh");
+                    wrapper.eq(TNameDictionary::getName, product.getProductName());
+                    TNameDictionary nameDictionary = nameDictionaryService.getOne(wrapper);
+                    LambdaQueryWrapper<TProduct> queryWrapper = Wrappers.lambdaQuery();
+                    queryWrapper.eq(TProduct::getEquipmentId, id);
+                    queryWrapper.eq(TProduct::getNo, nameDictionary.getNo());
+                    tProduct = productService.getOnly(queryWrapper);
+                }
                 tProduct.setRmbPrice(BigDecimal.valueOf(product.getRmbPrice()));
                 tProduct.setCodePrice(BigDecimal.valueOf(product.getCodePrice()));
                 tProduct.setShowType(product.getShowType());
                 tProduct.setSellStatus(product.getSellStatus());
                 productService.updateById(tProduct);
-
             } else {
                 LambdaQueryWrapper<TProduct> queryProduct = Wrappers.lambdaQuery();
-                queryProduct.eq(TProduct::getEquipmentId, equipment.getId());
+                queryProduct.eq(TProduct::getEquipmentId, id);
                 queryProduct.eq(TProduct::getProductName, product.getProductName());
-                List<TProduct> productList = productService.list(queryProduct);
-                TProduct tProduct = productList.get(0);
+//                List<TProduct> productList = productService.list(queryProduct);
+//                TProduct tProduct = productList.get(0);
+                TProduct tProduct = productService.getOnly(queryProduct);
+                if (tProduct == null) {
+                    LambdaQueryWrapper<TNameDictionary> wrapper = Wrappers.lambdaQuery();
+                    wrapper.eq(TNameDictionary::getLanguage, "zh");
+                    wrapper.eq(TNameDictionary::getName, product.getProductName());
+                    TNameDictionary nameDictionary = nameDictionaryService.getOne(wrapper);
+                    LambdaQueryWrapper<TProduct> queryWrapper = Wrappers.lambdaQuery();
+                    queryWrapper.eq(TProduct::getEquipmentId, id);
+                    queryWrapper.eq(TProduct::getNo, nameDictionary.getNo());
+                    tProduct = productService.getOnly(queryWrapper);
+                }
                 tProduct.setRmbPrice(BigDecimal.valueOf(product.getRmbPrice()));
                 tProduct.setCodePrice(BigDecimal.valueOf(product.getCodePrice()));
                 tProduct.setSellStatus(product.getSellStatus());
@@ -2209,8 +2233,28 @@ public class IndexController {
                 return "fail";
             }
             TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipment.getId());
-            equipmentDesc.setLanguage(language);
-            equipmentDescService.updateById(equipmentDesc);
+            if (equipmentDesc.getLanguage() == null || !(equipmentDesc.getLanguage().equals(language))) {
+                equipmentDesc.setLanguage(language);
+                equipmentDescService.updateById(equipmentDesc);
+                LambdaQueryWrapper<TProduct> wrapper = Wrappers.lambdaQuery();
+                wrapper.eq(TProduct::getEquipmentId, equipment.getId());
+                List<TProduct> products = productService.list(wrapper);
+                for (TProduct product : products) {
+                    String no = product.getNo();
+                    // 如果没改过名才更改
+                    if (StringUtils.isEmpty(product.getName())) {
+                        LambdaQueryWrapper<TNameDictionary> lambdaQueryWrapper = Wrappers.lambdaQuery();
+                        lambdaQueryWrapper.eq(TNameDictionary::getLanguage, language);
+                        lambdaQueryWrapper.eq(TNameDictionary::getNo, no);
+                        TNameDictionary nameDictionary = nameDictionaryService.getOne(lambdaQueryWrapper);
+                        if (nameDictionary != null) {
+                            product.setModifyDate(new Date());
+                            product.setProductName(nameDictionary.getName());
+                            productService.updateById(product);
+                        }
+                    }
+                }
+            }
             return "success";
         }
         return "fail";

+ 22 - 1
src/main/java/com/szwl/controller/TPromoCodeController.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.szwl.constant.ResponseCodesEnum;
 import com.szwl.feign.bean.PayFeign;
 import com.szwl.constant.JoinpayConstant;
 import com.szwl.model.bo.JsonMessage;
@@ -144,7 +145,11 @@ public class TPromoCodeController {
         if(list1.size()>0){
             TPromoCode tPromoCode = list1.get(0);
             tPromoCode.setIsUse("1");
-            tPromoCode.setUseBy(equipment.getName());
+            if (StringUtils.isNotEmpty(equipment.getName())) {
+                tPromoCode.setUseBy(equipment.getName());
+            } else {
+                tPromoCode.setUseBy(clientId);
+            }
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             String time = sdf.format(new Date());
             tPromoCode.setUseDate(time);
@@ -622,7 +627,23 @@ public class TPromoCodeController {
         }else{
             return null;
         }
+    }
 
+    @ApiOperation(value = "批量删除优惠码")
+    @PostMapping (value = "/deletes")
+    @ResponseBody
+    public ResponseModel<?> deletes(@RequestBody Long[] ids) {
+        if(ids==null){
+            return R.fail(ResponseCodesEnum.A0001);
+        }
+        if(ids.length > 0){
+            ArrayList<Long> idList = new ArrayList<>();
+            for(int i = 0;i < ids.length; i++){
+                idList.add(ids[i]);
+            }
+            promoCodeService.removeByIds(idList);
+        }
+        return R.ok();
     }
 }