Commit 6d35c40e authored by Junling Bu's avatar Junling Bu
Browse files

fix: #341

parent 5e0bd4c0
...@@ -39,10 +39,8 @@ public class LitemallAddressService { ...@@ -39,10 +39,8 @@ public class LitemallAddressService {
return addressMapper.updateByPrimaryKeySelective(address); return addressMapper.updateByPrimaryKeySelective(address);
} }
public void delete(Integer userId, Integer id) { public void delete(Integer id) {
LitemallAddressExample example = new LitemallAddressExample(); addressMapper.logicalDeleteByPrimaryKey(id);
example.or().andUserIdEqualTo(userId).andIdEqualTo(id).andDeletedEqualTo(false);
addressMapper.logicalDeleteByExample(example);
} }
public LitemallAddress findDefault(Integer userId) { public LitemallAddress findDefault(Integer userId) {
......
...@@ -23,6 +23,12 @@ public class LitemallAftersaleService { ...@@ -23,6 +23,12 @@ public class LitemallAftersaleService {
return aftersaleMapper.selectByPrimaryKey(id); 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<LitemallAftersale> queryList(Integer userId, Short status, Integer page, Integer limit, String sort, String order) { public List<LitemallAftersale> queryList(Integer userId, Short status, Integer page, Integer limit, String sort, String order) {
LitemallAftersaleExample example = new LitemallAftersaleExample(); LitemallAftersaleExample example = new LitemallAftersaleExample();
LitemallAftersaleExample.Criteria criteria = example.or(); LitemallAftersaleExample.Criteria criteria = example.or();
......
...@@ -57,6 +57,12 @@ public class LitemallCartService { ...@@ -57,6 +57,12 @@ public class LitemallCartService {
return cartMapper.selectByPrimaryKey(id); 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<Integer> idsList, Boolean checked) { public int updateCheck(Integer userId, List<Integer> idsList, Boolean checked) {
LitemallCartExample example = new LitemallCartExample(); LitemallCartExample example = new LitemallCartExample();
example.or().andUserIdEqualTo(userId).andProductIdIn(idsList).andDeletedEqualTo(false); example.or().andUserIdEqualTo(userId).andProductIdIn(idsList).andDeletedEqualTo(false);
......
...@@ -28,6 +28,12 @@ public class LitemallFootprintService { ...@@ -28,6 +28,12 @@ public class LitemallFootprintService {
return footprintMapper.selectByPrimaryKey(id); 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) { public void deleteById(Integer id) {
footprintMapper.logicalDeleteByPrimaryKey(id); footprintMapper.logicalDeleteByPrimaryKey(id);
} }
......
...@@ -80,6 +80,19 @@ public class LitemallGrouponService { ...@@ -80,6 +80,19 @@ public class LitemallGrouponService {
return mapper.selectOneByExample(example); 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);
}
/** /**
* 返回某个发起的团购参与人数 * 返回某个发起的团购参与人数
* *
......
...@@ -289,7 +289,7 @@ public class WxOrderService { ...@@ -289,7 +289,7 @@ public class WxOrderService {
return ResponseUtil.fail(GROUPON_JOIN, "团购活动已经参加!"); return ResponseUtil.fail(GROUPON_JOIN, "团购活动已经参加!");
} }
// (2)不允许参加自己开团的团购 // (2)不允许参加自己开团的团购
LitemallGroupon groupon = grouponService.queryById(grouponLinkId); LitemallGroupon groupon = grouponService.queryById(userId, grouponLinkId);
if(groupon.getCreatorUserId().equals(userId)){ if(groupon.getCreatorUserId().equals(userId)){
return ResponseUtil.fail(GROUPON_JOIN, "团购活动已经参加!"); return ResponseUtil.fail(GROUPON_JOIN, "团购活动已经参加!");
} }
...@@ -912,6 +912,10 @@ public class WxOrderService { ...@@ -912,6 +912,10 @@ public class WxOrderService {
if (userId == null) { if (userId == null) {
return ResponseUtil.unlogin(); return ResponseUtil.unlogin();
} }
LitemallOrder order = orderService.findById(userId, orderId);
if (order == null) {
return ResponseUtil.badArgument();
}
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.findByOidAndGid(orderId, goodsId); List<LitemallOrderGoods> orderGoodsList = orderGoodsService.findByOidAndGid(orderId, goodsId);
int size = orderGoodsList.size(); int size = orderGoodsList.size();
......
...@@ -133,20 +133,28 @@ public class WxAddressController extends GetRegionService { ...@@ -133,20 +133,28 @@ public class WxAddressController extends GetRegionService {
return error; return error;
} }
if (address.getIsDefault()) {
// 重置其他收货地址的默认选项
addressService.resetDefault(userId);
}
if (address.getId() == null || address.getId().equals(0)) { if (address.getId() == null || address.getId().equals(0)) {
if (address.getIsDefault()) {
// 重置其他收货地址的默认选项
addressService.resetDefault(userId);
}
address.setId(null); address.setId(null);
address.setUserId(userId); address.setUserId(userId);
addressService.add(address); addressService.add(address);
} else { } else {
address.setUserId(userId); LitemallAddress litemallAddress = addressService.query(userId, address.getId());
if (addressService.update(address) == 0) { if (litemallAddress == null) {
return ResponseUtil.updatedDataFailed(); return ResponseUtil.badArgumentValue();
} }
if (address.getIsDefault()) {
// 重置其他收货地址的默认选项
addressService.resetDefault(userId);
}
address.setUserId(userId);
addressService.update(address);
} }
return ResponseUtil.ok(address.getId()); return ResponseUtil.ok(address.getId());
} }
...@@ -167,8 +175,12 @@ public class WxAddressController extends GetRegionService { ...@@ -167,8 +175,12 @@ public class WxAddressController extends GetRegionService {
if (id == null) { if (id == null) {
return ResponseUtil.badArgument(); 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(); return ResponseUtil.ok();
} }
} }
\ No newline at end of file
...@@ -94,6 +94,9 @@ public class WxAftersaleController { ...@@ -94,6 +94,9 @@ public class WxAftersaleController {
} }
LitemallOrder order = orderService.findById(userId, orderId); LitemallOrder order = orderService.findById(userId, orderId);
if (order == null){
return ResponseUtil.badArgumentValue();
}
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(orderId); List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(orderId);
LitemallAftersale aftersale = aftersaleService.findByOrderId(userId, orderId); LitemallAftersale aftersale = aftersaleService.findByOrderId(userId, orderId);
...@@ -129,9 +132,6 @@ public class WxAftersaleController { ...@@ -129,9 +132,6 @@ public class WxAftersaleController {
if(order == null){ if(order == null){
return ResponseUtil.badArgumentValue(); return ResponseUtil.badArgumentValue();
} }
if(!order.getUserId().equals(userId)){
return ResponseUtil.badArgumentValue();
}
// 订单必须完成才能进入售后流程。 // 订单必须完成才能进入售后流程。
if(!OrderUtil.isConfirmStatus(order) && !OrderUtil.isAutoConfirmStatus(order)){ if(!OrderUtil.isConfirmStatus(order) && !OrderUtil.isAutoConfirmStatus(order)){
...@@ -177,7 +177,7 @@ public class WxAftersaleController { ...@@ -177,7 +177,7 @@ public class WxAftersaleController {
if(id == null){ if(id == null){
return ResponseUtil.badArgument(); return ResponseUtil.badArgument();
} }
LitemallAftersale aftersaleOne = aftersaleService.findById(id); LitemallAftersale aftersaleOne = aftersaleService.findById(userId, id);
if(aftersaleOne == null){ if(aftersaleOne == null){
return ResponseUtil.badArgument(); return ResponseUtil.badArgument();
} }
......
...@@ -258,9 +258,6 @@ public class WxCartController { ...@@ -258,9 +258,6 @@ public class WxCartController {
if (userId == null) { if (userId == null) {
return ResponseUtil.unlogin(); return ResponseUtil.unlogin();
} }
if (cart == null) {
return ResponseUtil.badArgument();
}
Integer productId = cart.getProductId(); Integer productId = cart.getProductId();
Integer number = cart.getNumber().intValue(); Integer number = cart.getNumber().intValue();
Integer goodsId = cart.getGoodsId(); Integer goodsId = cart.getGoodsId();
...@@ -274,7 +271,7 @@ public class WxCartController { ...@@ -274,7 +271,7 @@ public class WxCartController {
//判断是否存在该订单 //判断是否存在该订单
// 如果不存在,直接返回错误 // 如果不存在,直接返回错误
LitemallCart existCart = cartService.findById(id); LitemallCart existCart = cartService.findById(userId, id);
if (existCart == null) { if (existCart == null) {
return ResponseUtil.badArgumentValue(); return ResponseUtil.badArgumentValue();
} }
...@@ -448,7 +445,7 @@ public class WxCartController { ...@@ -448,7 +445,7 @@ public class WxCartController {
if (cartId == null || cartId.equals(0)) { if (cartId == null || cartId.equals(0)) {
checkedGoodsList = cartService.queryByUidAndChecked(userId); checkedGoodsList = cartService.queryByUidAndChecked(userId);
} else { } else {
LitemallCart cart = cartService.findById(cartId); LitemallCart cart = cartService.findById(userId, cartId);
if (cart == null) { if (cart == null) {
return ResponseUtil.badArgumentValue(); return ResponseUtil.badArgumentValue();
} }
......
...@@ -139,7 +139,7 @@ public class WxCouponController { ...@@ -139,7 +139,7 @@ public class WxCouponController {
if (cartId == null || cartId.equals(0)) { if (cartId == null || cartId.equals(0)) {
checkedGoodsList = cartService.queryByUidAndChecked(userId); checkedGoodsList = cartService.queryByUidAndChecked(userId);
} else { } else {
LitemallCart cart = cartService.findById(cartId); LitemallCart cart = cartService.findById(userId, cartId);
if (cart == null) { if (cart == null) {
return ResponseUtil.badArgumentValue(); return ResponseUtil.badArgumentValue();
} }
......
...@@ -54,7 +54,7 @@ public class WxFootprintController { ...@@ -54,7 +54,7 @@ public class WxFootprintController {
if (footprintId == null) { if (footprintId == null) {
return ResponseUtil.badArgument(); return ResponseUtil.badArgument();
} }
LitemallFootprint footprint = footprintService.findById(footprintId); LitemallFootprint footprint = footprintService.findById(userId, footprintId);
if (footprint == null) { if (footprint == null) {
return ResponseUtil.badArgumentValue(); return ResponseUtil.badArgumentValue();
......
...@@ -87,7 +87,7 @@ public class WxGrouponController { ...@@ -87,7 +87,7 @@ public class WxGrouponController {
return ResponseUtil.unlogin(); return ResponseUtil.unlogin();
} }
LitemallGroupon groupon = grouponService.queryById(grouponId); LitemallGroupon groupon = grouponService.queryById(userId, grouponId);
if (groupon == null) { if (groupon == null) {
return ResponseUtil.badArgumentValue(); return ResponseUtil.badArgumentValue();
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment