DB_51aspx/2014年/存储过程or函数/存储过程-游标-查询店铺里会员的优惠券信息.sql
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
GO
-- =============================================
-- Author: 李朴
-- Create date: 2014-3-27
-- Description: 取店铺里某个会员的优惠券信息
-- =============================================
alter PROCEDURE p_ticket
@sid int,--店铺主键id
@uid int,--用户主键id
@degreeNum int,---用户级别
@ttcMoney decimal,---用户总的消费金额
@ticketidStr varchar(100) output ---返回优惠券id主键字符串,使用英文逗号(,)隔开
AS
BEGIN
set @ticketidStr=''
declare @usertype int ---人群类型
declare @id int ---优惠券主键id
declare @consumeMoney int --消费金额
declare yb_ticketinfo cursor --声明游标
for
select id,userType,consumeMoney from wx_ucard_ticket where sId=@sid and beginDate<getdate() and endDate>=getdate() and dbo.ufn_syTimesByTicket(@uid,id)>0 order by id asc
open yb_ticketinfo
fetch next from yb_ticketinfo into @id,@usertype,@consumeMoney
while @@FETCH_STATUS=0 --循环
begin
if @usertype=@degreeNum or @usertype=0 --根据会员等级来
begin
set @ticketidStr =@ticketidStr+','+convert(varchar,@id)
end
else if @usertype=1001 --新开会员
begin
set @ticketidStr =@ticketidStr+','+convert(varchar,@id)
end
else if @usertype=1002 --开卡从未消费的会员
begin
if @ttcMoney=0
begin
set @ticketidStr =@ticketidStr+','+convert(varchar,@id)
end
end
else if @usertype=1003 -- 一个月未消费的会员
begin
---查询该会员一个月内是否有消费
declare @xfcs int
select @xfcs=count(1) from wx_ucard_users_consumeinfo where sId=@sid and uid=@uid and addTime<=getdate() and addTime>=dateadd(month,-1,getdate())
if @xfcs=0
begin
set @ticketidStr =@ticketidStr+','+convert(varchar,@id)
end
end
else if @usertype=2001 --单次消费满X元的会员
begin
declare @dcje float --单次消费金额
后面还有 34 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
