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

fix: #341

parent 5e0bd4c0
......@@ -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) {
......
......@@ -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<LitemallAftersale> queryList(Integer userId, Short status, Integer page, Integer limit, String sort, String order) {
LitemallAftersaleExample example = new LitemallAftersaleExample();
LitemallAftersaleExample.Criteria criteria = example.or();
......
......@@ -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<Integer> idsList, Boolean checked) {
LitemallCartExample example = new LitemallCartExample();
example.or().andUserIdEqualTo(userId).andProductIdIn(idsList).andDeletedEqualTo(false);
......
......@@ -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);
}
......
......@@ -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);
}
/**
* 返回某个发起的团购参与人数
*
......
......@@ -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<LitemallOrderGoods> orderGoodsList = orderGoodsService.findByOidAndGid(orderId, goodsId);
int size = orderGoodsList.size();
......
......@@ -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
......@@ -94,6 +94,9 @@ public class WxAftersaleController {
}
LitemallOrder order = orderService.findById(userId, orderId);
if (order == null){
return ResponseUtil.badArgumentValue();
}
List<LitemallOrderGoods> 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();
}
......
......@@ -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();
}
......
......@@ -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();
}
......
......@@ -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();
......
......@@ -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();
}
......
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