兴国资源网 Design By www.nnzcdc.com
即以游客身份登录网站时以cookie的方式存储购物车,而以登录用户的身份进入时将购物车信息存储到数据库中去,若是先以游客身份完成购物再登录继续购物,则将cookies购物车存入数据库;
其中涉及到的存储过程主要如下:
一:已登录会员添加商品到购物车功能:
复制代码 代码如下:
/* @store_sum表示要添加的商品数量,添加同时确认购物车中自己已有的数量与将要加入的数量之和是否超过库存 */
CREATE proc ncp_Cart_Add
(
@store_id int,
@store_sum int=1,
@member_id int
)
as
DECLARE @Amount int
DECLARE @NowAmount int
Begin
select @Amount=(select amount from ncp_store where id=@store_id)
IF EXISTS(SELECT 1 FROM [ncp_cart] WHERE store_id=@store_id and member_id=@member_id)
Begin
select @NowAmount=(select store_sum+@store_sum from ncp_cart WHERE store_id=@store_id and member_id=@member_id)
if @NowAmount>@Amount
return 0
else
UPDATE [ncp_cart] SET store_sum=store_sum+@store_sum,addtime=getDate() where store_id=@store_id and member_id=@member_id
return 1
End
ELSE
Begin
select @NowAmount=(select store_sum from ncp_cart WHERE store_id=@store_id and member_id=@member_id)
if @NowAmount>@Amount
return 0
else
INSERT INTO [ncp_cart](store_id,store_sum,member_id) values(@store_id,@store_sum,@member_id)
return 1
END
End
GO
二:购物车的删除功能
复制代码 代码如下:
/* type 为1是全部删 0时只删一个 */
CREATE PROCEDURE ncp_Cart_Del
@type int=0,
@store_id int ,
@member_id int
AS
begin
if @type=0
delete from [ncp_cart] where store_id=@store_id and member_id=@member_id
else
delete from [ncp_cart] where member_id=@member_id
End
GO
其中涉及到的存储过程主要如下:
一:已登录会员添加商品到购物车功能:
复制代码 代码如下:
/* @store_sum表示要添加的商品数量,添加同时确认购物车中自己已有的数量与将要加入的数量之和是否超过库存 */
CREATE proc ncp_Cart_Add
(
@store_id int,
@store_sum int=1,
@member_id int
)
as
DECLARE @Amount int
DECLARE @NowAmount int
Begin
select @Amount=(select amount from ncp_store where id=@store_id)
IF EXISTS(SELECT 1 FROM [ncp_cart] WHERE store_id=@store_id and member_id=@member_id)
Begin
select @NowAmount=(select store_sum+@store_sum from ncp_cart WHERE store_id=@store_id and member_id=@member_id)
if @NowAmount>@Amount
return 0
else
UPDATE [ncp_cart] SET store_sum=store_sum+@store_sum,addtime=getDate() where store_id=@store_id and member_id=@member_id
return 1
End
ELSE
Begin
select @NowAmount=(select store_sum from ncp_cart WHERE store_id=@store_id and member_id=@member_id)
if @NowAmount>@Amount
return 0
else
INSERT INTO [ncp_cart](store_id,store_sum,member_id) values(@store_id,@store_sum,@member_id)
return 1
END
End
GO
二:购物车的删除功能
复制代码 代码如下:
/* type 为1是全部删 0时只删一个 */
CREATE PROCEDURE ncp_Cart_Del
@type int=0,
@store_id int ,
@member_id int
AS
begin
if @type=0
delete from [ncp_cart] where store_id=@store_id and member_id=@member_id
else
delete from [ncp_cart] where member_id=@member_id
End
GO
兴国资源网 Design By www.nnzcdc.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
兴国资源网 Design By www.nnzcdc.com
暂无评论...
更新日志
2024年10月11日
2024年10月11日
- 谭咏麟.1988-心手相连【宝丽金】【WAV+CUE】
- NewViennaOctetViennaWindSoloists-TheDeccaRecordings(2024)18CD[24-48][FLAC]--10
- 骅梓1996-不要匆忙(正东版)[红星生产社][WAV+CUE]
- 黑月追风1993-黑月追风[波丽佳音][WAV+CUE]
- 《直到黎明:复刻版》PS4&5图形对比:变化有点大
- 《寂静岭2:重制版》发售宣传片 三角头压迫感再临
- B站UP主《黑神话》沙地上笔练书法:撰写“悟空”
- 焦淼《“永恒的旋律”国家大剧院合唱团经典作品音乐会》[320K/MP3][101.62MB]
- 焦淼《“永恒的旋律”国家大剧院合唱团经典作品音乐会》[FLAC/分轨][252.67MB]
- 好舒服宝宝《好舒服宝宝音乐, Vol.5》[320K/MP3][28.02MB]
- 群星.2003-光阴的故事(陈复明,陈志远经典作品辑)【华纳】【WAV+CUE】
- 叶欢.1995-爱疯了【飞碟】【WAV+CUE】
- 赖慧如.2024-坚疕【发现梦想】【FLAC分轨】
- 若羚1996-痛心·心痛[海洋唱片][WAV+CUE]
- 南台湾小姑娘1996-爱情先天免疫[大旗][WAV+CUE]