|
|
|
@ -1,13 +1,56 @@ |
|
|
|
package cn.chjyj.szwh.service.impl; |
|
|
|
|
|
|
|
import cn.chjyj.szwh.bean.Goods; |
|
|
|
import cn.chjyj.szwh.bean.User; |
|
|
|
import cn.chjyj.szwh.exception.ChException; |
|
|
|
import cn.chjyj.szwh.mapper.GoodsMapper; |
|
|
|
import cn.chjyj.szwh.mapper.UserMapper; |
|
|
|
import cn.chjyj.szwh.service.ShopCarService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class ShopCarServiceImpl implements ShopCarService { |
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
@Autowired |
|
|
|
private GoodsMapper goodsMapper; |
|
|
|
|
|
|
|
/** |
|
|
|
* 添加到购物车 |
|
|
|
* @param userIsli user_isli 用户isli标识码 |
|
|
|
* @param goodsIsli goods_isli 商品isli标识码 |
|
|
|
* @param useYears use_years 购买使用年限 |
|
|
|
* @return 11 用户不存在 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int addShopCart(String userIsli, String goodsIsli, String useYears) { |
|
|
|
// 提交的用户
|
|
|
|
User user = userMapper.getUserByIsli(userIsli); |
|
|
|
if(user==null){ |
|
|
|
return 11; |
|
|
|
} |
|
|
|
//商品
|
|
|
|
Goods goods = goodsMapper.getGoodsByIsli(goodsIsli); |
|
|
|
if(goods==null){ |
|
|
|
return 21; |
|
|
|
}else{ |
|
|
|
if(goods.getGoodsStatus()!=1){ |
|
|
|
//'该标的现不在上架中'
|
|
|
|
return 22; |
|
|
|
} |
|
|
|
if(goods.getContractStatus()!=1){ |
|
|
|
// 标的未申请合约关联,不可购买
|
|
|
|
return 23; |
|
|
|
} |
|
|
|
if(userIsli.equalsIgnoreCase(goods.getUserIslicode())){ |
|
|
|
// 您是标的的授权方,不可添加
|
|
|
|
return 24; |
|
|
|
} |
|
|
|
// 检查订单是否存在
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|