'客户录入', 'communicate' => '需求沟通', 'guide' => '价值引导', 'try' => '打包试用', 'sign' => '签约', 'return' => '回款', 'deliver' => '实施交付', 'serve' => '跟踪服务', 'renew' => '续签增购' ]; //状态 public static $statusList = [ 'potential' => '潜在', 'intension' => '意向', 'negotiation' => '合同洽谈', 'payment-time' => '确认付款时间', 'signed' => '已签约', 'paid' => '已付款', 'failed' => '失败' ]; public static function getPageList($statusList = '', $name = '') { $list = self::alias('c') ->leftJoin('sys_user u', 'c.assignedTo = u.account') ->where('c.deleted', 0) ->when($statusList != '', function($query) use($statusList){ $query->whereIn('c.status', $statusList); }) ->when(!empty($name), function($query) use($name){ $query->where('c.name', 'like', "%$name%"); }) ->field('c.*,u.realname as assignedToName') ->order('c.contactedDate desc, c.createdDate desc') ->paginate([ 'list_rows'=> 50, 'var_page' => 'page', ]); $customerIDList = []; foreach($list as $item){ $item['stageStr'] = self::$stages[$item['stage']]; $item['statusStr'] = self::$statusList[$item['status']]; $item['contactedDateStr'] = substr($item['contactedDate'], 0, 10); $item['createdDateStr'] = substr($item['createdDate'], 0, 10); $customerIDList[] = $item['id']; } $communicationList = Communication::getListByCustomerList($customerIDList); $customerCommunicationList = []; foreach($communicationList as $c){ $customerCommunicationList[$c['objectID']][] = $c; } foreach($list as $item){ $tmpCommunicationStr = ''; if(!empty($customerCommunicationList[$item['id']])){ $tmpCommunicationList = $customerCommunicationList[$item['id']]; foreach($tmpCommunicationList as $t){ if(!empty($t['comment'])){ $tmpCommunicationStr .= '' . substr($t['date'], 0, 10) . ':' . $t['comment'] . "
"; } } } $item['communicationStr'] = $tmpCommunicationStr; } return $list; } }