|
@@ -20,8 +20,22 @@ class Gift extends Api
|
|
$this->gifttypeModel = new \app\common\model\GiftType();
|
|
$this->gifttypeModel = new \app\common\model\GiftType();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function test2(){
|
|
|
|
+ $user_id = $this->auth->id;
|
|
|
|
+ $gift_id = input('gift_id');
|
|
|
|
+ $pay_total = input('pay_total');
|
|
|
|
+
|
|
|
|
+ Db::startTrans();
|
|
|
|
+ $rs = $this->test($user_id,$gift_id,$pay_total);
|
|
|
|
+ if($rs !== true){
|
|
|
|
+ Db::rollback();
|
|
|
|
+ }
|
|
|
|
+ Db::commit();
|
|
|
|
+ dump($rs);
|
|
|
|
+ }
|
|
|
|
+
|
|
//gift_id必须是爆币礼物才可以
|
|
//gift_id必须是爆币礼物才可以
|
|
- public function test($user_id,$gift_id = 0,$pay_total = 10000){
|
|
|
|
|
|
+ public function test($user_id,$gift_id,$pay_total){
|
|
|
|
|
|
//奖项参数
|
|
//奖项参数
|
|
$conf_arr = Db::name('gift_baobi_config')->where('gift_id',$gift_id)->select();
|
|
$conf_arr = Db::name('gift_baobi_config')->where('gift_id',$gift_id)->select();
|
|
@@ -36,8 +50,9 @@ class Gift extends Api
|
|
'user_id' => $user_id,
|
|
'user_id' => $user_id,
|
|
'createtime' => ['BETWEEN',[$today_start,$today_end]],
|
|
'createtime' => ['BETWEEN',[$today_start,$today_end]],
|
|
];
|
|
];
|
|
- $today_data = Db::name('gift_baobi_log')->field('sum(pay_total) as today_pay_total,sum(baobi_total) as today_baobi_total')->where($map)->find('pay_total');
|
|
|
|
- if($today_data['today_baobi_total'] > $today_data['today_pay_total']){
|
|
|
|
|
|
+ $today_data = Db::name('gift_baobi_log')->field('IFNULL(sum(pay_total),0) as today_pay_total,IFNULL(sum(baobi_total),0) as today_baobi_total')->where($map)->find();
|
|
|
|
+ //dump($today_data);
|
|
|
|
+ if($today_data['today_baobi_total'] >= $today_data['today_pay_total']){
|
|
//爆币比消费还高了,不用抽奖了,记录个日志,返回。这里的日志仅用来记录今日消费 sum(pay_total)
|
|
//爆币比消费还高了,不用抽奖了,记录个日志,返回。这里的日志仅用来记录今日消费 sum(pay_total)
|
|
$data = [];
|
|
$data = [];
|
|
$data['user_id'] = $user_id;
|
|
$data['user_id'] = $user_id;
|