|
@@ -51,6 +51,7 @@ class Eggnew extends Api
|
|
|
|
|
|
|
|
|
$num = $this->request->request("num");
|
|
|
+ $type = $this->request->request("type",1);
|
|
|
$party_id = $this->request->request("party_id", 0);
|
|
|
if($num <=0) {
|
|
|
$this->error("参数错误");
|
|
@@ -68,42 +69,27 @@ class Eggnew extends Api
|
|
|
if($redisconfig['redis_selectdb'] > 0){
|
|
|
$redis->select($redisconfig['redis_selectdb']);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
$do_no = date("YmdHis").rand(10000,99999);
|
|
|
- $userinfo = \app\common\model\User::lock(true)->find($this->auth->id);
|
|
|
- if($userinfo->hammer < $num) {
|
|
|
- $this->error("小金锤数量不足!");
|
|
|
- }
|
|
|
|
|
|
- for($i=1;$i<=$num;$i++) {
|
|
|
- $redis->lpop("hammer_num_".$user_id);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
|
|
|
- $jackpot = \app\common\model\EggJackpot::where(["status"=>1])->find();
|
|
|
+ $jackpot = \app\common\model\EggJackpot::where(["status"=>1,'type'=>$type])->find();
|
|
|
if($jackpot) {
|
|
|
- \app\common\model\EggJackpot::order("id","asc")->find();
|
|
|
+
|
|
|
$jackpot_id = $jackpot["id"];
|
|
|
} else {
|
|
|
- $jackpotInfo = \app\common\model\EggJackpot::order("id","asc")->find();
|
|
|
+ $jackpotInfo = \app\common\model\EggJackpot::where('type',$type)->order('weigh asc,id asc')->find();
|
|
|
$jackpot_id = $jackpotInfo["id"];
|
|
|
- \app\common\model\EggJackpot::update(["status"=>1],["id"=>$jackpot_id]);
|
|
|
+ \app\common\model\EggJackpot::update(["status"=>1],["id"=>$jackpot_id]);
|
|
|
}
|
|
|
|
|
|
- $currentNotUsedWhere = [];
|
|
|
- if (in_array($num, [1, 10])) {
|
|
|
-
|
|
|
- $priceSection = $num == 1 ? '11111' : '88888';
|
|
|
- $currentNotUsedCount = \app\common\model\EggGift::where(["Jackpot_id" => $jackpot_id, "is_use" => 0])->where('price', '<=', $priceSection)->count();
|
|
|
- if ($currentNotUsedCount >= $num) {
|
|
|
- $currentNotUsedWhere['price'] = ['<=', $priceSection];
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- $jackpotGift = \app\common\model\EggGift::where(["Jackpot_id"=>$jackpot_id,"is_use"=>0])->where($currentNotUsedWhere)->select();
|
|
|
+ $jackpotGift = \app\common\model\EggGift::where(["Jackpot_id"=>$jackpot_id,"is_use"=>0])->select();
|
|
|
|
|
|
$giftCount = count($jackpotGift);
|
|
|
$next_jackpot_id = $this->getNextJackpot($jackpot_id);
|