diff --git a/admin/config/mimes.php b/admin/config/mimes.php
index 27f470a4..71c096a4 100644
--- a/admin/config/mimes.php
+++ b/admin/config/mimes.php
@@ -1,5 +1,5 @@
array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'),
- 'cpt' => 'application/mac-compactpro',
- 'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'),
- 'bin' => array('application/macbinary', 'application/mac-binary', 'application/octet-stream', 'application/x-binary', 'application/x-macbinary'),
- 'dms' => 'application/octet-stream',
- 'lha' => 'application/octet-stream',
- 'lzh' => 'application/octet-stream',
- 'exe' => array('application/octet-stream', 'application/x-msdownload'),
- 'class' => 'application/octet-stream',
- 'psd' => array('application/x-photoshop', 'image/vnd.adobe.photoshop'),
- 'so' => 'application/octet-stream',
- 'sea' => 'application/octet-stream',
- 'dll' => 'application/octet-stream',
- 'oda' => 'application/oda',
- 'pdf' => array('application/pdf', 'application/force-download', 'application/x-download', 'binary/octet-stream'),
- 'ai' => array('application/pdf', 'application/postscript'),
- 'eps' => 'application/postscript',
- 'ps' => 'application/postscript',
- 'smi' => 'application/smil',
- 'smil' => 'application/smil',
- 'mif' => 'application/vnd.mif',
- 'xls' => array('application/vnd.ms-excel', 'application/msexcel', 'application/x-msexcel', 'application/x-ms-excel', 'application/x-excel', 'application/x-dos_ms_excel', 'application/xls', 'application/x-xls', 'application/excel', 'application/download', 'application/vnd.ms-office', 'application/msword'),
- 'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint', 'application/vnd.ms-office', 'application/msword'),
- 'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/x-zip', 'application/zip'),
- 'wbxml' => 'application/wbxml',
- 'wmlc' => 'application/wmlc',
- 'dcr' => 'application/x-director',
- 'dir' => 'application/x-director',
- 'dxr' => 'application/x-director',
- 'dvi' => 'application/x-dvi',
- 'gtar' => 'application/x-gtar',
- 'gz' => 'application/x-gzip',
- 'gzip' => 'application/x-gzip',
- 'php' => array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/x-php', 'application/x-httpd-php-source'),
- 'php4' => 'application/x-httpd-php',
- 'php3' => 'application/x-httpd-php',
- 'phtml' => 'application/x-httpd-php',
- 'phps' => 'application/x-httpd-php-source',
- 'js' => array('application/x-javascript', 'text/plain'),
- 'swf' => 'application/x-shockwave-flash',
- 'sit' => 'application/x-stuffit',
- 'tar' => 'application/x-tar',
- 'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
- 'z' => 'application/x-compress',
- 'xhtml' => 'application/xhtml+xml',
- 'xht' => 'application/xhtml+xml',
- 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip'),
- 'rar' => array('application/x-rar', 'application/rar', 'application/x-rar-compressed'),
- 'mid' => 'audio/midi',
- 'midi' => 'audio/midi',
- 'mpga' => 'audio/mpeg',
- 'mp2' => 'audio/mpeg',
- 'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
- 'aif' => array('audio/x-aiff', 'audio/aiff'),
- 'aiff' => array('audio/x-aiff', 'audio/aiff'),
- 'aifc' => 'audio/x-aiff',
- 'ram' => 'audio/x-pn-realaudio',
- 'rm' => 'audio/x-pn-realaudio',
- 'rpm' => 'audio/x-pn-realaudio-plugin',
- 'ra' => 'audio/x-realaudio',
- 'rv' => 'video/vnd.rn-realvideo',
- 'wav' => array('audio/x-wav', 'audio/wave', 'audio/wav'),
- 'bmp' => array('image/bmp', 'image/x-bmp', 'image/x-bitmap', 'image/x-xbitmap', 'image/x-win-bitmap', 'image/x-windows-bmp', 'image/ms-bmp', 'image/x-ms-bmp', 'application/bmp', 'application/x-bmp', 'application/x-win-bitmap'),
- 'gif' => 'image/gif',
- 'jpeg' => array('image/jpeg', 'image/pjpeg'),
- 'jpg' => array('image/jpeg', 'image/pjpeg'),
- 'jpe' => array('image/jpeg', 'image/pjpeg'),
- 'jp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'j2k' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'jpf' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'jpg2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'jpx' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'jpm' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'mj2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'mjp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
- 'png' => array('image/png', 'image/x-png'),
- 'tiff' => 'image/tiff',
- 'tif' => 'image/tiff',
- 'css' => array('text/css', 'text/plain'),
- 'html' => array('text/html', 'text/plain'),
- 'htm' => array('text/html', 'text/plain'),
- 'shtml' => array('text/html', 'text/plain'),
- 'txt' => 'text/plain',
- 'text' => 'text/plain',
- 'log' => array('text/plain', 'text/x-log'),
- 'rtx' => 'text/richtext',
- 'rtf' => 'text/rtf',
- 'xml' => array('application/xml', 'text/xml', 'text/plain'),
- 'xsl' => array('application/xml', 'text/xsl', 'text/xml'),
- 'mpeg' => 'video/mpeg',
- 'mpg' => 'video/mpeg',
- 'mpe' => 'video/mpeg',
- 'qt' => 'video/quicktime',
- 'mov' => 'video/quicktime',
- 'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'),
- 'movie' => 'video/x-sgi-movie',
- 'doc' => array('application/msword', 'application/vnd.ms-office'),
- 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'),
- 'dot' => array('application/msword', 'application/vnd.ms-office'),
- 'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
- 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'),
- 'word' => array('application/msword', 'application/octet-stream'),
- 'xl' => 'application/excel',
- 'eml' => 'message/rfc822',
- 'json' => array('application/json', 'text/json'),
- 'pem' => array('application/x-x509-user-cert', 'application/x-pem-file', 'application/octet-stream'),
- 'p10' => array('application/x-pkcs10', 'application/pkcs10'),
- 'p12' => 'application/x-pkcs12',
- 'p7a' => 'application/x-pkcs7-signature',
- 'p7c' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
- 'p7m' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
- 'p7r' => 'application/x-pkcs7-certreqresp',
- 'p7s' => 'application/pkcs7-signature',
- 'crt' => array('application/x-x509-ca-cert', 'application/x-x509-user-cert', 'application/pkix-cert'),
- 'crl' => array('application/pkix-crl', 'application/pkcs-crl'),
- 'der' => 'application/x-x509-ca-cert',
- 'kdb' => 'application/octet-stream',
- 'pgp' => 'application/pgp',
- 'gpg' => 'application/gpg-keys',
- 'sst' => 'application/octet-stream',
- 'csr' => 'application/octet-stream',
- 'rsa' => 'application/x-pkcs7',
- 'cer' => array('application/pkix-cert', 'application/x-x509-ca-cert'),
- '3g2' => 'video/3gpp2',
- '3gp' => array('video/3gp', 'video/3gpp'),
- 'mp4' => 'video/mp4',
- 'm4a' => 'audio/x-m4a',
- 'f4v' => array('video/mp4', 'video/x-f4v'),
- 'flv' => 'video/x-flv',
- 'webm' => 'video/webm',
- 'aac' => 'audio/x-acc',
- 'm4u' => 'application/vnd.mpegurl',
- 'm3u' => 'text/plain',
- 'xspf' => 'application/xspf+xml',
- 'vlc' => 'application/videolan',
- 'wmv' => array('video/x-ms-wmv', 'video/x-ms-asf'),
- 'au' => 'audio/x-au',
- 'ac3' => 'audio/ac3',
- 'flac' => 'audio/x-flac',
- 'ogg' => array('audio/ogg', 'video/ogg', 'application/ogg'),
- 'kmz' => array('application/vnd.google-earth.kmz', 'application/zip', 'application/x-zip'),
- 'kml' => array('application/vnd.google-earth.kml+xml', 'application/xml', 'text/xml'),
- 'ics' => 'text/calendar',
- 'ical' => 'text/calendar',
- 'zsh' => 'text/x-scriptzsh',
- '7z' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
- '7zip' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
- 'cdr' => array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'),
- 'wma' => array('audio/x-ms-wma', 'video/x-ms-asf'),
- 'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'),
- 'svg' => array('image/svg+xml', 'application/xml', 'text/xml'),
- 'vcf' => 'text/x-vcard',
- 'srt' => array('text/srt', 'text/plain'),
- 'vtt' => array('text/vtt', 'text/plain'),
- 'ico' => array('image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon'),
- 'odc' => 'application/vnd.oasis.opendocument.chart',
- 'otc' => 'application/vnd.oasis.opendocument.chart-template',
- 'odf' => 'application/vnd.oasis.opendocument.formula',
- 'otf' => 'application/vnd.oasis.opendocument.formula-template',
- 'odg' => 'application/vnd.oasis.opendocument.graphics',
- 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
- 'odi' => 'application/vnd.oasis.opendocument.image',
- 'oti' => 'application/vnd.oasis.opendocument.image-template',
- 'odp' => 'application/vnd.oasis.opendocument.presentation',
- 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
- 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
- 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
- 'odt' => 'application/vnd.oasis.opendocument.text',
- 'odm' => 'application/vnd.oasis.opendocument.text-master',
- 'ott' => 'application/vnd.oasis.opendocument.text-template',
- 'oth' => 'application/vnd.oasis.opendocument.text-web'
+ 'hqx' => array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'),
+ 'cpt' => 'application/mac-compactpro',
+ 'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'),
+ 'bin' => array('application/macbinary', 'application/mac-binary', 'application/octet-stream', 'application/x-binary', 'application/x-macbinary'),
+ 'dms' => 'application/octet-stream',
+ 'lha' => 'application/octet-stream',
+ 'lzh' => 'application/octet-stream',
+ 'exe' => array('application/octet-stream', 'application/x-msdownload'),
+ 'class' => 'application/octet-stream',
+ 'psd' => array('application/x-photoshop', 'image/vnd.adobe.photoshop'),
+ 'so' => 'application/octet-stream',
+ 'sea' => 'application/octet-stream',
+ 'dll' => 'application/octet-stream',
+ 'oda' => 'application/oda',
+ 'pdf' => array('application/pdf', 'application/force-download', 'application/x-download', 'binary/octet-stream'),
+ 'ai' => array('application/pdf', 'application/postscript'),
+ 'eps' => 'application/postscript',
+ 'ps' => 'application/postscript',
+ 'smi' => 'application/smil',
+ 'smil' => 'application/smil',
+ 'mif' => 'application/vnd.mif',
+ 'xls' => array('application/vnd.ms-excel', 'application/msexcel', 'application/x-msexcel', 'application/x-ms-excel', 'application/x-excel', 'application/x-dos_ms_excel', 'application/xls', 'application/x-xls', 'application/excel', 'application/download', 'application/vnd.ms-office', 'application/msword'),
+ 'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint', 'application/vnd.ms-office', 'application/msword'),
+ 'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/x-zip', 'application/zip'),
+ 'wbxml' => 'application/wbxml',
+ 'wmlc' => 'application/wmlc',
+ 'dcr' => 'application/x-director',
+ 'dir' => 'application/x-director',
+ 'dxr' => 'application/x-director',
+ 'dvi' => 'application/x-dvi',
+ 'gtar' => 'application/x-gtar',
+ 'gz' => 'application/x-gzip',
+ 'gzip' => 'application/x-gzip',
+ 'php' => array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/x-php', 'application/x-httpd-php-source'),
+ 'php4' => 'application/x-httpd-php',
+ 'php3' => 'application/x-httpd-php',
+ 'phtml' => 'application/x-httpd-php',
+ 'phps' => 'application/x-httpd-php-source',
+ 'js' => array('application/x-javascript', 'text/plain'),
+ 'swf' => 'application/x-shockwave-flash',
+ 'sit' => 'application/x-stuffit',
+ 'tar' => 'application/x-tar',
+ 'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
+ 'z' => 'application/x-compress',
+ 'xhtml' => 'application/xhtml+xml',
+ 'xht' => 'application/xhtml+xml',
+ 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip'),
+ 'rar' => array('application/x-rar', 'application/rar', 'application/x-rar-compressed'),
+ 'mid' => 'audio/midi',
+ 'midi' => 'audio/midi',
+ 'mpga' => 'audio/mpeg',
+ 'mp2' => 'audio/mpeg',
+ 'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
+ 'aif' => array('audio/x-aiff', 'audio/aiff'),
+ 'aiff' => array('audio/x-aiff', 'audio/aiff'),
+ 'aifc' => 'audio/x-aiff',
+ 'ram' => 'audio/x-pn-realaudio',
+ 'rm' => 'audio/x-pn-realaudio',
+ 'rpm' => 'audio/x-pn-realaudio-plugin',
+ 'ra' => 'audio/x-realaudio',
+ 'rv' => 'video/vnd.rn-realvideo',
+ 'wav' => array('audio/x-wav', 'audio/wave', 'audio/wav'),
+ 'bmp' => array('image/bmp', 'image/x-bmp', 'image/x-bitmap', 'image/x-xbitmap', 'image/x-win-bitmap', 'image/x-windows-bmp', 'image/ms-bmp', 'image/x-ms-bmp', 'application/bmp', 'application/x-bmp', 'application/x-win-bitmap'),
+ 'gif' => 'image/gif',
+ 'jpeg' => array('image/jpeg', 'image/pjpeg'),
+ 'jpg' => array('image/jpeg', 'image/pjpeg'),
+ 'jpe' => array('image/jpeg', 'image/pjpeg'),
+ 'jp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'j2k' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'jpf' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'jpg2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'jpx' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'jpm' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'mj2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'mjp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'png' => array('image/png', 'image/x-png'),
+ 'tiff' => 'image/tiff',
+ 'tif' => 'image/tiff',
+ 'css' => array('text/css', 'text/plain'),
+ 'html' => array('text/html', 'text/plain'),
+ 'htm' => array('text/html', 'text/plain'),
+ 'shtml' => array('text/html', 'text/plain'),
+ 'txt' => 'text/plain',
+ 'text' => 'text/plain',
+ 'log' => array('text/plain', 'text/x-log'),
+ 'rtx' => 'text/richtext',
+ 'rtf' => 'text/rtf',
+ 'xml' => array('application/xml', 'text/xml', 'text/plain'),
+ 'xsl' => array('application/xml', 'text/xsl', 'text/xml'),
+ 'mpeg' => 'video/mpeg',
+ 'mpg' => 'video/mpeg',
+ 'mpe' => 'video/mpeg',
+ 'qt' => 'video/quicktime',
+ 'mov' => 'video/quicktime',
+ 'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'),
+ 'movie' => 'video/x-sgi-movie',
+ 'doc' => array('application/msword', 'application/vnd.ms-office'),
+ 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'),
+ 'dot' => array('application/msword', 'application/vnd.ms-office'),
+ 'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
+ 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip', 'application/octet-stream'),
+ 'word' => array('application/msword', 'application/octet-stream'),
+ 'xl' => 'application/excel',
+ 'eml' => 'message/rfc822',
+ 'json' => array('application/json', 'text/json'),
+ 'pem' => array('application/x-x509-user-cert', 'application/x-pem-file', 'application/octet-stream'),
+ 'p10' => array('application/x-pkcs10', 'application/pkcs10'),
+ 'p12' => 'application/x-pkcs12',
+ 'p7a' => 'application/x-pkcs7-signature',
+ 'p7c' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
+ 'p7m' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
+ 'p7r' => 'application/x-pkcs7-certreqresp',
+ 'p7s' => 'application/pkcs7-signature',
+ 'crt' => array('application/x-x509-ca-cert', 'application/x-x509-user-cert', 'application/pkix-cert'),
+ 'crl' => array('application/pkix-crl', 'application/pkcs-crl'),
+ 'der' => 'application/x-x509-ca-cert',
+ 'kdb' => 'application/octet-stream',
+ 'pgp' => 'application/pgp',
+ 'gpg' => 'application/gpg-keys',
+ 'sst' => 'application/octet-stream',
+ 'csr' => 'application/octet-stream',
+ 'rsa' => 'application/x-pkcs7',
+ 'cer' => array('application/pkix-cert', 'application/x-x509-ca-cert'),
+ '3g2' => 'video/3gpp2',
+ '3gp' => array('video/3gp', 'video/3gpp'),
+ 'mp4' => 'video/mp4',
+ 'm4a' => 'audio/x-m4a',
+ 'f4v' => array('video/mp4', 'video/x-f4v'),
+ 'flv' => 'video/x-flv',
+ 'webm' => 'video/webm',
+ 'aac' => 'audio/x-acc',
+ 'm4u' => 'application/vnd.mpegurl',
+ 'm3u' => 'text/plain',
+ 'xspf' => 'application/xspf+xml',
+ 'vlc' => 'application/videolan',
+ 'wmv' => array('video/x-ms-wmv', 'video/x-ms-asf'),
+ 'au' => 'audio/x-au',
+ 'ac3' => 'audio/ac3',
+ 'flac' => 'audio/x-flac',
+ 'ogg' => array('audio/ogg', 'video/ogg', 'application/ogg'),
+ 'kmz' => array('application/vnd.google-earth.kmz', 'application/zip', 'application/x-zip'),
+ 'kml' => array('application/vnd.google-earth.kml+xml', 'application/xml', 'text/xml'),
+ 'ics' => 'text/calendar',
+ 'ical' => 'text/calendar',
+ 'zsh' => 'text/x-scriptzsh',
+ '7z' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
+ '7zip' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
+ 'cdr' => array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'),
+ 'wma' => array('audio/x-ms-wma', 'video/x-ms-asf'),
+ 'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'),
+ 'svg' => array('image/svg+xml', 'application/xml', 'text/xml'),
+ 'vcf' => 'text/x-vcard',
+ 'srt' => array('text/srt', 'text/plain'),
+ 'vtt' => array('text/vtt', 'text/plain'),
+ 'ico' => array('image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon'),
+ 'odc' => 'application/vnd.oasis.opendocument.chart',
+ 'otc' => 'application/vnd.oasis.opendocument.chart-template',
+ 'odf' => 'application/vnd.oasis.opendocument.formula',
+ 'otf' => 'application/vnd.oasis.opendocument.formula-template',
+ 'odg' => 'application/vnd.oasis.opendocument.graphics',
+ 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
+ 'odi' => 'application/vnd.oasis.opendocument.image',
+ 'oti' => 'application/vnd.oasis.opendocument.image-template',
+ 'odp' => 'application/vnd.oasis.opendocument.presentation',
+ 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
+ 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
+ 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
+ 'odt' => 'application/vnd.oasis.opendocument.text',
+ 'odm' => 'application/vnd.oasis.opendocument.text-master',
+ 'ott' => 'application/vnd.oasis.opendocument.text-template',
+ 'oth' => 'application/vnd.oasis.opendocument.text-web'
);
diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php
index 3b70072e..ada1c868 100644
--- a/admin/controllers/receiver/Clues.php
+++ b/admin/controllers/receiver/Clues.php
@@ -28,20 +28,54 @@ class Clues extends HD_Controller
//首页信息
public function index()
{
- $this->lists();
+ $params = $this->input->get();
+ list($lists, $count) = $this->lists();
+ $map_cfrom = $this->clues_cfrom_model->map('id', 'title', array('status' => 1, 'pid' => 0, 'type' => 0), '', 0, 0, 'id, title');
+ $map_cfrom2 = $this->clues_cfrom_model->map('id', 'title', array('status' => 1, 'pid' => $params['cfrom_id']), '', 0, 0, 'id, title');
+ $statusList = array();
+ foreach ($this->clues_model->statusAry() as $key => $value) {
+ $cate = array();
+ $where = array("status" => $key);
+ $count1 = $this->clues_model->count($where);
+ if ($value['list']) {
+ foreach ($value['list'] as $key2 => $value2) {
+ $where['status2'] = $key2;
+ $count2 = $this->clues_model->count($where);
+ $cate[] = array("id" => $key2, "name" => $value2, "count" => $count2);
+ }
+ }
+ $statusList[] = array("id" => $key, "name" => $value['name'], "cate" => $cate, "count" => $count1);
+ }
+
+ $this->data['province_id'] = intval($params['province_id']);
+ $this->data['city_id'] = intval($params['city_id']);
+ $this->data['county_id'] = intval($params['county_id']);
+ $this->data['provinces'] = $this->province_ary();
+ $this->data['lists'] = $lists;
+ $this->data['searchTpAry'] = $this->searchTpAry;
+ $this->data['params'] = $params;
+ $this->data['cfromAry'] = $map_cfrom;
+ $this->data['cfromAry2'] = $map_cfrom2;
+ $this->data['statusList'] = $statusList;
+ $this->data['maintainAry'] = $this->maintainAry;
+ $this->data['export_button'] = SUPER_ADMIN == $this->role ? 1 : 0;
+ $this->data['_title'] = '线索池列表';
+ return $this->show_view('receiver/clues/lists', true);
}
- public function lists($where = array())
+ public function lists($export = false)
{
+ $where = [];
$statusAry = $this->clues_model->statusAry();
$params = $this->input->get();
- $this->data['province_id'] = $province_id = intval($params['province_id']);
- $this->data['city_id'] = $city_id = intval($params['city_id']);
- $this->data['county_id'] = $county_id = intval($params['county_id']);
+ $province_id = intval($params['province_id']);
+ $city_id = intval($params['city_id']);
+ $county_id = intval($params['county_id']);
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
+ $export && $size = 10000;
if ($params['title']) {
$where["{$params['search_tp']} like '%{$params['title']}%'"] = null;
@@ -82,7 +116,7 @@ class Clues extends HD_Controller
$where["biz_id in(select id from lc_biz where county_id={$params['county_id_admin']})"] = null;
} else if ($params['city_id_admin']) {
$where["biz_id in(select id from lc_biz where city_id={$params['city_id_admin']})"] = null;
- }else if ($params['province_id_admin']) {
+ } else if ($params['province_id_admin']) {
$where["biz_id in(select id from lc_biz where province_id={$params['province_id_admin']})"] = null;
}
@@ -155,7 +189,6 @@ class Clues extends HD_Controller
$str_ids = implode(',', $province_id_arr);
$map_area_province = $this->area_model->map('province_id', '', ["province_id in ({$str_ids})" => null], '', 0, $size, 'province_id,province_name');
}
-
foreach ($rows as $key => $val) {
$val['cf_title'] = $cf_title_arr[$val['cf2_id']] ? $cf_title_arr[$val['cf2_id']] : $cf_title_arr[$val['cf_id']];
@@ -168,10 +201,10 @@ class Clues extends HD_Controller
if ($val['county_id']) {
$area = $map_area_county[$val['county_id']][0];
$val['poi'] = "{$area['province_name']}-{$area['city_name']}-{$area['county_name']}";
- }elseif ($val['city_id']) {
+ } elseif ($val['city_id']) {
$area = $map_area_city[$val['city_id']][0];
$val['poi'] = "{$area['province_name']}-{$area['city_name']}";
- }elseif ($val['province_id']) {
+ } elseif ($val['province_id']) {
$area = $map_area_province[$val['province_id']][0];
$val['poi'] = "{$area['province_name']}";
}
@@ -184,35 +217,9 @@ class Clues extends HD_Controller
$lists[] = $val;
}
}
- $statusList = array();
- foreach ($this->clues_model->statusAry() as $key => $value) {
- $cate = array();
- $where = array("status" => $key);
- $count1 = $this->clues_model->count($where);
- if ($value['list']) {
- foreach ($value['list'] as $key2 => $value2) {
- $where['status2'] = $key2;
- $count2 = $this->clues_model->count($where);
- $cate[] = array("id" => $key2, "name" => $value2, "count" => $count2);
- }
- }
- $statusList[] = array("id" => $key, "name" => $value['name'], "cate" => $cate, "count" => $count1);
- }
-
- $map_cfrom = $this->clues_cfrom_model->map('id', 'title', array('status' => 1, 'pid' => 0, 'type' => 0), '', 0, 0, 'id, title');
- $map_cfrom2 = $this->clues_cfrom_model->map('id', 'title', array('status' => 1, 'pid' => $params['cfrom_id']), '', 0, 0, 'id, title');
-
- $this->data['provinces'] = $this->province_ary();
- $this->data['lists'] = $lists;
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
- $this->data['searchTpAry'] = $this->searchTpAry;
- $this->data['params'] = $params;
- $this->data['cfromAry'] = $map_cfrom;
- $this->data['cfromAry2'] = $map_cfrom2;
- $this->data['statusList'] = $statusList;
- $this->data['maintainAry'] = $this->maintainAry;
- $this->data['_title'] = '线索池列表';
- return $this->show_view('receiver/clues/lists', true);
+
+ return [$lists, $count];
}
public function get()
@@ -273,7 +280,7 @@ class Clues extends HD_Controller
//门店
$biz = $this->biz_model->get(['id' => $re['biz_id']]);
- $dataInfo['province_id_admin'] = $biz ? $biz['province_id'] :0;
+ $dataInfo['province_id_admin'] = $biz ? $biz['province_id'] : 0;
$dataInfo['city_id_admin'] = $biz ? $biz['city_id'] : 0;
$dataInfo['county_id_admin'] = $biz ? $biz['county_id'] : 0;
$customer = $this->customers_model->get(array('rid' => $re['id'], 'status >' => -1));
@@ -403,7 +410,7 @@ class Clues extends HD_Controller
$log = '新增线索';
$this->addLog(array('clue_id' => $ret, 'type' => 3, 'log' => $log));
return $this->show_json(SYS_CODE_SUCCESS, '新增成功');
- }else{
+ } else {
debug_log("[error]# add fail; " . $this->clues_model->db->last_query(), __FUNCTION__, $this->log_dir);
return $this->show_json(SYS_CODE_FAIL, '新增失败');
}
@@ -533,10 +540,10 @@ class Clues extends HD_Controller
$this->addLog(array('clue_id' => $info['id'], 'type' => 0, 'log' => $log));
}
} else if ($info['editType'] == 3) {
- if($cus = $this->customers_model->get(array('mobile' => $re['mobile'], 'status >' => -1, 'biz_id' => $info['biz_id']))){
+ if ($cus = $this->customers_model->get(array('mobile' => $re['mobile'], 'status >' => -1, 'biz_id' => $info['biz_id']))) {
$code = SYS_CODE_FAIL;
$msg = '门店已有该线索';
- }else{
+ } else {
$up_data = [
'biz_id' => $info['biz_id'],
'p_time' => date('Y-m-d H:i:s'),
@@ -550,11 +557,11 @@ class Clues extends HD_Controller
$this->addLog(array('clue_id' => $info['id'], 'type' => 3, 'log' => '派单'));
}
}
- }else if ($info['editType'] == 4) {
- if($cus = $this->customers_model->get(array('mobile' => $re['mobile'], 'status >' => -1, 'biz_id' => $re['biz_id']))){
+ } else if ($info['editType'] == 4) {
+ if ($cus = $this->customers_model->get(array('mobile' => $re['mobile'], 'status >' => -1, 'biz_id' => $re['biz_id']))) {
$code = SYS_CODE_FAIL;
$msg = '门店已在跟踪';
- }else{
+ } else {
$this->load->helper("order");
$biz = $this->biz_model->get(array('id' => $re['biz_id']));
$add = array(
@@ -576,7 +583,7 @@ class Clues extends HD_Controller
);
$customers_id = $this->customers_model->add($add);
- if($customers_id){
+ if ($customers_id) {
$this->addLog(array('clue_id' => $re['id'], 'type' => 3, 'log' => '移交门店跟进'));
$this->clues_model->update(['status' => 1], ['id' => $re['id']]);
@@ -649,7 +656,37 @@ class Clues extends HD_Controller
//导出数据列表
public function export()
{
-
+ list($lists, $count) = $this->lists(1);
+ $indexs = [
+ 'id' => 'ID',
+ 'name' => '客户姓名',
+ 'mobile' => '手机',
+ 'cf_title' => "来源",
+ 'biz_name' => '门店',
+ 'biz_poi' => '所在地区',
+ 'status_name' => '状态',
+ 'c_time' => '创建时间',
+ ];
+ $data = [];
+ if ($lists) {
+ foreach ($lists as $key => $val) {
+ $item = [
+ 'id' => $val['id'],
+ 'name' => $val['name'],
+ 'mobile' => $val['mobile'],
+ 'cf_title' => $val['cf_title'],
+ 'biz_name' => $val['biz_name'],
+ 'biz_poi' => $val['biz_poi'],
+ 'status_name' => $val['status_name'],
+ 'c_time' => date('Y-m-d H:i:s', $val['c_time']),
+ ];
+ $data[] = $item;
+ }
+ }
+ $fileName = '线索列表';
+ array_unshift($data, $indexs);
+ $this->load->library('excel');
+ $this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
}
//分配
@@ -846,7 +883,7 @@ class Clues extends HD_Controller
$where = array();
if (strlen($pid) > 0) {
$where['pid'] = $pid;
- }else{
+ } else {
!$type && $type = 0;
$where['type'] = $type;
}
diff --git a/admin/controllers/receiver/Customer.php b/admin/controllers/receiver/Customer.php
index f2783e22..4ad5b21c 100644
--- a/admin/controllers/receiver/Customer.php
+++ b/admin/controllers/receiver/Customer.php
@@ -136,7 +136,7 @@ class Customer extends HD_Controller
$this->data['status_arr'] = $status_arr;
$this->data['qdjl_lists'] = $qdjl_lists;
$this->data['provinces'] = $this->province_ary();
- $this->data['export_button'] = SUPER_ADMIN == $this->role || in_array($this->uid, array(1, 62, 82)) ? 1 : 0;
+ $this->data['export_button'] = SUPER_ADMIN == $this->role ? 1 : 0;
$this->data['_title'] = '客户列表';
return $this->show_view('receiver/customer/lists', true);
}
@@ -919,20 +919,17 @@ class Customer extends HD_Controller
"dt_time" => "到店时间",
"order_time" => "下单时间",
"cont_time" => "最后联系时间",
- "c_brand" => "品牌归属",
"of_title_1" => "来源1",
"of_title_2" => "来源2",
"biz_name" => "归属门店",
"admin_name" => "归属顾问",
- "wxqy_name" => "企微好友",
"wxgr_name" => "加个微",
];
$count = $this->customers_model->count($where);
$data = [];
-
- $onlineSources = $this->customers_model->offlineSources();
+ $offlineSources = $this->customers_model->offlineSources();
$status_arr = $this->customers_model->get_status();
unset($status_arr['-1']);
if ($count) {
@@ -962,12 +959,10 @@ class Customer extends HD_Controller
'dt_time' => $val['dt_time'],
'order_time' => $val['order_time'],
'cont_time' => $val['cont_time'],
- 'c_brand' => $this->customers_model->cbrandAry($val['c_brand']),
'of_title_1' => $of_title_1,
'of_title_2' => $of_title_2,
'biz_name' => $val['biz_name'],
'admin_name' => $val['admin_name'],
- 'wxqy_name' => $this->customers_model->wxqyAry($val['wxqy']),
'wxgr_name' => $this->customers_model->wxgrAry($val['wxgr']),
);
diff --git a/admin/controllers/receiver/Orders.php b/admin/controllers/receiver/Orders.php
index 714d7f1b..373cc33d 100644
--- a/admin/controllers/receiver/Orders.php
+++ b/admin/controllers/receiver/Orders.php
@@ -420,11 +420,11 @@ class Orders extends HD_Controller
$params['size'] = 10000;
$indexs = [];
$params['status_pid'] == 5 && $params['status'] = 1;
- $fieldAry = $this->ordersv2list->get_fields($params['status_pid'], 1);
+ $fieldAry = $this->orderslist->get_fields($params['status_pid'], 1);
foreach ($fieldAry as $key => $value) {
$indexs[$key] = $value['title'];
}
- $result = $this->ordersv2list->lists($params['status_pid'], $params);
+ $result = $this->orderslist->lists($params['status_pid'], $params);
$fileName = $result['_title'];
foreach ($result['lists'] as $key => $value) {
$temp = array();
@@ -438,782 +438,6 @@ class Orders extends HD_Controller
return $this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
}
- //修改按揭图片
- public function edit_loanfile()
- {
- $params = $this->input->post();
- $oid = $params['id'];
- $file = $params['value'];
-
- $row_order = $this->receiver_orders_v2_model->get(array('id' => $oid));
- if (!$file || !$row_order) {
- return $this->show_json(SYS_CODE_FAIL, '参数错误');
- }
-
- $row = $this->order_loans_model->get(['o_id' => $oid]);
- if (!$row) {
- $this->order_loans_model->add(['o_id' => $oid, 'c_time' => time()]);
- $row = $this->order_loans_model->get(['o_id' => $oid]);
- }
- $notify_file_list = $row['notify_file'] ? explode(',', $row['notify_file']) : [];
- $update = [];
- if ($file) { //上传按揭通知函
- if ($params['type']) {
- $update['lend_file'] = $file;
- # 此处不检查load_time为空的情况,最后做“按揭完成”时也会检查
- $loan_time = $params['loan_time'];
- if ($loan_time) {
- $update['loan_time'] = date('Y-m-d H:i:s', strtotime($loan_time));
- }
- } else {
- $notify_file_list[] = $file;
- $update['notify_file'] = implode(',', $notify_file_list);
- }
- $this->data['file_url'] = build_qiniu_image_url($file);
- }
- if ($update) {
- $result = $this->order_loans_model->update($update, ['id' => $row['id']]);
- }
- $this->order_status_check_after_edit_loan($row_order);
- return $result ? $this->show_json(SYS_CODE_SUCCESS, '保存成功') : $this->show_json(SYS_CODE_FAIL, '保存失败');
- }
-
- //修改按揭图片-首付按揭
- public function edit_loanfile0()
- {
- $params = $this->input->post();
- $oid = $params['id'];
- $file = $params['value'];
-
- $row_order = $this->receiver_orders_v2_model->get(array('id' => $oid));
- if (!$file || !$row_order) {
- return $this->show_json(SYS_CODE_FAIL, '参数错误');
- }
-
- $row = $this->order_loans0_model->get(['o_id' => $oid]);
- if (!$row) {
- $this->order_loans0_model->add(['o_id' => $oid, 'c_time' => time()]);
- $row = $this->order_loans0_model->get(['o_id' => $oid]);
- }
- $notify_file_list = $row['notify_file'] ? explode(',', $row['notify_file']) : [];
- $update = [];
- if ($file) { //上传按揭通知函
- if ($params['type']) {
- $update['lend_file'] = $file;
- # 此处不检查load_time为空的情况,最后做“按揭完成”时也会检查
- $loan_time = $params['loan_time'];
- if ($loan_time) {
- $update['loan_time'] = date('Y-m-d H:i:s', strtotime($loan_time));
- }
- } else {
- $notify_file_list[] = $file;
- $update['notify_file'] = implode(',', $notify_file_list);
- }
- $this->data['file_url'] = build_qiniu_image_url($file);
- }
- if ($update) {
- $result = $this->order_loans0_model->update($update, ['id' => $row['id']]);
- }
- $this->order_status_check_after_edit_loan($row_order);
- return $result ? $this->show_json(SYS_CODE_SUCCESS, '保存成功') : $this->show_json(SYS_CODE_FAIL, '保存失败');
- }
-
- //修改按揭
- public function edit_loan()
- {
- $params = $this->input->post();
- $info = $params['info'];
- $oid = $params['id'] ? $params['id'] : $info['id'];
- $file = $_FILES['file'];
- $row = $this->order_loans_model->get(['o_id' => $oid]);
- if (!$row) {
- $this->order_loans_model->add(['o_id' => $oid, 'c_time' => time()]);
- $row = $this->order_loans_model->get(['o_id' => $oid]);
- }
- $notify_file_list = $row['notify_file'] ? explode(',', $row['notify_file']) : [];
- $update = [];
- $update['company_id'] = $info['loan_info']['company_id'];
- $update['num'] = $info['loan_info']['num'];
- $price_loan = $info['loan_info']['price_loan'];
- if ($file) { //上传按揭通知函
- $path = FCPATH . 'temp/';
- if (!file_exists($path)) {
- $oldumask = umask(0);
- mkdir($path, 0777, true);
- umask($oldumask);
- }
- $file_name = md5($file['name'] . uniqid()) . '.' . end(explode('.', $file['name']));
- $tmp = $path . $file_name;
- move_uploaded_file($file['tmp_name'], $tmp);
-
- if (!filesize($tmp)) {
- return $this->show_json(SYS_CODE_FAIL, '上传文件失败!');
- }
- $this->load->library('qiniu');
- $res = $this->qiniu->save($file_name, file_get_contents($tmp));
- unlink($tmp);
- if (!$res) {
- return $this->show_json(SYS_CODE_FAIL, '上传文件失败!');
- }
- if ($params['type']) {
- $update['lend_file'] = $res['file'];
- } else {
- $notify_file_list[] = $res['file'];
- $update['notify_file'] = implode(',', $notify_file_list);
- }
- $this->data['file_url'] = build_qiniu_image_url($res['file']);
- }
- strlen($params['status']) && $update['status'] = $params['status'];
- $finance_id = $info['finance_id'];
- if (!$finance_id || !$price_loan) {
- return $this->show_json(SYS_CODE_FAIL, '请填写完整信息!');
- }
- if ($params['status'] == 1) { //等待放款
- if (!$row['notify_file']) {
- return $this->show_json(SYS_CODE_FAIL, '请先上传按揭通知函!');
- }
- $order_row = $this->receiver_orders_v2_model->get(['id' => $row['o_id']], 'id,mobile,money_json');
- $money_json = json_decode($order_row['money_json'], true);
- $money_json['price_loan'] = $price_loan;
- $this->receiver_orders_v2_model->update(['finance_id' => $finance_id, 'money_json' => json_encode($money_json, JSON_UNESCAPED_UNICODE)], ['id' => $row['o_id']]);
- //生成购车订单
- $userinfo = $this->app_liche_users_model->get(['mobile' => $order_row['mobile']]);
- $this->orders_v2_entity->add_order($order_row['id'], $userinfo['id']);
- $result = $this->orders_status_entity->set_status($oid, 1, 1);
- } elseif ($params['status'] == 2) { //完成按揭
- $loan_time = $info['loan_info']['loan_time'];
- if (!$loan_time) {
- return $this->show_json(SYS_CODE_FAIL, '请选择放款时间!');
- }
- if (!$row['lend_file']) {
- return $this->show_json(SYS_CODE_FAIL, '请先上传按揭放款函!');
- }
- $update['loan_time'] = date('Y-m-d H:i:s', strtotime($loan_time));
-
- $order_row = $this->receiver_orders_v2_model->get(['id' => $row['o_id']], 'id,mobile,money_json');
- $money_json = json_decode($order_row['money_json'], true);
- // 不考虑-首付按揭要先完成才能 set_status($oid,1,2)
- /* if ($money_json['price_loan0']){
- if(!$this->app_liche_orders_model->get(['o_id'=>$row['id'],'type'=>8,'status'=>1])){
- return $this->show_json(SYS_CODE_FAIL, '请先完成首付按揭!');
- }
- }*/
- // 防止此页面有修改,同时更新price_loan与finance_id
- $money_json['price_loan'] = $price_loan;
- $this->receiver_orders_v2_model->update(['finance_id' => $finance_id, 'money_json' => json_encode($money_json, JSON_UNESCAPED_UNICODE)], ['id' => $row['o_id']]);
- $result = $this->orders_status_entity->set_status($oid, 1, 2);
- //添加按揭收款记录
- if (!$this->app_liche_orders_model->get(['o_id' => $row['o_id'], 'type' => 7])) {
- $p_row = $this->app_liche_orders_model->get(['o_id' => $row['o_id'], 'pid' => 0, 'status>=' => 0]);
- $order_row = $this->receiver_orders_v2_model->get(['id' => $row['o_id']]);
- $this->load->helper('order');
- $sid = create_order_no(350200, 'liche');
- $pay_log = [
- 'o_id' => $order_row['id'],
- 'sid' => $sid,
- 'pid' => $p_row['id'],
- 'admin_id' => $this->uid,
- 'brand_id' => $order_row['brand_id'],
- 'company_id' => $info['loan_info']['company_id'],
- 's_id' => $order_row['s_id'],
- 'v_id' => $order_row['v_id'],
- 'cor_id' => $order_row['cor_id'],
- 'incor_id' => $order_row['incor_id'],
- 'total_price' => $price_loan,
- 'pay_price' => $price_loan,
- 'type' => 7,
- 'status' => 1,
- 'pay_time' => date('Y-m-d H:i:s'),
- 'c_time' => time()
- ];
- $p_row['uid'] && $pay_log['uid'] = $p_row['uid'];
- $p_row['entrust_uid'] && $pay_log['entrust_uid'] = $p_row['entrust_uid'];
- $this->app_liche_orders_model->add($pay_log);
- }
- }
- if ($update) {
- $result = $this->order_loans_model->update($update, ['id' => $row['id']]);
- }
- return $result ? $this->show_json(SYS_CODE_SUCCESS, '保存成功') : $this->show_json(SYS_CODE_FAIL, '保存失败');
- }
-
- //修改按揭-首付按揭
- public function edit_loan0()
- {
- $params = $this->input->post();
- $info = $params['info'];
- $oid = $params['id'] ? $params['id'] : $info['id'];
- $file = $_FILES['file'];
- $row = $this->order_loans0_model->get(['o_id' => $oid]);
- if (!$row) {
- $this->order_loans0_model->add(['o_id' => $oid, 'c_time' => time()]);
- $row = $this->order_loans0_model->get(['o_id' => $oid]);
- }
- $notify_file_list = $row['notify_file'] ? explode(',', $row['notify_file']) : [];
- $update = [];
- $update['company_id'] = $info['loan_info0']['company_id'];
- $update['num'] = $info['loan_info0']['num'];
- $price_loan = $info['loan_info0']['price_loan'];
- if ($file) { //上传按揭通知函
- $path = FCPATH . 'temp/';
- if (!file_exists($path)) {
- $oldumask = umask(0);
- mkdir($path, 0777, true);
- umask($oldumask);
- }
- $file_name = md5($file['name'] . uniqid()) . '.' . end(explode('.', $file['name']));
- $tmp = $path . $file_name;
- move_uploaded_file($file['tmp_name'], $tmp);
-
- if (!filesize($tmp)) {
- return $this->show_json(SYS_CODE_FAIL, '上传文件失败!');
- }
- $this->load->library('qiniu');
- $res = $this->qiniu->save($file_name, file_get_contents($tmp));
- unlink($tmp);
- if (!$res) {
- return $this->show_json(SYS_CODE_FAIL, '上传文件失败!');
- }
- if ($params['type']) {
- $update['lend_file'] = $res['file'];
- } else {
- $notify_file_list[] = $res['file'];
- $update['notify_file'] = implode(',', $notify_file_list);
- }
- $this->data['file_url'] = build_qiniu_image_url($res['file']);
- }
- strlen($params['status']) && $update['status'] = $params['status'];
- $finance_id = $info['finance_id0'];
- if (!$finance_id || !$price_loan) {
- return $this->show_json(SYS_CODE_FAIL, '请填写完整信息!');
- }
- if ($params['status'] == 1) { //等待放款
- if (!$row['notify_file']) {
- return $this->show_json(SYS_CODE_FAIL, '请先上传按揭通知函!');
- }
- $order_row = $this->receiver_orders_v2_model->get(['id' => $row['o_id']], 'id,mobile,money_json');
- $money_json = json_decode($order_row['money_json'], true);
- $money_json['price_loan0'] = $price_loan;
- $this->receiver_orders_v2_model->update(['finance_id0' => $finance_id, 'money_json' => json_encode($money_json, JSON_UNESCAPED_UNICODE)], ['id' => $row['o_id']]);
- //生成购车订单
- $userinfo = $this->app_liche_users_model->get(['mobile' => $order_row['mobile']]);
- $this->orders_v2_entity->add_order($order_row['id'], $userinfo['id']);
- //$result = $this->orders_status_entity->set_status($oid,1,1); // 首付按揭不改订单状态
- $result = true;
- } elseif ($params['status'] == 2) { //完成按揭
- $loan_time = $info['loan_info0']['loan_time'];
- if (!$loan_time) {
- return $this->show_json(SYS_CODE_FAIL, '请选择放款时间!');
- }
- if (!$row['notify_file']) {
- return $this->show_json(SYS_CODE_FAIL, '请先上传按揭通知函!');
- }
- if (!$row['lend_file']) {
- return $this->show_json(SYS_CODE_FAIL, '请先上传按揭放款函!');
- }
- $update['loan_time'] = date('Y-m-d H:i:s', strtotime($loan_time));
- $order_row = $this->receiver_orders_v2_model->get(['id' => $row['o_id']], 'id,mobile,money_json');
- $money_json = json_decode($order_row['money_json'], true);
- $money_json['price_loan0'] = $price_loan;
- $this->receiver_orders_v2_model->update(['finance_id0' => $finance_id, 'money_json' => json_encode($money_json, JSON_UNESCAPED_UNICODE)], ['id' => $row['o_id']]);
- //$result = $this->orders_status_entity->set_status($oid,1,2); // 首付按揭不改订单状态
- //添加按揭收款记录
- if (!$this->app_liche_orders_model->get(['o_id' => $row['o_id'], 'type' => 8])) {
- $p_row = $this->app_liche_orders_model->get(['o_id' => $row['o_id'], 'pid' => 0, 'status>=' => 0]);
- $order_row = $this->receiver_orders_v2_model->get(['id' => $row['o_id']]);
- $this->load->helper('order');
- $sid = create_order_no(350200, 'liche');
- $pay_log = [
- 'o_id' => $order_row['id'],
- 'sid' => $sid,
- 'pid' => $p_row['id'],
- 'admin_id' => $this->uid,
- 'brand_id' => $order_row['brand_id'],
- 'company_id' => $info['loan_info0']['company_id'],
- 's_id' => $order_row['s_id'],
- 'v_id' => $order_row['v_id'],
- 'cor_id' => $order_row['cor_id'],
- 'incor_id' => $order_row['incor_id'],
- 'total_price' => $price_loan,
- 'pay_price' => $price_loan,
- 'type' => 8,
- 'status' => 1,
- 'pay_time' => date('Y-m-d H:i:s'),
- 'c_time' => time()
- ];
- $p_row['uid'] && $pay_log['uid'] = $p_row['uid'];
- $p_row['entrust_uid'] && $pay_log['entrust_uid'] = $p_row['entrust_uid'];
- $this->app_liche_orders_model->add($pay_log);
- }
- }
- if ($update) {
- $result = $this->order_loans0_model->update($update, ['id' => $row['id']]);
- }
- return $result ? $this->show_json(SYS_CODE_SUCCESS, '保存成功') : $this->show_json(SYS_CODE_FAIL, '保存失败');
- }
-
- public function edit_item()
- {
- $this->load->model("items/items_model");
-
- $id = $this->input->post('id');
- $item_id = $this->input->post('item_id');
- $row = $this->receiver_orders_v2_model->get(['id' => $id]);
- if (!$row) {
- return $this->show_json(SYS_CODE_FAIL, '参数错误!');
- }
- if (!$item_id) return $this->show_json(SYS_CODE_FAIL, '请选择车辆!');
-
-// if ($this->receiver_order_status_model->get(['o_id'=>$id,'pid_status'=>3,'status'=>1])) {
-// return $this->show_json(SYS_CODE_FAIL, '已开票,不能修改!');
-// }
- $res = $this->receiver_orders_v2_model->update(['item_id' => $item_id], ['id' => $id]);
- if (!$res) {
- return $this->show_json(SYS_CODE_FAIL, '保存失败');
- }
- if ($row['item_id'] && $row['item_id'] != $item_id) {
- $this->items_model->update(['status' => 1], ['id' => $row['item_id']]);
- }
- $update = [
- 'status' => 2,
- ];
- if ($row['bill_time'] != '0000-00-00 00:00:00') {
- $update['bill_time'] = $row['bill_time'];
- }
- $buy_price = $this->input->post('buy_price');
- $buy_price_origin = $this->input->post('buy_price_origin');
- $estimated_rebate = $this->input->post('estimated_rebate');
- $estimated_rebate_origin = $this->input->post('estimated_rebate_origin');
- $buy_price != $buy_price_origin && $update['buy_price'] = $buy_price;
- $estimated_rebate != $estimated_rebate_origin && $update['estimated_rebate'] = $estimated_rebate;
- $result = $this->items_model->update($update, ['id' => $item_id]);
-
- if ($result) {
- $this->orders_status_entity->set_status($id, 2, 1);
- }
- if ($result) {
- return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
- } else {
- return $this->show_json(SYS_CODE_FAIL, '保存失败');
- }
- }
-
- //查看发票信息
- public function get_bill()
- {
- $oid = $this->input->get('oid');
- $row = $this->receiver_orders_v2_model->get(['id' => $oid]);
- $bill = $this->order_bills_model->get(['o_id' => $oid]);
- if (!$row) {
- return $this->show_json(SYS_CODE_FAIL, '参数错误!');
- }
- if (!$bill) {
- $add_data = [
- 'o_id' => $row['id'],
- 'c_time' => time()
- ];
- $bill['id'] = $this->order_bills_model->add($add_data);
- }
- $bill['src_file'] = $bill['file'] ? build_qiniu_image_url($bill['file']) : '';
- $bill['bill_time'] = $row['bill_time'] != '0000-00-00 00:00:00' ? $row['bill_time'] : '';
- $this->data['bill'] = $bill;
- return $this->show_view('receiver/orderv2/get/get_bill');
- }
-
- //编辑发票信息
- public function edit_bill()
- {
- $id = $this->input->post('id');
- $file = $this->input->post('value');
- $if_usedcar = $this->input->post('if_usedcar');
- $row_order = $this->receiver_orders_v2_model->get(array('id' => $id));
- if (!$file || !$row_order) {
- return $this->show_json(SYS_CODE_FAIL, '参数错误');
- }
- $row = $this->order_bills_model->get(['o_id' => $row_order['id']]);
- if (!$row) {
- $jsondata = [];
- $this->order_bills_model->add(['c_time' => time(), 'o_id' => $row_order['id']]);
- } else {
- $jsondata = json_decode($row['jsondata'], true);
- }
-
- $bill_time = date('Y-m-d H:i:s'); # 2023-03-02 $if_usedcar或识别图片开票时间失败,强制开票时间为当前时间
- if (!$if_usedcar) {
- //图片识别
- $img_url = build_qiniu_image_url($file);
- $orc_res = $this->tcorc->CarInvoiceInfos($img_url);
- if (!$orc_res['code']) {
- return $this->show_json(2, $orc_res['msg']);
- }
- $carinfo = $orc_res['data']['CarInvoiceInfos'];
- $bill_name = '';
- if (is_array($carinfo)) {
- foreach ($carinfo as $kye => $val) {
- if ($val['Name'] == '发票名称') {
- $bill_name = $val['Value'];
- }
- if ($val['Name'] == '开票日期') {
- $bill_time = $val['Value'];
- }
- }
- }
-
- # 发票名称为空, 按增值税发票处理
- if (!$bill_name) {
- $orc_res = $this->tcorc->VatInvoice($img_url);
- if (!$orc_res['code']) {
- return $this->show_json(3, $orc_res['msg']);
- }
- $carinfo = $orc_res['data']['VatInvoiceInfos'];
- if (is_array($carinfo)) {
- foreach ($carinfo as $kye => $val) {
- if ($val['Name'] == '发票名称') {
- $bill_name = $val['Value'];
- }
- if ($val['Name'] == '开票日期') {
- # 开票日期:2023年04月27日
- $tmp_value = $val['Value'];
- $tmp_value = str_replace("年", "-", $tmp_value);
- $tmp_value = str_replace("月", "-", $tmp_value);
- $tmp_value = str_replace("日", "", $tmp_value);
- $bill_time = $tmp_value;
- }
- }
- }
- # 发票名称为空,可能是保单等图片
- if (!$bill_name) {
- return $this->show_json(4, "识别失败");
- }
- }
-
- $jsondata['infos'] = $carinfo;
- }
- $update['file'] = $file;
- $update['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
- $result = $this->order_bills_model->update($update, ['o_id' => $row_order['id']]);
- if ($result) {
- //更新开票时间
- $this->load->model('items/items_model');
- $upd = array('bill_time' => $bill_time);
- $where = array('id' => $row_order['item_id']);
- $ret = $this->items_model->update($upd, $where);
- if ($ret) { //添加开票日志
- $this->load->library('entity/items_entity');
- $re_i = $this->items_model->get(['id' => $row_order['item_id']]);
- $params = array('item_id' => $row_order['item_id'], 'type' => 3, 'uid' => $this->uid, 'uname' => $this->username
- , 'com_time' => $bill_time, 'biz_id' => $re_i['biz_id'], 'addr_id' => $re_i['addr_id']);
- $this->items_entity->add_log($params);
- }
- $update = ['bill_time' => $bill_time];
- $if_usedcar && $update['if_usedcar'] = 1;
- $this->receiver_orders_v2_model->update($update, ['id' => $row_order['id']]);
- $this->orders_status_entity->set_status($row_order['id'], 3, 1);
- return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
- } else {
- return $this->show_json(SYS_CODE_FAIL, '保存失败');
- }
- }
-
- //确定交款
- public function edit_jk()
- {
- $oid = $this->input->post('oid');
- $row = $this->receiver_orders_v2_model->get(['id' => $oid]);
- if (!$row) {
- return $this->show_json(SYS_CODE_FAIL, '参数错误!');
- }
- $bill = $this->order_bills_model->get(['o_id' => $oid]);
- if (!$bill['file'] || !$bill['money']) {
- return $this->show_json(SYS_CODE_FAIL, '未上传开票文件或未填写到账金额!');
- }
- $where = [
- 'o_id' => $oid,
- 'status' => 1,
- 'pay_price>' => 0,
- 'type!=' => 7
- ];
- $sum = $this->app_liche_orders_model->sum('total_price', $where); //已收金额
- $need_price = $this->orders_v2_entity->recevable_price($oid); //应收金额
- if ($sum['total_price'] < $need_price) {
- return $this->show_json(SYS_CODE_FAIL, '修改失败,已收金额小于应收金额!');
- }
- $this->order_bills_model->update(['status' => 2], ['o_id' => $oid]);
- $this->orders_status_entity->set_status($oid, 3, 1);
- return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
- }
-
- //获取合同图片
- public function get_cimgs()
- {
- $type = $this->input->get('type');
- $oid = $this->input->get('oid');
- $row = $this->order_contracts_model->get(['type' => $type, 'o_id' => $oid]);
- $info['title'] = '相册标题';
- $info['id'] = '222';
- $info['start'] = 0;
- $data = [];
- if ($row) {
- $imgs = json_decode($row['imgs'], true);
- foreach ($imgs as $key => $val) {
- $data[] = [
- 'alt' => '图片名',
- 'pid' => $key,
- 'src' => build_qiniu_image_url($val),
- 'thumb' => build_qiniu_image_url($val)
- ];
- }
- }
- $info['data'] = $data;
- $this->data['info'] = $info;
- return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
- }
-
- //支付列表
- public function get_paylog()
- {
- $params = $this->input->get();
- if ($params['d_type'] == 'ajax') {
- $page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
- $size = $params['size'] = $params['size'] ? intval($params['size']) : 10;
- $list = [];
- $where = [
- 'o_id' => $params['id'],
- 'status' => 1,
- "id not in (select id from lc_app_liche_orders where (type=3 and o_id={$params['id']} and pay_price=0) or (o_id={$params['id']} and pid=0))" => null
- ];
- $count = $this->app_liche_orders_model->count($where);
- if ($count) {
- $rows = $this->app_liche_orders_model->select($where, 'id desc', $page, $size, 'id,total_price,type,pay_time,mch_id,descrip,status,pid,img,admin_id,company_id');
- $type_arr = $this->app_liche_orders_model->get_type_arr();
- foreach ($rows as $item) {
- $company = '';
- if ($item['mch_id']) {
- $company = $this->sys_company_model->get(['wx_mchid' => $item['mch_id']], 'short');
- }
- if ($item['company_id']) {
- $company = $this->sys_company_model->get(['id' => $item['company_id']], 'short');
- }
- $opt_name = '用户';
- if ($item['admin_id']) {
- $admin_user = $this->sys_admin_model->get(array('id' => $item['admin_id']), 'username');
- $opt_name = $admin_user['username'];
- }
- $list[] = [
- 'id' => $item['id'],
- 'money' => $item['total_price'],
- 'type_cn' => $type_arr[$item['type']],
- 'pay_time' => $item['pay_time'],
- 'company' => $company ? $company['short'] : '',
- 'opt_name' => $opt_name,
- 'show_img' => 0,
- 'descrip' => $item['descrip'],
- 'img' => $item['img'] ? build_qiniu_image_url($item['img']) : '',
- 'admin_id' => $item['admin_id'],
- ];
- }
- }
- $sum = $this->app_liche_orders_model->sum('total_price', ['o_id' => $params['id'], 'status' => 1, 'pay_price <>' => 0]);
- $this->data['pay_price'] = $sum['total_price'] ? $sum['total_price'] : 0;
- $this->data['need_price'] = $this->orders_v2_entity->recevable_price($params['id']);
- $this->data['list'] = $list;
- $hasNext = ceil($count / $size) > $page ? 1 : 0;
- $this->data['commonPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
-
- $car_info = [
- 'vin' => ''
- ];
- $row = $this->receiver_orders_v2_model->get(['id' => $params['id']]);
- $money_json = json_decode($row['money_json'], true);
- if (!$row['payway']) { //贷款
- $this->data['need_price'] += $money_json['price_loan'];
- $this->data['price_loan'] = $money_json['price_loan'];
-
- // 首付按揭
- if ($money_json['price_loan0']) {
- $this->data['need_price'] += $money_json['price_loan0'];
- $this->data['price_loan0'] = $money_json['price_loan0'];
- }
- }
- $car_info['name'] = $row['owner_name'];
- //获取车信息
- $brand = $this->auto_brand_model->get(['id' => $row['brand_id']], 'name');
- $serie = $this->auto_series_model->get(['id' => $row['s_id']], 'name');
- $row['brand_name'] = $brand['name'];
- $row['s_name'] = $serie['name'];
- $attr_arr = [$row['v_id'], $row['cor_id'], $row['incor_id']];
- $attr = $this->auto_attr_model->get_map_by_ids($attr_arr, 'id,title');
- $row['v_name'] = isset($attr[$row['v_id']]) ? $attr[$row['v_id']][0]['title'] : '';
- $row['cor_name'] = isset($attr[$row['cor_id']]) ? $attr[$row['cor_id']][0]['title'] : '';
- $row['incor_name'] = isset($attr[$row['incor_id']]) ? $attr[$row['incor_id']][0]['title'] : '';
- $car_info['car'] = "{$row['brand_name']}-{$row['s_name']}-{$row['v_name']}-{$row['incor_name']}";
- //获取选择车辆vin
- if ($row['item_id']) {
- $this->load->model('items/items_model', 'mdItems');
- $row_goods = $this->mdItems->get(array('id' => $row['item_id']));
- $car_info['vin'] = $row_goods['vin'];
- }
- $this->data['car_info'] = $car_info;
- return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
- }
- $this->data['id'] = $this->input->get('id');
- return $this->show_view('receiver/orderv2/get/paylog');
- }
-
- //添加支付日志
- public function add_paylog()
- {
- $id = $this->input->get_post('id');
- $log_id = $this->input->get_post('log_id');
- $row = $this->receiver_orders_v2_model->get(['id' => $id]);
- $order_row = $this->app_liche_orders_model->get(['id' => $log_id, 'o_id' => $row['id']]);
- $srv_price = $this->orders_v2_entity->order_srv_money($row['id']);
- $need_price = $this->orders_v2_entity->recevable_price($row['id']);
- $car_price = $need_price - $srv_price;
- if ($this->input->method() == 'post') {
- $money = $this->input->post('money');
- $pay_time = $this->input->post('pay_time');
- !$pay_time && $pay_time = date('Y-m-d H:i:s');
- $wx_mchid = $this->input->post('wx_mchid');
- $descrip = $this->input->post('descrip');
- $type = $this->input->post('type');
- $img = $this->input->post('img');
- if (!$money || !$row || !$wx_mchid) {
- return $this->show_json(SYS_CODE_FAIL, '参数错误');
- }
- $company_id = 0;
- $notify = true; # 0614 防止修改唯一已支付记录时,重发订单通知
- if ($order_row["id"]) { //修改订单更新旧订单为无效订单
- $this->app_liche_orders_model->update(['status' => -1], ['id' => $order_row['id']]);
- if ($order_row['pay_price'] >= 100 || $order_row['descrip'] == 1 && $order_row['descrip'] == '零首付') {
- $notify = false;
- }
- # 修改时此3项保持一致
- $company_id = $order_row['company_id'];
- $pay_time = $order_row['pay_time'];
- $type = $order_row['type'];
- }
- $p_row = $this->app_liche_orders_model->get(['pid' => 0, 'o_id' => $row['id']]);
- $last_p_row = $this->app_liche_orders_model->get(['o_id' => $row['id'], 'type' => 3, 'pid' => $p_row['id'], 'status>=' => 0]); //尾款父订单
-
- if ($type == 6) { //尾款
-// if($money>$car_price){
-// return $this->show_json(SYS_CODE_FAIL, '车款金额错误');
-// }
- $this->app_liche_orders_model->update(['status' => -1], ['o_id' => $row['id'], 'status' => 0, 'type' => 1]); //定金更新成无效订单
- $money_json = json_decode($row['money_json'], true);
- $last_pay_count = $this->app_liche_orders_model->count(['pid' => $last_p_row['id'], 'type' => 3, 'status' => 1]);//尾款支付订单
- $adimn_count = $this->app_liche_orders_model->count(['o_id' => $row['id'], 'type' => 6, 'status' => 1]);//车款订单
- if (!$last_pay_count && ($money != $money_json['price_book'] || $adimn_count)) { //若首笔金额 == 定金金额,尾款订单不要置为 -1若金额 > 定金金额 或者 非首笔,尾款订单置为 -1
- $this->app_liche_orders_model->update(['status' => -1], ['o_id' => $row['id'], 'type' => 3]); //尾款更新成无效订单
- } else {
- $last_noppay_row = $this->app_liche_orders_model->get(['o_id' => $row['id'], 'type' => 3, 'status' => 0]);//未支付尾款订单
- $pay_ck = $this->app_liche_orders_model->sum('pay_price', ['o_id' => $row['id'], 'type in (1,6)' => null, 'status' => 1]);//已支付车款
- if ($last_noppay_row) {
- $cj_money = $car_price - ($money + $pay_ck['pay_price']);
- $this->app_liche_orders_model->update(['total_price' => $cj_money], ['id' => $last_noppay_row['id']]);
- }
- }
- } else { //服务费
-// if($money>$srv_price){
-// return $this->show_json(SYS_CODE_FAIL, '服务费金额错误');
-// }
- $this->app_liche_orders_model->update(['status' => -1], ['o_id' => $row['id'], 'type' => 2, 'status' => 0]); //未支付更新成无效订单
- }
- $this->load->helper('order');
- $sid = create_order_no(350200, 'liche');
- $data = [
- 'o_id' => $row['id'],
- 'sid' => $sid,
- 'pid' => $p_row['id'],
- 'mch_id' => $wx_mchid,
- 'admin_id' => $this->uid,
- 'brand_id' => $row['brand_id'],
- 's_id' => $row['s_id'],
- 'v_id' => $row['v_id'],
- 'cor_id' => $row['cor_id'],
- 'incor_id' => $row['incor_id'],
- 'company_id' => $company_id,
- 'total_price' => $money,
- 'pay_price' => $money,
- 'type' => $type,
- 'status' => 1,
- 'pay_time' => $pay_time ? date('Y-m-d H:i:s', strtotime($pay_time)) : date('Y-m-d H:i:s'),
- 'c_time' => time()
- ];
- $p_row['uid'] && $data['uid'] = $p_row['uid'];
- $p_row['entrust_uid'] && $data['entrust_uid'] = $p_row['entrust_uid'];
- $img && $data['img'] = $img;
- $descrip && $data['descrip'] = $descrip;
- $this->app_liche_orders_model->add($data);
- if ($this->app_liche_orders_model->count(['status' => 1, 'o_id' => $row['id']]) == 1 && $money >= 100 && $notify) { //企业微信推送
- $this->orders_status_entity->set_status($row['id'], 0, 1);
- if (date('Y-m-d', strtotime($pay_time)) == date('Y-m-d')) { //当天
- $this->qyrobot->deposit_notify_v3($row['id']);
- } else {
- if (strtotime($data['pay_time']) >= strtotime(date('Y-m-01 00:00:00'))) { //直播报本月补缴订单
- $this->qyrobot->deposit_notify_v3($row['id'], 1, $data['pay_time']);
- }
- }
-
- }
- $where = [
- 'status' => 1,
- 'o_id' => $row['id'],
- 'pid>' => 0,
- ];
- $last_p_row && $where['id <>'] = $last_p_row['id'];
- $is_pay = $this->app_liche_orders_model->sum('total_price', $where); //已支付金额
- if ($need_price && $is_pay['total_price'] >= $need_price) { //完成支付
- $this->app_liche_orders_model->update(['status' => 1], ['o_id' => $row['id'], 'pid' => 0]);//主订单设置成支付
- $last_p_row && $this->app_liche_orders_model->update(['status' => 1], ['id' => $last_p_row['id']]);//完成未支付尾款
- $this->orders_status_entity->set_status($row['id'], 0, 2);
- }
- if (!$this->order_contracts_model->count(['o_id' => $row['id']])) { //生成合同
- $url = http_host_com('api') . '/pdfapi/add_pdf?oid=' . $row['id'];
- $pdf_res = file_get_contents($url);
- }
- if ($row['order_time'] == '0000-00-00 00:00:00') { //更新下定时间
- $this->receiver_orders_v2_model->update(['order_time' => date('Y-m-d H:i:s', strtotime($pay_time))], ['id' => $row['id']]);
- }
- //更新客户为订单客户
- $this->customers_model->update(['status' => 2], ['id' => $row['customer_id']]);
- return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
- }
-
- $companys = $this->sys_company_model->select(['status' => 1, 'wx_mchid!=' => ''], 'id desc', '', '', 'id,wx_mchid,short');
- $type = [];
- $type[] = ['id' => 6, 'name' => '车款'];
- $srv_price > 0 && $type[] = ['id' => 2, 'name' => '服务费'];
- $this->data['type'] = $type;
- $this->data['companys'] = $companys;
- $this->data['id'] = $this->input->get('id');
- $this->data['order_row'] = $order_row;
- return $this->show_view('receiver/orderv2/get/add_paylog');
- }
-
- //取消配车
- public function edit_ckcar()
- {
- $this->load->model('items/items_model');
- $id = $this->input->post('id');
- $row = $this->receiver_orders_v2_model->get(['id' => $id]);
- if (!$row || !$row['item_id']) {
- return $this->show_json(SYS_CODE_FAIL, '参数错误');
- }
- if ($this->receiver_order_status_model->get(['o_id' => $id, 'pid_status' => 3, 'status' => 1])) {
- return $this->show_json(SYS_CODE_FAIL, '订单已开票,不能修改!');
- }
- $res = $this->receiver_orders_v2_model->update(['item_id' => 0], ['id' => $row['id']]);
- if ($res) {
- $this->items_model->update(['status' => 1, 'bill_time' => '0000-00-00 00:00:00'], ['id' => $row['item_id']]);
- $this->receiver_order_status_model->delete(['o_id' => $id, 'pid_status' => 2, 'status' => 1]);
- return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
- } else {
- return $this->show_json(SYS_CODE_FAIL, '保存失败');
- }
- }
-
//修改图片
public function edit_imgs()
{
@@ -1247,93 +471,6 @@ class Orders extends HD_Controller
}
}
- public function edit_ckimg()
- {
- $type = $this->input->post('type');
- $ifcheck = $this->input->post('ifcheck');
- $o_id = $this->input->post('id');
- $img_data = $this->receiver_order_datas_model->get(['o_id' => $o_id]);
- if (!$img_data) {
- return $this->show_json(SYS_CODE_FAIL, '参数错误');
- }
- $ck_row = $this->app_checkdata_model->get(['cf_id' => $img_data['id'], 'app_id' => 2, 'type' => $type]);
- if ($ck_row) {
- $update = [
- 'ifcheck' => $ifcheck ? 1 : -1,
- ];
- $res = $this->app_checkdata_model->update($update, ['id' => $ck_row['id']]);
- } else {
- $add_data = [
- 'cf_id' => $img_data['id'],
- 'app_id' => 2,
- 'type' => $type,
- 'datatype' => 'img',
- 'ifcheck' => $ifcheck ? 1 : -1,
- 'c_time' => time()
- ];
- $res = $this->app_checkdata_model->add($add_data);
- }
- if ($res) {
- $count = $this->app_checkdata_model->count(['ifcheck' => 1, 'cf_id' => $img_data['id'], 'datatype' => 'img']);
-// if($count==5){
-// $this->orders_status_entity->set_status($img_data['o_id'],6,2);
-// }
- return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
- } else {
- return $this->show_json(SYS_CODE_FAIL, '保存失败');
- }
- }
-
- //修改资料信息
- public function edit_agent()
- {
- $params = $this->input->post();
- $row = $this->receiver_orders_v2_model->get(['id' => $params['oid']]);
- if (!$row) {
- return $this->show_json(SYS_CODE_FAIL, '参数错误!');
- }
- $agent = $this->order_agents_model->get(['o_id' => $row['id']]);
- $update = [];
- $update['car_num'] = $params['car_num'];
- $update['ins_time'] = $params['ins_time'] ? date('Y-m-d H:i:s', strtotime($params['ins_time'])) : '0000-00-00 00:00:00';
-
- if ($agent) {
- $result = $this->order_agents_model->update($update, ['id' => $agent['id']]);
- } else {
- $update['o_id'] = $row['id'];
- $update['c_time'] = time();
- $result = $this->order_agents_model->add($update);
- }
- if ($result) {
- $img_data = $this->receiver_order_datas_model->get(['o_id' => $row['id']]);
- $insurance_img = json_decode($img_data['insurance_img'], true);
- $business_img = json_decode($img_data['business_img'], true);
- $accident_img = json_decode($img_data['accident_img'], true);
- $insurance_img['product'] = $params['insurance_product'];
- $insurance_img['price'] = $params['insurance_price'];
- $business_img['product'] = $params['business_product'];
- $business_img['price'] = $params['business_price'];
- $accident_img['product'] = $params['accident_title'];
- $accident_img['price'] = $params['accident_price'];
-
- # 23-04-03: close accident_title, accident_price
- /*$img_data_jsondata = json_decode($img_data['jsondata'],true);
- $img_data_jsondata['accident_title'] = $params['accident_title'];
- $img_data_jsondata['accident_price'] = $params['accident_price'];*/
-
- $up_data = [
- 'insurance_img' => json_encode($insurance_img, JSON_UNESCAPED_UNICODE),
- 'business_img' => json_encode($business_img, JSON_UNESCAPED_UNICODE),
- 'accident_img' => json_encode($accident_img, JSON_UNESCAPED_UNICODE),
- #'jsondata' => json_encode($img_data_jsondata,JSON_UNESCAPED_UNICODE)
- ];
- $this->receiver_order_datas_model->update($up_data, ['o_id' => $row['id']]);
- return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
- } else {
- return $this->show_json(SYS_CODE_FAIL, '保存失败');
- }
- }
-
//修改支付订单状态
public function edit_status()
{
@@ -1364,469 +501,6 @@ class Orders extends HD_Controller
return $this->show_view('receiver/orderv2/edit_status');
}
- //修改支付订单状态-一键完成
- public function edit_finished()
- {
- if ($this->input->method() == 'post') {
- $id = $this->input->post('id');
- if (!$id) {
- return $this->show_json(SYS_CODE_FAIL, '订单id必须填写');
- }
-
- $row = $this->receiver_orders_v2_model->get(['id' => $id]);
- if (!$row) {
- return $this->show_json(SYS_CODE_FAIL, '订单不存在');
- }
- if ($row['status']) {
- return $this->show_json(SYS_CODE_FAIL, '订单无法操作');
- }
-
- $now_time = date('Y-m-d H:i:s');
- $jsondata = array();
- $res_order = $this->receiver_orders_v2_model->update(['status' => 1, 'ck_time' => $now_time], ['id' => $id]);
- !is_bool($res_order) && $res_order && $jsondata['order.status'] = "{$row['status']}->1";
- $res = $this->receiver_orders_v2_model->update(['order_time' => $now_time], ['id' => $id, 'order_time' => '0000-00-00 00:00:00']);
- !is_bool($res) && $res && $jsondata['order.order_time'] = "{$row['order_time']}";
- $res = $this->receiver_orders_v2_model->update(['bill_time' => $now_time], ['id' => $id, 'bill_time' => '0000-00-00 00:00:00']);
- !is_bool($res) && $res && $jsondata['order.bill_time'] = "{$row['bill_time']}";
-
- $res = $this->orders_status_entity->set_status($id, 0, 1);
- $res && $jsondata['set_status_0_1'] = $res;
-
- $res = $this->orders_status_entity->set_status($id, 0, 2);
- $res && $jsondata['set_status_0_2'] = $res;
-
- if (!$row['payway']) {
- $res = $this->orders_status_entity->set_status($id, 1, 1);
- $res && $jsondata['set_status_1_1'] = $res;
- $res = $this->orders_status_entity->set_status($id, 1, 2);
- $res && $jsondata['set_status_1_2'] = $res;
- }
-
- $res = $this->orders_status_entity->set_status($id, 2, 1);
- $res && $jsondata['set_status_2_1'] = $res;
-
- $res = $this->orders_status_entity->set_status($id, 3, 1);
- $res && $jsondata['set_status_3_1'] = $res;
-
- $res = $this->orders_status_entity->set_status($id, 4, 1);
- $res && $jsondata['set_status_4_1'] = $res;
-
- $res = $this->orders_status_entity->set_status($id, 4, 2);
- $res && $jsondata['set_status_4_2'] = $res;
-
- $res = $this->orders_status_entity->set_status($id, 5, 1);
- $res && $jsondata['set_status_5_1'] = $res;
-
- $cus_id = $row['customer_id'];
- $cus = $this->customers_model->get(['id' => $cus_id]);
- $res = $this->customers_model->update(['status' => 2, 'order_time' => $now_time], ['id' => $cus_id]);
- !is_bool($res) && $res && $jsondata['customer.status'] = "{$cus['status']}->2";
- $res = $this->customers_model->update(['order_time' => $now_time], ['id' => $cus_id, 'order_time' => '0000-00-00 00:00:00']);
- !is_bool($res) && $res && $jsondata['customer.order_time'] = "{$cus['order_time']}";
- $res && $jsondata['customer.order_time2'] = "{$cus['order_time']}, {$res}";
-
- $content = '后台一键完成';
- $cf_platform = 'pc_admin';
- $this->orders_entity->add_log($id, $this->uid, $this->username, $content, 0, $cf_platform, $jsondata = json_encode($jsondata, JSON_UNESCAPED_UNICODE));
-
- if ($res_order) {
- return $this->show_json(SYS_CODE_SUCCESS, '修改成功');
- } else {
- return $this->show_json(SYS_CODE_FAIL, '保存失败');
- }
- }
- return $this->show_json(SYS_CODE_FAIL, '提交失败');
- }
-
- //下载pdf
- public function get_down()
- {
- require_once COMMPATH . '/third_party/TCPDF/tcpdf.php';
- $id = $this->input->get('id');
- $type = intval($this->input->get('type'));
- $row = $this->receiver_orders_v2_model->get(['id' => $id], 'id,sid,owner_mobile,owner_name');
- $contract = $this->order_contracts_model->get(['o_id' => $row['id'], 'type' => $type], 'id,o_id,file,imgs,type');
- if (!$row || !$contract) {
- return false;
- }
- $type_arr = [0 => '汽车购车协议', 1 => '委托服务协议', 2 => '车辆确定', 3 => '车辆交付'];
- $old_type_arr = [0 => '整车合同', 1 => '委托服务协议', 2 => '车辆确定', 3 => '交车信息', 4 => '车辆买卖合同补充协议', 5 => '委托服务补充协议'];
- $path = FCPATH . "pdf/{$row['owner_name']}";
- $row['owner_mobile'] && $path .= "({$row['owner_mobile']})";
- if ($contract['o_id'] >= 10000) {
- $file_name = $type_arr[$contract['type']] ? $type_arr[$contract['type']] . '.pdf' : '其它_' . time() . '.pdf';
- } else {
- $file_name = $old_type_arr[$contract['type']] ? $old_type_arr[$contract['type']] . '.pdf' : '其它_' . time() . '.pdf';
- }
- $file = $path . '/' . $file_name;
- if (!file_exists($file)) {
- $imgs = json_decode($contract['imgs'], true);
- if (!$imgs) {
- file_get_contents("https://api.liche.cn/wxapp/licheb/protocol/pdf_img?id={$contract['id']}");
- $contract = $this->order_contracts_model->get(['o_id' => $row['o_id'], 'type' => $type], 'id,o_id,file,imgs,type');
- $imgs = json_decode($contract['imgs'], true);
- }
- if (!file_exists($path)) {
- $oldumask = umask(0);
- mkdir($path, 0777, true);
- umask($oldumask);
- }
- $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
- $pdf->SetCreator(PDF_CREATOR);
- //删除预定义的打印 页眉/页尾
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- //设置默认等宽字体
- $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
- $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
- $pdf->SetFont('stsongstdlight', '', 20);
- $pdf->AddPage();
- $options = array(
- // 解决SSL证书验证失败的问题
- "ssl" => array(
- "verify_peer" => false,
- "verify_peer_name" => false,
- )
- );
- //设置文件信息
- foreach ($imgs as $item) {
- $img_url = build_qiniu_image_url($item);
- $res = file_get_contents($img_url, false, stream_context_create($options));
- $pdf->Ln();
- $pdf->Image('@' . $res, '', '', '', '', '', $img_url, '', false, 300, '', false, false, 0.05, false, false, false);
- }
-
- $pdf->Output($file, 'F');
- }
- ob_end_clean();
- //检查文件是否存在于目录
- if (!file_exists($file)) {
- header('HTTP/1.1 404 NOT FOUND');
- } else {
- ob_end_clean();
- header('Content-Description: File Transfer');
- header('Content-Type: application/octet-stream');
- //请求范围的度量单位
- Header("Accept-Ranges: bytes");
- //下载后的文件名称为$file_name
- header('Content-Disposition: attachment; filename=' . $file_name);
- header('Content-Transfer-Encoding: binary');
- #Expires:设置页面缓存时间
- header('Expires: 0');
- header('Cache-Control: must-revalidate');
- header('Pragma: no cache');
- //Content-Length是指定包含于请求或响应中数据的字节长度
- header('Content-Length: ' . filesize($file));
- ob_clean();
- flush();
- readfile($file);
- ob_end_clean();
- }
- }
-
- //2022.12.19, 修改订单的优惠金额/服务费,判断是否到开票
- private function order_status_check_after_adjust_fee($id)
- {
- if (!$id) {
- return false;
- }
- $where = [
- 'o_id' => $id,
- 'status' => 1,
- 'pay_price>' => 0,
- 'type not in (7, 8)', // 'type!=' => 7 // 8为首付按揭
- ];
- $sum = $this->app_liche_orders_model->sum('total_price', $where); //已收金额
- $total_price = $sum['total_price'];
- $need_price = $this->orders_v2_entity->recevable_price($id); //应收金额
- if ($total_price >= $need_price) {
- $this->orders_status_entity->set_status($id, 0, 2);
- } else {
- $fee_status = $this->receiver_order_status_model->get(['o_id' => $id, 'pid_status' => 0, 'status' => 2]); //是否已付款
- $fee_status && $this->receiver_order_status_model->delete(['o_id' => $id, 'pid_status' => 0, 'status' => 2]);
- //$bill_status = $this->receiver_order_status_model->get(['o_id'=>$id,'pid_status'=>3,'status'=>1]); //是否已开票
- //$bill_status && $this->receiver_order_status_model->delete(['o_id'=>$id,'pid_status'=>3,'status'=>1]);
- }
-
- //是否已配车
- /*$car_status = $this->receiver_order_status_model->get(['o_id'=>$id,'pid_status'=>2,'status'=>1]);
- if (!$car_status){
- $row = $this->receiver_orders_v2_model->get(['id'=>$id]);
- $row && $row['item_id'] && $this->orders_status_entity->set_status($id,2,1);
- }*/
- }
-
- // 0首付下状态处理:非首付按揭有通知函 / 首付按揭时两个按揭的通知函都有,就可以设置 pid_status = 0 status = 2
- private function order_status_check_after_edit_loan($order_row)
- {
- if (!$order_row) {
- return false;
- }
-
- $money_json = json_decode($order_row['money_json'], true);
- $payway = $order_row['payway'];
- $deposit = $money_json['price_book'];
- $if_zero_firstpay = $payway == 0 && !$deposit ? 1 : 0;
- if (!$if_zero_firstpay) {
- return false;
- }
-
- $oid = $order_row['id'];
-
- $row = $this->order_loans_model->get(['o_id' => $oid]);
- $if_loans_notify_file = $row && $row['notify_file'] ? 1 : 0;
-
- if ($money_json['price_loan0']) {
- $row0 = $this->order_loans0_model->get(['o_id' => $oid]);
- $if_loans0_notify_file = $row0 && $row0['notify_file'] ? 1 : 0;
- } else {
- $if_loans0_notify_file = 1;
- }
-
- if ($if_loans_notify_file && $if_loans0_notify_file) {
- $this->orders_status_entity->set_status($oid, 0, 2);
- return true;
- }
- return false;
- }
-
- public function edit_price()
- {
- $id = $this->input->get_post('id');
- $row = $this->receiver_orders_v2_model->get(['id' => $id]);
- if (!$row) {
- return $this->show_json(SYS_CODE_FAIL, '订单不存在!');
- }
- $money_json = json_decode($row['money_json'], true);
- if ($this->input->method() == 'post') {
- $price_discount = $this->input->post('price_discount');
- $money_json['price_discount'] = floatval($price_discount);
- $updata = [
- 'money_json' => json_encode($money_json, JSON_UNESCAPED_UNICODE)
- ];
- $res = $this->receiver_orders_v2_model->update($updata, ['id' => $id]);
- if ($res) {
- //更新尾款订单
- if (!$this->app_liche_orders_model->count(['type' => 3, 'status' => 1, 'o_id' => $id])) { //不存在支付尾款更新尾款
- $this->app_liche_orders_model->update(['status' => -1], ['type' => 3, 'o_id' => $id, 'status' => 0]);
- //生成购车订单
- $userinfo = $this->app_liche_users_model->get(['mobile' => $row['mobile']]);
- $this->orders_v2_entity->add_order($id, $userinfo['id']);
- }
- $this->order_status_check_after_adjust_fee($id);
- //重新生成合同
- $this->order_contracts_model->delete(['o_id' => $id]);
- $url = http_host_com('api') . "/wxapp/licheb/protocol/create_pdf?id={$id}";
- file_get_contents($url);
-// $this->orders_v2_entity->create_pdf($id);
- return $this->show_json(SYS_CODE_SUCCESS, '保存成功!');
- } else {
- return $this->show_json(SYS_CODE_FAIL, '保存失败!');
- }
- }
- $this->data['price_discount'] = $money_json['price_discount'];
- $this->data['id'] = $id;
- return $this->show_view('receiver/orderv2/edit_price');
- }
-
- public function edit_price_car()
- {
- $id = $this->input->get_post('id');
- $row = $this->receiver_orders_v2_model->get(['id' => $id]);
- if (!$row) {
- return $this->show_json(SYS_CODE_FAIL, '订单不存在!');
- }
- $money_json = json_decode($row['money_json'], true);
- if ($this->input->method() == 'post') {
- $price_car = $this->input->post('price_car');
- if ($money_json['price_car'] > floatval($price_car)) {
- return $this->show_json(SYS_CODE_FAIL, '售价不能下调!');
- }
- $money_json['price_car'] = floatval($price_car);
- $updata = [
- 'money_json' => json_encode($money_json, JSON_UNESCAPED_UNICODE)
- ];
- $res = $this->receiver_orders_v2_model->update($updata, ['id' => $id]);
- if ($res) {
- //更新尾款订单
- if (!$this->app_liche_orders_model->count(['type' => 3, 'status' => 1, 'o_id' => $id])) { //不存在支付尾款更新尾款
- $this->app_liche_orders_model->update(['status' => -1], ['type' => 3, 'o_id' => $id, 'status' => 0]);
- //生成购车订单
- $userinfo = $this->app_liche_users_model->get(['mobile' => $row['mobile']]);
- $this->orders_v2_entity->add_order($id, $userinfo['id']);
- }
- $this->order_status_check_after_adjust_fee($id);
- //重新生成合同
- $this->order_contracts_model->delete(['o_id' => $id]);
- $url = http_host_com('api') . "/wxapp/licheb/protocol/create_pdf?id={$id}";
- file_get_contents($url);
-// $this->orders_v2_entity->create_pdf($id);
- return $this->show_json(SYS_CODE_SUCCESS, '保存成功!');
- } else {
- return $this->show_json(SYS_CODE_FAIL, '保存失败!');
- }
- }
- $this->data['price_car'] = $money_json['price_car'];
- $this->data['id'] = $id;
- return $this->show_view('receiver/orderv2/edit_price_car');
- }
-
- public function edit_srv()
- {
- $this->load->model('receiver/receiver_services_model', 'services_model');
- $id = $this->input->get_post('id');
- $row = $this->receiver_orders_v2_model->get(['id' => $id]);
- if (!$row) {
- return $this->show_json(SYS_CODE_FAIL, '订单不存在!');
- }
- $money_json = json_decode($row['money_json'], true);
- $services = json_decode($row['srv_ids'], true);
- if ($this->input->method() == 'post') {
- $new_services = [];
- $info = $this->input->post();
- if (is_array($info['money'])) {
- foreach ($info['money'] as $key => $val) {
- if ($val['checkbox']) {
- unset($val['checkbox']);
- $new_services[] = $val;
- $money_json[$val['key']] = floatval($val['price']);
- } else {
- $money_json[$val['key']] = 0;
- }
- # form改用vue后
- if (in_array('checked', array_keys($val))) {
- $val['price'] = $val['money'];
- $checked = $val['checked'] == 'true' ? true : false;#var_dump($checked);
- unset($val['checked']);
- unset($val['title']);
- unset($val['money']);
- $checked && $new_services[] = $val;
- $money_json[$val['key']] = $checked ? floatval($val['price']) : 0;
- }
- }
- }#var_dump($new_services);exit();
-
- # form改用vue后 增加精品选装
- $price_fine_select = 0;
- $fines = [];
- if (is_array($info['fines'])) {
- $fines = $info['fines'] ? $info['fines'] : [];
- foreach ($fines as $key => $val) {
- if ($val['id'] == -1 && intval($val['price']) == 0) {
- unset($fines[$key]);
- continue;
- }
- if ($val['txt'] == '' && intval($val['price']) == 0) {
- unset($fines[$key]);
- continue;
- }
- $price_fine_select += intval($val['price']);
- }
- }
- $money_json['price_fine_select'] = $price_fine_select;
-
- $srv_ids = is_array($new_services) ? array_column($new_services, 'id') : [];
- $updata = [
- 'if_insure' => in_array(1, $srv_ids) ? 1 : 0,
- 'if_num' => in_array(2, $srv_ids) ? 1 : 0,
- 'srv_ids' => json_encode($new_services, JSON_UNESCAPED_UNICODE),
- 'money_json' => json_encode($money_json, JSON_UNESCAPED_UNICODE),
- 'fines' => json_encode($fines, JSON_UNESCAPED_UNICODE),
- ];
- $res = $this->receiver_orders_v2_model->update($updata, ['id' => $id]);
- if ($res) {
- if (!$this->app_liche_orders_model->count(['type' => 2, 'status' => 1, 'o_id' => $id])) { //不存在支付服务费
- $this->app_liche_orders_model->update(['status' => -1], ['type' => 2, 'o_id' => $id, 'status' => 0]);
- //生成购车订单
- $userinfo = $this->app_liche_users_model->get(['mobile' => $row['mobile']]);
- $this->orders_v2_entity->add_order($id, $userinfo['id']);
- }
- $this->order_status_check_after_adjust_fee($id);
- //重新生成合同
- $this->order_contracts_model->delete(['o_id' => $id]);
- $url = http_host_com('api') . "/wxapp/licheb/protocol/create_pdf?id={$id}";
- file_get_contents($url);
-// $this->orders_v2_entity->create_pdf($id);
- return $this->show_json(SYS_CODE_SUCCESS, '保存成功!');
- } else {
- return $this->show_json(SYS_CODE_FAIL, '保存失败!');
- }
- }
- //获取车辆服务费
- $lists = [
- ['id' => 1, 'key' => 'price_insure', 'title' => '代办保险'],
- ['id' => 2, 'key' => 'fee_carno', 'title' => '代办上牌']
- ];
- !$row['payway'] && $lists[] = ['id' => 4, 'key' => 'price_finance', 'title' => '代办按揭'];
- $srv_ids = is_array($services) ? array_column($services, 'id') : [];
- foreach ($lists as $key => $val) {
- $lists[$key]['money'] = $money_json[$val['key']] ? $money_json[$val['key']] : 0;
- //$lists[$key]['checked'] = in_array($val['id'],$srv_ids) ? 'checked' : '';
- $lists[$key]['checked'] = in_array($val['id'], $srv_ids) ? true : false; // form 改 vue
- }
- $this->data['srv_info'] = $lists;
- $this->data['id'] = $id;
-
- // 0522增加精品选装(biz_type==1后台手工添加的均为自定义,biz_type!=1只能修改price)
- /*$this->load->model('receiver/receiver_fine_model');
- $where = [
- 'status' => 1
- ];
- $where['biz_id'] = $row['biz_id'];
- $fines_list = $this->receiver_fine_model->select($where,'id desc',0,0,'id,title,price');
- $this->data['fines_list'] = $fines_list;*/
- $biz = $this->biz_model->get(['id' => $row['biz_id']], 'id,city_id,type');
- $this->data['biz_type'] = $biz['type'];
- $this->data['fines'] = $row['fines'] ? json_decode($row['fines'], true) : [];
- if (!$this->data['fines']) {
- if ($biz['type'] != 1) {
- $this->data['fines'] = [array("id" => "-1", "txt" => "服务费", "price" => "0")];
- }
- }
- $this->data['price_fine_select'] = sprintf("%.2f", $money_json['price_fine_select']);
-
- return $this->show_view('receiver/orderv2/edit_srv');
- }
-
- public function edit_bill_img()
- {
- $id = $this->input->post('id');
- $file = $this->input->post('value');
- if (!$file || !$id) {
- $this->show_json(SYS_CODE_FAIL, '参数错误');
- }
- $re_data = $this->receiver_order_datas_model->get(['o_id' => $id]);
- $bill_ck_img = [];
- if (!$re_data) {
- $re_data_id = $this->receiver_order_datas_model->add(['c_time' => time(), 'o_id' => $id]);
- } else {
- $re_data_id = $re_data['id'];
- #$bill_ck_img = json_decode($re_data['bill_ck_img'],true); # 2022-12-07 都改成覆盖
- }
-
- if (strpos($file, '.pdf') !== false) {
- $this->load->library('pdf');
- $pdf_url = build_qiniu_image_url($file);
- $pdf_imgs = $this->pdf->pdf2img($pdf_url);
- if ($pdf_imgs) {
- $bill_ck_img = $this->up_qiniu($pdf_imgs);
- } else {
- return $this->show_json(SYS_CODE_FAIL, 'pdf识别失败');
- }
- } else {
- $bill_ck_img[] = $file;
- }
- $update = [
- 'bill_ck_img' => json_encode($bill_ck_img, JSON_UNESCAPED_UNICODE)
- ];
- $res = $this->receiver_order_datas_model->update($update, ['id' => $re_data_id]);
- if ($res) {
- return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
- } else {
- return $this->show_json(SYS_CODE_FAIL, '保存失败');
- }
- }
//图片上传七牛
private function up_qiniu($imgs)
diff --git a/admin/libraries/OrdersList.php b/admin/libraries/OrdersList.php
index e76f7554..4cd23db5 100644
--- a/admin/libraries/OrdersList.php
+++ b/admin/libraries/OrdersList.php
@@ -33,7 +33,7 @@ class OrdersList
!$params['of2_id'] && $params['of2_id'] = '';
!strlen($params['payway']) && $params['payway'] = '';
!strlen($params['over_id']) && $params['over_id'] = '';
- $fieldAry = $this->get_fields($status_pid, 0, $params['status']);
+ $fieldAry = $this->get_fields($status_pid, 0);
$show_info['offlineSourcesAry'] = $this->ci->mdCustomers->offlineSources_search();
$show_info['paywayAry'] = $this->paywayAry;//付款方式
//渠道经理
@@ -219,11 +219,13 @@ class OrdersList
$fields['id_card'] = $val['card_id'];
$fields['mobile'] = $size > 1000 ? '="' . $mobile . '"' : $mobile;
$fields['car_name'] = "{$brand_name}-{$series_name}-{$car_name}";
- $fields['price_car'] = 0;
$fields['payway_name'] = $this->paywayAry[$val['payway']];
$fields['payway'] = $fields['payway_name'];
$fields['brand_name'] = $brand_name;
$fields['series_name'] = $series_name;
+ $fields['c_name'] = $car_name;
+ $fields['color'] = $val['color'];
+ $fields['in_color'] = $val['in_color'];
$status_name = $order_status_cn[$val['status']];
$fields['status_name'] = $status_name;
$fields['biz_name'] = $bizs[$val['biz_id']] ? $bizs[$val['biz_id']]['biz_name'] . '
' . $admins[$val['admin_id']] : '';
@@ -251,44 +253,11 @@ class OrdersList
if ($size > 1000) {
$user_info = '';
- if ($bizs[$val['biz_id']]['type'] == 3) { //代理店显示渠道经理的姓名
- $channel_users = $this->ci->app_licheb_channel_biz_model->select(['biz_id' => $val['biz_id']], '', '', '', 'uid');
- $user_ids = array_column($channel_users, 'uid');
- $user_ids_str = implode(',', $user_ids);
- if ($user_ids_str && $user_ids) {
- $where = [
- 'group_id' => 4,
- 'status' => 1,
- "id in ($user_ids_str)" => null
- ];
- $users = $this->ci->mdLichebUsers->select($where, 'id desc', 1, 10, 'uname,biz_id'); //渠道经理
- $users && $user_info = implode(' ', array_column($users, 'uname'));
- }
- $fields['admin_name'] = $user_info;
- }
if (!$user_info) {
$sale = $this->ci->mdLichebUsers->get(['id' => $val['sale_id']], 'uname');
$fields['admin_name'] = $sale['uname'];
}
- $fields['address'] = $info_json['c_address'];
}
- if (!$val['payway']) { //按揭
- $fields['pro_loan'] = '';
- $fields['price_loan'] = $money_json['price_loan'];
- $fields['is_sure'] = '';
- $fields['is_tiexi'] = '是';
- // 首付按揭
- $fields['pro_loan0'] = '222';
- $fields['price_loan0'] = 10;
- $fields['is_sure0'] = '是';
- $fields['is_tiexi'] = '是';
- }
- $srv_info = [];
- $fields['srv_info_total'] = $srv_info['total'] > 0 ? $srv_info['total'] : '';
- $fields['srv_info_fee_carno'] = $srv_info['fee_carno'] ? $srv_info['fee_carno'] : '';
- $fields['srv_info_price_finance'] = $srv_info['price_finance'] ? $srv_info['price_finance'] : '';
- $fields['srv_info_price_fine_select'] = $srv_info['price_fine_select'] ? $srv_info['price_fine_select'] : '';
- $fields['srv_info_price_fine_select_detail'] = $srv_info['price_fine_select_detail'] ? $srv_info['price_fine_select_detail'] : '';
$lists[] = $fields;
}
}
@@ -307,7 +276,7 @@ class OrdersList
* @param int $export
* @return array
*/
- public function get_fields($status_pid, $export = 0, $status)
+ public function get_fields($status_pid, $export = 0)
{
$fields1 = $fields2 = [];
if ($export) {
@@ -316,10 +285,10 @@ class OrdersList
$fields1['id_card'] = ['title' => '证件号码'];
$fields1['brand_name'] = ['title' => '品牌'];
$fields1['series_name'] = ['title' => '车系'];
- $fields1['v_name'] = ['title' => '车型'];
- $fields1['cor_name'] = ['title' => '车身颜色'];
+ $fields1['c_name'] = ['title' => '车型'];
+ $fields1['color'] = ['title' => '车身颜色'];
+ $fields1['in_color'] = ['title' => '内饰颜色'];
$fields1['city_name'] = ['title' => '城市'];
- $fields1['biz_type'] = ['title' => '门店类型'];
$fields1['biz_name'] = ['title' => '门店'];
$fields1['admin_name'] = ['title' => '销售人员'];
$fields1['of_title_1'] = ['title' => '来源1'];
@@ -335,25 +304,9 @@ class OrdersList
$fields = array_merge($fields1, $fields2);
if ($export) {
unset($fields['price'], $fields['c_time'], $fields['car_name'], $fields['of_title']);
- $fields['payway_name'] = ['title' => '付款方式'];
- $fields['pro_loan0'] = ['title' => '首付按揭-金融机构'];
- $fields['price_loan0'] = ['title' => '首付按揭-金额'];
- $fields['is_sure0'] = ['title' => '首付按揭-确认到款(是/否)'];
- $fields['pro_loan'] = ['title' => '金融机构'];
- $fields['is_tiexi'] = ['title' => '贴息'];
- $fields['price_loan'] = ['title' => '按揭金额'];
- $fields['is_sure'] = ['title' => '确认到款(是/否)'];
- $fields['price_car'] = ['title' => '最终售价'];
- $fields['srv_info_total'] = ['title' => '手续费'];
- $fields['srv_info_fee_carno'] = ['title' => '手续费-上牌'];
- $fields['srv_info_price_finance'] = ['title' => '手续费-按揭'];
- $fields['srv_info_price_fine_select'] = ['title' => '手续费-精品选装'];
- $fields['srv_info_price_fine_select_detail'] = ['title' => '精品选装内容'];
!$fields['c_time'] && $fields['c_time'] = ['title' => '订单时间'];
- !$fields['over_time'] && $fields['over_time'] = ['title' => '止交付时间'];
!$fields['order_time'] && $fields['order_time'] = ['title' => '下定时间'];
!$fields['bill_time'] && $fields['bill_time'] = ['title' => '开票时间'];
- $fields['address'] = ['title' => '联系人地址'];
}
return $fields;
}
diff --git a/admin/views/receiver/clues/lists.php b/admin/views/receiver/clues/lists.php
index 511e10bf..af15d8d2 100644
--- a/admin/views/receiver/clues/lists.php
+++ b/admin/views/receiver/clues/lists.php
@@ -159,16 +159,19 @@
-
+