| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace addons\CloudStock\common\models;
- use common\enums\StatusEnum;
- use common\models\common\PaymentTrade;
- use Exception;
- use RuntimeException;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_cloud_stock_batch_fill_order".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $user_id
- * @property int $trade_id 支付流水ID
- * @property string $trade_no 支付流水号
- * @property string|null $full_order_info 单件补货订单返回值
- * @property int $status
- * @property int $created_at
- * @property int $updated_at
- */
- class CloudStockBatchFillOrder extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'qimall_addons_cloud_stock_batch_fill_order';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'trade_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['full_order_info'], 'safe'],
- [['trade_no'], 'string', 'max' => 100],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'user_id' => 'User ID',
- 'trade_id' => 'Trade ID',
- 'trade_no' => 'Trade No',
- 'full_order_info' => 'Full Order Info',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- public static function setData(array $params)
- {
- try {
- if(!empty($params['id'])){
- $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id'], 'status' => [StatusEnum::ENABLED,StatusEnum::DISABLED]]);
- if (!$model) {
- throw new RuntimeException('数据不存在或已删除');
- }
- }else{
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '')) throw new Exception($model->getErrorMessage());
- if (!$model->save()) throw new Exception($model->getErrorMessage());
- return $model;
- } catch (Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- public function getFillOrders()
- {
- return $this->hasMany(CloudStockFillOrder::class, ['batch_fill_order_id' => 'id']);
- }
- public function getPaymentTrade()
- {
- return $this->hasOne(PaymentTrade::class, ['id' => 'trade_id']);
- }
- }
|