首页 > 代码库 > 接口3
接口3
抽奖 领取奖项
<?php//抽奖 中奖 require dirname(__FILE__).‘/../includes/common.inc.php‘; $_clean = array(); $_clean[‘userId‘] = _check($_POST[‘userId‘]);//用户ID $_clean[‘prizeId‘] = _check($_POST[‘prizeId‘]);//奖品id $_info = array(); $_data = array(); if ( $_clean[‘userId‘] > 0 && $_clean[‘prizeId‘] > 0 ) { $_info[‘state‘] = 0; $_info[‘info‘] = ‘‘; mysql_query("BEGIN"); $flag=0; //插入中奖记录 _query("INSERT INTO tb_thePrizeLog VALUES (null,‘{$_clean[‘userId‘]}‘,now(),‘来自Android‘,‘{$_clean[‘prizeId‘]}‘,1)"); //通过中将ID查找 商家ID $_sql = "SELECT * FROM tb_thePrize WHERE id = ‘{$_clean[‘prizeId‘]}‘ AND State = 1"; $_result = _query($_sql); $_rows = _fetch_array($_result); $_html = array(); $_html[‘company‘] = $_rows[‘company‘]; $_html[‘useIntegral‘] = $_rows[‘useIntegral‘];//在线抽奖中官方奖品抽奖需要的积分 $_html[‘thePrizeType‘] = $_rows[‘thePrizeType‘];//奖品类型 $_html[‘oneReward‘] = $_rows[‘oneReward‘];//单条奖励的分数 $_html[‘goodsId‘] = $_rows[‘goodsId‘];//商品ID $_html = _html($_html); if ( $_html[‘company‘] == 0 ) { //如果商家id等于0 更新账户易币 插入记录集 _query("UPDATE tb_user SET integral_easyhunt = integral_easyhunt - ‘{$_html[‘useIntegral‘]}‘ WHERE id = ‘{$_clean[‘userId‘]}‘"); _query("INSERT INTO tb_cashAndebLog VALUES (null,1,‘{$_clean[‘userId‘]}‘,now(),‘来自Android‘,‘在线抽奖‘,‘{$_html[‘useIntegral‘]}‘,0)"); } //如果中奖的是易币 更新账户易币 插入记录集 if ( $_html[‘thePrizeType‘] == 1 ) { _query("UPDATE tb_user SET integral_easyhunt = integral_easyhunt + ‘{$_html[‘oneReward‘]}‘ WHERE id = ‘{$_clean[‘userId‘]}‘"); _query("INSERT INTO tb_cashAndebLog VALUES (null,1,‘{$_clean[‘userId‘]}‘,now(),‘来自Android‘,‘在线抽奖‘,‘{$_html[‘oneReward‘]}‘,1)"); } elseif ( $_html[‘thePrizeType‘] == 2 ) { _query("UPDATE tb_user SET cash_easyhunt = cash_easyhunt + ‘{$_html[‘oneReward‘]}‘ WHERE id = ‘{$_clean[‘userId‘]}‘"); _query("INSERT INTO tb_cashAndebLog VALUES (null,2,‘{$_clean[‘userId‘]}‘,now(),‘来自Android‘,‘在线抽奖‘,‘{$_html[‘oneReward‘]}‘,1)"); //如果是物品 查出商品现价 可使用易币 商品邮费 } elseif ( $_html[‘thePrizeType‘] == 3 ) { $_sql1 = "SELECT * FROM tb_easyGoods WHERE id = ‘{$_html[‘goodsId‘]}‘"; $_result1 = _query($_sql1); $_rows1 = _fetch_array($_result1); $_html1 = array(); $_html1[‘goodsMoneyPrice‘] = $_rows1[‘goodsMoneyPrice‘]; $_html1[‘goodsIntegralPrice‘] = $_rows1[‘goodsIntegralPrice‘]; $_html1[‘goodsPostage‘] = $_rows1[‘goodsPostage‘]; $_html1 = _html($_html1); $year_code = array(‘A‘,‘B‘,‘C‘,‘D‘,‘E‘,‘F‘,‘G‘,‘H‘,‘I‘,‘J‘,‘K‘,‘L‘,‘M‘,‘N‘,‘O‘,‘P‘,‘Q‘,‘R‘,‘S‘,‘T‘,‘U‘,‘V‘,‘W‘,‘X‘,‘Y‘,‘Z‘); $_orderNumber = $year_code[intval(date(‘Y‘))-2014].strtoupper(dechex(date(‘m‘))).date(‘d‘).substr(time(),-5).substr(microtime(),2,5).sprintf(‘d‘,rand(0,99)); //如果都大于0 插入订单 if ( $_html1[‘goodsMoneyPrice‘] > 0 or $_html1[‘goodsIntegralPrice‘] > 0 or $_html1[‘goodsPostage‘] > 0 ) { _query("INSERT INTO tb_easyGoodsOrder VALUES (null,5,now(),‘来自Android‘,‘{$_html[‘company‘]}‘,‘{$_clean[‘userId‘]}‘,‘$_orderNumber‘,‘{$_html[‘goodsId‘]}‘,‘{$_html1[‘goodsMoneyPrice‘]}‘,‘{$_html1[‘goodsIntegralPrice‘]}‘,‘{$_html1[‘goodsPostage‘]}‘,1,‘抽奖中奖‘,0,0,0,‘抽奖‘,0,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘)"); } else { _query("INSERT INTO tb_easyGoodsOrder VALUES (null,5,now(),‘来自Android‘,‘{$_html[‘company‘]}‘,‘{$_clean[‘userId‘]}‘,‘$_orderNumber‘,‘{$_html[‘goodsId‘]}‘,0,0,0,1,‘抽奖中奖‘,0,0,1,‘抽奖‘,1,‘‘,‘‘,‘‘,‘‘,‘‘,‘‘)"); } } //更新抽奖商品的易币数 _query("UPDATE tb_thePrize SET totalReward = totalReward - oneReward WHERE id = ‘{$_clean[‘prizeId‘]}‘"); $flag=1; if($flag==1){ mysql_query("COMMIT"); $_data["state"] = 0; $_data[‘info‘] = ‘领取成功‘; }else{ mysql_query("ROLLBACK"); $_data[‘state‘] = 1; $_data[‘info‘] = ‘领取失败‘; } $_info[‘data‘] = $_data; } else { $_info[‘state‘] = 1; $_info[‘info‘] = ‘参数有误!‘; } echo _json($_info); _free_result($_result); _free_result($_result1); _close();?>
接口3
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。