255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城ID', 'commission_type' => '分佣类型; score积分分佣, commission佣金分佣', 'enable' => '是否参与自提奖励[0:否, 1:是]', 'is_alone' => '是否独立设置[0:否, 1:是]', 'is_percent' => '类型 0百分比 1 固定金额', 'item_type' => '项目类型:商品goods', 'item_id' => '项目id', 'give_num' => '赠送数额', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => '创建时间', 'updated_at' => '更新时间', ]; } public static function setData($params, $data) { try{ foreach ($data as $item) { $model = self::findOne([ 'mall_id' => $params['mall_id'], 'item_type' => $item['item_type'], 'commission_type' => $item['commission_type'], 'item_id' => $params['item_id'], 'status' => [StatusEnum::ENABLED] ]); if (empty($model)) { $model = new self(); $model->mall_id = $params['mall_id']; $model->item_id = $params['item_id']; $model->loadDefaultValues(); } if(!$model->load($item,'') || !$model->save()){ throw new \Exception($model->getErrorMessage()); } } return true; }catch(\Exception $e){ self::$static_error = $e->getMessage(); return false; } } }