['l.created_at' => SORT_DESC]], ]; } /** * 明细列表 * @return array */ public function getList($params) { if (!$this->validate()) { return $this->responseErrorInfo(); } // $boss_level_list = AddonsBossLevel::getBossLevel([['mall_id' => $store['mall_id']]], [],true,'level,name'); $boss_level_list = (new \addons\Store\common\models\StoreBossLevelCommon)->getList(); $boss_level_arr = array_column($boss_level_list, null,'level'); $settlement_method = LevelEnum::getSettlementMethod();// 结算方式 $compute_type = LevelEnum::getComputeType();// 佣金计算方式 // 获取用户信息 $user = User::find()->select('nickname,avatar_url')->where(['mall_id' => $params['mall_id'],'id' => $params['id']])->asArray()->one(); $where = []; $where[] = ['=', 'mall_id', $params['mall_id']]; // $where[] = ['=', 'store_id', $params['store_id']]; $where[] = ['=', 'user_id', $params['id']]; $where[] = ['=', 'type', $params['type']]; $where[] = ['between', 'date', str_replace('-','',$params['start_time']), str_replace('-','',$params['end_time'])]; $where[] = ['=', 'is_settlement', StatusEnum::ENABLED]; $where[] = ['=', 'status', StatusEnum::ENABLED]; $order = 'created_at desc'; $params = array('where' => $where, 'order' => $order, 'limit' => 20); $list = StoreBossRewardLog::listPage($params, false, true); return [ 'code' => 0, 'msg' => '获取成功', 'data' => [ 'list' => $list, 'boss_level_arr' => $boss_level_arr, 'user'=>$user, 'settlement_method' => $settlement_method, 'compute_type' => $compute_type, ] ]; } /** * 结算列表 * @return array */ public function getSettlementList($params) { if (!$this->validate()) { return $this->responseErrorInfo(); } $store = \Yii::$app->session->get('o2o'); $commonission_type = LevelEnum::getCommissionType();// 分红类型 $compute_period = LevelEnum::getComputePeriod();// 分红周期 $where = []; $where[] = ['=', 'mall_id', $store['mall_id']]; $where[] = ['=', 'store_id', $store['id']]; // 根据用户昵称搜索 if (isset($params['keyword'])) { $where[] = ['=', 'user_id', $params['keyword']]; // $user_id = User::find()->select('id')->where(['mall_id' => $this->mall_id,'mobile' => $params['keyword'],'status' => StatusEnum::ENABLED])->asArray()->scalar(); // if ($user_id) $where[] = ['=', 'user_id', $user_id]; } $where[] = ['=', 'status', StatusEnum::ENABLED]; $where[] = ['in', 'source', [StoreBossRewardLog::SOURCE_ORDER_STORE,StoreBossRewardLog::SOURCE_CASHIER_STORE]]; $order = 'created_at desc'; $with = ['user']; $params = array('where' => $where, 'order' => $order, 'with' => $with, 'limit' => 20); $list = StoreBossCommissionLog::listPage($params, false, true); if (empty($list)){ return [ 'code' => 0, 'msg' => '', 'data' => [] ]; } foreach ($list['list'] as &$item) { $item['start_time'] = date("Y-m-d", $item['start_time']); $item['end_time'] = date("Y-m-d", $item['end_time']); } return [ 'code' => 0, 'msg' => '', 'data' => [ 'list' => $list, 'commonission_type' => $commonission_type, 'compute_period' => $compute_period, ] ]; } }