| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace app\modules\alliance\models;
- use app\models\SaaSLeaguePriceLog;
- use app\models\SaasUser;
- use app\models\Store;
- use yii\base\Model;
- class LeagueForm extends Model
- {
- public $saas_user;
- public $store_id;
- public $role;
- const ROLE_USER = 0;
- const ROLE_STORE = 1;
- public function leagueDetailLog() {
- if ($this->role === self::ROLE_USER) {
- $saas_user = $this->saas_user;
- $query = SaaSLeaguePriceLog::find()->alias('lpl')
- ->leftJoin(['su' => SaasUser::tableName()], 'su.id = lpl.saas_user_id')
- ->where(['lpl.role' => SaaSLeaguePriceLog::ROLE_USER, 'lpl.is_delete' => 0, 'lpl.saas_user_id' => $saas_user->id]);
- } else {
- $store_id = $this->store_id;
- $query = SaaSLeaguePriceLog::find()->alias('lpl')
- ->leftJoin(['s' => Store::tableName()], 's.id = lpl.store_id')
- ->where(['lpl.role' => SaaSLeaguePriceLog::ROLE_STORE, 'lpl.is_delete' => 0, 'lpl.store_id' => $store_id]);
- }
- $query->select('lpl.id, lpl.type, lpl.league_price, lpl.send_or_take_type, lpl.addtime')
- ->orderBy('lpl.id DESC');
- $list = pagination_make($query);
- foreach ($list['list'] as $index => &$item) {
- $item['send_or_take_type'] = intval($item['send_or_take_type']);
- $item['created_at'] = date('Y-m-d H:i:s', $item['addtime']);
- $item['type_text'] = SaaSLeaguePriceLog::getTypeStr($item['type']);
- unset($list['list'][$index]['addtime']);
- }
- return [
- 'code' => 0,
- 'msg' => '',
- 'data' => $list
- ];
- }
- }
|