| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace common\models\platform;
- use Yii;
- /**
- * This is the model class for table "{{%platform_finance_day}}".
- *
- *
- * @property int $id
- * @property float $add_money 收入,单位:元
- * @property float $sub_money 支出,单位:元
- * @property float $withdraw_money 已提现金额,单位:元
- * @property float $add_addons_pay 应用付费收入,单位:元
- * @property float $add_template 模板收入,单位:元
- * @property int $date 日期,年月日
- * @property int|null $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at 添加时间戳
- * @property int $updated_at 更新时间戳
- */
- class PlatformFinanceDay extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%platform_finance_day}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['add_money', 'sub_money', 'withdraw_money', 'add_addons_pay', 'add_template'], 'number'],
- [['date', 'status', 'created_at', 'updated_at'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'add_money' => '收入,单位:元',
- 'sub_money' => '支出,单位:元',
- 'withdraw_money' => '已提现金额,单位:元',
- 'add_addons_pay' => '应用付费收入,单位:元',
- 'add_template' => '模板收入,单位:元',
- 'date' => '日期,年月日',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'created_at' => '添加时间戳',
- 'updated_at' => '更新时间戳',
- ];
- }
- /**
- * 保存数据
- * @Author: lun
- * @DateTime: 2022/3/3 0003 18:30
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $data
- * @return bool
- */
- public static function setData($data) {
- try {
- $date = date('ymd', time());
- $model = self::find()->where(['date' => $date])->one();
- if (empty($model)) {
- $model = new self();
- $model->date = $date;
- }
- // 循环赋值
- foreach ($model as $key => $value) {
- if (isset($data[$key]) && !empty($data[$key])) $model->$key += $data[$key];
- }
- if (!$model->save()) {
- self::$static_error = $model->getErrorMessage();
- return false;
- }
- return true;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|