| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace addons\HiGo\common\models;
- use Yii;
- /**
- * This is the model class for table "{{%addons_higo_hibei_log}}".
- *
- * @property int $id
- * @property int $mall_id
- * @property string $change_type 操作类型:add-增加,sub-减少
- * @property float $change_num 操作数量
- * @property string $desc 变动说明
- * @property string $from_type 来源类型
- * @property int $status 状态,-1:失效,1:正常,2:冻结
- * @property int $created_at 添加时间戳
- * @property int $updated_at 更新时间戳
- * @property string $setting 系统设置
- */
- class HigoHibeiLog extends \common\models\base\BaseActiveRecord
- {
- const FROM_TYPE_AIRDROP = 'airdrop'; //空投
- const FROM_TYPE_DESTROY = 'destroy'; //销毁
- const FROM_TYPE_TRANSFER_DESTROY = 'transfer_destroy'; //转让销毁
- const FROM_TYPE_ORDER = 'order'; // 商城订单赠送
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_higo_hibei_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['change_num'], 'number'],
- [['change_type'], 'string', 'max' => 12],
- [['desc', 'from_type'], 'string', 'max' => 255],
- [['setting'],'string']
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'change_type' => 'Change Type',
- 'change_num' => 'Change Num',
- 'desc' => 'Desc',
- 'from_type' => 'From Type',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- /**
- * 保存数据
- * @Author: zmz
- * @DateTime: 2022/11/16 12:13
- * @Copyright: copyright (c) 2022 广东七件事集团
- * @param array $params
- * @return bool
- */
- public static function setData(array $params){
- try{
- if(isset($params['id']) && $params['id']) {
- $model = self::findOne(['id' => $params['id']]);
- if (empty($model)) throw new \Exception('服务不存在或已删除');
- }else{
- $model = new self();
- $model->loadDefaultValues();
- }
- if(!$model->load($params,'') || !$model->save()){
- throw new \Exception($model->getErrorMessage());
- }
- return $model;
- }catch(\Exception $e){
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- }
|