diff --git a/app/model/Customer.php b/app/model/Customer.php index 86adea5..d5f4985 100644 --- a/app/model/Customer.php +++ b/app/model/Customer.php @@ -67,20 +67,20 @@ class Customer extends Model */ public static function getCustomer($customer, $request, $tag = false) { - $customer['grade_txt'] = Constants::GRADE[$customer['grade']]; - $customer['magnitude_txt'] = Constants::MAGNITUDE[$customer['magnitude']]; - $customer['sex_txt'] = Constants::SEX[$customer['sex']]; $language = $request->user['language'] ?: 'en'; + $customer['grade_txt'] = $language=='en'?Constants::GRADE_EN[$customer['grade']]:Constants::GRADE[$customer['grade']]; + $customer['magnitude_txt'] = $language=='en'?Constants::MAGNITUDE_EN[$customer['magnitude']]:Constants::MAGNITUDE[$customer['magnitude']]; + $customer['sex_txt'] = $language=='en'?Constants::SEX_EN[$customer['sex']]:Constants::SEX[$customer['sex']]; if ($customer['grade']<=2) { $customer['follow'] = 0; - $customer['follow_txt'] = '跟进中'; + $customer['follow_txt'] = ($language == 'en' ? 'Following' : '跟进中'); }elseif ($customer['grade']<5) { $customer['follow'] = 1; - $customer['follow_txt'] = '已成交'; + $customer['follow_txt'] = ($language == 'en' ? 'transacted' : '已成交'); }else{ $customer['follow'] = 2; - $customer['follow_txt'] = '已流失'; + $customer['follow_txt'] = ($language == 'en' ? 'lost' : '已流失'); } $where = [ @@ -96,9 +96,11 @@ class Customer extends Model // $customer['updated_at'] = Util::timeTotDate($customer['updated_at']); $customer = Util::formatDate($customer,['follow_last']); - $customer['car_type_name'] = empty($customer['car_type_id'])?'':CarType::where(['id'=>$customer['car_type_id']])->value('name'); - $customer['country_name'] = empty($customer['country_id'])?'':Country::where(['id'=>$customer['country_id']])->value('cn_addr'); - $customer['channel_name'] = empty($customer['channel_id'])?'':Channel::where(['id'=>$customer['channel_id']])->value('name'); + $nameLang = $language=='en'?'name_en':'name'; + $countryLang = $language=='en'?'en_addr':'cn_addr'; + $customer['car_type_name'] = empty($customer['car_type_id'])?'':CarType::where(['id'=>$customer['car_type_id']])->value($nameLang); + $customer['country_name'] = empty($customer['country_id'])?'':Country::where(['id'=>$customer['country_id']])->value($countryLang); + $customer['channel_name'] = empty($customer['channel_id'])?'':Channel::where(['id'=>$customer['channel_id']])->value($nameLang); // $customer['last_follow'] = $last_follow; if ($tag) { diff --git a/config/constants/Constants.php b/config/constants/Constants.php index 0883ea5..36a21e5 100644 --- a/config/constants/Constants.php +++ b/config/constants/Constants.php @@ -68,4 +68,10 @@ class Constants self::CUSTOMER_SEX_MAN => '男', self::CUSTOMER_SEX_WOMAN => '女', ]; + + public const SEX_EN = [ + self::CUSTOMER_SEX_UNKNOWN => 'unknown', + self::CUSTOMER_SEX_MAN => 'man', + self::CUSTOMER_SEX_WOMAN => 'woman', + ]; } \ No newline at end of file