| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace addons\Pk\common\models;
- use Yii;
- /**
- * This is the model class for table "addons_pk_performance_order".
- *
- * @property int $id
- * @property int $order_id 订单ID
- * @property int $activity_id 活动ID
- * @property int $share_user_id 分享者用户ID
- * @property int $mall_id 商城ID
- * @property int $order_status 处理进度 【0未处理 1已处理 2无效】
- * @property int $source 来源【1自购 2直推 3分享】
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at 创建时间
- * @property int $updated_at 更新时间
- */
- class PkPerformanceOrder extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_pk_performance_order}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['order_id', 'activity_id', 'share_user_id', 'mall_id', 'order_status', 'source', 'status', 'created_at', 'updated_at'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'order_id' => '订单ID',
- 'activity_id' => '活动ID',
- 'share_user_id' => '分享者用户ID',
- 'mall_id' => '商城ID',
- 'order_status' => '处理进度 【0未处理 1已处理 2无效】',
- 'source' => '来源【1自购 2直推 3分享】',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'created_at' => '创建时间',
- 'updated_at' => '更新时间',
- ];
- }
- /**
- * 保存数据
- * @Author: ltm
- * @DateTime: 2022/6/8 0015 9:26
- * @Copyright: copyright (c) 2021
- * @param $mall_id
- * @param array $params
- * @return Rebate|bool
- */
- public static function setData(array $params){
- try{
- $mall_id = $params['mall_id'];
- if(!empty($params['id'])){
- $model = self::findOne(['and',['id' => $params['id'],'mall_id' => $mall_id],['<>','status', StatusEnum::ENABLED]]);
- if(empty($model)) throw new \Exception('活动不存在或已删除');
- }else{
- $model = new self();
- $model->loadDefaultValues();
- $model->mall_id = $mall_id;
- }
- if(!$model->load($params,'') || !$model->save()) throw new Exception($model->getErrorMessage());
- return $model;
- }catch(\Exception $e){
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- }
|