| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace common\models\statistics;
- use common\enums\StatusEnum;
- use Yii;
- /**
- * This is the model class for table "qimall_payment_type_refund_statistics".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $payment_type 支付方式
- * @property string $payment_identifier 数据唯一性标识符(支付方式加具体的支付方法拼接而成,如果是组合支付则用 , 分割,例如:7-WEIXIN_XCX,16-W06-CASHIER)
- * @property string $trade_type 聚合支付具体的支付方式
- * @property int $is_pay_group
- * @property int $created_at
- * @property int $updated_at
- */
- class PaymentTypeRefundStatistics extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'qimall_payment_type_refund_statistics';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'status', 'payment_type', 'is_pay_group', 'created_at', 'updated_at'], 'integer'],
- [['payment_identifier'], 'string', 'max' => 255],
- [['trade_type'], 'string', 'max' => 100],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'status' => 'Status',
- 'payment_type' => 'Payment Type',
- 'payment_identifier' => 'Payment Identifier',
- 'trade_type' => 'Trade Type',
- 'is_pay_group' => 'Is Pay Group',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- /**
- * @param array $data
- *
- * @return self
- */
- public static function setData(array $data): self
- {
- $model = self::findOne(['payment_identifier' => $data['payment_identifier'], 'status' => StatusEnum::ENABLED, 'mall_id' => $data['mall_id']]);
- if (!$model) {
- $model = new self();
- $model->loadDefaultValues();
- $model->load($data, '');
- if (!$model->save()) {
- throw new \RuntimeException('数据写入失败');
- }
- }
- return $model;
- }
- }
|