| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace addons\Album\common\models;
- use Yii;
- use yii\db\Exception;
- /**
- * This is the model class for table "qimall_addons_album_order".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property int $order_id 订单id
- * @property int $order_detail_id 订单详情id
- * @property int $user_id 用户id
- * @property int $album_id 画册id
- * @property int $album_page_id 画册页id
- * @property int $goods_id 商品id
- * @property int|null $order_count 订单数量
- * @property float $amount 支付金额
- * @property int $created_at 添加时间戳
- * @property string $date 日期
- */
- class AddonsAlbumOrder extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_album_order}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'order_id', 'order_detail_id', 'user_id', 'album_id', 'album_page_id', 'goods_id', 'order_count', 'created_at'], 'integer'],
- [['amount'], 'number'],
- [['date'], 'required'],
- [['date'], 'safe'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'order_id' => '订单id',
- 'order_detail_id' => '订单详情id',
- 'user_id' => '用户id',
- 'album_id' => '画册id',
- 'album_page_id' => '画册页id',
- 'goods_id' => '商品id',
- 'order_count' => '订单数量',
- 'amount' => '支付金额',
- 'created_at' => '添加时间戳',
- 'date' => '日期',
- ];
- }
- /**
- * @Author: ltm
- * @DateTime: 2022/2/15 0015 11:43
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $data
- * @return string
- */
- public static function setData(array $params){
- try{
- $date = date("Y-m-d");
- $porson_num = AddonsAlbumOrder::findOne(['date'=> $date,'user_id' => $params['user_id'],'album_id' => $params['album_id']]);
- $model = new self();
- $model->created_at = time();
- $model->loadDefaultValues();
- $model->date = $date;
- $model->mall_id = $params['mall_id'];
- if(!$model->load($params,'') || !$model->save()){
- throw new Exception($model->getErrorMessage());
- }
- return $porson_num;
- }catch(\Exception $e){
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|