| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace addons\Mch\common\models;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_mch_refund_address".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $mch_id 多商户id
- * @property string $refund_name 退货名称
- * @property string $name 联系人
- * @property string $mobile 退换货手机号
- * @property string $address 退换货地址
- * @property int $status 状态[0禁用 1启用 -1删除]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- */
- class MchRefundAddress extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_mch_refund_address}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'mch_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['refund_name', 'name', 'address'], 'string', 'max' => 255],
- [['mobile'], 'string', 'max' => 11],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'mch_id' => '多商户id',
- 'refund_name' => '退货名称',
- 'name' => '联系人',
- 'mobile' => '退换货手机号',
- 'address' => '退换货地址',
- 'status' => '状态[0禁用 1启用 -1删除]',
- 'created_at' => '创建时间',
- 'updated_at' => '修改时间',
- ];
- }
- public static function setData(array $params)
- {
- try {
- if (!empty($params['id'])) {
- $where = ['id' => $params['id'], ['status' => StatusEnum::ENABLED]];
- if (isset($params['mall_id'])) $where[] = ['mall_id' => $params['mall_id']];
- if (isset($params['store_id'])) $where[] = ['store_id' => $params['store_id']];
- $model = self::findOne($where);
- if (empty($model)) throw new \Exception('服务不存在或已删除');
- } else {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '') || !$model->save()) throw new \PHPUnit\Util\Exception($model->getErrorMessage());
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|