Ver Fonte

first commit

longyi há 1 ano atrás
commit
7e0f4b1e7f
100 ficheiros alterados com 75339 adições e 0 exclusões
  1. 6 0
      core/CoreApp/.htaccess
  2. 135 0
      core/CoreApp/config/autoload.php
  3. 93 0
      core/CoreApp/config/config.php
  4. 85 0
      core/CoreApp/config/constants.php
  5. 26 0
      core/CoreApp/config/database.php
  6. 24 0
      core/CoreApp/config/doctypes.php
  7. 103 0
      core/CoreApp/config/foreign_chars.php
  8. 18 0
      core/CoreApp/config/hooks.php
  9. 11 0
      core/CoreApp/config/index.html
  10. 19 0
      core/CoreApp/config/memcached.php
  11. 84 0
      core/CoreApp/config/migration.php
  12. 183 0
      core/CoreApp/config/mimes.php
  13. 14 0
      core/CoreApp/config/profiler.php
  14. 8 0
      core/CoreApp/config/routes.php
  15. 64 0
      core/CoreApp/config/smileys.php
  16. 214 0
      core/CoreApp/config/user_agents.php
  17. 1017 0
      core/CoreApp/controllers/Aa.php
  18. 475 0
      core/CoreApp/controllers/Aay.php
  19. 1924 0
      core/CoreApp/controllers/Ab.php
  20. 569 0
      core/CoreApp/controllers/Ac.php
  21. 360 0
      core/CoreApp/controllers/Ahc.php
  22. 283 0
      core/CoreApp/controllers/Allocation.php
  23. 347 0
      core/CoreApp/controllers/Amazonbarcode.php
  24. 2127 0
      core/CoreApp/controllers/Api.php
  25. 745 0
      core/CoreApp/controllers/Apismt.php
  26. 680 0
      core/CoreApp/controllers/Apismt_old.php
  27. 973 0
      core/CoreApp/controllers/Apitt.php
  28. 908 0
      core/CoreApp/controllers/Apitt_new.php
  29. 925 0
      core/CoreApp/controllers/Apitt_old.php
  30. 1962 0
      core/CoreApp/controllers/Apixw.php
  31. 378 0
      core/CoreApp/controllers/Apiyy.php
  32. 2629 0
      core/CoreApp/controllers/Apt.php
  33. 818 0
      core/CoreApp/controllers/Apt2.php
  34. 1278 0
      core/CoreApp/controllers/Aptsmt.php
  35. 477 0
      core/CoreApp/controllers/Bh.php
  36. 1635 0
      core/CoreApp/controllers/Boss.php
  37. 157 0
      core/CoreApp/controllers/Brand.php
  38. 171 0
      core/CoreApp/controllers/Caiwusfh.php
  39. 24 0
      core/CoreApp/controllers/Choice.php
  40. 60 0
      core/CoreApp/controllers/Ck.php
  41. 148 0
      core/CoreApp/controllers/Classid.php
  42. 200 0
      core/CoreApp/controllers/Code.php
  43. 260 0
      core/CoreApp/controllers/Color.php
  44. 380 0
      core/CoreApp/controllers/Colour.php
  45. 132 0
      core/CoreApp/controllers/Colourorderts.php
  46. 625 0
      core/CoreApp/controllers/Commodity.php
  47. 182 0
      core/CoreApp/controllers/Country.php
  48. 2138 0
      core/CoreApp/controllers/Customer.php
  49. 1053 0
      core/CoreApp/controllers/Customersmt.php
  50. 2134 0
      core/CoreApp/controllers/Customertt.php
  51. 2134 0
      core/CoreApp/controllers/Customerxw.php
  52. 273 0
      core/CoreApp/controllers/Customs.php
  53. 130 0
      core/CoreApp/controllers/Customsdeclaration.php
  54. 123 0
      core/CoreApp/controllers/Describecode.php
  55. 129 0
      core/CoreApp/controllers/Detailed.php
  56. 744 0
      core/CoreApp/controllers/Distribution.php
  57. 172 0
      core/CoreApp/controllers/Emaildata.php
  58. 135 0
      core/CoreApp/controllers/Employee.php
  59. 105 0
      core/CoreApp/controllers/Evaluate.php
  60. 388 0
      core/CoreApp/controllers/Express.php
  61. 1356 0
      core/CoreApp/controllers/Finance.php
  62. 5914 0
      core/CoreApp/controllers/Fullorder.php
  63. 2830 0
      core/CoreApp/controllers/Fullorder_smt.php
  64. 2295 0
      core/CoreApp/controllers/Fullorderexcel.php
  65. 479 0
      core/CoreApp/controllers/Fullorderout.php
  66. 4221 0
      core/CoreApp/controllers/Fullordersmt.php
  67. 5882 0
      core/CoreApp/controllers/Fullordertt.php
  68. 5864 0
      core/CoreApp/controllers/Fullorderxw.php
  69. 672 0
      core/CoreApp/controllers/Ga.php
  70. 80 0
      core/CoreApp/controllers/Img.php
  71. 20 0
      core/CoreApp/controllers/Is.php
  72. 95 0
      core/CoreApp/controllers/Kdniao.php
  73. 171 0
      core/CoreApp/controllers/Logistics.php
  74. 360 0
      core/CoreApp/controllers/Machining.php
  75. 247 0
      core/CoreApp/controllers/Matching.php
  76. 143 0
      core/CoreApp/controllers/News.php
  77. 709 0
      core/CoreApp/controllers/Notice.php
  78. 364 0
      core/CoreApp/controllers/Orderurl.php
  79. 449 0
      core/CoreApp/controllers/Outbound.php
  80. 130 0
      core/CoreApp/controllers/Packing.php
  81. 129 0
      core/CoreApp/controllers/Pay.php
  82. 138 0
      core/CoreApp/controllers/Paypal.php
  83. 228 0
      core/CoreApp/controllers/Power.php
  84. 379 0
      core/CoreApp/controllers/Printcode.php
  85. 398 0
      core/CoreApp/controllers/Product.php
  86. 274 0
      core/CoreApp/controllers/Productdescribe.php
  87. 168 0
      core/CoreApp/controllers/Productdescription.php
  88. 201 0
      core/CoreApp/controllers/Productprice.php
  89. 174 0
      core/CoreApp/controllers/Purchase.php
  90. 402 0
      core/CoreApp/controllers/Purchasedetailed.php
  91. 501 0
      core/CoreApp/controllers/Purchaseorder.php
  92. 300 0
      core/CoreApp/controllers/Qrcode.php
  93. 515 0
      core/CoreApp/controllers/Registration.php
  94. 105 0
      core/CoreApp/controllers/Reset.php
  95. 592 0
      core/CoreApp/controllers/Returns.php
  96. 214 0
      core/CoreApp/controllers/Review.php
  97. 334 0
      core/CoreApp/controllers/Shop.php
  98. 151 0
      core/CoreApp/controllers/Shopsku.php
  99. 4261 0
      core/CoreApp/controllers/Specialstock.php
  100. 0 0
      core/CoreApp/controllers/Staff.php

+ 6 - 0
core/CoreApp/.htaccess

@@ -0,0 +1,6 @@
+<IfModule authz_core_module>
+    Require all denied
+</IfModule>
+<IfModule !authz_core_module>
+    Deny from all
+</IfModule>

+ 135 - 0
core/CoreApp/config/autoload.php

@@ -0,0 +1,135 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+/*
+| -------------------------------------------------------------------
+| AUTO-LOADER
+| -------------------------------------------------------------------
+| This file specifies which systems should be loaded by default.
+|
+| In order to keep the framework as light-weight as possible only the
+| absolute minimal resources are loaded by default. For example,
+| the database is not connected to automatically since no assumption
+| is made regarding whether you intend to use it.  This file lets
+| you globally define which systems you would like loaded with every
+| request.
+|
+| -------------------------------------------------------------------
+| Instructions
+| -------------------------------------------------------------------
+|
+| These are the things you can load automatically:
+|
+| 1. Packages
+| 2. Libraries
+| 3. Drivers
+| 4. Helper files
+| 5. Custom config files
+| 6. Language files
+| 7. Models
+|
+*/
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Packages
+| -------------------------------------------------------------------
+| Prototype:
+|
+|  $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
+|
+*/
+$autoload['packages'] = array();
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Libraries
+| -------------------------------------------------------------------
+| These are the classes located in system/libraries/ or your
+| application/libraries/ directory, with the addition of the
+| 'database' library, which is somewhat of a special case.
+|
+| Prototype:
+|
+|	$autoload['libraries'] = array('database', 'email', 'session');
+|
+| You can also supply an alternative library name to be assigned
+| in the controller:
+|
+|	$autoload['libraries'] = array('user_agent' => 'ua');
+*/
+$autoload['libraries'] = array();
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Drivers
+| -------------------------------------------------------------------
+| These classes are located in system/libraries/ or in your
+| application/libraries/ directory, but are also placed inside their
+| own subdirectory and they extend the CI_Driver_Library class. They
+| offer multiple interchangeable driver options.
+|
+| Prototype:
+|
+|	$autoload['drivers'] = array('cache');
+|
+| You can also supply an alternative property name to be assigned in
+| the controller:
+|
+|	$autoload['drivers'] = array('cache' => 'cch');
+|
+*/
+$autoload['drivers'] = array();
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Helper Files
+| -------------------------------------------------------------------
+| Prototype:
+|
+|	$autoload['helper'] = array('url', 'file');
+*/
+$autoload['helper'] = array();
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Config files
+| -------------------------------------------------------------------
+| Prototype:
+|
+|	$autoload['config'] = array('config1', 'config2');
+|
+| NOTE: This item is intended for use ONLY if you have created custom
+| config files.  Otherwise, leave it blank.
+|
+*/
+$autoload['config'] = array();
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Language files
+| -------------------------------------------------------------------
+| Prototype:
+|
+|	$autoload['language'] = array('lang1', 'lang2');
+|
+| NOTE: Do not include the "_lang" part of your file.  For example
+| "codeigniter_lang.php" would be referenced as array('codeigniter');
+|
+*/
+$autoload['language'] = array();
+
+/*
+| -------------------------------------------------------------------
+|  Auto-load Models
+| -------------------------------------------------------------------
+| Prototype:
+|
+|	$autoload['model'] = array('first_model', 'second_model');
+|
+| You can also supply an alternative model name to be assigned
+| in the controller:
+|
+|	$autoload['model'] = array('first_model' => 'first');
+*/
+$autoload['model'] = array();

+ 93 - 0
core/CoreApp/config/config.php

@@ -0,0 +1,93 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/'; //CodeIgniter根URL
+$config['index_page'] = ''; //默认的索引文件 index.php
+$config['uri_protocol']	= 'REQUEST_URI'; //RUL链接 PATH_INFO
+$config['url_suffix'] = '.html'; //设置所有URL后缀
+$config['language']	= 'english';//使用的语言
+$config['charset'] = 'UTF-8';
+$config['enable_hooks'] = FALSE;//是否启用钩子功能
+$config['subclass_prefix'] = 'Lin_';//扩展类的前缀
+$config['composer_autoload'] = FALSE; //自动加载Composer
+$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-\='; //允许的链接字符
+$config['allow_get_array'] = TRUE; //是否启用$_GET array
+/*
+|--------------------------------------------------------------------------
+|设置查询的字符串
+|--------------------------------------------------------------------------
+|
+*/
+$config['enable_query_strings'] = FALSE;
+$config['controller_trigger'] = 'c';
+$config['function_trigger'] = 'm';
+$config['directory_trigger'] = 'd';
+
+/*
+|--------------------------------------------------------------------------
+| 错误记录
+|--------------------------------------------------------------------------
+|	0 = 禁用
+|	1 = 错误信息(包括PHP错误)
+|	2 = 调试消息
+|	3 = 信息消息
+|	4 = 所有的消息
+*/
+$config['log_threshold'] = 1;
+$config['log_path'] = FCPATH.'data/log/'; //记录日志的路径
+$config['log_file_extension'] = '';//日志的扩展名,空为.php
+$config['log_file_permissions'] = 0644;//日志的权限
+$config['log_date_format'] = 'Y-m-d H:i:s';//日志日期名称格式
+$config['error_views_path'] = 'data/errors/'; //提示错误的路径
+$config['cache_path'] = ''; //缓存目录路径
+
+$config['cache_query_string'] = FALSE;//是否启用缓存
+$config['encryption_key'] = 'Kay89757SC';//设置加密密匙
+
+/*
+|--------------------------------------------------------------------------
+| Session
+|--------------------------------------------------------------------------
+*/
+$config['sess_driver'] = 'files'; //使用于 files, database, redis, memcached
+$config['sess_cookie_name'] = 'star_session'; //名称
+$config['sess_expiration'] = 8640000; //时间
+$config['sess_save_path'] = FCPATH.'/tmp/'; //保存路径 只可绝对路径
+$config['sess_match_ip'] = FALSE; //是否匹配IP判断
+$config['sess_time_to_update'] = 8660000; //多久后生成新的ID
+$config['sess_regenerate_destroy'] = TRUE; //是否删除旧ID
+
+/*
+|--------------------------------------------------------------------------
+| Cookie
+|--------------------------------------------------------------------------
+*/
+$config['cookie_prefix']	= '_STAR'; //设置Cookie前缀
+$config['cookie_domain']	= ''; //设置范围
+$config['cookie_path']		= '/';
+$config['cookie_secure']	= FALSE; //只在HTTPS里存在
+$config['cookie_httponly'] 	= FALSE;//只可以通过HTTP里存在
+
+$config['standardize_newlines'] = FALSE;//是否规范换行,不推荐使用
+
+$config['global_xss_filtering'] = FALSE; //XSS过滤,不推荐使用
+
+/*
+|--------------------------------------------------------------------------
+| 跨站请求伪造
+|--------------------------------------------------------------------------
+*/
+$config['csrf_protection'] = FALSE; //是否开启
+$config['csrf_token_name'] = 'csrf_test_name'; //令牌名称
+$config['csrf_cookie_name'] = 'csrf_cookie_name'; //cookie名称
+$config['csrf_expire'] = 7200; //令牌过期时间
+$config['csrf_regenerate'] = TRUE; //每次重新生成令牌
+$config['csrf_exclude_uris'] = array();//忽略CSRF检查的URI数组
+
+$config['compress_output'] = FALSE;//启用输出Gzip压缩
+
+$config['time_reference'] = 'local';//时间时区
+
+$config['rewrite_short_tags'] = FALSE; //重写PHP短标签
+
+$config['proxy_ips'] = ''; //反向代理IP

+ 85 - 0
core/CoreApp/config/constants.php

@@ -0,0 +1,85 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+/*
+|--------------------------------------------------------------------------
+| Display Debug backtrace
+|--------------------------------------------------------------------------
+|
+| If set to TRUE, a backtrace will be displayed along with php errors. If
+| error_reporting is disabled, the backtrace will not display, regardless
+| of this setting
+|
+*/
+defined('SHOW_DEBUG_BACKTRACE') OR define('SHOW_DEBUG_BACKTRACE', TRUE);
+
+/*
+|--------------------------------------------------------------------------
+| File and Directory Modes
+|--------------------------------------------------------------------------
+|
+| These prefs are used when checking and setting modes when working
+| with the file system.  The defaults are fine on servers with proper
+| security, but you may wish (or even need) to change the values in
+| certain environments (Apache running a separate process for each
+| user, PHP under CGI with Apache suEXEC, etc.).  Octal values should
+| always be used to set the mode correctly.
+|
+*/
+defined('FILE_READ_MODE')  OR define('FILE_READ_MODE', 0644);
+defined('FILE_WRITE_MODE') OR define('FILE_WRITE_MODE', 0666);
+defined('DIR_READ_MODE')   OR define('DIR_READ_MODE', 0755);
+defined('DIR_WRITE_MODE')  OR define('DIR_WRITE_MODE', 0755);
+
+/*
+|--------------------------------------------------------------------------
+| File Stream Modes
+|--------------------------------------------------------------------------
+|
+| These modes are used when working with fopen()/popen()
+|
+*/
+defined('FOPEN_READ')                           OR define('FOPEN_READ', 'rb');
+defined('FOPEN_READ_WRITE')                     OR define('FOPEN_READ_WRITE', 'r+b');
+defined('FOPEN_WRITE_CREATE_DESTRUCTIVE')       OR define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
+defined('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE')  OR define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
+defined('FOPEN_WRITE_CREATE')                   OR define('FOPEN_WRITE_CREATE', 'ab');
+defined('FOPEN_READ_WRITE_CREATE')              OR define('FOPEN_READ_WRITE_CREATE', 'a+b');
+defined('FOPEN_WRITE_CREATE_STRICT')            OR define('FOPEN_WRITE_CREATE_STRICT', 'xb');
+defined('FOPEN_READ_WRITE_CREATE_STRICT')       OR define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
+
+/*
+|--------------------------------------------------------------------------
+| Exit Status Codes
+|--------------------------------------------------------------------------
+|
+| Used to indicate the conditions under which the script is exit()ing.
+| While there is no universal standard for error codes, there are some
+| broad conventions.  Three such conventions are mentioned below, for
+| those who wish to make use of them.  The CodeIgniter defaults were
+| chosen for the least overlap with these conventions, while still
+| leaving room for others to be defined in future versions and user
+| applications.
+|
+| The three main conventions used for determining exit status codes
+| are as follows:
+|
+|    Standard C/C++ Library (stdlibc):
+|       http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
+|       (This link also contains other GNU-specific conventions)
+|    BSD sysexits.h:
+|       http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
+|    Bash scripting:
+|       http://tldp.org/LDP/abs/html/exitcodes.html
+|
+*/
+defined('EXIT_SUCCESS')        OR define('EXIT_SUCCESS', 0); // no errors
+defined('EXIT_ERROR')          OR define('EXIT_ERROR', 1); // generic error
+defined('EXIT_CONFIG')         OR define('EXIT_CONFIG', 3); // configuration error
+defined('EXIT_UNKNOWN_FILE')   OR define('EXIT_UNKNOWN_FILE', 4); // file not found
+defined('EXIT_UNKNOWN_CLASS')  OR define('EXIT_UNKNOWN_CLASS', 5); // unknown class
+defined('EXIT_UNKNOWN_METHOD') OR define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
+defined('EXIT_USER_INPUT')     OR define('EXIT_USER_INPUT', 7); // invalid user input
+defined('EXIT_DATABASE')       OR define('EXIT_DATABASE', 8); // database error
+defined('EXIT__AUTO_MIN')      OR define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
+defined('EXIT__AUTO_MAX')      OR define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code

+ 26 - 0
core/CoreApp/config/database.php

@@ -0,0 +1,26 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+$active_group = 'default';
+$query_builder = TRUE;
+
+$db['default'] = array(
+	'hostname' => 'localhost', //数据库的主机名
+	'username' => 'kay89757sc', //需要连接到数据库的用户名	
+	'password' => 'Qq147258!', //登录数据库的密码
+	'database' => 'xing', //需要连接的数据库名
+	'dbdriver' => 'mysqli',//数据库类型。
+	'dbprefix' => 'x_', //表前缀
+	'pconnect' => TRUE, //是否使用持续连接
+	'db_debug' => TRUE, //是否显示数据库错误信息
+	'cache_on' => FALSE, // 是否开启数据库查询缓存
+	'cachedir' => '', //数据库查询缓存目录所在的服务器绝对路径
+	'char_set' => 'utf8', //与数据库通信时所使用的字符集
+	'dbcollat' => 'utf8_general_ci', //与数据库通信时所使用的字符规则
+	'swap_pre' => '', //替换默认的 dbprefix 表前缀
+	'encrypt' => FALSE, //是否使用加密连接。
+	'compress' => TRUE, //是否使用客户端压缩协议(只用于MySQL)
+	'stricton' => FALSE, //是否强制使用 "Strict Mode" 连接
+	'failover' => array(), 
+	'save_queries' => TRUE 
+);

+ 24 - 0
core/CoreApp/config/doctypes.php

@@ -0,0 +1,24 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+$_doctypes = array(
+	'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
+	'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
+	'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
+	'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
+	'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
+	'html5' => '<!DOCTYPE html>',
+	'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
+	'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
+	'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
+	'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
+	'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
+	'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
+	'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
+	'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
+	'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
+	'xhtml-math-svg-xh' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
+	'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
+	'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
+	'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">'
+);

+ 103 - 0
core/CoreApp/config/foreign_chars.php

@@ -0,0 +1,103 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+/*
+| -------------------------------------------------------------------
+| Foreign Characters
+| -------------------------------------------------------------------
+| This file contains an array of foreign characters for transliteration
+| conversion used by the Text helper
+|
+*/
+$foreign_characters = array(
+	'/ä|æ|ǽ/' => 'ae',
+	'/ö|œ/' => 'oe',
+	'/ü/' => 'ue',
+	'/Ä/' => 'Ae',
+	'/Ü/' => 'Ue',
+	'/Ö/' => 'Oe',
+	'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Α|Ά|Ả|Ạ|Ầ|Ẫ|Ẩ|Ậ|Ằ|Ắ|Ẵ|Ẳ|Ặ|А/' => 'A',
+	'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|α|ά|ả|ạ|ầ|ấ|ẫ|ẩ|ậ|ằ|ắ|ẵ|ẳ|ặ|а/' => 'a',
+	'/Б/' => 'B',
+	'/б/' => 'b',
+	'/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
+	'/ç|ć|ĉ|ċ|č/' => 'c',
+	'/Д/' => 'D',
+	'/д/' => 'd',
+	'/Ð|Ď|Đ|Δ/' => 'Dj',
+	'/ð|ď|đ|δ/' => 'dj',
+	'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ε|Έ|Ẽ|Ẻ|Ẹ|Ề|Ế|Ễ|Ể|Ệ|Е|Э/' => 'E',
+	'/è|é|ê|ë|ē|ĕ|ė|ę|ě|έ|ε|ẽ|ẻ|ẹ|ề|ế|ễ|ể|ệ|е|э/' => 'e',
+	'/Ф/' => 'F',
+	'/ф/' => 'f',
+	'/Ĝ|Ğ|Ġ|Ģ|Γ|Г|Ґ/' => 'G',
+	'/ĝ|ğ|ġ|ģ|γ|г|ґ/' => 'g',
+	'/Ĥ|Ħ/' => 'H',
+	'/ĥ|ħ/' => 'h',
+	'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Η|Ή|Ί|Ι|Ϊ|Ỉ|Ị|И|Ы/' => 'I',
+	'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|η|ή|ί|ι|ϊ|ỉ|ị|и|ы|ї/' => 'i',
+	'/Ĵ/' => 'J',
+	'/ĵ/' => 'j',
+	'/Ķ|Κ|К/' => 'K',
+	'/ķ|κ|к/' => 'k',
+	'/Ĺ|Ļ|Ľ|Ŀ|Ł|Λ|Л/' => 'L',
+	'/ĺ|ļ|ľ|ŀ|ł|λ|л/' => 'l',
+	'/М/' => 'M',
+	'/м/' => 'm',
+	'/Ñ|Ń|Ņ|Ň|Ν|Н/' => 'N',
+	'/ñ|ń|ņ|ň|ʼn|ν|н/' => 'n',
+	'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ|Ỏ|Ọ|Ồ|Ố|Ỗ|Ổ|Ộ|Ờ|Ớ|Ỡ|Ở|Ợ|О/' => 'O',
+	'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ|ỏ|ọ|ồ|ố|ỗ|ổ|ộ|ờ|ớ|ỡ|ở|ợ|о/' => 'o',
+	'/П/' => 'P',
+	'/п/' => 'p',
+	'/Ŕ|Ŗ|Ř|Ρ|Р/' => 'R',
+	'/ŕ|ŗ|ř|ρ|р/' => 'r',
+	'/Ś|Ŝ|Ş|Ș|Š|Σ|С/' => 'S',
+	'/ś|ŝ|ş|ș|š|ſ|σ|ς|с/' => 's',
+	'/Ț|Ţ|Ť|Ŧ|τ|Т/' => 'T',
+	'/ț|ţ|ť|ŧ|т/' => 't',
+	'/Þ|þ/' => 'th',
+	'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U',
+	'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u',
+	'/Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y',
+	'/ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y',
+	'/В/' => 'V',
+	'/в/' => 'v',
+	'/Ŵ/' => 'W',
+	'/ŵ/' => 'w',
+	'/Ź|Ż|Ž|Ζ|З/' => 'Z',
+	'/ź|ż|ž|ζ|з/' => 'z',
+	'/Æ|Ǽ/' => 'AE',
+	'/ß/' => 'ss',
+	'/IJ/' => 'IJ',
+	'/ij/' => 'ij',
+	'/Œ/' => 'OE',
+	'/ƒ/' => 'f',
+	'/ξ/' => 'ks',
+	'/π/' => 'p',
+	'/β/' => 'v',
+	'/μ/' => 'm',
+	'/ψ/' => 'ps',
+	'/Ё/' => 'Yo',
+	'/ё/' => 'yo',
+	'/Є/' => 'Ye',
+	'/є/' => 'ye',
+	'/Ї/' => 'Yi',
+	'/Ж/' => 'Zh',
+	'/ж/' => 'zh',
+	'/Х/' => 'Kh',
+	'/х/' => 'kh',
+	'/Ц/' => 'Ts',
+	'/ц/' => 'ts',
+	'/Ч/' => 'Ch',
+	'/ч/' => 'ch',
+	'/Ш/' => 'Sh',
+	'/ш/' => 'sh',
+	'/Щ/' => 'Shch',
+	'/щ/' => 'shch',
+	'/Ъ|ъ|Ь|ь/' => '',
+	'/Ю/' => 'Yu',
+	'/ю/' => 'yu',
+	'/Я/' => 'Ya',
+	'/я/' => 'ya'
+);

+ 18 - 0
core/CoreApp/config/hooks.php

@@ -0,0 +1,18 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+/*
+$hook['post_controller_constructor'] = array(
+                                'class'    => 'ApiClass',
+                                'function' => 'set_api',
+                                'filename' => 'Api.php',
+                                'filepath' => 'hooks'
+);
+
+$hook['display_override'] = array(
+    'class'    => 'CrClass',
+    'function' => 'set_foot_cr',
+    'filename' => 'Crclass.php',
+    'filepath' => 'hooks'
+);
+*/

+ 11 - 0
core/CoreApp/config/index.html

@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html>

+ 19 - 0
core/CoreApp/config/memcached.php

@@ -0,0 +1,19 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+/*
+| -------------------------------------------------------------------------
+| Memcached settings
+| -------------------------------------------------------------------------
+| Your Memcached servers can be specified below.
+|
+|	See: https://codeigniter.com/user_guide/libraries/caching.html#memcached
+|
+*/
+$config = array(
+	'default' => array(
+		'hostname' => '127.0.0.1',
+		'port'     => '11211',
+		'weight'   => '1',
+	),
+);

+ 84 - 0
core/CoreApp/config/migration.php

@@ -0,0 +1,84 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+/*
+|--------------------------------------------------------------------------
+| Enable/Disable Migrations
+|--------------------------------------------------------------------------
+|
+| Migrations are disabled by default for security reasons.
+| You should enable migrations whenever you intend to do a schema migration
+| and disable it back when you're done.
+|
+*/
+$config['migration_enabled'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Migration Type
+|--------------------------------------------------------------------------
+|
+| Migration file names may be based on a sequential identifier or on
+| a timestamp. Options are:
+|
+|   'sequential' = Sequential migration naming (001_add_blog.php)
+|   'timestamp'  = Timestamp migration naming (20121031104401_add_blog.php)
+|                  Use timestamp format YYYYMMDDHHIISS.
+|
+| Note: If this configuration value is missing the Migration library
+|       defaults to 'sequential' for backward compatibility with CI2.
+|
+*/
+$config['migration_type'] = 'timestamp';
+
+/*
+|--------------------------------------------------------------------------
+| Migrations table
+|--------------------------------------------------------------------------
+|
+| This is the name of the table that will store the current migrations state.
+| When migrations runs it will store in a database table which migration
+| level the system is at. It then compares the migration level in this
+| table to the $config['migration_version'] if they are not the same it
+| will migrate up. This must be set.
+|
+*/
+$config['migration_table'] = 'migrations';
+
+/*
+|--------------------------------------------------------------------------
+| Auto Migrate To Latest
+|--------------------------------------------------------------------------
+|
+| If this is set to TRUE when you load the migrations class and have
+| $config['migration_enabled'] set to TRUE the system will auto migrate
+| to your latest migration (whatever $config['migration_version'] is
+| set to). This way you do not have to call migrations anywhere else
+| in your code to have the latest migration.
+|
+*/
+$config['migration_auto_latest'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Migrations version
+|--------------------------------------------------------------------------
+|
+| This is used to set migration version that the file system should be on.
+| If you run $this->migration->current() this is the version that schema will
+| be upgraded / downgraded to.
+|
+*/
+$config['migration_version'] = 0;
+
+/*
+|--------------------------------------------------------------------------
+| Migrations Path
+|--------------------------------------------------------------------------
+|
+| Path to your migrations folder.
+| Typically, it will be within your application path.
+| Also, writing permission is required within the migrations path.
+|
+*/
+$config['migration_path'] = APPPATH.'migrations/';

Diff do ficheiro suprimidas por serem muito extensas
+ 183 - 0
core/CoreApp/config/mimes.php


+ 14 - 0
core/CoreApp/config/profiler.php

@@ -0,0 +1,14 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+/*
+| -------------------------------------------------------------------------
+| Profiler Sections
+| -------------------------------------------------------------------------
+| This file lets you determine whether or not various sections of Profiler
+| data are displayed when the Profiler is enabled.
+| Please see the user guide for info:
+|
+|	https://codeigniter.com/user_guide/general/profiling.html
+|
+*/

+ 8 - 0
core/CoreApp/config/routes.php

@@ -0,0 +1,8 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+$route['default_controller'] = 'start';
+$route['phone'] = "start/phone";
+$route['userlogin'] = "userlogin/login";
+$route['404_override'] = '';
+$route['translate_uri_dashes'] = FALSE;

+ 64 - 0
core/CoreApp/config/smileys.php

@@ -0,0 +1,64 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+/*
+| -------------------------------------------------------------------
+| SMILEYS
+| -------------------------------------------------------------------
+| This file contains an array of smileys for use with the emoticon helper.
+| Individual images can be used to replace multiple smileys.  For example:
+| :-) and :) use the same image replacement.
+|
+| Please see user guide for more info:
+| https://codeigniter.com/user_guide/helpers/smiley_helper.html
+|
+*/
+$smileys = array(
+
+//	smiley			image name						width	height	alt
+
+	':-)'			=>	array('grin.gif',			'19',	'19',	'grin'),
+	':lol:'			=>	array('lol.gif',			'19',	'19',	'LOL'),
+	':cheese:'		=>	array('cheese.gif',			'19',	'19',	'cheese'),
+	':)'			=>	array('smile.gif',			'19',	'19',	'smile'),
+	';-)'			=>	array('wink.gif',			'19',	'19',	'wink'),
+	';)'			=>	array('wink.gif',			'19',	'19',	'wink'),
+	':smirk:'		=>	array('smirk.gif',			'19',	'19',	'smirk'),
+	':roll:'		=>	array('rolleyes.gif',		'19',	'19',	'rolleyes'),
+	':-S'			=>	array('confused.gif',		'19',	'19',	'confused'),
+	':wow:'			=>	array('surprise.gif',		'19',	'19',	'surprised'),
+	':bug:'			=>	array('bigsurprise.gif',	'19',	'19',	'big surprise'),
+	':-P'			=>	array('tongue_laugh.gif',	'19',	'19',	'tongue laugh'),
+	'%-P'			=>	array('tongue_rolleye.gif',	'19',	'19',	'tongue rolleye'),
+	';-P'			=>	array('tongue_wink.gif',	'19',	'19',	'tongue wink'),
+	':P'			=>	array('raspberry.gif',		'19',	'19',	'raspberry'),
+	':blank:'		=>	array('blank.gif',			'19',	'19',	'blank stare'),
+	':long:'		=>	array('longface.gif',		'19',	'19',	'long face'),
+	':ohh:'			=>	array('ohh.gif',			'19',	'19',	'ohh'),
+	':grrr:'		=>	array('grrr.gif',			'19',	'19',	'grrr'),
+	':gulp:'		=>	array('gulp.gif',			'19',	'19',	'gulp'),
+	'8-/'			=>	array('ohoh.gif',			'19',	'19',	'oh oh'),
+	':down:'		=>	array('downer.gif',			'19',	'19',	'downer'),
+	':red:'			=>	array('embarrassed.gif',	'19',	'19',	'red face'),
+	':sick:'		=>	array('sick.gif',			'19',	'19',	'sick'),
+	':shut:'		=>	array('shuteye.gif',		'19',	'19',	'shut eye'),
+	':-/'			=>	array('hmm.gif',			'19',	'19',	'hmmm'),
+	'>:('			=>	array('mad.gif',			'19',	'19',	'mad'),
+	':mad:'			=>	array('mad.gif',			'19',	'19',	'mad'),
+	'>:-('			=>	array('angry.gif',			'19',	'19',	'angry'),
+	':angry:'		=>	array('angry.gif',			'19',	'19',	'angry'),
+	':zip:'			=>	array('zip.gif',			'19',	'19',	'zipper'),
+	':kiss:'		=>	array('kiss.gif',			'19',	'19',	'kiss'),
+	':ahhh:'		=>	array('shock.gif',			'19',	'19',	'shock'),
+	':coolsmile:'	=>	array('shade_smile.gif',	'19',	'19',	'cool smile'),
+	':coolsmirk:'	=>	array('shade_smirk.gif',	'19',	'19',	'cool smirk'),
+	':coolgrin:'	=>	array('shade_grin.gif',		'19',	'19',	'cool grin'),
+	':coolhmm:'		=>	array('shade_hmm.gif',		'19',	'19',	'cool hmm'),
+	':coolmad:'		=>	array('shade_mad.gif',		'19',	'19',	'cool mad'),
+	':coolcheese:'	=>	array('shade_cheese.gif',	'19',	'19',	'cool cheese'),
+	':vampire:'		=>	array('vampire.gif',		'19',	'19',	'vampire'),
+	':snake:'		=>	array('snake.gif',			'19',	'19',	'snake'),
+	':exclaim:'		=>	array('exclaim.gif',		'19',	'19',	'exclaim'),
+	':question:'	=>	array('question.gif',		'19',	'19',	'question')
+
+);

+ 214 - 0
core/CoreApp/config/user_agents.php

@@ -0,0 +1,214 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+/*
+| -------------------------------------------------------------------
+| USER AGENT TYPES
+| -------------------------------------------------------------------
+| This file contains four arrays of user agent data. It is used by the
+| User Agent Class to help identify browser, platform, robot, and
+| mobile device data. The array keys are used to identify the device
+| and the array values are used to set the actual name of the item.
+*/
+$platforms = array(
+	'windows nt 10.0'	=> 'Windows 10',
+	'windows nt 6.3'	=> 'Windows 8.1',
+	'windows nt 6.2'	=> 'Windows 8',
+	'windows nt 6.1'	=> 'Windows 7',
+	'windows nt 6.0'	=> 'Windows Vista',
+	'windows nt 5.2'	=> 'Windows 2003',
+	'windows nt 5.1'	=> 'Windows XP',
+	'windows nt 5.0'	=> 'Windows 2000',
+	'windows nt 4.0'	=> 'Windows NT 4.0',
+	'winnt4.0'			=> 'Windows NT 4.0',
+	'winnt 4.0'			=> 'Windows NT',
+	'winnt'				=> 'Windows NT',
+	'windows 98'		=> 'Windows 98',
+	'win98'				=> 'Windows 98',
+	'windows 95'		=> 'Windows 95',
+	'win95'				=> 'Windows 95',
+	'windows phone'			=> 'Windows Phone',
+	'windows'			=> 'Unknown Windows OS',
+	'android'			=> 'Android',
+	'blackberry'		=> 'BlackBerry',
+	'iphone'			=> 'iOS',
+	'ipad'				=> 'iOS',
+	'ipod'				=> 'iOS',
+	'os x'				=> 'Mac OS X',
+	'ppc mac'			=> 'Power PC Mac',
+	'freebsd'			=> 'FreeBSD',
+	'ppc'				=> 'Macintosh',
+	'linux'				=> 'Linux',
+	'debian'			=> 'Debian',
+	'sunos'				=> 'Sun Solaris',
+	'beos'				=> 'BeOS',
+	'apachebench'		=> 'ApacheBench',
+	'aix'				=> 'AIX',
+	'irix'				=> 'Irix',
+	'osf'				=> 'DEC OSF',
+	'hp-ux'				=> 'HP-UX',
+	'netbsd'			=> 'NetBSD',
+	'bsdi'				=> 'BSDi',
+	'openbsd'			=> 'OpenBSD',
+	'gnu'				=> 'GNU/Linux',
+	'unix'				=> 'Unknown Unix OS',
+	'symbian' 			=> 'Symbian OS'
+);
+
+
+// The order of this array should NOT be changed. Many browsers return
+// multiple browser types so we want to identify the sub-type first.
+$browsers = array(
+	'OPR'			=> 'Opera',
+	'Flock'			=> 'Flock',
+	'Edge'			=> 'Spartan',
+	'Chrome'		=> 'Chrome',
+	// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
+	'Opera.*?Version'	=> 'Opera',
+	'Opera'			=> 'Opera',
+	'MSIE'			=> 'Internet Explorer',
+	'Internet Explorer'	=> 'Internet Explorer',
+	'Trident.* rv'	=> 'Internet Explorer',
+	'Shiira'		=> 'Shiira',
+	'Firefox'		=> 'Firefox',
+	'Chimera'		=> 'Chimera',
+	'Phoenix'		=> 'Phoenix',
+	'Firebird'		=> 'Firebird',
+	'Camino'		=> 'Camino',
+	'Netscape'		=> 'Netscape',
+	'OmniWeb'		=> 'OmniWeb',
+	'Safari'		=> 'Safari',
+	'Mozilla'		=> 'Mozilla',
+	'Konqueror'		=> 'Konqueror',
+	'icab'			=> 'iCab',
+	'Lynx'			=> 'Lynx',
+	'Links'			=> 'Links',
+	'hotjava'		=> 'HotJava',
+	'amaya'			=> 'Amaya',
+	'IBrowse'		=> 'IBrowse',
+	'Maxthon'		=> 'Maxthon',
+	'Ubuntu'		=> 'Ubuntu Web Browser'
+);
+
+$mobiles = array(
+	// legacy array, old values commented out
+	'mobileexplorer'	=> 'Mobile Explorer',
+//  'openwave'			=> 'Open Wave',
+//	'opera mini'		=> 'Opera Mini',
+//	'operamini'			=> 'Opera Mini',
+//	'elaine'			=> 'Palm',
+	'palmsource'		=> 'Palm',
+//	'digital paths'		=> 'Palm',
+//	'avantgo'			=> 'Avantgo',
+//	'xiino'				=> 'Xiino',
+	'palmscape'			=> 'Palmscape',
+//	'nokia'				=> 'Nokia',
+//	'ericsson'			=> 'Ericsson',
+//	'blackberry'		=> 'BlackBerry',
+//	'motorola'			=> 'Motorola'
+
+	// Phones and Manufacturers
+	'motorola'		=> 'Motorola',
+	'nokia'			=> 'Nokia',
+	'palm'			=> 'Palm',
+	'iphone'		=> 'Apple iPhone',
+	'ipad'			=> 'iPad',
+	'ipod'			=> 'Apple iPod Touch',
+	'sony'			=> 'Sony Ericsson',
+	'ericsson'		=> 'Sony Ericsson',
+	'blackberry'	=> 'BlackBerry',
+	'cocoon'		=> 'O2 Cocoon',
+	'blazer'		=> 'Treo',
+	'lg'			=> 'LG',
+	'amoi'			=> 'Amoi',
+	'xda'			=> 'XDA',
+	'mda'			=> 'MDA',
+	'vario'			=> 'Vario',
+	'htc'			=> 'HTC',
+	'samsung'		=> 'Samsung',
+	'sharp'			=> 'Sharp',
+	'sie-'			=> 'Siemens',
+	'alcatel'		=> 'Alcatel',
+	'benq'			=> 'BenQ',
+	'ipaq'			=> 'HP iPaq',
+	'mot-'			=> 'Motorola',
+	'playstation portable'	=> 'PlayStation Portable',
+	'playstation 3'		=> 'PlayStation 3',
+	'playstation vita'  	=> 'PlayStation Vita',
+	'hiptop'		=> 'Danger Hiptop',
+	'nec-'			=> 'NEC',
+	'panasonic'		=> 'Panasonic',
+	'philips'		=> 'Philips',
+	'sagem'			=> 'Sagem',
+	'sanyo'			=> 'Sanyo',
+	'spv'			=> 'SPV',
+	'zte'			=> 'ZTE',
+	'sendo'			=> 'Sendo',
+	'nintendo dsi'	=> 'Nintendo DSi',
+	'nintendo ds'	=> 'Nintendo DS',
+	'nintendo 3ds'	=> 'Nintendo 3DS',
+	'wii'			=> 'Nintendo Wii',
+	'open web'		=> 'Open Web',
+	'openweb'		=> 'OpenWeb',
+
+	// Operating Systems
+	'android'		=> 'Android',
+	'symbian'		=> 'Symbian',
+	'SymbianOS'		=> 'SymbianOS',
+	'elaine'		=> 'Palm',
+	'series60'		=> 'Symbian S60',
+	'windows ce'	=> 'Windows CE',
+
+	// Browsers
+	'obigo'			=> 'Obigo',
+	'netfront'		=> 'Netfront Browser',
+	'openwave'		=> 'Openwave Browser',
+	'mobilexplorer'	=> 'Mobile Explorer',
+	'operamini'		=> 'Opera Mini',
+	'opera mini'	=> 'Opera Mini',
+	'opera mobi'	=> 'Opera Mobile',
+	'fennec'		=> 'Firefox Mobile',
+
+	// Other
+	'digital paths'	=> 'Digital Paths',
+	'avantgo'		=> 'AvantGo',
+	'xiino'			=> 'Xiino',
+	'novarra'		=> 'Novarra Transcoder',
+	'vodafone'		=> 'Vodafone',
+	'docomo'		=> 'NTT DoCoMo',
+	'o2'			=> 'O2',
+
+	// Fallback
+	'mobile'		=> 'Generic Mobile',
+	'wireless'		=> 'Generic Mobile',
+	'j2me'			=> 'Generic Mobile',
+	'midp'			=> 'Generic Mobile',
+	'cldc'			=> 'Generic Mobile',
+	'up.link'		=> 'Generic Mobile',
+	'up.browser'	=> 'Generic Mobile',
+	'smartphone'	=> 'Generic Mobile',
+	'cellphone'		=> 'Generic Mobile'
+);
+
+// There are hundreds of bots but these are the most common.
+$robots = array(
+	'googlebot'		=> 'Googlebot',
+	'msnbot'		=> 'MSNBot',
+	'baiduspider'		=> 'Baiduspider',
+	'bingbot'		=> 'Bing',
+	'slurp'			=> 'Inktomi Slurp',
+	'yahoo'			=> 'Yahoo',
+	'ask jeeves'		=> 'Ask Jeeves',
+	'fastcrawler'		=> 'FastCrawler',
+	'infoseek'		=> 'InfoSeek Robot 1.0',
+	'lycos'			=> 'Lycos',
+	'yandex'		=> 'YandexBot',
+	'mediapartners-google'	=> 'MediaPartners Google',
+	'CRAZYWEBCRAWLER'	=> 'Crazy Webcrawler',
+	'adsbot-google'		=> 'AdsBot Google',
+	'feedfetcher-google'	=> 'Feedfetcher Google',
+	'curious george'	=> 'Curious George',
+	'ia_archiver'		=> 'Alexa Crawler',
+	'MJ12bot'		=> 'Majestic-12',
+	'Uptimebot'		=> 'Uptimebot'
+);

Diff do ficheiro suprimidas por serem muito extensas
+ 1017 - 0
core/CoreApp/controllers/Aa.php


+ 475 - 0
core/CoreApp/controllers/Aay.php

@@ -0,0 +1,475 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Aay extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+		$this->load->_model('Model_fullorder_2020','fullorder2020');
+		$this->load->_model('Model_fullordersmt_2020','fullordersmt2020');
+		$this->load->_model('Model_customersmt','customersmt');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_hl','hl');
+		$this->load->_model('Model_is','is');
+		$this->load->_model('Model_kdniao','kdniao');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_fullorderexcel','fullorderexcel');
+		$this->load->_model('Model_dhl','dhl');
+		$this->load->_model('Model_usps','usps');
+		$this->load->_model('Model_dhltest','dhltest');
+		$this->load->_model('Model_customer','customer');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_notice','notice');
+		$this->load->_model('Model_whlabel','whlabel');
+		$this->load->_model('Model_productdescribe','productdescribe');
+		$this->load->_model('Model_ljg','ljg');
+		$this->load->_model('Model_commodityread','commodityread');
+		$this->load->_model('Model_service','service');
+		$this->load->_model('Model_fedex','fedex');
+		$this->load->_model('Model_commodity','commodity');
+		$this->load->_model('Model_fullordersmtorder','fullordersmtorder');
+		$this->load->_model('Model_ali','ali');
+		$this->load->_model('Model_fullordersmthb','fullordersmthb');
+		$this->load->_model('Model_fullordersmtbf','fullordersmtbf');
+		$this->load->_model('Model_taxzhengzhou','taxzhengzhou');
+		$this->load->_model('Model_taxshanghai','taxshanghai');
+		$this->load->_model('Model_excel','excel');
+		$this->load->_model('Model_ups','ups');
+		$this->load->_model('Model_dpd','dpd');
+		$this->load->_model('Model_dpdold','dpdold');
+		$this->load->_model('Model_dpd_IOSS','dpd_IOSS');
+		$this->load->_model('Model_dpdxw','dpdxw');
+		$this->load->_model('Model_cne','cne');
+		$this->load->_model('Model_outbound','outbound');
+		$this->load->_model('Model_api','api');
+		$this->load->_model('Model_dhlhz','dhlhz');
+		$this->load->_model('Model_apismt','apismt');
+		$this->load->_model('Model_specialstock','specialstock');
+		$this->load->_model('Model_systemwigsout','systemwigsout');
+		$this->load->_model('Model_purchaseorder','purchaseorder');
+		$this->load->_model('Model_returns','returns');
+		$this->load->_model('Model_whlabellabel','whlabellabel');
+		$this->load->_model('Model_whlabelbarcode','whlabelbarcode');
+		$this->load->_model('Model_tjadd','tjadd');
+		$this->load->_model('Model_stafflist','stafflist');
+		$this->load->_model('Model_paypal','paypal');
+		$this->load->_model('Model_warehousefactory','warehousefactory');
+		$this->load->_model('Model_commodityread_del','commodityreaddel');
+		$this->load->_model('Model_als','als');
+		$this->load->_model('Model_allocation','allocation');
+		$this->load->_model('Model_17track','17track');
+		$this->load->_model('Model_hualei','hualei');
+		$this->load->_model('Model_ck','ck');
+		$this->load->_model('Model_colour','colour');
+		$this->load->_model('Model_color','color');
+		$this->load->_model('Model_emaildata','emaildata');
+		$this->load->_model('Model_wigprint','wigprint');
+		$this->load->_model('Model_weight','weight');
+		$this->load->_model('Model_whlabeltransport','whlabeltransport');
+		$this->load->_model('Model_pay','pay');
+		$this->load->_model('Model_orderurl','orderurl');
+		$this->load->_model('Model_classid','classid');
+		$this->load->_model('Model_apiyy','apiyy');
+		$this->load->_model('Model_purchase','purchase');
+		$this->load->_model('Model_apitt','apitt');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'a')
+        {
+             $this->_a($arg_array);
+        }
+		else if($arg == 'b')
+        {
+             $this->_b($arg_array);
+        }
+		else if($arg == 'rk')
+        {
+             $this->_rk($arg_array);
+        }
+		else if($arg == 'dc')
+        {
+             $this->_dc($arg_array);
+        }
+    }
+	
+	
+	public function _dc($arg_array)
+	{
+		$data = $this->fullorder->get_number($arg_array[0]);
+		$classid = $this->classid->sku();
+		$tc = $this->typeclass->find_all();
+		$typeclass = array();
+		foreach ($tc as $v)
+		{
+			$tcjm[$v['id']] = array($v['jm'],$v['classid']);
+			$typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
+		}
+		$bm = '03';
+		$xysc = array();
+		$data['lh'] = array();
+		$scid = '';$cw = '';$lc = 0;
+		$sku = explode(';',trim($data['fpdata'],';'));
+		$whlabelsc = explode('|',trim($data['whlabel'],'|'));
+	$cs = array();
+		foreach($sku as $key=>$val)
+		{
+			$pm = $classid;
+		    $jm = $classid;
+			$bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
+			$features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$val);
+			$ts = explode('|',trim($features,'|'));
+			if(stripos($ts[0],',') !== false)
+			{
+				$ft = explode(',',$ts[0]);
+			    $features = explode('-',trim($ft[1],'-'));
+				$features[] = $ft[0];
+			}
+			else
+			{
+				$features = explode('-',trim($ts[0],'-'));
+			}
+			foreach($features as $k=>$v)
+			{
+				if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
+				{
+					if($typeclass[$v]['bm'] != '')
+					{
+						$bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
+					}
+				}
+				if($v != 0)
+				{
+					if(isset($pm[$typeclass[$v]['classid']]))
+					{
+						if($typeclass[$v]['title'] == '9A')
+						{
+							$pm[$typeclass[$v]['classid']] = '9A';
+						}
+						else if($typeclass[$v]['title'] == '10A')
+						{
+							$pm[$typeclass[$v]['classid']] = '10A';
+						}
+						else
+						{
+							$clzh = $typeclass[$v]['zh'];
+							if(stripos($typeclass[$v]['zh'],'|') !== false)
+							{
+								$clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
+								$clzh = $clzh[0];
+							}
+							$pm[$typeclass[$v]['classid']] = $clzh;
+						}
+					}
+					if(isset($jm[$typeclass[$v]['classid']]))
+					{
+						if($typeclass[$v]['jm'])
+						{
+						    $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
+						}
+					}
+				}
+			}
+			$cs[] = array($bmpx,$jm);
+			$jm = array_filter($jm);
+			$jm = implode("-",$jm);
+			$pm = array_filter($pm);//去除空值
+			$zh = implode(" ",$pm);
+			$zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
+			$data['lh'][] = array('sku'=>$jm,'ts'=>$ts[2]);
+		}
+		echo "<pre>";
+		print_r($cs);
+		echo "<pre>";
+		print_r($sku);
+	}
+	
+	public function _rk($arg_array)
+	{
+		
+		$a = $this->fullorder->get_number($arg_array[0]);
+		
+		$classid = $this->classid->sku();
+		$tcall = $this->typeclass->find_all();
+		$apiyy = $a;
+		$shop = $this->shop->read($a['shop']);
+		@$ay = $this->apiyy->_order($apiyy,$classid,$tcall);
+
+	
+		echo "<pre>";
+		print_r($ay);
+		echo "<pre>";
+		print_r($a);
+		echo "<pre>";
+		print_r($shop);
+		exit;
+	}
+	
+	
+	public function _b()
+	{
+		$data = $this->fullorder->get_number('Alipearl-70419-001');
+		echo "<pre>";
+		print_r($data);
+		exit;
+		
+		$data = $this->fullorder->get_number('KISS-30929-094');
+				$data['dtime'] = time();
+					$classid = $this->classid->sku();
+					$tc = $this->typeclass->find_all();
+				
+					
+		$error = '';
+		$typeclass = array();
+		foreach ($tc as $v)
+		{
+			$tcjm[$v['id']] = array($v['jm'],$v['classid']);
+			$typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
+		}
+		$pm = $classid;
+		$jm = $classid;
+		$bm = '03';
+		$bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
+		$data['lh'] = array();$sc = array();
+		$sku = explode(';',trim($data['fpdata'],';'));
+		$whlabelsc = explode('|',trim($data['whlabel'],'|'));
+		foreach($sku as $key=>$val)
+		{
+			$features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$val);
+			$ts = explode('|',trim($features,'|'));
+			if(stripos($ts[0],',') !== false)
+			{
+				$ft = explode(',',$ts[0]);
+			    $features = explode('-',trim($ft[1],'-'));
+				$features[] = $ft[0];
+			}
+			else
+			{
+				$features = explode('-',trim($ts[0],'-'));
+			}
+			foreach($features as $k=>$v)
+			{
+				if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
+				{
+					if($typeclass[$v]['bm'] != '')
+					{
+						$bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
+					}
+				}
+				if($v != 0)
+				{
+					if(isset($pm[$typeclass[$v]['classid']]))
+					{
+						if($typeclass[$v]['title'] == '9A')
+						{
+							$pm[$typeclass[$v]['classid']] = '9A';
+						}
+						else if($typeclass[$v]['title'] == '10A')
+						{
+							$pm[$typeclass[$v]['classid']] = '10A';
+						}
+						else
+						{
+							$clzh = $typeclass[$v]['zh'];
+							if(stripos($typeclass[$v]['zh'],'|') !== false)
+							{
+								$clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
+								$clzh = $clzh[0];
+							}
+							$pm[$typeclass[$v]['classid']] = $clzh;
+						}
+					}
+					if(isset($jm[$typeclass[$v]['classid']]))
+					{
+						$jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
+					}
+				}
+			}
+			$jm = array_filter($jm);//去除空值
+			$pm = array_filter($pm);//去除空值
+			$zh = implode(" ",$pm);
+			$zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
+			$data['lh'][] = array('sku'=>implode("-",$jm),'ts'=>$ts[2]);
+			$lh = $this->apiyy->get_cjlp(array('sku'=>implode("-",$jm),'title'=>$ts[1],'zh'=>$zh,'bm'=>$bm.implode("",$bmpx)));
+			$sfsc = explode('-',$whlabelsc[$key]);
+			if($sfsc[2] == 'DNOTO')
+			{
+			    $sc[] = $this->apiyy->get_sc(array('sku'=>implode("-",$jm),'title'=>$ts[1],'id'=>$data['id']));
+			}
+		}
+		if($error)
+		{
+			return array('c'=>1,'error'=>$error,'lx'=>'料号','number'=>$data['number']);exit;
+		}
+		$a = $this->apiyy->get_order($data);
+		if($a == 1)
+		{
+			return array('c'=>0);exit;
+		}
+		echo "<pre>";
+		print_r($a);
+		echo "<pre>";
+		print_r($sc);
+		echo "<pre>";
+		print_r($lh);
+		echo "<pre>";
+		exit;
+	}
+	
+		public function _bsd($arg_array)
+	{
+					
+					exit;
+					
+		$post = $this->fullorder->get_number($arg_array[0]);
+		$classid = $this->classid->sku();
+							$tcall = $this->typeclass->find_all();
+							$ay = $this->apiyy->_order($post,$classid,$tcall);
+							if($ay['c'] == 1)
+							{
+								$this->apiyy->insert(array('number'=>$ay['number'],'lx'=>$ay['lx'],'error'=>$ay['error']));
+							}
+print_r($a);
+		/**
+		$a = $this->apiyy->get_cjlp(array('sku'=>'9A-#color25-wavy25-5*5Bob-14-180%-M','title'=>'Wigs 9A #color25 wavy25 5*5 Bob Wig Medium 180% 14inch ','zh'=>'9A 5*5波波头套 14寸 (180%密度) (中号)'));
+		echo "<pre>";
+		print_r($a);
+		exit;
+		$tc = $this->typeclass->find_all();
+		$typeclass = array();
+		foreach ($tc as $v)
+		{
+			$this->typeclass->save(array('yzh'=>$v['zh']),$v['id']);
+		}
+		**/
+		exit;
+		
+		$s = $this->fullorder->get_number($arg_array[0]);
+		$a = $this->apiyy->get_chd($s);
+		echo "<pre>";
+		print_r($a);
+		exit;
+	}
+	public function _a($arg_array)
+	{
+		$list["SqlString"] = "select a.id,a.code,c.name,a.org,b.name org_name from CBO_Wh a  left join CBO_Wh_trl c on c.id=a.id left join Base_Organization_trl b on a.org=b.id";
+		$list = json_encode($list);
+		$token = $this->setting->get_yytoken_101();
+		$url = 'http://172.31.105.167/U9C/webapi/QueryCommon/QueryInfoBySql';
+		$header[] = "Content-Type: application/json";
+        $header[] = "Token: ".$token;
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+		curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
+		curl_setopt($ch, CURLOPT_POST, 1);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $list);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+        $res = curl_exec($ch);
+		$res = json_decode($res,true);
+	
+		echo "<pre>";
+		print_r($res);
+		exit;
+		$tc = $this->typeclass->find_all();
+		$typeclass = array();
+		foreach ($tc as $v)
+		{
+			$tcjm[$v['id']] = array($v['jm'],$v['classid']);
+			$typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
+		}
+			//$s = $this->fullorder->find_all('1=1','*','id desc',100,103);
+			$s = $this->fullorder->get_number($arg_array[0]);
+			$classid = $this->classid->sku();
+			$pm = $classid;
+			$jm = $classid;
+			$bm = '03';
+			$bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
+			$s['lh'] = array();
+			$sku = explode(';',trim($s['fpdata'],';'));
+			foreach($sku as $val)
+			{
+			    $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$val);
+				$ts = explode('|',trim($features,'|'));
+				if(stripos($ts[0],',') !== false)
+				{
+				    $ft = explode(',',$ts[0]);
+			        $features = explode('-',trim($ft[1],'-'));
+					$features[] = $ft[0];
+				}
+				else
+				{
+					$features = explode('-',trim($ft[1],'-'));
+				}
+			    foreach($features as $k=>$v)
+				{
+					if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
+					{
+						if($typeclass[$v]['bm'] != '')
+						{
+						    $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
+						}
+					}
+					if($v != 0)
+					{
+						if(isset($pm[$typeclass[$v]['classid']]))
+						{
+							if($typeclass[$v]['title'] == '9A')
+							{
+						        $pm[$typeclass[$v]['classid']] = '9A';
+							}
+							else if($typeclass[$v]['title'] == '10A')
+							{
+						        $pm[$typeclass[$v]['classid']] = '10A';
+							}
+							else
+							{
+								$clzh = $typeclass[$v]['zh'];
+								if(stripos($typeclass[$v]['zh'],'|') !== false)
+								{
+									$clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
+									$clzh = $clzh[0];
+								}
+								$pm[$typeclass[$v]['classid']] = $clzh;
+							}
+						}
+						if(isset($jm[$typeclass[$v]['classid']]))
+						{
+						       $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
+							
+						}
+				    }
+				}
+				$jm = array_filter($jm);//去除空值
+				$pm = array_filter($pm);//去除空值
+				$zh = implode(" ",$pm);
+				$zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
+				$s['lh'][] = array('sku'=>implode("-",$jm),'ts'=>$ts[2]);
+				$lh = $this->apiyy->get_cjlp(array('sku'=>implode("-",$jm),'title'=>$ts[1],'zh'=>$zh,'bm'=>$bm.implode("",$bmpx)));
+				if(!isset($lh['Data'][0]) || $lh['Data'][0]['m_isSucess'] != 1)
+		        {
+					if($lh['Data'][0]['m_errorMsg'] == '料号 已存在,请重新输入!')
+					{
+						continue;
+					}
+					else
+					{
+					    print_r($lh);exit;
+					}
+				}
+			}
+		$a = $this->apiyy->get_order($s);
+			echo "<pre>";
+		print_r($a);
+		echo "<pre>";
+		print_r(array('sku'=>implode("-",$jm),'title'=>$ts[1],'zh'=>$zh,'bm'=>$bm.implode("",$bmpx)));
+		exit;
+	}
+
+
+}

Diff do ficheiro suprimidas por serem muito extensas
+ 1924 - 0
core/CoreApp/controllers/Ab.php


Diff do ficheiro suprimidas por serem muito extensas
+ 569 - 0
core/CoreApp/controllers/Ac.php


+ 360 - 0
core/CoreApp/controllers/Ahc.php

@@ -0,0 +1,360 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Ahc extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_fullorder_smt','fullorder_smt');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullorderexcel','fullorderexcel');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_productdescribe','productdescribe');
+		$this->load->_model('Model_customs','customs');
+		$this->load->_model('Model_detailed','detailed');
+		$this->load->_model('Model_productdescription','productdescription');
+		$this->load->_model('Model_logistics','logistics');
+		$this->load->_model('Model_hl','hl');
+		$this->load->_model('Model_excel','excel');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_customer','customer');
+		$this->load->_model('Model_user','user');
+		$this->load->_model('Model_dhl','dhl');
+		$this->load->_model('Model_notice','notice');
+		$this->load->_model('Model_api','api');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'hcd')
+        {
+             $this->_hcd();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$dt = 0;
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$timetk = strtotime($timetk)+12*3600;
+			$timetj = strtotime($timetj)+12*3600;
+			$data = $this->input->post('data',true);
+			$where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
+			if($data == 1)
+			{
+				$where .= " and print = 2 and state = 207";
+			}
+			else if($data == 2)
+			{
+				$where .= " and print = 3 and library = 1 and printtime > '$timetk' and printtime < '$timetj'";
+			}
+			else if($data == 3)
+			{
+				$where .= " and print = 3 and library = 2 and librarytime > '$timetk' and librarytime < '$timetj'";
+			}
+			else if($data == 4)
+			{
+				$where .= " and print = 3 and library = 3 and retreattime > '$timetk' and retreattime < '$timetj'";
+			}
+            //数据排序
+            $order_str = "dtime desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            $info_list = $this->fullorder_smt->find_all($where,'id,shop,type,orderinfo,number,client,state,buytime,libraryconfirm,express,waybill,orderremarks,reviewremarks,printnumber,black,clientremarks',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$ud = $this->fullorder_smt->read($value['id']);
+				$ud['address'] = str_replace("'","’",$ud['address']);
+				$ud['name'] = str_replace("'","’",$ud['name']);
+				$customer = $this->customer->get_email($ud['email'],$value['shop']);
+				$customerb = $this->customer->get_shopdata($ud['name'],$ud['email'],$ud['address'],$value['shop']);
+				//$a = array_column($customer, 'email'); //三维找其中健的数组
+			    //$a = array_flip($a); //键和值调换
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				//$info_list[$key]['user'] = $shop['shopuser'];
+				$warehouse = $this->warehouse->read($value['type']);
+				$warehousetitle = $warehouse['title'];
+				if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
+				$info_list[$key]['type'] = $warehousetitle;
+				$typeclass = $this->typeclass->read($value['state']);
+				$info_list[$key]['state'] = $typeclass['spare'];
+				if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
+				{
+					$info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';
+				}
+				else
+				{
+				    $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']+$dt).'</p><p>'.date('H:i:s',$value['buytime']+$dt).'</p>';
+				}
+				if($value['waybill'] != "")
+				{
+					$info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>";
+				}
+				if($value['express'] != 0)
+				{
+				    $express = $this->express->read($value['express']);
+					$expressservicename = $express['servicename'];
+				if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
+				    $info_list[$key]['express'] = $expressservicename;
+				}
+				else
+				{
+					$info_list[$key]['express'] = "无";
+				}
+				$x = "";
+				if($value['libraryconfirm'] == 2 && $ud['review'] > 4 && $ud['library'] == 1)
+				{
+				    $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
+				}
+				else if(($ud['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
+				{
+					$x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
+				}
+				if(($ud['review'] > 4) && $ud['print'] == 2)
+				{
+				    $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
+				}
+				else if($ud['review'] >4 && $ud['print'] == 1)
+				{
+				    $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
+				}
+				if($value['waybill'] == "" && $ud['review'] > 4)
+				{
+					$x = $x."<p><b class='kn' data-type='2'>填写运单</b></p>";
+				}
+				else if($value['waybill'] != "" && $ud['review'] > 4)
+				{
+					$x = $x."<p><b class='kn' data-type='2'>修改运单</b></p>";
+				}
+				if(($ud['review'] == 1 || $ud['review'] == 3) && $ud['express'] > 0 && $ud['dtsbjz'] != 0 && $ud['ts'] != 0 && $ud['zsbjz'] != 0 && $ud['zjs'] != 0 && $ud['ts'] != 0)
+				{
+					$x = $x."<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
+				}
+				if($value['black'] == 0)
+				{
+					$x = $x."<p><b class='black' data-type='4' data-id='".$value['id']."'>加黑名单</b></p>";
+				}
+				$info_list[$key]['black'] = $x;
+				$tly = "";
+				if($value['clientremarks'] != "")
+				{
+					$tly = "<p style='color:#FF3333'>有客户留言</p>";
+				}
+				
+				$info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder_smt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
+				
+            }
+			$xx1 = $this->fullorder_smt->find_count("print = 2 and state = 207");
+			$xx2 = $this->fullorder_smt->find_count("print = 3 and library = 1 and printtime > '$timetk' and printtime < '$timetj'");
+			$xx3 = $this->fullorder_smt->find_count("print = 3 and library = 2 and librarytime > '$timetk' and librarytime < '$timetj'");
+			$xx4 = $this->fullorder_smt->find_count("print = 3 and library = 3 and retreattime > '$timetk' and retreattime < '$timetj'");
+		    $total = $this->fullorder_smt->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'xx'=>(array('1'=>$xx1,'2'=>$xx2,'3'=>$xx3,'4'=>$xx4)));
+		    echo json_encode($rows);exit;
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$this->data['express'] = $this->express->find_all();
+		$fullorderexcel = $this->fullorderexcel->find_all('type=1','*','idorder desc');//导出模板
+		$this->data['fullorderexcel'] = $fullorderexcel;
+		$error = $this->fullorder_smt->find_count("print = 1 and failed !='' and mergeid = 0 and waybill = '' and (".rtrim($fgshop,'or').")");
+		$this->data['error'] = $error;
+		$this->_Template('ahc_smt',$this->data);
+	}
+	
+	//管理
+	public function _hcd()
+	{
+		$dt = 0;
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$timetk = strtotime($timetk)+12*3600;
+			$timetj = strtotime($timetj)+12*3600;
+			$data = $this->input->post('data',true);
+			$where = "mergeid = 0 and type = 5 and review = 6 and (".rtrim($fgshop,'or').")";
+			if($data == 1)
+			{
+				$where .= " and print = 2 and state = 207 and dtime > 1557244800";
+			}
+			else if($data == 2)
+			{
+				$where .= " and print = 3 and library = 1 and printtime > '$timetk' and printtime < '$timetj'";
+			}
+			else if($data == 3)
+			{
+				$where .= " and print = 3 and library = 2 and librarytime > '$timetk' and librarytime < '$timetj'";
+			}
+			else if($data == 4)
+			{
+				$where .= " and print = 3 and library = 3 and retreattime > '$timetk' and retreattime < '$timetj'";
+			}
+            //数据排序
+            $order_str = "dtime desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,client,state,buytime,libraryconfirm,express,waybill,orderremarks,reviewremarks,printnumber,black,clientremarks',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$ud = $this->fullorder->read($value['id']);
+				$ud['address'] = str_replace("'","’",$ud['address']);
+				$ud['name'] = str_replace("'","’",$ud['name']);
+				$customer = $this->customer->get_email($ud['email'],$value['shop']);
+				$customerb = $this->customer->get_shopdata($ud['name'],$ud['email'],$ud['address'],$value['shop']);
+				//$a = array_column($customer, 'email'); //三维找其中健的数组
+			    //$a = array_flip($a); //键和值调换
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				//$info_list[$key]['user'] = $shop['shopuser'];
+				$warehouse = $this->warehouse->read($value['type']);
+				$warehousetitle = $warehouse['title'];
+				if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
+				$info_list[$key]['type'] = $warehousetitle;
+				$typeclass = $this->typeclass->read($value['state']);
+				$info_list[$key]['state'] = $typeclass['spare'];
+				if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
+				{
+					$info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';
+				}
+				else
+				{
+				    $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']+$dt).'</p><p>'.date('H:i:s',$value['buytime']+$dt).'</p>';
+				}
+				if($value['waybill'] != "")
+				{
+					$info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>";
+				}
+				if($value['express'] != 0)
+				{
+				    $express = $this->express->read($value['express']);
+					$expressservicename = $express['servicename'];
+				if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
+				    $info_list[$key]['express'] = $expressservicename;
+				}
+				else
+				{
+					$info_list[$key]['express'] = "无";
+				}
+				$x = "";
+				if($value['libraryconfirm'] == 2 && $ud['review'] > 4 && $ud['library'] == 1)
+				{
+				    $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
+				}
+				else if(($ud['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
+				{
+					$x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
+				}
+				if(($ud['review'] > 4) && $ud['print'] == 2)
+				{
+				    $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
+				}
+				else if($ud['review'] >4 && $ud['print'] == 1)
+				{
+				    $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
+				}
+				if($value['waybill'] == "" && $ud['review'] > 4)
+				{
+					$x = $x."<p><b class='kn' data-type='2'>填写运单</b></p>";
+				}
+				else if($value['waybill'] != "" && $ud['review'] > 4)
+				{
+					$x = $x."<p><b class='kn' data-type='2'>修改运单</b></p>";
+				}
+				if(($ud['review'] == 1 || $ud['review'] == 3) && $ud['express'] > 0 && $ud['dtsbjz'] != 0 && $ud['ts'] != 0 && $ud['zsbjz'] != 0 && $ud['zjs'] != 0 && $ud['ts'] != 0)
+				{
+					$x = $x."<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
+				}
+				if($value['black'] == 0)
+				{
+					$x = $x."<p><b class='black' data-type='4' data-id='".$value['id']."'>加黑名单</b></p>";
+				}
+				$info_list[$key]['black'] = $x;
+				$tly = "";
+				if($value['clientremarks'] != "")
+				{
+					$tly = "<p style='color:#FF3333'>有客户留言</p>";
+				}
+				
+				$info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
+				
+            }
+			$xx1 = $this->fullorder->find_count("print = 2 and dtime > 1557244800 and state = 207 and type = 5");
+			$xx2 = $this->fullorder->find_count("print = 3 and library = 1 and printtime > '$timetk' and printtime < '$timetj' and type = 5");
+			$xx3 = $this->fullorder->find_count("print = 3 and library = 2 and librarytime > '$timetk' and librarytime < '$timetj' and type = 5");
+			$xx4 = $this->fullorder->find_count("print = 3 and library = 3 and retreattime > '$timetk' and retreattime < '$timetj' and type = 5");
+		    $total = $this->fullorder->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'xx'=>(array('1'=>$xx1,'2'=>$xx2,'3'=>$xx3,'4'=>$xx4)));
+		    echo json_encode($rows);exit;
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$this->data['express'] = $this->express->find_all();
+		$fullorderexcel = $this->fullorderexcel->find_all('type=1','*','idorder desc');//导出模板
+		$this->data['fullorderexcel'] = $fullorderexcel;
+		$error = $this->fullorder->find_count("print = 1 and failed !='' and mergeid = 0 and waybill = '' and type = 5 and (".rtrim($fgshop,'or').")");
+		$this->data['error'] = $error;
+		$this->_Template('ahc_dlz',$this->data);
+	}
+}

+ 283 - 0
core/CoreApp/controllers/Allocation.php

@@ -0,0 +1,283 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Allocation extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_allocation','allocation');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_warehouse','warehouse');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'list')
+        {
+             $this->_list();
+        }
+		else if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$ktime = $this->input->post('ktime',true);
+			$jtime = $this->input->post('jtime',true);
+			$cwarehouse = $this->input->post('cwarehouse',true);
+			$type = $this->input->post('type',true);
+			$order = $this->input->post('order',true);
+			$ktime = strtotime($ktime);
+			$jtime = strtotime($jtime)+24*3600;
+			$where = "1=1 ";
+			if($cwarehouse)
+            {
+                $where  .= " and cwarehouse = '$cwarehouse'";
+            }
+			if($type)
+            {
+                $where  .= " and type = '$type'";
+            }
+			if($order)
+            {
+                $where  .= " and order = '$order'";
+            }
+			if($ktime && $jtime)
+            {
+                $where  .= " and addtime > '$ktime' and addtime < '$jtime'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->allocation->find_all($where,'id,	order,title,cwarehouse,rwarehouse,addtime,name,type',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				if($value['type'] == 1)
+				{
+					$info_list[$key]['type'] = "未调出";
+				}
+				else if($value['type'] == 2)
+				{
+					$info_list[$key]['type'] = "已调出";
+				}
+				else if($value['type'] == 3)
+				{
+					$info_list[$key]['type'] = "已调入";
+				}
+				else if($value['type'] == 4)
+				{
+					$info_list[$key]['type'] = "已结束";
+				}
+				$cwarehouse = $this->warehouse->read($value['cwarehouse']);
+				$info_list[$key]['cwarehouse'] = $cwarehouse['title'];
+				$rwarehouse = $this->warehouse->read($value['rwarehouse']);
+				$info_list[$key]['rwarehouse'] = $rwarehouse['title'];
+				$info_list[$key]['addtime'] = date('Y-m-d',$value['addtime']);
+		    }
+		    $total = $this->allocation->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('allocation',$this->data);
+	}
+	//管理
+	public function _list()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$ktime = $this->input->post('ktime',true);
+			$jtime = $this->input->post('jtime',true);
+			$cwarehouse = $this->input->post('cwarehouse',true);
+			$type = $this->input->post('type',true);
+			$order = $this->input->post('order',true);
+			$ktime = strtotime($ktime);
+			$jtime = strtotime($jtime)+24*3600;
+			$where = "1=1 ";
+			if($cwarehouse)
+            {
+                $where  .= " and cwarehouse = '$cwarehouse'";
+            }
+			if($type)
+            {
+                $where  .= " and type = '$type'";
+            }
+			if($order)
+            {
+                $where  .= " and order = '$order'";
+            }
+			if($ktime && $jtime)
+            {
+                $where  .= " and addtime > '$ktime' and addtime < '$jtime'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->allocation->find_all($where,'id,	order,title,cwarehouse,rwarehouse,addtime,name,type,time',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				if($value['type'] == 1)
+				{
+					$info_list[$key]['type'] = "未调出";
+					$info_list[$key]['time'] = "<p><b class='allocation' data-id='".$value['id']."'>订单已调出</b></p>";
+				}
+				else if($value['type'] == 2)
+				{
+					$info_list[$key]['type'] = "已调出";
+					$info_list[$key]['time'] = "<p><b class='allocation' data-id='".$value['id']."'>订单已调入</b></p>";
+				}
+				else if($value['type'] == 3)
+				{
+					$info_list[$key]['type'] = "已调入";
+					$info_list[$key]['time'] = "<p><b class='allocation' data-id='".$value['id']."'>订单已验收</b></p>";
+				}
+				else if($value['type'] == 4)
+				{
+					$info_list[$key]['type'] = "已结束";
+					$info_list[$key]['time'] = "<p></p>";
+				}
+				$cwarehouse = $this->warehouse->read($value['cwarehouse']);
+				$info_list[$key]['cwarehouse'] = $cwarehouse['title'];
+				$rwarehouse = $this->warehouse->read($value['rwarehouse']);
+				$info_list[$key]['rwarehouse'] = $rwarehouse['title'];
+				$info_list[$key]['addtime'] = date('Y-m-d',$value['addtime']);
+		    }
+		    $total = $this->allocation->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('allocation_list',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['title']))
+		{
+			$post['title'] = $this->input->post('title',true);
+			$post['name'] = $this->input->post('name',true);
+			$time = $this->input->post('time',true);
+			$post['time'] = strtotime($time);
+			$post['cwarehouse'] = $this->input->post('cwarehouse',true);
+			$post['rwarehouse'] = $this->input->post('rwarehouse',true);
+			$post['order'] = date('Ymd',time()).rand(100,999);
+			$user = $this->user->get_api($_SESSION['api']);
+			$post['name'] = $user['name'];
+			$post['type'] = 1;
+			$post['addtime'] = time();
+			if($post['cwarehouse'] == $post['rwarehouse'])
+			{
+				echo json_encode(array('msg'=>'调入仓库和调出仓库不能相同!','success'=>false));exit;
+			}
+			if($this->allocation->insert($post))
+        	{
+				echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		 $class = $this->typeclass->find_all('classid = 200');
+		 $this->data['class'] = $class;
+		$this->_Template('allocation_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$a = $this->allocation->read($id);
+			if($a['type'] == 1)
+			{
+				$type = 2;
+				$z = "已调出";
+				$c = "<b class='allocation' data-id='".$id."'>订单已调入</b>";
+			}
+			else if($a['type'] == 2)
+			{
+				$type = 3;
+				$z = "已调入";
+				$c = "<b class='allocation' data-id='".$id."'>订单已验收</b>";
+			}
+			else if($a['type'] == 3)
+			{
+				$type = 4;
+				$z = "已结束";
+				$c = "";
+			}
+			if($this->allocation->save(array('type'=>$type),$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','z'=>$z,'c'=>$c,'id'=>$id,'success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v)
+		    {
+                $this->allocation->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 347 - 0
core/CoreApp/controllers/Amazonbarcode.php

@@ -0,0 +1,347 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+header("Access-Control-Allow-Origin: *");
+class Amazonbarcode extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->_model('Model_amazonbarcode','amazonbarcode');
+		$this->load->_model('Model_excel','excel');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'addexcel')
+        {
+             $this->_addexcel();
+        }
+		else if($arg == 'print')
+        {
+             $this->_print();
+        }
+		else if($arg == 'see')
+        {
+             $this->_see();
+        }
+		else if($arg == 'edit')
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')
+        {
+             $this->_del();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+	
+	public function _see()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$number = $this->input->post('number',true);
+			$label = $this->input->post('label',true);
+			$print = $this->input->post('print',true);
+			$xztime = $this->input->post('xztime',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "1=1";
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($label)
+            {
+				$where  .= " and label = '$label'";
+            }
+			if($print != '')
+            {
+                $where  .= " and print = '$print'";
+            }
+			if($timetk && $timetj)
+            {
+                $where  .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
+            }
+            //数据排序
+            $order_str = $xztime." desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			$info_list = $this->amazonbarcode->find_all($where,'id,title,number,label,label2,num,time,addtime',$order_str,$start,$perpage);
+            foreach ($info_list as $key=>$value) 
+		    {
+				if($value['time'] != 0)
+				{
+				    $info_list[$key]['time'] = date('Y-m-d H:i',$value['time']);
+				}
+				else
+				{
+					$info_list[$key]['time'] = '';
+				}
+				if($value['addtime'] != 0)
+				{
+				    $info_list[$key]['addtime'] = date('Y-m-d H:i',$value['addtime']);
+				}
+				else
+				{
+					$info_list[$key]['addtime'] = '';
+				}
+				$info_list[$key]['cz'] = "<span class='amazonbarprint' data-id='".$value['id']."' data-num='".$value['num']."'>打印</span>";
+            }
+			$total = $this->amazonbarcode->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('amazonbarcode_see',$this->data);
+	}
+	
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$number = $this->input->post('number',true);
+			$label = $this->input->post('label',true);
+			$print = $this->input->post('print',true);
+			$xztime = $this->input->post('xztime',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "1=1";
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($label)
+            {
+				$where  .= " and label = '$label'";
+            }
+			if($print != '')
+            {
+                $where  .= " and print = '$print'";
+            }
+			if($timetk && $timetj)
+            {
+                $where  .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
+            }
+            //数据排序
+            $order_str = $xztime." desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			$info_list = $this->amazonbarcode->find_all($where,'id,title,number,label,label2,num,time,addtime',$order_str,$start,$perpage);
+            foreach ($info_list as $key=>$value) 
+		    {
+				if($value['time'] != 0)
+				{
+				    $info_list[$key]['time'] = date('Y-m-d H:i',$value['time']);
+				}
+				else
+				{
+					$info_list[$key]['time'] = '';
+				}
+				if($value['addtime'] != 0)
+				{
+				    $info_list[$key]['addtime'] = date('Y-m-d H:i',$value['addtime']);
+				}
+				else
+				{
+					$info_list[$key]['addtime'] = '';
+				}
+            }
+			$total = $this->amazonbarcode->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('amazonbarcode',$this->data);
+	}
+	
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$data = $this->amazonbarcode->read($id);
+			if($data['time'] != 0)
+			{
+				echo json_encode(array('msg'=>'此单已打印,无法修改!','success'=>false));exit;
+			}
+			if($this->amazonbarcode->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$amazonbarcode = $this->amazonbarcode->read($arg_array);
+		$this->data['amazonbarcode'] = $amazonbarcode;
+		$this->_Template('amazonbarcode_edit',$this->data);
+	}
+	
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+				$data = $this->amazonbarcode->read($v);
+				if($data['time'] != 0)
+				{
+					//echo json_encode(array('msg'=>$data['title'].'<br>已打印,无法删除!','success'=>false));exit;
+				}
+                $this->amazonbarcode->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	
+	public function _print()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+			$v = $this->input->post('s');
+			$va = explode(',',rtrim($v,','));
+			$n = $this->input->post('n');
+			$sl = $this->input->post('sl');
+			$text = array();$text['data'] = array();$time = time();
+			$data = $this->amazonbarcode->read($va[$n]);
+			$rows = array('number'=>$data['number'],'label'=>$data['label'],'label2'=>$data['label2'],'num'=>$sl,'data'=>$v,'n'=>$n-1);
+			if($this->amazonbarcode->save(array('print'=>1,'time'=>$time),$data['id']))
+        	{
+         		echo json_encode(array('rows'=>($rows),'success'=>true));exit;
+       	 	}
+       		else
+        	{	
+           		echo json_encode(array('msg'=>'数据写入异常,请重新打印!','success'=>false));exit;
+        	}
+		}
+	}
+	
+	public function _addexcel()
+	{
+		$dir = '/data/excel/'.date('Ymd',time()).'/';
+		$config['upload_path'] = '.'.$dir ;
+		$config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
+        $config['allowed_types'] = 'xls|xlsx|csv';
+        $config['max_size'] = 10240;
+		$this->load->library('upload', $config);
+		$this->upload->initialize($config);
+        if ($this->upload->do_upload('userfile'))
+        {
+			$full_path = $dir.$this->upload->data('file_name');
+			$fileName = '.' . $full_path;
+            if (!file_exists($fileName)) 
+			{
+				echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
+            }
+			else
+			{
+				libxml_use_internal_errors(true);
+				require_once "./data/excel/PHPExcel/IOFactory.php";
+				$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
+				$phpExcel->setActiveSheetIndex(0);// 设置为默认表
+				$sheetCount = $phpExcel->getSheetCount();// 获取表格数量
+				$row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
+				$column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
+				++$column;//如果列数大于26行
+				$list = array();
+				for ($i = 3; $i <= $row; $i++) // 行数循环
+				{
+					$data = array();
+                    for ($c = 'A'; $c != $column; $c++)  // 列数循环
+	                {
+						$data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
+                    }
+					$list[] = $data;
+                }
+			}
+			$i = 0;$j = 0;$ed = array();$time = time();
+		    foreach ($list as $key=>$value)
+		    {
+				$time = time();
+				if($value['0'] == "")
+				{
+					continue;
+				}
+				$post['title'] =  $value['0'];
+				$post['number'] =  $value['1'];
+				$post['label'] =  ($value['2'])?$value['2']:'';
+				$post['label2'] =  ($value['3'])?$value['3']:'';
+				$post['num'] =  $value['4'];
+				$post['addtime'] =  $time;
+				if(!is_numeric($post['num']))
+				{
+					$ed[] = array($key.' 行,非数字!');
+					$j++;
+					continue;
+				}
+				if($post['num'] < 1)
+				{
+					$ed[] = array($key.' 行,数量错误!');
+					$j++;
+					continue;
+				}
+				$this->amazonbarcode->insert($post);
+			}
+			if($j > 0)
+			{
+				$tt = date('Ymd',time());
+				$title = '库存导入错误信息-'.$tt;
+        		$titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
+				$tail = "\n";
+        		$filename = $title.".xls";
+        		$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
+				$dir = '/data/excel/'.$time.'/';
+				$file_name = 'error_'.$time.rand(1000,9999);
+				if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
+				$myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
+				fwrite($myfile,$ecl);
+				fclose($myfile);
+				$error = $dir.$file_name.'.xls';
+				echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
+			}
+		}
+	}
+}

Diff do ficheiro suprimidas por serem muito extensas
+ 2127 - 0
core/CoreApp/controllers/Api.php


Diff do ficheiro suprimidas por serem muito extensas
+ 745 - 0
core/CoreApp/controllers/Apismt.php


Diff do ficheiro suprimidas por serem muito extensas
+ 680 - 0
core/CoreApp/controllers/Apismt_old.php


+ 973 - 0
core/CoreApp/controllers/Apitt.php

@@ -0,0 +1,973 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Apitt extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_api','api');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_hl','hl');
+		$this->load->_model('Model_is','is');
+		$this->load->_model('Model_kdniao','kdniao');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_fullorderexcel','fullorderexcel');
+		$this->load->_model('Model_dhl','dhl');
+		$this->load->_model('Model_usps','usps');
+		$this->load->_model('Model_ups','ups');
+		$this->load->_model('Model_dhltest','dhltest');
+		$this->load->_model('Model_customer','customer');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_notice','notice');
+		$this->load->_model('Model_emaildata','emaildata');
+		$this->load->_model('Model_whlabel','whlabel');
+		$this->load->_model('Model_productdescribe','productdescribe');
+		$this->load->_model('Model_ljg','ljg');
+		$this->load->_model('Model_commodityread','commodityread');
+		$this->load->_model('Model_service','service');
+		$this->load->_model('Model_fedex','fedex');
+		$this->load->_model('Model_apismt','apismt');
+		$this->load->_model('Model_cne','cne');
+		$this->load->_model('Model_specialstock','specialstock');
+		$this->load->_model('Model_whlabellabel','whlabellabel');
+		$this->load->_model('Model_allocation','allocation');
+		$this->load->_model('Model_yswaybill','yswaybill');
+		$this->load->_model('Model_paypal','paypal');
+		$this->load->_model('Model_17track','17track');
+		$this->load->_model('Model_ck','ck');
+		$this->load->_model('Model_weight','weight');
+		$this->load->_model('Model_pay','pay');
+		$this->load->_model('Model_setting','setting');
+		$this->load->_model('Model_classid','classid');
+		$this->load->_model('Model_apitt','apitt');
+		$this->load->_model('Model_customertt','customertt');
+		$this->load->_model('Model_als','als');
+		$this->load->_model('Model_apiyy','apiyy');
+		$this->load->_model('Model_whlabel_fc','whlabel_fc');
+		$this->load->_model('Model_shopsku','shopsku');
+		$this->load->_model('Model_notice','notice');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'sq')
+        {
+             $this->_sq();
+        }
+		else if($arg == 'token')
+        {
+             $this->_token();
+        }
+		else if($arg == 'tb')
+        {
+             $this->_tb();
+        }
+		else if($arg == 'webhook')
+        {
+             $this->_webhook();
+        }
+		else if($arg == 'cs')
+        {
+             $this->_cs();
+        }
+		else if($arg == 'csa')
+        {
+             $this->_csa();
+        }
+    }
+	
+	public function get_list($shop,$from,$to,$order_status,$cuy,$num,$dtc,$money,$int,$dtctitle,$pay,$typeclass,$ex,$sjc)//获取订单列表
+	{
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/order/202309/orders/search';
+		$time = time();
+		$post['create_time_ge'] = $from;
+		$post['create_time_lt'] = $to;
+		$post['order_status'] = $order_status;
+		$queryParams['page_size'] = 100;
+		$queryParams['sort_order'] = 'DESC';
+		$queryParams['sort_field'] = 'create_time';
+		$queryParams['shop_cipher'] =$shop['shop_cipher'];
+		$queryParams['shop_id'] =$shop['codeid'];
+		$queryParams['app_key'] =$shop['app_key'];
+		$queryParams['timestamp'] =$time;
+		$link .= '?'.http_build_query($queryParams);
+		$sign = $this->apitt->sign($link,$shop['app_secret'],$post);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('Content-Type: application/json','x-tts-access-token:'.$shop['token']);
+		$res = $this->apitt->su_curl($post,$url,$headers);
+		$res = json_decode($res,true);
+		$list = array();$page_token = '';$arr = array();
+		if(isset($res['data']['orders']))
+		{
+			if($res['data']['total_count'] > 100)
+			{
+				$n = ceil($res['data']['total_count']/100);
+				for($i=0;$i<$n;$i++)
+				{
+					$net_date = $this->get_next_list($shop,$from,$to,$order_status,$page_token);
+					$page_token = $net_date[1];
+					foreach ($net_date['0'] as $val) 
+		        	{
+						$d = $this->fullordertt->get_orderinfo($val['id']);
+				    	if(!$d)
+				    	{
+							$list[] = $val['id'];
+						}
+					}
+				}
+			}
+			else
+			{
+			    foreach ($res['data']['orders'] as $val) 
+		        {
+				    $d = $this->fullordertt->get_orderinfo($val['id']);
+				    if(!$d)
+				    {
+					    $list[] = $val['id'];
+				    }
+			    }
+			}
+			$cs = array();
+			if(count($list) > 50)
+			{
+				$n = ceil(count($list)/50);$x = 0;
+				for($i=0;$i<$n;$i++)
+				{
+					$k = ($i<1)?0:$i*50;
+					$data = array_slice($list,$k,50);
+					$d = $this->get_data($data,$shop);
+					$cs[] = $d;
+					if(isset($d['data']))
+		            {
+					    foreach ($d['data']['orders'] as $val) 
+		                {
+						    $arr[$x] = $val;
+							$x++;
+					    }
+					}
+				}
+			}
+			else
+			{
+				$d = $this->get_data($list,$shop);
+				if(isset($d['data']))
+		        {
+					 foreach ($d['data']['orders'] as $val) 
+		             {
+						 $arr[] = $val;
+					 }
+				}
+			}
+		}
+		$read = array();
+		$gnum = array();
+		foreach ($arr as $val) 
+		{
+			$create_time = substr($val['create_time'],0,10)-$sjc;
+			if(isset($gnum[date('ymd',$create_time)]))
+			{
+				$gnum[date('ymd',$create_time)] += 1;
+			}
+			else
+			{
+				$num = $this->fullordertt->find_count('gtime = "'.date('Ymd',$create_time).'" and shop = "'.$shop['id'].'"');
+				$gnum[date('ymd',$create_time)] = $num+1;
+			}
+			$read[] = $this->get_read($val,$time,$shop,$cuy,$gnum[date('ymd',$create_time)],$dtc,$money,$int,$dtctitle,$pay,$typeclass,$ex,$sjc);
+		}
+		return array($read,$list);
+	}
+	
+	public function get_next_list($shop,$from,$to,$order_status,$page_token='')//获取订单列表
+	{
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/order/202309/orders/search';
+		$time = time();
+		$post['create_time_ge'] = $from;
+		$post['create_time_lt'] = $to;
+		$post['order_status'] = $order_status;
+		$queryParams['page_size'] = 100;
+		$queryParams['sort_order'] = 'DESC';
+		$queryParams['sort_field'] = 'create_time';
+		$queryParams['shop_cipher'] =$shop['shop_cipher'];
+		$queryParams['shop_id'] =$shop['codeid'];
+		$queryParams['app_key'] =$shop['app_key'];
+		$queryParams['timestamp'] =$time;
+		if($page_token)
+		{
+		    $queryParams['page_token'] = $page_token;
+		}
+		$link .= '?'.http_build_query($queryParams);
+		$sign = $this->apitt->sign($link,$shop['app_secret'],$post);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('Content-Type: application/json','x-tts-access-token:'.$shop['token']);
+		$res = $this->apitt->su_curl($post,$url,$headers);
+		$res = json_decode($res,true);
+		if(isset($res['data']['orders']))
+		{
+			return array($res['data']['orders'],$res['data']['next_page_token']);
+		}
+	}
+	
+	public function get_data($list,$shop)
+	{
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/order/202309/orders';
+		$time = time();
+		$ids = implode(",",$list);
+		$link .= '?shop_cipher='.$shop['shop_cipher'].'&app_key='.$shop['app_key'].'&timestamp='.$time.'&ids='.$ids;
+		$sign = $this->apitt->sign($link,$shop['app_secret'],'');
+		$url .= $link.'&sign='.$sign;
+		$headers = array('Content-Type: application/json','x-tts-access-token:'.$shop['token']);
+		$res = $this->apitt->su_curl('',$url,$headers,$date_type='json',$timeout=300,$httptype="GET");
+		$res = json_decode($res,true);
+		return $res;
+	}
+	
+	
+	
+	
+	
+	
+
+	public function _csa()
+	{
+		
+		$data = $this->fullordertt->get_orderinfo(576607595986915436);
+		$shop = $this->shop->read($data['shop']);
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/order/202309/orders';
+		$time = time();
+		$link .= '?shop_cipher='.$shop['shop_cipher'].'&app_key='.$shop['app_key'].'&timestamp='.$time.'&ids='.$data['orderinfo'];
+		$sign = $this->apitt->sign($link,$shop['token'],$shop['app_secret']);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('x-tts-access-token:'.$shop['token']);
+		$res = $this->api->su_curl('',$url,$headers,$date_type='json',$timeout=300,$httptype="GET",$userpwd='');
+		$res = json_decode($res,true);
+		echo "<pre>";
+		print_r($res);
+		exit;
+
+		
+		
+		$data = $this->fullordertt->get_orderinfo(576607595986915436);
+		$shop = $this->shop->read($data['shop']);
+		$list = array($data['orderinfo']);
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/api/orders/detail/query';
+		$time = time();
+		$post = array();
+		$post['order_id_list'] = json_encode($list);
+		$sign = $link.'app_key'.$shop['app_key'].'timestamp'.$time;
+		$sign = $shop['app_secret'].$sign.$shop['app_secret'];
+		$sign = hash_hmac('sha256', $sign, $shop['app_secret']);
+		$url .= $link.'?access_token='.$shop['token'].'&app_key='.$shop['app_key'].'&sign='.$sign.'&timestamp='.$time;
+		$ch = curl_init();
+		curl_setopt($ch, CURLOPT_URL,$url);
+		curl_setopt($ch, CURLOPT_POST, 1);
+		curl_setopt($ch, CURLOPT_HEADER, 0);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+		curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
+		curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+		$res = curl_exec($ch);
+		curl_close($ch);
+		$res = json_decode($res,true);
+		echo "<pre>";
+		print_r($res);
+		
+	}
+	
+
+
+	
+	public function _sq()
+	{
+		//授权获取app_key和code用于下一步获取token
+		$post = $this->input->get(NULL, TRUE);
+		if(isset($post['app_key']))
+		{
+		    $app_key = $this->input->get('app_key',true);
+			$code = $this->input->get('code',true);
+			if($code && $app_key)
+			{
+				$shop = $this->shop->app_key($app_key);
+				if($shop)
+				{
+				    $url = 'https://auth.tiktok-shops.com/api/v2/token/get?app_key='.$app_key.'&auth_code='.$code.'&app_secret='.$shop['app_secret'].'&grant_type=authorized_code';
+				    $ch = curl_init();
+       		        curl_setopt($ch, CURLOPT_URL,$url);//?status=any所有订单 &limit=200每页多少单
+       		        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
+       		        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
+       		        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+       		        $res = curl_exec($ch);
+       		        curl_close($ch);
+       		        $res = json_decode($res,true);
+				    if(isset($res['data']))
+				    {
+						$shop_cipher = '';
+						$shopcipher = $this->_shop_cipher($shop);
+						if(isset($shopcipher['data']['shops'][0]['cipher']))
+						{
+							$shop_cipher = $shopcipher['data']['shops'][0]['cipher'];
+						}
+					    $this->shop->save(array('token'=>$res['data']['access_token'],'tokentime'=>$res['data']['access_token_expire_in']-48*3600,'refresh_token'=>$res['data']['refresh_token'],'app_key'=>$app_key,'code'=>$code,'shop_cipher'=>$shop_cipher),$shop['id']);
+					    echo 'ok';
+						echo "<pre>";
+						print_r($res);
+				    }
+					else
+					{
+						echo json_encode($res);
+					}
+				}
+				else
+				{
+					echo "没有此店铺";
+				}
+			}
+		}
+				
+	}
+	
+	public function _token()//判断tokentime通过refresh_token刷新token
+	{
+		$shop = $this->shop->find_all("type = '1514'");//找TT店铺
+		foreach ($shop as $v) 
+		{
+			if($v['tokentime'] < time()+30*24*3600)
+			{
+				$url = 'https://auth.tiktok-shops.com/api/v2/token/refresh?app_key='.$v['app_key'].'&app_secret='.$v['app_secret'].'&grant_type=refresh_token&refresh_token='.$v['refresh_token'];
+		   	    $ch = curl_init();
+           	    curl_setopt($ch, CURLOPT_URL,$url);
+           	    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
+           	    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
+           	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+           	    $res = curl_exec($ch);
+           	    curl_close($ch);
+           	    $res = json_decode($res,true);
+		   	    if(isset($res['data']))
+		   	    {
+					$shop_cipher = '';
+					$shopcipher = $this->_shop_cipher($v);
+					if(isset($shopcipher['data']['shops'][0]['cipher']))
+					{
+						$shop_cipher = $shopcipher['data']['shops'][0]['cipher'];
+					}
+			   	    $this->shop->save(array('token'=>$res['data']['access_token'],'tokentime'=>$res['data']['access_token_expire_in']-48*3600,'refresh_token'=>$res['data']['refresh_token'],'shop_cipher'=>$shop_cipher),$v['id']);
+		   	    }
+				else
+				{
+					echo json_encode($res);
+					exit;
+				}
+			}	
+		}	
+		echo "ok";
+	}
+	
+	public function _shop_cipher($shop,$x=0)
+	{
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/authorization/202309/shops';
+		$time = time();$post = array();
+		$queryParams = array();
+		$queryParams['access_token'] = $shop['token'];
+		$queryParams['app_key'] = $shop['app_key'];
+		$queryParams['shop_id'] = $shop['codeid'];
+		$queryParams['timestamp'] = $time;
+		$queryParams['version'] = '202309';
+		$link .= '?'.http_build_query($queryParams);
+		$sign = $this->apitt->sign($link,$shop['app_secret'],$post);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('Content-Type: application/json','x-tts-access-token:'.$shop['token']);
+		$ch = curl_init();
+		curl_setopt($ch, CURLOPT_URL, $url);
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
+		curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
+		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+		$res = curl_exec($ch);
+		curl_close($ch);
+		$res = json_decode($res,true);
+		if(isset($res['data']['shops'][0]['cipher']) || $x == 5)
+		{
+			return $res;
+		}
+		else
+		{
+			$this->_shop_cipher($shop,1);
+		}
+	}
+	
+	public function _tb()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		$api = $this->input->get('api',true);
+		$dshop = $this->input->get('dshop',true);
+		$gethl = array();
+		/*  匹配加入  */
+		$dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32 and classid != 36');
+		// and (classid=13 or classid=22 or classid=8 or classid=15 or classid=27 or classid=25 or classid=26 or classid=18 or classid=14 or classid=9 or classid=12 or classid=10 or classid=6 or classid=100 or classid=999)
+		$dtc = array();
+		foreach ($dictionaries as $v) 
+		{
+			if(stripos($v['spare'],'|') !== false)//如果有多个值
+			{
+				$v['spare'] = explode('|',$v['spare']);
+				foreach ($v['spare'] as $k=>$vs) 
+		        {
+					if(stripos($v['zh'],'|') !== false)
+					{
+						$vzh = explode('|',$v['zh']);
+						$dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id']);
+					}
+					else
+					{
+					    $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
+					}
+				}
+			}
+			else
+			{
+				$dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
+			}
+			
+		}
+		$dictionaries2 = $this->typeclass->find_all();
+		foreach ($dictionaries2 as $v)
+		{
+			$dtctitle[$v['id']] = $v['title'];
+		}
+		/*  匹配结束  */    
+		/*  价格加入  */  
+		$money = array();
+		/**
+		$productdescribe = $this->productdescribe->find_all('1=1','number,purchase,cost,salesprice,title');
+		foreach ($productdescribe as $v) 
+		{
+			$money[$v['number']] = array('purchase'=>$v['purchase'],'cost'=>$v['cost'],'salesprice'=>$v['salesprice'],'title'=>$v['title']);
+		}
+		**/
+		/*  价格加入  */
+		/*  匹配ID加入  */
+		$int = array();
+		$intdata = $this->typeclass->find_all('classid=14','id,spare');
+		foreach ($intdata as $v) 
+		{
+			$v['spare'] = explode('|',$v['spare']);
+			$int[$v['id']] = $v['spare'][0];
+		}
+		/*  匹配ID结束  */
+		/*  国家加入键值-k  */
+		$cuy = array();
+		$cuydata = $this->country->find_all('1=1','lb,id');
+		foreach ($cuydata as $v) 
+		{
+			$cuy[$v['lb']] = $v['id'];//获取到国家ID
+		}
+		/*  国家加入键值-j  */
+		$typeclass = array();
+		$tdata = $this->typeclass->find_all('classid=30','id,title');
+		foreach ($tdata as $v) 
+		{
+			$typeclass[$v['title']] = $v['id'];
+		}
+		$ex = array();
+		$express = $this->express->find_all('1=1','id,title');
+		foreach ($express as $v) 
+		{
+			$ex[$v['title']] = array('id'=>$v['id']);
+		}
+		/*  币种加入键值-j  */
+		/*  支付方式-k  */
+		$pay = array();$sd = array();
+		$tdata = $this->typeclass->find_all('classid=4','id,spare');
+		foreach ($tdata as $v) 
+		{
+			$paytype = $this->pay->get_typeclass($v['id']);
+			if(isset($paytype['estimaterate']))
+			{
+				$estimaterate = $paytype['estimaterate'];
+			}
+			else
+			{
+				$estimaterate = 0;
+			}
+			if(stripos($v['spare'],'|') !== false)//如果有多个值
+			{
+				$v['spare'] = explode('|',$v['spare']);
+				foreach ($v['spare'] as $k=>$vs) 
+		        {
+					$pay[$vs] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
+				}
+			}
+			else
+			{
+				$pay[$v['spare']] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
+			}
+		}
+		/*  支付方式-j  */
+		/*  新增SKU-k  */
+		$zjsku = array();
+		$shopsku = $this->shopsku->find_all();
+		foreach ($shopsku as $val) 
+		{
+			$ss = explode(',',trim($val['shop'],','));
+			foreach ($ss as $v) 
+			{
+				if(isset($zjsku[$v]))
+				{
+					$zjsku[$v] .= ','.trim($val['sku'],',');
+				}
+				else
+				{
+					$zjsku[$v] = trim($val['sku'],',');
+				}
+			}
+		}	
+		/*  新增SKU-j  */
+		$time = time();
+		$tb = 0;
+		if($api = '89757')  
+		{
+			$shop = $this->shop->find_all("type = '1514' and tb = '1'");//TT店铺
+			foreach ($shop as $value) 
+		    {
+				if((time()-$value['tbtime']) < 1)
+				{
+					$tb = 1;//正在同步中
+					break;
+				}
+				$setting = $this->setting->get_settings();
+				$sjc = 15*3600+$setting['sctime'];//时间差
+				$num = $this->fullordertt->find_count('gtime = "'.date('Ymd',$time).'" and shop = "'.$value['id'].'"');
+				//$this->db->trans_begin();
+				$res = $this->apitt->get_list($value,$time-2*24*3600,$time,'AWAITING_SHIPMENT',$cuy,$num,$dtc,$money,$int,$dtctitle,$pay,$typeclass,$ex,$sjc,$zjsku);//查询2小时数 据-等待装运=AWAITING_SHIPMENT(111) ;-等待收集=AWAITING_COLLECTION (112);在途=IN_TRANSIT (121);-已交付=DELIVERED (122);
+				$sd[] = $res;
+				$res = $res[0];
+				if($res)
+				{
+					foreach ($res as $v) 
+		        	{
+						$post = $v;
+						$dataorder = $this->fullordertt->get_orderinfo($v['orderinfo']);
+						if(!isset($dataorder['id']))
+						{
+							/** 启用自动分配仓库 **/
+							$warehouse = $this->warehouse->find_all("fpzd = '1'",'*','fpsx desc');
+							if($post['cf'] == 1)
+							{
+								$post['type'] = 34;//TT仓
+							}
+							else
+							{
+							    foreach ($warehouse as $v) 
+		        	            {
+								    if($v['bdcountry'] != 0 && $v['bdcountry'] != $post['country'])
+								    {
+									    continue;
+								    }
+								    $yx = 'get_yx_'.$v['bdck'];
+								    $kczd = $this->ck->$yx($post['state'],$v,$post['shop'],$post['number'],$post['whlabel'],$post['fpdata']);
+								    if($kczd['t'] == 0)
+								    {
+									    $country = $this->country->read($post['country']);//获取国家中配置物流
+									    if($country['express'] != 0)
+									    {
+									    	$post['express'] = $country['express'];
+									    }
+									    if($v['express'] != 0)//优先使用仓库指定物流,替换掉上面的国家配置物流
+									    {
+									    	$post['express'] = $v['express'];
+									    }
+									    $post['type'] = $v['id'];
+									    $post['whlabel'] = $kczd['whlabel'];
+									    $post['fpdata'] = $kczd['fpdata'];
+									    if(stripos($kczd['whlabel'],$v['hz']) !== false)
+									    {
+									        break 1;
+									    }
+								    }
+							    }
+							    $qdw = $this->warehouse->read($post['type']);
+							    $fl = $this->ck->get_fl($qdw['hz'],$post['whlabel'],$post['fpdata']);
+							    $post['sfxh'] = $fl['sfxh'];
+							    $post['ckfl'] = $fl['ckfl'];
+							    //自动写位置 开始
+							   $zclp = array();$pxsl = array();
+							   $slpx = explode('|',$post['slpx']);//排序
+							   foreach ($slpx as $k=>$v) 
+							   {
+								   $v = explode('-',$v);
+								   if(!isset($v[1]))
+								   {
+									   $v[1] == 1;
+								   }
+								   for($i=$v[0];$i<$v[1];$i++)
+								   {
+			    					   $pxsl[$i] = $k;
+								   }
+							   }
+							   $mc = $qdw['bdck'];$zdidjl = '';$zdwzjl = '';
+							   if($qdw['wz'] == 1)
+							   {
+								   $pm = explode(';',trim($post['shipremarks'],';'));
+								   foreach ($pm as $k=>$vv) 
+		        				   {
+									   $vv = trim($vv,' ');
+									   $lp = $this->typeclass->find_all("zh = '$vv'");
+									   if(isset($lp[0]['classid']))
+									   {
+										   $zclp[] = $vv;
+										   unset($pm[$k]);
+									   }
+								   }
+								   $pm = array_values($pm);
+								   $w = explode('|',trim($post['whlabel'],'|'));
+								   foreach ($w as $k=>$val) 
+		        	    		   {
+									   $hwm = '';
+									   if(stripos($val,$qdw['hz']) !== false)
+									   {
+										   $num = explode('-',trim($val,'-'));
+										   $xq = explode('~',trim($num[2],'~'));
+										   $pmxq = '(';
+										   foreach ($xq as $v) 
+		        	           			   {
+											   $zdidjl .= '('.trim($v,$qdw['hz']).')';
+											   $h = $this->$mc->read(trim($v,$qdw['hz']));
+											   if($h['details'] != '')
+											   {
+									               $pmxq .= $qdw['title'].':'.$h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'').',';
+											   }
+								           }
+										   $xrid = ($h['cpid']>0)?'-'.$h['cpid']:'';
+										   if(isset($pxsl[$k]))
+										   {
+											   if(stripos($pm[$pxsl[$k]],$qdw['title'].':'.$h['details'].$xrid) === false)
+											   {
+												   $pm[$pxsl[$k]] .= trim($pmxq,',').')';
+											   }
+										   }
+										   $zdwzjl .= $h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'');
+							           }
+						           }
+								   if($zclp)
+								   {
+									   $zclp = ';'.implode(";",$zclp);
+								   }
+								   else
+								   {
+									   $zclp = '';
+								   }
+								   $post['shipremarks'] = implode(";",$pm).$zclp;
+								   $post['contents'] = $zdidjl.' - '.$zdwzjl;
+					           }
+							}
+							//自动写位置 结束
+							/** **/
+							//合并重复项
+							$hbcfw = explode('|',trim($post['whlabel'],'|'));
+							$hbcff = explode(';',trim($post['fpdata'],';'));
+							$c = 0;
+							$hbw = array();
+							$hbf = array();
+							for($i=0;$i<count($hbcfw);$i++)
+							{
+								$w = explode('-',$hbcfw[$i]);
+								$f = explode('|',$hbcff[$i]);
+								$w2 = ($w[2]==0)?0:'';
+								if(!isset($hbw[$w[0].$w2]))
+								{
+									$hbw[$w[0].$w2] = $hbcfw[$i];
+									$hbf[$w[0].$w2] = $hbcff[$i];
+								}
+								else
+								{
+									$c++;
+									$cw = explode('-',$hbw[$w[0].$w2]);
+									$cf = explode('|',$hbf[$w[0].$w2]);
+									if($cw[2] != 0 && $w[2] != 0)
+									{
+										$cf[2] += $f[2];
+										$cf[9] .= '~'.$f[9];
+									    $hbf[$w[0].$w2] = implode("|",$cf);
+									    $cw[1] += $f[2];
+										$cw[2] .= '~'.$f[9];
+									    $hbw[$w[0].$w2] = implode("-",$cw);
+									}
+									else if($cw[2] == 0 && $w[2] == 0)
+									{
+									    $cf[2] += $f[2];
+									    $hbf[$w[0].$w2] = implode("|",$cf);
+									    $cw[1] += $f[2];
+									    $hbw[$w[0].$w2] = implode("-",$cw);
+									}
+									else
+									{
+										$hbw[] = $hbcfw[$i];
+									    $hbf[] = $hbcff[$i];
+									}
+								}
+							}
+							if($c > 0)
+							{
+								$post['fpdata'] = implode(";",$hbf).';';
+								$post['whlabel'] = '|'.implode("|",$hbw).'|';
+							}
+							//合并重复项结束
+							//非占单设置为禁止占单开始
+							$hbw = explode('|',trim($post['whlabel'],'|'));
+							$hbf = explode(';',trim($post['fpdata'],';'));
+							foreach ($hbw as $k=>$val) 
+		        	    	{
+								$w = explode('-',$val);
+								$f = explode('|',$hbf[$k]);
+								if(!isset($w[2]) || $w[2] == 0)
+								{
+									$w[2] = "DNOTO";
+								    $f[9] = "DNOTO";
+								    $hbf[$k] =  implode("|",$f);
+								    $hbw[$k] = implode("-",$w);
+								}
+							}
+							$post['fpdata'] = implode(";",$hbf).';';
+							$post['whlabel'] = '|'.implode("|",$hbw).'|';
+							//非占单设置为禁止占单结束
+							//查询净重开始
+							$post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
+							//查询净重结束
+			   		   		$tjid = $this->fullordertt->insert($post);
+							if($post['email'] == '')
+							{
+								$post['email'] = $post['name'].'@qq.com';
+							}
+							$adrs = $this->customertt->get_email($post['email'],$post['shop']);
+							preg_match_all('/[0-9]/u',$post['phone'],$result);
+				            $numphone = join('',$result[0]);
+							$hmdaddress1 = str_replace(array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),strtolower($post['address']));
+			                $hmdaddress2 = str_replace(array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),strtolower($post['address']));
+			                $hmdaddress3 = str_replace(array(' avenue',' ave',' av'),array(' ave',' avenue',' ave'),strtolower($post['address']));
+							$hmdid = '';
+							$post['address'] = str_replace("'","&#8217;",$post['address']);
+							$hmdaddress1 = str_replace("'","&#8217;",$hmdaddress1);
+							$hmdaddress2 = str_replace("'","&#8217;",$hmdaddress2);
+							$customerb = $this->customertt->find_all('type = 2 and (email = "'.$post['email'].'" or address = "'.$post['address'].'" or address = "'.$hmdaddress1.'" or address = "'.$hmdaddress2.'" or address = "'.$hmdaddress3.'" or numphone = "'.$numphone.'")','*','id desc');
+							$lkh = (isset($customerb[0]['id']))?2:1;//白名单1黑名单2
+							if($lkh == 2)
+							{
+								$hmdid = $customerb[0]['id'].'-('.$post['email'].'|'.$post['address'].'|'.$numphone.')'.'('.$customerb[0]['email'].'|'.$customerb[0]['address'].$customerb[0]['numphone'].')';
+							}
+							if($adrs)
+							{
+								$pdlkh = 1;//这个是判断是否老客户
+								$this->customertt->save(array('time'=>$post['dtime'],'num'=>$adrs['num']+1,'money'=>$adrs['money']+$post['shouldmoney']),$adrs['id']);
+								$khid = $adrs['id'];
+							}
+							else
+							{
+								$str = $post['phone'];
+								preg_match_all('/[0-9]/u',$str,$result);
+								$numphone = join('',$result[0]);
+								$ct['shop'] = $post['shop'];
+								$ct['source'] = 9;
+								$ct['level'] = 5;
+								$ct['country'] = $post['country'];
+								$ct['time'] = $post['dtime'];
+								$ct['num'] = 1;
+								$ct['money'] = $post['shouldmoney'];
+								$ct['zipcode'] = $post['zipcode'];
+								$ct['name'] = $post['name'];
+								$ct['phone'] = $post['phone'];
+								$ct['numphone'] = $numphone;
+								$ct['email'] = preg_replace('/( | | |\s)+/','',$post['email']);
+								$ct['province'] = $post['province'];
+								$ct['city'] = $post['city'];
+								$ct['address'] = $post['address'];
+								$ct['zhcx'] = $post['shop'].'-'.$ct['email'];
+			     				$khid = $this->customertt->insert($ct);
+								$pdlkh = 0;
+							}
+							if($post['cf'] != 1)
+							{
+							    $this->_znxc($post,$post['orderinfo'],1);
+							}
+						}//else{}如果有此订单
+					}
+				}
+				/**
+				if ($this->db->trans_status() === FALSE)
+                {
+				    $this->db->trans_commit();
+                }
+                else
+                {
+                    $this->db->trans_commit();
+                }
+				**/
+				//sleep(1);//停留2秒
+				$this->shop->save(array('tbtime'=>time()),$value['id']);
+			}
+			if($tb == 1)
+			{
+				echo json_encode(array('msg'=>'有店铺正在同步中,请5分钟后再试!','success'=>true));exit;
+			}
+			//echo json_encode(array('msg'=>'OK!','success'=>true));exit;
+			echo "<pre>";
+			print_r($sd);
+		}
+	}
+	
+	public function _znxc($fullorder,$order_id,$type)
+	{
+		$time = time();
+		$fid = $this->fullordertt->get_orderinfo($order_id);
+		if($type == 1)//地址确认需要状态对应
+		{
+			$notice = $this->notice->find_all("shop = '".$fullorder['shop']."' and ordertatus = '".$fullorder['state']."' and tab = '0' and message = '3' and state = '1' and ktime < '$time' and jtime > '$time' and type = '$type'");//有条件不同模板匹配
+		}
+		else if($type == 4)//物流发送
+		{
+			$notice = $this->notice->find_all("shop = '".$fullorder['shop']."' and message = '3' and state = '1' and ktime < '$time' and jtime > '$time' and type = '$type'");//有条件不同模板匹配
+		}
+		if(isset($notice[0]['content']))
+		{
+			$shop = $this->shop->read($fullorder['shop']);
+			 $country = $this->country->read($fullorder['country']);
+			 $fullorder['country'] = $country['ename'];
+			 $express = array();
+			    $go = $this->notice->get_god($fullorder,$shop,$express,$notice[0]);
+			    if($go == 1)
+			    {
+				    $this->fullordertt->save(array('content'=>$fid['content'].'自动发送-成功;','zdstate'=>$fid['zdstate'].$notice[0]['type'].'-'.$notice[0]['tab'].'|','exstateerror'=>''),$fid['id']);
+					return 1;
+			    }
+			    else
+			    {
+				    $this->fullordertt->save(array('exstateerror'=>'自动发送失败1:'.date('Y-m-d H',time()).'-'.$go.'('.$notice[0]['type'].'-'.$notice[0]['message'].')'),$fid['id']);
+			    }
+		    }
+			else
+			{
+				$this->fullordertt->save(array('exstateerror'=>'当前订单状态无匹配模板'),$fid['id']);
+			}
+	}
+	
+	public function _webhook()
+	{
+		$j = '';
+		$xq = array();
+		$j = file_get_contents('PHP://input');
+		$j = json_decode($j, true);
+		if(isset($j['type']) && isset($j['data']['order_id']))
+		{
+			$d = $this->fullordertt->get_orderinfo($j['data']['order_id']);
+			if($d)
+			{
+				$qchz = array();
+				$f = explode('|',trim($d['whlabel'],'|'));
+				foreach ($f as $v) 
+		        {
+					$hz = explode('-',trim($v,'-'));
+					if(isset($hz[2]) && $hz[2] != 'DNOTO' && $hz[2] != '0')
+					{
+						$qchz[] = $hz[2];
+					}
+				}
+				$d['whlabel']= str_replace($qchz,'0',$d['whlabel']);
+				$d['fpdata']= str_replace($qchz,'0',$d['fpdata']);
+				$this->db->trans_begin();
+				if($j['type'] == 1)
+				{
+					if($j['data']['order_status'] == 'CANCEL' || $j['data']['order_status'] == 'Canceled')
+					{
+						$whlabel = $this->whlabel->find_all("zd = '".$d['number']."'");
+						foreach ($whlabel as $v) 
+		       		    {
+							$this->whlabel->save(array('zd'=>''),$v['id']);
+						}
+						$this->fullordertt->save(array('state'=>217,'whlabel'=>$d['whlabel'],'fpdata'=>$d['fpdata']),$d['id']);
+					}
+					else if(($j['data']['order_status'] == 'IN_TRANSIT' || $j['data']['order_status'] == 'DELIVERED' || $j['data']['order_status'] == 'COMPLETED currently)') && $d['state'] != 216)
+					{
+						if($d['cf'] == 1 && $d['type'] == 34 && $j['data']['order_status'] == 'IN_TRANSIT')
+						{
+							$shop = $this->shop->read($d['shop']);
+							$wb = $this->apitt->get_data(array($d['orderinfo']),$shop);
+							$waybill = $wb['data']['orders']['0']['tracking_number'];
+							$ex = $wb['data']['orders']['0']['shipping_provider'];
+							$express = 0;
+							if(stripos("UPS",$ex) !== false)
+							{
+								$express = 3;
+							}
+							else if(stripos("DHL",$ex) !== false)
+							{
+								$express = 1;
+							}
+							else if(stripos("FEDEX",$ex) !== false)
+							{
+								$express = 24;
+							}
+							else if(stripos("USPS",$ex) !== false)
+							{
+								$express = 2;
+							}
+							$time = time();
+							$this->fullordertt->save(array('state'=>216,'fpdata'=>$d['fpdata'],'waybill'=>$waybill,'print'=>3,'printtime'=>$time,'printnumber'=>1,'libraryconfirm'=>2,'library'=>2,'librarytime'=>$time,'weight'=>'0.4kg','review'=>6,'reviewtime'=>$time,'express'=>$express),$d['id']);
+						}
+						else
+						{
+						    $this->fullordertt->save(array('state'=>216,'whlabel'=>$d['whlabel'],'fpdata'=>$d['fpdata']),$d['id']);
+						}
+						$post = $this->fullordertt->read($d['id']);
+						if($post['express'] != 0)
+						{
+						    $this->_znxc($post,$post['orderinfo'],4);
+						}
+					}
+				}
+				if($j['type'] == 2)
+				{
+					if($j['reverse_order_status '] == 50 || $j['reverse_order_status '] == 51)
+				    {
+						$whlabel = $this->whlabel->find_all("zd = '".$d['number']."'");
+						foreach ($whlabel as $v) 
+		       		    {
+							$this->whlabel->save(array('zd'=>''),$v['id']);
+						}
+					    $this->fullordertt->save(array('state'=>214,'whlabel'=>$d['whlabel'],'fpdata'=>$d['fpdata']),$d['id']);
+					}
+					/**
+					reverse_order_status
+					售后申请 = 1
+					售后拒绝申请 = 2
+					售后退货 = 3
+					售后买家已发货 = 4
+					售后卖家_拒绝接收 = 5
+					售后成功 = 50
+					取消成功 = 51
+					关闭 = 99
+					完成 = 100
+					**/
+				}
+				if ($this->db->trans_status() === TRUE)
+        		{
+					$this->db->trans_commit();
+					header('HTTP/1.1 200 OK');
+				}
+				else
+				{
+					$this->db->trans_rollback();
+				}
+			}
+		}
+	}
+}

+ 908 - 0
core/CoreApp/controllers/Apitt_new.php

@@ -0,0 +1,908 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Apitt extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_api','api');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_hl','hl');
+		$this->load->_model('Model_is','is');
+		$this->load->_model('Model_kdniao','kdniao');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_fullorderexcel','fullorderexcel');
+		$this->load->_model('Model_dhl','dhl');
+		$this->load->_model('Model_usps','usps');
+		$this->load->_model('Model_ups','ups');
+		$this->load->_model('Model_dhltest','dhltest');
+		$this->load->_model('Model_customer','customer');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_notice','notice');
+		$this->load->_model('Model_emaildata','emaildata');
+		$this->load->_model('Model_whlabel','whlabel');
+		$this->load->_model('Model_productdescribe','productdescribe');
+		$this->load->_model('Model_ljg','ljg');
+		$this->load->_model('Model_commodityread','commodityread');
+		$this->load->_model('Model_service','service');
+		$this->load->_model('Model_fedex','fedex');
+		$this->load->_model('Model_apismt','apismt');
+		$this->load->_model('Model_cne','cne');
+		$this->load->_model('Model_specialstock','specialstock');
+		$this->load->_model('Model_whlabellabel','whlabellabel');
+		$this->load->_model('Model_allocation','allocation');
+		$this->load->_model('Model_yswaybill','yswaybill');
+		$this->load->_model('Model_paypal','paypal');
+		$this->load->_model('Model_17track','17track');
+		$this->load->_model('Model_ck','ck');
+		$this->load->_model('Model_weight','weight');
+		$this->load->_model('Model_pay','pay');
+		$this->load->_model('Model_setting','setting');
+		$this->load->_model('Model_classid','classid');
+		$this->load->_model('Model_apitt','apitt');
+		$this->load->_model('Model_customertt','customertt');
+		$this->load->_model('Model_als','als');
+		$this->load->_model('Model_apiyy','apiyy');
+		$this->load->_model('Model_whlabel_fc','whlabel_fc');
+		$this->load->_model('Model_shopsku','shopsku');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'sq')
+        {
+             $this->_sq();
+        }
+		else if($arg == 'token')
+        {
+             $this->_token();
+        }
+		else if($arg == 'tb')
+        {
+             $this->_tb();
+        }
+		else if($arg == 'webhook')
+        {
+             $this->_webhook();
+        }
+		else if($arg == 'cs')
+        {
+             $this->_cs();
+        }
+		else if($arg == 'csa')
+        {
+             $this->_csa();
+        }
+    }
+	
+	public function get_list($shop,$from,$to,$order_status,$cuy,$num,$dtc,$money,$int,$dtctitle,$pay,$typeclass,$ex,$sjc)//获取订单列表
+	{
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/order/202309/orders/search';
+		$time = time();
+		$post['create_time_ge'] = $from;
+		$post['create_time_lt'] = $to;
+		$post['order_status'] = $order_status;
+		$queryParams['page_size'] = 100;
+		$queryParams['sort_order'] = 'DESC';
+		$queryParams['sort_field'] = 'create_time';
+		$queryParams['shop_cipher'] =$shop['shop_cipher'];
+		$queryParams['shop_id'] =$shop['codeid'];
+		$queryParams['app_key'] =$shop['app_key'];
+		$queryParams['timestamp'] =$time;
+		$link .= '?'.http_build_query($queryParams);
+		$sign = $this->apitt->sign($link,$shop['app_secret'],$post);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('Content-Type: application/json','x-tts-access-token:'.$shop['token']);
+		$res = $this->apitt->su_curl($post,$url,$headers);
+		$res = json_decode($res,true);
+		$list = array();$page_token = '';$arr = array();
+		if(isset($res['data']['orders']))
+		{
+			if($res['data']['total_count'] > 100)
+			{
+				$n = ceil($res['data']['total_count']/100);
+				for($i=0;$i<$n;$i++)
+				{
+					$net_date = $this->get_next_list($shop,$from,$to,$order_status,$page_token);
+					$page_token = $net_date[1];
+					foreach ($net_date['0'] as $val) 
+		        	{
+						$d = $this->fullordertt->get_orderinfo($val['id']);
+				    	if(!$d)
+				    	{
+							$list[] = $val['id'];
+						}
+					}
+				}
+			}
+			else
+			{
+			    foreach ($res['data']['orders'] as $val) 
+		        {
+				    $d = $this->fullordertt->get_orderinfo($val['id']);
+				    if(!$d)
+				    {
+					    $list[] = $val['id'];
+				    }
+			    }
+			}
+			$cs = array();
+			if(count($list) > 50)
+			{
+				$n = ceil(count($list)/50);$x = 0;
+				for($i=0;$i<$n;$i++)
+				{
+					$k = ($i<1)?0:$i*50;
+					$data = array_slice($list,$k,50);
+					$d = $this->get_data($data,$shop);
+					$cs[] = $d;
+					if(isset($d['data']))
+		            {
+					    foreach ($d['data']['orders'] as $val) 
+		                {
+						    $arr[$x] = $val;
+							$x++;
+					    }
+					}
+				}
+			}
+			else
+			{
+				$d = $this->get_data($list,$shop);
+				if(isset($d['data']))
+		        {
+					 foreach ($d['data']['orders'] as $val) 
+		             {
+						 $arr[] = $val;
+					 }
+				}
+			}
+		}
+		$read = array();
+		$gnum = array();
+		foreach ($arr as $val) 
+		{
+			$create_time = substr($val['create_time'],0,10)-$sjc;
+			if(isset($gnum[date('ymd',$create_time)]))
+			{
+				$gnum[date('ymd',$create_time)] += 1;
+			}
+			else
+			{
+				$num = $this->fullordertt->find_count('gtime = "'.date('Ymd',$create_time).'" and shop = "'.$shop['id'].'"');
+				$gnum[date('ymd',$create_time)] = $num+1;
+			}
+			$read[] = $this->get_read($val,$time,$shop,$cuy,$gnum[date('ymd',$create_time)],$dtc,$money,$int,$dtctitle,$pay,$typeclass,$ex,$sjc);
+		}
+		return array($read,$list);
+	}
+	
+	public function get_next_list($shop,$from,$to,$order_status,$page_token='')//获取订单列表
+	{
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/order/202309/orders/search';
+		$time = time();
+		$post['create_time_ge'] = $from;
+		$post['create_time_lt'] = $to;
+		$post['order_status'] = $order_status;
+		$queryParams['page_size'] = 100;
+		$queryParams['sort_order'] = 'DESC';
+		$queryParams['sort_field'] = 'create_time';
+		$queryParams['shop_cipher'] =$shop['shop_cipher'];
+		$queryParams['shop_id'] =$shop['codeid'];
+		$queryParams['app_key'] =$shop['app_key'];
+		$queryParams['timestamp'] =$time;
+		if($page_token)
+		{
+		    $queryParams['page_token'] = $page_token;
+		}
+		$link .= '?'.http_build_query($queryParams);
+		$sign = $this->apitt->sign($link,$shop['app_secret'],$post);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('Content-Type: application/json','x-tts-access-token:'.$shop['token']);
+		$res = $this->apitt->su_curl($post,$url,$headers);
+		$res = json_decode($res,true);
+		if(isset($res['data']['orders']))
+		{
+			return array($res['data']['orders'],$res['data']['next_page_token']);
+		}
+	}
+	
+	public function get_data($list,$shop)
+	{
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/order/202309/orders';
+		$time = time();
+		$ids = implode(",",$list);
+		$link .= '?shop_cipher='.$shop['shop_cipher'].'&app_key='.$shop['app_key'].'&timestamp='.$time.'&ids='.$ids;
+		$sign = $this->apitt->sign($link,$shop['app_secret'],'');
+		$url .= $link.'&sign='.$sign;
+		$headers = array('Content-Type: application/json','x-tts-access-token:'.$shop['token']);
+		$res = $this->apitt->su_curl('',$url,$headers,$date_type='json',$timeout=300,$httptype="GET");
+		$res = json_decode($res,true);
+		return $res;
+	}
+	
+	
+	
+	
+	
+	
+
+	public function _csa()
+	{
+		
+		$data = $this->fullordertt->get_orderinfo(576607595986915436);
+		$shop = $this->shop->read($data['shop']);
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/order/202309/orders';
+		$time = time();
+		$link .= '?shop_cipher='.$shop['shop_cipher'].'&app_key='.$shop['app_key'].'&timestamp='.$time.'&ids='.$data['orderinfo'];
+		$sign = $this->apitt->sign($link,$shop['token'],$shop['app_secret']);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('x-tts-access-token:'.$shop['token']);
+		$res = $this->api->su_curl('',$url,$headers,$date_type='json',$timeout=300,$httptype="GET",$userpwd='');
+		$res = json_decode($res,true);
+		echo "<pre>";
+		print_r($res);
+		exit;
+
+		
+		
+		$data = $this->fullordertt->get_orderinfo(576607595986915436);
+		$shop = $this->shop->read($data['shop']);
+		$list = array($data['orderinfo']);
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/api/orders/detail/query';
+		$time = time();
+		$post = array();
+		$post['order_id_list'] = json_encode($list);
+		$sign = $link.'app_key'.$shop['app_key'].'timestamp'.$time;
+		$sign = $shop['app_secret'].$sign.$shop['app_secret'];
+		$sign = hash_hmac('sha256', $sign, $shop['app_secret']);
+		$url .= $link.'?access_token='.$shop['token'].'&app_key='.$shop['app_key'].'&sign='.$sign.'&timestamp='.$time;
+		$ch = curl_init();
+		curl_setopt($ch, CURLOPT_URL,$url);
+		curl_setopt($ch, CURLOPT_POST, 1);
+		curl_setopt($ch, CURLOPT_HEADER, 0);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+		curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
+		curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+		$res = curl_exec($ch);
+		curl_close($ch);
+		$res = json_decode($res,true);
+		echo "<pre>";
+		print_r($res);
+		
+	}
+	
+
+
+	
+	public function _sq()
+	{
+		//授权获取app_key和code用于下一步获取token
+		$post = $this->input->get(NULL, TRUE);
+		if(isset($post['app_key']))
+		{
+		    $app_key = $this->input->get('app_key',true);
+			$code = $this->input->get('code',true);
+			if($code && $app_key)
+			{
+				$shop = $this->shop->app_key($app_key);
+				if($shop)
+				{
+				    $url = 'https://auth.tiktok-shops.com/api/v2/token/get?app_key='.$app_key.'&auth_code='.$code.'&app_secret='.$shop['app_secret'].'&grant_type=authorized_code';
+				    $ch = curl_init();
+       		        curl_setopt($ch, CURLOPT_URL,$url);//?status=any所有订单 &limit=200每页多少单
+       		        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
+       		        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
+       		        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+       		        $res = curl_exec($ch);
+       		        curl_close($ch);
+       		        $res = json_decode($res,true);
+				    if(isset($res['data']))
+				    {
+						$shop_cipher = '';
+						if($shop['shop_cipher'] == '')
+						{
+							$shopcipher = $this->_shop_cipher($shop['id']);
+							if(isset($shopcipher['data']['shops'][0]['cipher']))
+							{
+								$shop_cipher = $shopcipher['data']['shops'][0]['cipher'];
+							}
+						}
+					    $this->shop->save(array('token'=>$res['data']['access_token'],'tokentime'=>$res['data']['access_token_expire_in']-48*3600,'refresh_token'=>$res['data']['refresh_token'],'app_key'=>$app_key,'code'=>$code,'shop_cipher'=>$shop_cipher),$shop['id']);
+					    echo 'ok';
+				    }
+					else
+					{
+						echo json_encode($res);
+					}
+				}
+				else
+				{
+					echo "没有此店铺";
+				}
+			}
+		}
+				
+	}
+	
+	public function _token()//判断tokentime通过refresh_token刷新token
+	{
+		$shop = $this->shop->find_all("type = '1514'");//找TT店铺
+		foreach ($shop as $v) 
+		{
+			if($v['tokentime'] < time()+20*24*3600)
+			{
+				$url = 'https://auth.tiktok-shops.com/api/v2/token/refresh?app_key='.$v['app_key'].'&app_secret='.$v['app_secret'].'&grant_type=refresh_token&refresh_token='.$v['refresh_token'];
+		   	    $ch = curl_init();
+           	    curl_setopt($ch, CURLOPT_URL,$url);
+           	    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
+           	    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
+           	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+           	    $res = curl_exec($ch);
+           	    curl_close($ch);
+           	    $res = json_decode($res,true);
+		   	    if(isset($res['data']))
+		   	    {
+					$shop_cipher = '';
+					if($v['shop_cipher'] == '')
+					{
+						$shopcipher = $this->_shop_cipher($v['id']);
+						if(isset($shopcipher['data']['shops'][0]['cipher']))
+						{
+							$shop_cipher = $shopcipher['data']['shops'][0]['cipher'];
+						}
+					}
+			   	    $this->shop->save(array('token'=>$res['data']['access_token'],'tokentime'=>$res['data']['access_token_expire_in']-48*3600,'refresh_token'=>$res['data']['refresh_token'],'shop_cipher'=>$shop_cipher),$v['id']);
+		   	    }
+				else
+				{
+					echo json_encode($res);
+					exit;
+				}
+			}	
+		}	
+		echo "ok";
+	}
+	
+	public function _shop_cipher($id)
+	{
+		$shop = $this->shop->read($id);
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/authorization/202309/shops';
+		$time = time();
+		$queryParams = array();
+		$queryParams['access_token'] = $shop['token'];
+		$queryParams['app_key'] = $shop['app_key'];
+		$queryParams['shop_id'] = $shop['codeid'];
+		$queryParams['timestamp'] = $time;
+		$queryParams['version'] = '202309';
+		$link .= '?' . http_build_query($queryParams);
+		$sign = $this->apitt->sign($link,$shop['token'],$shop['app_secret']);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('x-tts-access-token:'.$shop['token']);
+		$ch = curl_init();
+		curl_setopt($ch, CURLOPT_URL, $url);
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
+		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+		$res = curl_exec($ch);
+		curl_close($ch);
+		$res = json_decode($res,true);
+		return $res;
+	}
+	
+	public function _tb()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		$api = $this->input->get('api',true);
+		$dshop = $this->input->get('dshop',true);
+		$gethl = array();
+		/*  匹配加入  */
+		$dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32 and classid != 36');
+		// and (classid=13 or classid=22 or classid=8 or classid=15 or classid=27 or classid=25 or classid=26 or classid=18 or classid=14 or classid=9 or classid=12 or classid=10 or classid=6 or classid=100 or classid=999)
+		$dtc = array();
+		foreach ($dictionaries as $v) 
+		{
+			if(stripos($v['spare'],'|') !== false)//如果有多个值
+			{
+				$v['spare'] = explode('|',$v['spare']);
+				foreach ($v['spare'] as $k=>$vs) 
+		        {
+					if(stripos($v['zh'],'|') !== false)
+					{
+						$vzh = explode('|',$v['zh']);
+						$dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id']);
+					}
+					else
+					{
+					    $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
+					}
+				}
+			}
+			else
+			{
+				$dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
+			}
+			
+		}
+		$dictionaries2 = $this->typeclass->find_all();
+		foreach ($dictionaries2 as $v)
+		{
+			$dtctitle[$v['id']] = $v['title'];
+		}
+		/*  匹配结束  */    
+		/*  价格加入  */  
+		$money = array();
+		/**
+		$productdescribe = $this->productdescribe->find_all('1=1','number,purchase,cost,salesprice,title');
+		foreach ($productdescribe as $v) 
+		{
+			$money[$v['number']] = array('purchase'=>$v['purchase'],'cost'=>$v['cost'],'salesprice'=>$v['salesprice'],'title'=>$v['title']);
+		}
+		**/
+		/*  价格加入  */
+		/*  匹配ID加入  */
+		$int = array();
+		$intdata = $this->typeclass->find_all('classid=14','id,spare');
+		foreach ($intdata as $v) 
+		{
+			$v['spare'] = explode('|',$v['spare']);
+			$int[$v['id']] = $v['spare'][0];
+		}
+		/*  匹配ID结束  */
+		/*  国家加入键值-k  */
+		$cuy = array();
+		$cuydata = $this->country->find_all('1=1','lb,id');
+		foreach ($cuydata as $v) 
+		{
+			$cuy[$v['lb']] = $v['id'];//获取到国家ID
+		}
+		/*  国家加入键值-j  */
+		$typeclass = array();
+		$tdata = $this->typeclass->find_all('classid=30','id,title');
+		foreach ($tdata as $v) 
+		{
+			$typeclass[$v['title']] = $v['id'];
+		}
+		$ex = array();
+		$express = $this->express->find_all('1=1','id,title');
+		foreach ($express as $v) 
+		{
+			$ex[$v['title']] = array('id'=>$v['id']);
+		}
+		/*  币种加入键值-j  */
+		/*  支付方式-k  */
+		$pay = array();$sd = array();
+		$tdata = $this->typeclass->find_all('classid=4','id,spare');
+		foreach ($tdata as $v) 
+		{
+			$paytype = $this->pay->get_typeclass($v['id']);
+			if(isset($paytype['estimaterate']))
+			{
+				$estimaterate = $paytype['estimaterate'];
+			}
+			else
+			{
+				$estimaterate = 0;
+			}
+			if(stripos($v['spare'],'|') !== false)//如果有多个值
+			{
+				$v['spare'] = explode('|',$v['spare']);
+				foreach ($v['spare'] as $k=>$vs) 
+		        {
+					$pay[$vs] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
+				}
+			}
+			else
+			{
+				$pay[$v['spare']] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
+			}
+		}
+		/*  支付方式-j  */
+		/*  新增SKU-k  */
+		$zjsku = array();
+		$shopsku = $this->shopsku->find_all();
+		foreach ($shopsku as $val) 
+		{
+			$ss = explode(',',trim($val['shop'],','));
+			foreach ($ss as $v) 
+			{
+				if(isset($zjsku[$v]))
+				{
+					$zjsku[$v] .= ','.trim($val['sku'],',');
+				}
+				else
+				{
+					$zjsku[$v] = trim($val['sku'],',');
+				}
+			}
+		}	
+		/*  新增SKU-j  */
+		$time = time();
+		$tb = 0;
+		if($api = '89757')  
+		{
+			$shop = $this->shop->find_all("type = '1514' and tb = '1'");//TT店铺
+			foreach ($shop as $value) 
+		    {
+				if((time()-$value['tbtime']) < 500)
+				{
+					$tb = 1;//正在同步中
+					break;
+				}
+				$setting = $this->setting->get_settings();
+				$sjc = 15*3600+$setting['sctime'];//时间差
+				$num = $this->fullordertt->find_count('gtime = "'.date('Ymd',$time).'" and shop = "'.$value['id'].'"');
+				//$this->db->trans_begin();
+				$res = $this->apitt->get_list($value,$time-18*3600,$time,'AWAITING_SHIPMENT',$cuy,$num,$dtc,$money,$int,$dtctitle,$pay,$typeclass,$ex,$sjc,$zjsku);//查询2小时数 据-等待装运=AWAITING_SHIPMENT(111) ;-等待收集=AWAITING_COLLECTION (112);在途=IN_TRANSIT (121);-已交付=DELIVERED (122);
+				$sd[] = $res;
+				$res = $res[0];
+				if($res)
+				{
+					foreach ($res as $v) 
+		        	{
+						$post = $v;
+						$dataorder = $this->fullordertt->get_orderinfo($v['orderinfo']);
+						if(!isset($dataorder['id']))
+						{
+							/** 启用自动分配仓库 **/
+							$warehouse = $this->warehouse->find_all("fpzd = '1'",'*','fpsx desc');
+							if($post['cf'] == 1)
+							{
+								$post['type'] = 34;//TT仓
+							}
+							else
+							{
+							    foreach ($warehouse as $v) 
+		        	            {
+								    if($v['bdcountry'] != 0 && $v['bdcountry'] != $post['country'])
+								    {
+									    continue;
+								    }
+								    $yx = 'get_yx_'.$v['bdck'];
+								    $kczd = $this->ck->$yx($post['state'],$v,$post['shop'],$post['number'],$post['whlabel'],$post['fpdata']);
+								    if($kczd['t'] == 0)
+								    {
+									    $country = $this->country->read($post['country']);//获取国家中配置物流
+									    if($country['express'] != 0)
+									    {
+									    	$post['express'] = $country['express'];
+									    }
+									    if($v['express'] != 0)//优先使用仓库指定物流,替换掉上面的国家配置物流
+									    {
+									    	$post['express'] = $v['express'];
+									    }
+									    $post['type'] = $v['id'];
+									    $post['whlabel'] = $kczd['whlabel'];
+									    $post['fpdata'] = $kczd['fpdata'];
+									    if(stripos($kczd['whlabel'],$v['hz']) !== false)
+									    {
+									        break 1;
+									    }
+								    }
+							    }
+							    $qdw = $this->warehouse->read($post['type']);
+							    $fl = $this->ck->get_fl($qdw['hz'],$post['whlabel'],$post['fpdata']);
+							    $post['sfxh'] = $fl['sfxh'];
+							    $post['ckfl'] = $fl['ckfl'];
+							    //自动写位置 开始
+							   $zclp = array();$pxsl = array();
+							   $slpx = explode('|',$post['slpx']);//排序
+							   foreach ($slpx as $k=>$v) 
+							   {
+								   $v = explode('-',$v);
+								   if(!isset($v[1]))
+								   {
+									   $v[1] == 1;
+								   }
+								   for($i=$v[0];$i<$v[1];$i++)
+								   {
+			    					   $pxsl[$i] = $k;
+								   }
+							   }
+							   $mc = $qdw['bdck'];$zdidjl = '';$zdwzjl = '';
+							   if($qdw['wz'] == 1)
+							   {
+								   $pm = explode(';',trim($post['shipremarks'],';'));
+								   foreach ($pm as $k=>$vv) 
+		        				   {
+									   $vv = trim($vv,' ');
+									   $lp = $this->typeclass->find_all("zh = '$vv'");
+									   if(isset($lp[0]['classid']))
+									   {
+										   $zclp[] = $vv;
+										   unset($pm[$k]);
+									   }
+								   }
+								   $pm = array_values($pm);
+								   $w = explode('|',trim($post['whlabel'],'|'));
+								   foreach ($w as $k=>$val) 
+		        	    		   {
+									   $hwm = '';
+									   if(stripos($val,$qdw['hz']) !== false)
+									   {
+										   $num = explode('-',trim($val,'-'));
+										   $xq = explode('~',trim($num[2],'~'));
+										   $pmxq = '(';
+										   foreach ($xq as $v) 
+		        	           			   {
+											   $zdidjl .= '('.trim($v,$qdw['hz']).')';
+											   $h = $this->$mc->read(trim($v,$qdw['hz']));
+											   if($h['details'] != '')
+											   {
+									               $pmxq .= $qdw['title'].':'.$h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'').',';
+											   }
+								           }
+										   $xrid = ($h['cpid']>0)?'-'.$h['cpid']:'';
+										   if(isset($pxsl[$k]))
+										   {
+											   if(stripos($pm[$pxsl[$k]],$qdw['title'].':'.$h['details'].$xrid) === false)
+											   {
+												   $pm[$pxsl[$k]] .= trim($pmxq,',').')';
+											   }
+										   }
+										   $zdwzjl .= $h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'');
+							           }
+						           }
+								   if($zclp)
+								   {
+									   $zclp = ';'.implode(";",$zclp);
+								   }
+								   else
+								   {
+									   $zclp = '';
+								   }
+								   $post['shipremarks'] = implode(";",$pm).$zclp;
+								   $post['contents'] = $zdidjl.' - '.$zdwzjl;
+					           }
+							}
+							//自动写位置 结束
+							/** **/
+							//合并重复项
+							$hbcfw = explode('|',trim($post['whlabel'],'|'));
+							$hbcff = explode(';',trim($post['fpdata'],';'));
+							$c = 0;
+							$hbw = array();
+							$hbf = array();
+							for($i=0;$i<count($hbcfw);$i++)
+							{
+								$w = explode('-',$hbcfw[$i]);
+								$f = explode('|',$hbcff[$i]);
+								$w2 = ($w[2]==0)?0:'';
+								if(!isset($hbw[$w[0].$w2]))
+								{
+									$hbw[$w[0].$w2] = $hbcfw[$i];
+									$hbf[$w[0].$w2] = $hbcff[$i];
+								}
+								else
+								{
+									$c++;
+									$cw = explode('-',$hbw[$w[0].$w2]);
+									$cf = explode('|',$hbf[$w[0].$w2]);
+									if($cw[2] != 0 && $w[2] != 0)
+									{
+										$cf[2] += $f[2];
+										$cf[9] .= '~'.$f[9];
+									    $hbf[$w[0].$w2] = implode("|",$cf);
+									    $cw[1] += $f[2];
+										$cw[2] .= '~'.$f[9];
+									    $hbw[$w[0].$w2] = implode("-",$cw);
+									}
+									else if($cw[2] == 0 && $w[2] == 0)
+									{
+									    $cf[2] += $f[2];
+									    $hbf[$w[0].$w2] = implode("|",$cf);
+									    $cw[1] += $f[2];
+									    $hbw[$w[0].$w2] = implode("-",$cw);
+									}
+									else
+									{
+										$hbw[] = $hbcfw[$i];
+									    $hbf[] = $hbcff[$i];
+									}
+								}
+							}
+							if($c > 0)
+							{
+								$post['fpdata'] = implode(";",$hbf).';';
+								$post['whlabel'] = '|'.implode("|",$hbw).'|';
+							}
+							//合并重复项结束
+							//非占单设置为禁止占单开始
+							$hbw = explode('|',trim($post['whlabel'],'|'));
+							$hbf = explode(';',trim($post['fpdata'],';'));
+							foreach ($hbw as $k=>$val) 
+		        	    	{
+								$w = explode('-',$val);
+								$f = explode('|',$hbf[$k]);
+								if(!isset($w[2]) || $w[2] == 0)
+								{
+									$w[2] = "DNOTO";
+								    $f[9] = "DNOTO";
+								    $hbf[$k] =  implode("|",$f);
+								    $hbw[$k] = implode("-",$w);
+								}
+							}
+							$post['fpdata'] = implode(";",$hbf).';';
+							$post['whlabel'] = '|'.implode("|",$hbw).'|';
+							//非占单设置为禁止占单结束
+							//查询净重开始
+							$post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
+							//查询净重结束
+			   		   		$tjid = $this->fullordertt->insert($post);
+							if($post['email'] == '')
+							{
+								$post['email'] = $post['name'].'@qq.com';
+							}
+							$adrs = $this->customertt->get_email($post['email'],$post['shop']);
+							preg_match_all('/[0-9]/u',$post['phone'],$result);
+				            $numphone = join('',$result[0]);
+							$hmdaddress1 = str_replace(array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),strtolower($post['address']));
+			                $hmdaddress2 = str_replace(array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),strtolower($post['address']));
+			                $hmdaddress3 = str_replace(array(' avenue',' ave',' av'),array(' ave',' avenue',' ave'),strtolower($post['address']));
+							$hmdid = '';
+							$post['address'] = str_replace("'","&#8217;",$post['address']);
+							$hmdaddress1 = str_replace("'","&#8217;",$hmdaddress1);
+							$hmdaddress2 = str_replace("'","&#8217;",$hmdaddress2);
+							$customerb = $this->customertt->find_all('type = 2 and (email = "'.$post['email'].'" or address = "'.$post['address'].'" or address = "'.$hmdaddress1.'" or address = "'.$hmdaddress2.'" or address = "'.$hmdaddress3.'" or numphone = "'.$numphone.'")','*','id desc');
+							$lkh = (isset($customerb[0]['id']))?2:1;//白名单1黑名单2
+							if($lkh == 2)
+							{
+								$hmdid = $customerb[0]['id'].'-('.$post['email'].'|'.$post['address'].'|'.$numphone.')'.'('.$customerb[0]['email'].'|'.$customerb[0]['address'].$customerb[0]['numphone'].')';
+							}
+							if($adrs)
+							{
+								$pdlkh = 1;//这个是判断是否老客户
+								$this->customertt->save(array('time'=>$post['dtime'],'num'=>$adrs['num']+1,'money'=>$adrs['money']+$post['shouldmoney']),$adrs['id']);
+								$khid = $adrs['id'];
+							}
+							else
+							{
+								$str = $post['phone'];
+								preg_match_all('/[0-9]/u',$str,$result);
+								$numphone = join('',$result[0]);
+								$ct['shop'] = $post['shop'];
+								$ct['source'] = 9;
+								$ct['level'] = 5;
+								$ct['country'] = $post['country'];
+								$ct['time'] = $post['dtime'];
+								$ct['num'] = 1;
+								$ct['money'] = $post['shouldmoney'];
+								$ct['zipcode'] = $post['zipcode'];
+								$ct['name'] = $post['name'];
+								$ct['phone'] = $post['phone'];
+								$ct['numphone'] = $numphone;
+								$ct['email'] = preg_replace('/( | | |\s)+/','',$post['email']);
+								$ct['province'] = $post['province'];
+								$ct['city'] = $post['city'];
+								$ct['address'] = $post['address'];
+								$ct['zhcx'] = $post['shop'].'-'.$ct['email'];
+			     				$khid = $this->customertt->insert($ct);
+								$pdlkh = 0;
+							}
+						}//else{}如果有此订单
+					}
+				}
+				/**
+				if ($this->db->trans_status() === FALSE)
+                {
+				    $this->db->trans_commit();
+                }
+                else
+                {
+                    $this->db->trans_commit();
+                }
+				**/
+				//sleep(1);//停留2秒
+				$this->shop->save(array('tbtime'=>time()),$value['id']);
+			}
+			if($tb == 1)
+			{
+				echo json_encode(array('msg'=>'有店铺正在同步中,请5分钟后再试!','success'=>true));exit;
+			}
+			//echo json_encode(array('msg'=>'OK!','success'=>true));exit;
+			echo "<pre>";
+			print_r($sd);
+		}
+	}
+	
+	public function _webhook()
+	{
+		$j = '';
+		$xq = array();
+		$j = file_get_contents('PHP://input');
+		$j = json_decode($j, true);
+		if(isset($j['type']) && isset($j['data']['order_id']))
+		{
+			$d = $this->fullordertt->get_orderinfo($j['data']['order_id']);
+			if($d)
+			{
+				$qchz = array();
+				$f = explode('|',trim($d['whlabel'],'|'));
+				foreach ($f as $v) 
+		        {
+					$hz = explode('-',trim($v,'-'));
+					if(isset($hz[2]) && $hz[2] != 'DNOTO' && $hz[2] != '0')
+					{
+						$qchz[] = $hz[2];
+					}
+				}
+				$d['whlabel']= str_replace($qchz,'0',$d['whlabel']);
+				$d['fpdata']= str_replace($qchz,'0',$d['fpdata']);
+				$this->db->trans_begin();
+				if($j['type'] == 1)
+				{
+					if($j['data']['order_status'] == 'CANCEL' || $j['data']['order_status'] == 'Canceled')
+					{
+						$whlabel = $this->whlabel->find_all("zd = '".$d['number']."'");
+						foreach ($whlabel as $v) 
+		       		    {
+							$this->whlabel->save(array('zd'=>''),$v['id']);
+						}
+						$this->fullordertt->save(array('state'=>217,'whlabel'=>$d['whlabel'],'fpdata'=>$d['fpdata']),$d['id']);
+					}
+					else if(($j['data']['order_status'] == 'IN_TRANSIT' || $j['data']['order_status'] == 'DELIVERED' || $j['data']['order_status'] == 'COMPLETED currently)') && $d['state'] != 216)
+					{
+						if($d['cf'] == 1 && $d['type'] == 34 && $j['data']['order_status'] == 'IN_TRANSIT')
+						{
+							$shop = $this->shop->read($d['shop']);
+							$wb = $this->apitt->get_data(array($d['orderinfo']),$shop);
+							$waybill = $wb['data']['order_list']['0']['order_line_list']['0']['tracking_number'];
+							$time = time();
+							$this->fullordertt->save(array('state'=>216,'whlabel'=>$d['whlabel'],'fpdata'=>$d['fpdata'],'waybill'=>$waybill,'print'=>3,'printtime'=>$time,'printnumber'=>1,'libraryconfirm'=>2,'library'=>2,'librarytime'=>$time,'weight'=>'0.4kg','	
+review'=>6,'reviewtime'=>$time),$d['id']);
+						}
+						else
+						{
+						    $this->fullordertt->save(array('state'=>216,'whlabel'=>$d['whlabel'],'fpdata'=>$d['fpdata']),$d['id']);
+						}
+					}
+				}
+				if($j['type'] == 2)
+				{
+					if($j['reverse_order_status '] == 50 || $j['reverse_order_status '] == 51)
+				    {
+						$whlabel = $this->whlabel->find_all("zd = '".$d['number']."'");
+						foreach ($whlabel as $v) 
+		       		    {
+							$this->whlabel->save(array('zd'=>''),$v['id']);
+						}
+					    $this->fullordertt->save(array('state'=>214,'whlabel'=>$d['whlabel'],'fpdata'=>$d['fpdata']),$d['id']);
+					}
+					/**
+					reverse_order_status
+					售后申请 = 1
+					售后拒绝申请 = 2
+					售后退货 = 3
+					售后买家已发货 = 4
+					售后卖家_拒绝接收 = 5
+					售后成功 = 50
+					取消成功 = 51
+					关闭 = 99
+					完成 = 100
+					**/
+				}
+				if ($this->db->trans_status() === TRUE)
+        		{
+					$this->db->trans_commit();
+					header('HTTP/1.1 200 OK');
+				}
+				else
+				{
+					$this->db->trans_rollback();
+				}
+			}
+		}
+	}
+}

+ 925 - 0
core/CoreApp/controllers/Apitt_old.php

@@ -0,0 +1,925 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Apitt extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_api','api');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_hl','hl');
+		$this->load->_model('Model_is','is');
+		$this->load->_model('Model_kdniao','kdniao');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_fullorderexcel','fullorderexcel');
+		$this->load->_model('Model_dhl','dhl');
+		$this->load->_model('Model_usps','usps');
+		$this->load->_model('Model_ups','ups');
+		$this->load->_model('Model_dhltest','dhltest');
+		$this->load->_model('Model_customer','customer');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_notice','notice');
+		$this->load->_model('Model_emaildata','emaildata');
+		$this->load->_model('Model_whlabel','whlabel');
+		$this->load->_model('Model_productdescribe','productdescribe');
+		$this->load->_model('Model_ljg','ljg');
+		$this->load->_model('Model_commodityread','commodityread');
+		$this->load->_model('Model_service','service');
+		$this->load->_model('Model_fedex','fedex');
+		$this->load->_model('Model_apismt','apismt');
+		$this->load->_model('Model_cne','cne');
+		$this->load->_model('Model_specialstock','specialstock');
+		$this->load->_model('Model_whlabellabel','whlabellabel');
+		$this->load->_model('Model_allocation','allocation');
+		$this->load->_model('Model_yswaybill','yswaybill');
+		$this->load->_model('Model_paypal','paypal');
+		$this->load->_model('Model_17track','17track');
+		$this->load->_model('Model_ck','ck');
+		$this->load->_model('Model_weight','weight');
+		$this->load->_model('Model_pay','pay');
+		$this->load->_model('Model_setting','setting');
+		$this->load->_model('Model_classid','classid');
+		$this->load->_model('Model_apitt','apitt');
+		$this->load->_model('Model_customertt','customertt');
+		$this->load->_model('Model_als','als');
+		$this->load->_model('Model_apiyy','apiyy');
+		$this->load->_model('Model_whlabel_fc','whlabel_fc');
+		$this->load->_model('Model_shopsku','shopsku');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'sq')
+        {
+             $this->_sq();
+        }
+		else if($arg == 'token')
+        {
+             $this->_token();
+        }
+		else if($arg == 'tb')
+        {
+             $this->_tb();
+        }
+		else if($arg == 'webhook')
+        {
+             $this->_webhook();
+        }
+		else if($arg == 'cs')
+        {
+             $this->_cs();
+        }
+		else if($arg == 'csa')
+        {
+             $this->_csa();
+        }
+    }
+	
+	public function get_list($shop,$from,$to,$order_status,$cuy,$num,$dtc,$money,$int,$dtctitle,$pay,$typeclass,$ex,$sjc)//获取订单列表
+	{
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/api/202309/orders/search';
+		$time = time();
+		$post = array();
+		$post['create_time_ge'] = $from;
+		$post['create_time_lt'] = $to;
+		$post['order_status'] = $order_status;
+		$post['page_size'] = 100;
+		$post['sort_order'] = 'DESC';
+		$link .= '?app_key='.$shop['app_key'].'&sign='.$sign.'&timestamp='.$time;
+		$sign = $this->sign($link,$shop['token'],$shop['app_secret']);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('x-tts-access-token:'.$shop['token']);
+		$res = $this->su_curl('',$url,$headers,$date_type='json',$timeout=300,$httptype="GET",$userpwd='');
+		$res = json_decode($res,true);
+		$list = array();$page_token = '';$arr = array();
+		if(isset($res['data']['orders']))
+		{
+			if($res['data']['total'] > 100)
+			{
+				$n = ceil($res['data']['total']/100);
+				for($i=0;$i<$n;$i++)
+				{
+					$net_date = $this->get_next_list($shop,$from,$to,$order_status,$page_token);
+					$page_token = $net_date[1];
+					foreach ($net_date['0'] as $val) 
+		        	{
+						$d = $this->fullordertt->get_orderinfo($val['order_id']);
+				    	if(!$d)
+				    	{
+							$list[] = $val['order_id'];
+						}
+					}
+				}
+			}
+			else
+			{
+			    foreach ($res['data']['orders'] as $val) 
+		        {
+				    $d = $this->fullordertt->get_orderinfo($val['order_id']);
+				    if(!$d)
+				    {
+					    $list[] = $val['order_id'];
+				    }
+			    }
+			}
+			$cs = array();
+			if(count($list) > 50)
+			{
+				$n = ceil(count($list)/50);$x = 0;
+				for($i=0;$i<$n;$i++)
+				{
+					$k = ($i<1)?0:$i*50;
+					$data = array_slice($list,$k,50);
+					$d = $this->get_data($data,$shop);
+					$cs[] = $d;
+					if(isset($d['data']))
+		            {
+					    foreach ($d['data']['orders'] as $val) 
+		                {
+						    $arr[$x] = $val;
+							$x++;
+					    }
+					}
+				}
+			}
+			else
+			{
+				$d = $this->get_data($list,$shop);
+				if(isset($d['data']))
+		        {
+					 foreach ($d['data']['orders'] as $val) 
+		             {
+						 $arr[] = $val;
+					 }
+				}
+			}
+		}
+		$read = array();
+		$gnum = array();
+		foreach ($arr as $val) 
+		{
+			$create_time = substr($val['create_time'],0,10)-$sjc;
+			if(isset($gnum[date('ymd',$create_time)]))
+			{
+				$gnum[date('ymd',$create_time)] += 1;
+			}
+			else
+			{
+				$num = $this->fullordertt->find_count('gtime = "'.date('Ymd',$create_time).'" and shop = "'.$shop['id'].'"');
+				$gnum[date('ymd',$create_time)] = $num+1;
+			}
+			$read[] = $this->get_read($val,$time,$shop,$cuy,$gnum[date('ymd',$create_time)],$dtc,$money,$int,$dtctitle,$pay,$typeclass,$ex,$sjc);
+		}
+		return array($read,$list);
+	}
+	
+	public function get_next_list($shop,$from,$to,$order_status,$page_token)//获取订单列表
+	{
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/api/202309/orders/search';
+		$time = time();
+		$post = array();
+		$post['create_time_ge'] = $from;
+		$post['create_time_lt'] = $to;
+		$post['order_status'] = $order_status;
+		$post['page_size'] = 100;
+		$post['sort_order'] = 'DESC';
+		if($page_token)
+		{
+		    $post['page_token'] = $page_token;
+		}
+		$post['sort_type'] = 2;
+		$link .= '?app_key='.$shop['app_key'].'&sign='.$sign.'&timestamp='.$time;
+		$sign = $this->sign($link,$shop['token'],$shop['app_secret']);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('x-tts-access-token:'.$shop['token']);
+		$res = $this->su_curl('',$url,$headers,$date_type='json',$timeout=300,$httptype="GET",$userpwd='');
+		$res = json_decode($res,true);
+		if(isset($res['data']['orders']))
+		{
+			return array($res['data']['orders'],$res['data']['next_page_token']);
+		}
+	}
+	
+	public function get_data($list,$shop)
+	{
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/order/202309/orders';
+		$time = time();
+		$ids = implode(",",$list);
+		$link .= '?shop_cipher='.$shop['shop_cipher'].'&app_key='.$shop['app_key'].'&timestamp='.$time.'&ids='.$ids;
+		$sign = $this->sign($link,$shop['token'],$shop['app_secret']);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('x-tts-access-token:'.$shop['token']);
+		$res = $this->su_curl('',$url,$headers,$date_type='json',$timeout=300,$httptype="GET",$userpwd='');
+		$res = json_decode($res,true);
+		return $res;
+	}
+	
+	
+	
+	
+	
+	
+	
+
+	public function _csa()
+	{
+		/**
+		$data = $this->fullordertt->find_all("type = '34' and waybill = '' and state = 216");
+		foreach ($data as $d) 
+		{
+			$shop = $this->shop->read($d['shop']);
+			$wb = $this->apitt->get_data(array($d['orderinfo']),$shop);
+			if(isset($wb['data']['order_list']['0']['order_line_list']['0']['tracking_number']))
+			{
+			    $waybill = $wb['data']['order_list']['0']['order_line_list']['0']['tracking_number'];
+			    $this->fullordertt->save(array('waybill'=>$waybill),$d['id']);
+			}
+		}
+		
+		exit;
+		
+		
+		
+		
+		
+		
+		
+		exit;
+		
+		$shop = $this->shop->read($data['shop']);
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/order/202309/orders';
+		$time = time();
+		$link .= '?shop_cipher='.$shop['shop_cipher'].'&app_key='.$shop['app_key'].'&timestamp='.$time.'&ids='.$data['orderinfo'];
+		$sign = $this->apitt->sign($link,$shop['token'],$shop['app_secret']);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('x-tts-access-token:'.$shop['token']);
+		$res = $this->api->su_curl('',$url,$headers,$date_type='json',$timeout=300,$httptype="GET",$userpwd='');
+		$res = json_decode($res,true);
+		echo "<pre>";
+		print_r($res);
+		exit;
+**/
+		
+		
+		$data = $this->fullordertt->get_orderinfo(576617206704803866);
+		$shop = $this->shop->read($data['shop']);
+		$list = array($data['orderinfo']);
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/api/orders/detail/query';
+		$time = time();
+		$post = array();
+		$post['order_id_list'] = json_encode($list);
+		$sign = $link.'app_key'.$shop['app_key'].'timestamp'.$time;
+		$sign = $shop['app_secret'].$sign.$shop['app_secret'];
+		$sign = hash_hmac('sha256', $sign, $shop['app_secret']);
+		$url .= $link.'?access_token='.$shop['token'].'&app_key='.$shop['app_key'].'&sign='.$sign.'&timestamp='.$time;
+		$ch = curl_init();
+		curl_setopt($ch, CURLOPT_URL,$url);
+		curl_setopt($ch, CURLOPT_POST, 1);
+		curl_setopt($ch, CURLOPT_HEADER, 0);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+		curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
+		curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+		$res = curl_exec($ch);
+		curl_close($ch);
+		$res = json_decode($res,true);
+		echo "<pre>";
+		print_r($res);
+		
+	}
+	
+
+
+	
+	public function _sq()
+	{
+		//授权获取app_key和code用于下一步获取token
+		$post = $this->input->get(NULL, TRUE);
+		if(isset($post['app_key']))
+		{
+		    $app_key = $this->input->get('app_key',true);
+			$code = $this->input->get('code',true);
+			if($code && $app_key)
+			{
+				$shop = $this->shop->app_key($app_key);
+				if($shop)
+				{
+				    $url = 'https://auth.tiktok-shops.com/api/v2/token/get?app_key='.$app_key.'&auth_code='.$code.'&app_secret='.$shop['app_secret'].'&grant_type=authorized_code';
+				    $ch = curl_init();
+       		        curl_setopt($ch, CURLOPT_URL,$url);//?status=any所有订单 &limit=200每页多少单
+       		        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
+       		        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
+       		        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+       		        $res = curl_exec($ch);
+       		        curl_close($ch);
+       		        $res = json_decode($res,true);
+				    if(isset($res['data']))
+				    {
+						$shop_cipher = '';
+						if($shop['shop_cipher'] == '')
+						{
+							$shopcipher = $this->_shop_cipher($shop['id']);
+							if(isset($shopcipher['data']['shops'][0]['cipher']))
+							{
+								$shop_cipher = $shopcipher['data']['shops'][0]['cipher'];
+							}
+						}
+					    $this->shop->save(array('token'=>$res['data']['access_token'],'tokentime'=>$res['data']['access_token_expire_in']-48*3600,'refresh_token'=>$res['data']['refresh_token'],'app_key'=>$app_key,'code'=>$code,'shop_cipher'=>$shop_cipher),$shop['id']);
+					    echo 'ok';
+				    }
+					else
+					{
+						echo json_encode($res);
+					}
+				}
+				else
+				{
+					echo "没有此店铺";
+				}
+			}
+		}
+				
+	}
+	
+	public function _token()//判断tokentime通过refresh_token刷新token
+	{
+		$shop = $this->shop->find_all("type = '1514'");//找TT店铺
+		foreach ($shop as $v) 
+		{
+			if($v['tokentime'] < time()+20*24*3600)
+			{
+				$url = 'https://auth.tiktok-shops.com/api/v2/token/refresh?app_key='.$v['app_key'].'&app_secret='.$v['app_secret'].'&grant_type=refresh_token&refresh_token='.$v['refresh_token'];
+		   	    $ch = curl_init();
+           	    curl_setopt($ch, CURLOPT_URL,$url);
+           	    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
+           	    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
+           	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+           	    $res = curl_exec($ch);
+           	    curl_close($ch);
+           	    $res = json_decode($res,true);
+		   	    if(isset($res['data']))
+		   	    {
+					$shop_cipher = '';
+					if($v['shop_cipher'] == '')
+					{
+						$shopcipher = $this->_shop_cipher($v['id']);
+						if(isset($shopcipher['data']['shops'][0]['cipher']))
+						{
+							$shop_cipher = $shopcipher['data']['shops'][0]['cipher'];
+						}
+					}
+			   	    $this->shop->save(array('token'=>$res['data']['access_token'],'tokentime'=>$res['data']['access_token_expire_in']-48*3600,'refresh_token'=>$res['data']['refresh_token'],'shop_cipher'=>$shop_cipher),$v['id']);
+		   	    }
+				else
+				{
+					echo json_encode($res);
+					exit;
+				}
+			}	
+		}	
+		echo "ok";
+	}
+	
+	public function _shop_cipher($id)
+	{
+		$shop = $this->shop->read($id);
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/authorization/202309/shops';
+		$time = time();
+		$queryParams = array();
+		$queryParams['access_token'] = $shop['token'];
+		$queryParams['app_key'] = $shop['app_key'];
+		$queryParams['shop_id'] = $shop['codeid'];
+		$queryParams['timestamp'] = $time;
+		$queryParams['version'] = '202309';
+		$link .= '?' . http_build_query($queryParams);
+		$sign = $this->apitt->sign($link,$shop['token'],$shop['app_secret']);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('x-tts-access-token:'.$shop['token']);
+		$ch = curl_init();
+		curl_setopt($ch, CURLOPT_URL, $url);
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
+		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+		$res = curl_exec($ch);
+		curl_close($ch);
+		$res = json_decode($res,true);
+		return $res;
+	}
+	
+	public function _tb()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		$api = $this->input->get('api',true);
+		$dshop = $this->input->get('dshop',true);
+		$gethl = array();
+		/*  匹配加入  */
+		$dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32 and classid != 36');
+		// and (classid=13 or classid=22 or classid=8 or classid=15 or classid=27 or classid=25 or classid=26 or classid=18 or classid=14 or classid=9 or classid=12 or classid=10 or classid=6 or classid=100 or classid=999)
+		$dtc = array();
+		foreach ($dictionaries as $v) 
+		{
+			if(stripos($v['spare'],'|') !== false)//如果有多个值
+			{
+				$v['spare'] = explode('|',$v['spare']);
+				foreach ($v['spare'] as $k=>$vs) 
+		        {
+					if(stripos($v['zh'],'|') !== false)
+					{
+						$vzh = explode('|',$v['zh']);
+						$dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
+					}
+					else
+					{
+					    $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
+					}
+				}
+			}
+			else
+			{
+				$dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
+			}
+			
+		}
+		$dictionaries2 = $this->typeclass->find_all();
+		foreach ($dictionaries2 as $v)
+		{
+			$dtctitle[$v['id']] = $v['title'];
+		}
+		/*  匹配结束  */    
+		/*  价格加入  */  
+		$money = array();
+		/**
+		$productdescribe = $this->productdescribe->find_all('1=1','number,purchase,cost,salesprice,title');
+		foreach ($productdescribe as $v) 
+		{
+			$money[$v['number']] = array('purchase'=>$v['purchase'],'cost'=>$v['cost'],'salesprice'=>$v['salesprice'],'title'=>$v['title']);
+		}
+		**/
+		/*  价格加入  */
+		/*  匹配ID加入  */
+		$int = array();
+		$intdata = $this->typeclass->find_all('classid=14','id,spare');
+		foreach ($intdata as $v) 
+		{
+			$v['spare'] = explode('|',$v['spare']);
+			$int[$v['id']] = $v['spare'][0];
+		}
+		/*  匹配ID结束  */
+		/*  国家加入键值-k  */
+		$cuy = array();
+		$cuydata = $this->country->find_all('1=1','lb,id');
+		foreach ($cuydata as $v) 
+		{
+			$cuy[$v['lb']] = $v['id'];//获取到国家ID
+		}
+		/*  国家加入键值-j  */
+		$typeclass = array();
+		$tdata = $this->typeclass->find_all('classid=30','id,title');
+		foreach ($tdata as $v) 
+		{
+			$typeclass[$v['title']] = $v['id'];
+		}
+		$ex = array();
+		$express = $this->express->find_all('1=1','id,title');
+		foreach ($express as $v) 
+		{
+			$ex[$v['title']] = array('id'=>$v['id']);
+		}
+		/*  币种加入键值-j  */
+		/*  支付方式-k  */
+		$pay = array();$sd = array();
+		$tdata = $this->typeclass->find_all('classid=4','id,spare');
+		foreach ($tdata as $v) 
+		{
+			$paytype = $this->pay->get_typeclass($v['id']);
+			if(isset($paytype['estimaterate']))
+			{
+				$estimaterate = $paytype['estimaterate'];
+			}
+			else
+			{
+				$estimaterate = 0;
+			}
+			if(stripos($v['spare'],'|') !== false)//如果有多个值
+			{
+				$v['spare'] = explode('|',$v['spare']);
+				foreach ($v['spare'] as $k=>$vs) 
+		        {
+					$pay[$vs] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
+				}
+			}
+			else
+			{
+				$pay[$v['spare']] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
+			}
+		}
+		/*  支付方式-j  */
+		/*  新增SKU-k  */
+		$zjsku = array();
+		$shopsku = $this->shopsku->find_all();
+		foreach ($shopsku as $val) 
+		{
+			$ss = explode(',',trim($val['shop'],','));
+			foreach ($ss as $v) 
+			{
+				if(isset($zjsku[$v]))
+				{
+					$zjsku[$v] .= ','.trim($val['sku'],',');
+				}
+				else
+				{
+					$zjsku[$v] = trim($val['sku'],',');
+				}
+			}
+		}	
+		/*  新增SKU-j  */
+		$time = time();
+		$tb = 0;
+		if($api = '89757')  
+		{
+			$shop = $this->shop->find_all("type = '1514' and tb = '1'");//TT店铺
+			foreach ($shop as $value) 
+		    {
+				if((time()-$value['tbtime']) < 1)
+				{
+					$tb = 1;//正在同步中
+					break;
+				}
+				$setting = $this->setting->get_settings();
+				$sjc = 15*3600+$setting['sctime'];//时间差
+				$num = $this->fullordertt->find_count('gtime = "'.date('Ymd',$time).'" and shop = "'.$value['id'].'"');
+				//$this->db->trans_begin();
+				$res = $this->apitt->get_list($value,$time-18*3600,$time,'111',$cuy,$num,$dtc,$money,$int,$dtctitle,$pay,$typeclass,$ex,$sjc,$zjsku);//查询2小时数 据-等待装运=AWAITING_SHIPMENT(111) ;-等待收集=AWAITING_COLLECTION (112);在途=IN_TRANSIT (122);-已交付=DELIVERED (122);
+				$sd[] = $res;
+				$res = $res[0];
+				if($res)
+				{
+					foreach ($res as $v) 
+		        	{
+						$post = $v;
+						$dataorder = $this->fullordertt->get_orderinfo($v['orderinfo']);
+						if(!isset($dataorder['id']))
+						{
+							/** 启用自动分配仓库 **/
+							$warehouse = $this->warehouse->find_all("fpzd = '1'",'*','fpsx desc');
+							if($post['cf'] == 1)
+							{
+								$post['type'] = 34;//TT仓
+							}
+							else
+							{
+							    foreach ($warehouse as $v) 
+		        	            {
+								    if($v['bdcountry'] != 0 && $v['bdcountry'] != $post['country'])
+								    {
+									    continue;
+								    }
+								    $yx = 'get_yx_'.$v['bdck'];
+								    $kczd = $this->ck->$yx($post['state'],$v,$post['shop'],$post['number'],$post['whlabel'],$post['fpdata']);
+								    if($kczd['t'] == 0)
+								    {
+									    $country = $this->country->read($post['country']);//获取国家中配置物流
+									    if($country['express'] != 0)
+									    {
+									    	$post['express'] = $country['express'];
+									    }
+									    if($v['express'] != 0)//优先使用仓库指定物流,替换掉上面的国家配置物流
+									    {
+									    	$post['express'] = $v['express'];
+									    }
+									    $post['type'] = $v['id'];
+									    $post['whlabel'] = $kczd['whlabel'];
+									    $post['fpdata'] = $kczd['fpdata'];
+									    if(stripos($kczd['whlabel'],$v['hz']) !== false)
+									    {
+									        break 1;
+									    }
+								    }
+							    }
+							    $qdw = $this->warehouse->read($post['type']);
+							    $fl = $this->ck->get_fl($qdw['hz'],$post['whlabel'],$post['fpdata']);
+							    $post['sfxh'] = $fl['sfxh'];
+							    $post['ckfl'] = $fl['ckfl'];
+							    //自动写位置 开始
+							    if($post['slpx'])
+							    {
+								    $zclp = array();$pxsl = array();
+								    $slpx = explode('|',$post['slpx']);//排序
+								    foreach ($slpx as $k=>$v) 
+								    {
+									    $v = explode('-',$v);
+									    if(!isset($v[1]))
+									    {
+										    $v[1] == 1;
+									    }
+									    for($i=$v[0];$i<$v[1];$i++)
+									    {
+			    						    $pxsl[$i] = $k;
+									    }
+								    }
+								    $mc = $qdw['bdck'];$zdidjl = '';$zdwzjl = '';
+								    if($qdw['wz'] == 1)
+								    {
+									    $pm = explode(';',trim($post['shipremarks'],';'));
+									    foreach ($pm as $k=>$vv) 
+		        					    {
+										    $vv = trim($vv,' ');
+										    $lp = $this->typeclass->find_all("zh = '$vv'");
+										    if(isset($lp[0]['classid']))
+										    {
+											    $zclp[] = $vv;
+											    unset($pm[$k]);
+										    }
+									    }
+									    $pm = array_values($pm);
+									    $w = explode('|',trim($post['whlabel'],'|'));
+									    foreach ($w as $k=>$val) 
+		        	    			    {
+										    $hwm = '';
+										    if(stripos($val,$qdw['hz']) !== false)
+										    {
+											    $num = explode('-',trim($val,'-'));
+											    $xq = explode('~',trim($num[2],'~'));
+											    $pmxq = '(';
+											    foreach ($xq as $v) 
+		        	           				    {
+											    	$h = $this->$mc->read(trim($v,$qdw['hz']));
+												    if($h['details'] != '')
+												    {
+									          	      $pmxq .= $qdw['title'].':'.$h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'').',';
+												    }
+								        	    }
+												$xrid = ($h['cpid']>0)?'-'.$h['cpid']:'';
+											    if(isset($pxsl[$k]))
+											    {
+												    if(stripos($pm[$pxsl[$k]],$qdw['title'].':'.$h['details'].$xrid) === false)
+												    {
+													    $pm[$pxsl[$k]] .= trim($pmxq,',').')';
+												    }
+											    }
+											    $zdwzjl .= $h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'');
+							       	         }
+						        	    }
+									    if($zclp)
+									    {
+										    $zclp = ';'.implode(";",$zclp);
+									    }
+									    else
+									    {
+										    $zclp = '';
+									    }
+									    $post['shipremarks'] = implode(";",$pm).$zclp;
+										$post['contents'] = $zdidjl.' - '.$zdwzjl;
+					        	    }
+							    }
+							//自动写位置 结束
+							}
+							/** **/
+							//合并重复项
+							$hbcfw = explode('|',trim($post['whlabel'],'|'));
+							$hbcff = explode(';',trim($post['fpdata'],';'));
+							$c = 0;
+							$hbw = array();
+							$hbf = array();
+							for($i=0;$i<count($hbcfw);$i++)
+							{
+								$w = explode('-',$hbcfw[$i]);
+								$f = explode('|',$hbcff[$i]);
+								$w2 = ($w[2]==0)?0:'';
+								if(!isset($hbw[$w[0].$w2]))
+								{
+									$hbw[$w[0].$w2] = $hbcfw[$i];
+									$hbf[$w[0].$w2] = $hbcff[$i];
+								}
+								else
+								{
+									$c++;
+									$cw = explode('-',$hbw[$w[0].$w2]);
+									$cf = explode('|',$hbf[$w[0].$w2]);
+									if($cw[2] != 0 && $w[2] != 0)
+									{
+										$cf[2] += $f[2];
+										$cf[9] .= '~'.$f[9];
+									    $hbf[$w[0].$w2] = implode("|",$cf);
+									    $cw[1] += $f[2];
+										$cw[2] .= '~'.$f[9];
+									    $hbw[$w[0].$w2] = implode("-",$cw);
+									}
+									else if($cw[2] == 0 && $w[2] == 0)
+									{
+									    $cf[2] += $f[2];
+									    $hbf[$w[0].$w2] = implode("|",$cf);
+									    $cw[1] += $f[2];
+									    $hbw[$w[0].$w2] = implode("-",$cw);
+									}
+									else
+									{
+										$hbw[] = $hbcfw[$i];
+									    $hbf[] = $hbcff[$i];
+									}
+								}
+							}
+							if($c > 0)
+							{
+								$post['fpdata'] = implode(";",$hbf).';';
+								$post['whlabel'] = '|'.implode("|",$hbw).'|';
+							}
+							//合并重复项结束
+							//非占单设置为禁止占单开始
+							$hbw = explode('|',trim($post['whlabel'],'|'));
+							$hbf = explode(';',trim($post['fpdata'],';'));
+							foreach ($hbw as $k=>$val) 
+		        	    	{
+								$w = explode('-',$val);
+								$f = explode('|',$hbf[$k]);
+								if(!isset($w[2]) || $w[2] == 0)
+								{
+									$w[2] = "DNOTO";
+								    $f[9] = "DNOTO";
+								    $hbf[$k] =  implode("|",$f);
+								    $hbw[$k] = implode("-",$w);
+								}
+							}
+							$post['fpdata'] = implode(";",$hbf).';';
+							$post['whlabel'] = '|'.implode("|",$hbw).'|';
+							//非占单设置为禁止占单结束
+							//查询净重开始
+							$post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
+							//查询净重结束
+			   		   		$tjid = $this->fullordertt->insert($post);
+							if($post['email'] == '')
+							{
+								$post['email'] = $post['name'].'@qq.com';
+							}
+							$adrs = $this->customertt->get_email($post['email'],$post['shop']);
+							preg_match_all('/[0-9]/u',$post['phone'],$result);
+				            $numphone = join('',$result[0]);
+							$hmdaddress1 = str_replace(array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),strtolower($post['address']));
+			                $hmdaddress2 = str_replace(array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),strtolower($post['address']));
+			                $hmdaddress3 = str_replace(array(' avenue',' ave',' av'),array(' ave',' avenue',' ave'),strtolower($post['address']));
+							$hmdid = '';
+							$post['address'] = str_replace("'","&#8217;",$post['address']);
+							$hmdaddress1 = str_replace("'","&#8217;",$hmdaddress1);
+							$hmdaddress2 = str_replace("'","&#8217;",$hmdaddress2);
+							$customerb = $this->customertt->find_all('type = 2 and (email = "'.$post['email'].'" or address = "'.$post['address'].'" or address = "'.$hmdaddress1.'" or address = "'.$hmdaddress2.'" or address = "'.$hmdaddress3.'" or numphone = "'.$numphone.'")','*','id desc');
+							$lkh = (isset($customerb[0]['id']))?2:1;//白名单1黑名单2
+							if($lkh == 2)
+							{
+								$hmdid = $customerb[0]['id'].'-('.$post['email'].'|'.$post['address'].'|'.$numphone.')'.'('.$customerb[0]['email'].'|'.$customerb[0]['address'].$customerb[0]['numphone'].')';
+							}
+							if($adrs)
+							{
+								$pdlkh = 1;//这个是判断是否老客户
+								$this->customertt->save(array('time'=>$post['dtime'],'num'=>$adrs['num']+1,'money'=>$adrs['money']+$post['shouldmoney']),$adrs['id']);
+								$khid = $adrs['id'];
+							}
+							else
+							{
+								$str = $post['phone'];
+								preg_match_all('/[0-9]/u',$str,$result);
+								$numphone = join('',$result[0]);
+								$ct['shop'] = $post['shop'];
+								$ct['source'] = 9;
+								$ct['level'] = 5;
+								$ct['country'] = $post['country'];
+								$ct['time'] = $post['dtime'];
+								$ct['num'] = 1;
+								$ct['money'] = $post['shouldmoney'];
+								$ct['zipcode'] = $post['zipcode'];
+								$ct['name'] = $post['name'];
+								$ct['phone'] = $post['phone'];
+								$ct['numphone'] = $numphone;
+								$ct['email'] = preg_replace('/( | | |\s)+/','',$post['email']);
+								$ct['province'] = $post['province'];
+								$ct['city'] = $post['city'];
+								$ct['address'] = $post['address'];
+								$ct['zhcx'] = $post['shop'].'-'.$ct['email'];
+			     				$khid = $this->customertt->insert($ct);
+								$pdlkh = 0;
+							}
+						}//else{}如果有此订单
+					}
+				}
+				/**
+				if ($this->db->trans_status() === FALSE)
+                {
+				    $this->db->trans_commit();
+                }
+                else
+                {
+                    $this->db->trans_commit();
+                }
+				**/
+				//sleep(1);//停留2秒
+				$this->shop->save(array('tbtime'=>time()),$value['id']);
+			}
+			if($tb == 1)
+			{
+				echo json_encode(array('msg'=>'有店铺正在同步中,请5分钟后再试!','success'=>true));exit;
+			}
+			//echo json_encode(array('msg'=>'OK!','success'=>true));exit;
+			echo "<pre>";
+			print_r($sd);
+		}
+	}
+	
+	public function _webhook()
+	{
+		$j = '';
+		$xq = array();
+		$j = file_get_contents('PHP://input');
+		$j = json_decode($j, true);
+		if(isset($j['type']) && isset($j['data']['order_id']))
+		{
+			$d = $this->fullordertt->get_orderinfo($j['data']['order_id']);
+			if($d)
+			{
+				$qchz = array();
+				$f = explode('|',trim($d['whlabel'],'|'));
+				foreach ($f as $v) 
+		        {
+					$hz = explode('-',trim($v,'-'));
+					if(isset($hz[2]) && $hz[2] != 'DNOTO' && $hz[2] != '0')
+					{
+						$qchz[] = $hz[2];
+					}
+				}
+				$d['whlabel']= str_replace($qchz,'0',$d['whlabel']);
+				$d['fpdata']= str_replace($qchz,'0',$d['fpdata']);
+				$this->db->trans_begin();
+				if($j['type'] == 1)
+				{
+					if($j['data']['order_status'] == 'CANCEL' || $j['data']['order_status'] == 'Canceled')
+					{
+						$whlabel = $this->whlabel->find_all("zd = '".$d['number']."'");
+						foreach ($whlabel as $v) 
+		       		    {
+							$this->whlabel->save(array('zd'=>''),$v['id']);
+						}
+						$this->fullordertt->save(array('state'=>217,'whlabel'=>$d['whlabel'],'fpdata'=>$d['fpdata']),$d['id']);
+					}
+					else if(($j['data']['order_status'] == 'IN_TRANSIT' || $j['data']['order_status'] == 'DELIVERED' || $j['data']['order_status'] == 'COMPLETED currently)') && $d['state'] != 216)
+					{
+						if($d['cf'] == 1 && $d['type'] == 34 && $j['data']['order_status'] == 'IN_TRANSIT')
+						{
+							$shop = $this->shop->read($d['shop']);
+							$wb = $this->apitt->get_data(array($d['orderinfo']),$shop);
+							$waybill = $wb['data']['order_list']['0']['order_line_list']['0']['tracking_number'];
+							$time = time();
+							$this->fullordertt->save(array('state'=>216,'whlabel'=>$d['whlabel'],'fpdata'=>$d['fpdata'],'waybill'=>$waybill,'print'=>3,'printtime'=>$time,'printnumber'=>1,'libraryconfirm'=>2,'library'=>2,'librarytime'=>$time,'weight'=>'0.4kg','	
+review'=>6,'reviewtime'=>$time),$d['id']);
+						}
+						else
+						{
+						    $this->fullordertt->save(array('state'=>216,'whlabel'=>$d['whlabel'],'fpdata'=>$d['fpdata']),$d['id']);
+						}
+					}
+				}
+				if($j['type'] == 2)
+				{
+					if($j['reverse_order_status '] == 50 || $j['reverse_order_status '] == 51)
+				    {
+						$whlabel = $this->whlabel->find_all("zd = '".$d['number']."'");
+						foreach ($whlabel as $v) 
+		       		    {
+							$this->whlabel->save(array('zd'=>''),$v['id']);
+						}
+					    $this->fullordertt->save(array('state'=>214,'whlabel'=>$d['whlabel'],'fpdata'=>$d['fpdata']),$d['id']);
+					}
+					/**
+					reverse_order_status
+					售后申请 = 1
+					售后拒绝申请 = 2
+					售后退货 = 3
+					售后买家已发货 = 4
+					售后卖家_拒绝接收 = 5
+					售后成功 = 50
+					取消成功 = 51
+					关闭 = 99
+					完成 = 100
+					**/
+				}
+				if ($this->db->trans_status() === TRUE)
+        		{
+					$this->db->trans_commit();
+					header('HTTP/1.1 200 OK');
+				}
+				else
+				{
+					$this->db->trans_rollback();
+				}
+			}
+		}
+	}
+}

Diff do ficheiro suprimidas por serem muito extensas
+ 1962 - 0
core/CoreApp/controllers/Apixw.php


+ 378 - 0
core/CoreApp/controllers/Apiyy.php

@@ -0,0 +1,378 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Apiyy extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_api','api');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_hl','hl');
+		$this->load->_model('Model_is','is');
+		$this->load->_model('Model_kdniao','kdniao');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_fullorderexcel','fullorderexcel');
+		$this->load->_model('Model_dhl','dhl');
+		$this->load->_model('Model_usps','usps');
+		$this->load->_model('Model_ups','ups');
+		$this->load->_model('Model_dhltest','dhltest');
+		$this->load->_model('Model_customer','customer');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_notice','notice');
+		$this->load->_model('Model_emaildata','emaildata');
+		$this->load->_model('Model_whlabel','whlabel');
+		$this->load->_model('Model_productdescribe','productdescribe');
+		$this->load->_model('Model_ljg','ljg');
+		$this->load->_model('Model_commodityread','commodityread');
+		$this->load->_model('Model_service','service');
+		$this->load->_model('Model_fedex','fedex');
+		$this->load->_model('Model_apismt','apismt');
+		$this->load->_model('Model_cne','cne');
+		$this->load->_model('Model_specialstock','specialstock');
+		$this->load->_model('Model_whlabellabel','whlabellabel');
+		$this->load->_model('Model_allocation','allocation');
+		$this->load->_model('Model_yswaybill','yswaybill');
+		$this->load->_model('Model_paypal','paypal');
+		$this->load->_model('Model_17track','17track');
+		$this->load->_model('Model_ck','ck');
+		$this->load->_model('Model_weight','weight');
+		$this->load->_model('Model_pay','pay');
+		$this->load->_model('Model_setting','setting');
+		$this->load->_model('Model_classid','classid');
+		$this->load->_model('Model_apitt','apitt');
+		$this->load->_model('Model_customertt','customertt');
+		$this->load->_model('Model_als','als');
+		$this->load->_model('Model_apiyy','apiyy');
+		$this->load->_model('Model_whlabel_fc','whlabel_fc');
+		$this->load->_model('Model_excel','excel');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'c')
+        {
+             $this->_c();
+        }
+		else if($arg == 'excel')
+        {
+             $this->_excel($arg_array);
+        }
+		else if($arg == 'rz')
+        {
+             $this->_rz($arg_array);
+        }
+    }
+	
+	
+	public function _excel($arg_array)
+	{
+		$filePath = './data/yyexcel/'.$arg_array[0].'/excel.txt';
+		$fileContent = file_get_contents($filePath);
+		if ($fileContent !== false) 
+		{
+			header( 'Content-Type: application/vnd.ms-excel; name=excel' ); 
+			header( 'Content-type: application/octet-stream' ); 
+			header( 'Content-Disposition: attachment; filename='.$arg_array[0].'.xls'); 
+			header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' ); 
+			header( 'Pragma: no-cache' ); 
+			header( 'Expires: 0' ); 
+    		echo $fileContent;
+		} 
+		else 
+		{
+			echo "文件无法读取";
+		}
+	}
+	
+	public function _rz($arg_array)
+	{
+		$a = './data/yylog/RK-'.$arg_array[0].'.txt';
+		if(is_file($a))
+		{
+			$myfile = fopen($a, "r") or die("Unable to open file!");
+            $bc = fread($myfile,filesize($a));
+            fclose($myfile);
+			$zt = explode('\n',trim($bc,'\n'));
+			//$bc = json_decode($bc,true);
+			$nr = array();
+			foreach($zt as $k=>$val)
+		    {
+				$xx = explode(' = ',trim($val,' = '));
+				if(stripos($xx[0],'RK-F') !== false)
+				{
+					$nr[$k][][0] = '入库发送';
+				}
+				else if(stripos($xx[0],'RK-J') !== false)
+				{
+					$nr[$k][][0] = '入库接收';
+				}
+				else if(stripos($xx[0],'SH-F') !== false)
+				{
+					$nr[$k][][0] = '审核发送';
+				}
+				else if(stripos($xx[0],'SH-J') !== false)
+				{
+					$nr[$k][][0] = '审核接收';
+				}
+				else if(stripos($xx[0],'DC-F') !== false)
+				{
+					$nr[$k][][0] = '调出发送';
+				}
+				else if(stripos($xx[0],'DC-J') !== false)
+				{
+					$nr[$k][][0] = '调出接收';
+				}
+				$nr[$k][][1] = $xx[1];
+			}
+			echo "<pre>";
+			print_r($nr);
+		}
+		else
+		{
+			echo '无';
+		}
+	}
+	
+	
+	
+	public function _c()
+	{
+		$asd = array();
+		$f = array('fullordersmt','fullordertt','fullorder');
+		foreach($f as $v)
+		{
+		    $d = $this->$v->find_all("librarytime > '".(time()-(5*24*3600))."' and (type = '13' or type = '16') and dbapi < 99");
+			if($d)
+			{
+		        $h = $this->_list($d,$v);
+			    foreach($h as $vv)
+			    {
+				    $x = 0;$c = 0;
+				    $xs = $this->apiyy->_cxxsdd($vv['0']);
+				    $chd = $this->apiyy->_cxchd($vv['0']);
+				    if(isset($xs['Data'][0]))
+				    {
+					    $vv[] = '成功';
+					    $x = 1;
+				    }
+				    else
+				    {
+				    	$vv[] = '无';
+				    }
+				    if(isset($chd['Data'][0]))
+				    {
+				    	$vv[] = '成功';
+					    $c = 1;
+				    }
+				    else
+				    {
+				    	$vv[] = '无';
+				    }
+				    if($x==1 && $c==1)
+				    {
+					    $this->$v->save(array('dbapi'=>99),$vv[4]);
+				    }
+				    $asd[] = $vv;
+				}
+			}
+		}
+		
+		$title = "表 ".date("Y-m-d"); 
+            $titlename = "<table border=1>
+            <tr><th colspan='6' align='left'><h3>".$title."<h3></th></tr>
+            <tr>
+            <td>编号</td>
+			<td>销售订单发送</td>
+			<td>销售订单接收</td>
+            <td>出货单发送</td>
+			<td>出货单接收</td>
+			<td>销售订单验证</td>
+            <td>出货单验证</td>
+            </tr>
+            </table>"; 
+            $filename = $title.".xls"; 
+			$tail = "\n"; 
+            $data = $this->excel->get_fz2_bc($asd,$titlename,$filename,$tail);
+			$orderinfo = time();
+			$pdtime = date('Y-m-d',time());
+			$folderPath = './data/yyexcel/'.$pdtime; // 文件夹路径
+			$permissions = 0777; // 权限设置
+			if (!file_exists($folderPath)) { mkdir($folderPath, $permissions); }//创建文件夹
+			file_exists($folderPath);
+			if(!is_file($folderPath."/".$orderinfo.".txt"))
+			{
+				$myfile = fopen($folderPath."/excel.txt", "w") or die("Unable to open file!");
+				fwrite($myfile, $data);
+				fclose($myfile);
+			}
+			else
+			{
+				$myfile = fopen($folderPath."/exce.txt", "a+") or die("Unable to open file!");
+				fwrite($myfile, $data);
+				fclose($myfile);
+			}
+	}
+	
+	public function _list($d,$fullorder)//获取订单列表
+	{
+		$xx = array();
+		foreach($d as $k=>$data)
+		{
+			$xx[$k] = array(0=>$data['number'],'xsf'=>'','xss'=>'','fhf'=>'','fhs'=>'',4=>$data['id']);
+			$kh = $this->shop->read($data['shop']);
+			$classid = $this->classid->sku();
+		    $tcall = $this->typeclass->find_all();
+			$typeclass = array();
+			foreach ($tcall as $v)
+			{
+				$tcjm[$v['id']] = array($v['jm'],$v['classid']);
+				$typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
+			}
+			$bm = '03';
+			$xysc = array();
+			$data['lh'] = array();
+			$scid = '';$cw = '';$lc = 0;
+			$sku = explode(';',trim($data['fpdata'],';'));
+			$whlabelsc = explode('|',trim($data['whlabel'],'|'));
+			foreach($sku as $key=>$val)
+			{
+				if(stripos($val,'-131-') !== false)
+				{
+					continue;
+				}
+				$pm = $classid;
+		    	$jm = $classid;
+				$bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
+				$features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$val);
+				$ts = explode('|',trim($features,'|'));
+				if(stripos($ts[0],',') !== false)
+				{
+					$ft = explode(',',$ts[0]);
+			    	$features = explode('-',trim($ft[1],'-'));
+					$features[] = $ft[0];
+				}
+				else
+				{
+					$features = explode('-',trim($ts[0],'-'));
+				}
+				foreach($features as $k=>$v)
+				{
+					if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
+					{
+						if($typeclass[$v]['bm'] != '')
+						{
+							$bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
+						
+						}
+					}
+					if($v != 0)
+					{
+						if(isset($pm[$typeclass[$v]['classid']]))
+						{
+							if($typeclass[$v]['title'] == '9A')
+							{
+								$pm[$typeclass[$v]['classid']] = '9A';
+							}
+							else if($typeclass[$v]['title'] == '10A')
+							{
+								$pm[$typeclass[$v]['classid']] = '10A';
+							}
+							else
+							{
+								$clzh = $typeclass[$v]['zh'];
+								if(stripos($typeclass[$v]['zh'],'|') !== false)
+								{
+									$clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
+									$clzh = $clzh[0];
+								}
+								$pm[$typeclass[$v]['classid']] = $clzh;
+							}
+						}
+						if(isset($jm[$typeclass[$v]['classid']]))
+						{
+							if($typeclass[$v]['jm'])
+							{
+						    	$jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
+							}
+						}
+					}
+				}
+				$jm = array_filter($jm);//去除空值
+				$jm = implode("-",$jm);
+				$pm = array_filter($pm);//去除空值
+				$zh = implode(" ",$pm);
+				$zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
+				$lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$ts[1],'zh'=>$zh,'bm'=>$bm.implode("",$bmpx)));
+				if(isset($lh['Data'][0]))
+				{
+					if($lh['Data'][0]['m_isSucess'] != 1)
+					{
+						if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
+						{
+							$xx[$k][1] = $lh;
+							$this->apiyy->insert(array('number'=>$data['number'],'error'=>$lh['Data'][0]['m_errorMsg'],'type'=>'料号','cs'=>$fullorder));
+							continue;
+						}
+					}
+				}
+				else
+				{
+					$this->apiyy->insert(array('number'=>$data['number'],'error'=>json_encode($lh),'type'=>'料号','cs'=>$fullorder));
+					continue;
+				}
+				$data['lh'][] = array('sku'=>$jm,'ts'=>$ts[2]);
+				if(stripos($val,'-131-') !== false)
+				{
+					continue;
+				}
+				if(stripos($val,'-126-') !== false)
+				{
+					$drck = '12003';//进入发条库
+				}
+				else if(stripos($val,'-127-') !== false)
+				{
+					$drck = '12004';//进入发块库
+				}
+				else
+				{
+					$drck = '12006';//其它进入完成库
+				}
+			}
+		    $data['yyid'] = $kh['yyid'];
+		    @$ay = $this->apiyy->_neworder($data,$classid,$tcall);
+			$xx[$k]['xsf'] = $ay['fs'];
+			$xx[$k]['xss'] = $ay['fh'];
+		    if($ay['c'] != 0)
+		    {
+				$this->$fullorder->save(array('dbapi'=>0),$data['id']);
+				$this->apiyy->insert(array('number'=>$data['number'],'type'=>'销售订单','error'=>$ay['error'],'cs'=>$fullorder));
+		    }
+			else
+		    {
+				$this->$fullorder->save(array('dbapi'=>99),$data['id']);
+				$chdfs = '';$chdjs = '';$chdcg = 0;
+				foreach($data['lh'] as $k=>$v)
+				{
+					$chd = array('number'=>$data['number'],'i'=>$k+1,'ts'=>$v['ts']);
+					$c = $this->apiyy->get_chd($chd);
+					$chdfs = $c['1'];
+					$chdjs = json_encode($c['0']);
+					if($c['Data'][0]['m_isSucess'] == 1)
+			    	{
+						$chdcg += 1;
+			        }
+				}
+				$xx[$k]['fhf'] = $chdfs;
+				$xx[$k]['fhs'] = $chdjs;
+			    if($chdcg == count($data['lh']))
+			    {
+					$cs = $this->$fullorder->save(array('dbapi'=>100),$data['id']);
+			    }
+		    }
+		}
+		return $xx;
+	}
+}

Diff do ficheiro suprimidas por serem muito extensas
+ 2629 - 0
core/CoreApp/controllers/Apt.php


+ 818 - 0
core/CoreApp/controllers/Apt2.php

@@ -0,0 +1,818 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+header("Access-Control-Allow-Origin: *");
+class Apt extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_whlabel','whlabel');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_productprice','productprice');
+		$this->load->_model('Model_excel','excel');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_kdniao','kdniao');
+		$this->load->_model('Model_notice','notice');
+		$this->load->_model('Model_dhl','dhl');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_user','user');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'fout')//出库页
+        {
+             $this->_fout();
+        }
+		else if($arg == 'printing')//打印操作
+        {
+             $this->_printing();
+        }
+		else if($arg == 'print')//打印操作
+        {
+             $this->_print();
+        }
+		else if($arg == 'fhd')//发货单
+        {
+             $this->_fhd($arg_array);
+        }
+		else if($arg == 'fhddata')//发货单
+        {
+             $this->_fhddata();
+        }
+		else if($arg == 'fpdata')//发货单
+        {
+             $this->_fpdata();
+        }
+		else if($arg == 'shop')//发货单
+        {
+             $this->_shop();
+        }
+		else if($arg == 'express')//发货单
+        {
+             $this->_express();
+        }
+		else if($arg == 'retreat')//发货单
+        {
+             $this->_retreat();
+        }
+		else if($arg == 'excel')//发货单
+        {
+             $this->_excel();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['userid']))
+		{
+			$userid = $this->input->post('userid',true);
+			$userpass = $this->input->post('userpass',true);
+			$password = sha1($userpass);
+			$user = $this->user->get_uid($userid);
+			if($user)
+			{
+				if($user['type'] == 2)
+				{
+					echo json_encode(array('msg'=>"账户已停用",'success'=>false));exit;
+				}
+				if($user['userpass'] == $password)
+				{
+                    $this->user->get_land($user);  //更新登录数据
+					echo json_encode(array('url'=>'?id='.$user['api'],'success'=>true));exit;
+				}
+				else
+				{
+					echo json_encode(array('msg'=>"用户或密码不正确",'success'=>false));exit;
+				}
+			}
+			else
+			{
+				echo json_encode(array('msg'=>"用户不正确",'success'=>false));exit;
+			}
+		}
+	}
+	//出库
+	public function _fout()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['order']))  
+		{
+			$time = time();
+			$order = $this->input->post('order',true);
+			$y = $this->fullorder->get_waybill($order);
+			if(!$y)
+			{
+				$y = $this->fullorder->get_number($order);
+				if(!$y)
+				{
+					 echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
+				}
+			}
+			if($y['libraryconfirm'] == 1)
+			{
+				echo json_encode(array('msg'=>$y['librarynot'],'success'=>false));exit;
+			}
+			if($y['library'] == 2)
+			{
+				echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作','success'=>false));exit;
+			}
+			if($this->fullorder->save(array('library'=>2,'librarytime'=>$time),$y['id']))
+        	{
+         		echo json_encode(array('success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
+        	}
+		}
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$shop = $this->input->post('shop',true);
+			$source = $this->input->post('source',true);
+			$orderinfo = $this->input->post('orderinfo',true);
+			$number = $this->input->post('number',true);
+			$library = $this->input->post('library',true);
+			$waybill = $this->input->post('waybill',true);
+			$express = $this->input->post('express',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
+			if($timetk && $timetj && $library == 2)
+            {
+                $where  .= " and librarytime > '$timetk' and librarytime < '$timetj'";
+            }
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($library)
+            {
+                $where  .= " and library = '$library'";
+            }
+			if($waybill)
+            {
+                $where  .= " and waybill = '$waybill'";
+            }
+			if($express)
+            {
+				$where  .= " and express = '$express'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+            //数据排序
+            $order_str = "librarytime desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				if($value['waybill'] == 0)
+				{
+					$info_list[$key]['waybill'] = "";
+				}
+				$express = $this->express->read($value['express']);
+				$info_list[$key]['express'] = $express['servicename'];
+				$warehouse = $this->warehouse->read($value['type']);
+				$info_list[$key]['type'] = $warehouse['title'];
+				if($value['print'] == 1)
+				{
+					$info_list[$key]['print'] = '不可打印';
+				}
+				else if($value['print'] == 2)
+				{
+					$info_list[$key]['print'] = '未打印';
+				}
+				else if($value['print'] == 3)
+				{
+					$info_list[$key]['print'] = '已打印';
+				}
+				if($value['library'] == 1)
+				{
+					$info_list[$key]['library'] = '<em class="c">未出库</em>';
+				}
+				else if($value['library'] == 2)
+				{
+					$info_list[$key]['library'] = '<em class="c">已出库</em>';
+				}
+				else if($value['library'] == 3)
+				{
+					$info_list[$key]['library'] = '<em class="c">已退库</em>';
+				}
+				if($value['librarytime'] == '0')
+				{
+					$info_list[$key]['librarytime'] = '<em class="t"></em>';
+				}
+				else
+				{
+					$info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
+				}
+            }
+		    $total = $this->fullorder->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->data['express'] = $this->express->find_all();
+		$this->_Template('whlabel_fout',$this->data);
+	}
+	//退库
+	public function _retreat()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['order']))  
+		{
+			$time = time();
+			$order = $this->input->post('order',true);
+			$y = $this->fullorder->get_waybill($order);
+			if(!$y)
+			{
+				$y = $this->fullorder->get_number($order);
+				if(!$y)
+				{
+					 echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
+				}
+			}
+			if($y['library'] == 3)
+			{
+				echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['retreattime']).' 已操作','success'=>false));exit;
+			}
+			if($y['library'] == 1)
+			{
+				echo json_encode(array('msg'=>'此数据未出库','success'=>false));exit;
+			}
+			if($this->fullorder->save(array('library'=>3,'retreattime'=>$time),$y['id']))
+        	{
+         		echo json_encode(array('success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'退库失败,请重试','success'=>false));exit;
+        	}
+		}
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$shop = $this->input->post('shop',true);
+			$source = $this->input->post('source',true);
+			$orderinfo = $this->input->post('orderinfo',true);
+			$number = $this->input->post('number',true);
+			$waybill = $this->input->post('waybill',true);
+			$express = $this->input->post('express',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "library=3 and gtime > 20190127";
+			if($timetk && $timetj)
+            {
+                $where  .= " and retreattime > '$timetk' and retreattime < '$timetj'";
+            }
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($waybill)
+            {
+                $where  .= " and waybill = '$waybill'";
+            }
+			if($express)
+            {
+				$where  .= " and express = '$express'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+            //数据排序
+            $order_str = "retreattime desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,state,retreattime',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				if($value['waybill'] == 0)
+				{
+					$info_list[$key]['waybill'] = "";
+				}
+				$express = $this->express->read($value['express']);
+				$info_list[$key]['express'] = $express['servicename'];
+				$warehouse = $this->warehouse->read($value['type']);
+				$info_list[$key]['type'] = $warehouse['title'];
+				$typeclass = $this->typeclass->read($value['state']);
+				$info_list[$key]['state'] = $typeclass['spare'];
+				if($value['print'] == 1)
+				{
+					$info_list[$key]['print'] = '不可打印';
+				}
+				else if($value['print'] == 2)
+				{
+					$info_list[$key]['print'] = '未打印';
+				}
+				else if($value['print'] == 3)
+				{
+					$info_list[$key]['print'] = '已打印';
+				}
+				if($value['retreattime'] == '0')
+				{
+					$info_list[$key]['retreattime'] = '<em class="t"></em>';
+				}
+				else
+				{
+					$info_list[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
+				}
+				
+            }
+		    $total = $this->fullorder->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->data['express'] = $this->express->find_all();
+		$this->_Template('whlabel_fout',$this->data);
+	}
+	//打印页面
+	public function _print()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$shop = $this->input->post('shop',true);
+			$print = $this->input->post('print',true);
+			$express = $this->input->post('express',true);
+			$waybill = $this->input->post('waybill',true);
+			$printtype = $this->input->post('printtype',true);
+			$orderinfo = $this->input->post('orderinfo',true);
+			$number = $this->input->post('number',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "type = 1 and express != 0 and printtype > 0 and printtype < 3 and print != 1 and review > 4";
+			if($timetk && $timetj && $print == 3)
+            {
+                $where  .= " and printtime > '$timetk' and printtime < '$timetj'";
+            }
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($print)
+            {
+				if($print == 2)
+				{
+                    $where  .= " and state = 207 and print = '$print'";
+				}
+				else
+				{
+					$where  .= " and print = '$print'";
+				}
+            }
+			if($express)
+            {
+				$where  .= " and express = '$express'";
+            }
+			if($printtype)
+            {
+                $where  .= " and printtype = '$printtype'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($waybill)
+            {
+                $where  .= " and waybill = '$waybill'";
+            }
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				$express = $this->express->read($value['express']);
+				if($express)
+				{
+				    $info_list[$key]['express'] = $express['servicename'];
+				}
+				else
+				{
+					$info_list[$key]['express'] = '未选择';
+				}
+				if($value['printtime'] != 0)
+				{
+				    $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
+				}
+				else
+				{
+					$info_list[$key]['printtime'] = '无';
+				}
+				if($value['print'] == 1)
+				{
+					$info_list[$key]['print'] = "禁止打印";
+				}
+				else if($value['print'] == 2)
+				{
+					$info_list[$key]['print'] = "未打印";
+				}
+				else if($value['print'] == 3)
+				{
+					$info_list[$key]['print'] = "已打印";
+				}
+				if($value['printtype'] == 1)
+				{
+					$info_list[$key]['printtype'] = "运单";
+				}
+				else if($value['printtype'] == 2)
+				{
+					$info_list[$key]['printtype'] = "发货单";
+				}
+				else if($value['printtype'] == 0)
+				{
+					$info_list[$key]['printtype'] = "未选择";
+				}
+            }
+		    $total = $this->fullorder->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('whlabel_print',$this->data);
+	}
+	//打印
+	public function _printing()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		$dhlover = 1;
+		if(isset($post['s']))  
+		{
+			$v = $this->input->post('s');
+			$va = explode(',',rtrim($v,','));
+			$n = $this->input->post('n');
+            $fullorder = $this->fullorder->read($va[$n]);
+			$exp = $this->express->read($fullorder['express']);//获取快递信息
+			if($fullorder['printtype'] == 1)
+			{
+				//获取所用相关信息
+				$warehouse = $this->warehouse->read($fullorder['type']);
+				$al = $this->country->read($warehouse['country']);
+				foreach ($warehouse as $kk=>$vv)
+		        {
+				    $warehouse['al'] = $al['lb'];
+				}
+				$fullorder['baddress'] = explode(',',$fullorder['baddress']);
+				$fullorder['baddress'] = array_reverse($fullorder['baddress']);
+				$country = $this->country->get_al($fullorder['baddress'][1]);
+				$fullorder['baddress'][1] = $country['ename'];
+				$fcountry = $this->country->read($warehouse['country']);
+				$warehouse['country'] = $fcountry['ename'];
+				$fullorder['warehouse'] = $warehouse;
+				$fullorder['al'] = $country['lb'];//收货加改联邦名 此项过完春节口可以去掉,之前订单同步没添加此项
+				$fullorder['country'] = $country['ename'];
+				//获取完毕
+				if($exp['servicecode'] == "DHLGF")//如果打印过那么重新获取运单
+				{
+				   	$barcode = $this->dhl->get_data($fullorder);//获取DHL快递信息
+					if(isset($barcode['AirwayBillNumber']))
+					{
+						$Hwaybill = $barcode['AirwayBillNumber'];
+						$Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f'.$Hwaybill);
+					    $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y'.$Hwaybill);
+					}
+					else if(isset($barcode['Response']['Status']['Condition']['ConditionData']))
+					{
+						$dhlover = $barcode['Response']['Status']['Condition']['ConditionData'];
+					}
+					else if(isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
+					{
+						$dhlover = $barcode['Response']['Status']['Condition'][0]['ConditionData'];
+					}
+
+else
+{
+$dhlover = "错误!";
+}
+				}
+				if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
+				{
+					if($this->fullorder->save(array('waybill'=>$Hwaybill,'fp'=>$Hfp,'yd'=>$Hyd,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>time(),'printnumber'=>$fullorder['printnumber']+1,'print'=>3),$va[$n]))
+				    {
+						$rows = array('type'=>1,'t'=>11000,'n'=>$n-1,'data'=>$v,'rows'=>array('1'=>$Hfp,'0'=>$Hyd,'2'=>$va[$n]));
+					}
+
+				}
+			}
+			else if($fullorder['printtype'] == 2)
+			{
+				if($this->fullorder->save(array('libraryconfirm'=>2,'librarynot'=>'','printtime'=>time(),'printnumber'=>$fullorder['printnumber']+1,'print'=>3),$va[$n]))
+				{
+					$country = $this->country->read($fullorder['country']);
+					$rows = array('type'=>2,'fhd'=>$va[$n],'t'=>3000,'n'=>$n-1,'data'=>$v);
+				}
+			}
+			if(isset($rows))
+			{
+				echo json_encode(array('rows'=>($rows),'success'=>true));exit;
+			}
+			else
+			{
+				if($dhlover != 1)
+				{
+					echo json_encode(array('msg'=>"订单号:".$fullorder['orderinfo']." - ".$dhlover,'success'=>false));exit;
+				}
+				else
+				{
+				    echo json_encode(array('msg'=>"订单号:".$fullorder['orderinfo']."打印类型错误!请跳过!",'success'=>false));exit;
+				}
+			}
+		}
+	}
+	public function _excel()
+	{
+		if(isset($_GET['fexcel']))  
+		{
+			$dowid = $this->input->get('a');
+			$wid = "";
+			if($dowid != "")
+			{
+				$id_arr =  explode(',',rtrim($dowid,','));
+				foreach ($id_arr as $v) 
+		        {
+					$wid  .= " id = 0 or";
+                    $wid  .= " id = '$v' or";
+                }
+				$wid = " and".rtrim($wid,'or');
+			}
+		    $t = $this->input->get('t',true);
+			$timetk = $this->input->get('timetk',true);
+			$timetj = $this->input->get('timetj',true);
+			$shop = $this->input->get('shop',true);
+			$source = $this->input->get('source',true);
+			$orderinfo = $this->input->get('orderinfo',true);
+			$number = $this->input->get('number',true);
+			$library = $this->input->get('library',true);
+			$waybill = $this->input->get('waybill',true);
+			$express = $this->input->get('express',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
+			if($timetk && $timetj && $library == 2)
+            {
+                $where  .= " and librarytime > '$timetk' and librarytime < '$timetj'";
+            }
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($library)
+            {
+                $where  .= " and library = '$library'";
+            }
+			if($waybill)
+            {
+                $where  .= " and waybill = '$waybill'";
+            }
+			if($express)
+            {
+				$where  .= " and express = '$express'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+            //数据排序
+            $order_str = "librarytime desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime',$order_str);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				if($value['waybill'] == 0)
+				{
+					$info_list[$key]['waybill'] = "";
+				}
+				$express = $this->express->read($value['express']);
+				$info_list[$key]['express'] = $express['servicename'];
+				$warehouse = $this->warehouse->read($value['type']);
+				$info_list[$key]['type'] = $warehouse['title'];
+				if($value['print'] == 1)
+				{
+					$info_list[$key]['print'] = '不可打印';
+				}
+				else if($value['print'] == 2)
+				{
+					$info_list[$key]['print'] = '未打印';
+				}
+				else if($value['print'] == 3)
+				{
+					$info_list[$key]['print'] = '已打印';
+				}
+				if($value['library'] == 1)
+				{
+					$info_list[$key]['library'] = '<em class="c">未出库</em>';
+				}
+				else if($value['library'] == 2)
+				{
+					$info_list[$key]['library'] = '<em class="c">已出库</em>';
+				}
+				else if($value['library'] == 3)
+				{
+					$info_list[$key]['library'] = '<em class="c">已退库</em>';
+				}
+				if($value['librarytime'] == '0')
+				{
+					$info_list[$key]['librarytime'] = '<em class="t"></em>';
+				}
+				else
+				{
+					$info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
+				}
+            }
+            $title = '订单出库-'.date('Ymd',time());
+            $titlename = "<table border=1>".$t."</table>";
+			$tail = "\n";
+            $filename = $title.".xls";
+            $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
+		}
+	}
+	public function _pdf($pdf,$title)
+    {
+		$time = date('Ymd',time());
+    	$pdf_path = './data/pdf/'.$time.'/';
+        $file_base64 = $pdf; 
+        $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);  
+        $file_base64 = base64_decode($file_base64);
+		if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
+        file_put_contents($pdf_path.$title.'.pdf',$file_base64);
+		return 'data/pdf/'.$time.'/'.$title.'.pdf';
+    }
+	public function _fhd($arg_array)
+    {
+		$id = $arg_array[0];
+		$data = $this->fullorder->read($id);
+		$country = $this->country->read($data['country']);
+		$express = $this->express->read($data['express']);
+		$data['country'] = $country['ename'];
+		$data['express'] = $express['servicename'];
+		$this->data['data'] = $data;
+		$this->_Template('apt_fhd',$this->data);
+    }
+	public function _fhddata()
+    {
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['g']))  
+		{
+			$id = $this->input->post('g',true);
+			$data = $this->fullorder->read($id);
+			$country = $this->country->read($data['country']);
+			$express = $this->express->read($data['express']);
+			$data['country'] = $country['ename'];
+			$data['express'] = $express['servicename'];
+			echo json_encode(array('express'=>$data['express'],'orderinfo'=>$data['orderinfo'],'country'=>$data['country'],'number'=>$data['number'],'shipremarks'=>$data['shipremarks'],'ts'=>$data['ts'],'printnumber'=>$data['printnumber'],'barcode'=>'<img id="imgId" src="http://'.$_SERVER['HTTP_HOST'].$data['barcode'].'" style="width:75%;margin: 10px 0 0 70px;" />','success'=>true));exit;
+		}
+    }
+	public function _fpdata()
+    {
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['g']))  
+		{
+			$id = $this->input->post('g',true);
+			$fullorder = $this->fullorder->read($id);
+			$warehouse = $this->warehouse->read($fullorder['type']);
+			$al = $this->country->read($warehouse['country']);
+			foreach ($warehouse as $kk=>$vv)
+		    {
+				$warehouse['al'] = $al['lb'];
+			}
+			$fullorder['baddress'] = explode(',',$fullorder['baddress']);
+			$fullorder['baddress'] = array_reverse($fullorder['baddress']);
+			$country = $this->country->get_al($fullorder['baddress'][1]);
+			$fullorder['baddress'][1] = $country['ename'];
+			$fcountry = $this->country->read($warehouse['country']);
+			$warehouse['country'] = $fcountry['ename'];
+			$fullorder['warehouse'] = $warehouse;
+			$fullorder['al'] = $country['lb'];
+			$fullorder['country'] = $country['ename'];
+			$fullorder['time'] = date('Y-m-d',time());
+			$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
+			$fullorder['adr'] = 0;
+			if(strlen($fullorder['address'].$fullorder['address2']) > 44)
+			{
+				$adl = $fullorder['address'].$fullorder['address2'];
+				$adl1 = substr($adl,0,44);//截取44字符前内容
+				$adlnum = strripos($adl1," ");//查找最后一次出现空格位置
+				$adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容
+				$adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容
+				$fullorder['adr'] = 1;
+				$fullorder['adr1'] = $adl1;
+				$fullorder['adr2'] = $adl2;
+			}
+			echo json_encode(array('data'=>$fullorder,'success'=>true));exit;
+		}
+    }
+	public function _shop()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['shop']))  
+		{
+		    $shop = $this->shop->find_all();
+		    echo json_encode(array('msg'=>$shop));exit;
+		}
+	}
+	public function _express()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['express']))  
+		{
+		    $express = $this->express->find_all();
+		    echo json_encode(array('msg'=>$express));exit;
+		}
+	}
+}

Diff do ficheiro suprimidas por serem muito extensas
+ 1278 - 0
core/CoreApp/controllers/Aptsmt.php


+ 477 - 0
core/CoreApp/controllers/Bh.php

@@ -0,0 +1,477 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Bh extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_whlabel','whlabel');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_purchase','purchase');
+		$this->load->_model('Model_excel','excel');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullorder_smt','fullorder_smt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_kdniao','kdniao');
+		$this->load->_model('Model_notice','notice');
+		$this->load->_model('Model_dhl','dhl');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_fullorderexcel','fullorderexcel');
+		$this->load->_model('Model_ljg','ljg');
+		$this->load->_model('Model_usps','usps');
+		$this->load->_model('Model_specialstock','specialstock');
+		$this->load->_model('Model_whlabellabel','whlabellabel');
+		$this->load->_model('Model_whlabelwz','whlabelwz');
+		$this->load->_model('Model_whlabelbarcode','whlabelbarcode');
+		$this->load->_model('Model_bh','bh');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'xr')//在库标签
+        {
+             $this->_xr();
+        }
+		else if($arg == 'exceljs')
+        {
+             $this->_exceljs();
+        }
+		else if($arg == 'uck')
+        {
+             $this->_uck();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+	//进销存浏览
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$category = $this->input->post('category',true);
+			$size = $this->input->post('size',true);
+			$grade = $this->input->post('grade',true);
+			$color = $this->input->post('color',true);
+			$lowe = $this->input->post('lowe',true);
+			$sku = $this->input->post('sku',true);
+			$warehouse = $this->input->post('warehouse',true);
+			$usa = $this->input->post('usa',true);
+			$purchase = $this->input->post('purchase',true);
+			$lacetype = $this->input->post('lacetype',true);
+			$state = $this->input->post('state',true);
+			$px = $this->input->post('px',true);
+			$ktime = $this->input->post('ktime',true);
+			$jtime = $this->input->post('jtime',true);
+			//$ktime = strtotime($ktime);
+			//$jtime = strtotime($jtime);
+			$where = "1=1";$gj = "";$ck = "";
+			if($lacetype)
+            {
+                $where  .= " and features like '%-$lacetype-%'";
+            }
+			if($category)
+            {
+                $where  .= " and features like '%-$category-%'";
+            }
+			if($size)
+            {
+                $where  .= " and features like '%-$size-%'";
+            }
+			if($grade)
+            {
+                $where  .= " and features like '%-$grade-%'";
+            }
+			if($color)
+            {
+                $where  .= " and features like '%-$color-%'";
+            }
+			if($lowe)
+            {
+                $where  .= " and features like '%-$lowe-%'";
+            }
+			if($usa)
+            {
+				if(!$warehouse)
+				{
+                    $where  .= " and (warehouse = '5' or warehouse = '8')";
+				}
+            }
+			if($warehouse)
+            {
+                $where  .= " and warehouse = '$warehouse'";
+            }
+			if($purchase)
+            {
+                $where  .= " and purchase = '$purchase'";
+            }
+			if($state)
+            {
+                $where  .= " and state = '$state'";
+            }
+			
+			if($ktime && $jtime)
+            {
+                $gj  = " and enter > '$ktime' and enter < '$jtime'";
+				$ck  = " and outk > '$ktime' and outk < '$jtime'";
+            }
+            //数据排序
+            if($px == 'ksts')
+			{
+				$order_str = "ksts asc,jybh desc";
+				$where .= " and jybh > 0";
+			}
+			else
+			{
+				$order_str = $px." desc";
+			}
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			if($sku)
+            {
+                $where  .= " and sku like '%$sku%'";
+				$info_list = $this->bh->find_all($where,'id,sku,title,t1,t3,t7,t14,t30,t60,t90,jybh,ksts',$order_str,$start,$perpage);
+            }
+			else
+			{
+				$info_list = $this->bh->find_all($where,'id,sku,title,t1,t3,t7,t14,t30,t60,t90,jybh,ksts',$order_str,$start,$perpage);
+			}
+            foreach ($info_list as $key=>$value) 
+		    {
+				if($value['jybh'] == '0')
+				{
+					$info_list[$key]['jybh'] = '无';
+				}
+			}
+			$rows = array();$list = array();
+		    $total = count($this->bh->find_all($where));
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('bh',$this->data);
+	}
+	
+	//进销存浏览
+	public function _xr()//数据写入
+	{
+	    $this->db->query("delete from crowd_bh");
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($_GET['xr']))  
+		{
+			$info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,title,number');
+			$this->db->trans_begin();
+			foreach ($info_list as $key=>$value) 
+		    {
+				$c = $this->whlabel->find_count('warehouse = "5" and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and number = "'.$value['number'].'"');
+				$info_list[$key]['t1'] = 0;
+				$info_list[$key]['t3'] = 0;
+				$info_list[$key]['t7'] = 0;
+				$info_list[$key]['t14'] = 0;
+				$info_list[$key]['t30'] = 0;
+				$info_list[$key]['t60'] = 0;
+				$info_list[$key]['t90'] = 0;
+				$fullorder = $this->fullorder->find_all("whlabel like '%".$value['number']."%' and librarytime > '".(strtotime(date("Y-m-d",time()))-90*24*3600)."'",'whlabel,librarytime');
+				$fullordersmt = $this->fullordersmt->find_all("whlabel like '%".$value['number']."%' and librarytime > '".(strtotime(date("Y-m-d",time()))-90*24*3600)."'",'whlabel,librarytime');
+				$data = array_merge($fullorder,$fullordersmt);
+				foreach ($data as $val) 
+		        {
+					$dt = explode('|',trim($val['whlabel'],'|'));
+					foreach ($dt as $v) 
+		            {
+						$v = explode('-',$v);
+						if($v[0] == $value['number'])
+						{
+							if($val['librarytime'] > (strtotime(date("Y-m-d",time()))-24*3600))
+							{
+								$info_list[$key]['t1'] += $v[1];
+							}
+							if($val['librarytime'] > (strtotime(date("Y-m-d",time()))-3*24*3600))
+							{
+								$info_list[$key]['t3'] += $v[1];
+							}
+							if($val['librarytime'] > (strtotime(date("Y-m-d",time()))-7*24*3600))
+							{
+								$info_list[$key]['t7'] += $v[1];
+							}
+							if($val['librarytime'] > (strtotime(date("Y-m-d",time()))-14*24*3600))
+							{
+								$info_list[$key]['t14'] += $v[1];
+							}
+							if($val['librarytime'] > (strtotime(date("Y-m-d",time()))-30*24*3600))
+							{
+								$info_list[$key]['t30'] += $v[1];
+							}
+							if($val['librarytime'] > (strtotime(date("Y-m-d",time()))-60*24*3600))
+							{
+								$info_list[$key]['t60'] += $v[1];
+							}
+							if($val['librarytime'] > (strtotime(date("Y-m-d",time()))-90*24*3600))
+							{
+								$info_list[$key]['t90'] += $v[1];
+							}
+						}
+					}
+					
+				}
+				if($info_list[$key]['t30'] > 0)
+				{
+				    $mt = $info_list[$key]['t30']/30;
+				    $info_list[$key]['ksts'] = intval($c/$mt);
+				    $info_list[$key]['jybh'] = ($info_list[$key]['ksts'] < 30)?($info_list[$key]['t30'] - $c):0;
+				}
+				else
+				{
+					$info_list[$key]['ksts'] = 0;
+				    $info_list[$key]['jybh'] = 0;
+				}
+				$this->bh->insert($info_list[$key]);
+		    }
+			if ($this->db->trans_status() === TRUE)
+            {
+			    $this->db->trans_commit();
+			    echo 'OK';
+		    }
+		    else
+		    {
+			    $this->db->trans_rollback();
+			    echo 'orver';
+		    }
+		}
+	}
+	
+	public function _exceljs()
+	{
+		if(isset($_GET['excel']))  
+		{
+			$page = $this->input->get('page',true);
+		    $perpage = $this->input->get('perpage',true);
+			$category = $this->input->get('category',true);
+			$size = $this->input->get('size',true);
+			$grade = $this->input->get('grade',true);
+			$color = $this->input->get('color',true);
+			$lowe = $this->input->get('lowe',true);
+			$sku = $this->input->get('sku',true);
+			$warehouse = $this->input->get('warehouse',true);
+			$usa = $this->input->get('usa',true);
+			$purchase = $this->input->get('purchase',true);
+			$lacetype = $this->input->get('lacetype',true);
+			$state = $this->input->get('state',true);
+			$px = $this->input->get('px',true);
+			$ktime = $this->input->get('ktime',true);
+			$jtime = $this->input->get('jtime',true);
+			//$ktime = strtotime($ktime);
+			//$jtime = strtotime($jtime);
+			$where = "1=1";$gj = "";$ck = "";
+			if($lacetype)
+            {
+                $where  .= " and features like '%-$lacetype-%'";
+            }
+			if($category)
+            {
+                $where  .= " and features like '%-$category-%'";
+            }
+			if($size)
+            {
+                $where  .= " and features like '%-$size-%'";
+            }
+			if($grade)
+            {
+                $where  .= " and features like '%-$grade-%'";
+            }
+			if($color)
+            {
+                $where  .= " and features like '%-$color-%'";
+            }
+			if($lowe)
+            {
+                $where  .= " and features like '%-$lowe-%'";
+            }
+			if($usa)
+            {
+				if(!$warehouse)
+				{
+                    $where  .= " and (warehouse = '5' or warehouse = '8')";
+				}
+            }
+			if($warehouse)
+            {
+                $where  .= " and warehouse = '$warehouse'";
+            }
+			if($purchase)
+            {
+                $where  .= " and purchase = '$purchase'";
+            }
+			if($state)
+            {
+                $where  .= " and state = '$state'";
+            }
+			
+			if($ktime && $jtime)
+            {
+                $gj  = " and enter > '$ktime' and enter < '$jtime'";
+				$ck  = " and outk > '$ktime' and outk < '$jtime'";
+            }
+            //数据排序
+			if($px == 'ksts')
+			{
+				$order_str = "ksts asc,jybh desc";
+				$where .= " and jybh > 0";
+			}
+			else
+			{
+				$order_str = $px." desc";
+			}
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			if($sku)
+            {
+                $where  .= " and sku like '%$sku%'";
+				$info_list = $this->bh->find_all($where,'sku,title,t1,t3,t7,t14,t30,t60,t90,jybh,ksts',$order_str);
+            }
+			else
+			{
+				$info_list = $this->bh->find_all($where,'sku,title,t1,t3,t7,t14,t30,t60,t90,jybh,ksts',$order_str);
+			}
+			/**
+			foreach ($info_list as $key=>$value) 
+		    {
+				$warehouse = $this->warehouse->read($value['warehouse']);
+				$info_list[$key]['warehouse'] = $warehouse['title'];
+			}
+			**/
+			foreach ($info_list as $key=>$value) 
+		    {
+				if($value['jybh'] == '0')
+				{
+					$info_list[$key]['jybh'] = '无';
+				}
+			}
+            $title = "备货详情 ".date("Y-m-d",time()); 
+            $titlename = "<table border=1>
+            <tr align='center'>
+			<td>SKU</td>
+			<td>产品名称</td>
+			<td>昨天销量</td>
+			<td>3天销量</td>
+			<td>7天销量</td>
+			<td>14天销量</td>
+			<td>30天销量</td>
+			<td>60天销量</td>
+			<td>90天销量</td>
+			<td>建议备货</td>
+			<td>可售天数</td>
+            </tr>
+            </table>"; 
+            $filename = $title.".xls";
+			$tail = "";
+            $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
+	    }
+	}
+	
+	public function _uck()
+	{
+		if(isset($_GET['excel']))
+		{
+			$tc = array();
+			$typeclass = $this->typeclass->find_all();
+			foreach ($typeclass as $v) 
+		    {
+				$tc[$v['id']] = $v['zh'];
+			}
+			$data = array();$t = array();$rq = '';
+			$ts = strtotime(date("Y-m-d",time()))-strtotime(date("Y-m",time()));
+			$ts = $ts/(24*3600);
+			for($i=0;$i<$ts;$i++)
+			{
+				$t[] = date("Y-m-d",strtotime('-'.($ts-$i).' day'));
+				$rq .=  "<td>".date("Y-m-d",strtotime('-'.($ts-$i).' day'))."</td>";
+			}
+			$info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,features');
+			foreach ($info_list as $k=>$v) 
+		    {
+				$features = explode('-',trim($v['features'],'-'));
+				if(!isset($features[3]) || !isset($features[4]))
+				{
+					continue;
+				}
+				$data[$k][0] = $tc[$features[0]];//类型
+				$data[$k][1] = ($features[3] != 57)?$tc[$features[3]]:'';//颜色,自然色不显示
+				$data[$k][2] = $tc[$features[4]];//曲度
+				$data[$k][3] = '';
+				if(isset($data[$k][1]))
+				{
+					$data[$k][3] .= $data[$k][1];
+				}
+				if(isset($data[$k][2]))
+				{
+					$data[$k][3] .= $data[$k][2];
+				}
+				if(isset($features[5]))
+				{
+					$data[$k][3] .= $tc[$features[5]];
+				}
+				if(isset($features[2]))
+				{
+					$data[$k][3] .= $tc[$features[2]];
+				}
+				//$data[$k][3] 颜色,曲度,头套种类,尺寸
+				$data[$k][4] = $v['sku'];
+				$data[$k][5] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and (state = 0 or (state = 1 and outk > '.strtotime(date("Y-m",time())).'))');//月初库存
+				$data[$k][] = $this->whlabel->find_count('warehouse = "5" and sku = "'.$v['sku'].'" and state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');//剩余库存
+				$data[$k][] = '';
+				$data[$k][] = '';
+				$byck = 0;
+				foreach ($t as $vv) 
+		        {
+					$sl = $this->whlabel->find_count('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and state = 1 and outk > '.strtotime($vv).' and outk < '.(strtotime($vv)+24*3600));
+					$data[$k][] = ($sl > 0)?'<b>'.$sl.'</b>':'';
+					$byck += $sl;
+				}
+				$data[$k][] = ($byck > 0)?$byck:'';
+			}
+			
+            $title = "详情 ".date("Y-m-d",time());
+            $titlename = "<table border=1>
+            <tr align='center'>
+			<td>类别</td>
+			<td>颜色</td>
+			<td>曲度</td>
+			<td>名称</td>
+			<td>SKU</td>
+			<td>月初库存</td>
+			<td>剩余库存</td>
+			<td>在途数量</td>
+			<td>预达日期</td>".
+			$rq
+			."<td>本月出库</td></tr>
+            </table>"; 
+            $filename = $title.".xls";
+			$tail = "";
+            $this->excel->get_fz2($data,$titlename,$filename,$tail);
+	    }
+	}
+}

Diff do ficheiro suprimidas por serem muito extensas
+ 1635 - 0
core/CoreApp/controllers/Boss.php


+ 157 - 0
core/CoreApp/controllers/Brand.php

@@ -0,0 +1,157 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Brand extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_user','user');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_brand','brand');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$title = $this->input->post('title',true);
+			$where = "1=1 ";
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			if($title)
+			{
+				$where .= " and title = '$title'";
+			}
+            //取得信息列表
+            $info_list = $this->brand->find_all($where,'id,title,shop',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$t = '';
+				$shop = explode('|',trim($value['shop'],'|'));
+				if($shop)
+				{
+					foreach ($shop as $v) 
+		            {
+						$s = $this->shop->read($v);
+						$t .= $s['shopname'].', ';
+					}
+					$info_list[$key]['shop'] = rtrim($t,', ');
+				}
+				else
+				{
+					$info_list[$key]['shop'] = '没有关联店铺';
+				}
+            }
+		    $total = $this->brand->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('brand',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['title']))
+		{
+			$post['title'] = $this->input->post('title',true);
+			$shop = $this->input->post('shop',true);
+			if($shop)
+			{
+				$shop = trim($shop,',');
+				$post['shop'] = "|".str_replace(',','|',$shop)."|";
+			}
+			if($this->brand->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('brand_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['title'] = $this->input->post('title',true);
+			$shop = $this->input->post('shop',true);
+			if($shop)
+			{
+				$shop = trim($shop,',');
+				$post['shop'] = "|".str_replace(',','|',$shop)."|";
+			}
+			if($this->brand->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$brand = $this->brand->read($arg_array);
+		$this->data['brand'] = $brand;
+		$this->_Template('brand_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->brand->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 171 - 0
core/CoreApp/controllers/Caiwusfh.php

@@ -0,0 +1,171 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Caiwusfh extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_caiwusfh','caiwusfh');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')
+		{
+			$this->_edit($arg_array);
+		}
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$orderno = $this->input->post('orderno',true);
+			$ht = $this->input->post('ht',true);
+			$sfh = $this->input->post('sfh',true);
+			$apptype = $this->input->post('apptype',true);
+			$appstatus = $this->input->post('appstatus',true);
+			$charge = $this->input->post('charge',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "1=1 ";
+			if($timetk && $timetj)
+            {
+                $where  .= " and createtime > '$timetk' and createtime < '$timetj'";
+            }
+			if($orderno)
+            {
+                $where  .= " and orderno = '$orderno'";
+            }
+			if($ht)
+            {
+                $where  .= " and ht = '$ht'";
+            }
+			if($sfh)
+            {
+                $where  .= " and sfh = '$sfh'";
+            }
+			if($apptype)
+            {
+                $where  .= " and apptype = '$apptype'";
+            }
+			if($appstatus)
+            {
+                $where  .= " and appstatus = '$appstatus'";
+            }
+			if($charge)
+            {
+                $where  .= " and charge = '$charge'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->caiwusfh->find_all($where,'id,orderno,ht,sfh,apptype,appstatus,charge,createtime',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				if($value['sfh'] == '1')
+				{
+					$info_list[$key]['sfh'] = '付汇';
+				}
+				else if($value['sfh'] == '2')
+				{
+					$info_list[$key]['sfh'] = '收汇';
+				}
+				if($value['apptype'] == '1')
+				{
+					$info_list[$key]['apptype'] = '新增';
+				}
+				else if($value['apptype'] == '2')
+				{
+					$info_list[$key]['apptype'] = '变更';
+				}
+				else if($value['apptype'] == '3')
+				{
+					$info_list[$key]['apptype'] = '删除';
+				}
+				if($value['appstatus'] == '1')
+				{
+					$info_list[$key]['appstatus'] = '暂存';
+				}
+				else if($value['appstatus'] == '2')
+				{
+					$info_list[$key]['appstatus'] = '申报';
+				}
+				$info_list[$key]['createtime'] = date('Y-m-d h:i:s',$value['createtime']);
+            }
+		    $total = $this->caiwusfh->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('caiwusfh',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['createtime']))
+		{
+			$createtime = $this->input->post('createtime',true);
+			$post['createtime'] = strtotime($createtime);
+			
+			$accountingdate = $this->input->post('accountingdate',true);
+			$post['accountingdate'] = strtotime($accountingdate);
+			if($this->caiwusfh->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('caiwusfh_add',$this->data);
+	}
+	
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$createtime = $this->input->post('createtime',true);
+			$post['createtime'] = strtotime($createtime);
+			$accountingdate = $this->input->post('accountingdate',true);
+			$post['accountingdate'] = strtotime($accountingdate);
+			if($this->caiwusfh->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$caiwusfh = $this->caiwusfh->read($arg_array);
+		$this->data['caiwusfh'] = $caiwusfh;
+		$this->_Template('caiwusfh_edit',$this->data);
+	}
+}

+ 24 - 0
core/CoreApp/controllers/Choice.php

@@ -0,0 +1,24 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Choice extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		 if($arg == 'Choices')
+        {
+             $this->_Choices($arg_array);
+        }
+		else
+        {
+             $this->_Choice($arg);
+        }
+    }
+	public function _Choice($arg)//查找重复
+	{
+		$this->data['arg'] = $arg;
+		$this->_Template('choice',$this->data);
+	}
+
+}

+ 60 - 0
core/CoreApp/controllers/Ck.php

@@ -0,0 +1,60 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Ck extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->_model('Model_ck','ck');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_specialstock','specialstock');
+		$this->load->_model('Model_whlabel','whlabel');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_whlabel_fc','whlabel_fc');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'kcyz')//添加
+        {
+             $this->_kcyz();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	public function _kcyz()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['warehouse']))  
+		{
+			$warehouse = $this->input->post('warehouse',true);
+		    $whlabel = $this->input->post('whlabel',true);
+			$id = $this->input->post('id',true);
+			$shop = $this->input->post('shop',true);
+			$number = $this->input->post('number',true);
+			$state = $this->input->post('state',true);
+			$warehouse = $this->warehouse->read($warehouse);
+			if(!$state)
+			{
+				$state = 207;
+			}
+			if(!$number)
+			{
+				$number = '001';
+			}
+			if(!$whlabel || $whlabel == '|')
+			{
+				echo json_encode(array('msg'=>'请先添加产品信息!','success'=>false));exit;
+			}
+			$z = $this->ck->get_kcyz($state,$warehouse,$shop,$number,$whlabel,'');
+			if($z['t'] > '0')
+			{
+				echo $z['m'];
+			}
+			else
+			{
+				echo json_encode(array('success'=>true));exit;
+			}
+		}
+	}
+}

+ 148 - 0
core/CoreApp/controllers/Classid.php

@@ -0,0 +1,148 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Classid extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_classid','classid');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add($arg_array);
+        }
+		else if($arg == 'edit')
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')
+        {
+             $this->_del();
+        }
+		else if($arg == 'px')
+        {
+             $this->_px();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['rows']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$title = $this->input->post('title',true);
+			$pp = $this->input->post('pp',true);
+			$order_str = "px asc";
+			$where = "1='1'";
+			if($title)
+            {
+                $where  .= " and title like '%$title%'";
+            }
+			if($pp)
+            {
+                $where  .= " and pp = '$pp'";
+            }
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+            //取得信息列表
+            $info_list = $this->classid->find_all($where,'*',$order_str);
+		    echo json_encode(array('data'=>$info_list,'power'=>array(),'success'=>true));exit;
+		}
+		$this->_Template('classid',$this->data);
+	}
+	
+	//添加
+	public function _add($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['title']))
+		{
+			$dn = $this->classid->find_count("1=1","*","px asc");
+			$post['px'] = $dn+1;
+			if($this->classid->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('classid_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			if($this->classid->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$classid = $this->classid->read($arg_array[0]);
+		$this->data['classid'] = $classid;
+		$this->_Template('classid_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->classid->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	
+	public function _px()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['data']))  
+		{
+			//echo json_encode(array('msg'=>'防止误排序,请联系开启!','success'=>false));exit;
+			$data = $this->input->post('data',true);
+			$data = explode('|',trim($data,'|'));
+			$this->db->trans_begin();
+			foreach ($data as $k=>$v)
+		    {
+				$this->classid->save(array('px'=>$k),$v);
+			}
+			if ($this->db->trans_status() === TRUE)
+        	{
+				$this->db->trans_commit();
+			}
+			else
+			{
+				$this->db->trans_rollback();
+			}
+		}
+	}
+}

+ 200 - 0
core/CoreApp/controllers/Code.php

@@ -0,0 +1,200 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Code extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_code','code');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$type = $this->input->post('type',true);
+			/**
+			$timek = $this->input->post('timetk',true);
+			$timej = $this->input->post('timetj',true);
+			$timek = strtotime($timek);
+			$timej = strtotime($timej);
+			**/
+			$where = "1=1 ";
+			/**
+			if($timetk && $timetj)
+            {
+                $where  .= " and printtime > '$timek' and printtime < '$timej'";
+            }
+			**/
+			if($type || $type==0)
+            {
+                $where  .= " and type = '$type'";
+            }
+            //数据排序
+            $order_str = "addtime desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->code->find_all($where,'id,number,content,addtime,print',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$info_list[$key]['addtime'] = date('Y-m-d H:i:s',$value['addtime']);
+            }
+		    $total = $this->code->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('code',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$dir = '/data/excel/'.date('Ymd',time()).'/';
+		$config['upload_path'] = '.'.$dir ;
+		$config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
+        $config['allowed_types'] = 'xls|xlsx|csv';
+        $config['max_size'] = 10240;
+		$this->load->library('upload', $config);
+		$this->upload->initialize($config);
+        if ($this->upload->do_upload('userfile'))
+        {
+			$full_path = $dir.$this->upload->data('file_name');
+			$fileName = '.' . $full_path;
+            if (!file_exists($fileName)) 
+			{
+				echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
+            }
+			else
+			{
+				require_once "./data/excel/PHPExcel/IOFactory.php";
+				$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
+				$phpExcel->setActiveSheetIndex(0);// 设置为默认表
+				$sheetCount = $phpExcel->getSheetCount();// 获取表格数量
+				$row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
+				$column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
+				++$column;//如果列数大于26行
+				$list = array();
+				for ($i = 2; $i <= $row; $i++) // 行数循环
+				{
+					$data = array();
+                    for ($c = 'A'; $c != $column; $c++)  // 列数循环
+	                {
+						$data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
+                    }
+					$list[] = $data;
+                }
+			}
+			$i = 0;$j = 0;$ed = array();$tytime = time();
+		    foreach ($list as $key=>$value)
+		    {
+				$value['6'] =  preg_replace('/\D/s','',$value['6']);
+				if($value['6'] && !isset($n[$value['6']])) 
+				{
+			        $this->code->insert(array('content'=>$value['5'],'number'=>$value['6'],'addtime'=>time()));
+				}
+				else
+				{
+					$ed[] = array($value['6'].'-错误或重复操作');
+					$i++;
+				}
+			}
+			if($i+$j > 0)
+			{
+				$time = date('Ymd',time());
+				$title = '错误信息-'.$time;
+        		$titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
+				$tail = "\n";
+        		$filename = $title.".xls";
+        		$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
+				$dir = '/data/excel/'.$time.'/';
+				$file_name = 'error_'.$time.rand(1000,9999);
+				if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
+				$myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
+				fwrite($myfile,$ecl);
+				fclose($myfile);
+				$error = $dir.$file_name.'.xls';
+				echo json_encode(array('msg'=>'添加成功,'.$i.'条异常','error'=>$error,'success'=>true));exit;
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
+			}
+        }
+		else
+		{
+			echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
+		}
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+				$d = $this->code->read($v);
+               $this->code->save(array('print'=>$d['print']+1,'printtime'=>time(),'type'=>1),$v);
+            }
+			 echo json_encode(array('success'=>true));
+		}
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->code->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 260 - 0
core/CoreApp/controllers/Color.php

@@ -0,0 +1,260 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Color extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_color','color');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'see')
+        {
+             $this->_see($arg_array);
+        }
+		else if($arg == 'seeindex')
+        {
+             $this->_seeindex();
+        }
+		else if($arg == 'seephone')
+        {
+             $this->_seephone();
+        }
+		else if($arg == 'del')
+        {
+             $this->_del();
+        }
+		else
+		{
+			$this->_index();
+		}
+    }
+	
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$title = $this->input->post('title',true);
+			$content = $this->input->post('content',true);
+			$warehouse = $this->input->post('warehouse',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "1=1";
+			if($title)
+            {
+                $where  .= " and title like '%$title%'";
+            }
+			if($content)
+            {
+                $where  .= " and content like '%$content%'";
+            }
+			if($warehouse)
+            {
+                $where  .= " and warehouse = '$warehouse'";
+            }
+			if($timetk && $timetj)
+            {
+                $where  .= " and time > '$timetk' and time < '$timetj'";
+            }
+			//数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			$info_list = $this->color->find_all($where,'id,title,color,lowe,img,content,time',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$colorimg = explode('|',$value['img']);
+				$v = $colorimg[0];
+					$lx = explode(".",$v);
+					$lx = strtolower(end($lx));
+					if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
+					{
+						$info_list[$key]['img'] = '<video src="'.$v.'" controls="controls" title="点击视频左上角删除"></video>';
+					}
+					else if($v != '')
+					{
+			 		   $info_list[$key]['img'] = "<img src='".site_url('img/thumb')."?src=".str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','/img/thumb?src='),'',$v)."&w=200&h=100' data-src='".$v."'>";
+					}
+					else
+					{
+						$info_list[$key]['img'] = '';
+					}
+				$info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
+			}
+			$total = $this->color->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+        $this->_Template('color',$this->data);
+	}
+	
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['title']))
+		{
+			$title = $this->input->post('title',true);
+			$img = $this->input->post('img',true);
+			if($img == '')
+			{
+				echo json_encode(array('msg'=>'必须上传图片或者视频!','success'=>false));exit;
+			}
+			$post['img'] = rtrim($img,'|');
+			$post['content'] = $this->input->post('content',true);
+			$post['time'] = time();
+			if($this->color->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('color_add',$this->data);
+	}
+	
+	public function _edit($arg_array)
+	{
+		$user = $this->user->get_api($_SESSION['api']);
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['warehouse'] = $this->input->post('warehouse',true);
+			$img = $this->input->post('img',true);
+			if($img == '')
+			{
+				echo json_encode(array('msg'=>'必须上传图片或者视频!','success'=>false));exit;
+			}
+			$post['img'] = rtrim($img,'|');
+			$post['content'] = $this->input->post('content',true);
+			$post['edittime'] = time();
+			if($this->color->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$color = $this->color->read($arg_array);
+		$colorimg = explode('|',$color['img']);
+		$img = '';
+		foreach ($colorimg as $v) 
+		{
+			$lx = explode(".",$v);
+			$lx = strtolower(end($lx));
+			if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
+			{
+				$img .= '<video src="'.$v.'" controls="controls" title="点击视频左上角删除"></video>';
+			}
+			else if($v != '')
+			{
+			    $img .= "<img src='".site_url('img/thumb')."?src=".str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','/img/thumb?src='),'',$v)."&w=500&h=500' data-src='".$v."'>";
+			}
+			else
+			{
+				$img = '';
+			}
+		}
+		$this->data['userid'] = $user['userid'];
+		$color['img'] = $img;
+		$this->data['color'] = $color;
+		$this->_Template('color_edit',$this->data);
+	}
+	
+	public function _see($arg_array)
+	{
+		$arg_array = $arg_array[0];
+		$color = $this->color->read($arg_array);
+		$colorimg = explode('|',$color['img']);
+		$img = array();$i = 1;
+		foreach ($colorimg as $v) 
+		{
+			$lx = explode(".",$v);
+			$lx = strtolower(end($lx));
+			/**
+			if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
+			{
+				$img .= '<video src="'.$v.'" controls="controls"></video>';
+			}
+			else if($v != '')
+			{
+			    $img .= "<a href='".$v."' download='".$color['number']."第".$i."张图片'><img src='".site_url('img/thumb')."?src=".str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','img/thumb?src='),'',$v)."&w=500&h=500' data-src='".$v."'></a>";
+			}
+			else
+			{
+				$img = '';
+			}
+			**/
+			if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
+			{
+				$img[] = array('sp',$v); 
+			}
+			else if($v != '')
+			{
+			    $img[] = array('tp',"<a href='".$v."' download='".$color['number']."第".$i."张图片'><img src='".site_url('img/thumb')."?src=".str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','img/thumb?src='),'',$v)."&w=500&h=500' data-src='".$v."'></a>");
+			}
+			$i++;
+		}
+		$color['img'] = $img;
+		$this->data['color'] = $color;
+		$this->_Template('color_see',$this->data);
+	}
+	
+	public function _seephone()
+	{
+		$this->_Template('color_seephone',$this->data);
+	}
+	
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->color->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 380 - 0
core/CoreApp/controllers/Colour.php

@@ -0,0 +1,380 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Colour extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_colour','colour');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'see')
+        {
+             $this->_see($arg_array);
+        }
+		else if($arg == 'seeindex')
+        {
+             $this->_seeindex();
+        }
+		else if($arg == 'seephone')
+        {
+             $this->_seephone();
+        }
+		else if($arg == 'del')
+        {
+             $this->_del();
+        }
+		else
+		{
+			$this->_index();
+		}
+    }
+	
+	public function _index()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+			$fgshop .= " shop = '0' or";
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$number = $this->input->post('number',true);
+			$shop = $this->input->post('shop',true);
+			$warehouse = $this->input->post('warehouse',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "(".rtrim($fgshop,'or').")";
+			if($number)
+            {
+                $where  .= " and number like '%$number%'";
+            }
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($warehouse)
+            {
+                $where  .= " and warehouse = '$warehouse'";
+            }
+			if($timetk && $timetj)
+            {
+                $where  .= " and time > '$timetk' and time < '$timetj'";
+            }
+			//数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			$info_list = $this->colour->find_all($where,'id,number,shop,warehouse,time',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
+				if($value['shop'] == '0')
+				{
+					$info_list[$key]['shop'] = '常用色';
+				}
+				else
+				{
+				    $shop = $this->shop->read($value['shop']);
+				    $info_list[$key]['shop'] = $shop['shopname'];
+				}
+				$warehouse = $this->warehouse->read($value['warehouse']);
+				$info_list[$key]['warehouse'] = $warehouse['title'];
+			}
+			$total = $this->colour->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$fgshop);
+		    echo json_encode($rows);exit;
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+        $this->_Template('colour',$this->data);
+	}
+	
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['number']))
+		{
+			$number = $this->input->post('number',true);
+			$post['number'] = trim($number,' ');
+			$post['warehouse'] = $this->input->post('warehouse',true);
+			$img = $this->input->post('img',true);
+			$post['img'] = rtrim($img,'|');
+			$post['content'] = $this->input->post('content',true);
+			$post['time'] = time();
+			if($this->colour->get_number($post['number']))
+			{
+				echo json_encode(array('msg'=>'此订单编号已存在!','success'=>false));exit;
+			}
+			if(stripos($post['number'],'#') !== false)
+			{
+				$post['shop'] = 0;
+			}
+			else
+			{
+			    $number = $this->fullorder->get_number($post['number']);
+			    if(!$number)
+			    {
+				    $number = $this->fullordersmt->get_number($post['number']);
+				    if(!$number)
+				    {
+						 $number = $this->fullordertt->get_number($post['number']);
+				    	 if(!$number)
+				    	 {
+							 echo json_encode(array('msg'=>'订单中未找到此编号!','success'=>false));exit;
+						 }
+						 
+				    }
+			    }
+			}
+			$post['shop'] = $number['shop'];
+			if($this->colour->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('colour_add',$this->data);
+	}
+	
+	public function _edit($arg_array)
+	{
+		$user = $this->user->get_api($_SESSION['api']);
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['warehouse'] = $this->input->post('warehouse',true);
+			$img = $this->input->post('img',true);
+			$post['img'] = rtrim($img,'|');
+			$post['content'] = $this->input->post('content',true);
+			$post['edittime'] = time();
+			if($this->colour->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$colour = $this->colour->read($arg_array);
+		$colourimg = explode('|',$colour['img']);
+		$img = '';
+		foreach ($colourimg as $v) 
+		{
+			$lx = explode(".",$v);
+			$lx = strtolower(end($lx));
+			if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
+			{
+				$img .= '<video src="'.$v.'" controls="controls" title="点击视频左上角删除"></video>';
+			}
+			else if($v != '')
+			{
+			    $img .= "<img src='".site_url('img/thumb')."?src=".str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','https://1.wepolicy.cn/','/img/thumb?src='),'',$v)."&w=500&h=500' data-src='".$v."'>";
+			}
+			else
+			{
+				$img = '';
+			}
+		}
+		$this->data['userid'] = $user['userid'];
+		$colour['img'] = $img;
+		$this->data['colour'] = $colour;
+		$this->_Template('colour_edit',$this->data);
+	}
+	
+	public function _see($arg_array)
+	{
+		$arg_array = $arg_array[0];
+		$colour = $this->colour->read($arg_array);
+		$colourimg = explode('|',$colour['img']);
+		$img = array();$i = 1;
+		foreach ($colourimg as $v) 
+		{
+			$lx = explode(".",$v);
+			$lx = strtolower(end($lx));
+			/**
+			if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
+			{
+				$img .= '<video src="'.$v.'" controls="controls"></video>';
+			}
+			else if($v != '')
+			{
+			    $img .= "<a href='".$v."' download='".$colour['number']."第".$i."张图片'><img src='".site_url('img/thumb')."?src=".str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','img/thumb?src='),'',$v)."&w=500&h=500' data-src='".$v."'></a>";
+			}
+			else
+			{
+				$img = '';
+			}
+			**/
+			if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
+			{
+				$img[] = array('sp',$v); 
+			}
+			else if($v != '')
+			{
+			    $img[] = array('tp',"<a href='".$v."' download='".$colour['number']."第".$i."张图片'><img src='".site_url('img/thumb')."?src=".str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','https://1.wepolicy.cn/','img/thumb?src='),'',$v)."&w=500&h=500' data-src='".$v."'></a>");
+			}
+			$i++;
+		}
+		$colour['img'] = $img;
+		$this->data['colour'] = $colour;
+		$this->_Template('colour_see',$this->data);
+	}
+	
+	public function _seeindex()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";$wid="";$wtype="";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			$userwh = explode('|',trim($user['warehouse'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+			foreach ($userwh as $value) 
+		    {
+				$wid .= " id = ".$value." or";
+				$wtype .= " warehouse = ".$value." or";
+			}
+			$fgshop .= " shop = '0' or";
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$number = $this->input->post('number',true);
+			$shop = $this->input->post('shop',true);
+			$warehouse = $this->input->post('warehouse',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "(".rtrim($fgshop,'or').")";
+			if($number)
+            {
+                $where  .= " and number like '%$number%'";
+            }
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($warehouse)
+            {
+                $where  .= " and warehouse = '$warehouse'";
+            }
+			if($timetk && $timetj)
+            {
+                $where  .= " and time > '$timetk' and time < '$timetj'";
+            }
+			//数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			$info_list = $this->colour->find_all($where,'id,number,shop,warehouse,time',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
+				if($value['shop'] == '0')
+				{
+					$info_list[$key]['shop'] = '常用色';
+				}
+				else
+				{
+				    $shop = $this->shop->read($value['shop']);
+				    $info_list[$key]['shop'] = $shop['shopname'];
+				}
+				$warehouse = $this->warehouse->read($value['warehouse']);
+				$info_list[$key]['warehouse'] = $warehouse['title'];
+			}
+			$total = $this->colour->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
+		$this->data['warehouse'] = $warehouse;
+        $this->_Template('colour_seeindex',$this->data);
+	}
+	
+	public function _seephone()
+	{
+		$this->_Template('colour_seephone',$this->data);
+	}
+	
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->colour->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 132 - 0
core/CoreApp/controllers/Colourorderts.php

@@ -0,0 +1,132 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Colourorderts extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->_model('Model_colourorderts','colourorderts');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')
+        {
+             $this->_del();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$text = $this->input->post('text',true);
+			$where = "1=1 ";
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			if($text)
+			{
+				$where .= " and text like '%$text%'";
+			}
+            //取得信息列表
+            $info_list = $this->colourorderts->find_all($where,'id,text,colour',$order_str,$start,$perpage);
+			foreach ($info_list as $k=>$v) 
+		    {
+			   $info_list[$k]['colour'] = '<font style="width:50px;height:10px;display:inline-block;background-color:#'.$v["colour"].'"></font>';
+            }
+		    $total = $this->colourorderts->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('colourorderts',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['text']))
+		{
+			$post['text'] = $this->input->post('text',true);
+			$a = $this->colourorderts->find_all("text = '".$post['text']."'");
+			if(isset($a[0]['id']))
+			{
+				echo json_encode(array('msg'=>'添加失败,有重复内容','success'=>false));exit;
+			}
+			if($this->colourorderts->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('colourorderts_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['text'] = $this->input->post('text',true);
+			if($this->colourorderts->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$colourorderts = $this->colourorderts->read($arg_array);
+		$this->data['colourorderts'] = $colourorderts;
+		$this->_Template('colourorderts_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->colourorderts->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 625 - 0
core/CoreApp/controllers/Commodity.php

@@ -0,0 +1,625 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Commodity extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_commodity','commodity');
+		$this->load->_model('Model_commodityread','commodityread');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_apismt','apismt');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_commodityread_del','commodityreaddel');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'aeorder')//同步
+        {
+             $this->_aeorder();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'batchedit')//批量修改
+        {
+             $this->_batchedit();
+        }
+		else if($arg == 'skuedit')//修改
+        {
+             $this->_skuedit($arg_array);
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$dt = 0;
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$shop = $this->input->post('shop',true);
+			$productid = $this->input->post('productid',true);
+			$title = $this->input->post('title',true);
+			$type = $this->input->post('type',true);
+			$code = $this->input->post('code',true);
+			$skuid = $this->input->post('skuid',true);
+			$category = $this->input->post('category',true);
+			$categorytypeclass =  $this->typeclass->get_titleclassid($category,16);
+			$where = "1=1 and (".rtrim($fgshop,'or').")";
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($productid)
+            {
+                $where  .= " and productid = '$productid'";
+            }
+			if($title)
+            {
+				$where  .= " and title like '%$title%'";
+            }
+			if($type)
+            {
+                $where  .= " and type = '$type'";
+            }
+			if($category)
+            {
+                $where  .= " and category like '%".$categorytypeclass['id']."%'";
+            }
+			if($code)
+            {
+				$u = $this->commodityread->get_sku($code);
+				$u = $u['productid'];
+                $where  .= " and productid = '$u'";
+            }
+			if($skuid)
+            {
+				$u = $this->commodityread->get_skuid($skuid);
+				$u = $u['productid'];
+                $where  .= " and productid = '$u'";
+            }
+            //数据排序
+            $order_str = "time desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->commodity->find_all($where,'id,shop,productid,img,title,category,time',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$v) 
+		    {
+				$shop = $this->shop->read($v['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				$info_list[$key]['img'] = "<img src='".$v['img']."' style='height:55px' />";
+				$category = '';
+				if($v['category'])
+				{
+				    $v['category'] = explode(',',trim($v['category'],','));
+				    foreach ($v['category'] as $vv) 
+		            {
+				        $typeclass = $this->typeclass->read($vv);
+					    $category .= "<p>".$typeclass['title']."</p>";
+				    }
+				    $info_list[$key]['category'] = $category;
+				}
+				else
+				{
+					$info_list[$key]['category'] = '';
+				}
+				$info_list[$key]['time'] = "<p><a href='http://posting.aliexpress.com/wsproduct/edit_wholesale_product.htm?product_id=".$v['productid']."' target='_blank'>编辑</a></p><p><a href='http://www.aliexpress.com/item/".$v['productid'].".html' target='_blank'>浏览</a></p>";
+				
+            }
+		    $total = $this->commodity->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$this->_Template('commodity',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$category = $this->input->post('category',true);
+			$data = $this->input->post('data');
+			if($data)
+			{
+			    $data = explode('|',rtrim($data,'|'));
+			    foreach ($data as $v) 
+		        {
+				    $d = explode('@',$v);
+				    $this->commodityread->save(array('sku'=>$d[1]),$d[0]);
+			    }
+			}
+			if($this->commodity->save(array('category'=>','.$category),$id))
+        	{
+         		echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$commodity = $this->commodity->read($arg_array);
+		$this->data['commodity'] = $commodity;
+		$sku = $this->commodityread->find_all('productid = '.$commodity['productid']);
+		$this->data['sku'] = $sku;
+		$this->_Template('commodity_edit',$this->data);
+	}
+	
+	public function _batchedit_b()//老系统形式,保留,不用
+	{
+		$dictionaries = $this->typeclass->find_all('ae!= "" and (classid=13 or classid=22 or classid=8 or classid=15 or classid=27 or classid=25 or classid=26 or classid=18 or classid=14 or classid=9 or classid=12 or classid=10 or classid=6)'); //产品人发类型颜色
+		$dtc = array();$ctd = array();
+		foreach ($dictionaries as $v) 
+		{
+			if(stripos($v['spare'],'|') !== false)//如果有多个值
+			{
+				$v['spare'] = explode('|',$v['spare']);
+				foreach ($v['spare'] as $vs)
+		        {
+					$dtc[strtolower($vs)] = array('classid'=>$v['classid'],'title'=>$v['title'],'id'=>$v['id']);
+				}
+			}
+			else
+			{
+				$dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'title'=>$v['title'],'id'=>$v['id']);
+			}
+			$ctd[$v['id']] = $v['title'];
+		}
+		$ctd[126] = 'Hair Weaving';
+		$ctd[127] = 'Closure';
+		$ctd[128] = 'Wigs';
+		$ctd[130] = 'Clip-in Full Head';
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$ndata = $this->input->post('data',true);
+			$id = explode(',',rtrim($id,','));
+			$data = explode('-',rtrim($ndata,'-'));
+			$rows = array();
+			foreach ($id as $val) 
+		    {
+				//a:颜色 b:密度 c:头路设计
+			    $u = $this->commodityread->read($val);
+				$u['codeid'] = strtolower($u['codeid']);
+				$u['codeid'] = str_replace(array('stretched length','inches','& '),array('length','',''),$u['codeid']);
+				$sku = explode(';',rtrim($u['codeid'],';'));
+				$codeid = array();$whlabel = ''; $fpdata = '';
+				foreach ($sku as $v)
+		        {
+					$va = explode(':',$v);
+					$codeid[$va[0]] = $va[1];
+				}
+				$num = '';$ti = '';$tit = '';$error = '';$i = 1;
+				foreach ($data as $k=>$v) 
+		        {
+					if($v == 'a')
+					{
+						if(isset($codeid['color']) && isset($dtc[$codeid['color']]))
+						{
+						    $num .= $dtc[$codeid['color']]['id'].'-';
+							$ti .= $dtc[$codeid['color']]['title'].' ';
+						}
+						else
+						{
+							$num .= '57-';
+							$ti .= 'Natural Black ';
+						}
+					}
+					else if($v == 'b')
+					{
+						if(isset($codeid['density']) && isset($dtc[$codeid['density']]))
+						{
+						    $num .= $dtc[$codeid['density']]['id'].'-';
+							$ti .= $dtc[$codeid['density']]['title'].' ';
+						}
+						else
+						{
+							$num .= '71-';
+							$ti .= '150% ';
+						}
+					}
+					else if($v == 'c')
+					{
+						if(isset($codeid['part design']) && isset($dtc[$codeid['part design']]))
+						{
+						    $num .= $dtc[$codeid['part design']]['id'].'-';
+							$ti .= $dtc[$codeid['part design']]['title'].' ';
+						}
+						else
+						{
+							$num .= '75-';
+							$ti .= 'Free Part ';
+						}
+					}
+					else
+					{
+						if($i == 2)
+						{
+							$num .= $v.'-id-';
+						}
+						else
+						{
+							$num .= $v.'-';
+						}
+						$ti .= $ctd[$v].' ';
+					}
+					$i++;
+			    }
+				if(stripos($codeid['length'],'closure') !== false && stripos($ndata,'127') !== false)
+				{
+					$v = preg_replace(array('/([\s\S]*)closure/','/([\s\S]*)closure\s/'),array('',''),$codeid['length']);
+					$v = preg_replace('/([\s]*)/','',$v);
+					$fpdata = $dtc[$v]['id'].',-'.str_replace('id-','',$num).'|'.$ti.$v.'inch |1|0.00|0.00|'.$v.'|0.00|0.00;';
+					$tit = '<p>'.$ti.$v.'inch</p>';
+					$whlabel = '|'.str_replace(array('-','id'),array('',$dtc[$v]['id']),$num).'-1';
+				}
+				else
+				{
+				    $codeid['length'] = explode(' ',$codeid['length']);
+				    foreach ($codeid['length'] as $v) 
+		            {
+					    if(is_numeric($v))
+					    {
+					    	$fpdata .= $dtc[$v]['id'].',-'.str_replace('id-','',$num).'|'.$ti.$v.'inch |1|0.00|0.00|'.$v.'|0.00|0.00;';
+						    $tit .= '<p>'.$ti.$v.'inch</p>';
+						    $whlabel .= '|'.str_replace(array('-','id'),array('',$dtc[$v]['id']),$num).'-1';
+					    }
+					    else
+					    {
+					    	break;
+					    }
+				    }
+				}
+				$fa = '';$wl = '';
+				$u['fpdata'] = explode(';',rtrim($u['fpdata'],';'));
+				$u['whlabel'] = explode('|',trim($u['whlabel'],'|'));
+				for($i=0;$i<count($u['fpdata']);$i++) 
+		        {
+					if(stripos($u['fpdata'][$i],$data[0]) === false)
+					{
+						if($u['fpdata'][$i] != '')
+						{
+						    $fa .= $u['fpdata'][$i].';';
+							$te = explode('|',$u['fpdata'][$i]);
+						    $tit .= '<p>'.$te[1].'</p>';
+						}
+					}
+					if(stripos($u['whlabel'][$i],$data[0]) === false)
+					{
+						if($u['whlabel'][$i] != '')
+						{
+						    $wl .= '|'.$u['whlabel'][$i];
+						}
+					}
+				}
+				$this->commodityread->save(array('fpdata'=>$fa.$fpdata,'whlabel'=>$wl.$whlabel.'|'),$val);
+				$rows[] = array('id'=>$val,'title'=>$tit);
+            }
+			echo json_encode(array('rows'=>$rows,'success'=>true));exit;
+		}
+	}
+	public function _skuedit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['fpdata'] = $this->input->post('fpdata',true);
+			$post['whlabel'] = $this->input->post('whlabel',true);
+			if($this->commodityread->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];$fpdata = array();
+		$commodityread = $this->commodityread->read($arg_array);
+		if(stripos($commodityread['fpdata'],';') !== false)
+		{
+		    $fpdata = explode(';',rtrim($commodityread['fpdata'],';'));
+		    foreach ($fpdata as $k=>$v) 
+		    {
+			    $fpdata[$k] = explode('|',$v);
+            }
+		}
+		$this->data['fpdata'] = $fpdata;
+		$this->data['commodityread'] = $commodityread;
+		$this->_Template('commodityread_edit',$this->data);
+	}
+	
+	//获取
+	public function _aeorder()
+	{
+		$sid = '';
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$sid .= " id = '$value' or";
+			}
+			$sid = " and (".rtrim($sid,'or').")";
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if($sid)  
+		{
+			$shop = $this->shop->find_all("code != '' and type = '270'".$sid);//获取店铺信息
+			foreach ($shop as $value)
+		    {
+				$res = array();
+				for($x=1;$x<5;$x++)
+				{
+				    $resi = $this->apismt->get_commoditylist($x,100,$value['code']);//获取商品列表
+					if($resi)
+					{
+				        $res += $resi;
+					}
+				}
+				if($res)
+				{
+				        $yzpid = $this->commodity->find_all('shop = '.$value['id']);
+						foreach ($yzpid as $v)
+		        	    {
+							if($v['productid'] == '' || $v['productid'] == '0')
+							{
+								$this->commodity->remove($v['id']);
+								continue;
+							}
+							if(!isset($res[$v['productid']]))
+							{
+								$this->commodity->save(array('type'=>'offline'),$v['id']);
+							}
+						}
+						foreach ($res as $v)
+		        	    {
+						    $productid = $this->commodity->get_productid($v);
+						    //if(!$productid)
+							//{
+								@$read = $this->apismt->get_commodityread($v,$value['code']);
+								if(is_array($read))
+								{
+									@$cid = $this->apismt->get_commoditysku($read['cid'],$value['code']);
+								}
+								else
+								{
+									continue;
+								}
+								//处理结束
+								if(isset($cid[0]))
+								{
+									// 处理 $cid
+									$cc = array();
+									foreach ($cid as $c)
+		        	            	{
+										$names = json_decode($c['names'],true);
+										$cc[$c['id']] = $names['en'];
+										if(!isset($c['values']))
+										{
+											continue;
+										}
+										if(isset($c['values']['aeop_attr_value_dto'][0]))
+										{
+									 	   foreach ($c['values']['aeop_attr_value_dto'] as $cv)
+		        	                 	   {
+											   if(isset($read['gg'][$cv['id']]))//如果有自定义
+											   {
+												   $cc[$cv['id']] = $read['gg'][$cv['id']];
+											   }
+											   else
+											   {
+											       $cnames = json_decode($cv['names'],true);
+											       $cc[$cv['id']] = $cnames['en'];
+											   }
+									    	}
+										}
+										else
+										{
+											$cnames = json_decode($c['values']['aeop_attr_value_dto']['names'],true);
+											$cc[$c['values']['aeop_attr_value_dto']['id']] = $cnames['en'];
+										}
+									}
+									$read['title'] = ($read['title'])?$read['title']:'';
+									if(!$productid)
+									{
+									    //处理结束
+							            $this->commodity->insert(array('shop'=>$value['id'],'productid'=>$v,'title'=>$read['title'],'img'=>$read['img'],'type'=>$read['type'],'time'=>time()));
+									}
+									else
+									{
+										$this->commodity->save(array('shop'=>$value['id'],'productid'=>$read['productid'],'title'=>$read['title'],'img'=>$read['img'],'type'=>$read['type']),$productid['id']);
+									}
+									$this->_aeordersku($read['sku'],$value['id'],$v,$cc);
+								}
+						    //}
+					    }
+				}
+				else
+				{
+					continue;
+				}
+			}
+			echo json_encode(array('msg'=>'同步完成!','success'=>true));exit;
+		}
+	}
+	public function _aeordersku($sku,$shop,$productid,$cc)
+	{
+		$yzsku = $this->commodityread->find_all("productid = '$productid'");
+		foreach ($yzsku as $v)
+		{
+			$s = 0;
+			if(!isset($sku[$v['skuid']]))
+			{
+				$skuid = explode(';',$v['skuid']);
+				if(count($skuid) < 2)
+				{
+					$this->commodityreaddel->insert($v);
+					$this->commodityread->remove($v['id']);//asd
+					continue;
+				}
+				else
+				{
+					$skuidarray = $this->_qpl($skuid);
+					foreach ($skuidarray as $skuv)
+		            {
+						if(isset($sku[$skuv]))
+						{
+							$this->commodityread->save(array('skuid'=>$skuv),$v['id']);
+							$s++;
+							break 1;
+						}
+					}
+				}
+				if($s < 1)
+				{
+				    $this->commodityreaddel->insert($v);
+				    $this->commodityread->remove($v['id']);//asd
+				}
+			}
+		}
+		foreach ($sku as $v)
+	    {
+			$read = $this->commodityread->get_productid($productid,$v['skuid']);
+			if(isset($read['productid']))
+			{
+				$cd = explode(';',$v['skuid']);$cod = '';
+				foreach ($cd as $vv)
+	            {
+					$cv = explode(':',$vv);
+					$cod .=$cc[$cv[0]].":".$cc[$cv[1]].";";
+				}
+				$this->commodityread->save(array('shop'=>$shop,'productid'=>$productid,'codeid'=>$cod,'skuid'=>$v['skuid'],'code'=>$v['code'],'time'=>time()),$read['id']);
+			}
+			else
+			{
+				$cd = explode(';',$v['skuid']);$cod = '';
+				foreach ($cd as $vv)
+	            {
+					$cv = explode(':',$vv);
+					$cod .=$cc[$cv[0]].":".$cc[$cv[1]].";";
+				}
+				$this->commodityread->insert(array('shop'=>$shop,'productid'=>$productid,'codeid'=>$cod,'skuid'=>$v['skuid'],'code'=>$v['code'],'time'=>time()));
+			}
+		}
+	}
+	
+	public function _qpl($source)//全排列
+	{
+		$qpl = array();
+		sort($source); //保证初始数组是有序的
+		$last = count($source) - 1; //$source尾部元素下标
+		$x = $last;
+		$count = 1; //组合个数统计
+		$qpl[implode(';', $source)] = implode(';', $source); //输出第一种组合
+		while (true) 
+		{
+		    $y = $x--; //相邻的两个元素
+		    if ($source[$x] < $source[$y])//如果前一个元素的值小于后一个元素的值
+			{ 
+		        $z = $last;
+		        while ($source[$x] > $source[$z]) //从尾部开始,找到第一个大于 $x 元素的值
+				{
+					$z--;
+				}
+				/* 交换 $x 和 $z 元素的值 */
+                list($source[$x], $source[$z]) = array($source[$z], $source[$x]);
+                /* 将 $y 之后的元素全部逆向排列 */
+                for ($i = $last; $i > $y; $i--, $y++) 
+				{
+					list($source[$i], $source[$y]) = array($source[$y], $source[$i]);
+				}
+				$qpl[implode(';', $source)] = implode(';', $source); //输出组合
+				$x = $last;
+				$count++;
+			}
+			if ($x == 0)//全部组合完毕
+			{
+			    break;
+			}
+		}
+        return $qpl;
+	}
+	
+	public function _skudelhf($a)//commodityread 同步删除的恢复
+	{
+		$this->db->trans_begin();
+		$qbpid = array();
+		$a = $this->commodityread->find_all("time > '1653613200'");
+		foreach ($a as $v)
+	    {
+		   $qbpid[$v['productid']] = $v['productid'];
+	    }
+		foreach ($qbpid as $valer)
+	    {
+	       $del = $this->commodityreaddel->find_all("productid = '".$valer."' and sku != ''",'*','id asc');
+		   if($del)
+		   {
+	           foreach ($del as $val)
+	           {
+		           $skuid = explode(';',$val['skuid']);
+				   if(count($skuid) < 2)
+				   {
+					   continue;
+				   }
+		           $skuidarray = $this->_qpl($skuid);
+		           $red = $this->commodityread->find_all("productid = '".$val['productid']."' and sku = ''");
+		           foreach ($red as $v)
+	               {
+					   if(isset($skuidarray[$v['skuid']]))
+			           {
+						   $this->commodityread->save(array('sku'=>$val['sku']),$v['id']);
+			           }
+		           }
+	           }
+		   }
+	    }
+	   if ($this->db->trans_status() === TRUE)
+        {
+			$this->db->trans_commit();
+			echo 1;
+		}
+		else
+		{
+			$this->db->trans_rollback();
+			echo 2;
+		}
+	}
+}

+ 182 - 0
core/CoreApp/controllers/Country.php

@@ -0,0 +1,182 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Country extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_express','express');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')//获取数据
+        {
+             $this->_rows();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$continent = $this->input->post('continent',true);
+			$express = $this->input->post('express',true);
+			$ename = $this->input->post('ename',true);
+			$zname = $this->input->post('zname',true);
+			$where = "1=1 ";
+			if($continent)
+            {
+                $where  .= " and continent = '$continent'";
+            }
+			if($express)
+            {
+                $where  .= " and express = '$express'";
+            }
+			if($ename)
+            {
+                $where  .= " and ename like '%$ename%'";
+            }
+			if($zname)
+            {
+                $where  .= " and zname like '%$zname%'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->country->find_all($where,'id,name,ename,zname,continent,al,lb,threebitcode,express',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				if($value['express'] != 0)
+				{
+				    $express = $this->express->read($value['express']);
+				    $info_list[$key]['express'] = $express['servicename'];
+				}
+				else
+				{
+					$info_list[$key]['express'] = "";
+				}
+				$class = $this->typeclass->read($value['continent']);
+				$info_list[$key]['continent'] = $class['title'];
+            }
+		    $total = $this->country->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$class = $this->typeclass->find_all('classid = 2','id,title');
+		$this->data['class'] = $class;
+		$express = $this->express->find_all();
+		$this->data['express'] = $express;
+		$this->_Template('country',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['zname']))
+		{
+			if($this->country->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$class = $this->typeclass->find_all('classid = 2','id,title');
+		$this->data['class'] = $class;
+		$express = $this->express->find_all();
+		$this->data['express'] = $express;
+		$this->_Template('country_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			if($this->country->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$country = $this->country->read($arg_array);
+		$class = $this->typeclass->find_all('classid = 2','id,title');
+		$this->data['class'] = $class;
+		$this->data['country'] = $country;
+		$express = $this->express->find_all();
+		$this->data['express'] = $express;
+		$this->_Template('country_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->country->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	//删除
+	public function _rows()
+	{
+		$this->load->library('pagination');
+
+$config['base_url'] = 'http://127.0.0.1/country/rows';
+$config['total_rows'] = 200;
+$config['per_page'] = 20;
+
+$this->pagination->initialize($config);
+
+echo $this->pagination->create_links();
+	}
+}

Diff do ficheiro suprimidas por serem muito extensas
+ 2138 - 0
core/CoreApp/controllers/Customer.php


Diff do ficheiro suprimidas por serem muito extensas
+ 1053 - 0
core/CoreApp/controllers/Customersmt.php


Diff do ficheiro suprimidas por serem muito extensas
+ 2134 - 0
core/CoreApp/controllers/Customertt.php


Diff do ficheiro suprimidas por serem muito extensas
+ 2134 - 0
core/CoreApp/controllers/Customerxw.php


+ 273 - 0
core/CoreApp/controllers/Customs.php

@@ -0,0 +1,273 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Customs extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_customs','customs');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_detailed','detailed');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'detailed')//修改
+        {
+             $this->_detailed();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$country = $this->input->post('country',true);
+			$express = $this->input->post('express',true);
+			$where = "1=1 ";
+			if($country)
+            {
+                $where  .= " and country = '$country'";
+            }
+			if($express)
+            {
+                $where  .= " and express = '$express'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->customs->find_all($where,'id,express,country',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$country = $this->country->read($value['country']);
+				$info_list[$key]['country'] = $country['name'];
+				$express = $this->express->read($value['express']);
+				$info_list[$key]['express'] = $express['title'];
+            }
+		    $total = $this->customs->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$country = $this->country->find_all();
+		$this->data['country'] = $country;
+		$express = $this->express->find_all();
+		$this->data['express'] = $express;
+		$this->_Template('customs',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['express']))
+		{
+			$post['express'] = $this->input->post('express',true);
+			$detailedrows = $this->input->post('detailed',true);
+			//添加detailed信息开始
+			if($detailedrows != NULL)
+			{
+				$dnum = array();
+				$detaileddata = explode('|',rtrim($detailedrows,'|'));
+                foreach ($detaileddata as $k=>$v) 
+		        {
+				    $rows = explode(',',rtrim($v,','));
+					$detailedpost['lowerlimit'] = $rows[0];
+			        $detailedpost['includelower'] = $rows[1];
+			        $detailedpost['upperlimit'] = $rows[2];
+					$detailedpost['includeupper'] = $rows[3];
+			        $detailedpost['calculatemethod'] = $rows[4];
+			        $detailedpost['customsval'] = $rows[5];
+					$detailedpost['time'] = time().rand(1000,9999);
+					if($this->detailed->insert($detailedpost))
+					{
+						$dnum[] = $detailedpost['time'];
+					}
+					
+                }
+			    $post['detailed'] = "|";
+				foreach ($dnum as $k=>$v) 
+		        {
+				    $ddata = $this->detailed->get_time($v);
+				    $post['detailed'] = $post['detailed'].$ddata['id']."|";
+			    }
+			}
+			//添加detailed信息结束
+			$countryck = $this->input->post('country',true);
+			if($countryck)
+			{
+				$countryck = explode(',',rtrim($countryck,','));
+				foreach ($countryck as $key=>$value) 
+		        {
+					$post['country'] = $value;
+				    $this->customs->insert($post);
+                }
+				
+				echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+			}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$country = $this->country->find_all();
+		$this->data['country'] = $country;
+		$express = $this->express->find_all();
+		$this->data['express'] = $express;
+		$this->_Template('customs_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['express'] = $this->input->post('express',true);
+			$post['country'] = $this->input->post('country',true);
+			$detailedrows = $this->input->post('detailed',true);
+			$customs = $this->customs->read($id);
+			$detaileddata="";
+			if($detailedrows != NULL)
+			{
+				$dnum = array();
+				$rw = explode('|',rtrim($detailedrows,'|'));
+                foreach ($rw as $k=>$v) 
+		        {
+				    $rows = explode(',',rtrim($v,','));
+					$detailedpost['lowerlimit'] = $rows[0];
+			        $detailedpost['includelower'] = $rows[1];
+			        $detailedpost['upperlimit'] = $rows[2];
+					$detailedpost['includeupper'] = $rows[3];
+			        $detailedpost['calculatemethod'] = $rows[4];
+			        $detailedpost['customsval'] = $rows[5];
+					$detailedpost['time'] = time().rand(1000,9999);
+					if($this->detailed->insert($detailedpost))
+					{
+						$dnum[] = $detailedpost['time'];
+					}
+					
+                }
+				foreach ($dnum as $k=>$v) 
+		        {
+				    $ddata = $this->detailed->get_time($v);
+				    $detaileddata = $detaileddata.$ddata['id']."|";
+			    }
+			}
+			if($customs['detailed'] == "")
+			{
+				$customs['detailed'] = "|";
+			}
+			$post['detailed'] = $customs['detailed'].$detaileddata;
+			if($this->customs->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$customs = $this->customs->read($arg_array);
+		$this->data['customs'] = $customs;
+		$country = $this->country->find_all();
+		$this->data['country'] = $country;
+		$express = $this->express->find_all();
+		$this->data['express'] = $express;
+		$rows = array();
+		if($customs['detailed'])
+		{
+		    $detailed = $customs['detailed'];
+		    $detailed = explode('|',trim($detailed,'|'));
+		    foreach ($detailed as $k=>$v) 
+		    {
+				$rw = $this->detailed->read($v);
+				if($rw['calculatemethod'] == 1)
+				{
+					$wr = array('title'=>"按总价");
+				}
+				else
+				{
+					$wr = array('title'=>"按单价");
+				}
+				$rw = array_merge($rw,$wr);
+		    	$rows[] = $rw;
+            }
+		}
+		$this->data['rows'] = $rows;
+		$this->_Template('customs_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->customs->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	//修改数据
+	public function _detailed()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $s = $this->input->post('s');
+			$id= $this->input->post('id');
+			$customs = $this->customs->read($id);
+            $detailed = str_replace('|'.$s.'|','|',$customs['detailed']);
+			if($detailed == "|")
+			{
+				$detailed = "";
+			}
+            if($this->customs->save(array('detailed'=>$detailed),$id))//写入删除后的数据
+			{
+				 echo json_encode(array('success'=>true));exit;
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
+			}
+		}
+    }
+}

+ 130 - 0
core/CoreApp/controllers/Customsdeclaration.php

@@ -0,0 +1,130 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Customsdeclaration extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_customsdeclaration','customsdeclaration');
+	}
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//在库标签
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//在库标签
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//在库标签
+        {
+             $this->_del();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$ename = $this->input->post('ename',true);
+			$zname = $this->input->post('zname',true);
+			$bname = $this->input->post('bname',true);
+			$where = "1=1 ";
+			if($ename)
+            {
+                $where  .= " and ename = '$ename'";
+            }
+			if($zname)
+            {
+                $where  .= " and zname = '$zname'";
+            }
+			if($bname)
+            {
+                $where  .= " and bname = '$bname'";
+            }
+            //数据排序
+            $order_str = "px asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->customsdeclaration->find_all($where,'id,ename,zname,bname,px',$order_str,$start,$perpage);
+		    $total = $this->customsdeclaration->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('customsdeclaration',$this->data);
+	}
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['ename']))
+		{
+			if($this->customsdeclaration->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败','success'=>false));exit;
+        	}
+		}
+		$this->_Template('customsdeclaration_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['ename']))
+		{
+			$id = $this->input->post('id',true);
+			if($this->customsdeclaration->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$customsdeclaration = $this->customsdeclaration->read($arg_array);
+		$this->data['customsdeclaration'] = $customsdeclaration;
+		$this->_Template('customsdeclaration_edit',$this->data);
+	}
+	//删除
+    public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->customsdeclaration->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 123 - 0
core/CoreApp/controllers/Describecode.php

@@ -0,0 +1,123 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Describecode extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_describecode','describecode');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')//获取数据
+        {
+             $this->_rows();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$where = "1=1 ";
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->describecode->find_all($where,'id,product,expresscode',$order_str,$start,$perpage);
+		    $total = $this->describecode->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('describecode',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['describecodename']))
+		{
+			$post['product'] = $this->input->post('product',true);
+			$post['expresscode'] = $this->input->post('expresscode',true);
+			$post['time'] = time().rand(1000,9999);
+			if($this->describecode->insert($post))
+        	{
+				$data = $this->describecode->get_time($post['time']);
+         		echo json_encode(array('msg'=>'添加成功','data'=>$data,'success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['class'] = $this->input->post('class',true);
+			$post['product'] = $this->input->post('product',true);
+			$post['expresscode'] = $this->input->post('expresscode',true);
+			if($this->describecode->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->describecode->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 129 - 0
core/CoreApp/controllers/Detailed.php

@@ -0,0 +1,129 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Detailed extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_detailed','detailed');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')//获取数据
+        {
+             $this->_rows();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$where = "1=1 ";
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->detailed->find_all($where,'id,lowerlimit,includelower,upperlimit,includeupper,calculatemethod,customsval',$order_str,$start,$perpage);
+		    $total = $this->detailed->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('detailed',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['lowerlimit']))
+		{
+			$post['lowerlimit'] = $this->input->post('lowerlimit',true);
+			$post['includelower'] = $this->input->post('includelower',true);
+			$post['upperlimit'] = $this->input->post('upperlimit',true);
+			$post['includeupper'] = $this->input->post('includeupper',true);
+			$post['calculatemethod'] = $this->input->post('calculatemethod',true);
+			$post['customsval'] = $this->input->post('customsval',true);
+			$post['time'] = time().rand(1000,1000);
+			if($this->detailed->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['lowerlimit'] = $this->input->post('lowerlimit',true);
+			$post['includelower'] = $this->input->post('includelower',true);
+			$post['upperlimit'] = $this->input->post('upperlimit',true);
+			$post['includeupper'] = $this->input->post('includeupper',true);
+			$post['calculatemethod'] = $this->input->post('calculatemethod',true);
+			$post['customsval'] = $this->input->post('customsval',true);
+			if($this->detailed->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v)
+		    {
+                $this->detailed->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 744 - 0
core/CoreApp/controllers/Distribution.php

@@ -0,0 +1,744 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Distribution extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_user','user');
+		$this->load->_model('Model_distribution','distribution');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_productprice','productprice');
+		$this->load->_model('Model_excel','excel');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'drmb')//修改
+        {
+             $this->_drmb();
+        }
+		else if($arg == 'dr')
+        {
+             $this->_dr();
+        }
+		else if($arg == 'db')
+        {
+             $this->_db();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$t = array();
+		$typeclass = $this->typeclass->find_all();
+		foreach ($typeclass as $v)
+		{
+			$t[$v['id']] = $v['title'];
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$category = $this->input->post('category',true);
+			$where = "1=1 ";
+            //数据排序
+            $order_str = "id asc";
+			if($category)
+			{
+				$where .= "and category = '$category'";
+			}
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->distribution->find_all($where,'id,category,lace,density,size,weight,pb',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				if(isset($t[$value['category']]))
+				{
+					$info_list[$key]['category'] = $t[$value['category']];
+				}
+				if(isset($t[$value['lace']]))
+				{
+					$info_list[$key]['lace'] = $t[$value['lace']];
+				}
+				if(isset($t[$value['density']]))
+				{
+					$info_list[$key]['density'] = $t[$value['density']];
+				}
+				if(isset($t[$value['size']]))
+				{
+					$info_list[$key]['size'] = $t[$value['size']];
+				}
+				if($value['pb'] != '')
+				{
+					$info_list[$key]['pb'] = '';
+					$pb = explode('/',trim($value['pb'],'/'));
+					foreach ($pb as $vv) 
+		            {
+						$vv = explode('*',trim($vv,'*'));
+						foreach ($vv as $v) 
+		                {
+							$info_list[$key]['pb'] .= '<p>'.trim($v,' ').'</p>';
+						}
+					}
+				}
+            }
+		    $total = $this->distribution->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('distribution',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['category']))
+		{
+			$category = $this->input->post('category',true);
+			$lace = $this->input->post('lace',true);
+			$density = $this->input->post('density',true);
+			$size = $this->input->post('size',true);
+			$size = trim($size,',');
+			$pb = $this->input->post('pb',true);
+			$post['category'] = (isset($t[$category]))?$t[$category]:'';
+			$post['lace'] = (isset($t[$lace]))?$t[$lace]:'';
+			$post['density'] = (isset($t[$density]))?$t[$density]:'';
+			$post['size'] = (isset($t[$size]))?$t[$size]:'';
+			$post['pb'] = $pb;
+			if($post['category'] == '' || $post['size'] == '')
+			{
+				echo json_encode(array('msg'=>'提交信息有误,请检查','success'=>false));exit;
+			}
+			$gl = '';$fl = array();$zzl = 0;$cw = 0;$xq = '';
+			if($pb != '')
+			{
+				if($post['category'] == 128)
+				{
+					$pb = explode('/',trim($pb,'/'));
+					$ftpb = $this->ft($pb);
+					if($ftpb['cw'] > 0)
+					{
+						$cw++;
+					}
+					else
+					{
+						$xq .= $ftpb['pb'];
+					}
+					if(isset($pb[1]))//有蕾丝头套
+					{
+						$xq .= $pb['1'].'+';//发块
+					}
+					$hf = $this->js($xq);
+				}
+				else
+				{
+					if(stripos($pb,'/') !== false)
+					{
+						$cw++;
+					}
+					$xq .= $pb;
+					$pb = explode('+',trim($pb,'+'));
+					$hf = $this->js($pb);
+				}
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'请填写配比信息!','success'=>false));exit;
+			}
+			if($cw > 0)
+			{
+				echo json_encode(array('msg'=>'配比信息错误,请检查!','success'=>false));exit;
+			}
+			$post['gl'] = $hf['gl'];
+			$post['weight'] = $hf['zzl'];
+			$post['zh'] = $hf['zh'];
+			$post['time'] = time();
+			$pid = $post['category'].'-'.$post['lace'].'-'.$post['density'].'-'.$post['size'];
+			$post['pid'] = str_replace(array('---','--'),'-',$pid);
+			$post['pbxq'] = trim($xq,'+');
+			if($this->distribution->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('distribution_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$category = $this->input->post('category',true);
+			$lace = $this->input->post('lace',true);
+			$density = $this->input->post('density',true);
+			$size = $this->input->post('size',true);
+			$size = trim($size,',');
+			$pb = $this->input->post('pb',true);
+			$post['category'] = (isset($t[$category]))?$t[$category]:'';
+			$post['lace'] = (isset($t[$lace]))?$t[$lace]:'';
+			$post['density'] = (isset($t[$density]))?$t[$density]:'';
+			$post['size'] = (isset($t[$size]))?$t[$size]:'';
+			$post['pb'] = $pb;
+			if($post['category'] == '' || $post['size'] == '')
+			{
+				echo json_encode(array('msg'=>'提交信息有误,请检查','success'=>false));exit;
+			}
+			$gl = '';$fl = array();$zzl = 0;$cw = 0;$xq = '';
+			if($pb != '')
+			{
+				if($post['category'] == 128)
+				{
+					$pb = explode('/',trim($pb,'/'));
+					$ftpb = $this->ft($pb);
+					if($ftpb['cw'] > 0)
+					{
+						$cw++;
+					}
+					else
+					{
+						$xq .= $ftpb['pb'];
+					}
+					if(isset($pb[1]))//有蕾丝头套
+					{
+						$xq .= $pb['1'].'+';//发块
+					}
+					$hf = $this->js($xq);
+				}
+				else
+				{
+					if(stripos($pb,'/') !== false)
+					{
+						$cw++;
+					}
+					$xq .= $pb;
+					$pb = explode('+',trim($pb,'+'));
+					$hf = $this->js($pb);
+				}
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'请填写配比信息!','success'=>false));exit;
+			}
+			if($cw > 0)
+			{
+				echo json_encode(array('msg'=>'配比信息错误,请检查!','success'=>false));exit;
+			}
+			$post['gl'] = $hf['gl'];
+			$post['weight'] = $hf['zzl'];
+			$post['zh'] = $hf['zh'];
+			$post['time'] = time();
+			$pid = $post['category'].'-'.$post['lace'].'-'.$post['density'].'-'.$post['size'];
+			$post['pid'] = str_replace(array('---','--'),'-',$pid);
+			$post['pbxq'] = trim($xq,'+');
+			if($this->distribution->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$distribution = $this->distribution->read($arg_array);
+		$this->data['distribution'] = $distribution;
+		$this->_Template('distribution_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->distribution->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	
+	public function _drmb()
+	{
+				$title = '导入模板'; 
+                $titlename = "<table border=1>
+                <tr align='center'>
+				<td>类目</td>
+				<td>蕾丝类型</td>
+				<td>密度</td>
+				<td>尺寸</td>
+				<td style='width:300px'>配比 (按照右侧格式填写)</td>
+				<td>发条 :原材料尺寸-克数+原材料尺寸-克数  具体示例: 6-0.2+8-0.2+10-0.3+12-0.3<br>
+				发块: 原材料尺寸-克数+原材料尺寸-克数  具体示例: 8-0.1+10-0.1+12-0.25+14-0.25+16-0.3<br>
+				不含蕾丝头套:填写所需发条的尺寸(发条尺寸-克数+发条尺寸-克数+发条尺寸-克数) 具体示例: 14-20+16-10+18-8<br>
+				有发块的蕾丝头套(/后填发块原材料配比):发条尺寸-克数+发条尺寸-克数+发条尺寸-克数/发块原材料配比 具体示例: 14-20+16-10+18-8/18<br>
+				无发块的蕾丝头套(/后填蕾丝配比):发条尺寸-克数+发条尺寸-克数+发条尺寸-克数/蕾丝原材料配比 具体示例: 14-20+16-10+18-8/6-0.2+8-0.2+10-0.1<br>
+				全蕾丝头套:原材料尺寸-克数+原材料尺寸-克数  具体示例: 6-0.2+8-0.2+10-0.3+12-0.3<br></td>
+                </tr></table>";
+				$lm = array('发条','发块前头','头套');
+				$md = $this->typeclass->find_all("classid = '10'");
+				$ttls = $this->typeclass->find_all("classid = '18'");
+				$fkls = $this->typeclass->find_all("classid = '25' or classid = '26'");
+				$cc = $this->typeclass->find_all("classid = '14'");
+				$rowsdq = array();
+				foreach ($lm as $vvv) 
+		        {
+					
+					if($vvv == '头套')
+					{
+						foreach ($ttls as $vv) 
+		                {
+							foreach ($md as $v) 
+		                    {
+								foreach ($cc as $val) 
+		                        {
+									if(stripos($v['zh'],'|') !== false)
+									{
+										$vzh =  explode('|',$v['zh']);
+										$v['zh'] = $vzh[0];
+									}
+									if($val['spare'] == 'Short Hair')
+									{
+										$val['spare'] = '短款';
+									}
+					                $rowsdq[] = array($vvv,$vv['zh'],$v['title'],$val['spare'],'');
+								}
+							}
+						}
+					}
+					else if($vvv == '发块前头')
+					{
+						foreach ($fkls as $vv) 
+		                {
+							foreach ($md as $v) 
+		                    {
+					            foreach ($cc as $val) 
+		                        {
+									if(stripos($v['zh'],'|') !== false)
+									{
+										$vzh =  explode('|',$v['zh']);
+										$v['zh'] = $vzh[0];
+									}
+									if($val['spare'] == 'Short Hair')
+									{
+										$val['spare'] = '短款';
+									}
+					               $rowsdq[] = array($vvv,$vv['zh'],$v['title'],$val['spare'],'');
+								}
+							}
+						}
+					}
+					else
+					{
+						foreach ($cc as $val) 
+		                {
+							if($val['spare'] == 'Short Hair')
+							{
+								$val['spare'] = '短款';
+							}
+							$rowsdq[] = array($vvv,'','',$val['spare'],'');
+						}
+					}
+				}
+	    $filename = $title.".xls";
+			        $tail = "\n";
+                    $this->excel->get_fz2($rowsdq,$titlename,$filename,$tail);
+	}
+	
+	public function _dr()
+	{
+		$dir = '/data/excel/'.date('Ymd',time()).'/';
+		$config['upload_path'] = '.'.$dir ;
+		$config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
+        $config['allowed_types'] = 'xls|xlsx|csv';
+        $config['max_size'] = 10240;
+		$this->load->library('upload', $config);
+		$this->upload->initialize($config);
+        if ($this->upload->do_upload('userfile'))
+        {
+			$full_path = $dir.$this->upload->data('file_name');
+			$fileName = '.' . $full_path;
+            if (!file_exists($fileName)) 
+			{
+				echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
+            }
+			else
+			{
+				libxml_use_internal_errors(true);
+				require_once "./data/excel/PHPExcel/IOFactory.php";
+				$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
+				$phpExcel->setActiveSheetIndex(0);// 设置为默认表
+				$sheetCount = $phpExcel->getSheetCount();// 获取表格数量
+				$row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
+				$column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
+				++$column;//如果列数大于26行
+				$list = array();
+				for ($i = 2; $i <= $row; $i++) // 行数循环
+				{
+					$data = array();
+                    for ($c = 'A'; $c != $column; $c++)  // 列数循环
+	                {
+						$data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
+                    }
+					$list[] = $data;
+                }
+			}
+			$tz = array();$bs = array();
+			$typeclassa = $this->typeclass->find_all("zh != ''");
+			foreach ($typeclassa as $v)
+			{
+				$tz[$v['zh']] = $v['id'];
+			}
+			$typeclassb = $this->typeclass->find_all("bqsku != ''");
+			foreach ($typeclassb as $v)
+			{
+				$bs[$v['bqsku']] = $v['id'];
+			}
+			$i = 0;$j = 0;$ed = array();$x=0;$cs = array();
+		    foreach ($list as $k=>$v)
+		    {
+				$hs = $k+2;
+				$post['category']= (isset($tz[$v[0]]))?$tz[$v[0]]:'';
+				$post['lace'] = (isset($tz[$v[1]]))?$tz[$v[1]]:'';
+			    $post['density'] = (isset($bs[$v[2]]))?$bs[$v[2]]:'';
+			    $post['size'] = (isset($bs[$v[3]]))?$bs[$v[3]]:'';
+				$post['pb'] = $v[4];
+				$pb = $v[4];
+			    $gl = '';$fl = array();$zzl = 0;$cw = 0;$xq = '';
+			    if($pb != null)
+			    {
+				    if($post['category'] == 128)
+				    {
+					    $pb = explode('/',trim($pb,'/'));
+						$ftpb = $this->ft($pb);
+						if($ftpb['cw'] > 0)
+						{
+							$j++;
+							$ed[] = array('第'.$hs.'行导入失败,发条的配比信息有误!');
+							continue;
+						}
+						else
+						{
+							$xq .= $ftpb['pb'];
+						}
+						if(isset($pb[1]))//有蕾丝头套
+						{
+							$xq .= $pb['1'].'+';//发块
+						}
+					    $hf = $this->js($xq);
+				    }
+				    else
+				    {
+					    if(stripos($pb,'/') !== false)
+					    {
+						    $j++;
+							$ed[] = array('第'.$hs.'行导入失败,请检查配比内容1');
+							continue;
+					    }
+						$xq .= $v[4];
+					    $hf = $this->js($pb);
+				    }
+			    
+				if($hf['cw'] > 0)
+				{
+					$j++;
+					$ed[] = array($hf['cw'].' - '.json_encode($hf['nr']).' - 第'.$hs.'行导入失败,请检查配比内容2');
+					continue;
+				}
+			    $post['gl'] = $hf['gl'];
+			    $post['weight'] = $hf['zzl'];
+				$post['zh'] = $hf['zh'];
+			    $pid = $post['category'].'-'.$post['lace'].'-'.$post['density'].'-'.$post['size'];
+			    $post['pid'] = str_replace(array('---','--'),'-',$pid);
+			    $post['pbxq'] = trim($xq,'+');
+				$x = $this->distribution->get_pid($post['pid']);
+				if($x)
+				{
+					if(!$this->distribution->save($post,$x['id']))
+					{
+						$j++;
+						$ed[] = array('第'.$hs.'行导入失败,请重试1');
+					}
+				}
+				else
+				{
+					$post['time'] = time();
+					if(!$this->distribution->insert($post))
+					{
+						$j++;
+						$ed[] = array('第'.$hs.'行导入失败,请重试2');
+					}
+				}
+				}
+			}
+			if($j > 0)
+			{
+				$time = date('Ymd',time());
+				$tt = date('Ymd',time());
+				$title = '导入错误信息-'.$tt;
+        		$titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
+				$tail = "\n";
+        		$filename = $title.".xls";
+        		$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
+				$dir = '/data/excel/'.$time.'/';
+				$file_name = 'error_'.$time.rand(1000,9999);
+				if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
+				$myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
+				fwrite($myfile,$ecl);
+				fclose($myfile);
+				$error = $dir.$file_name.'.xls';
+				echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'导入成功!','error'=>$cs,'success'=>true));exit;
+			}
+		}
+	}
+	
+	public function ft($pb)
+	{
+		$t = array();$bs = array();
+		$typeclass = $this->typeclass->find_all();
+		foreach ($typeclass as $v)
+		{
+			$t[$v['id']] = $v['id'];
+			$bs[$v['bqsku']] = $v['id'];
+		}
+		$xq = '';$j = 0;
+		$pb[0] = explode('+',trim($pb[0],'+'));
+		foreach ($pb[0] as $val) //发条
+		{
+			$sz = explode('-',$val);
+			if(!isset($sz[1]) || !isset($bs[$sz[0]]))
+			{
+				$j++;
+				break;
+			}
+			$sizedata = $this->distribution->ge_size(126,$bs[$sz[0]]);
+			if(!$sizedata)
+			{
+				 $j++;
+				 break;
+			}
+			$bl = $sz[1]/$sizedata['weight'];
+			$ftpb = explode('+',$sizedata['pb']);
+			foreach ($ftpb as $v) 
+		    {
+				$xxzl = explode('-',$v);
+				$xq .= $xxzl[0].'-'.sprintf("%01.2f",$xxzl[1]*$bl).'+';
+			}
+		}
+		if($j > 0)
+		{
+			return array('cw'=>1);
+		}
+		else
+		{
+			return array('cw'=>0,'pb'=>$xq);
+		}
+	}
+	public function js($data)
+	{
+		$zzl = 0;$gl = '';$fl=array();$cw=0;$nr = array();$zh = '';
+		$pb = explode('+',trim($data,'+'));
+		if(isset($pb))
+		{
+		    foreach ($pb as $k=>$v) 
+		    {
+			    $v = explode('-',trim($v,'-'));
+				if(!isset($v[1]))
+				{
+					$cw = 1;
+					$nr[] = array($pb,$pb[$k]);
+					break;
+				}
+			    if(!is_numeric($v[0]) || !is_numeric($v[1]))
+			    {
+			    	$cw = 2;
+					$nr[] = array($pb,$pb[$k]);
+					break;
+			    }
+			    $zzl += $v[1];
+			    if(isset($fl[$v[0]]))
+			    {
+			    	$fl[$v[0]] += $v[1];
+			    }
+			    else
+			    {
+			    	$fl[$v[0]] = $v[1];
+			    }
+		    }
+		    foreach ($fl as $k=>$v) 
+		    {
+				$zh .= $k.'inch:'.$v.'g<br>'; 
+		    	$gl .= $k.'-'.$v.'+';
+		    }
+		}
+		else
+		{
+			$cw = 3;
+		}
+		if($cw < 1)
+		{
+			return array('cw'=>0,'gl'=>trim($gl,'+'),'zzl'=>$zzl,'zh'=>trim($zh,'<br>'));
+		}
+		else
+		{
+			return array('cw'=>$cw,'nr'=>$nr);
+		}
+	}
+	
+	public function _db()
+	{
+		$t = array();$y = array();$w = array();$cc = array();
+		$typeclass = $this->typeclass->find_all();
+		foreach ($typeclass as $v)
+		{
+			if($v['classid'] == 14)
+			{
+				$cc[$v['bqsku']] = 0;
+			}
+			$t[$v['id']] = $v['bqsku'];
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($_GET['dktime']))  
+		{
+		    $ktime = $this->input->get('dktime',true);
+			$jtime = $this->input->get('djtime',true);
+			$ktime = strtotime($ktime);
+			$jtime = strtotime($jtime);
+		$pb = array();$zz = '';
+		$distribution = $this->distribution->find_all();
+		foreach ($distribution as $val) 
+		{
+			$pb[$val['pid']] = array('weight'=>$val['weight'],'gl'=>$val['gl'],'zh'=>$val['zh']);
+		}
+		$where = "shop != '9' and shop != '26' and type != '3' and type != '5' and type != '7' and type != '8' and type != '9' and type != '10' and type != '12' and library = '2' and librarytime > '".$ktime."' and librarytime < '".$jtime."'";
+		$dlz = $this->fullorder->find_all($where,'id,fpdata,number,orderinfo','id desc',0,5);
+		$smt = $this->fullordersmt->find_all($where,'id,fpdata,number,orderinfo','id desc',0,5);
+		$data = array_merge($dlz,$smt);
+		$product = array();
+		foreach ($data as $val) 
+		{
+			$sy = array();
+			$cp = explode(';',trim($val['fpdata'],';'));
+			foreach ($cp as $v) 
+		    {
+				$a = 0;
+				$v = explode('|',trim($v,'|'));
+				$qb = explode(',',$v[0]);
+				$szid = $qb[0];//尺寸ID
+				if(!isset($qb[1]))
+				{
+					$w[] = array('number'=>$val['number'],'orderinfo'=>$val['orderinfo'],'产品参数错误',$v);
+					continue;
+				}
+				$qb = explode('-',trim($qb[1],'-'));//尺寸外其它参数
+				if($qb[0] == '126')
+				{
+					if(isset($pb[$qb[0].'-'.$szid]))
+					{
+						$a = 1;
+						$zz .= $pb[$qb[0].'-'.$szid]['gl'].'+';
+						$y[] = array('number'=>$val['number'],'orderinfo'=>$val['orderinfo'],'title'=>$v[1],'weight'=>$pb[$qb[0].'-'.$szid]['weight'].'g','zh'=>$pb[$qb[0].'-'.$szid]['zh']);
+					}
+				}
+				else if($qb[0] == '127')
+				{
+					if(isset($pb[$qb[0].'-'.$qb[6].'-'.$qb[7].'-'.$szid]))
+					{
+						$a = 1;
+						$zz .= $pb[$qb[0].'-'.$qb[6].'-'.$qb[7].'-'.$szid]['gl'].'+';
+						$y[] = array('number'=>$val['number'],'orderinfo'=>$val['orderinfo'],'title'=>$v[1],'weight'=>$pb[$qb[0].'-'.$qb[6].'-'.$qb[7].'-'.$szid]['weight'].'g','zh'=>$pb[$qb[0].'-'.$qb[6].'-'.$qb[7].'-'.$szid]['zh']);
+					}
+				}
+				else if($qb[0] == '128')
+				{
+					if(isset($pb[$qb[0].'-'.$qb[4].'-'.$qb[6].'-'.$szid]))
+					{
+						$a = 1;
+						$zz .= $pb[$qb[0].'-'.$qb[4].'-'.$qb[6].'-'.$szid]['gl'].'+';
+						$y[] = array('number'=>$val['number'],'orderinfo'=>$val['orderinfo'],'title'=>$v[1],'weight'=>$pb[$qb[0].'-'.$qb[4].'-'.$qb[6].'-'.$szid]['weight'].'g','zh'=>$pb[$qb[0].'-'.$qb[4].'-'.$qb[6].'-'.$szid]['zh']);
+					}
+				}
+				if($a == 0)
+				{
+					$w[] = array('number'=>$val['number'],'orderinfo'=>$val['orderinfo'],'','');
+				}
+			}
+		}
+		    $zz = explode('+',trim($zz,'+'));
+		    foreach ($zz as $v) 
+		    {
+				$cd = explode('-',trim($v,'-'));
+				if(isset($cc[$cd[0]]))
+				{
+					$cc[$cd[0]] += $cd[1];
+				}
+			}
+			$zzcx = '';
+			foreach ($cc as $k=>$v) 
+		    {
+				$zzcx .= $k.'inch:'.$v.'g'.'<br>';
+			}
+		    $title = date('Y-m-d',$ktime).' 至 '.date('Y-m-d',$jtime).'订单原材料配比'; 
+            $titlename = "<table border=1>
+                <tr align='center'>
+				<td>编号</td>
+				<td>订单号</td>
+				<td>产品名称</td>
+				<td>总重量</td>
+				<td>配比详情</td>
+                </tr></table>";
+		    $filename = $title.".xls";
+		    $tail = "<tr align='center'><td></td><td></td><td></td><td>所有尺寸合并数据:</td><td>".trim($zzcx,'<br>')."</td></tr>";
+            $this->excel->get_fz2($y,$titlename,$filename,$tail);
+		}
+	}
+}

+ 172 - 0
core/CoreApp/controllers/Emaildata.php

@@ -0,0 +1,172 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Emaildata extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_emaildata','emaildata');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$shop = $this->input->post('shop',true);
+			$where = "1=1 and (".rtrim($fgshop,'or').")";
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->emaildata->find_all($where,'id,shop,smtp_user,smtp_pass,smtp_host,smtp_port,protocol,smtp_crypto',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value)
+		    {
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+            }
+		    $total = $this->emaildata->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$this->_Template('emaildata',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['shop']))
+		{
+			$post['time'] = time();
+			if($this->emaildata->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$this->_Template('emaildata_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		$id = $this->input->post('id', TRUE);
+		if(isset($post['id']))
+		{
+			if($this->emaildata->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$email = $this->emaildata->read($arg_array);
+		$this->data['emaildata'] = $email;
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$this->_Template('emaildata_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->emaildata->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 135 - 0
core/CoreApp/controllers/Employee.php

@@ -0,0 +1,135 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Employee extends Start_Controller {
+    public function __construct(){
+		parent::__construct();
+        $this->load->library('session');
+		$this->load->_model('Model_employee','employee');
+    }
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'sign')//添加
+        {
+             $this->sign();
+        }elseif ($arg == 'add') {
+			$this->_add();
+		}elseif ($arg == 'edit') {
+			$this->_edit($arg_array);
+		}
+		else
+		{
+			 $this->_index();
+		}
+    }
+		//管理
+		public function _index()
+		{
+			$post = $this->input->post(NULL, TRUE);
+			if(isset($post['page']))  
+			{
+				$page = $this->input->post('page',true);
+				$id = $this->input->post('id',true);
+				$name = $this->input->post('name',true);
+				$number = $this->input->post('number',true);
+				$where = "1=1 ";
+				if($id)
+				{
+					$where  .= " and id = '$id'";
+				}
+				if($name)
+				{
+					$where  .= " and name = '$name'";
+				}
+				if($number)
+				{
+					$where  .= " and number = '$number'";
+				}
+				
+				//数据排序
+				$order_str = "id asc";
+				
+				//取得信息列表
+				$info_list = $this->employee->find_all($where,'id,number,name,sex,sign_at,created_at',$order_str);
+				foreach ($info_list as $key=>$value) 
+				{
+					if($value['sex'] == 1)
+					{
+						$info_list[$key]['sex'] = "男";
+					}
+					else
+					{
+						$info_list[$key]['sex'] = "女";
+					}
+					$info_list[$key]['sign_at'] =$info_list[$key]['sign_at'] ? date('Y-m-d',$value['sign_at']):"未打卡";
+					$info_list[$key]['created_at'] = date('Y-m-d',$value['created_at']);
+				}
+				$rows = array('rows'=>($info_list));
+				echo json_encode($rows);exit;
+			}
+			$this->_Template('employee',$this->data);
+		}
+			//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['number']))
+		{
+			$post['number'] = $this->input->post('number',true);
+			$post['name'] = $this->input->post('name',true);
+			$post['sex'] = $this->input->post('sex',true);
+			$post['created_at'] = time();
+			if($this->employee->insert($post))
+        	{
+				echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('employee_add',$this->data);
+	}
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['number'] = $this->input->post('number',true);
+			$post['name'] = $this->input->post('name',true);
+			$post['sex'] = $this->input->post('sex',true);
+			if($this->employee->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$employee = $this->employee->read($arg_array);
+		$this->data['employee'] = $employee;
+		$this->_Template('employee_edit',$this->data);
+	}
+	public function sign(){
+		$post = $this->input->post(NULL, TRUE);
+		$employee_ids=$post['ids'];
+		$employee_ids=explode(',',trim($employee_ids,','));
+		if(!isset($employee_ids)||empty($employee_ids)){
+			return false;
+		}
+		$res1=$this->db->set('sign_at',time())->where_in('id',$employee_ids)->update('employee');
+		// $res2=$this->db->set('sign_at',NULL)->where_not_in('id',$employee_ids)->update('employee');
+		if($res1){
+			echo json_encode(array('msg'=>'打卡成功','success'=>true));exit;
+		}else{
+			echo json_encode(array('msg'=>'打卡失败,请重试','success'=>false));exit;
+		}
+		return ;
+	}
+
+	
+
+
+
+}

+ 105 - 0
core/CoreApp/controllers/Evaluate.php

@@ -0,0 +1,105 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Evaluate extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_evaluate','evaluate');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$shop = $this->input->post('shop',true);
+			$orderinfo = $this->input->post('orderinfo',true);
+			$name = $this->input->post('name',true);
+			$grade = $this->input->post('grade',true);
+			$where = "1=1";
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($name)
+            {
+                $where  .= " and name = '$name'";
+            }
+			if($grade != "")
+            {
+                $where  .= " and grade = '$grade'";
+            }
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->evaluate->find_all($where,'id,shopname,shopid,orderinfo,name,grade,content,time',$order_str,$start,$perpage);
+			//格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				if($value['grade'] == 0)
+				{
+					$info_list[$key]['grade'] = "未评价";
+				}
+				else
+				{
+					$info_list[$key]['grade'] = $value['grade']."星";
+				}
+				$info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
+            }
+		    $total = $this->evaluate->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('evaluate',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['grade']))
+		{
+			$post['grade'] = $this->input->post('grade',true);
+			$post['content'] = $this->input->post('content',true);
+			/** 接口提交
+			if($this->evaluate->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+			**/
+		}
+		$this->_Template('evaluate_add',$this->data);
+	}
+}

+ 388 - 0
core/CoreApp/controllers/Express.php

@@ -0,0 +1,388 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Express extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_service','service');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_describecode','describecode');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')//获取数据
+        {
+             $this->_rows();
+        }
+		else if($arg == 'describecode')//修改describecode数据
+        {
+             $this->_describecode();
+        }
+		else if($arg == 'packing')//修改packing数据
+        {
+             $this->_packing();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$servicename = $this->input->post('servicename',true);
+			$off = $this->input->post('off',true);
+			$where = "1=1 ";
+			if($servicename)
+            {
+                $where  .= " and servicename like '%$servicename%'";
+            }
+			if($off != '')
+            {
+                $where  .= " and off = '$off'";
+            }
+            //数据排序
+            $order_str = "idsort desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->express->find_all($where,'id,servicename,title,url,printcode,cxcode,type,out,addresssize,off,idsort',$order_str,$start,$perpage);
+			foreach ($info_list as $k=>$v) 
+		    {
+				if($v['type'] == '1')
+				{
+					$info_list[$k]['type'] = '运单';
+				}
+				else if($v['type'] == '2')
+				{
+					$info_list[$k]['type'] = '发货单';
+				}
+				else if($v['type'] == '3')
+				{
+					$info_list[$k]['type'] = '不打印单据';
+				}
+				if($v['out'] == '1')
+				{
+					$info_list[$k]['out'] = '运单';
+				}
+				else if($v['out'] == '2')
+				{
+					$info_list[$k]['out'] = '发货单';
+				}
+				else if($v['out'] == '3')
+				{
+					$info_list[$k]['out'] = '运单+发货单';
+				}
+				if($v['off'] == '0')
+				{
+					$info_list[$k]['off'] = '显示';
+				}
+				else if($v['off'] == '1')
+				{
+					$info_list[$k]['off'] = '隐藏';
+				}
+			}
+			//格式化数据
+		    $total = $this->express->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$class = $this->service->find_all();
+		$this->data['class'] = $class;
+		$this->_Template('express',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['title']))
+		{
+			$post['title'] = $this->input->post('title',true);
+			$post['service'] = $this->input->post('service',true);
+			$post['servicecode'] = $this->input->post('servicecode',true);
+			$post['servicetitle'] = $this->input->post('servicetitle',true);
+			$post['servicename'] = $this->input->post('servicename',true);
+			//$post['account'] = $this->input->post('account',true);
+			//$post['billweight'] = $this->input->post('billweight',true);
+			//$post['often'] = $this->input->post('often',true);
+			$post['url'] = $this->input->post('url',true);
+			$post['type'] = $this->input->post('type',true);
+			$post['ioss'] = $this->input->post('ioss',true);
+			//$post['freight'] = $this->input->post('freight',true);
+			//$post['ordername'] = $this->input->post('ordername',true);
+			//$post['slip'] = $this->input->post('slip',true);
+			//$post['deliver'] = $this->input->post('deliver',true);
+			$packing = $this->input->post('packing',true);
+			$describecode = $this->input->post('describecode',true);
+			if($packing != NULL)
+			{
+				$pnum = array();
+				$packingdata = explode('|',rtrim($packing,'|'));
+                foreach ($packingdata as $k=>$v) 
+		        {
+				    $rows = explode(',',rtrim($v,','));
+					$packingpost['classid'] = 1;
+					$packingpost['model'] = $rows[0];
+			        $packingpost['weightend'] = $rows[1];
+			        $packingpost['weight'] = $rows[2];
+					$packingpost['time'] = time().rand(1000,9999);
+					if($this->packing->insert($packingpost))
+					{
+						$pnum[] = $packingpost['time'];
+					}
+					
+                }
+			    $post['packing'] = "|";
+				foreach ($pnum as $k=>$v) 
+		        {
+				    $pdata = $this->packing->get_time($v);
+				    $post['packing'] = $post['packing'].$pdata['id']."|";
+			    }
+			}
+			if($describecode != NULL)
+			{
+				$dnum = array();
+				$describecodedata = explode('|',rtrim($describecode,'|'));
+                foreach ($describecodedata as $k=>$v) 
+		        {
+				    $rows = explode(',',rtrim($v,','));
+					$describecodepost['product'] = $rows[0];
+			        $describecodepost['expresscode'] = $rows[1];
+					$describecodepost['time'] = time().rand(1000,9999);
+					if($this->describecode->insert($describecodepost))
+					{
+						$dnum[] = $describecodepost['time'];
+					}
+                }
+				$post['describecode'] = "|";
+				foreach ($dnum as $k=>$v) 
+		        {
+				    $ddata = $this->describecode->get_time($v);
+				    $post['describecode'] = $post['describecode'].$ddata['id']."|";
+			    }
+			}
+			if($this->express->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$class = $this->service->find_all("1=1",'*','title asc');
+		$this->data['class'] = $class;
+		$this->_Template('express_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['title'] = $this->input->post('title',true);
+			$post['service'] = $this->input->post('service',true);
+			$post['servicecode'] = $this->input->post('servicecode',true);
+			$post['servicetitle'] = $this->input->post('servicetitle',true);
+			$post['servicename'] = $this->input->post('servicename',true);
+			//$post['account'] = $this->input->post('account',true);
+			$post['billweight'] = $this->input->post('billweight',true);
+			$post['often'] = $this->input->post('often',true);
+			$post['url'] = $this->input->post('url',true);
+			$post['type'] = $this->input->post('type',true);
+			$post['freight'] = $this->input->post('freight',true);
+			$post['ordername'] = $this->input->post('ordername',true);
+			$post['slip'] = $this->input->post('slip',true);
+			$post['deliver'] = $this->input->post('deliver',true);
+			$post['ioss'] = $this->input->post('ioss',true);
+			$packingsun = $this->input->post('packing',true);
+			$describecodesun = $this->input->post('describecode',true);
+			$express = $this->express->read($id);
+			$packingmoon="";$describecodemoon="";
+			if($packingsun != NULL)
+			{
+				$pnum = array();
+				$packingdata = explode('|',rtrim($packingsun,'|'));
+                foreach ($packingdata as $k=>$v) 
+		        {
+				    $rows = explode(',',rtrim($v,','));
+					$packingpost['classid'] = 1;
+					$packingpost['model'] = $rows[0];
+			        $packingpost['weightend'] = $rows[1];
+			        $packingpost['weight'] = $rows[2];
+					$packingpost['time'] = time().rand(1000,9999);
+					if($this->packing->insert($packingpost))
+					{
+						$pnum[] = $packingpost['time'];
+					}
+					
+                }
+				foreach ($pnum as $k=>$v) 
+		        {
+				    $pdata = $this->packing->get_time($v);
+				    $packingmoon = $packingmoon.$pdata['id']."|";
+			    }
+			}
+			if($describecodesun != NULL)
+			{
+				$dnum = array();
+				$describecodedata = explode('|',rtrim($describecodesun,'|'));
+                foreach ($describecodedata as $k=>$v) 
+		        {
+				    $rows = explode(',',rtrim($v,','));
+					$describecodepost['product'] = $rows[0];
+			        $describecodepost['expresscode'] = $rows[1];
+					$describecodepost['time'] = time().rand(1000,9999);
+					if($this->describecode->insert($describecodepost))
+					{
+						$dnum[] = $describecodepost['time'];
+					}
+                }
+				foreach ($dnum as $k=>$v) 
+		        {
+				    $ddata = $this->describecode->get_time($v);
+				    $describecodemoon = $describecodemoon.$ddata['id']."|";
+			    }
+			}
+			$post['packing'] = $express['packing'].$packingmoon;
+			$post['describecode'] = $express['describecode'].$describecodemoon;
+			if($this->express->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$express = $this->express->read($arg_array);
+		$class = $this->service->find_all("1=1",'*','title asc');
+		$this->data['class'] = $class;
+		$this->data['express'] = $express;
+		$pdata = array();$ddata = array();
+		if($express['packing'])
+		{
+		    $packing = $express['packing'];
+		    $packing = explode('|',trim($packing,'|'));
+		    foreach ($packing as $k=>$v) 
+		    {
+		    	$pdata[] = $this->packing->read($v);
+            }
+		}
+		if($express['describecode'])
+		{
+		    $describecode = $express['describecode'];
+		    $describecode = explode('|',trim($describecode,'|'));
+		    foreach ($describecode as $k=>$v) 
+		    {
+			    $ddata[] = $this->describecode->read($v);
+            }
+			foreach ($ddata as $k=>$v) 
+		    {
+			    $sdata = $this->typeclass->read($v['product']);
+			    $ddata[$k]['producttitle'] = $sdata['title'];
+            }
+		}
+		$this->data['pdata'] = $pdata;
+		$this->data['ddata'] = $ddata;
+		$this->_Template('express_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->express->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	//修改数据
+	public function _describecode()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $s = $this->input->post('s');
+			$id= $this->input->post('id');
+			$express = $this->express->read($id);
+            $describecode = str_replace('|'.$s.'|','|',$express['describecode']);
+			if($describecode == "|")
+			{
+				$describecode = "";
+			}
+            if($this->express->save(array('describecode'=>$describecode),$id))//写入删除后的数据
+			{
+				 echo json_encode(array('success'=>true));exit;
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
+			}
+		}
+    }
+	//修改数据
+	public function _packing()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $s = $this->input->post('s');
+			$id= $this->input->post('id');
+			$express = $this->express->read($id);
+            $packing = str_replace('|'.$s.'|','|',$express['packing']);
+			if($packing == "|")
+			{
+				$packing = "";
+			}
+            if($this->express->save(array('packing'=>$packing),$id))//写入删除后的数据
+			{
+				 echo json_encode(array('success'=>true));exit;
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
+			}
+		}
+    }
+}

Diff do ficheiro suprimidas por serem muito extensas
+ 1356 - 0
core/CoreApp/controllers/Finance.php


Diff do ficheiro suprimidas por serem muito extensas
+ 5914 - 0
core/CoreApp/controllers/Fullorder.php


Diff do ficheiro suprimidas por serem muito extensas
+ 2830 - 0
core/CoreApp/controllers/Fullorder_smt.php


Diff do ficheiro suprimidas por serem muito extensas
+ 2295 - 0
core/CoreApp/controllers/Fullorderexcel.php


+ 479 - 0
core/CoreApp/controllers/Fullorderout.php

@@ -0,0 +1,479 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Fullorderout extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+		$this->load->_model('Model_fullorderout','fullorderout');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_whlabel','whlabel');
+		$this->load->_model('Model_specialstock','specialstock');
+		$this->load->_model('Model_fullorderoutlist','fullorderoutlist');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'edit')
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'cz')
+        {
+             $this->_cz($arg_array);
+        }
+		else if($arg == 'list')
+        {
+             $this->_list($arg_array);
+        }
+		else
+		{
+			$this->_index();
+		}
+    }
+	
+	public function _index()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$name = $this->input->post('name',true);
+			$shop = $this->input->post('shop',true);
+			$number = $this->input->post('number',true);
+			$orderinfo = $this->input->post('orderinfo',true);
+			$waybill = $this->input->post('waybill',true);
+			$timetk = $this->input->post('timetkk',true);
+			$timetj = $this->input->post('timetjj',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "1 = 1";
+			if($timetk && $timetj)
+            {
+                $where .= " and stime > '$timetk' and stime < '$timetj'";
+            }
+			if($name)
+            {
+                $where  .= " and name = '$name'";
+            }
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($waybill)
+            {
+                $where  .= " and waybill = '$waybill'";
+            }
+            //数据排序
+            $order_str = "stime desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->fullorderout->find_all($where,'id,shop,name,number,orderinfo,express,waybill,stime',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				$express = $this->express->read($value['express']);
+				$info_list[$key]['express'] = $express['servicename'];
+				$info_list[$key]['stime'] = date('Y-d-m H:i:s',$value['stime']);
+		    }
+		    $total = $this->fullorderout->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		if(isset($post['hq']))  
+		{
+			$label = $this->input->post('hq',true);
+			$warehouse = $this->input->post('warehouse',true);
+			if(!$label)
+			{
+				echo json_encode(array('msg'=>'输入信息不能为空!','success'=>false));exit;
+			}
+			$fullorder_name = 'fullorder';$outtype = 1;
+			$y = $this->fullorder->get_waybill($label);
+			if(!$y)
+			{
+				$y = $this->fullorder->get_number($label);
+				if(!$y)
+				{
+					$fullorder_name = 'fullordersmt';$outtype = 1;
+					$y = $this->fullordersmt->get_waybill($label);
+					if(!$y)
+				    {
+						$y = $this->fullordersmt->get_number($label);
+						if(!$y)
+						{
+							echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
+						}
+						
+					}
+				}
+			}
+			
+			$y['stime'] = time();
+			unset($y['id']);
+		    $fpdata = explode(';',rtrim($y['fpdata'],';'));
+			$y['fpdata'] = '';
+		    foreach ($fpdata as $k=>$v) 
+		    {
+				$d = explode('|',$v);
+				$c = $d[2];
+				for($i=0;$i<$c;$i++) 
+		        {
+					$d['2'] = 0;
+					$d['3'] = '';
+					$y['fpdata'] .= implode("|",$d).';';
+				}
+            }
+			$whlabellist = '|';
+			$whlabel = explode('|',trim($y['whlabel'],'|'));
+			foreach ($whlabel as $k=>$v) 
+		    {
+				$d = explode('-',$v);
+				$c = $d[1];
+				for($i=0;$i<$c;$i++) 
+		        {
+					$d['1'] = 1;
+					$whlabellist .= implode("-",$d).'|';
+				}
+            }
+			$y['whlabel'] = $whlabellist;
+			$y['content'] = '';
+			if($this->fullorderout->insert($y))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$this->_Template('fullorderout',$this->data);
+    }
+	
+	public function _edit($arg_array)
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			if($user['vip'] == 1)
+			{
+				$vip = 1;
+			}
+			else
+			{
+				$vip = 0;
+			}
+		}
+		else
+		{
+			$vip = 0;
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$data = $this->fullorderout->read($id);
+			$content = $this->input->post('content',true);
+			$fpdata = $this->input->post('fpdata',true);
+			$torderinfo = $this->input->post('torderinfo',true);
+			$thexpress = $this->input->post('thexpress',true);
+			$fpdata = preg_replace(array('/(\_+)/'),array(' '),$fpdata);
+			$fpdata =str_replace(array(' |','| '),array('|','|'),$fpdata);
+			$number = $this->input->post('number',true);
+			$whlabel = $data['whlabel'];
+			$whlabellist  = explode('|',trim($whlabel,'|'));
+			$fpdatalist = explode(';',rtrim($fpdata,';'));
+			$asd = array();
+			$this->db->trans_begin();
+			foreach ($whlabellist as $k=>$v) 
+		    {
+				$list = $this->fullorderoutlist->get_u($number,$v,$k);
+				if($list)
+				{
+					$read = explode('|',trim($fpdatalist[$k],'|'));
+					$this->fullorderoutlist->save(array('content'=>$content,'fpdata'=>$fpdatalist[$k],'torderinfo'=>$torderinfo,'thexpress'=>$thexpress,'fd'=>$read[3]),$list['id']);
+				}
+			}
+			$this->fullorderout->save(array('content'=>$content,'fpdata'=>$fpdata,'torderinfo'=>$torderinfo,'thexpress'=>$thexpress),$id);
+			if ($this->db->trans_status() === TRUE)
+        	{
+				$this->db->trans_commit();
+				echo json_encode(array('msg'=>'提交成功','id'=>$id,'asd'=>$whlabellist,'success'=>true));exit;
+			}
+			else
+			{
+				$this->db->trans_rollback();
+				echo json_encode(array('msg'=>'提交失败,请重试','success'=>false));exit;
+			}
+			
+		}
+		$arg_array = $arg_array[0];$fpdata = array();
+		$fullorder = $this->fullorderout->read($arg_array);
+		$this->data['fullorder'] = $fullorder;
+		
+		$shop = $this->shop->read($fullorder['shop']);
+		$this->data['shop'] = $shop['shopname'];
+		
+		$express = $this->express->read($fullorder['express']);
+		$this->data['express'] = $express['servicename'];
+		
+		$country = $this->country->read($fullorder['country']);
+		$this->data['country'] = $country['ename'];$f = array();
+		
+		$whlabel = explode('|',trim($fullorder['whlabel'],'|'));
+		$fpdata = explode(';',rtrim($fullorder['fpdata'],';'));
+		    foreach ($fpdata as $k=>$v) 
+		    {
+				$d = explode('|',$v);
+				$d['w'] = $whlabel[$k];
+				$f[] = $d;
+            }
+		$this->data['fpdata'] = $f;
+		$this->_Template('fullorderout_edit',$this->data);
+	}
+	
+	public function _cz()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['czid']))  
+		{
+			$time = time();
+			$czid = $this->input->post('czid',true);
+			$whlabel = $this->input->post('whlabel',true);
+			$number = $this->input->post('number',true);
+			$x = $this->input->post('x',true);
+			$data = $this->fullorderout->get_number($number);
+			$fpdata = explode(';',rtrim($data['fpdata'],';'));
+			$title = array(1=>'加入库存',2=>'退回国内',3=>'美仓销售',4=>'货物错误',5=>'待入库存');
+			$d = explode('|',$fpdata[$x]);
+			$d[2] = $czid;
+			$fpdata[$x] = implode("|",$d);
+			$this->db->trans_begin();
+			$k = 0;
+			if($czid == 1)
+			{
+				$k = explode('-',$whlabel);
+				if($k[2] == 'z')//特殊库存
+				{
+					$t = $this->specialstock->get_cxzd($k[0],$number);
+					if($t)
+					{
+						$this->specialstock->save(array('state'=>0,'retreat'=>$time,'time'=>$time),$t['id']);
+						$this->fullorderout->save(array('fpdata'=>implode(";",$fpdata).';'),$data['id']);
+					}
+					else
+					{
+						$d[2] = 5;
+						$fpdata[$x] = implode("|",$d);
+						$this->fullorderout->save(array('fpdata'=>implode(";",$fpdata).';'),$data['id']);
+					}
+				
+				}
+				else
+				{
+					$t = $this->whlabel->get_cxzd($k[0],$number);
+					if($t)
+					{
+						$this->whlabel->save(array('state'=>0,'retreat'=>$time,'time'=>$time),$t['id']);
+						$this->fullorderout->save(array('fpdata'=>implode(";",$fpdata).';'),$data['id']);
+					}
+					else
+					{
+						$d[2] = 5;
+						$fpdata[$x] = implode("|",$d);
+						$this->fullorderout->save(array('fpdata'=>implode(";",$fpdata).';'),$data['id']);
+					}
+					
+				}
+				$post = $data;
+				$post['pzt'] = $d[2];
+				$post['fpdata'] = $fpdata[$x];
+				$post['whlabel'] = $whlabel;
+				$post['time'] = time();
+				$post['num'] = $x;
+				unset($post['id']);
+				$this->fullorderoutlist->insert($post);
+				if ($this->db->trans_status() === TRUE)
+        		{
+					$this->db->trans_commit();
+					echo json_encode(array('msg'=>'操作成功!','id'=>$d[2],'title'=>$title[$d[2]],'x'=>$x,'success'=>true));exit;
+				}
+				else
+				{
+					$this->db->trans_rollback();
+					echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
+				}
+			}
+			else
+			{
+				$post = $data;
+				$post['pzt'] = $czid;
+				$post['fpdata'] = $fpdata[$x];
+				$post['whlabel'] = $whlabel;
+				$post['time'] = time();
+				$post['num'] = $x;
+				unset($post['id']);
+				$this->fullorderoutlist->insert($post);
+				$this->fullorderout->save(array('fpdata'=>implode(";",$fpdata).';'),$data['id']);
+				if ($this->db->trans_status() === TRUE)
+        		{
+					$this->db->trans_commit();
+					echo json_encode(array('msg'=>'操作成功!','id'=>$czid,'title'=>$title[$czid],'x'=>$x,'success'=>true));exit;
+				}
+				else
+				{
+					$this->db->trans_rollback();
+					echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
+				}
+			}
+		}
+	}
+	
+	
+	public function _list()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$name = $this->input->post('name',true);
+			$shop = $this->input->post('shop',true);
+			$number = $this->input->post('number',true);
+			$orderinfo = $this->input->post('orderinfo',true);
+			$waybill = $this->input->post('waybill',true);
+			$pzt = $this->input->post('pzt',true);
+			$timetk = $this->input->post('timetkk',true);
+			$timetj = $this->input->post('timetjj',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "1 = 1";
+			if($timetk && $timetj)
+            {
+                $where .= " and stime > '$timetk' and stime < '$timetj'";
+            }
+			if($name)
+            {
+                $where  .= " and name = '$name'";
+            }
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($waybill)
+            {
+                $where  .= " and waybill = '$waybill'";
+            }
+			if($pzt)
+            {
+                $where  .= " and pzt = '$pzt'";
+            }
+            //数据排序
+            $order_str = "stime desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->fullorderoutlist->find_all($where,'id,shop,pzt,number,fpdata,fd,stime',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				if($value['pzt'] == 1)
+				{
+					$info_list[$key]['pzt'] = '加入库存';
+				}
+				else if($value['pzt'] == 2)
+				{
+					$info_list[$key]['pzt'] = '退回国内';
+				}
+				else if($value['pzt'] == 3)
+				{
+					$info_list[$key]['pzt'] = '美仓销售';
+				}
+				else if($value['pzt'] == 4)
+				{
+					$info_list[$key]['pzt'] = '货物错误';
+				}
+				else if($value['pzt'] == 5)
+				{
+					$info_list[$key]['pzt'] = '待入库存';
+				}
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				$title = explode('|',trim($value['fpdata'],'|'));
+				$info_list[$key]['fpdata'] = $title[1];
+				
+				$info_list[$key]['stime'] = date('Y-d-m H:i:s',$value['stime']);
+		    }
+		    $total = $this->fullorderoutlist->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+	    $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$this->_Template('fullorderoutlist',$this->data);
+    }
+}

Diff do ficheiro suprimidas por serem muito extensas
+ 4221 - 0
core/CoreApp/controllers/Fullordersmt.php


Diff do ficheiro suprimidas por serem muito extensas
+ 5882 - 0
core/CoreApp/controllers/Fullordertt.php


Diff do ficheiro suprimidas por serem muito extensas
+ 5864 - 0
core/CoreApp/controllers/Fullorderxw.php


+ 672 - 0
core/CoreApp/controllers/Ga.php

@@ -0,0 +1,672 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Ga extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_shop','shop');
+	}
+public function _remap($arg,$arg_array)
+    {
+		if($arg=="contentpage"){
+			$this->$arg();
+		}elseif($arg=="trafficsource"){
+			$this->$arg();
+		}elseif($arg=="chart"){
+			$this->$arg();
+		}elseif($arg=="productinfo"){
+			$this->$arg($arg_array);
+		}elseif($arg=="regionproduct"){
+			$this->$arg($arg_array);
+		}elseif($arg=="goals"){
+			$this->$arg();
+		}else{
+			$this->_index();
+		}
+	}
+	public function _index(){
+		$url="http://getdata.mywigs.com/index/index";
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+			if($user['vip'] == 1)
+			{
+				$vip = 1;
+			}
+			else
+			{
+				$vip = 0;
+			}
+		}
+		else
+		{
+			$vip = 0;
+		}
+
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		
+
+		$post = $this->input->post(NULL, TRUE);
+		$shop = $this->input->post('shop', TRUE);
+
+		if(!$shop){
+			$shop=$wlshop[0];
+		}
+		
+		$this->data['shop'] = $shop;
+
+		if(isset($post['shop']))  {
+			$param=[];
+			$days=intval($post['days']);
+			if($shop>6){
+				echo json_encode(array('msg'=>'无权限或者店铺不存在','success'=>false));exit;
+			}
+			$param['store']=$shop;
+			$param['start']=date('Y-m-d',time()-3600*24*$days);
+			$param['end']=date('Y-m-d',time());
+            $url=$url.'?'.http_build_query($param);
+			$data=$this->_curl([],$url,300,"GET");
+			$data=json_decode($data,true);
+			$last_data_url=$url.http_build_query([
+				'store'=>$shop,
+				'start'=>date('Y-m-d',time()-3600*24*$days*2),
+				'end'=>date('Y-m-d',time()-3600*24*$days),
+			]);
+			$last_data=$this->_curl([],$last_data_url,300,"GET");
+			$last_data=json_decode($last_data,true);
+			
+			if(!$data['status']||!$last_data['status']){
+				echo json_encode(array('msg'=>'获取失败,请重试','success'=>false));exit;
+			}else{
+				$data=$data['data'];
+				$last_data=$last_data['data'];
+
+				$users=[];
+				$visitor=$data['visitor'];
+				$geo=$data['geo'];
+				foreach($visitor as $k=>$v){
+					if($v['userType']=="New Visitor"){
+						$users['new'][]=$v['newUsers'];
+						$users['date'][]=date('Y-m-d',strtotime($v['date']));
+					}else{
+						$users['return'][]=$v['users'];
+					}
+				}
+				$totalSellCount=array_sum(array_column($geo,'transactions'));
+				$regionStr="";
+				foreach($geo as $k=>$v){
+					$percent=round($v['transactions']/$totalSellCount*100,2)."%";
+					$geo[$k]['percent']=$percent;
+				}
+				$sell=[];
+				$sell['date']['hour']=array_column($data['sell']['hour'],'dateHour');
+				$sell['date']['day']=array_column($data['sell']['day'],'date');
+				$sell['date']['week']=array_column($data['sell']['week'],'isoYearIsoWeek');
+				$sell['date']['month']=array_column($data['sell']['month'],'yearMonth');
+
+				$sell['date']['hour']=array_map(function($item){
+					return date('m/d H',strtotime($item."00")).":00";
+				},$sell['date']['hour']);
+
+				$sell['date']['day']=array_map(function($item){
+					return date('m/d',strtotime($item));
+				},$sell['date']['day']);
+				$sell['date']['week']=array_map(function($item){
+					return date('Y/W',strtotime(substr_replace($item,"W",-2,0)));
+				},$sell['date']['week']);
+
+				$sell['date']['month']=array_map(function($item){
+					return date('Y/m',strtotime($item));
+				},$sell['date']['month']);
+				foreach($data['sell'] as $k=>$v){
+					foreach($v as $item){
+						if(isset($item['date'])&&!empty($item['date'])){
+							$date=date('m/d',strtotime($item['date']));
+						}
+						if(isset($item['dateHour'])&&!empty($item['dateHour'])){
+							$date=date('m/d H',strtotime($item['dateHour']."00")).":00";
+						}
+						if(isset($item['yearMonth'])&&!empty($item['yearMonth'])){
+							$date=date('Y-m',strtotime($item['yearMonth']));
+						}
+
+						if(isset($item['isoYearIsoWeek'])&&!empty($item['isoYearIsoWeek'])){
+							$date=date('Y/W',strtotime(substr_replace($item['isoYearIsoWeek'],"W",-2,0)));
+						}
+						$item['date']=$date;
+						// $date=$item['date']??($item['dateHour']??($item['yearWeek']??$item['yearMonth']));
+						$sell['data'][$k][$date]=$item;
+					}
+				}
+				foreach($last_data['sell'] as $k=>$v){
+					foreach($v as $item){
+						$last_sell[$k][]=$item['itemQuantity'];
+					}
+				}
+				$data['store']['广告-销量']=0;
+				$data['store']['广告-订单数']=0;
+				$data['store']['广告-收入']=0;
+				$data['store']['广告-点击次数']=0;
+				$data['store']['广告-成本']=0;
+
+				
+				foreach($data['ads'] as $k=>$v){
+					if($v['campaign']=="(not set)"){
+						continue;
+					}
+					$data['store']['广告-销量'] +=$v['itemQuantity'];
+					$data['store']['广告-订单数'] +=$v['transactions'];
+					$data['store']['广告-收入'] +=$v['transactionRevenue'];
+					$data['store']['广告-点击次数'] +=$v['adClicks'];
+					$data['store']['广告-成本'] +=$v['adCost'];
+
+				}
+				$data['store']['广告-收入']=round($data['store']['广告-收入'],2);
+				$data['store']['广告-成本']=round($data['store']['广告-成本'],2);
+
+				$page=array_slice($data['page'],0,99);
+				foreach($page as $k=>$v){
+					$page[$k]['pageValue']=round($v['pageValue'],2);
+				}
+
+				$rows=array(
+					'success'=>1,
+					'data'=>[
+						'users'=>$users,
+						'geo'=>$geo,
+						'product'=>$data['product'],
+						'ads'=>$data['ads'],
+						'sell'=>$sell,
+						'last_sell'=>$last_sell,
+						'store'=>$data['store'],
+						'page'=>$page,
+						'channel'=>$data['channel']
+					]
+				);
+				echo json_encode($rows);exit;
+			}
+		}
+		$this->_Template('ga_index',$this->data);
+	}
+	public function getStoreData(){
+		$base_url="http://getdata.mywigs.com/index/index";
+		$post = $this->input->post(NULL, TRUE);
+		// $shop=$post['store'];
+		// $days=intval($post['days']);
+
+
+		$shop=3;
+		$days=15;
+		$param['store']=$shop;
+		$param['start']=date('Y-m-d',time()-3600*24*$days);
+		$param['end']=date('Y-m-d',time());
+		$url=$base_url.'?'.http_build_query($param);
+		$data=$this->_curl([],$url,300,"GET");
+		$data=json_decode($data,true);
+		$param1['store']=$shop;
+		$param1['start']=date('Y-m-d',time()-3600*24*($days*2+1));
+		$param1['end']=date('Y-m-d',time()-3600*24*($days+1));
+		$url=$base_url.'?'.http_build_query($param1);
+		$last_data=$this->_curl([],$url,300,"GET");
+		$last_data=json_decode($last_data,true);
+
+		if(!$data['status']||!$last_data['status']){
+			echo json_encode(array('msg'=>'获取失败,请重试','success'=>false));exit;
+		}else{
+			$storeData=$data['data']['storeData'];
+			$lastStoreData=$last_data['data']['storeData'];
+			echo "<pre>";
+			print_r($storeData);exit;
+			
+			$res=[
+				[
+					'name'=>'销量',
+					'value'=>$storeData['transactions'],
+					// 'compare'=>round(($storeData['transactions']-$lastStoreData['transactions'])/$lastStoreData['transactions']*100,2)."%",
+					'compare'=>round(($lastStoreData['transactions']-$storeData['transactions'])/$lastStoreData['transactions']*100,2)."%",
+				],
+				// [
+				// 	'name'=>
+				// ]
+			];
+
+
+			echo json_encode($res);
+			exit;
+		}
+		
+
+
+
+
+	}
+	public function contentpage(){
+		$url="http://getdata.mywigs.com/index/contentpage";
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  {
+			$page = $this->input->post('page',true);
+			$perpage = $this->input->post('perpage',true);
+			
+			if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            
+			$param=[];
+			$param['limit']=$perpage;
+            $param['page']=$page;
+            $url=$url.'?'.http_build_query($param);
+			$data=$this->_curl([],$url,300,"GET");
+            $data=json_decode($data,true);
+			if(!$data['status']){
+				echo json_encode(array('msg'=>'获取失败,请重试','success'=>false));exit;
+			}else{
+				$data=$data['data'];
+				$total=$data['total'];
+				$items=$data['items'];
+				foreach($items as $k=>$v){
+					$items[$k]['avgTimeOnPage']=round($items[$k]['avgTimeOnPage'],2);
+					$items[$k]['bounceRate']=round($items[$k]['bounceRate'],2);
+					$items[$k]['exitRate']=round($items[$k]['exitRate'],2);
+					$items[$k]['pageValue']=round($items[$k]['pageValue'],2);
+					unset($items[$k]['created_at']);
+				}
+				$pagenum = ceil($total/$perpage);
+				$over = $total-($start+$perpage);
+				$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($items));
+				echo json_encode($rows);exit;
+			}
+		}
+		$this->_Template('ga_contentpage',$this->data);
+
+    }
+    // public function Trafficsource(){
+	// 	$url="http://getdata.mywigs.com/index/source";
+	// 	$post = $this->input->post(NULL, TRUE);
+	// 	if(isset($post['page']))  {
+	// 		$page = $this->input->post('page',true);
+	// 		$perpage = $this->input->post('perpage',true);
+			
+	// 		if(empty($page))
+	// 	    {
+    //             $start = 0;
+	// 	    	$perpage = 1;
+    //         }
+	// 	    else
+	// 	    {
+    //             $start = ($page - 1)*$perpage;
+    //         }
+            
+	// 		$param=[];
+	// 		$param['limit']=$perpage;
+    //         $param['page']=$page;
+    //         $url=$url.'?'.http_build_query($param);
+	// 		$data=$this->_curl([],$url,300,"GET");
+    //         $data=json_decode($data,true);
+	// 		if(!$data['status']){
+	// 			echo json_encode(array('msg'=>'获取失败,请重试','success'=>false));exit;
+	// 		}else{
+	// 			$data=$data['data'];
+	// 			$total=$data['total'];
+	// 			$items=$data['items'];
+	// 			foreach($items as $k=>$v){
+
+	// 				$items[$k]['pageviewsPerSession']=round($items[$k]['pageviewsPerSession'],2);
+	// 				$items[$k]['bounceRate']=round($items[$k]['bounceRate'],2);
+	// 				$items[$k]['avgSessionDuration']=round($items[$k]['avgSessionDuration'],2);
+	// 				$items[$k]['transactionsPerVisit']=round($items[$k]['transactionsPerVisit'],2);
+	// 				unset($items[$k]['created_at']);
+	// 			}
+	// 			$pagenum = ceil($total/$perpage);
+	// 			$over = $total-($start+$perpage);
+	// 			$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($items));
+	// 			echo json_encode($rows);exit;
+	// 		}
+	// 	}
+	// 	$this->_Template('ga_trafficsource',$this->data);
+
+	// }
+	public function Trafficsource(){
+		$url="http://getdata.mywigs.com/index/statistic";
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+			if($user['vip'] == 1)
+			{
+				$vip = 1;
+			}
+			else
+			{
+				$vip = 0;
+			}
+		}
+		else
+		{
+			$vip = 0;
+		}
+
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		
+
+		$post = $this->input->post(NULL, TRUE);
+		$shop = $this->input->post('shop', TRUE);
+
+		if(!$shop){
+			$shop=$wlshop[0];
+		}
+		
+		$this->data['shop'] = $shop;
+
+		if(isset($post['shop']))  {
+			$param=[];
+			$days=intval($post['days']);
+			if($shop>6){
+				echo json_encode(array('msg'=>'无权限或者店铺不存在','success'=>false));exit;
+			}
+			$param['store']=$shop;
+			$param['start']=date('Y-m-d',time()-3600*24*$days);
+			$param['end']=date('Y-m-d',time());
+            $url=$url.'?'.http_build_query($param);
+			$data=$this->_curl([],$url,300,"GET");
+			$data=json_decode($data,true);
+			if(!$data['status']){
+				echo json_encode(array('msg'=>'获取失败,请重试','success'=>false));exit;
+			}else{
+				$data=$data['data'];
+				$users=[];
+				$visitor=$data['visitor'];
+				$sell=$data['sell'];
+				foreach($visitor as $k=>$v){
+					if($v['userType']=="New Visitor"){
+						$users['new'][]=$v['newUsers'];
+						$users['date'][]=date('Y-m-d',strtotime($v['date']));
+					}else{
+						$users['return'][]=$v['users'];
+					}
+				}
+				$totalSellCount=array_sum(array_column($sell,'transactions'));
+				// echo $totalSellCount;exit;
+				$regionStr="";
+				foreach($sell as $k=>$v){
+					$percent=round($v['transactions']/$totalSellCount*100,2)."%";
+					$sell[$k]['percent']=$percent;
+				}
+
+				$rows=array(
+					'success'=>1,
+					'data'=>[
+						'users'=>$users,
+						'sell'=>$sell,
+						'product'=>$data['product'],
+					]
+				);
+				echo json_encode($rows);exit;
+			}
+		}
+		$this->_Template('ga_chart',$this->data);
+
+	}
+	public function productinfo($arg_array=[]){
+		$url="http://getdata.mywigs.com/index/productinfo";
+		$shop=$arg_array[0];
+		$days=intval($arg_array[1])??7;
+		$productName=base64_decode($arg_array[2]);
+
+		if(isset($productName)&&!empty($productName))  {
+			$param=[];
+			$param['store']=$shop;
+			$param['productName']=$productName;
+			$param['start']=date('Y-m-d',time()-3600*24*$days);
+			$param['end']=date('Y-m-d',time());
+			$url=$url.'?'.http_build_query($param);
+			$data=$this->_curl([],$url,300,"GET");
+			$data=json_decode($data,true);
+			if(!$data['status']){
+				echo json_encode(array('msg'=>'获取失败,请重试','success'=>false));exit;
+			}else{
+				$data=$data['data'];
+
+				$sell=[];
+				$sell['date']['hour']=array_column($data['sell']['hour'],'dateHour');
+				$sell['date']['day']=array_column($data['sell']['day'],'date');
+				$sell['date']['week']=array_column($data['sell']['week'],'isoYearIsoWeek');
+				$sell['date']['month']=array_column($data['sell']['month'],'yearMonth');
+
+				$sell['date']['hour']=array_map(function($item){
+					return date('m/d H',strtotime($item."00")).":00";
+				},$sell['date']['hour']);
+
+				$sell['date']['day']=array_map(function($item){
+					return date('m/d',strtotime($item));
+				},$sell['date']['day']);
+				$sell['date']['week']=array_map(function($item){
+					return date('Y/W',strtotime(substr_replace($item,"W",-2,0)));
+				},$sell['date']['week']);
+
+				$sell['date']['month']=array_map(function($item){
+					return date('Y/m',strtotime($item));
+				},$sell['date']['month']);
+				// echo "<pre>"; 
+				// print_r($data['sell']['week']);
+				foreach($data['sell'] as $k=>$v){
+					foreach($v as $item){
+						if(isset($item['date'])&&!empty($item['date'])){
+							$date=date('m/d',strtotime($item['date']));
+						}
+						if(isset($item['dateHour'])&&!empty($item['dateHour'])){
+							$date=date('m/d H',strtotime($item['dateHour']."00")).":00";
+						}
+						if(isset($item['yearMonth'])&&!empty($item['yearMonth'])){
+							$date=date('Y-m',strtotime($item['yearMonth']));
+						}
+
+						if(isset($item['isoYearIsoWeek'])&&!empty($item['isoYearIsoWeek'])){
+							$date=date('Y/W',strtotime(substr_replace($item['isoYearIsoWeek'],"W",-2,0)));
+						}
+						$item['date']=$date;
+						// $date=$item['date']??($item['dateHour']??($item['yearWeek']??$item['yearMonth']));
+						$sell['data'][$k][$date]=$item;
+					}
+				}
+			}
+			// echo "<pre>";
+			// print_r($sell);exit;
+			$this->data['sell']=json_encode($sell,true);
+			$this->data['sku']=json_encode($data['sku'],true);
+			$this->data['days']=$days;
+		}
+		$this->data['productName']=$productName;
+		$this->_Template('ga_productinfo',$this->data);
+
+	}
+	public function regionproduct($arg_array=[]){
+		$url="http://getdata.mywigs.com/index/region-product";
+		$shop=$arg_array[0];
+		$days=intval($arg_array[1])??7;
+		$region=base64_decode($arg_array[2]);
+		if(isset($region)&&!empty($region))  {
+			$param=[];
+			$param['store']=$shop;
+			$param['region']=$region;
+			$param['start']=date('Y-m-d',time()-3600*24*$days);
+			$param['end']=date('Y-m-d',time());
+			$url=$url.'?'.http_build_query($param);
+			$data=$this->_curl([],$url,300,"GET");
+			$data=json_decode($data,true);
+			if(!$data['status']){
+				echo json_encode(array('msg'=>'获取失败,请重试','success'=>false));exit;
+			}else{
+				$data=$data['data'];
+			}
+			$this->data['info']=$data[0];
+		}
+		$this->_Template('ga_productinfo',$this->data);
+
+	}
+	public function goals(){
+		$url="http://getdata.mywigs.com/index/goals";
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+			if($user['vip'] == 1)
+			{
+				$vip = 1;
+			}
+			else
+			{
+				$vip = 0;
+			}
+		}
+		else
+		{
+			$vip = 0;
+		}
+
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		
+
+		$post = $this->input->post(NULL, TRUE);
+		$shop = $this->input->post('shop', TRUE);
+
+		if(!$shop){
+			$shop=$wlshop[0];
+		}
+		
+		$this->data['shop'] = $shop;
+		
+		
+
+		if(isset($post['page']))  {
+			$param=[];
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);	
+			// $days=intval($post['days']);
+			if($shop>6){
+				echo json_encode(array('msg'=>'无权限或者店铺不存在','success'=>false));exit;
+			}
+			$param['store']=$shop;
+			$param['start']=date('Y-m-d',strtotime($timetk));
+			$param['end']=date('Y-m-d',strtotime($timetj));
+			$url=$url.'?'.http_build_query($param);
+			$data=$this->_curl([],$url,300,"GET");
+			$data=json_decode($data,true);
+			if(!$data['status']){
+				echo json_encode(array('msg'=>'获取失败,请重试','success'=>false));exit;
+			}else{
+				$data=$data['data'];
+				// foreach($sell as $k=>$v){
+				// 	$percent=round($v['transactions']/$totalSellCount*100,2)."%";
+				// 	$sell[$k]['percent']=$percent;
+				// }
+				$row=[
+					$data['pageviews'],
+					$data['sessions'],
+					$data['users'],
+					$data['newUsers'],
+					round($data['bounceRate'],2).'%',
+					$data['cartCompletions'],
+					round($data['cartConversionRate'],2).'%',
+					$data['orderCompletions'],
+					round($data['orderConversionRate'],2).'%',
+					$data['transactionRevenue'],
+					round($data['revenuePerTransaction'],2),
+				];
+				$rows = array('rows'=>[$row]);
+				echo json_encode($rows);exit;
+			}
+		}
+		$this->_Template('ga_goals',$this->data);
+	}
+
+
+	public function _curl($data,$url,$timeout=300,$httptype="POST",$date_type=false,$header=array(),$userpwd='')
+    {
+    
+        if ($date_type == 'http_build_query')
+		{
+            $data = http_build_query($data);
+        }
+		else if ($date_type == 'json')
+		{
+            $data = json_encode($data);
+        }
+
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_HEADER, false);
+        switch ($httptype)
+		{
+            case "GET":
+            curl_setopt($ch, CURLOPT_HTTPGET, true);
+            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
+            break;
+			
+            case "POST":
+            curl_setopt($ch, CURLOPT_POST, true);
+            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
+            break;
+			
+            case "PUT":
+            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
+            break;
+			
+            case "DELETE":
+            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
+            break;
+        }
+        $isSecure = strpos($url, "https://");
+        if ($isSecure === 0)
+		{
+            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+        }
+        if(!empty($header))
+		{
+            curl_setopt($ch, CURLOPT_SSLVERSION , 6); //NEW ADDITION
+            curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
+        }
+
+        if(!empty($userpwd))
+		{
+            curl_setopt($ch,CURLOPT_USERPWD,$userpwd);
+        }
+        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
+        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+        $result = curl_exec($ch);
+        curl_close($ch);
+        return $result;
+    }
+}

+ 80 - 0
core/CoreApp/controllers/Img.php

@@ -0,0 +1,80 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Img extends Admin_Controller {
+    function __construct(){
+        parent::__construct();
+		$this->load->library('upload');
+	}
+	
+	public function _remap($arg)
+    {
+		if($arg == 'textimg')
+        {
+             $this->_textimg();
+        }
+		else if($arg == 'thumb')
+		{
+			$this->_thumb();
+		}
+		else
+		{
+			$this->_index();
+		}
+    }
+	//上传图片
+	public function _index()
+	{
+		$dir = '/data/img/'.date('Ymd',time()).'/';
+		$config['upload_path'] = '.'.$dir ;
+		$config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
+        $config['allowed_types'] = '*';
+        $config['max_size'] = 51200;
+		$this->load->library('upload', $config);
+		$this->upload->initialize($config);
+        if ($this->upload->do_upload('userfile'))
+        {
+			$full_path = $dir.$this->upload->data('file_name');
+            echo json_encode(array('ok'=>1,'lx'=>$this->upload->data('file_ext'),'filename'=>$full_path));
+        }
+		else
+		{
+			echo json_encode(array('msg'=>$this->upload->display_errors()));
+		}
+    }
+	//编辑器上传图
+	public function _textimg()
+	{
+		$dir = '/data/img/'.date('Ymd',time()).'/';
+		$config['upload_path'] = '.'.$dir ;
+		$config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
+        $config['allowed_types'] = 'gif|jpg|png';
+        $config['max_size'] = 51200;
+		$field_name = "upfile";
+		$this->load->library('upload', $config);
+		$this->upload->initialize($config);
+        if ($this->upload->do_upload($field_name))
+        {
+			$name = $this->upload->data('file_name'); //重命名后的图片名称+后缀
+			$client_name = $this->upload->data('client_name');//提交的图片名称+后缀
+			$file_ext = $this->upload->data('file_ext');//图片后缀
+			$file_size = $this->upload->data('file_size');//图片大小
+			$full_path = $dir.$this->upload->data('file_name');//图片上传的完整路径+名称+后缀
+            echo json_encode(array('errno'=>0,'data'=>array('url'=>'http://a.wepolicy.cn'.$full_path)));
+        }
+		else
+		{
+			echo json_encode(array('errno'=>1,'data'=>array('message'=>$this->upload->display_errors())));
+		}
+    }
+	public function _thumb()
+	{
+	    $this->load->library('thumb');
+	    $test=new thumb();  
+	    $src = FCPATH.$this->input->get('src');
+	    $w = $this->input->get('w');
+	    $h = $this->input->get('h');
+	    $a = $this->input->get('a');
+ 
+	    $test->SetVar($src,'link');  
+	    $test->PRorate($src,$w,$h);  
+	}
+}

+ 20 - 0
core/CoreApp/controllers/Is.php

@@ -0,0 +1,20 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Is extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_is','is');
+		$this->load->_model('Model_is2','is2');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+	}
+public function _remap($arg,$arg_array)
+    {
+		 $this->_index($arg);
+	}
+	public function _index($arg)
+	{
+        $data = $this->fullorder->get_orderinfo($arg);
+		$this->fullorder->save(array('library'=>1,'retreattime'=>0),$data['id']);
+	}
+}

+ 95 - 0
core/CoreApp/controllers/Kdniao.php

@@ -0,0 +1,95 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Kdniao extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_notice','notice');
+		$this->load->_model('Model_kdniao','kdniao');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_warehouse','warehouse');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'js')//添加
+        {
+             $this->_js();
+        }
+    }
+	public function _js()
+	{
+		$post = $this->input->post(NULL, TRUE);
+        $data = $this->input->post('RequestData',true);
+		if(isset($data))
+		{
+			$data = json_decode($data,true);//josn转数组
+			foreach ($data['Data'] as $value)//循环出每个运单信息
+			{
+				$rows = "";
+				$waybill = $value['LogisticCode'];//运单号
+				$fullorder = $this->fullorder->get_waybill($waybill);//查找此运单号
+				if($fullorder)//如果有此运单号
+				{
+					if($fullorder['exstate'] != $value['State'])//如果状态已更新
+					{
+						$notice = $this->notice->get_type($fullorder['shop'],2,$value['State'],0);//查找消息配置
+						if($notice)//如果有此消息配置
+				 	    {
+							$warehouse = $this->warehouse->read($fullorder['type']);
+							if($notice['type'] == 2)//发送邮件
+				    	    {
+						    	$st = $this->_email($notice['content'],$fullorder,$warehouse['company']);//发送数据
+							}
+							else
+							{
+								$st = 2;
+								//订单留言 AE需要 1.成功2.失败
+							}
+						}
+						foreach ($value['Traces'] as $v)//物流详情
+		            	{
+							$rows .= "<p>时间:".$v['AcceptTime']." 状态:".$v['AcceptStation']."</p>";
+						}
+						$this->fullorder->save(array('exstate'=>$value['State'],'fsstate'=>$st,'content'=>$rows),$fullorder['id']);
+					
+					}
+				}
+			}
+		}
+		$echo = array("EBusinessID"=>$data['EBusinessID'],"UpdateTime"=>date('Y-m-d H:i:s',time()),"Success"=>true,"Reason"=>"");
+		echo json_encode($echo);
+	}
+	
+	public function _email($content,$data,$shopname)
+	{
+		$express = $this->express->read($data['express']);
+		$t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
+		$h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['title'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
+		$content = str_replace($t,$h,$content);
+		$this->load->library('email');		
+		$config['protocol'] = 'smtp';
+		$config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
+		$config['smtp_port'] = 465; 
+		$config['smtp_user'] = 'service@email.supernovahair.com';
+		$config['smtp_pass'] = 'LONGyihair374';
+		$config['smtp_crypto'] = 'ssl';
+		$config['crlf'] = "\r\n"; 
+		$config['newline'] = "\r\n";
+		$this->email->initialize($config);
+		$this->email->from('service@email.supernovahair.com',$shopname);
+		$this->email->to($data['email']);//收件
+		$this->email->subject('The product you purchased has a new progress');//标题
+		$this->email->message($content);//内容
+		if ( ! $this->email->send())
+        {
+			return 2;
+        }
+		else
+		{
+			return 1;
+		}
+	}
+}

+ 171 - 0
core/CoreApp/controllers/Logistics.php

@@ -0,0 +1,171 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Logistics extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_logistics','logistics');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_express','express');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$country = $this->input->post('country',true);
+			$express = $this->input->post('express',true);
+			$where = "1=1 ";
+			if($country)
+            {
+                $where  .= " and country = '$country'";
+            }
+			if($express)
+            {
+                $where  .= " and express = '$express'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->logistics->find_all($where,'id,express,country,first,firstmoney,factfirstcost,addition,additionmoney,factaddition',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$country = $this->country->read($value['country']);
+				$info_list[$key]['country'] = $country['name'];
+				$express = $this->express->read($value['express']);
+				$info_list[$key]['express'] = $express['title'];
+            }
+		    $total = $this->logistics->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$country = $this->country->find_all();
+		$this->data['country'] = $country;
+		$express = $this->express->find_all();
+		$this->data['express'] = $express;
+		$this->_Template('logistics',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['express']))
+		{
+			$post['express'] = $this->input->post('express',true);
+			$post['first'] = $this->input->post('first',true);
+			$post['addition'] = $this->input->post('addition',true);
+			$post['firstmoney'] = $this->input->post('firstmoney',true);
+			$post['additionmoney'] = $this->input->post('additionmoney',true);
+			$post['factfirstcost'] = $this->input->post('factfirstcost',true);
+			$post['factaddition'] = $this->input->post('factaddition',true);
+			$countryck = $this->input->post('country',true);
+			if($countryck)
+			{
+				$countryck = explode(',',rtrim($countryck,','));
+				foreach ($countryck as $key=>$value) 
+		        {
+					$post['country'] = $value;
+				    $this->logistics->insert($post);
+                }
+				
+				echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+			}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$country = $this->country->find_all();
+		$this->data['country'] = $country;
+		$express = $this->express->find_all();
+		$this->data['express'] = $express;
+		$this->_Template('logistics_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['express'] = $this->input->post('express',true);
+			$post['first'] = $this->input->post('first',true);
+			$post['addition'] = $this->input->post('addition',true);
+			$post['firstmoney'] = $this->input->post('firstmoney',true);
+			$post['additionmoney'] = $this->input->post('additionmoney',true);
+			$post['factfirstcost'] = $this->input->post('factfirstcost',true);
+			$post['factaddition'] = $this->input->post('factaddition',true);
+			$post['country'] = $this->input->post('country',true);
+			if($this->logistics->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$logistics = $this->logistics->read($arg_array);
+		$this->data['logistics'] = $logistics;
+		$country = $this->country->find_all();
+		$this->data['country'] = $country;
+		$express = $this->express->find_all();
+		$this->data['express'] = $express;
+		$this->_Template('logistics_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->logistics->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 360 - 0
core/CoreApp/controllers/Machining.php

@@ -0,0 +1,360 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Machining extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_machining','machining');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_customer','customer');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'excel')
+        {
+             $this->_excel();
+        }
+		else if($arg == 'down')
+        {
+             $this->_down();
+        }
+		else if($arg == 'pindex')
+        {
+			$this->_pindex();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$title = $this->input->post('title',true);
+			$type = $this->input->post('type',true);
+			$where = "1=1 ";
+			if($type)
+            {
+                $where  .= " and type = '$type'";
+            }
+			if($title)
+            {
+                $where  .= " and title like '%$title%'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			if($type)
+			{
+                //取得信息列表
+                $info_list = $this->machining->find_all($where,'id,type,num,title,color',$order_str,$start,$perpage);
+			    foreach ($info_list as $k=>$v) 
+		        {
+				    if($v['type'] == 1)
+				    {
+					    $info_list[$k]['type'] = '半成品';
+				    }
+				    else if($v['type'] == 2)
+				    {
+					    $info_list[$k]['type'] = '成品';
+				    }
+			    }
+				$total = $this->machining->find_count($where);
+			}
+			else
+			{
+				$list = $this->machining->find_all($where,'id,type,num,title,color');
+				$info = array();$data = array();
+				foreach ($list as $k=>$v) 
+		    	{
+					$key = preg_replace('/( | | |\s)/','',$v['title']).preg_replace('/( | | |\s)/','',$v['color']);
+					if(isset($data[$key]))
+					{
+						$data[$key]['num'] += $v['num'];
+						$data[$key]['type'] = '(半成品+成品)';
+					}
+					else
+					{
+						if($v['type'] == 1)
+				        {
+					        $v['type'] = '半成品';
+				        }
+				        else if($v['type'] == 2)
+				        {
+					        $v['type'] = '成品';
+				        }
+					    $data[$key] = $v;
+					}
+		    	}
+				array_multisort(array_column($data,'type'),SORT_ASC,$data);
+				foreach ($data as $k=>$v) 
+		    	{
+					//if($v['type'] == '半成品+成品')
+					//{
+					    $info[] = $v;
+					//}
+				}
+				$info_list = array_slice($info,$start,$perpage);
+				$total = count($info);
+			}
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('machining',$this->data);
+	}
+	
+	//手机管理
+	public function _pindex()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$title = $this->input->post('title',true);
+			$type = $this->input->post('type',true);
+			$where = "1=1 ";
+			if($type)
+            {
+                $where  .= " and type = '$type'";
+            }
+			if($title)
+            {
+                $where  .= " and title like '%$title%'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            if($type)
+			{
+                //取得信息列表
+                $info_list = $this->machining->find_all($where,'id,type,num,title,color',$order_str,$start,$perpage);
+			    foreach ($info_list as $k=>$v) 
+		        {
+				    if($v['type'] == 1)
+				    {
+					    $info_list[$k]['type'] = '半';
+				    }
+				    else if($v['type'] == 2)
+				    {
+					    $info_list[$k]['type'] = '成';
+				    }
+			    }
+				$total = $this->machining->find_count($where);
+			}
+			else
+			{
+				$list = $this->machining->find_all($where,'id,type,num,title,color');
+				$info = array();$data = array();
+				foreach ($list as $k=>$v) 
+		    	{
+					$key = preg_replace('/( | | |\s)/','',$v['title']).preg_replace('/( | | |\s)/','',$v['color']);
+					if(isset($data[$key]))
+					{
+						$data[$key]['num'] += $v['num'];
+						$data[$key]['type'] = '半+成';
+					}
+					else
+					{
+						if($v['type'] == 1)
+				        {
+					        $v['type'] = '半';
+				        }
+				        else if($v['type'] == 2)
+				        {
+					        $v['type'] = '成';
+				        }
+					    $data[$key] = $v;
+					}
+		    	}
+				array_multisort(array_column($data,'type'),SORT_ASC,$data);
+				foreach ($data as $k=>$v) 
+		    	{
+					//if($v['type'] == '半成品+成品')
+					//{
+					    $info[] = $v;
+					//}
+				}
+				$info_list = array_slice($info,$start,$perpage);
+				$total = count($info);
+			}
+		    $total = $this->machining->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('phone/p_machining',$this->data);
+	}
+
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['title']))
+		{
+			$post['time'] = time();
+			if($this->machining->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('machining_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			if($this->machining->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$machining = $this->machining->read($arg_array[0]);
+		$this->data['machining'] = $machining;
+		$this->_Template('machining_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->machining->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	
+	public function _excel()
+	{
+		$dir = '/data/excel/'.date('Ymd',time()).'/';
+		$config['upload_path'] = '.'.$dir ;
+		$config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
+        $config['allowed_types'] = 'xls|xlsx';
+        $config['max_size'] = 10240;
+		$this->load->library('upload', $config);
+		$this->upload->initialize($config);
+        if ($this->upload->do_upload('userfile'))
+        {
+			$full_path = $dir.$this->upload->data('file_name');
+			$fileName = '.' . $full_path;
+            if (!file_exists($fileName)) 
+			{
+				echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
+            }
+			else
+			{
+				require_once "./data/excel/PHPExcel/IOFactory.php";
+				@$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
+				@$phpExcel->setActiveSheetIndex(0);// 设置为默认表
+				$sheetCount = $phpExcel->getSheetCount();// 获取表格数量
+				$row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
+				$column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
+				++$column;//如果列数大于26行
+				$list = array();
+				for ($i = 2; $i <= $row; $i++) // 行数循环
+				{
+					$data = array();
+                    for ($c = 'A'; $c != $column; $c++)  // 列数循环
+	                {
+						$data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
+                    }
+					$list[] = $data;
+                }
+			}
+			$i = 0;
+		    $this->db->trans_begin();
+		    foreach ($list as $key=>$value)
+		    {
+				$value['2'] = $value['2']?str_replace(array('/( | | |\s)/'),array(' '),$value['2']):'';
+				$value['3'] = $value['3']?str_replace(array('/( | | |\s)/'),array(' '),$value['3']):'';
+				$post['type'] = $value['0'];
+				$post['num'] = $value['1'];
+				$post['title'] = $value['2'];
+				$post['color'] = $value['3'];
+			    $post['time'] = time();
+		    	$this->machining->insert($post);
+			}
+			if ($this->db->trans_status() === FALSE)
+            {
+				$this->db->trans_commit();
+				echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+            }
+            else
+            {
+                $this->db->trans_commit();
+				echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+            }
+        }
+		else
+		{
+			echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
+		}
+    }
+	public function _down()
+	{
+		if(isset($_GET['excel']))  
+		{
+            $title = "导入模板"; 
+            $titledata = array(array('类型:1.半成品2.成品','数量','名称','蕾丝颜色'),array('1','20','4*4 body','black'));
+            $filename = $title.".xls";
+            $this->customer->get_excel($titledata,$filename);
+	    }
+	}
+}

+ 247 - 0
core/CoreApp/controllers/Matching.php

@@ -0,0 +1,247 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Matching extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->_model('Model_matching','matching');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_classid','classid');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')
+        {
+             $this->_del();
+        }
+		else if($arg == 'list')
+        {
+             $this->_list();
+        }
+		else
+		{
+			$this->_index();
+		}
+    }
+	
+	public function _index()
+	{
+			$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$category = $this->input->post('category',true);
+			$where = "1=1";
+			if($category)
+            {
+                $where  .= " and category like '%$category%'";
+            }
+			//数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			$typeclass = array();
+			$class = $this->typeclass->find_all();
+			foreach ($class as $v)
+			{
+				$v['spare'] = explode('|',$v['spare']);
+			    $typeclass[$v['id']] = array('spare'=>$v['spare'][0],'title'=>$v['title']);
+			}
+			$info_list = $this->matching->find_all($where,'id,category,listid,type,tdata,hdata',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$info_list[$key]['category'] = $typeclass[$value['category']]['title'];
+				$cl = $this->classid->read($value['listid']);
+				$info_list[$key]['listid'] = $cl['title'];
+				$info_list[$key]['tdata'] = ($value['tdata'])?$typeclass[$value['tdata']]['spare']:'';
+				if($value['type'] == 1)
+				{
+					$info_list[$key]['type'] = '可适配';
+				}
+				else if($value['type'] == 2)
+				{
+					$info_list[$key]['type'] = '可不包含此SKU';
+				}
+				else if($value['type'] == 3)
+				{
+					$info_list[$key]['type'] = '类目可提档';
+					$info_list[$key]['listid'] = "长度提档";
+				}
+				if($value['hdata'])
+				{
+				    $hdata = explode(',',trim($value['hdata'],','));
+				    $hlist = '';
+				    foreach ($hdata as $v) 
+		            {
+					    $hlist .= $typeclass[$v]['spare'].',';
+				    }
+				    $info_list[$key]['hdata'] = $hlist;
+				}
+				else
+				{
+					$info_list[$key]['hdata'] = '';
+				}
+			}
+			$total = $this->matching->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$class = $this->classid->find_all("id = 10 or id = 13 or id = 15 or id = 18 or id = 9",'*','ckpx asc');
+		$this->data['class'] = $class;
+        $this->_Template('matching',$this->data);
+	}
+	
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['category']))
+		{
+			$post['category'] = $this->input->post('category',true);
+			$post['listid'] = $this->input->post('listid',true);
+			$post['tdata'] = $this->input->post('tdata',true);
+			$post['type'] = $this->input->post('type',true);
+			$post['hdata'] = $this->input->post('hdata',true);
+			if(!$post['category'])
+			{
+				echo json_encode(array('msg'=>'请选择类目','success'=>false));exit;
+			}
+			if(!$post['listid'])
+			{
+				echo json_encode(array('msg'=>'请选择类型','success'=>false));exit;
+			}
+			if(!$post['type'])
+			{
+				echo json_encode(array('msg'=>'请选择条件','success'=>false));exit;
+			}
+			if($post['type'] == 1 && (!$post['hdata'] || !$post['tdata']))
+			{
+				echo json_encode(array('msg'=>'数据不完整','success'=>false));exit;
+			}
+			if($post['type'] == 2 && !$post['hdata'])
+			{
+				echo json_encode(array('msg'=>'请选择原始SKU','success'=>false));exit;
+			}
+			$post['tdata'] = rtrim($post['tdata'],',');
+			if($this->matching->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$class = $this->classid->find_all("id = 10 or id = 13 or id = 15 or id = 18 or id = 9",'*','ckpx asc');
+		$this->data['class'] = $class;
+		$this->_Template('matching_add',$this->data);
+	}
+	
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$post['category'] = $this->input->post('category',true);
+			$post['listid'] = $this->input->post('listid',true);
+			$post['tdata'] = $this->input->post('tdata',true);
+			$post['type'] = $this->input->post('type',true);
+			$post['hdata'] = $this->input->post('hdata',true);
+			if(!$post['category'])
+			{
+				echo json_encode(array('msg'=>'请选择类目','success'=>false));exit;
+			}
+			if(!$post['listid'])
+			{
+				echo json_encode(array('msg'=>'请选择类型','success'=>false));exit;
+			}
+			if(!$post['type'])
+			{
+				echo json_encode(array('msg'=>'请选择条件','success'=>false));exit;
+			}
+			if($post['type'] == 1 && (!$post['hdata'] || !$post['tdata']))
+			{
+				echo json_encode(array('msg'=>'数据不完整','success'=>false));exit;
+			}
+			if($post['type'] == 2 && !$post['hdata'])
+			{
+				echo json_encode(array('msg'=>'请选择原始SKU','success'=>false));exit;
+			}
+			if($post['type'] == 3)
+			{
+				$post['tdata'] = '';
+				$post['hdata'] = '';
+			}
+			$post['tdata'] = rtrim($post['tdata'],',');
+			$id = $this->input->post('id',true);
+			if($this->matching->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$matching = $this->matching->read($arg_array);
+		$this->data['matching'] = $matching;
+		$class = $this->classid->find_all("id = 10 or id = 13 or id = 15 or id = 18 or id = 9",'*','ckpx asc');
+		$this->data['class'] = $class;
+		$this->_Template('matching_edit',$this->data);
+	}
+	
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->matching->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	public function _list()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$typeclass = $this->typeclass->find_all("classid = $id");
+			if($typeclass)
+			{
+			    echo json_encode(array('data'=>$typeclass,'success'=>true));exit;
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'没有找到数据!','success'=>false));exit;
+			}
+		}
+	}
+}

+ 143 - 0
core/CoreApp/controllers/News.php

@@ -0,0 +1,143 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class News extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_user','user');
+		$this->load->_model('Model_news','news');
+	}
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')
+        {
+             $this->_rows();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$title = $this->input->post('title',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "1=1 ";
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			if($title)
+            {
+				$where  .= " and title like '%$title%'";
+            }
+			if($timetk && $timetj)
+            {
+                $where  .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
+            }
+            //取得信息列表
+            $info_list = $this->news->find_all($where,'id,title,addtime',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$info_list[$key]['addtime'] = date('Y-m-d H:i',$value['addtime']);
+            }
+		    $total = $this->news->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('news',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['title']))
+		{
+			$post['title'] = $this->input->post('title',true);
+			$post['content'] = $this->input->post('content',true);
+			$post['addtime'] = time();
+			if($this->news->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('news_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['title']))
+		{
+			$post['title'] = $this->input->post('title',true);
+			$post['content'] = $this->input->post('content',true);
+			if($this->news->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$news = $this->news->read($arg_array);
+		$this->data['news'] = $news;
+		$this->_Template('news_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->news->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 709 - 0
core/CoreApp/controllers/Notice.php

@@ -0,0 +1,709 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Notice extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_user','user');
+		$this->load->_model('Model_notice','notice');
+		$this->load->_model('Model_noticeemail','noticeemail');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_emaildata','emaildata');
+		$this->load->_model('Model_als','als');
+		$this->load->_model('Model_apitt','apitt');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add($arg_array);
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')//数据
+        {
+             $this->_rows();
+        }
+		else if($arg == 'email')
+        {
+             $this->_email();
+        }
+		else if($arg == 'addemail')
+        {
+             $this->_addemail();
+        }
+		else if($arg == 'emailfs')
+        {
+             $this->_emailfs();
+        }
+		else if($arg == 'testfs')
+        {
+             $this->_testfs();
+        }
+		else
+		{
+			 $this->_index($arg_array);
+		}
+    }
+
+	//管理
+	public function _index($arg_array)
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$shop = $this->input->post('shop',true);
+			$type = $this->input->post('type',true);
+			$ordertatus = $this->input->post('ordertatus',true);
+			$arg = $this->input->post('arg',true);
+			$logisticstatus = $this->input->post('logisticstatus',true);
+			$where = "1=1 and (".rtrim($fgshop,'or').")";
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($type)
+            {
+                $where  .= " and type = '$type'";
+            }
+			if($ordertatus)
+            {
+                $where  .= " and ordertatus = '$ordertatus'";
+            }
+			if($logisticstatus)
+            {
+                $where  .= " and logisticstatus = '$logisticstatus'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->notice->find_all($where,'id,shop,title,type,message,email,ordertatus,logisticstatus,ktime,jtime,state',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				$email = $this->emaildata->read($value['email']);
+				$info_list[$key]['email'] = $email['smtp_user'];
+				$info_list[$key]['ktime'] = date('Y-m-d',$value['ktime']);
+				$info_list[$key]['jtime'] = date('Y-m-d',$value['jtime']);
+		    	if($value['type'] == 1)
+				{
+					$info_list[$key]['type'] = '自动发送';
+				}
+				else if($value['type'] == 2)
+				{
+					$info_list[$key]['type'] = '物流追踪';
+				}
+				else if($value['type'] == 3)
+				{
+					$info_list[$key]['type'] = '营销';
+				}
+				else if($value['type'] == 4)
+				{
+					$info_list[$key]['type'] = '运单号通知';
+				}
+				if($value['message'] == 1)
+				{
+					$info_list[$key]['message'] = '发送邮件';
+				}
+				//订单状态开始
+				$typeclass = $this->typeclass->read($value['ordertatus']);
+				$info_list[$key]['ordertatus'] = $typeclass?(($arg==1)?$typeclass['title']:$typeclass['spare']):'';
+				//订单状态结束
+				if($value['logisticstatus'] == 0)
+				{
+					$info_list[$key]['logisticstatus'] = "无信息";
+				}
+				else if($value['logisticstatus'] == 2)
+				{
+					$info_list[$key]['logisticstatus'] = "已取件";
+				}
+				else if($value['logisticstatus'] == 3)
+				{
+					$info_list[$key]['logisticstatus'] = "在途中";
+				}
+				/**
+				else if($value['logisticstatus'] == 4)
+				{
+					$info_list[$key]['logisticstatus'] = "到达目的地国";
+				}
+				**/
+				else if($value['logisticstatus'] == 4 || $value['logisticstatus'] == 5)
+				{
+					$info_list[$key]['logisticstatus'] = "即将派送";
+				}
+				else if($value['logisticstatus'] == 6)
+				{
+					$info_list[$key]['logisticstatus'] = "已签收";
+				}
+				else if($value['logisticstatus'] == 1)
+				{
+					$info_list[$key]['logisticstatus'] = "派送异常";
+				}
+				if($value['message'] == 1)
+				{
+					$info_list[$key]['message'] = '发送邮件';
+				}
+				else if($value['message'] == 2)
+				{
+					$info_list[$key]['message'] = 'AE站内信';
+				}
+				else if($value['message'] == 3)
+				{
+					$info_list[$key]['message'] = 'TT会话';
+				}
+				if($value['state'] == 1)
+				{
+					$info_list[$key]['state'] = '启用中';
+				}
+				else if($value['state'] == 2)
+				{
+					$info_list[$key]['state'] = '未启用';
+				}
+            }
+		    $total = $this->notice->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$mb = 2;
+		if(isset($arg_array[0]))
+		{
+			if($arg_array[0]=='smt')
+			{
+				$mb = 1;
+			}
+			else if($arg_array[0]=='dlz')
+			{
+				$mb = 2;
+			}
+			else if($arg_array[0]=='tt')
+			{
+				$mb = 3;
+			}
+		}
+		$this->data['arg'] = $mb;
+		$this->_Template('notice',$this->data);
+	}
+	//添加
+	public function _add($arg_array)
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['title']))
+		{
+			$post['title'] = $this->input->post('title',true);
+			$post['shop'] = $this->input->post('shop',true);
+			$post['message'] = $this->input->post('message',true);
+			$post['type'] = $this->input->post('type',true);
+			$post['repeat'] = $this->input->post('repeat',true);
+			$ktime = $this->input->post('ktime',true);
+			$post['ktime'] = strtotime($ktime);
+			$jtime = $this->input->post('jtime',true);
+			$post['jtime'] = strtotime($jtime);
+			$post['content'] = $this->input->post('content');
+			$emailtitle = $this->input->post('emailtitle');
+			$post['js'] = '';
+			if($emailtitle)
+			{
+				$post['emailtitle'] = $emailtitle;
+			}
+			if($post['type'] == 1)
+			{
+				$post['ordertatus'] = $this->input->post('ordertatus',true);
+				if($post['ordertatus'] == 2 || $post['ordertatus'] == 3)
+				{
+					$post['sending'] = $this->input->post('sending',true);
+					$post['timeinterval'] = $this->input->post('timeinterval',true);
+				}
+			}
+			else if($post['type'] == 2)
+			{
+				$post['logisticstatus'] = $this->input->post('logisticstatus',true);
+			}
+			else if($post['type'] == 3)
+			{
+				$marketing = $this->input->post('marketing',true);
+			    $post['marketing'] = strtotime($marketing);
+			}
+			else if($post['type'] == 4)
+			{
+				$post['js'] = $this->input->post('js',true);
+				if($post['js'] != '')
+				{
+					$post['js'] = ','.$post['js'];
+				}
+				$post['express'] = $this->input->post('express',true);
+				if($post['express'] != '')
+				{
+					$post['express'] = ','.$post['express'];
+				}
+			}
+			$post['state'] = $this->input->post('state',true);
+			if($post['state'] == 1)
+			{
+				$post['statetime'] = time();
+			}
+			
+			if($this->notice->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$email = $this->emaildata->find_all('1=1 and '.rtrim($fgshop,'or'));
+		$this->data['email'] = $email;
+		$mb = 2;
+		if(isset($arg_array[0]))
+		{
+			if($arg_array[0]=='smt')
+			{
+				$mb = 1;
+			}
+			else if($arg_array[0]=='dlz')
+			{
+				$mb = 2;
+			}
+			else if($arg_array[0]=='tt')
+			{
+				$mb = 3;
+			}
+		}
+		$this->data['arg'] = $mb;
+		$this->_Template('notice_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['title'] = $this->input->post('title',true);
+			$post['shop'] = $this->input->post('shop',true);
+			$post['message'] = $this->input->post('message',true);
+			$post['type'] = $this->input->post('type',true);
+			$post['repeat'] = $this->input->post('repeat',true);
+			$ktime = $this->input->post('ktime',true);
+			$post['ktime'] = strtotime($ktime);
+			$jtime = $this->input->post('jtime',true);
+			$post['jtime'] = strtotime($jtime);
+			$post['content'] = $this->input->post('content');
+			$post['emailtitle'] = $this->input->post('emailtitle');
+			$post['js'] = '';
+			if($post['type'] == 1)
+			{
+				$post['ordertatus'] = $this->input->post('ordertatus',true);
+				if($post['ordertatus'] == 2 || $post['ordertatus'] == 3)
+				{
+					$post['sending'] = $this->input->post('sending',true);
+					$post['timeinterval'] = $this->input->post('timeinterval',true);
+				}
+				$post['logisticstatus'] = 0;
+			}
+			else if($post['type'] == 2)
+			{
+				$post['ordertatus'] = 0;//非订单状态写入:未获取
+				$post['logisticstatus'] = $this->input->post('logisticstatus',true);
+			}
+			else if($post['type'] == 3)
+			{
+				$post['ordertatus'] = 0;//非订单状态写入:未获取
+				$marketing = $this->input->post('marketing',true);
+			    $post['marketing'] = strtotime($marketing);
+			}
+			else if($post['type'] == 4)
+			{
+				$post['js'] = $this->input->post('js',true);
+				if($post['js'] != '')
+				{
+					$post['js'] = ','.$post['js'];
+				}
+				$post['express'] = $this->input->post('express',true);
+				if($post['express'] != '')
+				{
+					$post['express'] = ','.$post['express'];
+				}
+			}
+			$post['state'] = $this->input->post('state',true);
+			if($post['state'] == 1)
+			{
+				$post['statetime'] = time();
+			}
+			if($this->notice->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$notice = $this->notice->read($arg_array[0]);
+		$this->data['notice'] = $notice;
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$email = $this->emaildata->find_all('1=1 and '.rtrim($fgshop,'or'));
+		$this->data['email'] = $email;
+		$mb = 2;
+		if(isset($arg_array[0]))
+		{
+			if($arg_array[0]=='smt')
+			{
+				$mb = 1;
+			}
+			else if($arg_array[0]=='dlz')
+			{
+				$mb = 2;
+			}
+			else if($arg_array[0]=='tt')
+			{
+				$mb = 3;
+			}
+		}
+		$this->data['arg'] = $mb;
+		$this->_Template('notice_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->notice->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	
+	public function _email()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$shop = $this->input->post('shop',true);
+			$email = $this->input->post('email',true);
+			$notice = $this->input->post('notice',true);
+			$xztime = $this->input->post('xztime',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "1=1 and (".rtrim($fgshop,'or').")";
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($email)
+            {
+                $where  .= " and email like '%$email%'";
+            }
+			if($notice)
+            {
+                $where  .= " and notice = '$notice'";
+            }
+			if($timetk && $timetj)
+            {
+                $where  .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
+            }
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->noticeemail->find_all($where,'id,shop,email,notice,addtime,time',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$data = $this->noticeemail->read($value['id']);
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				$info_list[$key]['addtime'] = date('Y-m-d H:i:s',$value['addtime']);
+				if(is_numeric($value['time']) &&  $value['time'] > 0)
+				{
+				    $info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
+				}
+				else
+				{
+					$info_list[$key]['time'] = '';
+					if($data['error'] != '')
+					{
+						$info_list[$key]['time'] = $data['error'];
+					}
+				}
+				$notice = $this->notice->read($value['notice']);
+				$info_list[$key]['notice'] = $notice['title'];
+            }
+		    $total = $this->noticeemail->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$notice = $this->notice->find_all("message = 1 and type = '3' and (".rtrim($fgshop,'or').")");
+		$this->data['notice'] = $notice;
+		$this->_Template('notice_email',$this->data);
+	}
+	
+	public function _addemail()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['email']))  
+		{
+			$time = time();$cw = '';$i = 0;$fs = '';
+		    $notice = $this->input->post('notice',true);
+			$n = $this->notice->read($notice);
+			$email = $this->input->post('email',true);
+			$email = str_replace(PHP_EOL, ',', $email);
+            $email =  explode(',',trim($email,','));
+			$this->db->trans_begin();
+			foreach ($email as $v) 
+		    {
+				$f = $this->fullorder->find_all("email = '$v' and shop = '".$n['shop']."'",'*','id desc');
+				if(isset($f[0]['email']))
+				{
+					$tid = $this->noticeemail->insert(array('shop'=>$f[0]['shop'],'email'=>$v,'notice'=>$notice,'addtime'=>$time));
+					$fs .= $f[0]['id'].'-'.$tid.',';
+				}
+				else
+				{
+					$i++;
+					$cw .= $v.',';
+				}
+			}
+			if(count($email) == $i)
+			{
+				echo json_encode(array('msg'=>'Email地址全部错误,请排查!','success'=>false));exit;
+			}
+			if($this->db->trans_status() === TRUE)
+			{
+				$this->db->trans_commit();
+				$ch = curl_init();
+				$url = 'http://a'.rand(10,50).'.wepolicy.cn/notice/emailfs';
+				curl_setopt($ch,CURLOPT_URL,$url);
+				curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
+				curl_setopt($ch,CURLOPT_HEADER,0);
+				curl_setopt($ch,CURLOPT_POST, 1);
+				curl_setopt($ch,CURLOPT_TIMEOUT,1);
+        		//设置post数据
+				$post = array();
+				$post['notice'] = $notice;
+				$post['fs'] = trim($fs,',');
+        		curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
+				$res = curl_exec($ch);
+				curl_close($ch);
+				if($i > 0)
+				{
+					echo json_encode(array('msg'=>'有错误Email地址,请排查!其它正常发送中。<br>错误Email:<br>'.trim($cw,',').'<br>','success'=>true));exit;
+				}
+				else
+				{
+					echo json_encode(array('n'=>0,'msg'=>'添加成功,邮件逐条发送中','success'=>true));exit;
+			    }
+				
+			}
+			else
+			{
+			    $this->db->trans_rollback();
+				echo json_encode(array('msg'=>'系统错误,请重试!!','success'=>false));exit;
+		    }
+		}
+		$notice = $this->notice->find_all("message = 1 and type = '3' and (".rtrim($fgshop,'or').")");
+		$this->data['notice'] = $notice;
+		$this->_Template('notice_addemail',$this->data);
+	}
+	
+	public function _emailfs()
+	{
+		$time = time();
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['notice']))  
+		{
+			$notice = $this->input->post('notice');
+			$notice = $this->notice->read($notice);
+			$notice['email'] = $this->emaildata->read($notice['email']);
+			$fs = $this->input->post('fs');
+			$fs =  explode(',',$fs);
+			foreach ($fs as $v) 
+		    {
+				$v = explode('-',$v);
+				$data = $this->fullorder->read($v[0]);
+				$shop = $this->shop->read($data['shop']);
+				$express = $this->express->read($data['express']);
+				$this->als->save(array('cs'=>json_encode(array($data,$shop,$express,$notice))),1);
+				$go = $this->notice->get_god($data,$shop,$express,$notice);
+				if($go == 1)
+		        {
+					$this->noticeemail->save(array('time'=>time()),$v[1]);
+				}
+				else
+				{
+					$this->noticeemail->save(array('error'=>$go),$v[1]);
+				}
+				sleep(50);
+			}
+		}
+	}
+	
+	public function _testfs()
+	{
+		$time = time();
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))  
+		{
+			$id = $this->input->post('id');
+			$email = $this->input->post('email');
+			$number = $this->input->post('number');
+			$data = $this->fullorder->get_number($number);
+			if(!$data)
+			{
+				$data = $this->fullordersmt->get_number($number);
+				if(!$data)
+				{
+					$data = $this->fullordertt->get_number($number);
+					if(!$data)
+					{
+						echo json_encode(array('msg'=>'编号无效!','success'=>false));exit;
+					}
+				}
+			}
+			else
+			{
+				if(!$email)
+				{
+					echo json_encode(array('msg'=>'请输入邮箱!','success'=>false));exit;
+				}
+			}
+			$data['email'] = $email;
+			$shop = $this->shop->read($data['shop']);
+			$express = $this->express->read($data['express']);
+			$id_arr =  explode(',',trim($id,','));$i = 0;
+			foreach ($id_arr as $v) 
+		    {
+				$notice = $this->notice->read($v);
+				if($notice)
+				{
+					$notice['email'] = $this->emaildata->read($notice['email']);
+					$go = $this->notice->get_god($data,$shop,$express,$notice);
+					if($go == 1)
+		        	{
+						$i++;
+					}
+				}
+			}
+			if($i == count($id_arr))
+			{
+				echo json_encode(array('msg'=>'发送成功','success'=>false));exit;
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'有部分发送失败'.$go,'success'=>false));exit;
+			}
+		}
+	}
+}

+ 364 - 0
core/CoreApp/controllers/Orderurl.php

@@ -0,0 +1,364 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Orderurl extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_orderurl','orderurl');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_fullorderexcel','fullorderexcel');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'order')//修改
+        {
+             $this->_order();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+	
+	public function _index()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$shop = $this->input->post('shop',true);
+			$url = $this->input->post('url',true);
+			$title = $this->input->post('title',true);
+			$where = "(".rtrim($fgshop,'or').")";
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			if($shop)
+			{
+				$where .= " and shop = '$shop'";
+			}
+			if($title)
+			{
+				$where .= " and title like '%$title%'";
+			}
+			if($url)
+			{
+				$where .= " and url like '%$url%'";
+			}
+            //取得信息列表
+            $info_list = $this->orderurl->find_all($where,'id,title,url',$order_str,$start,$perpage);
+		    $total = $this->orderurl->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$this->_Template('orderurl',$this->data);
+	}
+	
+	
+	
+	public function _order()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$sid .= " id = ".$value." or";
+			}
+		}
+		else
+		{
+			echo "请重新登录";
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$warehouse = $this->input->post('warehouse',true);
+			$xztime = $this->input->post('xztime',true);
+			$timetk = $this->input->post('timetkk',true);
+			$timetj = $this->input->post('timetjj',true);
+			$shop = $this->input->post('shop',true);
+			$source = $this->input->post('source',true);
+			$orderinfo = $this->input->post('orderinfo',true);
+			$number = $this->input->post('number',true);
+			$sfxh = $this->input->post('sfxh',true);
+			$express = $this->input->post('express',true);
+			$waybill = $this->input->post('waybill',true);
+			$library = $this->input->post('library',true);
+			$country = $this->input->post('country',true);
+			$so = $this->input->post('so',true);
+			$libraryconfirm = $this->input->post('libraryconfirm',true);
+			$print = $this->input->post('print',true);
+			$state = $this->input->post('state',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			/**
+			$sj = $this->input->post('sj',true);
+			if($sj)
+			{
+				$sj = $this->input->post('sj',true);
+			}
+			else
+			{
+				$sj = "fullorder";
+			}
+			**/
+			$sj = "fullorder";
+			$where = "mergeid = 0";
+			if($warehouse)
+            {
+                $where  .= " and type = '$warehouse'";
+            }
+			if($timetk && $timetj)
+            {
+                $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($express)
+            {
+                $where  .= " and express = '$express'";
+            }
+			if($waybill)
+            {
+                $where  .= " and waybill = '$waybill'";
+            }
+			if($library)
+            {
+                $where  .= " and library = '$library'";
+            }
+			if($print)
+            {
+                $where  .= " and print = '$print'";
+            }
+			if($libraryconfirm)
+            {
+                $where .= " and libraryconfirm = '$libraryconfirm'";
+            }
+			if($state)
+            {
+                $where .= " and state = '$state'";
+            }
+			if($shop)
+            {
+                $where .= " and shop = '$shop'";
+            }
+			if($country)
+            {
+                $where .= " and country = '$country'";
+            }
+			if($sfxh != '')
+            {
+                $where .= " and sfxh = '$sfxh'";
+            }
+			if($so)
+            {
+                $where  .= " and shipremarks like '%$so%'";
+            }
+			if($source)
+            {
+				if($source == '2d')
+				{
+					$where  .= " and source >= '2'";
+				}
+				else
+				{
+                    $where  .= " and source = '$source'";
+				}
+            }
+			if(isset($_SESSION['api']))
+		        {
+			        foreach ($user as $value) 
+		            {
+			        	$fgshop .= " shop = ".$value." or";
+			        }
+					$where .= " and (".rtrim($fgshop,'or').")";
+		        }
+            //数据排序
+            $order_str = "librarytime desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				$express = $this->express->read($value['express']);
+				$info_list[$key]['express'] = $express['servicename'];
+				$warehouse = $this->warehouse->read($value['type']);
+				$info_list[$key]['type'] = $warehouse['title'];
+				if($value['librarytime'] == '0')
+				{
+					$info_list[$key]['librarytime'] = '<em class="t"></em>';
+				}
+				else
+				{
+					$info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
+				}
+            }
+		    $total = $this->$sj->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->data['express'] = $this->express->find_all();
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$this->data['fullorderexcel'] = $this->fullorderexcel->find_all('type=2','*','idorder desc');//导出模板
+		$this->_Template('orderurl_order',$this->data);
+	}
+	
+	//添加
+	public function _add()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['url']))
+		{
+			$d = $this->orderurl->get_url($post['url']);
+			if($d)
+			{
+				echo json_encode(array('msg'=>'已有此链接','success'=>false));exit;
+			}
+			if($this->orderurl->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$this->_Template('orderurl_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $user = explode('|',trim($user['shop'],'|'));
+			foreach ($user as $value) 
+		    {
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			if($this->orderurl->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$orderurl = $this->orderurl->read($arg_array);
+		$this->data['orderurl'] = $orderurl;
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+		$this->_Template('orderurl_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->orderurl->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 449 - 0
core/CoreApp/controllers/Outbound.php

@@ -0,0 +1,449 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+header("Access-Control-Allow-Origin: *");
+class Outbound extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_outbound','outbound');
+		$this->load->_model('Model_excel','excel');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'data')//出库页
+        {
+             $this->_data();
+        }
+		else if($arg == 'del')
+        {
+             $this->_del();
+        }
+		else if($arg == 'add')
+        {
+             $this->_add();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['number']))
+		{
+			$where = "gtime = '".date('Ymd',time())."'";
+			$number = $this->input->post('number',true);
+			$id = $this->input->post('id',true);
+			$type = $this->input->post('type',true);
+			$express = $this->input->post('express',true);
+			if($id)
+            {
+				if($type)
+            	{
+                	$where  .= " and type = '$type'";
+           		}
+				else
+				{
+					$uw = '';
+				    $u = $this->user->get_api($id);
+				    $u['warehouse'] =  explode('|',trim($u['warehouse'],'|'));
+				    foreach ($u['warehouse'] as $v) 
+		            {
+					    $uw  .= " type = '$v' or";
+                    }
+				    $uw = rtrim($uw,'or');
+					$uw = " and (".ltrim($uw,' ').")";
+					$where  .= $uw;
+				}
+            }
+			if(!$number)
+			{
+				echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
+			}
+			if(!$type)
+			{
+				echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;
+			}
+			if(!$express)
+			{
+				echo json_encode(array('msg'=>'请选择需要录入的快递!','success'=>false));exit;
+			}
+			if(stripos($number,'-') !== false)
+				{
+					echo json_encode(array('msg'=>'请扫描正确的运单号!','success'=>false));exit;
+				}
+				if(substr($number,0,3) == '788' && substr($number,-4,4) == '0430')//Fedex联邦
+				{
+					$number = substr($number,0,12);
+				}
+				if(strlen($number) == '34')//联邦杭州超长运单截取
+				{
+					$number = substr($number,22,12);
+				}
+				$sex = $this->express->read($express);
+				$ex = array('DHL'=>10,'FEDEX'=>12,'FEDEXGF'=>12,'UPS'=>18,'GES'=>17,'TNT'=>9,'ARAMEX'=>11,'EMS_ZX_ZX_US'=>13);
+				if(isset($ex[$sex['printcode']]))
+				{
+					if(strlen($number) != $ex[$sex['printcode']])
+					{
+						echo json_encode(array('msg'=>'运单号错误,此单请重新录入运单号!','success'=>false));exit;
+					}
+				}
+				$yd = $this->fullorder->find_all("waybill = '$number' and library = '2'");
+				if(isset($yd[0]['number']))
+				{
+					$number = $yd[0]['number'];
+				}
+				else
+				{
+					$yd = $this->fullordersmt->find_all("waybill = '$number'");
+					if(isset($yd[0]['number']))
+				    {
+					    $number = $yd[0]['number'];
+				    }
+					else
+					{
+						echo json_encode(array('msg'=>'系统中未查到此运单,请确认!','success'=>false));exit;
+					}
+				}
+				$nu = $this->outbound->get_number($number);
+			if($nu)
+			{
+				echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
+			}
+				if($this->outbound->insert(array('type'=>$type,'number'=>$number,'express'=>$express,'gtime'=>date('Ymd',time()),'time'=>time())))
+					{
+						$data = $this->outbound->find_count($where);
+						echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
+					}
+				else
+				{
+					echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
+				}
+			
+		}
+	}
+	
+	
+	public function _indexxxxx()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['number']))
+		{
+			$where = "gtime = '".date('Ymd',time())."'";
+			$number = $this->input->post('number',true);
+			$id = $this->input->post('id',true);
+			$type = $this->input->post('type',true);
+			$express = $this->input->post('express',true);
+			if($id)
+            {
+				if($type)
+            	{
+                	$where  .= " and type = '$type'";
+           		}
+				else
+				{
+					$uw = '';
+				    $u = $this->user->get_api($id);
+				    $u['warehouse'] =  explode('|',trim($u['warehouse'],'|'));
+				    foreach ($u['warehouse'] as $v) 
+		            {
+					    $uw  .= " type = '$v' or";
+                    }
+				    $uw = rtrim($uw,'or');
+					$uw = " and (".ltrim($uw,' ').")";
+					$where  .= $uw;
+				}
+            }
+			if(!$number)
+			{
+				echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
+			}
+			if(!$type)
+			{
+				echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;
+			}
+			if(!$express)
+			{
+				echo json_encode(array('msg'=>'请选择需要录入的快递!','success'=>false));exit;
+			}
+			$nu = $this->outbound->get_number($number);
+			if($nu)
+			{
+				echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
+			}
+			$wa = $this->outbound->get_waybill($number);
+			if($wa)
+			{
+				echo json_encode(array('msg'=>'错误!此运单号'.date('Ymd',$wa['time']).'已录入!','success'=>false));exit;
+			}
+			$jd = $this->outbound->find_all($where,'*','id desc');
+			if(!isset($jd[0]) || $jd[0]['waybill'] != '')
+			{
+				$pd = explode('-',$number);
+				if(!isset($pd[1]) || !isset($pd[2]))
+				{
+					echo json_encode(array('msg'=>'编号不正确,请重试!','success'=>false));exit;
+				}
+				if(strlen($pd[1]) == '5' && strlen($pd[2]) == '3')
+				{
+					if($this->outbound->insert(array('type'=>$type,'number'=>$number,'express'=>$express,'gtime'=>date('Ymd',time()),'time'=>time())))
+					{
+						$data = $this->outbound->find_count($where);
+						echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
+					}
+					else
+					{
+						echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
+					}
+				}
+				else
+				{
+					echo json_encode(array('msg'=>'编号不正确!','success'=>false));exit;
+				}
+			}
+			else
+			{
+				if(stripos($number,'-') !== false)
+				{
+					echo json_encode(array('msg'=>'请扫描'.$jd[0]['number'].'对应的运单号!','success'=>false));exit;
+				}
+				if(substr($number,0,3) == '788' && substr($number,-4,4) == '0430')//Fedex联邦
+				{
+					$number = substr($number,0,12);
+				}
+				if(strlen($number) == '34')//联邦杭州超长运单截取
+				{
+					$number = substr($number,22,12);
+				}
+				$sex = $this->express->read($express);
+				$ex = array('DHL'=>10,'FEDEX'=>12,'FEDEXGF'=>12,'UPS'=>18,'GES'=>17,'TNT'=>9,'ARAMEX'=>11,'EMS_ZX_ZX_US'=>13);
+				if(isset($ex[$sex['printcode']]))
+				{
+					if(strlen($number) != $ex[$sex['printcode']])
+					{
+						echo json_encode(array('msg'=>'运单号错误,此单请重新录入运单号!','success'=>false));exit;
+					}
+				}
+				if($this->outbound->save(array('waybill'=>$number),$jd[0]['id']))
+				{
+					$data = $this->outbound->find_count($where);
+					echo json_encode(array('msg'=>$data,'music'=>'1','success'=>true));exit;
+				}
+				else
+				{
+					echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
+				}
+			}
+			
+		}
+	}
+	
+	public function _data()
+	{
+		if(isset($_GET['fexcel']))  
+		{
+			$id = $this->input->get('id',true);
+			$timetk = $this->input->get('timetk',true);
+			$timetj = $this->input->get('timetj',true);
+			$library = $this->input->get('library',true);
+			$type = $this->input->get('type',true);
+			$number = $this->input->get('number',true);
+			$waybill = $this->input->get('waybill',true);
+			$express = $this->input->get('express',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "type != 0";
+			if($timetk && $timetj)
+            {
+                $where  .= " and time > '$timetk' and time < '$timetj'";
+            }
+			if($id)
+            {
+				if($type)
+            	{
+                	$where  .= " and type = '$type'";
+           		}
+				else
+				{
+					$uw = '';
+				    $u = $this->user->get_api($id);
+				    $u['warehouse'] =  explode('|',trim($u['warehouse'],'|'));
+				    foreach ($u['warehouse'] as $v) 
+		            {
+					    $uw  .= " type = '$v' or";
+                    }
+				    $uw = rtrim($uw,'or');
+					$uw = " and (".ltrim($uw,' ').")";
+					$where  .= $uw;
+				}
+            }
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($waybill)
+            {
+                $where  .= " and waybill = '$waybill'";
+            }
+			if($express)
+            {
+				$where  .= " and express = '$express'";
+            }
+			$data = array();
+			$datafy = array();
+			$j = 0;
+			$info_list = $this->outbound->find_all($where,'number,waybill');
+			foreach ($info_list as $key=>$value)
+		    {
+				$datafy[] = array($value['number'],$value['waybill']);
+				if($j == $library-1)
+				{
+					$data[] = $datafy;
+					$j = 0;$datafy = array();
+				}
+				else
+				{
+					$j++;
+				}
+			}
+			$data[] = $datafy;
+			 //格式化数据
+			$i = 0;$cpexcel = array();
+            $title = date('Ymd',time())."发货统计信息"; $td = '';
+			for($i=0;$i<ceil(count($info_list)/$library);$i++)
+			{
+				$td .= "<td>组".($i+1)."</td><td></td>";
+			}
+            $titlename = "<table border=1>
+            <tr>
+            ".$td."
+            </tr>
+            </table>"; 
+            $filename = $title.".xls";
+            $this->excel->get_fz6($data,$titlename,$filename);
+	    }
+	}
+	
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['number']))
+		{
+			$where = "gtime = '".date('Ymd',time())."'";
+			$number = $this->input->post('number',true);
+			$waybill = $this->input->post('waybill',true);
+			$id = $this->input->post('id',true);
+			$type = $this->input->post('type',true);
+			$express = $this->input->post('express',true);
+			$time = $this->input->post('time',true);
+			$time = strtotime($time);
+			if($id)
+            {
+				if($type)
+            	{
+                	$where  .= " and type = '$type'";
+           		}
+				else
+				{
+					$uw = '';
+				    $u = $this->user->get_api($id);
+				    $u['warehouse'] =  explode('|',trim($u['warehouse'],'|'));
+				    foreach ($u['warehouse'] as $v) 
+		            {
+					    $uw  .= " type = '$v' or";
+                    }
+				    $uw = rtrim($uw,'or');
+					$uw = " and (".ltrim($uw,' ').")";
+					$where  .= $uw;
+				}
+            }
+			if(!$number)
+			{
+				echo json_encode(array('msg'=>'编号不能为空!','success'=>false));exit;
+			}
+			if(!$waybill)
+			{
+				echo json_encode(array('msg'=>'运单号不能为空!','success'=>false));exit;
+			}
+			if(!$type)
+			{
+				echo json_encode(array('msg'=>'请选择需要录入数据的仓库!','success'=>false));exit;
+			}
+			if(!$express)
+			{
+				echo json_encode(array('msg'=>'请选择需要录入的快递!','success'=>false));exit;
+			}
+			$nu = $this->outbound->get_number($number);
+			if($nu)
+			{
+				echo json_encode(array('msg'=>'错误!此编号'.date('Ymd',$nu['time']).'已录入!','success'=>false));exit;
+			}
+			$wa = $this->outbound->get_waybill($waybill);
+			if($wa)
+			{
+				echo json_encode(array('msg'=>'错误!此运单号'.date('Ymd',$wa['time']).'已录入!','success'=>false));exit;
+			}
+			
+			$sex = $this->express->read($express);
+			$ex = array('DHL'=>10,'FEDEX'=>12,'FEDEXGF'=>12,'UPS'=>18,'GES'=>17,'TNT'=>9,'ARAMEX'=>11,'EMS_ZX_ZX_US'=>13);
+			if(isset($ex[$sex['printcode']]))
+			{
+				if(strlen($waybill) != $ex[$sex['printcode']])
+				{
+					echo json_encode(array('msg'=>'运单号错误,此单请重新录入运单号!','success'=>false));exit;
+				}
+			}
+			
+			if($this->outbound->insert(array('type'=>$type,'number'=>$number,'waybill'=>$waybill,'express'=>$express,'gtime'=>date('Ymd',$time),'time'=>$time+1)))
+			{
+				echo json_encode(array('msg'=>'添加成功!','success'=>true));exit;
+			}
+			
+		}
+	}
+	
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['delarr']))  
+		{
+            $id_arr = $this->input->post('delarr');
+            $id_arr =  explode(',',rtrim($id_arr,','));
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'未选择需要删除的内容!','success'=>false));exit;
+            }
+            //循环删除记录
+			$a=0;
+            foreach ($id_arr as $v) 
+		    {
+				if($this->outbound->remove($v))
+				{
+					$a++;
+				}
+				
+            }
+			if($a == count($id_arr))
+			{
+				$data = $this->outbound->find_count("gtime = '".date('Ymd',time())."'");
+                echo json_encode(array('del'=>$id_arr,'data'=>$data,'msg'=>'删除成功!','success'=>true));
+			}
+			else
+			{
+				echo json_encode(array('del'=>$id_arr,'msg'=>'部分记录删除失败,请查询确认!','success'=>true));
+			}
+		}
+	}
+	public function _ex()
+	{
+		
+	}
+}

+ 130 - 0
core/CoreApp/controllers/Packing.php

@@ -0,0 +1,130 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Packing extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_packing','packing');
+		$this->load->_model('Model_whlabel','whlabel');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')//获取数据
+        {
+             $this->_rows();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$where = "1=1 ";
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->packing->find_all($where,'id,model,weightend,weight',$order_str,$start,$perpage);
+		    $total = $this->packing->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('packing',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['model']))
+		{
+			$post['classid'] = 2;
+			$post['model'] = $this->input->post('model',true);
+			$post['weightend'] = $this->input->post('weightend',true);
+			$post['weight'] = $this->input->post('weight',true);
+			if($this->packing->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('packing_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['classid'] = 2;
+			$post['model'] = $this->input->post('model',true);
+			$post['weightend'] = $this->input->post('weightend',true);
+			$post['weight'] = $this->input->post('weight',true);
+			if($this->packing->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$packing = $this->packing->read($arg_array);
+		$this->data['packing'] = $packing;
+		$this->_Template('packing_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->packing->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 129 - 0
core/CoreApp/controllers/Pay.php

@@ -0,0 +1,129 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Pay extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_pay','pay');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$where = "1=1 ";
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->pay->find_all($where,'id,typeclass,estimaterate',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$type = $this->typeclass->read($value['typeclass']);
+				$info_list[$key]['typeclass'] = $type['title'];
+            }
+		    $total = $this->pay->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('pay',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['typeclass']))
+		{
+			$d = $this->pay->get_typeclass($post['typeclass']);
+			if($d)
+			{
+				echo json_encode(array('msg'=>'此支付方式已有设置数据','success'=>false));exit;
+			}
+			if($this->pay->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('pay_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			if($this->pay->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$pay = $this->pay->read($arg_array);
+		$this->data['pay'] = $pay;
+		$this->_Template('pay_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->pay->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 138 - 0
core/CoreApp/controllers/Paypal.php

@@ -0,0 +1,138 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Paypal extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'token')
+        {
+			$this->_token();
+        }
+		else
+		{
+			$this->_index($arg_array);
+		}
+    }
+	public function _index($arg_array)
+	{
+		$url = 'https://api.sandbox.paypal.com/v1/customer/disputes/';
+		$header[] = 'Content-Type: application/json';
+        $header[] = 'Accept-Language: en_US';
+        $header[] = 'Accept: */*';
+        $method = 'POST';
+        $hf_account = 'paypal-facilitator@supernovahair.com';
+        $client_id = 'Ae5ZECTwT-JY-GrHW2-XW234yJ4tYT-7RAt3s1mY8GtW1rX470Kr8weXkCH3GMaO-V7mnmnCTsxFvsiy';
+        $secret_id = 'EOiZjIwRaiK3pvbJgMURKcGy6ULt5YCGLkqN7WngwG-r34brYrfVwS6ECI8cig7l8lOObvF-ukeZxB-3';
+		$data = array('grant_type' => 'client_credentials');
+		$data['start_time'] = date('Y-m-d',time()-20*24*3600);
+		$data['page'] = $arg_array[0];
+		$data['page_size'] = 50;
+		$data['next_page_token'] = $this->_token();
+		$data['dispute_state'] = 'OPEN_INQUIRIES';
+        $userpwd = $client_id . ':' . $secret_id;
+        $info = $this->_curl($data,$url,3000,$method,true,$header,$userpwd);
+		echo "<pre>";
+		print_r($info);
+    }
+	
+	public function _token()
+	{
+		$url = 'https://api.sandbox.paypal.com/v1/oauth2/token';
+        $header[] = 'Content-Type: application/json';
+        $header[] = 'Accept-Language: en_US';
+        $header[] = 'Accept: */*';
+        $data = array('grant_type' => 'client_credentials');//请求头内容
+        $method = 'POST';
+        $hf_path = $_SERVER["DOCUMENT_ROOT"] . '/data/hf_access_token.txt';
+        $hf_access_token = '';
+        if(file_exists($hf_path))
+		{
+            $file_read = fopen($hf_path, 'r');
+            $access_str = fgets($file_read);
+            fclose($file_read);
+            $access_arr = explode(':', $access_str);
+            if (time() < intval($access_arr[0])) 
+			{
+				$hf_access_token = isset($access_arr[1]) ? $access_arr[1] : '';
+            }
+        }
+        if(!$hf_access_token)
+		{
+            $file = fopen($hf_path, 'w');
+            $hf_account = 'paypal-facilitator@supernovahair.com';
+            $client_id = 'Ae5ZECTwT-JY-GrHW2-XW234yJ4tYT-7RAt3s1mY8GtW1rX470Kr8weXkCH3GMaO-V7mnmnCTsxFvsiy';
+            $secret_id = 'EOiZjIwRaiK3pvbJgMURKcGy6ULt5YCGLkqN7WngwG-r34brYrfVwS6ECI8cig7l8lOObvF-ukeZxB-3';
+            $userpwd = $client_id . ':' . $secret_id;
+            $info = $this->_curl($data,$url,3000,$method,true,$header,$userpwd);
+            $result = json_decode($info,true);
+            $access_new = (time() + $result['expires_in']) . ':' . $result['access_token'];
+            fwrite($file, $access_new);
+            fclose($file);
+			$hf_access_token = $result['access_token'];
+		}
+		return $hf_access_token;
+    }
+	
+	public function _curl($data,$url,$timeout=300,$httptype="POST",$date_type=false,$header=array(),$userpwd='')
+    {
+    
+        if ($date_type == 'http_build_query')
+		{
+            $data = http_build_query($data);
+        }
+		else if ($date_type == 'json')
+		{
+            $data = json_encode($data);
+        }
+
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_HEADER, false);
+        switch ($httptype)
+		{
+            case "GET":
+            curl_setopt($ch, CURLOPT_HTTPGET, true);
+            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
+            break;
+			
+            case "POST":
+            curl_setopt($ch, CURLOPT_POST, true);
+            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
+            break;
+			
+            case "PUT":
+            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
+            break;
+			
+            case "DELETE":
+            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
+            break;
+        }
+        $isSecure = strpos($url, "https://");
+        if ($isSecure === 0)
+		{
+            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+        }
+        if(!empty($header))
+		{
+            curl_setopt($ch, CURLOPT_SSLVERSION , 6); //NEW ADDITION
+            curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
+        }
+
+        if(!empty($userpwd))
+		{
+            curl_setopt($ch,CURLOPT_USERPWD,$userpwd);
+        }
+        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
+        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+        $result = curl_exec($ch);
+        curl_close($ch);
+        return $result;
+    }
+}

+ 228 - 0
core/CoreApp/controllers/Power.php

@@ -0,0 +1,228 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Power extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_power','power');
+		$this->load->_model('Model_user','user');
+		$this->load->_model('Model_nav','nav');
+		$this->load->_model('Model_fullorderexcel','fullorderexcel');
+		$this->load->_model('Model_fullorderexcelclassid','fullorderexcelclassid');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')//获取数据
+        {
+             $this->_rows();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$user = $this->user->get_api($_SESSION['api']);
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$powername = $this->input->post('powername',true);
+			$where = "own='".$user['own']."'";
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			if($powername)
+			{
+				$where .= "and powername like '%$powername%'";
+			}
+            //取得信息列表
+            $info_list = $this->power->find_all($where,'id,powername,title,powertext,exceltext',$order_str,$start,$perpage);
+		    $total = $this->power->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('power',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$user = $this->user->get_api($_SESSION['api']);
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['powername']))
+		{
+			$post['powername'] = $this->input->post('powername',true);
+			//$post['excelshop'] = $this->input->post('excelshop',true);
+			$powertext= $this->input->post('powertext',true);
+			$powerid = $this->input->post('powerid',true);
+			$post['powertext'] = "|".$powertext;
+			$post['powerid'] = "|".$powerid;
+			$post['own'] = $user['own'];
+			if($this->power->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('power_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['powername'] = $this->input->post('powername',true);
+			$post['excelshop'] = $this->input->post('excelshop',true);
+			$powertext= $this->input->post('powertext',true);
+			$powerid = $this->input->post('powerid',true);
+			$post['powertext'] = "|".ltrim($powertext,'|');
+			$post['powerid'] = "|".ltrim($powerid,'|');
+			$exceltext= $this->input->post('exceltext',true);
+			$excelid = $this->input->post('excelid',true);
+			$post['exceltext'] = "|".ltrim($exceltext,'|');
+			$post['excelid'] = "|".ltrim($excelid,'|');
+			if($this->power->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$power = $this->power->read($arg_array);
+		$this->data['power'] = $power;
+		$this->_Template('power_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->power->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	//获取数据
+	public function _rows()
+	{
+		$user = $this->user->get_api($_SESSION['api']);
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['rows']))  
+		{
+			$rows = $this->input->post('rows',true);
+            $dataa = $this->nav->find_all('type=1 and '.$user['own'].'=1','*','sort asc');
+		    $datab = $this->nav->find_all('type=2 and '.$user['own'].'=1','*','son asc');
+		    $datac = $this->nav->find_all('type=3 and '.$user['own'].'=1','*','sort asc');
+		    $an = array();
+		    foreach ($dataa as $key=>$value) 
+		    {
+			    foreach ($datab as $ke=>$va) 
+		        {
+			    	if($va['class'] == $value['id'])
+			        {
+				    	foreach ($datac as $k=>$v) 
+		                {
+					    	if($v['class'] == $va['id'])
+			                {
+					    		$va['cn'][]=$v;
+			                }
+			            }
+						$value['bn'][]=$va;
+			        }
+			     }//循环出二级导航航
+				 $an[] = $value;
+            }
+			$power = array();
+			if($rows != "null")
+			{
+			    $power = $this->power->read($rows);//找出次ID的权限内容
+				if($power['powerid'])
+				{
+			        $power = explode('|',trim($power['powerid'],'|'));//数组化权限内容
+				}
+				else
+				{
+					$power = array();
+				}
+			}
+		    echo json_encode(array('msg'=>($an),'power'=>($power),'success'=>true));
+		}
+		else if(isset($post['excel']))  
+		{
+			$excel = $this->input->post('excel',true);
+			$rows = $excel;
+            $dataa = $this->fullorderexcelclassid->find_all('1=1','*','id asc');
+		    $datab = $this->fullorderexcel->find_all('1=1','*','id asc');
+		    $an = array();
+		    foreach ($dataa as $key=>$value) 
+		    {
+			    foreach ($datab as $ke=>$va) 
+		        {
+			    	if($va['type'] == $value['id'])
+			        {
+						$value['bn'][]=$va;
+			        }
+			     }//循环出二级导航航
+				 $an[] = $value;
+            }
+			$power = array();
+			if($rows != "null")
+			{
+			    $power = $this->power->read($rows);//找出次ID的权限内容
+				if($power['excelid'])
+				{
+			        $power = explode('|',trim($power['excelid'],'|'));//数组化权限内容
+				}
+				else
+				{
+					$power = array();
+				}
+			}
+		    echo json_encode(array('msg'=>($an),'power'=>($power),'success'=>true));
+		}
+    }
+}

+ 379 - 0
core/CoreApp/controllers/Printcode.php

@@ -0,0 +1,379 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Printcode extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->_model('Model_print_code','printcode');
+		$this->load->_model('Model_excel','excel');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'addexcel')
+        {
+             $this->_addexcel();
+        }
+		else if($arg == 'print')
+        {
+             $this->_print();
+        }
+		else if($arg == 'see')
+        {
+             $this->_see();
+        }
+		else if($arg == 'add')
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')
+        {
+             $this->_del();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+	
+	public function _see()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$number = $this->input->post('number',true);
+			$label = $this->input->post('label',true);
+			$print = $this->input->post('print',true);
+			$xztime = $this->input->post('xztime',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "1=1";
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($label)
+            {
+				$where  .= " and label = '$label'";
+            }
+			if($print != '')
+            {
+                $where  .= " and print = '$print'";
+            }
+			if($timetk && $timetj)
+            {
+                $where  .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
+            }
+            //数据排序
+            $order_str = $xztime." desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			$info_list = $this->printcode->find_all($where,'id,title,number,label,label2,num,time,addtime',$order_str,$start,$perpage);
+            foreach ($info_list as $key=>$value) 
+		    {
+				if($value['time'] != 0)
+				{
+				    $info_list[$key]['time'] = date('Y-m-d H:i',$value['time']);
+				}
+				else
+				{
+					$info_list[$key]['time'] = '';
+				}
+				if($value['addtime'] != 0)
+				{
+				    $info_list[$key]['addtime'] = date('Y-m-d H:i',$value['addtime']);
+				}
+				else
+				{
+					$info_list[$key]['addtime'] = '';
+				}
+				$info_list[$key]['cz'] = "<span class='amazonbarprint' data-id='".$value['id']."' data-num='".$value['num']."'>打印</span>";
+            }
+			$total = $this->printcode->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('printcode_see',$this->data);
+	}
+	
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$number = $this->input->post('number',true);
+			$label = $this->input->post('label',true);
+			$print = $this->input->post('print',true);
+			$xztime = $this->input->post('xztime',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "1=1";
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($label)
+            {
+				$where  .= " and label = '$label'";
+            }
+			if($print != '')
+            {
+                $where  .= " and print = '$print'";
+            }
+			if($timetk && $timetj)
+            {
+                $where  .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
+            }
+            //数据排序
+            $order_str = $xztime." desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			$info_list = $this->printcode->find_all($where,'id,title,number,label,label2,num,time,addtime',$order_str,$start,$perpage);
+            foreach ($info_list as $key=>$value) 
+		    {
+				if($value['time'] != 0)
+				{
+				    $info_list[$key]['time'] = date('Y-m-d H:i',$value['time']);
+				}
+				else
+				{
+					$info_list[$key]['time'] = '';
+				}
+				if($value['addtime'] != 0)
+				{
+				    $info_list[$key]['addtime'] = date('Y-m-d H:i',$value['addtime']);
+				}
+				else
+				{
+					$info_list[$key]['addtime'] = '';
+				}
+            }
+			$total = $this->printcode->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('printcode',$this->data);
+	}
+	
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['num']))
+		{
+		    $post['num'] = $this->input->post('num');
+			$post['addtime'] = time();
+			if(!is_numeric($post['num']))
+			{
+				echo json_encode(array('msg'=>'数量必须是数字!','success'=>false));exit;
+			}
+			if($this->printcode->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('printcode_add',$this->data);
+	}
+	
+	
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$data = $this->printcode->read($id);
+			$post['num'] = $this->input->post('num');
+			if(!is_numeric($post['num']))
+			{
+				echo json_encode(array('msg'=>'数量必须是数字!','success'=>false));exit;
+			}
+			if($data['time'] != 0)
+			{
+				echo json_encode(array('msg'=>'此单已打印,无法修改!','success'=>false));exit;
+			}
+			if($this->printcode->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$printcode = $this->printcode->read($arg_array);
+		$this->data['printcode'] = $printcode;
+		$this->_Template('printcode_edit',$this->data);
+	}
+	
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+				$data = $this->printcode->read($v);
+				if($data['time'] != 0)
+				{
+					echo json_encode(array('msg'=>$data['title'].'<br>已打印,无法删除!','success'=>false));exit;
+				}
+                $this->printcode->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	
+	public function _print()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+			$v = $this->input->post('s');
+			$va = explode(',',rtrim($v,','));
+			$n = $this->input->post('n');
+			$sl = $this->input->post('sl');
+			$text = array();$text['data'] = array();$time = time();
+			$data = $this->printcode->read($va[$n]);
+			$rows = array('number'=>$data['number'],'label'=>$data['label'],'label2'=>$data['label2'],'num'=>$sl,'data'=>$v,'n'=>$n-1);
+			if($this->printcode->save(array('print'=>1,'time'=>$time),$data['id']))
+        	{
+         		echo json_encode(array('rows'=>($rows),'success'=>true));exit;
+       	 	}
+       		else
+        	{	
+           		echo json_encode(array('msg'=>'数据写入异常,请重新打印!','success'=>false));exit;
+        	}
+		}
+	}
+	
+	public function _addexcel()
+	{
+		$dir = '/data/excel/'.date('Ymd',time()).'/';
+		$config['upload_path'] = '.'.$dir ;
+		$config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
+        $config['allowed_types'] = 'xls|xlsx|csv';
+        $config['max_size'] = 10240;
+		$this->load->library('upload', $config);
+		$this->upload->initialize($config);
+        if ($this->upload->do_upload('userfile'))
+        {
+			$full_path = $dir.$this->upload->data('file_name');
+			$fileName = '.' . $full_path;
+            if (!file_exists($fileName)) 
+			{
+				echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
+            }
+			else
+			{
+				libxml_use_internal_errors(true);
+				require_once "./data/excel/PHPExcel/IOFactory.php";
+				$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
+				$phpExcel->setActiveSheetIndex(0);// 设置为默认表
+				$sheetCount = $phpExcel->getSheetCount();// 获取表格数量
+				$row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
+				$column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
+				++$column;//如果列数大于26行
+				$list = array();
+				for ($i = 3; $i <= $row; $i++) // 行数循环
+				{
+					$data = array();
+                    for ($c = 'A'; $c != $column; $c++)  // 列数循环
+	                {
+						$data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
+                    }
+					$list[] = $data;
+                }
+			}
+			$i = 0;$j = 0;$ed = array();$time = time();
+		    foreach ($list as $key=>$value)
+		    {
+				$time = time();
+				if($value['0'] == "")
+				{
+					continue;
+				}
+				$post['title'] =  $value['1'];
+				$post['number'] =  $value['3'];
+				$post['label'] =  $value['0'];
+				$post['label2'] =  $value['2'];
+				$post['num'] =  $value['4'];
+				$post['addtime'] =  $time;
+				if(!is_numeric($post['num']))
+				{
+					$ed[] = array($key.' 行,非数字!');
+					$j++;
+					continue;
+				}
+				if($post['num'] < 1)
+				{
+					$ed[] = array($key.' 行,数量错误!');
+					$j++;
+					continue;
+				}
+				$this->printcode->insert($post);
+			}
+			if($j > 0)
+			{
+				$tt = date('Ymd',time());
+				$title = '库存导入错误信息-'.$tt;
+        		$titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
+				$tail = "\n";
+        		$filename = $title.".xls";
+        		$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
+				$dir = '/data/excel/'.$time.'/';
+				$file_name = 'error_'.$time.rand(1000,9999);
+				if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
+				$myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
+				fwrite($myfile,$ecl);
+				fclose($myfile);
+				$error = $dir.$file_name.'.xls';
+				echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
+			}
+		}
+	}
+}

+ 398 - 0
core/CoreApp/controllers/Product.php

@@ -0,0 +1,398 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class product extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_product','product');
+		$this->load->_model('Model_typeclass','typeclass');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'list')//修改
+        {
+             $this->_list();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$sku = $this->input->post('sku',true);
+			$category = $this->input->post('category',true);
+			$productweight = $this->input->post('productweight',true);
+			$grade = $this->input->post('grade',true);
+			$size = $this->input->post('size',true);
+			$lowe = $this->input->post('lowe',true);
+			$color = $this->input->post('color',true);
+			$where = "1=1 ";
+			if($sku)
+            {
+                $where  .= " and sku = '$sku'";
+            }
+			if($category)
+            {
+                $where  .= " and category = '$category'";
+            }
+			if($productweight)
+            {
+                $where  .= " and productweight = '$productweight'";
+            }
+			if($grade)
+            {
+                $where  .= " and grade = '$grade'";
+            }
+			if($size)
+            {
+                $where  .= " and size = '$size'";
+            }
+			if($lowe)
+            {
+                $where  .= " and lowe = '$lowe'";
+            }
+			if($color)
+            {
+                $where  .= " and color = '$color'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->product->find_all($where,'id,sku,title,productweight',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$info_list[$key]['title'] = $value['title'].' '.$value['productweight'];
+			}
+		    $total = $this->product->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('product',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['category']))
+		{
+			$category = $this->input->post('category',true);
+			$productweight = $this->input->post('productweight',true);
+			$hairtype = explode(',',rtrim($this->input->post('hairtype',true),','));
+			$grade = explode(',',rtrim($this->input->post('grade',true),','));
+			$size = explode(',',rtrim($this->input->post('size',true),','));
+			$color = explode(',',rtrim($this->input->post('color',true),','));
+			$lowe = explode(',',rtrim($this->input->post('lowe',true),','));
+			$title = "";
+			$ps = array('productweight'=>$productweight);
+			$rows = array(array($category),$hairtype,$grade,$size,$color,$lowe);
+			$key = array('category','hairtype','grade','size','color','lowe');
+			if($category == 126 || $category == 131|| $category == 132)
+			{
+				$number = $this->cp($ps,$rows,$key);
+			}
+			else if($category == 127)
+			{
+				$type = $this->input->post('type',true);
+				$headroad = explode(',',rtrim($this->input->post('headroad',true),','));
+				$density = explode(',',rtrim($this->input->post('density',true),','));
+				$lacesize = explode(',',rtrim($this->input->post('lacesize',true),','));
+				if($type == 195 || $type == 197 || $type == 199)
+				{
+					array_push($rows,array($type),$headroad,$density,$lacesize);
+					array_push($key,'type','headroad','density','lacesize');
+					$number = $this->cp($ps,$rows,$key);
+				}
+			    else
+				{
+					array_push($rows,array($type),$headroad,$density);
+					array_push($key,'type','headroad','density');
+					$number = $this->cp($ps,$rows,$key);
+				}
+				
+			}
+			
+			else if($category == 128)
+			{
+				$lacetype = $this->input->post('lacetype',true);
+				$haircap = explode(',',rtrim($this->input->post('haircap',true),','));
+				$density = explode(',',rtrim($this->input->post('density',true),','));
+			    array_push($rows,array($lacetype),$haircap,$density);
+				array_push($key,'lacetype','haircap','density');
+				$number = $this->cp($ps,$rows,$key);
+				
+			}
+			else if($category == 129)
+			{
+				$wide = explode(',',rtrim($this->input->post('wide',true),','));
+			    array_push($rows,$wide);
+				array_push($key,'wide');
+				$number = $this->cp($ps,$rows,$key);
+				
+			}
+			else if($category == 130)
+			{
+				$weight = explode(',',rtrim($this->input->post('weight',true),','));
+			    array_push($rows,$weight);
+				array_push($key,'weight');
+				$number = $this->cp($ps,$rows,$key);
+				
+			}
+			else if($category == 133)
+			{
+				$package = explode(',',rtrim($this->input->post('package',true),','));
+				$unitweight = explode(',',rtrim($this->input->post('unitweight',true),','));
+			    array_push($rows,$package,$unitweight);
+				array_push($key,'package','unitweight');
+				$number = $this->cp($ps,$rows,$key);
+				
+			}
+			else if($category == 134)
+			{
+				$pieceweight = explode(',',rtrim($this->input->post('pieceweight',true),','));
+			    array_push($rows,$pieceweight);
+				array_push($key,'pieceweight');
+				$number = $this->cp($ps,$rows,$key);
+				
+			}
+			if(isset($number))
+			{
+			    echo json_encode(array('msg'=>'提交成功,重复数据:'.$number.' 条。','success'=>true));exit;
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'提交失败,请重试','success'=>true));exit;
+			}
+		}
+		$this->_Template('product_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$list = array();$num = "";$title = "";
+			$id = $this->input->post('id',true);
+			$data = $this->product->read($id);
+			foreach($data as $k=>$v)
+			{
+				$post[$k] = 0;
+            }
+			$post['id'] = $id;
+			$post['sku'] = $this->input->post('sku',true);
+			$post['productweight'] = $this->input->post('productweight',true);
+			$category = $this->input->post('category',true);
+			$list['category'] = $category;
+			$list['hairtype'] = $this->input->post('hairtype',true);
+			$list['grade'] = $this->input->post('grade',true);
+			$list['size'] = $this->input->post('size',true);
+			$list['color'] = $this->input->post('color',true);
+			$list['lowe'] = $this->input->post('lowe',true);
+			if($category == 127)
+			{
+				$list['type'] = $this->input->post('type',true);
+				$list['headroad'] = $this->input->post('headroad',true);
+				$list['density'] = $this->input->post('density',true);
+				if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
+				{
+					$list['lacesize'] = $this->input->post('lacesize',true);
+				}
+			}
+			else if($category == 128)
+			{
+				$list['lacetype'] = $this->input->post('lacetype',true);
+				$list['haircap'] = $this->input->post('haircap',true);
+				$list['density'] = $this->input->post('density',true);
+			}
+			else if($category == 129)
+			{
+				$list['wide'] = $this->input->post('wide',true);
+			}
+			else if($category == 130)
+			{
+				$list['weight'] = $this->input->post('weight',true);
+			}
+			else if($category == 133)
+			{
+				$list['package'] = $this->input->post('package',true);
+				$list['unitweight'] = $this->input->post('unitweight',true);
+			}
+			else if($category == 134)
+			{
+				$list['pieceweight'] = $this->input->post('pieceweight',true);
+			}
+			foreach($list as $k=>$v)
+			{
+				if($v != 0)
+				{
+					$num .=$v;
+					$post[$k] = $v;
+					$typeclass = $this->typeclass->read($v);
+			        $title = $title.$typeclass['title']." ";
+				}
+            }
+			$post['title'] = rtrim($title,' ');
+			$post['number'] = $num;
+			$rows = $this->product->get_number($num);
+			if(!$rows || $rows['id'] == $id)
+        	{
+				$this->product->save($post,$id);
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,有重复数据','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$product = $this->product->read($arg_array);
+		$this->data['product'] = $product;
+		$this->_Template('product_edit',$this->data);
+	}
+	//删除
+    public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->product->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	//笛卡儿积
+	function cp($ps,$sets,$list)
+	{
+        $result = array();$j=0;
+        for($i=0,$count=count($sets); $i<$count-1; $i++)
+	    {
+            if($i==0)
+			{
+                $result = $sets[$i];
+            }
+        $tmp = array();
+        foreach($result as $res)
+		{
+            foreach($sets[$i+1] as $set)
+			{
+                $tmp[] = $res.','.$set;
+            }
+        }
+        $result = $tmp;
+
+        }
+        $this->db->trans_begin();
+        foreach ($result as $v) 
+	    {
+		    $post = array();$title = "";$num="";
+		    $data = explode(',',$v);
+		    for($i=0;$i<count($list); $i++)
+		    {
+			    $post[$list[$i]] = $data[$i];
+			    $typeclass = $this->typeclass->read($data[$i]);
+			    $title = $title.$typeclass['title']." ";
+				if($data[$i] != 0)
+				{
+				    $num .=$data[$i];//所有数据ID拼接
+				}
+		    }
+			 foreach ($ps as $kp=>$vp) 
+	        {
+				$post[$kp] = $vp;
+			}
+			$post['number'] = $num;
+			$info_list = $this->product->get_number($num);//查询product是否存在此拼接的数据ID
+			if($info_list)
+			{
+				$j++;
+			}
+			else
+			{
+				$skunum = $this->product->find_count();
+				$post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
+		        $post['title'] = rtrim($title,' ');
+		        $this->product->insert($post);
+			}
+					
+	    }
+	    if ($this->db->trans_status() === FALSE)
+        {
+            $this->db->trans_commit();
+			return NULL;
+        }
+        else
+        {
+            $this->db->trans_commit();
+			return $j;
+        }
+    }
+	
+		//删除
+    public function _list()
+	{
+		$info_list = $this->product->find_all('1=1','id,category,grade,size,color,lowe,type,	lacetype,headroad,haircap,density,lacesize,wide,weight,package,unitweight,pieceweight');
+		$this->db->trans_begin();
+		foreach ($info_list as $key=>$value) 
+		{
+			$num = '';
+			foreach ($value as $k=>$v) 
+		    {
+				if($v != 0 && $k != 'id')
+				{
+				    $num .= $v;
+				}
+			}
+			$this->product->save(array('number'=>$num),$value['id']);
+		}
+		if ($this->db->trans_status() === FALSE)
+        {
+            $this->db->trans_commit();
+			echo 1;
+        }
+        else
+        {
+            $this->db->trans_commit();
+			echo 2;
+        }
+    }
+}

+ 274 - 0
core/CoreApp/controllers/Productdescribe.php

@@ -0,0 +1,274 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Productdescribe extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_productdescribe','productdescribe');
+		$this->load->_model('Model_product','product');
+		$this->load->_model('Model_productprice','productprice');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_excel','excel');
+		$this->load->_model('Model_whlabel','whlabel');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add($arg_array);
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'money')
+        {
+             $this->_money($arg_array);
+        }
+		else
+		{
+			 $this->_index($arg_array);
+		}
+    }
+
+	//管理
+	public function _index($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$category = $this->input->post('category',true);
+			$grade = $this->input->post('grade',true);
+			$size = $this->input->post('size',true);
+			$lowe = $this->input->post('lowe',true);
+			$color = $this->input->post('color',true);
+			$sku = $this->input->post('sku',true);
+			$arg_array = $this->input->post('arg_array',true);
+			$where = "1=1 ";
+			if($category)
+            {
+                $where  .= " and features like '%-$category-%'";
+            }
+			if($grade)
+            {
+                $where  .= " and features like '%-$grade-%'";
+            }
+			if($size)
+            {
+                $where  .= " and features like '%-$size-%'";
+            }
+			if($lowe)
+            {
+                $where  .= " and features like '%-$lowe-%'";
+            }
+			if($color)
+            {
+                $where  .= " and features like '%-$color-%'";
+            }
+			if($sku)
+            {
+                $where  .= " and sku like '%$sku%'";
+            }
+			if($arg_array || $arg_array != 0)
+            {
+                $where  .= " and purchase = '$arg_array'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->productdescribe->find_all($where,'id,sku,title,money',$order_str,$start,$perpage);
+		    $total = $this->productdescribe->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		if(isset($arg_array[0]))
+		{
+		    $arg_array = $arg_array[0];
+		}
+		else
+		{
+			$arg_array = "";
+		}
+		$this->data['arg_array'] = $arg_array;
+		$this->_Template('productdescribe',$this->data);
+	}
+	//添加
+	public function _add($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['category']))
+		{
+			if($this->productdescribe->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('productdescribe_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			if($this->productdescribe->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$productdescribe = $this->productdescribe->read($arg_array);
+		$this->data['productdescribe'] = $productdescribe;
+		$this->_Template('productdescribe_edit',$this->data);
+	}
+	//删除
+    public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->productdescribe->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	//数量调整模板导入
+	public function _money($arg_array)
+	{
+		$dir = '/data/excel/'.date('Ymd',time()).'/';
+		$config['upload_path'] = '.'.$dir ;
+		$config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
+        $config['allowed_types'] = 'xls|xlsx|csv';
+        $config['max_size'] = 10240;
+		$this->load->library('upload', $config);
+		$this->upload->initialize($config);
+        if ($this->upload->do_upload('userfile'))
+        {
+			$full_path = $dir.$this->upload->data('file_name');
+			$fileName = '.' . $full_path;
+            if (!file_exists($fileName)) 
+			{
+				echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
+            }
+			else
+			{
+				libxml_use_internal_errors(true);
+				require_once "./data/excel/PHPExcel/IOFactory.php";
+				$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
+				$phpExcel->setActiveSheetIndex(0);// 设置为默认表
+				$sheetCount = $phpExcel->getSheetCount();// 获取表格数量
+				$row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
+				$column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
+				++$column;//如果列数大于26行
+				$list = array();
+				for ($i = 2; $i <= $row; $i++) // 行数循环
+				{
+					$data = array();
+                    for ($c = 'A'; $c != $column; $c++)  // 列数循环
+	                {
+						$data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
+                    }
+					$list[] = $data;
+                }
+			}
+			$i = 0;$j = 0;$ed = array();
+		    foreach ($list as $key=>$value)
+		    {
+				$time = time();
+				$sku =  $value['0'];
+				if($sku == "" || $value['3'] == "" || !isset($arg_array[0]))
+				{
+					continue;
+				}
+				$d = $this->whlabel->get_sku($sku);
+				$p = $this->productdescribe->get_sku($sku);
+				if(!$d)//如果没有这个SKU
+				{
+					$ed[] = array($sku.'-库存中不存在此SKU');
+					$j++;
+					continue;
+				}
+				if(!is_numeric($value['3']))
+				{
+					$ed[] = array($sku.'-'.$value['3'].'-金额错误!');
+					$j++;
+					continue;
+				}
+				if(isset($p['money']) && $p['money'] != $value['3'])
+				{
+					$this->productdescribe->save(array('money'=>$value['3']),$p['id']);
+				}
+				else if(!isset($p['money']))
+				{
+				    $this->productdescribe->insert(array('sku'=>$sku,'number'=>$d['number'],'features'=>$d['features'],'title'=>$d['title'],'time'=>$time,'money'=>$value['3'],'purchase'=>$arg_array[0]));
+				}
+			}
+			
+			if ($this->db->trans_status() === FALSE)
+        	{
+				$this->db->trans_commit();
+				echo json_encode(array('msg'=>'导入失败,请重试,','error'=>$error,'success'=>true));exit;
+        	}
+        	else
+        	{
+            	$this->db->trans_commit();
+				if($j > 0)
+			    {
+					$tt = date('Ymd',time());
+					$title = '库存导入错误信息-'.$tt;
+        			$titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
+					$tail = "\n";
+        			$filename = $title.".xls";
+        			$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
+					$dir = '/data/excel/'.$time.'/';
+					$file_name = 'error_'.$time.rand(1000,9999);
+					if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
+					$myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
+					fwrite($myfile,$ecl);
+					fclose($myfile);
+					$error = $dir.$file_name.'.xls';
+					echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
+				}
+				else
+				{
+					echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
+				}
+			}
+		}
+	}
+}

+ 168 - 0
core/CoreApp/controllers/Productdescription.php

@@ -0,0 +1,168 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Productdescription extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_productdescription','productdescription');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_typeclass','typeclass');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$country = $this->input->post('country',true);
+			$express = $this->input->post('express',true);
+			$where = "1=1 ";
+			if($country)
+            {
+                $where  .= " and country = '$country'";
+            }
+			if($express)
+            {
+                $where  .= " and express = '$express'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->productdescription->find_all($where,'id,express,country,description',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$country = $this->country->read($value['country']);
+				$info_list[$key]['country'] = $country['name'];
+				$express = $this->express->read($value['express']);
+				$info_list[$key]['express'] = $express['title'];
+				$typeclass = $this->typeclass->read($value['description']);
+				$info_list[$key]['description'] = $typeclass['title'];
+            }
+		    $total = $this->productdescription->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$country = $this->country->find_all();
+		$this->data['country'] = $country;
+		$express = $this->express->find_all();
+		$this->data['express'] = $express;
+		$this->_Template('productdescription',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['express']))
+		{
+			$post['express'] = $this->input->post('express',true);
+			$post['description'] = $this->input->post('description',true);
+			$countryck = $this->input->post('country',true);
+			if($countryck)
+			{
+				$countryck = explode(',',rtrim($countryck,','));
+				foreach ($countryck as $key=>$value) 
+		        {
+					$post['country'] = $value;
+				    $this->productdescription->insert($post);
+                }
+				
+				echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+			}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$country = $this->country->find_all();
+		$this->data['country'] = $country;
+		$express = $this->express->find_all();
+		$this->data['express'] = $express;
+		$typeclass = $this->typeclass->find_all('classid = 3');
+		$this->data['description'] = $typeclass;
+		$this->_Template('productdescription_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['express'] = $this->input->post('express',true);
+			$post['description'] = $this->input->post('description',true);
+			$post['country'] = $this->input->post('country',true);
+			if($this->productdescription->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$productdescription = $this->productdescription->read($arg_array);
+		$this->data['productdescription'] = $productdescription;
+		$country = $this->country->find_all();
+		$this->data['country'] = $country;
+		$express = $this->express->find_all();
+		$this->data['express'] = $express;
+		$typeclass = $this->typeclass->find_all('classid = 3');
+		$this->data['description'] = $typeclass;
+		$this->_Template('productdescription_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->productdescription->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

+ 201 - 0
core/CoreApp/controllers/Productprice.php

@@ -0,0 +1,201 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class productprice extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_productprice','productprice');
+		$this->load->_model('Model_typeclass','typeclass');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')//获取数据
+        {
+             $this->_rows();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$name = $this->input->post('name',true);
+			$supplier = $this->input->post('supplier',true);
+			$where = "1=1 ";
+			if($name)
+            {
+                $where  .= " and name = '$name'";
+            }
+			if($supplier)
+            {
+                $where  .= " and supplier = '$supplier'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->productprice->find_all($where,'id,name,supplier,purchase,cost,salesprice,time,class',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$purchase = $this->typeclass->read($value['purchase']);
+				$info_list[$key]['purchase'] = $purchase['title'];
+				
+				$cost = $this->typeclass->read($value['cost']);
+				$info_list[$key]['cost'] = $cost['title'];
+				
+				$salesprice = $this->typeclass->read($value['salesprice']);
+				$info_list[$key]['salesprice'] = $salesprice['title'];
+				$info_list[$key]['name'] = "<a href='/productdescribe/index/".$value['class']."'>".$value['name']."</a>";
+			    $info_list[$key]['time'] = date('Y-m-d',$value['time']);
+				$info_list[$key]['class'] = '<span onclick=url("/productdescribe/index/'.$value['class'].'")>价格表明细配置</span><span onclick=copy("productprice","'.$value['class'].'")>复制价格表</span>';
+		    }
+		    $total = $this->productprice->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('productprice',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['name']))
+		{
+			$post['name'] = $this->input->post('name',true);
+			$post['supplier'] = $this->input->post('supplier',true);
+			$post['user'] = $this->input->post('user',true);
+			$post['phone'] = $this->input->post('phone',true);
+			$post['purchase'] = $this->input->post('purchase',true);
+			$post['cost'] = $this->input->post('cost',true);
+			$post['salesprice'] = $this->input->post('salesprice',true);
+			$time = $this->input->post('time',true);
+			$post['time'] = strtotime($time);
+			$post['operation'] = time().rand(1000,9999);
+			if($this->productprice->insert($post))
+        	{
+				$productprice = $this->productprice->get_operation($post['operation']);
+				if($this->productprice->save(array('class'=>$productprice['id']),$productprice['id']))
+				{
+					echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+				}
+         		else
+				{
+					$this->productprice->remove($productprice['id']);
+					echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+				}
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('productprice_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['name'] = $this->input->post('name',true);
+			$post['supplier'] = $this->input->post('supplier',true);
+			$post['user'] = $this->input->post('user',true);
+			$post['phone'] = $this->input->post('phone',true);
+			$post['purchase'] = $this->input->post('purchase',true);
+			$post['cost'] = $this->input->post('cost',true);
+			$post['salesprice'] = $this->input->post('salesprice',true);
+			$time = $this->input->post('time',true);
+			$post['time'] = strtotime($time);
+			if($this->productprice->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$productprice = $this->productprice->read($arg_array);
+		$this->data['productprice'] = $productprice;
+		$this->_Template('productprice_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v)
+		    {
+                $this->productprice->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	//拷贝价格
+	public function _rows()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['copyid']))
+		{
+			$copyid = $this->input->post('copyid',true);
+			$productprice = $this->productprice->read($copyid);
+			$post['name'] = $productprice['name']."副本";
+			$post['supplier'] = $productprice['supplier'];
+			$post['user'] = $productprice['user'];
+			$post['phone'] = $productprice['phone'];
+			$post['purchase'] = $productprice['purchase'];
+			$post['cost'] = $productprice['cost'];
+			$post['salesprice'] = $productprice['salesprice'];
+			$post['class'] = $productprice['class'];
+			$post['time'] = $productprice['time'];
+			if($this->productprice->insert($post))
+        	{
+				echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+	}
+}

+ 174 - 0
core/CoreApp/controllers/Purchase.php

@@ -0,0 +1,174 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Purchase extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_purchase','purchase');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_productprice','productprice');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')//修改
+        {
+             $this->_rows();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$title = $this->input->post('title',true);
+			$where = "1=1 ";
+			if($title)
+            {
+                $where  .= " and title like '%$title%'";
+            }
+            //数据排序
+            $order_str = "px desc,id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->purchase->find_all($where,'id,title,bm,yyid,px',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				//$country = $this->country->read($value['country']);
+				//$info_list[$key]['country'] = $country['name'];
+		    }
+		    $total = $this->purchase->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('purchase',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['title']))
+		{
+			$bm = $this->input->post('bm',true);
+		$n = $this->purchase->find_all("bm = '$bm'");
+		if(count($n) > 0)
+		{
+			echo json_encode(array('msg'=>'供应商编码必须唯一','success'=>false));exit;
+		}
+			if($this->purchase->insert($post))
+        	{
+				echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		 $country = $this->country->find_all();
+		 $this->data['country'] = $country;
+		$this->_Template('purchase_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$bm = $this->input->post('bm',true);
+			$n = $this->purchase->find_all("bm = '$bm'");
+			if(count($n) > 0 && $n[0]['id'] != $post['id'])
+			{
+				echo json_encode(array('msg'=>'供应商编码必须唯一','success'=>false));exit;
+			}
+			$id = $this->input->post('id',true);
+			if($this->purchase->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$purchase = $this->purchase->read($arg_array);
+		$country = $this->country->find_all();
+		$this->data['country'] = $country;
+		$this->data['purchase'] = $purchase;
+		$this->_Template('purchase_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v)
+		    {
+                $this->purchase->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	//获取数据
+	public function _rows()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['rows']))  
+		{
+			$rows = $this->input->post('rows',true);
+			$an = array();
+			$data = $this->productprice->find_all();
+			foreach ($data as $k=>$v) 
+		    {
+				$an[] = array('id'=>$v['id'],'title'=>$v['supplier']);
+			}
+			$price = array();
+			if($rows != "null")
+			{
+			    $a = $this->purchase->read($rows);//找出次ID的权限内容
+				if($a['price'])
+				{
+			        $price = explode('|',trim($a['price'],'|'));//数组化权限内容
+				}
+			}
+			echo json_encode(array('msg'=>($an),'power'=>($price),'success'=>true));
+		}
+    }
+}

+ 402 - 0
core/CoreApp/controllers/Purchasedetailed.php

@@ -0,0 +1,402 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Purchasedetailed extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_purchasedetailed','purchasedetailed');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_pricedeploy','pricedeploy');
+		$this->load->_model('Model_asd','asd');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add($arg_array);
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')//修改
+        {
+             $this->_rows();
+        }
+		else
+		{
+			 $this->_index($arg_array);
+		}
+    }
+
+	//管理
+	public function _index($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$category = $this->input->post('category',true);
+			$size = $this->input->post('size',true);
+			$grade = $this->input->post('grade',true);
+			$density = $this->input->post('density',true);
+			$lacetype = $this->input->post('lacetype',true);
+			$arg_array = $this->input->post('arg_array',true);
+			$where = "1=1 ";
+			if($category)
+            {
+                $where  .= " and category = '$category	'";
+            }
+			if($size)
+            {
+                $where  .= " and size = '$size'";
+            }
+			if($grade)
+            {
+                $where  .= " and grade = '$grade'";
+            }
+			if($density)
+            {
+                $where  .= " and density = '$density'";
+            }
+			if($lacetype)
+            {
+                $where  .= " and lacetype = '$lacetype'";
+            }
+			if($arg_array || $arg_array != 0)
+            {
+                $where  .= " and classid = '$arg_array'";
+            }
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->purchasedetailed->find_all($where,'id,category,size,grade,density,lacetype,lowe,color,haircap,money,classid',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$category = $this->typeclass->read($value['category']);
+				$info_list[$key]['category'] = $category['title'];
+				$size = $this->typeclass->read($value['size']);
+				$info_list[$key]['size'] = $size['title'];
+				$grade = $this->typeclass->read($value['grade']);
+				$info_list[$key]['grade'] = $grade['title'];
+				if($value['density'] == 0)
+				{
+					$info_list[$key]['density'] = "未选择";
+				}
+				else
+				{
+				    $density = $this->typeclass->read($value['density']);
+				    $info_list[$key]['density'] = $density['title'];
+				}
+				if($value['lacetype'] == 0)
+				{
+					$info_list[$key]['lacetype'] = "未选择";
+				}
+				else
+				{
+				    $lacetype = $this->typeclass->read($value['lacetype']);
+				    $info_list[$key]['lacetype'] = $lacetype['title'];
+				}
+				
+				$lowe = explode('|',trim($value['lowe'],'|'));
+				$lowex = "";
+				foreach ($lowe as $k=>$v) 
+		        {
+					$lower = $this->typeclass->read($v);
+					$lowex = $lowex.$lower['title'].",";
+				}
+				$info_list[$key]['lowe'] = $lowex;
+				$color = explode('|',trim($value['color'],'|'));
+				$colorx = "";
+				foreach ($color as $k=>$v) 
+		        {
+					$colorr = $this->typeclass->read($v);
+					$colorx = $colorx.$colorr['title'].",";
+				}
+				$info_list[$key]['color'] = $colorx;
+				if($value['haircap'])
+				{
+				    $haircap = explode('|',trim($value['haircap'],'|'));
+				    $haircapx = "";
+				    foreach ($haircap as $k=>$v) 
+		            {
+				    	$haircapr = $this->typeclass->read($v);
+				    	$haircapx = $haircapx.$haircapr['title'].",";
+				    }
+				    $info_list[$key]['haircap'] = $haircapx;
+			    }
+				$money = $this->pricedeploy->read($value['classid']);
+				if($money['money'] == 1)
+				{
+					$money = "CNY";
+				}
+				else
+				{
+					$money = "USD";
+				}
+				$info_list[$key]['money'] = $value['money']."(".$money.")";
+				
+            }
+		    $total = $this->purchasedetailed->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$category=array();$size=array();$grade=array();$density=array();$lacetype=array();$lowe=array();$color=array();$haircap=array();
+		$typeclass = $this->typeclass->find_all();
+		foreach ($typeclass as $key=>$value) 
+		{
+			if($value['classid'] == 16)
+			{
+				$category[] = $value;
+			}
+			if($value['classid'] == 14)
+			{
+				$size[] = $value;
+			}
+			if($value['classid'] == 13)
+			{
+				$grade[] = $value;
+			}
+			if($value['classid'] == 10)
+			{
+				$density[] = $value;
+			}
+			if($value['classid'] == 19)
+			{
+				$lacetype[] = $value;
+			}
+			if($value['classid'] == 15)
+			{
+				$lowe[] = $value;
+			}
+			if($value['classid'] == 8)
+			{
+				$color[] = $value;
+			}
+			if($value['classid'] == 6)
+			{
+				$haircap[] = $value;
+			}
+		}
+		$this->data['category'] = $category;
+		$this->data['size'] = $size;
+		$this->data['grade'] = $grade;
+		$this->data['density'] = $density;
+		$this->data['lacetype'] = $lacetype;
+		$this->data['lowe'] = $lowe;
+		$this->data['color'] = $color;
+		$this->data['haircap'] = $haircap;
+		if(isset($arg_array[0]))
+		{
+		    $arg_array = $arg_array[0];
+		}
+		else
+		{
+			$arg_array = "";
+		}
+		$this->data['arg_array'] = $arg_array;
+		$this->_Template('purchasedetailed',$this->data);
+	}
+	//添加
+	public function _add($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['category']))
+		{
+			$post['classid'] = $this->input->post('class',true);
+			$post['category'] = $this->input->post('category',true);
+			$post['size'] = $this->input->post('size',true);
+			$post['grade'] = $this->input->post('grade',true);
+			$post['density'] = $this->input->post('density',true);
+			$post['lacetype'] = $this->input->post('lacetype',true);
+			$post['money'] = $this->input->post('money',true);
+			$lowedata = $this->input->post('lowe',true);
+			$colordata = $this->input->post('color',true);
+			$haircapdata = $this->input->post('haircap',true);
+			$post['lowe'] = "|".str_replace(',','|',$lowedata);
+			$post['color'] = "|".str_replace(',','|',$colordata);
+			$post['haircap'] = "|".str_replace(',','|',$haircapdata);
+			if($this->purchasedetailed->insert($post))
+			{
+				echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+			}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$category=array();$size=array();$grade=array();$density=array();$lacetype=array();$lowe=array();$color=array();$haircap=array();
+		$typeclass = $this->typeclass->find_all();
+		foreach ($typeclass as $key=>$value) 
+		{
+			if($value['classid'] == 16)
+			{
+				$category[] = $value;
+			}
+			if($value['classid'] == 14)
+			{
+				$size[] = $value;
+			}
+			if($value['classid'] == 13)
+			{
+				$grade[] = $value;
+			}
+			if($value['classid'] == 10)
+			{
+				$density[] = $value;
+			}
+			if($value['classid'] == 19)
+			{
+				$lacetype[] = $value;
+			}
+			if($value['classid'] == 15)
+			{
+				$lowe[] = $value;
+			}
+			if($value['classid'] == 8)
+			{
+				$color[] = $value;
+			}
+			if($value['classid'] == 6)
+			{
+				$haircap[] = $value;
+			}
+		}
+		$this->data['category'] = $category;
+		$this->data['size'] = $size;
+		$this->data['grade'] = $grade;
+		$this->data['density'] = $density;
+		$this->data['lacetype'] = $lacetype;
+		$this->data['lowe'] = $lowe;
+		$this->data['color'] = $color;
+		$this->data['haircap'] = $haircap;
+		$this->data['class'] = $arg_array[0];
+		$this->_Template('purchasedetailed_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['category'] = $this->input->post('category',true);
+			$post['size'] = $this->input->post('size',true);
+			$post['grade'] = $this->input->post('grade',true);
+			$post['density'] = $this->input->post('density',true);
+			$post['lacetype'] = $this->input->post('lacetype',true);
+			$post['money'] = $this->input->post('money',true);
+			$lowedata = $this->input->post('lowe',true);
+			$colordata = $this->input->post('color',true);
+			$haircap = $this->input->post('haircap',true);
+			$post['lowe'] = "|".str_replace(',','|',$lowedata);
+			$post['color'] = "|".str_replace(',','|',$colordata);
+			$post['haircap'] = "|".str_replace(',','|',$haircap);
+			if($this->purchasedetailed->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$purchasedetailed = $this->purchasedetailed->read($arg_array);
+		$this->data['purchasedetailed'] = $purchasedetailed;
+		$this->data['xlowe'] = $purchasedetailed['lowe'];
+		$this->data['xcolor'] = $purchasedetailed['color'];
+		$this->data['xhaircap'] = $purchasedetailed['haircap'];
+		$category=array();$size=array();$grade=array();$density=array();$lacetype=array();$lowe=array();$color=array();$haircap=array();
+		$typeclass = $this->typeclass->find_all();
+		foreach ($typeclass as $key=>$value) 
+		{
+			if($value['classid'] == 16)
+			{
+				$category[] = $value;
+			}
+			if($value['classid'] == 14)
+			{
+				$size[] = $value;
+			}
+			if($value['classid'] == 13)
+			{
+				$grade[] = $value;
+			}
+			if($value['classid'] == 10)
+			{
+				$density[] = $value;
+			}
+			if($value['classid'] == 19)
+			{
+				$lacetype[] = $value;
+			}
+			if($value['classid'] == 15)
+			{
+				$lowe[] = $value;
+			}
+			if($value['classid'] == 8)
+			{
+				$color[] = $value;
+			}
+			if($value['classid'] == 6)
+			{
+				$haircap[] = $value;
+			}
+		}
+		$this->data['category'] = $category;
+		$this->data['size'] = $size;
+		$this->data['grade'] = $grade;
+		$this->data['density'] = $density;
+		$this->data['lacetype'] = $lacetype;
+		$this->data['lowe'] = $lowe;
+		$this->data['color'] = $color;
+		$this->data['haircap'] = $haircap;
+		$this->_Template('purchasedetailed_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->purchasedetailed->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	//rows
+	public function _rows()
+	{
+		$info_list = $this->purchasedetailed->find_all();
+		foreach ($info_list as $key=>$value) 
+		{
+			
+		}
+    }
+}

+ 501 - 0
core/CoreApp/controllers/Purchaseorder.php

@@ -0,0 +1,501 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Purchaseorder extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_purchaseorder','purchaseorder');
+		$this->load->_model('Model_purchase','purchase');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_productdescribe','productdescribe');
+		$this->load->_model('Model_customs','customs');
+		$this->load->_model('Model_detailed','detailed');
+		$this->load->_model('Model_productdescription','productdescription');
+		$this->load->_model('Model_logistics','logistics');
+		$this->load->_model('Model_hl','hl');
+		$this->load->_model('Model_excel','excel');
+		$this->load->_model('Model_warehouse','warehouse');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'price')//获取供应商价格表
+        {
+             $this->_price();
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'describe')
+        {
+             $this->_describe();
+        }
+		else if($arg == 'list')
+        {
+             $this->_list();
+        }
+		else if($arg == 'monitor')
+        {
+             $this->_monitor();
+        }
+		else if($arg == 'lssue')
+        {
+             $this->_lssue();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$purchase = $this->input->post('purchase',true);//供应商
+			$orderinfo = $this->input->post('orderinfo',true);//订单号
+			$type = $this->input->post('type',true);//订单状态
+			$ktime = $this->input->post('ktime',true);
+			$jtime = $this->input->post('jtime',true);
+			$ktime = strtotime($ktime);
+			$jtime = strtotime($jtime);
+			$where = "1=1";
+			if($purchase)
+            {
+                $where  .= " and purchase = '$purchase'";
+            }
+			if($ktime && $jtime)
+            {
+                $where  .= " and addtime > '$ktime' and addtime < '$jtime'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($type)
+            {
+                $where  .= " and type = '$type'";
+            }
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->purchaseorder->find_all($where,'id,purchase,orderinfo,type,time,addtime,monitor',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$purchase = $this->purchase->read($value['purchase']);
+				$info_list[$key]['purchase'] = $purchase['title'];
+				if($value['type'] == 1)
+				{
+					$info_list[$key]['type'] = "待发货";
+				}
+				else if($value['type'] == 2)
+				{
+					$info_list[$key]['type'] = "已发货";
+				}
+				else if($value['type'] == 3)
+				{
+					$info_list[$key]['type'] = "已验收";
+				}
+				$info_list[$key]['time'] = date('Y-m-d',$value['time']);
+				$info_list[$key]['addtime'] = date('Y-m-d H:i:s',$value['addtime']);
+				if($value['monitor'] == 0)
+				{
+					$info_list[$key]['monitor'] = "";
+				}
+				else
+				{
+				    $info_list[$key]['monitor'] = date('Y-m-d H:i:s',$value['monitor']);
+				}
+            }
+		    $total = $this->purchaseorder->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->data['purchase'] = $this->purchase->find_all();
+		$this->_Template('purchaseorder',$this->data);
+	}
+	
+	//管理
+	public function _list()
+	{
+		$this->_Template('purchaseorder_list',$this->data);
+	}
+	
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['purchase']))
+		{
+			$post['purchase'] = $this->input->post('purchase',true);
+			$post['price'] = $this->input->post('price',true);
+			$post['warehouse'] = $this->input->post('warehouse',true);
+			$time = $this->input->post('time',true);
+			$post['time'] = strtotime($time);
+			$post['money'] = $this->input->post('money',true);
+			$post['content'] = $this->input->post('content',true);
+			$post['client'] = $this->input->post('client');
+			$post['name'] = $this->input->post('name',true);
+			$post['phone'] = $this->input->post('phone',true);
+			$post['country'] = $this->input->post('country',true);
+			$post['province'] = $this->input->post('province',true);
+			$post['city'] = $this->input->post('city',true);
+			$post['zipcode'] = $this->input->post('zipcode',true);
+			$post['street'] = $this->input->post('street',true);
+			$post['address'] = $this->input->post('address',true);
+			$post['express'] = $this->input->post('express',true);
+			$post['product'] = $this->input->post('fpdata',true);
+			$post['orderinfo'] = date('Ymd',time()).rand(100,999);
+			$post['addtime'] = time();
+			if($this->purchaseorder->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$country = $this->country->find_all('1=1','id,name');//所有国家信息
+		$this->data['country'] = $country;
+		$purchase = $this->purchase->find_all('1=1','id,title');
+		$this->data['purchase'] = $purchase;
+		$this->_Template('purchaseorder_add',$this->data);
+		//$price = explode('|',trim($purchase['price'],'|'));//数组化权限内容
+		//$pricetitle = explode('|',trim($purchase['pricetitle'],'|'));//数组化权限内容
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$post['purchase'] = $this->input->post('purchase',true);
+			$post['price'] = $this->input->post('price',true);
+			$post['warehouse'] = $this->input->post('warehouse',true);
+			$time = $this->input->post('time',true);
+			$post['time'] = strtotime($time);
+			$post['money'] = $this->input->post('money',true);
+			$post['content'] = $this->input->post('content',true);
+			$post['client'] = $this->input->post('client');
+			$post['name'] = $this->input->post('name',true);
+			$post['phone'] = $this->input->post('phone',true);
+			$post['country'] = $this->input->post('country',true);
+			$post['province'] = $this->input->post('province',true);
+			$post['city'] = $this->input->post('city',true);
+			$post['zipcode'] = $this->input->post('zipcode',true);
+			$post['street'] = $this->input->post('street',true);
+			$post['address'] = $this->input->post('address',true);
+			$post['express'] = $this->input->post('express',true);
+			$post['product'] = $this->input->post('fpdata',true);
+			if($this->purchaseorder->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$purchaseorder = $this->purchaseorder->read($arg_array);
+		$country = $this->country->find_all('1=1','id,name');//所有国家信息
+		$this->data['purchaseorder'] = $purchaseorder;
+		//获取供应商价格表开始
+			$data = $this->purchase->read($purchaseorder['purchase']);
+			$priceid = explode('|',rtrim($data['price'],'|'));//数组内容
+			$pricetitle = explode('|',rtrim($data['pricetitle'],'|'));//数组内容
+			$price = array();
+			for($i=0;$i<count($priceid);$i++) 
+		    {
+			    $price[] = array('id'=>$priceid[$i],'title'=>$pricetitle[$i]);
+            }
+		//获取供应商价格表结束
+		$purchase = $this->purchase->find_all('1=1','id,title');
+		$this->data['purchase'] = $purchase;
+		$this->data['price'] = $price;
+		$this->data['country'] = $country;
+		$fpdata = explode('*',rtrim($purchaseorder['product'],'*'));
+		foreach ($fpdata as $k=>$v) 
+		{
+			$fpdata[$k] = explode('|',$v);
+        }
+		$this->data['fpdata'] = $fpdata;
+		$this->_Template('purchaseorder_edit',$this->data);
+	}
+	//查找供应商价格表
+	public function _price()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$data = $this->purchase->read($id);
+			$priceid = explode('|',rtrim($data['price'],'|'));//数组内容
+			$pricetitle = explode('|',rtrim($data['pricetitle'],'|'));//数组内容
+			$price = array();
+			for($i=0;$i<count($priceid);$i++) 
+		    {
+			    $price[] = array('id'=>$priceid[$i],'title'=>$pricetitle[$i]);
+            }
+			echo json_encode(array('msg'=>($price),'success'=>true));exit;
+		}
+	}
+	//查找商品价格
+	public function _describe()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['data']))  
+		{
+            $data = $this->input->post('data');
+			$priceid = $this->input->post('priceid');
+            $data =  explode('-',$data);
+			$number = '';$num = count($data);
+            //循环删除记录
+            for($i=0;$i<$num-1;$i++)
+		    {
+				if($data[$i] != 0)
+				{
+				    $number=$number.$data[$i];
+					if($i == 2)
+				    {
+					    $number=$number.$data[$num-1];
+				    }
+				}
+            }
+			$list = $this->productdescribe->get_price($priceid,$number);
+			if($list)
+			{
+				echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'success'=>true));
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'此信息没有配置价格!','n'=>$data[$num-1],'success'=>false));exit;
+			}
+		}
+    }
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->purchaseorder->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	
+	//管理
+	public function _lssue()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))  
+		{
+			$id = $this->input->post('id',true);
+			if($this->purchaseorder->save(array('type'=>2,'lssue'=>time()),$id))
+        	{
+         		echo json_encode(array('msg'=>'操作成功','id'=>$id,'success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$purchase = $this->input->post('purchase',true);//供应商
+			$orderinfo = $this->input->post('orderinfo',true);//订单号
+			$type = $this->input->post('type',true);//订单状态
+			$ktime = $this->input->post('ktime',true);
+			$jtime = $this->input->post('jtime',true);
+			$ktime = strtotime($ktime);
+			$jtime = strtotime($jtime);
+			$where = "1=1 and type = 1";
+			if($purchase)
+            {
+                $where  .= " and purchase = '$purchase'";
+            }
+			if($ktime && $jtime)
+            {
+                $where  .= " and addtime > '$ktime' and addtime < '$jtime'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($type)
+            {
+                $where  .= " and type = '$type'";
+            }
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->purchaseorder->find_all($where,'id,purchase,orderinfo,type,time,addtime,currency',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$purchase = $this->purchase->read($value['purchase']);
+				$info_list[$key]['purchase'] = $purchase['title'];
+				if($value['type'] == 1)
+				{
+					$info_list[$key]['type'] = "待发货";
+				}
+				else if($value['type'] == 2)
+				{
+					$info_list[$key]['type'] = "已发货";
+				}
+				else if($value['type'] == 3)
+				{
+					$info_list[$key]['type'] = "已验收";
+				}
+				$info_list[$key]['time'] = date('Y-m-d',$value['time']);
+				$info_list[$key]['addtime'] = date('Y-m-d H:i:s',$value['addtime']);
+				$info_list[$key]['currency'] = "<p><b class='purchaseorder' data-id='".$value['id']."'>标记为已发货</b></p>";
+            }
+		    $total = $this->purchaseorder->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->data['purchase'] = $this->purchase->find_all();
+		$this->_Template('purchaseorder_lssue',$this->data);
+	}
+	//管理
+	public function _monitor()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))  
+		{
+			$id = $this->input->post('id',true);
+			if($this->purchaseorder->save(array('type'=>3,'monitor'=>time()),$id))
+        	{
+         		echo json_encode(array('msg'=>'操作成功','id'=>$id,'success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$purchase = $this->input->post('purchase',true);//供应商
+			$orderinfo = $this->input->post('orderinfo',true);//订单号
+			$type = $this->input->post('type',true);//订单状态
+			$ktime = $this->input->post('ktime',true);
+			$jtime = $this->input->post('jtime',true);
+			$ktime = strtotime($ktime);
+			$jtime = strtotime($jtime);
+			$where = "1=1 and type = 2";
+			if($purchase)
+            {
+                $where  .= " and purchase = '$purchase'";
+            }
+			if($ktime && $jtime)
+            {
+                $where  .= " and addtime > '$ktime' and addtime < '$jtime'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($type)
+            {
+                $where  .= " and type = '$type'";
+            }
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->purchaseorder->find_all($where,'id,purchase,orderinfo,type,time,addtime,lssue,currency',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$purchase = $this->purchase->read($value['purchase']);
+				$info_list[$key]['purchase'] = $purchase['title'];
+				if($value['type'] == 1)
+				{
+					$info_list[$key]['type'] = "待发货";
+				}
+				else if($value['type'] == 2)
+				{
+					$info_list[$key]['type'] = "已发货";
+				}
+				else if($value['type'] == 3)
+				{
+					$info_list[$key]['type'] = "已验收";
+				}
+				$info_list[$key]['time'] = date('Y-m-d',$value['time']);
+				$info_list[$key]['addtime'] = date('Y-m-d H:i:s',$value['addtime']);
+				$info_list[$key]['lssue'] = date('Y-m-d H:i:s',$value['lssue']);
+				$info_list[$key]['currency'] = "<p><b class='purchaseorder' data-id='".$value['id']."'>标记为已验收</b></p>";
+            }
+		    $total = $this->purchaseorder->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->data['purchase'] = $this->purchase->find_all();
+		$this->_Template('purchaseorder_monitor',$this->data);
+	}
+}

+ 300 - 0
core/CoreApp/controllers/Qrcode.php

@@ -0,0 +1,300 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Qrcode extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_qrcode','qrcode');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')
+        {
+             $this->_edit();
+        }
+		else if($arg == 'see')
+        {
+             $this->_see($arg_array);
+        }
+		else if($arg == 'automatic')
+        {
+             $this->_automatic();
+        }
+		else if($arg == 'closepz')
+        {
+             $this->_closepz();
+        }
+		else
+		{
+			$this->_index();
+		}
+    }
+	
+	public function _index()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+			$fgshop .= " shop = '0' or";
+		}
+		
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$number = $this->input->post('number',true);
+			$shop = $this->input->post('shop',true);
+			$warehouse = $this->input->post('warehouse',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "(".rtrim($fgshop,'or').")";
+			if($number)
+            {
+                $where  .= " and number like '%$number%'";
+            }
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($warehouse)
+            {
+                $where  .= " and warehouse = '$warehouse'";
+            }
+			if($timetk && $timetj)
+            {
+                $where  .= " and time > '$timetk' and time < '$timetj'";
+            }
+			//数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			$info_list = $this->qrcode->find_all($where,'id,number,shop,warehouse,time',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				$warehouse = $this->warehouse->read($value['warehouse']);
+				$info_list[$key]['warehouse'] = $warehouse['title'];
+			}
+			$total = $this->qrcode->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		//$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		//$this->data['wlshop'] = $wlshop;
+        $this->_Template('qrcode',$this->data);
+	}
+	
+	public function _add()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";$wid="";$wtype="";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			$userwh = explode('|',trim($user['warehouse'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+			foreach ($userwh as $value) 
+		    {
+				$wid .= " id = ".$value." or";
+				$wtype .= " type = ".$value." or";
+			}
+		}
+		
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['number']))
+		{
+			$time =  time();
+			$bctime = date('Ymd',$time);
+			$post['number'] = $this->input->post('number',true);
+			$post['time'] = $time;
+			$qrcode = $this->qrcode->get_number($post['number']);
+			if($qrcode)
+			{
+				echo json_encode(array('msg'=>'此订单编号已存在!','img'=>$qrcode['img'],'success'=>false));exit;
+			}
+			$number = $this->fullorder->get_number($post['number']);
+			if(!$number)
+			{
+				$number = $this->fullordersmt->get_number($post['number']);
+				if(!$number)
+				{
+					echo json_encode(array('msg'=>'订单中未找到此编号!','success'=>false));exit;
+				}
+			}
+			$img = $this->input->post('img',true);
+			$post['img'] = $this->_img($img,$post['number'],$bctime);
+			$post['shop'] = $number['shop'];
+			$post['warehouse'] = $number['type'];
+			if($this->qrcode->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		//$warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
+		//$this->data['warehouse'] = $warehouse;
+		$this->_Template('qrcode_add',$this->data);
+	}
+	
+	public function _automatic()
+	{
+		$this->_Template('qrcode_automatic',$this->data);
+	}
+	
+	public function _edit()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['number']))
+		{
+			$time =  time();
+			$bctime = date('Ymd',$time);
+			$post['number'] = $this->input->post('number',true);
+			$post['warehouse'] = $this->input->post('warehouse',true);
+			$post['time'] = $time;
+			$qrcode = $this->qrcode->get_number($post['number']);
+			if(!$qrcode)
+			{
+				echo json_encode(array('msg'=>'错误,未找到需要修改的订单!','success'=>false));exit;
+			}
+			else
+			{
+			    $number = $this->fullorder->get_number($post['number']);
+			    if(!$number)
+			    {
+				    $number = $this->fullordersmt->get_number($post['number']);
+				    if(!$number)
+				    {
+				        echo json_encode(array('msg'=>'订单中未找到此编号!','success'=>false));exit;
+				    }
+			    }
+			    $img = $this->input->post('img',true);
+			    $post['img'] = $this->_img($img,$post['number'],$bctime);
+			    if($this->qrcode->save(array('img'=>$post['img'],'time'=>time()),$qrcode['id']))
+        	    {
+         		    echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	    }
+       		    else
+        	    {
+           		    echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	    }
+			}
+		}
+	}
+	
+	public function _see($arg_array)
+	{
+		$arg_array = $arg_array[0];
+		$qrcode = $this->qrcode->read($arg_array);
+		$qrcodeimg = explode('|',$qrcode['img']);
+		$img = '';
+		foreach ($qrcodeimg as $v) 
+		{
+			$lx = explode(".",$v);
+			$lx = strtolower(end($lx));
+			$img .= "<img src='".$v."'>";
+		}
+		$shop = $this->shop->read($qrcode['shop']);
+		$qrcode['shop'] = $shop['shortname'];
+		$qrcode['img'] = $img;
+		$this->data['qrcode'] = $qrcode;
+		$this->_Template('qrcode_see',$this->data);
+	}
+	
+	
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->qrcode->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	
+	public function _img($img,$title,$bctime)
+    {
+    	$img_path = './data/outimg/'.$bctime.'/';
+        $file_base64 = $img;
+        $file_base64 = preg_replace('/data:*;base64,/i', '', $file_base64);
+		$file_base64 = str_replace('[removed]','',$file_base64);
+        $file_base64 = base64_decode($file_base64);
+		if(!is_dir($img_path))mkdir($img_path,0777); //上传目录不存在则创建
+        file_put_contents($img_path.$title.'.png',$file_base64);
+		return '/data/outimg/'.$bctime.'/'.$title.'.png';
+    }
+	
+	public function _closepz()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['closepz']))
+		{
+			$ch = curl_init();
+			$url = 'http://'.$_SERVER['SERVER_NAME'].':2121/?type=publish&to=closepz&content=closepz';
+			curl_setopt($ch,CURLOPT_URL,$url);
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        	curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
+        	curl_setopt($ch, CURLOPT_TIMEOUT_MS, 5000);
+        	//设置post数据
+			$res = curl_exec($ch);
+			curl_close($ch);
+			if($res == 'ok')
+			{
+				echo json_encode(array('success'=>true));
+			}
+			else
+			{
+				echo json_encode(array('success'=>false));
+			}
+		}
+	}
+}

+ 515 - 0
core/CoreApp/controllers/Registration.php

@@ -0,0 +1,515 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Registration extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_user','user');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_registration','registration');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullorderam','fullorderam');
+		$this->load->_model('Model_shop','shop');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')//修改
+        {
+             $this->_rows();
+        }
+		else if($arg == 'see')//修改
+        {
+             $this->_see($arg_array);
+        }
+		else if($arg == 'order')//修改
+        {
+             $this->_order();
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		else
+		{
+			$vip = 0;
+			header('Location: /');exit;
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$number = $this->input->post('number',true);
+			$orderinfo = $this->input->post('orderinfo',true);
+			$state = $this->input->post('state',true);
+			$objective = $this->input->post('objective',true);
+			$name = $this->input->post('name',true);
+			$phone = $this->input->post('phone',true);
+			$where = "1=1 and (".rtrim($fgshop,'or').")";
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			if($number)
+            {
+				$where  .= " and number = '$number'";
+            }
+			if($orderinfo)
+            {
+				$where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($state)
+            {
+				$where  .= " and state = '$state'";
+            }
+			if($objective)
+            {
+				$where  .= " and objective = '$objective'";
+            }
+			if($name)
+            {
+				$where  .= " and name like '%$name%'";
+            }
+			if($phone)
+            {
+				$where  .= " and phone like '%$phone%'";
+            }
+            //取得信息列表
+            $info_list = $this->registration->find_all($where,'id,number,state,objective,address,stime,product,name,phone,content,usacontent',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$d = $this->registration->read($value['id']);
+				if($value['state'] == 1)
+				{
+					$info_list[$key]['state'] = '沟通中';
+				}
+				else if($value['state'] == 2)
+				{
+					$info_list[$key]['state'] = '<font style="color:#F00">待客户上门</font>';
+				}
+				else if($value['state'] == 3)
+				{
+					$info_list[$key]['state'] = '已自提';
+				}
+				else if($value['state'] == 4)
+				{
+					$info_list[$key]['state'] = '已退货';
+				}
+				else if($value['state'] == 5)
+				{
+					$info_list[$key]['state'] = '已换货';
+				}
+				if($value['objective'] == 1)
+				{
+					$info_list[$key]['objective'] = '仅自提';
+				}
+				else if($value['objective'] == 2)
+				{
+					$info_list[$key]['objective'] = '仅退货';
+				}
+				else if($value['objective'] == 3)
+				{
+					$info_list[$key]['objective'] = '退换货';
+				}
+				else if($value['objective'] == 4)
+				{
+					$info_list[$key]['objective'] = '安装头套';
+				}
+				if($value['address'] == 1)
+				{
+					$info_list[$key]['address'] = 'BK850';
+				}
+				else if($value['address'] == 2)
+				{
+					$info_list[$key]['address'] = 'Manhattan819';
+				}
+				else if($value['address'] == 3)
+				{
+					$info_list[$key]['address'] = 'Flatbush933';
+				}
+				$info_list[$key]['number'] = "<p>".$value['number']."</p><p>".$d['orderinfo']."</p>";
+			    if($d['red'] == 1)
+			    {
+				    $info_list[$key]['content'] = "<font style='color:#F00'>".$value['content']."</font>";
+			    }
+            }
+		    $total = $this->registration->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('registration',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['state']))
+		{
+			$post['number'] = $this->input->post('number',true);
+			$post['orderinfo'] = $this->input->post('orderinfo',true);
+			$post['objective'] = $this->input->post('objective',true);
+			$post['thproduct'] = $this->input->post('thproduct',true);
+			if($post['objective'] == 1 && $post['product'] == '')
+			{
+				echo json_encode(array('msg'=>'必须填写待取货物!','success'=>false));exit;
+			}
+			if($post['objective'] == 2 && $post['thproduct'] == '')
+			{
+				echo json_encode(array('msg'=>'必须填写退货货物!','success'=>false));exit;
+			}
+			if($post['objective'] == 3 && ($post['thproduct'] == '' || $post['product'] == ''))
+			{
+				echo json_encode(array('msg'=>'必须填写待取货物和退货货物!','success'=>false));exit;
+			}
+			$f = $this->typeclass->find_all("classid = '32' and id != 2297");
+			$t = 0;
+			foreach ($f as $v) 
+		    {
+				$fl = $v['bqsku'];
+				$b = $this->$fl->get_number($post['number']);
+				$d = $this->$fl->get_orderinfo($post['orderinfo']);
+				if($d && $b)
+				{
+					$t += 1;
+				}
+			}
+			if($t < 1)
+			{
+				echo json_encode(array('msg'=>'编号或订单号填写错误','success'=>false));exit;
+			}
+			$red = $this->input->post('red',true);
+			$post['ted'] = rtrim($red,',');
+			if($this->registration->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('registration_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$t = 0;
+			$post['number'] = $this->input->post('number',true);
+			$post['orderinfo'] = $this->input->post('orderinfo',true);
+			$post['objective'] = $this->input->post('objective',true);
+			$post['thproduct'] = $this->input->post('thproduct',true);
+			if($post['objective'] == 1 && $post['product'] == '')
+			{
+				echo json_encode(array('msg'=>'必须填写待取货物!','success'=>false));exit;
+			}
+			if($post['objective'] == 2 && $post['thproduct'] == '')
+			{
+				echo json_encode(array('msg'=>'必须填写退货货物!','success'=>false));exit;
+			}
+			if($post['objective'] == 3 && ($post['thproduct'] == '' || $post['product'] == ''))
+			{
+				echo json_encode(array('msg'=>'必须填写待取货物和退货货物!','success'=>false));exit;
+			}
+			$f = $this->typeclass->find_all("classid = '32' and id != 2297");
+			foreach ($f as $v) 
+		    {
+				$fl = $v['bqsku'];
+				$b = $this->$fl->get_number($post['number']);
+				$d = $this->$fl->get_orderinfo($post['orderinfo']);
+				if($d && $b)
+				{
+					$t += 1;
+				}
+			}
+			if($t < 1)
+			{
+				echo json_encode(array('msg'=>'编号或订单号填写错误','success'=>false));exit;
+			}
+			$red = $this->input->post('red',true);
+			$post['ted'] = rtrim($red,',');
+			if($this->registration->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$registration = $this->registration->read($arg_array);
+		$this->data['registration'] = $registration;
+		$this->_Template('registration_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->registration->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	//数据
+	public function _rows()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+		    $fgshop = "";
+		    $warehouse = explode('|',trim($user['warehouse'],'|'));
+			foreach ($warehouse as $value) 
+		    {
+				$fgshop .= " warehouse = ".$value." or";
+			}
+		}
+		else
+		{
+			$vip = 0;
+			header('Location: /');exit;
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$number = $this->input->post('number',true);
+			$orderinfo = $this->input->post('orderinfo',true);
+			$state = $this->input->post('state',true);
+			$objective = $this->input->post('objective',true);
+			$name = $this->input->post('name',true);
+			$phone = $this->input->post('phone',true);
+			$where = "1=1 and (".rtrim($fgshop,'or').")";
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			if($number)
+            {
+				$where  .= " and number = '$number'";
+            }
+			if($orderinfo)
+            {
+				$where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($state)
+            {
+				$where  .= " and state = '$state'";
+            }
+			if($objective)
+            {
+				$where  .= " and objective = '$objective'";
+            }
+			if($name)
+            {
+				$where  .= " and name like '%$name%'";
+            }
+			if($phone)
+            {
+				$where  .= " and phone like '%$phone%'";
+            }
+            //取得信息列表
+            $info_list = $this->registration->find_all($where,'id,number,state,objective,address,stime,product,name,phone,content,usacontent',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$d = $this->registration->read($value['id']);
+				if($value['state'] == 1)
+				{
+					$info_list[$key]['state'] = '沟通中';
+				}
+				else if($value['state'] == 2)
+				{
+					$info_list[$key]['state'] = '<font style="color:#F00">待客户上门</font>';
+				}
+				else if($value['state'] == 3)
+				{
+					$info_list[$key]['state'] = '已自提';
+				}
+				else if($value['state'] == 4)
+				{
+					$info_list[$key]['state'] = '已退货';
+				}
+				else if($value['state'] == 5)
+				{
+					$info_list[$key]['state'] = '已换货';
+				}
+				if($value['objective'] == 1)
+				{
+					$info_list[$key]['objective'] = '仅自提';
+				}
+				else if($value['objective'] == 2)
+				{
+					$info_list[$key]['objective'] = '仅退货';
+				}
+				else if($value['objective'] == 3)
+				{
+					$info_list[$key]['objective'] = '退换货';
+				}
+				else if($value['objective'] == 4)
+				{
+					$info_list[$key]['objective'] = '安装头套';
+				}
+				if($value['address'] == 1)
+				{
+					$info_list[$key]['address'] = 'BK850';
+				}
+				else if($value['address'] == 2)
+				{
+					$info_list[$key]['address'] = 'Manhattan819';
+				}
+				else if($value['address'] == 3)
+				{
+					$info_list[$key]['address'] = 'Flatbush933';
+				}
+				$info_list[$key]['number'] = "<p>".$value['number']."</p><p>".$d['orderinfo']."</p>";
+			    if($d['red'] == 1)
+			    {
+				    $info_list[$key]['content'] = "<font style='color:#F00'>".$value['content']."</font>";
+			    }
+            }
+		    $total = $this->registration->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('registration_rows',$this->data);
+    }
+	
+	public function _see($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			if($this->registration->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$product = '';
+		$registration = $this->registration->read($arg_array);
+		$lk = explode(',',rtrim($registration['url'],','));
+					for($i=0;$i<count($lk);$i++)
+					{
+						$product .= '<a href="'.$lk[$i].'" target="_blank">'.$lk[$i].'</a>,';
+					}
+					$registration['url'] = rtrim($product,',');
+		$this->data['registration'] = $registration;
+		$this->_Template('registration_see',$this->data);
+	}
+	
+	public function _order()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['number']))
+		{
+			$data = array();
+			$f = $this->typeclass->find_all("classid = '32' and id != 2297");
+			$number = $this->input->post('number',true);
+			foreach ($f as $v) 
+		    {
+				$fl = $v['bqsku'];
+				$d = $this->$fl->get_number($number);
+				if($d)
+				{
+					$data = $d;
+					continue;
+				}
+			}
+			if($data)
+        	{
+				if($data['source'] == 1)
+				{
+					$shop = $this->shop->read($data['shop']);
+					$data['url'] = $shop['url'];
+				}
+				else
+				{
+					$product = '';
+					$lk = explode(',',$data['link']);
+					for($i=0;$i<count($lk);$i++)
+					{
+						$product .= $lk[$i].',';
+					}
+					$data['url'] = $product;
+				}
+         		echo json_encode(array('msg'=>$data,'success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'请检查编号是否正确','success'=>false));exit;
+        	}
+		}
+	}
+}

+ 105 - 0
core/CoreApp/controllers/Reset.php

@@ -0,0 +1,105 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Reset extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_reset','fullreset');
+		$this->load->_model('Model_shop','shop');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'edit')
+        {
+             $this->_edit($arg_array);
+        }
+		else
+		{
+			$this->_index();
+		}
+    }
+	
+	public function _index()
+	{
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $fgshop = "";$sid = "";
+		    $usersp = explode('|',trim($user['shop'],'|'));
+			foreach ($usersp as $value) 
+		    {
+				$fgshop .= " shop = ".$value." or";
+				$sid .= " id = ".$value." or";
+			}
+		}
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$shop = $this->input->post('shop',true);
+			$orderinfo = $this->input->post('orderinfo',true);
+			$number = $this->input->post('number',true);
+			$where = "1=1 ";
+			if($shop)
+            {
+                $where  .= " and shop = '$shop'";
+            }
+			if($orderinfo)
+            {
+                $where  .= " and orderinfo = '$orderinfo'";
+            }
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->fullreset->find_all($where,'id,shop,orderinfo,number,warehouse,state,express,time',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$shop = $this->shop->read($value['shop']);
+				$info_list[$key]['shop'] = $shop['shopname'];
+				$info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
+            }
+		    $total = $this->fullreset->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
+		$this->data['wlshop'] = $wlshop;
+        $this->_Template('reset',$this->data);
+	}
+	public function _edit($arg_array)
+	{
+		$arg_array = $arg_array[0];$fpdata = array();
+		$reset = $this->fullreset->read($arg_array);
+		$shop = $this->shop->read($reset['shop']);
+		$reset['shop'] = $shop['shopname'];
+		$this->data['reset'] = $reset;
+		if(stripos($reset['fpdata'],';') !== false)
+		{
+		    $fpdata = explode(';',rtrim($reset['fpdata'],';'));
+		    foreach ($fpdata as $k=>$v) 
+		    {
+			    $fpdata[$k] = explode('|',$v);
+            }
+		}
+		$this->data['fpdata'] = $fpdata;
+		$this->_Template('reset_edit',$this->data);
+	}
+}

Diff do ficheiro suprimidas por serem muito extensas
+ 592 - 0
core/CoreApp/controllers/Returns.php


+ 214 - 0
core/CoreApp/controllers/Review.php

@@ -0,0 +1,214 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Review extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_api','api');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_fullorder','fullorder');
+		$this->load->_model('Model_fullordertt','fullordertt');
+		$this->load->_model('Model_fullorder_smt','fullorder_smt');
+		$this->load->_model('Model_fullordersmt','fullordersmt');
+		$this->load->_model('Model_country','country');
+		$this->load->_model('Model_hl','hl');
+		$this->load->_model('Model_is','is');
+		$this->load->_model('Model_kdniao','kdniao');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_fullorderexcel','fullorderexcel');
+		$this->load->_model('Model_dhl','dhl');
+		$this->load->_model('Model_customer','customer');
+		$this->load->_model('Model_express','express');
+		$this->load->_model('Model_notice','notice');
+		$this->load->_model('Model_whlabel','whlabel');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'isorder')//添加
+        {
+             $this->_isorder();
+        }
+		else if($arg == 'kcyz')//库存验证
+        {
+             $this->_kcyz();
+        }
+		else
+        {
+             $this->_index($arg_array);
+        }
+    }
+	public function _index($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+			$a = "";$b = 3;
+			$id_arr = $this->input->post('s');
+			$id_arr =  explode(',',rtrim($id_arr,','));
+			$review = $this->input->post('review',true);
+			$sb = 0;
+			$fu = $arg_array[0];
+			foreach ($id_arr as $v)
+		    {
+				$fullorder = $this->$fu->read($v);
+				if(!isset($fullorder))
+				{
+					$sb++;
+					continue;
+				}
+				if($fullorder['print'] < 3)
+			    {
+					$a = "订单未打印,";
+				    $b = 2;
+			    }
+				/**
+			    if(($fullorder['budget'] >  $fullorder['cost'] && $fullorder['review']==1) || $fullorder['source']==1)
+			    {
+			        $review = 6;
+			    }
+				**/
+				if($review == 3)
+				{
+					$review = 3;
+				}
+				else if($fullorder['source'] == 1 && $review == 2)
+				{
+					$review = 2;
+				}
+				else
+				{
+					/**
+					$kcyz = $this->_kcyz($v,$fu);
+					if($kcyz != 1)
+					{
+						echo json_encode(array('msg'=>$kcyz,'success'=>true));exit;
+					}
+					**/
+					$review = 6;
+				}
+				if($fullorder['review'] > 4 && $review == 2)
+			    {
+			        echo json_encode(array('msg'=>'已有提交操作,请刷新再试','success'=>true));exit;
+			    }
+				$this->$fu->save(array('review'=>$review,'reviewtime'=>time(),'librarynot'=>$a,'print'=>$b),$v);
+			}
+			if(count($id_arr) > 1)
+			{
+		        echo json_encode(array('msg'=>'操作完成!'.$sb.'条订单异常','success'=>true));exit;
+			}
+			else
+			{
+				echo json_encode(array('msg'=>'操作完成!鼠标任意点击关闭','success'=>true));exit;
+			}
+		}
+	}
+	function _kcyz($id,$fu)
+	{
+		if(isset($id))  
+		{
+			$data = $this->$fu->read($id);
+			if($data['type'] != 5)//目前只有美店验证仓库
+			{
+				return 1;exit;
+			}
+			$warehouse = $data['type'];
+			$shop = $data['shop'];
+			$whlabel = $data['whlabel'];
+			if(!$whlabel)
+			{
+				return '请先添加产品信息!';exit;
+			}
+			$save = array();$x=0;
+			$pp = explode('|',trim($whlabel,'|'));
+			$asd = array();
+			foreach ($pp as $va)
+			{
+				$ckcg = 0;
+				$num = explode('-',$va);
+				$ftime = time()-30*24*3600;
+				$order = $this->fullorder->find_all("time > '$ftime' and type = '$warehouse' and library = 1 and state = 207 and whlabel like '%|$num[0]-%'","whlabel,shop");
+				$order2 = $this->fullorder_smt->find_all("time > '$ftime' and type = '$warehouse' and library = 1 and state = 207 and whlabel like '%|$num[0]-%'","whlabel,shop");
+				$order3 = $this->fullordersmt->find_all("time > '$ftime' and type = '$warehouse' and library = 1 and state = 207 and whlabel like '%|$num[0]-%'","whlabel,shop");
+				$whlabel = $this->whlabel->find_count("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (shop IS NULL or shop = '')");
+				$shopwhlabel = $this->whlabel->find_count("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and shop like '%,".$shop.",%'");
+				
+				$od = 0;
+				foreach ($order as $v) 
+		        {
+					$or = explode('|',ltrim($v['whlabel'],'|'));
+					for($i=0;$i<count($or);$i++)
+					{
+						$orod = explode('-',$or[$i]);
+						if($orod[0] == $num[0])
+						{
+							$zs = $this->whlabel->find_count("warehouse = '$warehouse' and number = '$orod[0]' and shop like '%,".$v['shop'].",%' and state = 0");
+							if($zs < 1)
+							{
+							    $od += $orod[1];
+							}
+						}
+					}
+				}
+				foreach ($order2 as $v) 
+		        {
+					$or = explode('|',ltrim($v['whlabel'],'|'));
+					for($i=0;$i<count($or);$i++)
+					{
+						$orod = explode('-',$or[$i]);
+						if($orod[0] == $num[0])
+						{
+							$zs = $this->whlabel->find_count("warehouse = '$warehouse' and number = '$orod[0]' and shop like '%,".$v['shop'].",%' and state = 0");
+							if($zs < 1)
+							{
+							    $od += $orod[1];
+							}
+						}
+					}
+				}
+				foreach ($order3 as $v) 
+		        {
+					$or = explode('|',ltrim($v['whlabel'],'|'));
+					for($i=0;$i<count($or);$i++)
+					{
+						$orod = explode('-',$or[$i]);
+						if($orod[0] == $num[0])
+						{
+							$zs = $this->whlabel->find_count("warehouse = '$warehouse' and number = '$orod[0]' and shop like '%,".$v['shop'].",%' and state = 0");
+							if($zs < 1)
+							{
+							    $od += $orod[1];
+							}
+						}
+					}
+				}
+				if(($whlabel+$shopwhlabel < 1) || ($shopwhlabel+$whlabel-$od) < $num[1])
+				{
+					$save[] = $x;
+				}
+				$x++;
+				//$asd[] = $whlabel.'!'.$shopwhlabel.'!!'.$od.'~'.$num[1].'-'.count($order);
+			}
+			if(count($save) > 0)
+            {
+				return "库存匹配错误或库存不够扣减";exit;
+            }
+			else
+			{
+				return 1;exit;
+			}
+		}
+	}
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+	
+}

+ 334 - 0
core/CoreApp/controllers/Shop.php

@@ -0,0 +1,334 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Shop extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->library('session');
+		$this->load->_model('Model_user','user');
+		$this->load->_model('Model_shop','shop');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_warehouse','warehouse');
+		$this->load->_model('Model_productprice','productprice');
+		$this->load->_model('Model_apiyy','apiyy');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')//添加
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')//修改
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')//修改
+        {
+             $this->_del();
+        }
+		else if($arg == 'rows')//修改
+        {
+             $this->_rows();
+        }
+		else if($arg == 'code')//修改
+        {
+             $this->_code($arg_array);
+        }
+		else
+		{
+			 $this->_index();
+		}
+    }
+
+	//管理
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$where = "1=1 ";
+            //数据排序
+            $order_str = "id asc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+            //取得信息列表
+            $info_list = $this->shop->find_all($where,'id,type,shopname,shortname,estimaterate,mustba,yyid,tb',$order_str,$start,$perpage);
+			 //格式化数据
+            foreach ($info_list as $key=>$value) 
+		    {
+				$type = $this->typeclass->read($value['type']);
+				$info_list[$key]['type'] = $type['title'];
+				if($value['mustba'] == 1)
+				{
+					$info_list[$key]['mustba'] = '需要审核';
+				}
+				else
+				{
+					$info_list[$key]['mustba'] = '不审核';
+				}
+				if($value['tb'] == 1)
+				{
+					$info_list[$key]['tb'] = '同步';
+				}
+				else
+				{
+					$info_list[$key]['tb'] = '不同步';
+				}
+            }
+		    $total = $this->shop->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('shop',$this->data);
+	}
+	//添加
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['shopid']))
+		{
+			$post['type'] = $this->input->post('type',true);
+			$post['notice'] = $this->input->post('notice',true);
+			$post['shopid'] = $this->input->post('shopid',true);
+			$post['shopname'] = $this->input->post('shopname',true);
+			$post['shortname'] = $this->input->post('shortname',true);
+			$post['shopuser'] = $this->input->post('shopuser',true);
+			$post['shopphone'] = $this->input->post('shopphone',true);
+			$post['brandname'] = $this->input->post('brandname',true);
+			/**
+			$post['companyname'] = $this->input->post('companyname',true);
+			$post['country'] = $this->input->post('country',true);
+			$post['province'] = $this->input->post('province',true);
+			$post['city'] = $this->input->post('city',true);
+			$post['zip'] = $this->input->post('zip',true);
+			$post['adress'] = $this->input->post('adress',true);
+			$post['defaultpricetype'] = $this->input->post('defaultpricetype',true);
+			$post['updcycle'] = $this->input->post('updcycle',true);
+			$post['taxrate'] = $this->input->post('taxrate',true);
+			$post['uphone'] = $this->input->post('uphone',true);
+			**/
+			$post['estimaterate'] = $this->input->post('estimaterate',true);
+			$post['userexp'] = $this->input->post('userexp',true);
+			$post['mustba'] = $this->input->post('mustba',true);
+			$post['shopcost'] = $this->input->post('shopcost',true);
+			$post['shopcosttext'] = $this->input->post('shopcosttext',true);
+			$post['shopwh'] = $this->input->post('shopwh',true);
+			$post['shopwhtext'] = $this->input->post('shopwhtext',true);
+			$post['edittime'] = time();
+			$post['addtime'] = time();
+			$px = $this->shop->find_all("1=1",'*','px desc');
+			$post['px'] = $px[0]['px']+10;
+			$s = $post;
+			$s['id'] = $post['yyid'];
+			$s['name'] = $post['shortname'];
+			if($post['type'] == '1514')
+			{
+				$z = '跨境';
+			}
+			else if($post['type'] == '269')
+			{
+				$z = '独-';
+			}
+			else if($post['type'] == '1514')
+			{
+				$z = '速-';
+			}
+			$tc = $this->apiyy->get_cjkh($s);
+			if(isset($tc['Data'][0]))
+			{
+				
+			}
+			else
+			{
+				echo json_encode(array('msg'=>$tc['Data'][0]['ErrorMsg'],'success'=>false));exit;
+			}
+			if($this->shop->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('shop_add',$this->data);
+	}
+	//修改
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			$ps = $this->shop->read($id);
+			$post['type'] = $this->input->post('type',true);
+			$post['notice'] = $this->input->post('notice',true);
+			$post['shopid'] = $this->input->post('shopid',true);
+			$post['shopname'] = $this->input->post('shopname',true);
+			$post['shortname'] = $this->input->post('shortname',true);
+			$post['shopuser'] = $this->input->post('shopuser',true);
+			$post['shopphone'] = $this->input->post('shopphone',true);
+			$post['brandname'] = $this->input->post('brandname',true);
+			/**
+			$post['companyname'] = $this->input->post('companyname',true);
+			$post['country'] = $this->input->post('country',true);
+			$post['province'] = $this->input->post('province',true);
+			$post['city'] = $this->input->post('city',true);
+			$post['zip'] = $this->input->post('zip',true);
+			$post['adress'] = $this->input->post('adress',true);
+			$post['defaultpricetype'] = $this->input->post('defaultpricetype',true);
+			$post['updcycle'] = $this->input->post('updcycle',true);
+			$post['taxrate'] = $this->input->post('taxrate',true);
+			$post['uphone'] = $this->input->post('uphone',true);
+			**/
+			$post['estimaterate'] = $this->input->post('estimaterate',true);
+			$post['userexp'] = $this->input->post('userexp',true);
+			$post['mustba'] = $this->input->post('mustba',true);
+			$post['shopcost'] = $this->input->post('shopcost',true);
+			$post['shopcosttext'] = $this->input->post('shopcosttext',true);
+			$post['shopwh'] = $this->input->post('shopwh',true);
+			$post['shopwhtext'] = $this->input->post('shopwhtext',true);
+			$post['edittime'] = time();
+			if($this->shop->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$shop = $this->shop->read($arg_array);
+		$this->data['shop'] = $shop;
+		$this->_Template('shop_edit',$this->data);
+	}
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->shop->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+	//数据
+	public function _rows()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['shopcost']))  
+		{
+			$productprice = $this->input->post('shopcost',true);
+            $data = $this->productprice->find_all('1=1');
+			$list = array();
+			foreach ($data as $key=>$value) 
+		    {
+				$list[] = array('id'=>$value['id'],'title'=>$value['name']);
+            }
+			$num = array();
+			if($productprice != "null")
+			{
+			    $num = $this->shop->read($productprice);//找出内容
+				if($num['shopcost'])
+				{
+			        $num = explode('|',trim($num['shopcost'],'|'));//数组化内容
+				}
+				else
+				{
+					$num = array();
+				}
+			}
+		    echo json_encode(array('msg'=>($list),'num'=>($num),'success'=>true));
+		}
+		if(isset($post['shopwh']))  
+		{
+			$warehouse = $this->input->post('shopwh',true);
+            $data = $this->warehouse->find_all('1=1');
+			$list = array();
+			foreach ($data as $key=>$value) 
+		    {
+				$list[] = array('id'=>$value['id'],'title'=>$value['title']);
+            }
+			$num = array();
+			if($warehouse != "null")
+			{
+			    $num = $this->shop->read($warehouse);//找出内容
+				if($num['shopwh'])
+				{
+			        $num = explode('|',trim($num['shopwh'],'|'));//数组化内容
+				}
+				else
+				{
+					$num = array();
+				}
+			}
+		    echo json_encode(array('msg'=>($list),'num'=>($num),'success'=>true));
+		}
+    }
+	
+	public function _code($arg_array)
+	{
+		$shop = $this->shop->read($arg_array[0]);
+		if($shop['type'] == 1514)
+		{
+			header('Location:https://services.us.tiktokshop.com/open/authorize?service_id='.$shop['codeid']);exit;
+		}
+		else
+		{
+			$setting['appkey'] = '26004389';
+			$setting['secret'] = 'd880d725c67b449c8a601e9b0766955d';
+			$setting['code'] = 'https://oauth.aliexpress.com/authorize';
+			$setting['token'] = 'https://oauth.aliexpress.com/token';
+			if(!$_GET['code'])
+			{
+				header('Location:'.$setting['code'].'?response_type=code&client_id='.$setting['appkey'].'&redirect_uri='.'http://'.$_SERVER['HTTP_HOST'].'/shop/code'.'&state='.$arg_array[0].'&view=web&sp=ae');exit;
+			}
+			$code = $_GET['code'];
+			$url = $setting['token'];
+			$postfields= array('grant_type'=>'authorization_code',
+			'client_id'=>$setting['appkey'],
+			'client_secret'=>$setting['secret'],
+			'code'=>$_GET['code'],
+			'sp'=>'ae',
+			'redirect_uri'=>'http://'.$_SERVER['HTTP_HOST'].'/shop/code');
+			$post_data = '';
+			foreach($postfields as $key=>$value){
+			$post_data .="$key=".urlencode($value)."&";}
+			$ch = curl_init();
+			curl_setopt($ch, CURLOPT_URL, $url);
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+			curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
+			curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
+			//指定post数据
+			curl_setopt($ch, CURLOPT_POST, true);
+			//添加变量
+        	curl_setopt($ch, CURLOPT_POSTFIELDS, substr($post_data,0,-1));
+			$output = curl_exec($ch);
+			$output = json_decode($output,true);
+			print_r($output);
+			$this->shop->save(array('code'=>$output["access_token"],'codetime'=>substr($output["expire_time"],0,10)),$_GET['state']);
+			header('Location:http://'.$_SERVER['HTTP_HOST'].'/user/');exit;
+		}
+	}
+}

+ 151 - 0
core/CoreApp/controllers/Shopsku.php

@@ -0,0 +1,151 @@
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
+class Shopsku extends Start_Controller {
+	public function __construct(){
+		parent::__construct();
+		$this->load->_model('Model_shopsku','shopsku');
+		$this->load->_model('Model_typeclass','typeclass');
+		$this->load->_model('Model_shop','shop');
+	}
+	//定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+		if($arg == 'add')
+        {
+             $this->_add();
+        }
+		else if($arg == 'edit')
+        {
+             $this->_edit($arg_array);
+        }
+		else if($arg == 'del')
+        {
+             $this->_del();
+        }
+		else
+		{
+			$this->_index();
+		}
+    }
+	
+	public function _index()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$title = $this->input->post('title',true);
+			$where = "1=1";
+			if($title)
+            {
+                $where  .= " and title like '%$title%'";
+            }
+			//数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			$typeclass = array();
+			$class = $this->typeclass->find_all();
+			foreach ($class as $v)
+			{
+				$v['spare'] = explode('|',$v['spare']);
+			    $typeclass[$v['id']] = $v['spare'][0];
+			}
+			$s = array();
+			$shop = $this->shop->find_all();
+			foreach ($shop as $v)
+			{
+			    $s[$v['id']] = $v['shopname'];
+			}
+			$info_list = $this->shopsku->find_all($where,'id,shop,sku',$order_str,$start,$perpage);
+			foreach ($info_list as $key=>$value) 
+		    {
+				$info_list[$key]['sku'] = '';
+				$info_list[$key]['shop'] = '';
+				$sku = explode(',',trim($value['sku'],','));
+				foreach ($sku as $v) 
+		        {
+			    	$info_list[$key]['sku'] .= $v.'<br>';
+				}
+				$shop = explode(',',trim($value['shop'],','));
+				foreach ($shop as $v) 
+		        {
+			    	$v = $s[$v];
+				    $info_list[$key]['shop'] .= $v.'<br>';
+				}
+			}
+			$total = $this->shopsku->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+        $this->_Template('shopsku',$this->data);
+	}
+	
+	public function _add()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['sku']))
+		{
+			if($this->shopsku->insert($post))
+        	{
+         		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
+        	}
+		}
+		$this->_Template('shopsku_add',$this->data);
+	}
+	
+	public function _edit($arg_array)
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			$id = $this->input->post('id',true);
+			if($this->shopsku->save($post,$id))
+        	{
+         		echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
+       	 	}
+       		else
+        	{
+           		echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
+        	}
+		}
+		$arg_array = $arg_array[0];
+		$shopsku = $this->shopsku->read($arg_array);
+		$this->data['shopsku'] = $shopsku;
+		$this->_Template('shopsku_edit',$this->data);
+	}
+	
+	//删除
+	public function _del()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',$id_arr);
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $this->shopsku->remove($v);
+            }
+            echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
+		}
+    }
+}

Diff do ficheiro suprimidas por serem muito extensas
+ 4261 - 0
core/CoreApp/controllers/Specialstock.php


+ 0 - 0
core/CoreApp/controllers/Staff.php


Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff