'ID', 'mall_id' => '商城ID', 'period_num' => '第N期', 'amounts' => '出单奖励奖金池,单位:元', 'amounts_num' => '出单奖励奖金人数', 'extra_amounts' => '加权分红奖金池,单位:元', 'total_amounts_num' => '总分红人数', 'compute_period' => '结算周期:1天,2周,3月', 'start_time' => '结算开始日期', 'end_time' => '结算结束日期', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * 保存数据 * @Author: lun * @DateTime: 2022/1/26 0026 10:30 * @Copyright: copyright (c) 2021 广东七件事集团 * @param $mall_id * @param null $params * @return bool|int */ public static function setData($mall_id, $params = null) { try { if (empty($params)) { $model = new self(); $model->loadDefaultValues(); $model->mall_id = $mall_id; $model->period_num = self::getPrevPeriodNum($mall_id); } else { $model = self::findOne(['id' => $params['id']]); } if ($params && !$model->load($params, '')) throw new Exception($model->getErrorMessage()); if (!$model->save()) throw new Exception($model->getErrorMessage()); return $model->id; } catch (\Exception $e) { return false; } } /** * 获取上一期期数 * @Author: lun * @DateTime: 2022/1/26 0026 10:28 * @Copyright: copyright (c) 2021 广东七件事集团 * @param $mall_id * @return false|int|string */ public static function getPrevPeriodNum($mall_id) { $period_num = self::find()->select("period_num")->where(['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED])->orderBy('period_num desc')->asArray()->scalar(); $num = empty($period_num) ? 1 : $period_num + 1; return $num; } }