62,047
社区成员
发帖
与我相关
我的任务
分享
declare @gdp_syCount bigint--剩余总额
declare @CurrentPrice_ml decimal(18,2) /*--当前价--*/
declare @Number decimal(18,2) /*--购买数量--*/
declare @MoneyCompoundGold decimal(18,2) /*--当前用户总--*/
declare @SystemInfo11 bit ----是否自动------
select @gdp_syCount=dbo.GetDecimal(SystemInfo16)-dbo.GetDecimal(SystemInfo46),@CurrentPrice_ml=SystemInfo17,@SystemInfo11=SystemInfo11 from YH_SystemInfo where ID=1
if @gdp_syCount<=0
return
if @CurrentPrice_ml>=4
return
if @SystemInfo11=0
return
select @MoneyCompoundGold=MoneyCompoundGold from YH_Personnel where ID=@PersonnelID
if @MoneyCompoundGold>=@GGB_Nub
set @Number=@GGB_Nub/@CurrentPrice_ml
else
set @Number=@MoneyCompoundGold/@CurrentPrice_ml
if @Number<=0
return
set @Number=dbo.GetInt(@Number)
set @GGB_Nub=@Number*@CurrentPrice_ml
if @MoneyCompoundGold-@GGB_Nub<0 --小于0则返回不执行
return
insert into YH_GdpTransaction(yhGUID,PersonnelID,Transaction01,Transaction02,Transaction03,Transaction04,Transaction05,Transaction11)
values (NEWID(),@PersonnelID,@CurrentPrice_ml,@Number,@GGB_Nub,1,2,GETDATE())
update YH_Personnel set MoneyCompoundGold=dbo.GetDecimal(MoneyCompoundGold)-@GGB_Nub,
MoneyGDP=dbo.GetDecimal(MoneyGDP)+@Number where ID=@PersonnelID
insert into YH_TakeMoney(yhGUID,PersonnelID,EventType,Money,Currency,Remark,Status,Editor,TM01,MER02)
values (NEWID(),@PersonnelID,52,-@GGB_Nub,5,'扣除积分:'+CONVERT(nvarchar,@GGB_Nub)+' 获得XX数量:'+CONVERT(nvarchar,@Number),2,@PersonnelID,@PersonnelID,'auto')
--同一时间戳,执行了2次
declare @s int
exec BuyEDA @PersonnelID,@Number,@s out