| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- namespace addons\Agent\common\models;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_agent_commission_item_setting_detail".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property int $agent_commission_item_setting_id
- * @property int $level
- * @property float $agent_team_prize 渠道奖
- * @property float $agent_equal_prize 平级奖
- * @property float $agent_over_prize 越级奖
- * @property float $agent_extra_prize 额外奖
- * @property float $agent_drainage_subsidy_prize 额外分红奖励:引流补贴
- * @property float $agent_team_subsidy_prize 额外分红奖励:渠道补贴
- * @property float $extra_equal_prize1 渠道分红平1级奖
- * @property float $extra_equal_prize2 渠道分红平2级奖
- * @property float $agent_recommend_prize 推荐奖
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at
- * @property int $updated_at
- */
- class AgentCommissionItemSettingDetail extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_agent_commission_item_setting_detail}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'agent_commission_item_setting_id'], 'required'],
- [['mall_id', 'agent_commission_item_setting_id', 'level', 'status', 'created_at', 'updated_at'], 'integer'],
- [['agent_team_prize', 'agent_equal_prize', 'agent_over_prize', 'agent_extra_prize','agent_recommend_prize',
- 'agent_drainage_subsidy_prize','agent_team_subsidy_prize','extra_equal_prize1','extra_equal_prize2'
- ], 'number'],
- [['alone_agent_equal_prize_info'], 'string', 'max' => 1000],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'agent_commission_item_setting_id' => 'Agent Commission Item Setting ID',
- 'level' => 'Level',
- 'agent_team_prize' => '渠道奖',
- 'agent_equal_prize' => '平级奖',
- 'agent_over_prize' => '越级奖',
- 'agent_extra_prize' => '额外奖',
- 'agent_drainage_subsidy_prize' => '额外分红奖励:引流补贴',
- 'agent_team_subsidy_prize' => '额外分红奖励:渠道补贴',
- 'extra_equal_prize1' => '渠道分红平1级奖',
- 'extra_equal_prize2' => '渠道分红平2级奖',
- 'agent_recommend_prize' => '推荐奖',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- public static function setData($params, $data)
- {
- try{
- foreach ($data as $item) {
- $model = self::findOne([
- 'mall_id' => $params['mall_id'],
- 'level' => $item['level'],
- 'agent_commission_item_setting_id' => $params['agent_commission_item_setting_id'],
- 'status' => [StatusEnum::ENABLED]
- ]);
- if (empty($model)) {
- $model = new self();
- $model->mall_id = $params['mall_id'];
- $model->agent_commission_item_setting_id = $params['agent_commission_item_setting_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;
- }
- }
- }
|