61 lines
1.7 KiB
PHP
61 lines
1.7 KiB
PHP
<?php
|
|
namespace Yunshop\CulturalSpace\models;
|
|
use app\common\facades\Setting;
|
|
use app\common\models\BaseModel;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class CulturalFund extends BaseModel
|
|
{
|
|
public $table = 'yz_cultural_fund';
|
|
public $timestamps = true;
|
|
public $casts = [
|
|
'created_at' => 'datetime:Y-m-d H:i:s',
|
|
'updated_at' => 'datetime:Y-m-d H:i:s',
|
|
];
|
|
public function getfund(){
|
|
$result = self::uniacid()
|
|
->first();
|
|
if(empty($result)){
|
|
$set = Setting::get('plugin.cultural_space_set');
|
|
$result=[
|
|
'uniacid'=>\YunShop::app()->uniacid,
|
|
'last_fee'=>$set['fund_start_price']??0,
|
|
'current_fee'=>$set['fund_start_price']??0,
|
|
'fund_money'=>0,
|
|
'voucher_number'=>0,
|
|
'history_number'=>0,
|
|
'created_at'=>time(),
|
|
'updated_at'=>time()
|
|
];
|
|
if($result['last_fee']!=0){
|
|
self::insert($result);
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
/***
|
|
* 保存数据
|
|
* @param $data
|
|
* @return bool
|
|
*
|
|
*/
|
|
public function SaveData($data){
|
|
|
|
$result = self::uniacid()
|
|
->update($data);
|
|
$this->saveLog($data);
|
|
return $result;
|
|
}
|
|
|
|
public function saveLog($data){
|
|
$uniacid=\YunShop::app()->uniacid;
|
|
$data['up_voucher_number']=$data['voucher_number'];
|
|
$data['up_current_fee']=$data['current_fee'];
|
|
$data['fund_multiple']=0;
|
|
$data['uniacid']=$uniacid;
|
|
$data['created_at']=time();
|
|
$data['updated_at']=time();
|
|
DB::table('yz_cultural_fund_increase_log')->insert($data);
|
|
}
|
|
} |