CloudStockPriceDifferenceProfit.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace addons\CloudStock\common\models;
  3. use common\models\base\BaseActiveRecord;
  4. use Yii;
  5. /**
  6. * This is the model class for table "qimall_addons_cloud_stock_price_difference_profit".
  7. *
  8. * @property int $id
  9. * @property int $mall_id 商城id
  10. * @property int $user_id 代理商用户id
  11. * @property string $order_no 订单编号
  12. * @property int $type 业务类型:1:上级配货,2:下级补货;3:会员买货
  13. * @property int $child_id 下级代理商用户id
  14. * @property int $num 商品件数
  15. * @property float $money 价差利润
  16. * @property int $goods_id 商品id
  17. * @property int $status 状态[-1:删除;0:禁用;1启用]
  18. * @property int $created_at
  19. * @property int $updated_at
  20. */
  21. class CloudStockPriceDifferenceProfit extends BaseActiveRecord
  22. {
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public static function tableName()
  27. {
  28. return '{{%addons_cloud_stock_price_difference_profit}}';
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function rules()
  34. {
  35. return [
  36. [['mall_id', 'user_id', 'order_no', 'child_id'], 'required'],
  37. [['mall_id', 'user_id', 'type', 'child_id', 'num', 'goods_id', 'status', 'created_at', 'updated_at'], 'integer'],
  38. [['money'], 'number'],
  39. [['order_no'], 'string', 'max' => 255],
  40. ];
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function attributeLabels()
  46. {
  47. return [
  48. 'id' => 'ID',
  49. 'mall_id' => 'Mall ID',
  50. 'user_id' => 'User ID',
  51. 'order_no' => 'Order No',
  52. 'type' => 'Type',
  53. 'child_id' => 'Child ID',
  54. 'num' => 'Num',
  55. 'money' => 'Money',
  56. 'goods_id' => 'Goods ID',
  57. 'status' => 'Status',
  58. 'created_at' => 'Created At',
  59. 'updated_at' => 'Updated At',
  60. ];
  61. }
  62. public static function add($params)
  63. {
  64. try {
  65. $model = new self();
  66. $model->loadDefaultValues();
  67. if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
  68. if (!$model->save()) throw new \Exception($model->getErrorMessage());
  69. return $model;
  70. } catch (\Exception $e) {
  71. self::$static_error = $e->getMessage();
  72. return false;
  73. }
  74. }
  75. }