| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- namespace addons\WriteOff\common\models;
- use Yii;
- use common\enums\StatusEnum;
- /**
- * This is the model class for table "{{%addons_write_off_member_log}}".
- *
- * @property int $id ID
- * @property int $mall_id 商城ID
- * @property int $setting_id 设置ID
- * @property int $goods_id 商品ID
- * @property int $user_id 用户ID
- * @property float $change_num 操作数量
- * @property float $current_num 当前数量
- * @property string $order_no 订单号
- * @property string $source_table 来源表
- * @property int $source_table_id 操作来源业务id
- * @property string $desc 说明
- * @property int $status 状态[-1删除; 0禁用; 1正常]
- * @property int $created_at 创建时间
- * @property int $updated_at 更新时间
- */
- class WriteOffMemberLog extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_write_off_member_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'setting_id', 'goods_id', 'user_id', 'source_table_id', 'status', 'created_at', 'updated_at','store_id','code'], 'integer'],
- [['change_num', 'current_num'], 'number'],
- [['order_no'], 'string', 'max' => 64],
- [['change_type'], 'string', 'max' => 12],
- [['source_table', 'desc'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'setting_id' => 'Setting ID',
- 'goods_id' => 'Goods ID',
- 'user_id' => 'User ID',
- 'change_num' => 'Change Num',
- 'current_num' => 'Current Num',
- 'order_no' => 'Order No',
- 'source_table' => 'Source Table',
- 'source_table_id' => 'Source Table ID',
- 'desc' => 'Desc',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'change_type' => 'Change Type',
- 'store_id' => 'Store Id',
- ];
- }
- /**
- * 保存数据
- * @Author: lun
- * @DateTime: 2021/10/20 0020 18:01
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param array $params
- * @return AddonsBossLevel|bool
- */
- public static function setData(array $params){
- $trans = Yii::$app->db->beginTransaction();
- try{
- if(!empty($params['id'])){
- $model = self::findOne(['and',['id' => $params['id'],'mall_id' => $params['mall_id']],['<>','status',StatusEnum::DELETE]]);
- if(empty($model)) throw new \Exception('数据不存在或已删除');
- }else{
- $model = new self();
- $model->loadDefaultValues();
- $model->mall_id = $params['mall_id'];
- }
- if(!$model->load($params,'') || !$model->save()){
- throw new \Exception($model->getErrorMessage());
- }
- $trans->commit();
- return $model;
- }catch(\Exception $e){
- $trans->rollBack();
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|