| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace addons\CloudStock\common\models;
- use common\models\base\BaseActiveRecord;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_cloud_stock_price_difference_profit".
- *
- * @property int $id
- * @property int $mall_id 商城id
- * @property int $user_id 代理商用户id
- * @property string $order_no 订单编号
- * @property int $type 业务类型:1:上级配货,2:下级补货;3:会员买货
- * @property int $child_id 下级代理商用户id
- * @property int $num 商品件数
- * @property float $money 价差利润
- * @property int $goods_id 商品id
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at
- * @property int $updated_at
- */
- class CloudStockPriceDifferenceProfit extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_cloud_stock_price_difference_profit}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'order_no', 'child_id'], 'required'],
- [['mall_id', 'user_id', 'type', 'child_id', 'num', 'goods_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['money'], 'number'],
- [['order_no'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'user_id' => 'User ID',
- 'order_no' => 'Order No',
- 'type' => 'Type',
- 'child_id' => 'Child ID',
- 'num' => 'Num',
- 'money' => 'Money',
- 'goods_id' => 'Goods ID',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- public static function add($params)
- {
- try {
- $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;
- }
- }
- }
|