First commit
This commit is contained in:
152
app/shop/model/LuckRecord.php
Executable file
152
app/shop/model/LuckRecord.php
Executable file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\farm\model\Coupon;
|
||||
use think\facade\Db;
|
||||
|
||||
class LuckRecord extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_luck_record';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-21 18:03
|
||||
*/
|
||||
public function getCouponTitleAttr($value,$data){
|
||||
|
||||
if(isset($data['coupon_id'])){
|
||||
|
||||
$coupon_model = new Coupon();
|
||||
|
||||
$title = $coupon_model->where(['id'=>$data['coupon_id']])->value('title');
|
||||
|
||||
return $title;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:24
|
||||
* @功能说明:添加奖品信息
|
||||
*/
|
||||
public function updateSome($id,$data,$uniacid){
|
||||
|
||||
$config_model = new LuckConfig();
|
||||
|
||||
$config_model->where(['luck_id'=>$id])->delete();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $k=>$v){
|
||||
|
||||
$v['uniacid'] = $uniacid;
|
||||
|
||||
$v['luck_id'] = $id;
|
||||
|
||||
$config_model->insert($v);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-26 16:14
|
||||
* @功能说明:中奖记录
|
||||
*/
|
||||
public function recordList($dis,$page=10){
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_user_list b','a.user_id = b.id','left')
|
||||
->where($dis)
|
||||
->field('a.*,b.nickName,b.avatarurl')
|
||||
->group('a.id')
|
||||
->order('a.id desc')
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user