Explorar el Código

商户号更新为null问题

wanxl hace 1 año
padre
commit
6880f54563

+ 1 - 1
src/main/java/com/sqx/modules/goods/entity/GoodsShop.java

@@ -180,7 +180,7 @@ public class GoodsShop implements Serializable {
     private Integer reservationOpenFlag;
 
     @ApiModelProperty("商户id")
-    @TableField(updateStrategy = FieldStrategy.IGNORED)
+//    @TableField(updateStrategy = FieldStrategy.IGNORED)
     private String mchId;
 
     /**

+ 18 - 11
src/main/java/com/sqx/modules/goods/service/impl/GoodsShopServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -264,18 +265,24 @@ public class GoodsShopServiceImpl extends ServiceImpl<GoodsShopDao, GoodsShop> i
 //            sendMsgDXB(goodsShop.getPhone(), null, 1);
             userService.sendMsg(goodsShop.getPhone(),"weigui");
         }
-        baseMapper.updateById(goodsShop);
+//        baseMapper.updateById(goodsShop);
+        //更新商户号、snCode、打印机参数为空设置为null
+        baseMapper.update(goodsShop,Wrappers.<GoodsShop>lambdaUpdate()
+                .eq(GoodsShop::getShopId,goodsShop.getShopId())
+                .set(GoodsShop::getMchId , StringUtils.isEmpty(goodsShop.getMchId())?null:goodsShop.getMchId())
+                .set(GoodsShop::getSnCode , StringUtils.isEmpty(goodsShop.getSnCode())?null:goodsShop.getSnCode())
+                .set(GoodsShop::getValue , StringUtils.isEmpty(goodsShop.getValue())?null:goodsShop.getValue()));
         //snCode value
-        if(StringUtils.isEmpty(goodsShop.getSnCode())){
-            baseMapper.update(null, Wrappers.<GoodsShop>lambdaUpdate()
-                    .eq(GoodsShop::getShopId, goodsShop.getShopId())
-                    .set(GoodsShop::getSnCode , null));
-        }
-        if(StringUtils.isEmpty(goodsShop.getValue())){
-            baseMapper.update(null, Wrappers.<GoodsShop>lambdaUpdate()
-                    .eq(GoodsShop::getShopId, goodsShop.getShopId())
-                    .set(GoodsShop::getValue, null));
-        }
+//        if(StringUtils.isEmpty(goodsShop.getSnCode())){
+//            baseMapper.update(null, Wrappers.<GoodsShop>lambdaUpdate()
+//                    .eq(GoodsShop::getShopId, goodsShop.getShopId())
+//                    .set(GoodsShop::getSnCode , null));
+//        }
+//        if(StringUtils.isEmpty(goodsShop.getValue())){
+//            baseMapper.update(null, Wrappers.<GoodsShop>lambdaUpdate()
+//                    .eq(GoodsShop::getShopId, goodsShop.getShopId())
+//                    .set(GoodsShop::getValue, null));
+//        }
         return Result.success();
     }
 

+ 6 - 1
src/main/java/com/sqx/modules/shop/service/impl/ShopMessageServiceImpl.java

@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.sqx.common.constant.RedisKey;
@@ -314,7 +315,11 @@ public class ShopMessageServiceImpl extends ServiceImpl<ShopMessageDao, GoodsSho
         //     }
         // }
 
-        baseMapper.updateById(goodsShop);
+//        baseMapper.updateById(goodsShop);
+        //更新商户号可为null
+        baseMapper.update(goodsShop,Wrappers.<GoodsShop>lambdaUpdate()
+                .eq(GoodsShop::getShopId,goodsShop.getShopId())
+                .set(GoodsShop::getMchId,StringUtils.isEmpty(goodsShop.getMchId())?null:goodsShop.getMchId()));
 
         redisUtils.delete(String.format(RedisKey.SHOP_INFO_CACHE_KEY, goodsShop.getShopId()));