| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace addons\Store\common\models;
- use common\models\base\BaseActiveRecord;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_store_goods_ranking".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $store_id 门店id
- * @property int $goods_id 商品id
- * @property int $sales_money 销售额
- * @property int $status 状态[0禁用 1启用 -1删除]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- */
- class StoreGoodsRanking extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_store_goods_ranking}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'store_id', 'goods_id', 'sales_money', 'status', 'created_at', 'updated_at'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'store_id' => '门店id',
- 'goods_id' => '商品id',
- 'sales_money' => '销售额',
- 'status' => '状态[0禁用 1启用 -1删除]',
- 'created_at' => '创建时间',
- 'updated_at' => '修改时间',
- ];
- }
- public static function setData($params)
- {
- try {
- if (!empty($params['mall_id']) && !empty($params['store_id']) && !empty($params['goods_id'])) {
- $model = StoreGoodsRanking::findOne(['goods_id' => $params['goods_id'], 'store_id' => $params['store_id'], 'mall_id' => $params['mall_id']]);
- if (empty($model)) {
- $model = new StoreGoodsRanking();
- $model->loadDefaultValues();
- $model->mall_id = $params['mall_id'];
- $model->store_id = $params['store_id'];
- $model->goods_id = $params['goods_id'];
- }
- if (!empty($params['sales_money'])) $model->sales_money += $params['sales_money'];
- $res = $model->save();
- }
- return true;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|