| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace addons\WriteOff\common\models;
- use Yii;
- use common\enums\StatusEnum;
- /**
- * This is the model class for table "{{%addons_write_off_award_log}}".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $user_id 用户id
- * @property float $achievement_sum 总业绩
- * @property float $award_money 奖励金额
- * @property int|null $is_settlement 是否已结算打款 1:是
- * @property int $created_at
- * @property int $updated_at
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- */
- class WriteOffAwardLog extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_write_off_award_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'is_settlement', 'created_at', 'updated_at', 'status'], 'integer'],
- [['achievement_sum', 'award_money','rate'], 'number'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'user_id' => 'User ID',
- 'achievement_sum' => 'Achievement Sum',
- 'award_money' => 'Award Money',
- 'is_settlement' => 'Is Settlement',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'status' => 'Status',
- ];
- }
- /**
- * 保存数据
- * @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;
- }
- }
- }
|