微信红包发放

for($i=0;$i200){ $qz1=floor($rs[$i]['moneys']);//取整 $qz=floor($rs[$i]['moneys']/200);//取整 $qy=$rs[$i]['moneys']%200;//取余 $qy1=$rs[$i]['moneys']-$qz1;//有小数的时候用 $qy=$rs[$i]['moneys']%200+$qy1;//有小数的时候用 for($m=0;$m<$qz;$m++){ $money=200; $openid=$rs[$i]['open_id']; $sendResult=self::plguaguaLe($appid,$openid,$money);//调用发送红包的方法 if($sendResult['status']==0){//发送红包成功 $sql2="INSERT weixin_test_ggl(op_id,amount) VALUES ('".$rs[$i]['open_id']."',200)"; $this->db->query($sql2);$sql3 ="UPDATE wx_lottery_win set check_code='已兑奖' where uid='".$rs[$i]['open_id']."' and lottery_date BETWEEN '2016-09-20' and '".$end_time."' "; $this->db->query($sql3); } } if($qy>0){ $money=$qy; $openid=$rs[$i]['open_id']; $sendResult=self::plguaguaLe($appid,$openid,$money);//调用发送红包的方法 if($sendResult['status']==0){//发送红包成功 $sql3="INSERT weixin_test_ggl(op_id,amount) VALUES ('".$rs[$i]['open_id']."','".$qy."')"; $this->db->query($sql3); $sql4 ="UPDATE wx_lottery_win set check_code='已兑奖' where uid='".$rs[$i]['open_id']."' and lottery_date BETWEEN '2016-09-20' and '".$end_time."' "; $this->db->query($sql4); } } }else{ $money=$rs[$i]['moneys']; $openid=$rs[$i]['open_id']; $sendResult=self::plguaguaLe($appid,$openid,$money);//调用发送红包的方法 if($sendResult['status']==0){//发送红包成功 $sql4="INSERT weixin_test_ggl(op_id,amount) VALUES ('".$rs[$i]['open_id']."','".$rs[$i]['moneys']."')"; $this->db->query($sql4);$sql5 ="UPDATE wx_lottery_win set check_code='已兑奖' where uid='".$rs[$i]['open_id']."' and lottery_date BETWEEN '2016-09-20' and '".$end_time."' "; $this->db->query($sql5); } } }

你可能感兴趣的:(微信)