|
@@ -1872,6 +1872,8 @@ class Party extends Api
|
|
|
//热度值
|
|
|
$hotValue = 0;
|
|
|
|
|
|
+ Db::startTrans();
|
|
|
+
|
|
|
if($is_back == 1) {
|
|
|
// 获取背包礼物信息
|
|
|
$giftbackInfo = Db::name('gift_back')->field('gift_id')->where('id',$gift_id)->find();
|
|
@@ -1882,31 +1884,17 @@ class Party extends Api
|
|
|
|
|
|
// 随机获取一个礼物
|
|
|
$allCount = $number*$userCount;
|
|
|
- $giftbackList = Db::name('gift_back')->field('id,value,name,image,gif_image,number')->where(["gift_id"=>$backGiftId,"user_id"=>$userauthid,'is_use'=>0])->limit($allCount)->order('id asc')->select();
|
|
|
-
|
|
|
- $giftInfo = isset($giftbackList[0]) ? $giftbackList[0] : [];
|
|
|
- $gift_realinfo = Db::name('gift')->field('is_baobi')->where('id',$backGiftId)->find();
|
|
|
- $giftInfo['is_baobi'] = $gift_realinfo ? $gift_realinfo['is_baobi'] : 0;
|
|
|
-
|
|
|
- $giftcount = 0;
|
|
|
- $giftList = [];
|
|
|
-
|
|
|
- if(!empty($giftbackList)) {
|
|
|
- foreach($giftbackList as $k => $v) {
|
|
|
- $giftList[$k] = $v;
|
|
|
-
|
|
|
- $giftcount += $v["number"];
|
|
|
- if($giftcount >= $allCount) {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ $giftbackList = Db::name('gift_back')->field('id,value,name,image,gif_image,number')->where(["gift_id"=>$backGiftId,"user_id"=>$userauthid,'is_use'=>0])->limit($allCount)->order('id asc')->lock(true)->select();
|
|
|
|
|
|
- if($giftcount < $allCount)
|
|
|
+ if(count($giftbackList) < $allCount)
|
|
|
{
|
|
|
+ Db::rollback();
|
|
|
$this->error("背包数量不足");
|
|
|
}
|
|
|
|
|
|
+ $giftInfo = isset($giftbackList[0]) ? $giftbackList[0] : [];
|
|
|
+ $giftInfo['is_baobi'] = 0;
|
|
|
+
|
|
|
$giftValue = $giftInfo["value"] * $number;
|
|
|
$getValue = $giftValue;
|
|
|
|
|
@@ -1957,7 +1945,7 @@ class Party extends Api
|
|
|
|
|
|
//
|
|
|
$returnData = [];
|
|
|
- Db::startTrans();
|
|
|
+
|
|
|
try {
|
|
|
|
|
|
|
|
@@ -1975,20 +1963,14 @@ class Party extends Api
|
|
|
foreach($user_id_arr as $user_id_key => $user_id) {
|
|
|
|
|
|
if($is_back == 1) {
|
|
|
- $b=0;
|
|
|
- foreach($giftList as $k => $v) {
|
|
|
- for($a=1;$a<=$v["number"];$a++) {
|
|
|
- $b++;
|
|
|
- $num = $v["number"] - $a;
|
|
|
- if($num > 0) {
|
|
|
- $res1 = Db::name('gift_back')->where(["id"=>$v["id"]])->setDec("number");
|
|
|
- } else {
|
|
|
- $res1 = Db::name('gift_back')->where(["id"=>$v["id"]])->delete();
|
|
|
- }
|
|
|
- if($b == $number) break;
|
|
|
- }
|
|
|
+ $giftback_ids = array_column($giftbackList,'id');
|
|
|
|
|
|
+ $res1 = Db::name('gift_back')->where(["id"=>$giftback_ids])->delete();
|
|
|
+ if(!$res1){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('背包送礼物失败');
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
$res1 = true;
|
|
|
|
|
@@ -2026,6 +2008,10 @@ class Party extends Api
|
|
|
$data['task_status'] = 0;
|
|
|
$data["createtime"] = time();
|
|
|
$res5 = Db::name('gift_user_party')->insertGetId($data);
|
|
|
+ if(!$res5){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('送礼物失败');
|
|
|
+ }
|
|
|
|
|
|
//大礼物飘屏
|
|
|
//$this->bigGiftNotice($this->auth->nickname,$touserInfo['nickname'],$partyInfo,$data);
|