| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- namespace addons\CloudStock\common\models;
- use common\enums\StatusEnum;
- use Exception;
- use RuntimeException;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_cloud_stock_agent_order_refund".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $order_id 自提订单id
- * @property int $order_type 订单类型
- * @property int $user_id 用户id
- * @property string $order_no 退款编号
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $is_refund 是否已打款 -1 打款失败 0未打款 1打款成功
- * @property int $refund_at 打款时间
- * @property float $refund_price 退款金额
- * @property float $reality_refund_price 实际退款金额
- * @property int $created_at
- * @property int $updated_at
- */
- class CloudStockAgentOrderRefund extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'qimall_addons_cloud_stock_agent_order_refund';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'order_id', 'order_type', 'user_id', 'status', 'is_refund', 'refund_at', 'created_at', 'updated_at'], 'integer'],
- [['refund_price', 'reality_refund_price'], 'number'],
- [['order_no'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'order_id' => 'Order ID',
- 'order_type' => 'Order Type',
- 'user_id' => 'User ID',
- 'order_no' => 'Order No',
- 'status' => 'Status',
- 'is_refund' => 'Is Refund',
- 'refund_at' => 'Refund At',
- 'refund_price' => 'Refund Price',
- 'reality_refund_price' => 'Reality Refund Price',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- /**
- * @param array $params
- *
- * @return bool|self
- */
- public static function setData(array $params)
- {
- try {
- if (!empty($params['id'])) {
- $model = self::findOne(['id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if (!$model) {
- throw new RuntimeException('数据不存在或已删除');
- }
- if ($model->mall_id != $params['mall_id']) {
- throw new RuntimeException('不允许操作此数据');
- }
- } else {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '')) {
- throw new RuntimeException($model->getErrorMessage());
- }
- if (!$model->save()) {
- throw new RuntimeException($model->getErrorMessage());
- }
- return $model;
- } catch (Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|