diff --git a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAddressService.java b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAddressService.java index a6c886c8..87c6147e 100644 --- a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAddressService.java +++ b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAddressService.java @@ -39,10 +39,8 @@ public class LitemallAddressService { return addressMapper.updateByPrimaryKeySelective(address); } - public void delete(Integer userId, Integer id) { - LitemallAddressExample example = new LitemallAddressExample(); - example.or().andUserIdEqualTo(userId).andIdEqualTo(id).andDeletedEqualTo(false); - addressMapper.logicalDeleteByExample(example); + public void delete(Integer id) { + addressMapper.logicalDeleteByPrimaryKey(id); } public LitemallAddress findDefault(Integer userId) { diff --git a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAftersaleService.java b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAftersaleService.java index 2c881c1f..17a0fe63 100644 --- a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAftersaleService.java +++ b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallAftersaleService.java @@ -23,6 +23,12 @@ public class LitemallAftersaleService { return aftersaleMapper.selectByPrimaryKey(id); } + public LitemallAftersale findById(Integer userId, Integer id) { + LitemallAftersaleExample example = new LitemallAftersaleExample(); + example.or().andIdEqualTo(id).andUserIdEqualTo(userId).andDeletedEqualTo(false); + return aftersaleMapper.selectOneByExample(example); + } + public List queryList(Integer userId, Short status, Integer page, Integer limit, String sort, String order) { LitemallAftersaleExample example = new LitemallAftersaleExample(); LitemallAftersaleExample.Criteria criteria = example.or(); diff --git a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCartService.java b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCartService.java index 6d16ae10..93be0dc9 100644 --- a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCartService.java +++ b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCartService.java @@ -57,6 +57,12 @@ public class LitemallCartService { return cartMapper.selectByPrimaryKey(id); } + public LitemallCart findById(Integer userId, Integer id) { + LitemallCartExample example = new LitemallCartExample(); + example.or().andUserIdEqualTo(userId).andIdEqualTo(id).andDeletedEqualTo(false); + return cartMapper.selectOneByExample(example); + } + public int updateCheck(Integer userId, List idsList, Boolean checked) { LitemallCartExample example = new LitemallCartExample(); example.or().andUserIdEqualTo(userId).andProductIdIn(idsList).andDeletedEqualTo(false); diff --git a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallFootprintService.java b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallFootprintService.java index 0b4706c7..65e79c01 100644 --- a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallFootprintService.java +++ b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallFootprintService.java @@ -28,6 +28,12 @@ public class LitemallFootprintService { return footprintMapper.selectByPrimaryKey(id); } + public LitemallFootprint findById(Integer userId, Integer id) { + LitemallFootprintExample example = new LitemallFootprintExample(); + example.or().andIdEqualTo(id).andUserIdEqualTo(userId).andDeletedEqualTo(false); + return footprintMapper.selectOneByExample(example); + } + public void deleteById(Integer id) { footprintMapper.logicalDeleteByPrimaryKey(id); } diff --git a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGrouponService.java b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGrouponService.java index e7a3f457..ddfdbb19 100644 --- a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGrouponService.java +++ b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallGrouponService.java @@ -80,6 +80,19 @@ public class LitemallGrouponService { return mapper.selectOneByExample(example); } + /** + * 根据ID查询记录 + * + * @param userId + * @param id + * @return + */ + public LitemallGroupon queryById(Integer userId, Integer id) { + LitemallGrouponExample example = new LitemallGrouponExample(); + example.or().andIdEqualTo(id).andUserIdEqualTo(id).andDeletedEqualTo(false); + return mapper.selectOneByExample(example); + } + /** * 返回某个发起的团购参与人数 * diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/service/WxOrderService.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/service/WxOrderService.java index db0dc369..1e964a81 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/service/WxOrderService.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/service/WxOrderService.java @@ -289,7 +289,7 @@ public class WxOrderService { return ResponseUtil.fail(GROUPON_JOIN, "团购活动已经参加!"); } // (2)不允许参加自己开团的团购 - LitemallGroupon groupon = grouponService.queryById(grouponLinkId); + LitemallGroupon groupon = grouponService.queryById(userId, grouponLinkId); if(groupon.getCreatorUserId().equals(userId)){ return ResponseUtil.fail(GROUPON_JOIN, "团购活动已经参加!"); } @@ -912,6 +912,10 @@ public class WxOrderService { if (userId == null) { return ResponseUtil.unlogin(); } + LitemallOrder order = orderService.findById(userId, orderId); + if (order == null) { + return ResponseUtil.badArgument(); + } List orderGoodsList = orderGoodsService.findByOidAndGid(orderId, goodsId); int size = orderGoodsList.size(); diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAddressController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAddressController.java index 6853ecaa..74f6f899 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAddressController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAddressController.java @@ -133,20 +133,28 @@ public class WxAddressController extends GetRegionService { return error; } - if (address.getIsDefault()) { - // 重置其他收货地址的默认选项 - addressService.resetDefault(userId); - } - if (address.getId() == null || address.getId().equals(0)) { + if (address.getIsDefault()) { + // 重置其他收货地址的默认选项 + addressService.resetDefault(userId); + } + address.setId(null); address.setUserId(userId); addressService.add(address); } else { - address.setUserId(userId); - if (addressService.update(address) == 0) { - return ResponseUtil.updatedDataFailed(); + LitemallAddress litemallAddress = addressService.query(userId, address.getId()); + if (litemallAddress == null) { + return ResponseUtil.badArgumentValue(); } + + if (address.getIsDefault()) { + // 重置其他收货地址的默认选项 + addressService.resetDefault(userId); + } + + address.setUserId(userId); + addressService.update(address); } return ResponseUtil.ok(address.getId()); } @@ -167,8 +175,12 @@ public class WxAddressController extends GetRegionService { if (id == null) { return ResponseUtil.badArgument(); } + LitemallAddress litemallAddress = addressService.query(userId, id); + if (litemallAddress == null) { + return ResponseUtil.badArgumentValue(); + } - addressService.delete(userId, id); + addressService.delete(id); return ResponseUtil.ok(); } } \ No newline at end of file diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAftersaleController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAftersaleController.java index 9b51f485..ba11bf9c 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAftersaleController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAftersaleController.java @@ -94,6 +94,9 @@ public class WxAftersaleController { } LitemallOrder order = orderService.findById(userId, orderId); + if (order == null){ + return ResponseUtil.badArgumentValue(); + } List orderGoodsList = orderGoodsService.queryByOid(orderId); LitemallAftersale aftersale = aftersaleService.findByOrderId(userId, orderId); @@ -129,9 +132,6 @@ public class WxAftersaleController { if(order == null){ return ResponseUtil.badArgumentValue(); } - if(!order.getUserId().equals(userId)){ - return ResponseUtil.badArgumentValue(); - } // 订单必须完成才能进入售后流程。 if(!OrderUtil.isConfirmStatus(order) && !OrderUtil.isAutoConfirmStatus(order)){ @@ -177,7 +177,7 @@ public class WxAftersaleController { if(id == null){ return ResponseUtil.badArgument(); } - LitemallAftersale aftersaleOne = aftersaleService.findById(id); + LitemallAftersale aftersaleOne = aftersaleService.findById(userId, id); if(aftersaleOne == null){ return ResponseUtil.badArgument(); } diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCartController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCartController.java index 0e888959..f1d933c4 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCartController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCartController.java @@ -258,9 +258,6 @@ public class WxCartController { if (userId == null) { return ResponseUtil.unlogin(); } - if (cart == null) { - return ResponseUtil.badArgument(); - } Integer productId = cart.getProductId(); Integer number = cart.getNumber().intValue(); Integer goodsId = cart.getGoodsId(); @@ -274,7 +271,7 @@ public class WxCartController { //判断是否存在该订单 // 如果不存在,直接返回错误 - LitemallCart existCart = cartService.findById(id); + LitemallCart existCart = cartService.findById(userId, id); if (existCart == null) { return ResponseUtil.badArgumentValue(); } @@ -448,7 +445,7 @@ public class WxCartController { if (cartId == null || cartId.equals(0)) { checkedGoodsList = cartService.queryByUidAndChecked(userId); } else { - LitemallCart cart = cartService.findById(cartId); + LitemallCart cart = cartService.findById(userId, cartId); if (cart == null) { return ResponseUtil.badArgumentValue(); } diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCouponController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCouponController.java index a15b1d24..ee0fa5be 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCouponController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCouponController.java @@ -139,7 +139,7 @@ public class WxCouponController { if (cartId == null || cartId.equals(0)) { checkedGoodsList = cartService.queryByUidAndChecked(userId); } else { - LitemallCart cart = cartService.findById(cartId); + LitemallCart cart = cartService.findById(userId, cartId); if (cart == null) { return ResponseUtil.badArgumentValue(); } diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFootprintController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFootprintController.java index 327439fa..f9fa73a3 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFootprintController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFootprintController.java @@ -54,7 +54,7 @@ public class WxFootprintController { if (footprintId == null) { return ResponseUtil.badArgument(); } - LitemallFootprint footprint = footprintService.findById(footprintId); + LitemallFootprint footprint = footprintService.findById(userId, footprintId); if (footprint == null) { return ResponseUtil.badArgumentValue(); diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGrouponController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGrouponController.java index 0194bcc5..57765f56 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGrouponController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxGrouponController.java @@ -87,7 +87,7 @@ public class WxGrouponController { return ResponseUtil.unlogin(); } - LitemallGroupon groupon = grouponService.queryById(grouponId); + LitemallGroupon groupon = grouponService.queryById(userId, grouponId); if (groupon == null) { return ResponseUtil.badArgumentValue(); }