Systemfout.php 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. header("Access-Control-Allow-Origin: *");
  3. class Systemfout extends Start_Controller {
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->library('session');
  7. $this->load->_model('Model_whlabel','whlabel');
  8. $this->load->_model('Model_warehouse','warehouse');
  9. $this->load->_model('Model_productprice','productprice');
  10. $this->load->_model('Model_excel','excel');
  11. $this->load->_model('Model_fullorder','fullorder');
  12. $this->load->_model('Model_fullordertt','fullordertt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_outbound','outbound');
  15. $this->load->_model('Model_express','express');
  16. $this->load->_model('Model_shop','shop');
  17. $this->load->_model('Model_typeclass','typeclass');
  18. $this->load->_model('Model_country','country');
  19. $this->load->_model('Model_kdniao','kdniao');
  20. $this->load->_model('Model_notice','notice');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_dhlhz','dhlhz');
  23. $this->load->_model('Model_usps','usps');
  24. $this->load->_model('Model_fedex','fedex');
  25. $this->load->_model('Model_fedex_cby','fedex_cby');
  26. $this->load->_model('Model_ups','ups');
  27. $this->load->_model('Model_ali','ali');
  28. $this->load->_model('Model_dpd','dpd');
  29. $this->load->_model('Model_shop','shop');
  30. $this->load->_model('Model_user','user');
  31. $this->load->_model('Model_whlabel','whlabel');
  32. $this->load->_model('Model_specialstock','specialstock');
  33. $this->load->_model('Model_ck','ck');
  34. $this->load->_model('Model_whlabellabel','whlabellabel');
  35. $this->load->_model('Model_apiyy','apiyy');
  36. $this->load->helper('url');
  37. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  38. $this->load->_model('Model_systemtransfer','systemtransfer');
  39. $this->load->_model('Model_classid','classid');
  40. $this->load->_model('Model_allocation','allocation');
  41. $this->load->_model('Model_fullorderxw','fullorderxw');
  42. $this->load->_model('Model_fullorderpaypal','fullorderpaypal');
  43. $this->load->_model("Model_logic_ding","logic_ding");
  44. $this->load->_model("Model_fedexv1",'fedexv1');
  45. $this->load->_model("Model_zzquque_u9","zzquque_u9");
  46. }
  47. //定义方法的调用规则 获取URI第二段值
  48. public function _remap($arg,$arg_array)
  49. {
  50. if($arg == 'fedexhz')
  51. {
  52. $this->_fedexhz();
  53. }
  54. else if($arg == 'fout')
  55. {
  56. $this->_fout($arg_array);
  57. }
  58. else if($arg == 'fouthb')//合并出库的
  59. {
  60. $this->_fouthb($arg_array);
  61. }
  62. else if($arg == 'excel')
  63. {
  64. $this->_excel($arg_array);
  65. }
  66. else if($arg == 'cpexcel')
  67. {
  68. $this->_cpexcel($arg_array);
  69. }
  70. else if($arg == 'orderyz')
  71. {
  72. $this->_orderyz();
  73. }
  74. else if($arg == 'hwyz')
  75. {
  76. $this->_hwyz();
  77. }
  78. else if($arg == 'outnumber')
  79. {
  80. $this->_outnumber();
  81. }
  82. else if($arg == 'hb')
  83. {
  84. $this->_hb();
  85. }
  86. else
  87. {
  88. $this->_index();
  89. }
  90. }
  91. public function _index()
  92. {
  93. $post = $this->input->post(NULL, TRUE);
  94. $xw = '';
  95. if(isset($_SESSION['api']))
  96. {
  97. $user = $this->user->get_api($_SESSION['api']);
  98. $usp = $user;
  99. $fgshop = "";$sid = "";$wid="";$wtype="";
  100. $usersp = explode('|',trim($user['shop'],'|'));
  101. $userwh = explode('|',trim($user['warehouse'],'|'));
  102. foreach ($usersp as $value)
  103. {
  104. $fgshop .= " shop = ".$value." or";
  105. $sid .= " id = ".$value." or";
  106. }
  107. foreach ($userwh as $value)
  108. {
  109. $wid .= " id = ".$value." or";
  110. $wtype .= " type = ".$value." or";
  111. }
  112. if($user['userid'] == 'xw')
  113. {
  114. $xw = 1;
  115. }
  116. }
  117. if(isset($post['page']))
  118. {
  119. $page = $this->input->post('page',true);
  120. $perpage = $this->input->post('perpage',true);
  121. $timetk = $this->input->post('timetk',true);
  122. $timetj = $this->input->post('timetj',true);
  123. $shop = $this->input->post('shop',true);
  124. $source = $this->input->post('source',true);
  125. $orderinfo = $this->input->post('orderinfo',true);
  126. $number = $this->input->post('number',true);
  127. $library = $this->input->post('library',true);
  128. $waybill = $this->input->post('waybill',true);
  129. $express = $this->input->post('express',true);
  130. $type = $this->input->post('type',true);
  131. $lowe = $this->input->post('lowe',true);
  132. $so = $this->input->post('so',true);
  133. $librarytime = $this->input->post('librarytime',true);
  134. $timetk = strtotime($timetk);
  135. $timetj = strtotime($timetj);
  136. $cxtime = 'id';
  137. $where = "library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")";
  138. if($timetk && $timetj && $library == 1)
  139. {
  140. //$cxtime = 'reviewtime';
  141. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  142. $where .= " and state != 217";
  143. }
  144. else if($timetk && $timetj && $library == 2)
  145. {
  146. $cxtime = 'librarytime';
  147. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  148. }
  149. if($shop)
  150. {
  151. $where .= " and shop = '$shop'";
  152. }
  153. if($number)
  154. {
  155. $where .= " and number = '$number'";
  156. }
  157. if($library)
  158. {
  159. $where .= " and library = '$library'";
  160. }
  161. if($waybill)
  162. {
  163. $where .= " and waybill = '$waybill'";
  164. }
  165. if($express)
  166. {
  167. $where .= " and express = '$express'";
  168. }
  169. if($orderinfo)
  170. {
  171. $where .= " and orderinfo = '$orderinfo'";
  172. }
  173. if($type)
  174. {
  175. $where .= " and type = '$type'";
  176. }
  177. if($lowe)
  178. {
  179. $where .= " and shipremarks like '%$lowe%'";
  180. }
  181. if($so)
  182. {
  183. $where .= " and shipremarks like '%$so%'";
  184. }
  185. //数据排序
  186. $order_str = $cxtime." desc";
  187. if(empty($page))
  188. {
  189. $start = 0;
  190. $perpage = 1;
  191. }
  192. else
  193. {
  194. $start = ($page - 1)*$perpage;
  195. }
  196. //取得信息列表
  197. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  198. //格式化数据
  199. foreach ($info_list as $key=>$value)
  200. {
  201. $shop = $this->shop->read($value['shop']);
  202. $info_list[$key]['shop'] = $shop['shopname'];
  203. if($value['waybill'] == '0')
  204. {
  205. $info_list[$key]['waybill'] = "";
  206. }
  207. $express = $this->express->read($value['express']);
  208. $info_list[$key]['express'] = $express['servicename'];
  209. $warehouse = $this->warehouse->read($value['type']);
  210. $info_list[$key]['type'] = $warehouse['title'];
  211. if($value['print'] == 1)
  212. {
  213. $info_list[$key]['print'] = '不可打印';
  214. }
  215. else if($value['print'] == 2)
  216. {
  217. $info_list[$key]['print'] = '未打印';
  218. }
  219. else if($value['print'] == 3)
  220. {
  221. $info_list[$key]['print'] = '已打印';
  222. }
  223. if($value['library'] == 1)
  224. {
  225. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  226. }
  227. else if($value['library'] == 2)
  228. {
  229. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  230. }
  231. else if($value['library'] == 3)
  232. {
  233. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  234. }
  235. if($value['librarytime'] == '0')
  236. {
  237. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  238. }
  239. else
  240. {
  241. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  242. }
  243. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  244. }
  245. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  246. //格式化数据
  247. foreach ($info_listtt as $key=>$value)
  248. {
  249. $shop = $this->shop->read($value['shop']);
  250. $info_listtt[$key]['shop'] = $shop['shopname'];
  251. if($value['waybill'] == '0')
  252. {
  253. $info_listtt[$key]['waybill'] = "";
  254. }
  255. $express = $this->express->read($value['express']);
  256. $info_listtt[$key]['express'] = $express['servicename'];
  257. $warehouse = $this->warehouse->read($value['type']);
  258. $info_listtt[$key]['type'] = $warehouse['title'];
  259. if($value['print'] == 1)
  260. {
  261. $info_listtt[$key]['print'] = '不可打印';
  262. }
  263. else if($value['print'] == 2)
  264. {
  265. $info_listtt[$key]['print'] = '未打印';
  266. }
  267. else if($value['print'] == 3)
  268. {
  269. $info_listtt[$key]['print'] = '已打印';
  270. }
  271. if($value['library'] == 1)
  272. {
  273. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  274. }
  275. else if($value['library'] == 2)
  276. {
  277. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  278. }
  279. else if($value['library'] == 3)
  280. {
  281. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  282. }
  283. if($value['librarytime'] == '0')
  284. {
  285. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  286. }
  287. else
  288. {
  289. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  290. }
  291. }
  292. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  293. //格式化数据
  294. foreach ($info_listxw as $key=>$value)
  295. {
  296. $shop = $this->shop->read($value['shop']);
  297. $info_listxw[$key]['shop'] = $shop['shopname'];
  298. if($value['waybill'] == '0')
  299. {
  300. $info_listxw[$key]['waybill'] = "";
  301. }
  302. $express = $this->express->read($value['express']);
  303. $info_listxw[$key]['express'] = $express['servicename'];
  304. $warehouse = $this->warehouse->read($value['type']);
  305. $info_listxw[$key]['type'] = $warehouse['title'];
  306. if($value['print'] == 1)
  307. {
  308. $info_listxw[$key]['print'] = '不可打印';
  309. }
  310. else if($value['print'] == 2)
  311. {
  312. $info_listxw[$key]['print'] = '未打印';
  313. }
  314. else if($value['print'] == 3)
  315. {
  316. $info_listxw[$key]['print'] = '已打印';
  317. }
  318. if($value['library'] == 1)
  319. {
  320. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  321. }
  322. else if($value['library'] == 2)
  323. {
  324. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  325. }
  326. else if($value['library'] == 3)
  327. {
  328. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  329. }
  330. if($value['librarytime'] == '0')
  331. {
  332. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  333. }
  334. else
  335. {
  336. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  337. }
  338. }
  339. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  340. //格式化数据
  341. foreach ($info_listsmt as $key=>$value)
  342. {
  343. $shop = $this->shop->read($value['shop']);
  344. $info_listsmt[$key]['shop'] = $shop['shopname'];
  345. if($value['waybill'] == '0')
  346. {
  347. $info_listsmt[$key]['waybill'] = "";
  348. }
  349. $express = $this->express->read($value['express']);
  350. $info_listsmt[$key]['express'] = $express['servicename'];
  351. $warehouse = $this->warehouse->read($value['type']);
  352. $info_listsmt[$key]['type'] = $warehouse['title'];
  353. if($value['print'] == 1)
  354. {
  355. $info_listsmt[$key]['print'] = '不可打印';
  356. }
  357. else if($value['print'] == 2)
  358. {
  359. $info_listsmt[$key]['print'] = '未打印';
  360. }
  361. else if($value['print'] == 3)
  362. {
  363. $info_listsmt[$key]['print'] = '已打印';
  364. }
  365. if($value['library'] == 1)
  366. {
  367. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  368. }
  369. else if($value['library'] == 2)
  370. {
  371. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  372. }
  373. else if($value['library'] == 3)
  374. {
  375. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  376. }
  377. if($value['librarytime'] == '0')
  378. {
  379. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  380. }
  381. else
  382. {
  383. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  384. }
  385. }
  386. $total = $this->fullorder->find_count($where);
  387. $total += $this->fullordertt->find_count($where);
  388. $total += $this->fullorderxw->find_count($where);
  389. $total += $this->fullordersmt->find_count($where);
  390. $pagenum = ceil($total/$perpage);
  391. $over = $total-($start+$perpage);
  392. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listtt,$info_listxw,$info_listsmt)));
  393. echo json_encode($rows);exit;
  394. }
  395. if(isset($_SESSION['api']))
  396. {
  397. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  398. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  399. $this->data['wlshop'] = $wlshop;
  400. $this->data['warehouse'] = $warehouse;
  401. }
  402. $this->data['xw'] = $xw;
  403. $this->_Template('systemfout',$this->data);
  404. }
  405. public function _fout()
  406. {
  407. $post = $this->input->post(NULL, TRUE);
  408. if(isset($post['order']))
  409. {
  410. $time = time();
  411. $order = $this->input->post('order',true);
  412. $weight = $this->input->post('weight',true);
  413. if(!isset($weight))//测试没问题后可以删
  414. {
  415. $weight = '';
  416. }
  417. if(substr($order,0,3) == '788' && substr($order,-4,4) == '0430')//Fedex联邦
  418. {
  419. $order = substr($order,0,12);
  420. }
  421. if(strlen($order) == '34')//联邦杭州超长运单截取
  422. {
  423. $order = substr($order,22,12);
  424. }
  425. if(!$order)
  426. {
  427. echo json_encode(array('msg'=>'出库信息不能为空!','success'=>false));exit;
  428. }
  429. if(strlen($order) == 30)
  430. {
  431. $order = substr($order, 8);
  432. }
  433. $fullorder_name = 'fullorder';$outtype = 1;
  434. $y = $this->fullorder->get_waybill($order);
  435. if(!$y)
  436. {
  437. $y = $this->fullorder->get_number($order);
  438. $outtype = 2;
  439. if(!$y)
  440. {
  441. $fullorder_name = 'fullordersmt';$outtype = 1;
  442. $y = $this->fullordersmt->get_waybill($order);
  443. if(!$y)
  444. {
  445. $y = $this->fullordersmt->get_number($order);
  446. $outtype = 2;
  447. if(!$y)
  448. {
  449. $fullorder_name = 'fullordertt';$outtype = 1;
  450. $y = $this->fullordertt->get_waybill($order);
  451. if(!$y)
  452. {
  453. $y = $this->fullordertt->get_number($order);
  454. $outtype = 2;
  455. if(!$y)
  456. {
  457. $fullorder_name = 'fullorderxw';$outtype = 1;
  458. $y = $this->fullorderxw->get_waybill($order);
  459. if(!$y)
  460. {
  461. $y = $this->fullorderxw->get_number($order);
  462. $outtype = 2;
  463. if(!$y)
  464. {
  465. echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
  466. }
  467. }
  468. }
  469. }
  470. }
  471. }
  472. }
  473. }
  474. if($y['mergeid'] == '1')
  475. {
  476. $y = $this->$fullorder_name->read($y['merge']);
  477. }
  478. $express = $this->express->read($y['express']);
  479. if($y['state'] == 216 && $fullorder_name == 'fullordersmt')
  480. {
  481. $y['librarynot'] = '客户已取消!';
  482. }
  483. if($y['print'] != 3 || $y['libraryconfirm'] == 1 || $y['state'] == 214 || $y['state'] == 217 || $y['state'] == 283 || $y['state'] == 206 || $y['state'] == 205 || $y['state'] == 204 || $y['state'] == 210 || $y['state'] == 211 || $y['state'] == 212 || ($y['state'] == 216 && $fullorder_name == 'fullordersmt'))//独立站216先关了
  484. {
  485. echo json_encode(array('msg'=>'禁止出库!'.$y['librarynot'],'success'=>false));exit;
  486. }
  487. if($y['library'] > 1)
  488. {
  489. echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作','success'=>false));exit;
  490. }
  491. if($express['out'] != 3)
  492. {
  493. if($express['out'] != $outtype)
  494. {
  495. $smlx = ($express['out']=='1')?'运单':'发货单';
  496. echo json_encode(array('msg'=>'扫描类型错误!此单需要扫描'.$smlx,'success'=>false));exit;
  497. }
  498. }
  499. if($y['type'] != 7 && $y['waybill'] != '' && $y['printtype'] == '1')
  500. {
  501. $y['waybill'] = trim($y['waybill'],' ');
  502. if(strlen($y['waybill']) == 12 && $y['express'] != 24 && $y['express'] != 31 && $y['express'] != 38 && $y['express'] != 41 && $y['express'] != 6 && $y['express'] != 43 && $y['express'] != 48 && $y['express'] != 50 && $y['express'] != 63)
  503. {
  504. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-1','success'=>false));exit;
  505. }
  506. else if(strlen($y['waybill']) == 10 && $y['express'] != 1 && $y['express'] != 37 && $y['express'] != 49 && $y['express'] != 42)
  507. {
  508. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-2','success'=>false));exit;
  509. }
  510. else if(strlen($y['waybill']) == 18 && $y['express'] != 3 && $y['express'] != 66 && $y['express'] != 67)
  511. {
  512. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-3','success'=>false));exit;
  513. }
  514. }
  515. if(stripos($weight,',') !== false){
  516. $tmp_arr = explode(",",$weight);
  517. $weight = end($tmp_arr);
  518. $numweight = (float)$weight;
  519. $weight = $numweight."kg";
  520. }
  521. $numweight = str_replace('kg','',$weight);
  522. // if(($y['express'] == '24' || $y['express'] == '3' || $y['express'] == '28' || $y['express'] == '33' || $y['express'] == '42') && $y['type'] != 6)//杭州除外
  523. // {
  524. // if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
  525. // {
  526. // echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
  527. // }
  528. // $yzweight = explode('.',$numweight);
  529. // if($yzweight[0] == '')
  530. // {
  531. // echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  532. // }
  533. // if($numweight < ($y['jweight']/1000))
  534. // {
  535. // echo json_encode(array('msg'=>'重量小于净重,请重新称重!','success'=>false));exit;
  536. // }
  537. // if($numweight -($y['jweight']/1000) > 0.9 && $y['number'] != 'QQS-30401-002')
  538. // {
  539. // echo json_encode(array('msg'=>'称重重量和净重相差过大,请找成会或梦体处理!','success'=>false));exit;
  540. // }
  541. // if($numweight > '0.98' && $y['express'] == '3')
  542. // {
  543. // echo json_encode(array('msg'=>'UPS大于0.98公斤需要拆包!','success'=>false));exit;
  544. // }
  545. // if($numweight > '2' && $y['express'] == '37')
  546. // {
  547. // echo json_encode(array('msg'=>'杭州DHL大于2公斤需要联系店员!','success'=>false));exit;
  548. // }
  549. // if($numweight >= '10' && ($y['express'] == '24' || $y['express'] == '31'))
  550. // {
  551. // echo json_encode(array('msg'=>'联邦不能大于10公斤!','success'=>false));exit;
  552. // }
  553. // }
  554. //根据要求 USPS-USA 2 FEDEX-US2 63 USPS-US2 64 这三个快递方式除外的所有快递都需要称重再发货 或者说是【国内发货】的都需要称重
  555. //还有翔文仓库的 不执行
  556. //源代码是
  557. //所有快递必须称重
  558. //所有快递必须称重 翔文除外
  559. //$this->logic_ding->sendToDing("检测订单".$y['number']."称重".$numweight."快递公司".$y['express']."-".$weight."[".$numweight."]");
  560. if(!in_array($y['express'],[2,39,43,44,45,47,48,49,55,61,63,64,65])){
  561. if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
  562. {
  563. echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
  564. }
  565. $yzweight = explode('.',$numweight);
  566. if($yzweight[0] == '')
  567. {
  568. echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  569. }
  570. if(empty($numweight)){
  571. echo json_encode(array('msg'=>'此单需要称重2!','success'=>false));exit;
  572. }
  573. //$this->logic_ding->sendToDing("检测订单---------------------标记需要认证的东西".$y['number']);
  574. }
  575. //$this->logic_ding->sendToDing("检测订单".$y['number']."称重".$numweight."快递公司".$y['express']);
  576. $express_info = $this->express->read($y['express']);
  577. if(empty($express_info)){
  578. echo json_encode(array('msg'=>'该快递信息异常,请联系技术!','success'=>false));exit;
  579. }
  580. $weight_limit = $express_info['weight_limit']*1;
  581. if($weight_limit > 0){
  582. $yzweight = explode('.',$numweight);
  583. if($yzweight[0] == '')
  584. {
  585. echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  586. }
  587. if($numweight < ($y['jweight']/1000)){
  588. echo json_encode(array('msg'=>'重量小于净重,请重新称重!','success'=>false));exit;
  589. }
  590. //Fedex(杭州),UPS,DHL官方-美国 需要判断实际重量和净重差 其他快递不需要
  591. if(in_array($y['express'],[3,24,42])){
  592. //规定实际重量不允许超过 净重为1kg
  593. if($numweight -($y['jweight']/1000) > 1 )
  594. {
  595. echo json_encode(array('msg'=>'称重重量和净重相差过大,请找成会处理!','success'=>false));exit;
  596. }
  597. }
  598. if($weight_limit < $numweight){
  599. echo json_encode(array('msg'=>$express['servicename'].'大于'.$weight_limit.'公斤需要拆包!','success'=>false));exit;
  600. }
  601. }
  602. if(((time() - $y['printtime']) > (15*24*3600) || $y['printtime'] < 1590211800) && $y['express'] == '24' && $y['type'] != 6)//杭州店铺除外
  603. {
  604. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  605. }
  606. if((time() - $y['printtime']) > (6*24*3600) && $y['express'] == '3' && $y['type'] != 6)//杭州店铺除外
  607. {
  608. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  609. echo json_encode(array('msg'=>'此运单过期无法出库,请联系成会处理!','success'=>false));exit;
  610. }
  611. if((time() - $y['printtime']) > (7*24*3600) && $y['express'] == '37' && $y['type'] != 6)//杭州店铺除外
  612. {
  613. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  614. }
  615. $this->db->trans_begin();
  616. $warehouse = $this->warehouse->read($y['type']);
  617. $bdck = $warehouse['bdck'];
  618. if($warehouse['zd'] == '1')
  619. {
  620. if($warehouse['bdck'] == '')
  621. {
  622. echo json_encode(array('msg'=>'仓库设置错误!','success'=>false));exit;
  623. }
  624. $wh = $this->_fout_db($y,$warehouse,$bdck);
  625. if($wh['fh'] == 2)
  626. {
  627. $kcyz = $this->ck->get_kc($y['state'],$warehouse,$y['shop'],$y['number'],$y['whlabel'],$y['fpdata']);
  628. if($kcyz['t'] == '0')
  629. {
  630. if($kcyz['fpdata'] != '')
  631. {
  632. $x['whlabel'] = $kcyz['whlabel'];
  633. $x['fpdata'] = $kcyz['fpdata'];
  634. $y['whlabel'] = $x['whlabel'];
  635. $this->$fullorder_name->save($x,$y['id']);
  636. }
  637. }
  638. $wh = $this->_fout_db($y,$warehouse,$bdck);
  639. if($wh['fh'] == 2)
  640. {
  641. echo json_encode(array('msg'=>'库存占用量与实际出库量不符!','success'=>false));exit;
  642. }
  643. }
  644. foreach ($wh['sj'] as $v)
  645. {
  646. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  647. }
  648. }
  649. /**
  650. if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') === false)
  651. {
  652. $whlabel = $this->whlabel->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  653. $cpsl = 0;
  654. $pp = explode('|',trim($y['whlabel'],'|'));
  655. foreach ($pp as $va)
  656. {
  657. $num = explode('-',$va);
  658. $cpsl += $num[1];
  659. }
  660. if(count($whlabel) != $cpsl)
  661. {
  662. echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
  663. }
  664. foreach ($whlabel as $v)
  665. {
  666. $this->whlabel->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  667. }
  668. }
  669. if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') !== false)
  670. {
  671. $wh = $this->specialstock->find_all("zd = '".$y['number']."' and state = '0'");
  672. $cpsl = 0;
  673. $pp = explode('|',trim($y['whlabel'],'|'));
  674. foreach ($pp as $va)
  675. {
  676. $num = explode('-',$va);
  677. if(stripos($num[2],'z') !== false)//如果是特殊库存
  678. {
  679. $cpsl += $num[1];
  680. }
  681. }
  682. if(count($wh) != $cpsl)
  683. {
  684. echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
  685. }
  686. foreach ($wh as $v)
  687. {
  688. if(!$this->specialstock->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']))
  689. {
  690. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  691. }
  692. }
  693. }
  694. **/
  695. /**
  696. if($y['dbapi'] == 99 && $y['scapi'] == 99)
  697. {
  698. $d = $this->apiyy->get_chd($y);
  699. if($d['Data'][0]['m_isSucess'] != 1)
  700. {
  701. echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
  702. }
  703. }
  704. $systemtransfer = $this->systemtransfer->find_all("number = '".$y['number']."'");
  705. if(isset($systemtransfer[0]))
  706. {
  707. foreach ($systemtransfer as $v)
  708. {
  709. if($v['dbapi'] != 99)
  710. {
  711. echo json_encode(array('msg'=>'此订单货物:'.$v['pm'].'没有成功扫布标入库,无法出库!','success'=>false));exit;
  712. }
  713. }
  714. $y['ts'] = count($systemtransfer);
  715. $d = $this->apiyy->get_chd($y);
  716. if($d['Data'][0]['m_isSucess'] != 1)
  717. {
  718. echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
  719. }
  720. }
  721. **/
  722. $shop = $this->shop->read($y['shop']);
  723. if($express['printcode'] == "DHLUSA" && $y['waybill'] != '')
  724. {
  725. $type = $this->typeclass->read($shop['type']);
  726. $y['shoptype'] = $type['title'];
  727. $y['weight'] = $weight;
  728. $d = $this->dhl->get_data_9610($y);
  729. if($d != 1)
  730. {
  731. $this->allocation->insert(array('order'=>1,'title'=>$y['number'],'content'=>$d));
  732. echo json_encode(array('msg'=>'9610失败,'.$d,'success'=>false));exit;
  733. }
  734. $this->allocation->insert(array('order'=>9610,'title'=>$y['number']));
  735. }
  736. if($fullorder_name == 'fullordersmt')
  737. {
  738. $stt = ($y['waybill']!='')?209:$y['state'];
  739. $post = array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  740. /**
  741. if($this->$fullorder_name->save(array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  742. {
  743. echo json_encode(array('success'=>true));exit;
  744. }
  745. else
  746. {
  747. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  748. }
  749. **/
  750. }
  751. else if(($fullorder_name == 'fullordertt' || $fullorder_name == 'fullorderxw' || $fullorder_name == 'fullorder') && $y['source'] == 1)
  752. {
  753. /**
  754. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  755. {
  756. echo json_encode(array('success'=>true));exit;
  757. }
  758. else
  759. {
  760. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  761. }
  762. **/
  763. $post = array('library'=>2,'state'=>216,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  764. }
  765. else
  766. {
  767. /**
  768. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  769. {
  770. echo json_encode(array('success'=>true));exit;
  771. }
  772. else
  773. {
  774. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  775. }
  776. **/
  777. $post = array('library'=>2,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  778. }
  779. /**
  780. if($fullorder_name == 'fullorder')
  781. {
  782. $orderinfo = preg_replace('/^' . preg_quote($y['shop'], '/') . '/', '', $y['orderinfo']);
  783. $post['incrementId'] = $orderinfo;
  784. $post['trackingNumber'] = $y['waybill'];
  785. $ex = $this->express->read($y['express']);
  786. $post['carrier'] = $ex['iscode'];
  787. $url = 'https://www.romandhair.com/applepay/payment/addTrack';
  788. $ch = curl_init();
  789. curl_setopt($ch,CURLOPT_URL,$url);
  790. curl_setopt($ch, CURLOPT_POST, 1);
  791. curl_setopt($ch, CURLOPT_HEADER, 0);
  792. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  793. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  794. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  795. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  796. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  797. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1800000);
  798. $res = curl_exec($ch);
  799. curl_close($ch);
  800. $res = json_decode($res,true);
  801. if($res['success'] == 0)
  802. {
  803. $this->fullorderpaypal->insert(array('orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'time'=>$time,'cw'=>$res['msg']));//失败
  804. }
  805. else
  806. {
  807. $this->fullorderpaypal->insert(array('orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'time'=>$time,'type'=>1));
  808. }
  809. }
  810. **/
  811. if($outtype == 2 && $y['printnumber'] > 1)
  812. {
  813. $p = json_encode($post);
  814. echo json_encode(array('msg'=>'该单共打印过'.$y['printnumber'].'次,请注意核对当前发货单是否是最新发货单!','outnumber'=>$y['id'],'post'=>$p,'fullorder_name'=>$fullorder_name,'success'=>false));exit;
  815. }
  816. $this->$fullorder_name->save($post,$y['id']);
  817. //开始录入执行u9队列的数据
  818. $quque_u9_list = [];
  819. $queue_u9_list[] = [
  820. 'platform'=>$fullorder_name,
  821. 'warehouse'=>$y['type'],
  822. 'type'=>($y['type'] == 5)?11:10, //5代表美仓
  823. 'order_no'=>$y['number'],
  824. 'status'=>0,
  825. ];
  826. //合并订单自动发货
  827. $hb = $this->$fullorder_name->find_all("merge = '".$y['id']."' and id != '".$y['id']."'");
  828. $post['waybill'] = $y['waybill'];
  829. $post['express'] = $y['express'];
  830. $post['printtype'] = $y['printtype'];
  831. $post['ioss'] = $y['ioss'];
  832. $post['review'] = 6;
  833. $post['bx'] = $y['bx'];
  834. $post['qm'] = $y['qm'];
  835. $post['js'] = $y['js'];
  836. //$post['state'] = 216;
  837. $post['print'] = $y['print'];
  838. $post['printtime'] = $y['printtime'];
  839. $post['library'] = 2;
  840. $post['librarytime'] = $time;
  841. $post['libraryconfirm'] = 2;
  842. $post['librarynot'] = '';
  843. foreach ($hb as $v)
  844. {
  845. $post['state'] = $v['state'];
  846. $vshop = $this->shop->read($v['shop']);
  847. $vwarehouse = $this->warehouse->read($v['type']);
  848. $this->$fullorder_name->save($post,$v['id']);
  849. //2025年1月25日发现翔文合并订单发现此问题
  850. if($warehouse['zd'] == '1'){
  851. $wh = $this->_fout_db($v,$warehouse,$bdck);
  852. foreach ($wh['sj'] as $vv)
  853. {
  854. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$v['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$vv['id']);
  855. }
  856. }
  857. //添加队列的录入
  858. $queue_u9_list[] = [
  859. 'platform'=>$fullorder_name,
  860. 'warehouse'=>$v['type'],
  861. 'type'=>($y['type'] == 5)?11:10,
  862. 'order_no'=>$v['number'],
  863. 'status'=>0,
  864. ];
  865. // $wh = $this->_fout_db($v,$warehouse,$bdck);
  866. // foreach ($wh['sj'] as $vv)
  867. // {
  868. // $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$v['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$vv['id']);
  869. // }
  870. //$this->ck->get_kc($post['state'],$vwarehouse,$vshop,$v['number'],$v['whlabel'],$v['fpdata']);
  871. }
  872. if ($this->db->trans_status() === TRUE)
  873. {
  874. $this->db->trans_commit();
  875. //将要执行的队列数据添加进去
  876. foreach($queue_u9_list as $item){
  877. if($item['platform'] != 'fullorderxw'){
  878. $this->zzquque_u9->insert($item);
  879. }
  880. }
  881. echo json_encode(array('success'=>true));
  882. }
  883. else
  884. {
  885. $this->db->trans_rollback();
  886. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));
  887. }
  888. }
  889. }
  890. public function _outnumber()//对比占单是否正确
  891. {
  892. $post = $this->input->post(NULL, TRUE);
  893. if(isset($post['outnumber']))
  894. {
  895. $post = $this->input->post('post',true);
  896. $fullorder_name = $this->input->post('fullorder_name',true);
  897. $outnumber = $this->input->post('outnumber',true);
  898. $post = json_decode($post,true);
  899. $this->$fullorder_name->save($post,$outnumber);
  900. }
  901. }
  902. public function _fout_db($y,$warehouse,$bdck)//对比占单是否正确
  903. {
  904. $wh = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  905. $cpsl = 0;
  906. $pp = explode('|',trim($y['whlabel'],'|'));
  907. foreach ($pp as $va)
  908. {
  909. $num = explode('-',$va);
  910. if(isset($num[2]))
  911. {
  912. if(stripos($num[2],$warehouse['hz']) !== false)
  913. {
  914. $cpsl += $num[1];
  915. }
  916. }
  917. }
  918. if(count($wh) == $cpsl)
  919. {
  920. return array('fh'=>1,'sj'=>$wh);
  921. }
  922. else
  923. {
  924. return array('fh'=>2);
  925. }
  926. }
  927. public function _fedexhz()
  928. {
  929. $post = $this->input->post(NULL, TRUE);
  930. if(isset($post['id']))
  931. {
  932. $id = $this->input->post('id',true);
  933. $fullorder_name = $this->input->post('name',true);
  934. $express = $this->input->post('express',true);
  935. $express = $this->express->read($express);
  936. $fullorder = $this->$fullorder_name->read($id);
  937. if($fullorder['type'] == '2')
  938. {
  939. $fullorder['type'] = 1;
  940. }
  941. $time = time();
  942. $fullorder = $this->_text($fullorder);//获取所需信息
  943. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  944. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  945. $time = time();
  946. if($express['printcode'] == "FEDEXGF")
  947. {
  948. //$barcode = $this->fedex->get_data($fullorder);//获取联邦快递信息
  949. //升级的api
  950. $barcode = $this->fedexv1->get_data($fullorder);//获取联邦快递信息
  951. if($barcode['x'] == 1)
  952. {
  953. $bctime = date('Ymd',$time);
  954. $Hwaybill = $barcode['waybill'];
  955. // $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  956. // $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  957. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  958. $Hfp = $this->_pdfurl($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  959. if(isset($barcode['label']) && isset($Hwaybill))
  960. {
  961. if($fullorder['waybill'] != "")
  962. {
  963. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  964. }
  965. else
  966. {
  967. $oldwaybill = $fullorder['oldwaybill'];
  968. }
  969. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  970. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  971. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  972. {
  973. $warehouse = $this->warehouse->read($fullorder['type']);
  974. $text = array();
  975. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  976. $text['number'] = $fullorder['number'];
  977. $text['mode'] = '95';
  978. $text['pdfnum'] = 1;
  979. $rows = array('text'=>$text);
  980. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  981. }
  982. else
  983. {
  984. echo json_encode(array($fullorder['number'].'msg'=>'打印错误,请联系店员','cw'=>'写入数据库错误','success'=>false));exit;
  985. }
  986. }
  987. }
  988. else
  989. {
  990. echo json_encode(array('msg'=>'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  991. }
  992. }
  993. else if($express['printcode'] == "UPS")//接口UPS暂时不打
  994. {
  995. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会处理','success'=>false));exit;
  996. $barcode = $this->ups->get_data($fullorder);//获取快递信息
  997. if($barcode['x'] == 1)
  998. {
  999. $bctime = date('Ymd',$time);
  1000. $Hwaybill = $barcode['waybill'];
  1001. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1002. if(isset($barcode['label']) && isset($Hwaybill))
  1003. {
  1004. if($fullorder['waybill'] != "")
  1005. {
  1006. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1007. }
  1008. else
  1009. {
  1010. $oldwaybill = $fullorder['oldwaybill'];
  1011. }
  1012. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1013. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1014. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1015. {
  1016. $type = 1;
  1017. $text = array('yd'=>'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','data'=>$fullorder,'id'=>$fullorder['id'],'pt'=>$fullorder_name);
  1018. }
  1019. }
  1020. }
  1021. else
  1022. {
  1023. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  1024. }
  1025. }
  1026. else if($express['printcode'] == "DHLHZ")//如果打印过那么重新获取运单
  1027. {
  1028. $barcode = $this->dhlhz->get_data($fullorder);//获取DHL快递信息
  1029. if($barcode['c'] == 1)
  1030. {
  1031. $bctime = date('Ymd',$time);
  1032. $Hwaybill = $barcode['data']['waybill'];
  1033. $Hfp = $this->_pdf($barcode['data']['fp'],'f-'.$Hwaybill,$bctime);
  1034. $Hyd = $this->_pdf($barcode['data']['yd'],'y-'.$Hwaybill,$bctime);
  1035. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  1036. {
  1037. if($fullorder['waybill'] != "")
  1038. {
  1039. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1040. }
  1041. else
  1042. {
  1043. $oldwaybill = $fullorder['oldwaybill'];
  1044. }
  1045. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1046. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删d
  1047. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  1048. {
  1049. $warehouse = $this->warehouse->read($fullorder['type']);
  1050. $text = array();
  1051. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  1052. $text['number'] = $fullorder['number'];
  1053. $text['mode'] = '95';
  1054. $text['pdfnum'] = 1;
  1055. $rows = array('text'=>$text);
  1056. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1057. }
  1058. }
  1059. }
  1060. else
  1061. {
  1062. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  1063. }
  1064. }
  1065. else
  1066. {
  1067. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会或者梦体处理','success'=>false));exit;
  1068. }
  1069. }
  1070. }
  1071. public function _text($fullorder)
  1072. {
  1073. /** 发票地址信息暂时无用
  1074. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1075. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1076. $fullorder['baddress'][1] = $country['ename'];
  1077. **/
  1078. //获取所用相关信息
  1079. $warehouse = $this->warehouse->read($fullorder['type']);
  1080. $country = $this->country->read($fullorder['country']);//订单国家信息
  1081. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1082. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1083. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1084. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1085. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1086. $fullorder['country'] = $country['ename'];//订单国家名
  1087. $fullorder['zhou'] = $country['continent'];//所属州
  1088. $express = $this->express->read($fullorder['express']);
  1089. $fullorder['express'] = $express['servicename'];
  1090. $fullorder['account'] = $express['account'];
  1091. $fullorder['printcode'] = $express['printcode'];
  1092. $fullorder['time'] = date('Y-m-d',time());
  1093. $fullorder['times'] = date('Y-m-d H:i',time());
  1094. $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1095. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1096. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1097. $shop = $this->shop->read($fullorder['shop']);
  1098. $fullorder['shop'] = $shop['shopname'];
  1099. return $fullorder;
  1100. }
  1101. public function _lowe()
  1102. {
  1103. $post = $this->input->post(NULL, TRUE);
  1104. if(isset($post['lowe']))
  1105. {
  1106. $lowe = $this->typeclass->find_all('classid = 15 and id != 105 and id != 107 and id != 108 and id != 112 and id != 114 and id != 115 and id != 116 and id != 117 and id != 118 and id != 119 and id != 120 and id != 121 and id != 122 and id != 123 and id != 124 and id != 125 and id != 292 and id != 63 and id != 289 and id != 290 and id != 181 and id != 273 and id != 148 and id != 38 and id != 291 and id != 55 and id != 271 and id != 285 and id != 186 and id != 187 and id != 188 and id != 189');
  1107. echo json_encode(array('msg'=>$lowe));exit;
  1108. }
  1109. }
  1110. public function _pdf($pdf,$title,$bctime)
  1111. {
  1112. $pdf_path = './data/pdf/'.$bctime.'/';
  1113. $file_base64 = $pdf;
  1114. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  1115. $file_base64 = base64_decode($file_base64);
  1116. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1117. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  1118. return $bctime;
  1119. }
  1120. public function _pdfurl($pdf,$title,$bctime)
  1121. {
  1122. $pdf_path = './data/pdf/'.$bctime.'/';
  1123. $pdf = fopen($pdf,"r");
  1124. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1125. file_put_contents($pdf_path.$title.'.pdf',$pdf);
  1126. return $bctime;
  1127. }
  1128. public function _excel()
  1129. {
  1130. $xw = '';
  1131. if(isset($_SESSION['api']))
  1132. {
  1133. $user = $this->user->get_api($_SESSION['api']);
  1134. $usp = $user;
  1135. $fgshop = "";$sid = "";$wid="";$wtype="";
  1136. $usersp = explode('|',trim($user['shop'],'|'));
  1137. $userwh = explode('|',trim($user['warehouse'],'|'));
  1138. foreach ($usersp as $value)
  1139. {
  1140. $fgshop .= " shop = ".$value." or";
  1141. $sid .= " id = ".$value." or";
  1142. }
  1143. foreach ($userwh as $value)
  1144. {
  1145. $wid .= " id = ".$value." or";
  1146. $wtype .= " type = ".$value." or";
  1147. }
  1148. if($user['userid'] == 'xw')
  1149. {
  1150. $xw = 1;
  1151. }
  1152. }
  1153. if(isset($_GET['fexcel']))
  1154. {
  1155. $dowid = $this->input->get('a');
  1156. $wid = "";
  1157. if($dowid != "")
  1158. {
  1159. $id_arr = explode(',',rtrim($dowid,','));
  1160. foreach ($id_arr as $v)
  1161. {
  1162. $wid .= " id = '$v' or";
  1163. }
  1164. $wid = " and".rtrim($wid,'or');
  1165. }
  1166. $t = $this->input->get('t',true);
  1167. $timetk = $this->input->get('timetk',true);
  1168. $timetj = $this->input->get('timetj',true);
  1169. $shop = $this->input->get('shop',true);
  1170. $source = $this->input->get('source',true);
  1171. $orderinfo = $this->input->get('orderinfo',true);
  1172. $number = $this->input->get('number',true);
  1173. $library = $this->input->get('library',true);
  1174. $waybill = $this->input->get('waybill',true);
  1175. $express = $this->input->get('express',true);
  1176. $type = $this->input->get('type',true);
  1177. $so = $this->input->get('so',true);
  1178. $timetk = strtotime($timetk);
  1179. $timetj = strtotime($timetj);
  1180. $where = (isset($_SESSION['api']))?"library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0'";
  1181. if($timetk && $timetj && $library == 1)
  1182. {
  1183. //$cxtime = 'reviewtime';
  1184. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  1185. $where .= " and state != 217";
  1186. }
  1187. else if($timetk && $timetj && $library == 2)
  1188. {
  1189. $cxtime = 'librarytime';
  1190. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1191. }
  1192. /**
  1193. $where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
  1194. if($timetk && $timetj && $library == 1)
  1195. {
  1196. //$cxtime = 'reviewtime';
  1197. //$where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1198. }
  1199. else if($timetk && $timetj && $library == 2)
  1200. {
  1201. $cxtime = 'librarytime';
  1202. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1203. }
  1204. **/
  1205. if(isset($_SESSION['api']))
  1206. {
  1207. if($type)
  1208. {
  1209. $where .= " and type = '$type'";
  1210. }
  1211. else
  1212. {
  1213. $uw = '';
  1214. $u = $this->user->get_api($_SESSION['api']);
  1215. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1216. foreach ($u['warehouse'] as $v)
  1217. {
  1218. $uw .= " type = '$v' or";
  1219. }
  1220. $uw = rtrim($uw,'or');
  1221. $uw = " and (".ltrim($uw,' ').")";
  1222. $where .= $uw;
  1223. }
  1224. }
  1225. else
  1226. {
  1227. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  1228. }
  1229. if($shop)
  1230. {
  1231. $where .= " and shop = '$shop'";
  1232. }
  1233. if($number)
  1234. {
  1235. $where .= " and number = '$number'";
  1236. }
  1237. if($library)
  1238. {
  1239. $where .= " and library = '$library'";
  1240. }
  1241. if($waybill)
  1242. {
  1243. $where .= " and waybill = '$waybill'";
  1244. }
  1245. if($express)
  1246. {
  1247. $where .= " and express = '$express'";
  1248. }
  1249. if($orderinfo)
  1250. {
  1251. $where .= " and orderinfo = '$orderinfo'";
  1252. }
  1253. if($so)
  1254. {
  1255. $where .= " and shipremarks like '%$so%'";
  1256. }
  1257. //数据排序
  1258. //$order_str = ($print != 3)?"id desc":"librarytime desc";
  1259. $order_str = "librarytime desc";
  1260. if(empty($page))
  1261. {
  1262. $start = 0;
  1263. $perpage = 1;
  1264. }
  1265. else
  1266. {
  1267. $start = ($page - 1)*$perpage;
  1268. }
  1269. $typeclass = array();
  1270. $tclass = $this->typeclass->find_all();
  1271. foreach ($tclass as $v)
  1272. {
  1273. $typeclass[$v['id']] = $v;
  1274. }
  1275. //取得信息列表
  1276. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1277. //格式化数据
  1278. foreach ($info_list as $key=>$value)
  1279. {
  1280. $shop = $this->shop->read($value['shop']);
  1281. $info_list[$key]['shop'] = $shop['shopname'];
  1282. if($value['waybill'] == '0')
  1283. {
  1284. $info_list[$key]['waybill'] = "";
  1285. }
  1286. $express = $this->express->read($value['express']);
  1287. $info_list[$key]['express'] = $express['servicename'];
  1288. $warehouse = $this->warehouse->read($value['type']);
  1289. $info_list[$key]['type'] = $warehouse['title'];
  1290. if($value['print'] == 1)
  1291. {
  1292. $info_list[$key]['print'] = '不可打印';
  1293. }
  1294. else if($value['print'] == 2)
  1295. {
  1296. $info_list[$key]['print'] = '未打印';
  1297. }
  1298. else if($value['print'] == 3)
  1299. {
  1300. $info_list[$key]['print'] = '已打印';
  1301. }
  1302. if($value['library'] == 1)
  1303. {
  1304. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  1305. }
  1306. else if($value['library'] == 2)
  1307. {
  1308. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  1309. }
  1310. else if($value['library'] == 3)
  1311. {
  1312. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  1313. }
  1314. if($value['librarytime'] == '0')
  1315. {
  1316. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  1317. }
  1318. else
  1319. {
  1320. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1321. }
  1322. $classid = $classid = $this->classid->sku();
  1323. $dbapi = explode(';',trim($value['fpdata'],';'));
  1324. foreach ($dbapi as $va)
  1325. {
  1326. $pm = $classid;
  1327. $jm = $classid;
  1328. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1329. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1330. $ts = explode('|',trim($features,'|'));
  1331. if(stripos($ts[0],',') !== false)
  1332. {
  1333. $ft = explode(',',$ts[0]);
  1334. $features = explode('-',trim($ft[1],'-'));
  1335. $features[] = $ft[0];
  1336. }
  1337. else
  1338. {
  1339. $features = explode('-',trim($ts[0],'-'));
  1340. }
  1341. foreach($features as $k=>$v)
  1342. {
  1343. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1344. {
  1345. if($typeclass[$v]['bm'] != '')
  1346. {
  1347. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1348. }
  1349. }
  1350. if($v != 0 && isset($typeclass[$v]))
  1351. {
  1352. if($typeclass[$v]['classid'] == 13)
  1353. {
  1354. $dj = $typeclass[$v]['title'];
  1355. }
  1356. if($typeclass[$v]['classid'] == 8)
  1357. {
  1358. $ys = $typeclass[$v]['title'];
  1359. }
  1360. if($typeclass[$v]['classid'] == 15)
  1361. {
  1362. $hx = $typeclass[$v]['title'];
  1363. }
  1364. if(isset($pm[$typeclass[$v]['classid']]))
  1365. {
  1366. if($typeclass[$v]['title'] == '9A')
  1367. {
  1368. $pm[$typeclass[$v]['classid']] = '9A';
  1369. }
  1370. else if($typeclass[$v]['title'] == '10A')
  1371. {
  1372. $pm[$typeclass[$v]['classid']] = '10A';
  1373. }
  1374. else
  1375. {
  1376. $clzh = $typeclass[$v]['zh'];
  1377. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1378. {
  1379. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1380. $clzh = $clzh[0];
  1381. }
  1382. $pm[$typeclass[$v]['classid']] = $clzh;
  1383. }
  1384. }
  1385. if(isset($jm[$typeclass[$v]['classid']]))
  1386. {
  1387. if($typeclass[$v]['jm'])
  1388. {
  1389. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1390. }
  1391. }
  1392. }
  1393. }
  1394. $jm = array_filter($jm);//去除空值
  1395. $jm = implode("-",$jm);
  1396. $pm = array_filter($pm);//去除空值
  1397. $zh = implode(" ",$pm);
  1398. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1399. }
  1400. $info_list[$key]['jm'] = $jm;
  1401. $info_list[$key]['zh'] = $zh;
  1402. }
  1403. //取得信息列表
  1404. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1405. //格式化数据
  1406. foreach ($info_listsmt as $key=>$value)
  1407. {
  1408. $shop = $this->shop->read($value['shop']);
  1409. $info_listsmt[$key]['shop'] = $shop['shopname'];
  1410. if($value['waybill'] == '0')
  1411. {
  1412. $info_listsmt[$key]['waybill'] = "";
  1413. }
  1414. $express = $this->express->read($value['express']);
  1415. $info_listsmt[$key]['express'] = $express['servicename'];
  1416. $warehouse = $this->warehouse->read($value['type']);
  1417. $info_listsmt[$key]['type'] = $warehouse['title'];
  1418. if($value['print'] == 1)
  1419. {
  1420. $info_listsmt[$key]['print'] = '不可打印';
  1421. }
  1422. else if($value['print'] == 2)
  1423. {
  1424. $info_listsmt[$key]['print'] = '未打印';
  1425. }
  1426. else if($value['print'] == 3)
  1427. {
  1428. $info_listsmt[$key]['print'] = '已打印';
  1429. }
  1430. if($value['library'] == 1)
  1431. {
  1432. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  1433. }
  1434. else if($value['library'] == 2)
  1435. {
  1436. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  1437. }
  1438. else if($value['library'] == 3)
  1439. {
  1440. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  1441. }
  1442. if($value['librarytime'] == '0')
  1443. {
  1444. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  1445. }
  1446. else
  1447. {
  1448. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1449. }
  1450. $classid = $classid = $this->classid->sku();
  1451. $dbapi = explode(';',trim($value['fpdata'],';'));
  1452. foreach ($dbapi as $va)
  1453. {
  1454. $pm = $classid;
  1455. $jm = $classid;
  1456. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1457. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1458. $ts = explode('|',trim($features,'|'));
  1459. if(stripos($ts[0],',') !== false)
  1460. {
  1461. $ft = explode(',',$ts[0]);
  1462. $features = explode('-',trim($ft[1],'-'));
  1463. $features[] = $ft[0];
  1464. }
  1465. else
  1466. {
  1467. $features = explode('-',trim($ts[0],'-'));
  1468. }
  1469. foreach($features as $k=>$v)
  1470. {
  1471. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1472. {
  1473. if($typeclass[$v]['bm'] != '')
  1474. {
  1475. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1476. }
  1477. }
  1478. if($v != 0 && isset($typeclass[$v]))
  1479. {
  1480. if($typeclass[$v]['classid'] == 13)
  1481. {
  1482. $dj = $typeclass[$v]['title'];
  1483. }
  1484. if($typeclass[$v]['classid'] == 8)
  1485. {
  1486. $ys = $typeclass[$v]['title'];
  1487. }
  1488. if($typeclass[$v]['classid'] == 15)
  1489. {
  1490. $hx = $typeclass[$v]['title'];
  1491. }
  1492. if(isset($pm[$typeclass[$v]['classid']]))
  1493. {
  1494. if($typeclass[$v]['title'] == '9A')
  1495. {
  1496. $pm[$typeclass[$v]['classid']] = '9A';
  1497. }
  1498. else if($typeclass[$v]['title'] == '10A')
  1499. {
  1500. $pm[$typeclass[$v]['classid']] = '10A';
  1501. }
  1502. else
  1503. {
  1504. $clzh = $typeclass[$v]['zh'];
  1505. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1506. {
  1507. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1508. $clzh = $clzh[0];
  1509. }
  1510. $pm[$typeclass[$v]['classid']] = $clzh;
  1511. }
  1512. }
  1513. if(isset($jm[$typeclass[$v]['classid']]))
  1514. {
  1515. if($typeclass[$v]['jm'])
  1516. {
  1517. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1518. }
  1519. }
  1520. }
  1521. }
  1522. $jm = array_filter($jm);//去除空值
  1523. $jm = implode("-",$jm);
  1524. $pm = array_filter($pm);//去除空值
  1525. $zh = implode(" ",$pm);
  1526. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1527. }
  1528. $info_listsmt[$key]['jm'] = $jm;
  1529. $info_listsmt[$key]['zh'] = $zh;
  1530. }
  1531. //取得信息列表
  1532. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1533. //格式化数据
  1534. foreach ($info_listtt as $key=>$value)
  1535. {
  1536. $shop = $this->shop->read($value['shop']);
  1537. $info_listtt[$key]['shop'] = $shop['shopname'];
  1538. if($value['waybill'] == '0')
  1539. {
  1540. $info_listtt[$key]['waybill'] = "";
  1541. }
  1542. $express = $this->express->read($value['express']);
  1543. $info_listtt[$key]['express'] = $express['servicename'];
  1544. $warehouse = $this->warehouse->read($value['type']);
  1545. $info_listtt[$key]['type'] = $warehouse['title'];
  1546. if($value['print'] == 1)
  1547. {
  1548. $info_listtt[$key]['print'] = '不可打印';
  1549. }
  1550. else if($value['print'] == 2)
  1551. {
  1552. $info_listtt[$key]['print'] = '未打印';
  1553. }
  1554. else if($value['print'] == 3)
  1555. {
  1556. $info_listtt[$key]['print'] = '已打印';
  1557. }
  1558. if($value['library'] == 1)
  1559. {
  1560. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  1561. }
  1562. else if($value['library'] == 2)
  1563. {
  1564. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  1565. }
  1566. else if($value['library'] == 3)
  1567. {
  1568. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  1569. }
  1570. if($value['librarytime'] == '0')
  1571. {
  1572. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  1573. }
  1574. else
  1575. {
  1576. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1577. }
  1578. $classid = $classid = $this->classid->sku();
  1579. $dbapi = explode(';',trim($value['fpdata'],';'));
  1580. foreach ($dbapi as $va)
  1581. {
  1582. $pm = $classid;
  1583. $jm = $classid;
  1584. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1585. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1586. $ts = explode('|',trim($features,'|'));
  1587. if(stripos($ts[0],',') !== false)
  1588. {
  1589. $ft = explode(',',$ts[0]);
  1590. $features = explode('-',trim($ft[1],'-'));
  1591. $features[] = $ft[0];
  1592. }
  1593. else
  1594. {
  1595. $features = explode('-',trim($ts[0],'-'));
  1596. }
  1597. foreach($features as $k=>$v)
  1598. {
  1599. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1600. {
  1601. if($typeclass[$v]['bm'] != '')
  1602. {
  1603. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1604. }
  1605. }
  1606. if($v != 0 && isset($typeclass[$v]))
  1607. {
  1608. if($typeclass[$v]['classid'] == 13)
  1609. {
  1610. $dj = $typeclass[$v]['title'];
  1611. }
  1612. if($typeclass[$v]['classid'] == 8)
  1613. {
  1614. $ys = $typeclass[$v]['title'];
  1615. }
  1616. if($typeclass[$v]['classid'] == 15)
  1617. {
  1618. $hx = $typeclass[$v]['title'];
  1619. }
  1620. if(isset($pm[$typeclass[$v]['classid']]))
  1621. {
  1622. if($typeclass[$v]['title'] == '9A')
  1623. {
  1624. $pm[$typeclass[$v]['classid']] = '9A';
  1625. }
  1626. else if($typeclass[$v]['title'] == '10A')
  1627. {
  1628. $pm[$typeclass[$v]['classid']] = '10A';
  1629. }
  1630. else
  1631. {
  1632. $clzh = $typeclass[$v]['zh'];
  1633. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1634. {
  1635. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1636. $clzh = $clzh[0];
  1637. }
  1638. $pm[$typeclass[$v]['classid']] = $clzh;
  1639. }
  1640. }
  1641. if(isset($jm[$typeclass[$v]['classid']]))
  1642. {
  1643. if($typeclass[$v]['jm'])
  1644. {
  1645. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1646. }
  1647. }
  1648. }
  1649. }
  1650. $jm = array_filter($jm);//去除空值
  1651. $jm = implode("-",$jm);
  1652. $pm = array_filter($pm);//去除空值
  1653. $zh = implode(" ",$pm);
  1654. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1655. }
  1656. $info_listtt[$key]['jm'] = $jm;
  1657. $info_listtt[$key]['zh'] = $zh;
  1658. }
  1659. //取得信息列表
  1660. $info_listxw = $this->fullorderxw->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1661. //格式化数据
  1662. foreach ($info_listxw as $key=>$value)
  1663. {
  1664. $shop = $this->shop->read($value['shop']);
  1665. $info_listxw[$key]['shop'] = $shop['shopname'];
  1666. if($value['waybill'] == '0')
  1667. {
  1668. $info_listxw[$key]['waybill'] = "";
  1669. }
  1670. $express = $this->express->read($value['express']);
  1671. $info_listxw[$key]['express'] = $express['servicename'];
  1672. $warehouse = $this->warehouse->read($value['type']);
  1673. $info_listxw[$key]['type'] = $warehouse['title'];
  1674. if($value['print'] == 1)
  1675. {
  1676. $info_listxw[$key]['print'] = '不可打印';
  1677. }
  1678. else if($value['print'] == 2)
  1679. {
  1680. $info_listxw[$key]['print'] = '未打印';
  1681. }
  1682. else if($value['print'] == 3)
  1683. {
  1684. $info_listxw[$key]['print'] = '已打印';
  1685. }
  1686. if($value['library'] == 1)
  1687. {
  1688. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  1689. }
  1690. else if($value['library'] == 2)
  1691. {
  1692. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  1693. }
  1694. else if($value['library'] == 3)
  1695. {
  1696. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  1697. }
  1698. if($value['librarytime'] == '0')
  1699. {
  1700. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  1701. }
  1702. else
  1703. {
  1704. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1705. }
  1706. $classid = $classid = $this->classid->sku();
  1707. $dbapi = explode(';',trim($value['fpdata'],';'));
  1708. foreach ($dbapi as $va)
  1709. {
  1710. $pm = $classid;
  1711. $jm = $classid;
  1712. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1713. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1714. $ts = explode('|',trim($features,'|'));
  1715. if(stripos($ts[0],',') !== false)
  1716. {
  1717. $ft = explode(',',$ts[0]);
  1718. $features = explode('-',trim($ft[1],'-'));
  1719. $features[] = $ft[0];
  1720. }
  1721. else
  1722. {
  1723. $features = explode('-',trim($ts[0],'-'));
  1724. }
  1725. foreach($features as $k=>$v)
  1726. {
  1727. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1728. {
  1729. if($typeclass[$v]['bm'] != '')
  1730. {
  1731. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1732. }
  1733. }
  1734. if($v != 0 && isset($typeclass[$v]))
  1735. {
  1736. if($typeclass[$v]['classid'] == 13)
  1737. {
  1738. $dj = $typeclass[$v]['title'];
  1739. }
  1740. if($typeclass[$v]['classid'] == 8)
  1741. {
  1742. $ys = $typeclass[$v]['title'];
  1743. }
  1744. if($typeclass[$v]['classid'] == 15)
  1745. {
  1746. $hx = $typeclass[$v]['title'];
  1747. }
  1748. if(isset($pm[$typeclass[$v]['classid']]))
  1749. {
  1750. if($typeclass[$v]['title'] == '9A')
  1751. {
  1752. $pm[$typeclass[$v]['classid']] = '9A';
  1753. }
  1754. else if($typeclass[$v]['title'] == '10A')
  1755. {
  1756. $pm[$typeclass[$v]['classid']] = '10A';
  1757. }
  1758. else
  1759. {
  1760. $clzh = $typeclass[$v]['zh'];
  1761. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1762. {
  1763. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1764. $clzh = $clzh[0];
  1765. }
  1766. $pm[$typeclass[$v]['classid']] = $clzh;
  1767. }
  1768. }
  1769. if(isset($jm[$typeclass[$v]['classid']]))
  1770. {
  1771. if($typeclass[$v]['jm'])
  1772. {
  1773. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1774. }
  1775. }
  1776. }
  1777. }
  1778. $jm = array_filter($jm);//去除空值
  1779. $jm = implode("-",$jm);
  1780. $pm = array_filter($pm);//去除空值
  1781. $zh = implode(" ",$pm);
  1782. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1783. }
  1784. $info_listxw[$key]['jm'] = $jm;
  1785. $info_listxw[$key]['zh'] = $zh;
  1786. }
  1787. $title = '订单出库-'.date('Ymd',time());
  1788. $titlename = "<table border=1>".$t."<td>条数</td><td>料品</td><td>品名</td></table>";
  1789. $tail = "\n";
  1790. $filename = $title.".xls";
  1791. $this->excel->get_fz2(array_merge($info_list,$info_listtt,$info_listxw,$info_listsmt),$titlename,$filename,$tail);
  1792. }
  1793. }
  1794. public function _cpexcel()
  1795. {
  1796. if(isset($_SESSION['api']))
  1797. {
  1798. $user = $this->user->get_api($_SESSION['api']);
  1799. $usp = $user;
  1800. $fgshop = "";$sid = "";$excelshop="";
  1801. $usersp = explode('|',trim($user['shop'],'|'));
  1802. foreach ($usersp as $value)
  1803. {
  1804. $fgshop .= " shop = ".$value." or";
  1805. $sid .= " id = ".$value." or";
  1806. }
  1807. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1808. foreach ($userexcel as $value)
  1809. {
  1810. $excelshop .= " shop = ".$value." or";
  1811. }
  1812. if($excelshop != "")
  1813. {
  1814. $excelshop = "(".rtrim($excelshop,'or').")";
  1815. }
  1816. }
  1817. if(isset($_GET['excel']))
  1818. {
  1819. $timetk = $this->input->get('timetk',true);
  1820. $timetj = $this->input->get('timetj',true);
  1821. $shop = $this->input->get('shop',true);
  1822. $library = $this->input->get('library',true);
  1823. $type = $this->input->get('type',true);
  1824. $number = $this->input->get('number',true);
  1825. $orderinfo = $this->input->get('orderinfo',true);
  1826. $so = $this->input->get('so',true);
  1827. $number = $this->input->get('number',true);
  1828. $express = $this->input->get('express',true);
  1829. $timetk = strtotime($timetk);
  1830. $timetj = strtotime($timetj);
  1831. $where = "mergeid = 0";
  1832. if($timetk && $timetj && $library == 2)
  1833. {
  1834. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1835. }
  1836. else
  1837. {
  1838. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  1839. }
  1840. if(isset($_SESSION['api']))
  1841. {
  1842. if($type)
  1843. {
  1844. $where .= " and type = '$type'";
  1845. }
  1846. else
  1847. {
  1848. $uw = '';
  1849. $u = $this->user->get_api($_SESSION['api']);
  1850. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1851. foreach ($u['warehouse'] as $v)
  1852. {
  1853. $uw .= " type = '$v' or";
  1854. }
  1855. $uw = rtrim($uw,'or');
  1856. $uw = " and (".ltrim($uw,' ').")";
  1857. $where .= $uw;
  1858. }
  1859. }
  1860. else
  1861. {
  1862. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  1863. }
  1864. if($shop)
  1865. {
  1866. $where .= " and shop = '$shop'";
  1867. }
  1868. else
  1869. {
  1870. $where .= " and ".$excelshop;
  1871. }
  1872. if($library)
  1873. {
  1874. $where .= " and library = '$library'";
  1875. }
  1876. if($number)
  1877. {
  1878. $where .= " and number = '$number'";
  1879. }
  1880. if($orderinfo)
  1881. {
  1882. $where .= " and orderinfo = '$orderinfo'";
  1883. }
  1884. if($so)
  1885. {
  1886. $where .= " and shipremarks like '%$so%'";
  1887. }
  1888. if($express)
  1889. {
  1890. $where .= " and express = '$express'";
  1891. }
  1892. /* 匹配ID加入 */
  1893. $tc = array();
  1894. $typeclass = $this->typeclass->find_all();
  1895. foreach ($typeclass as $v)
  1896. {
  1897. $tc[$v['id']] = $v['title'];
  1898. }
  1899. $shouldmoney=0;$expressmoney=0;$budget=0;$refundj=0;$refundj=0;$cost=0;$lr=0;
  1900. //取得信息列表
  1901. $info_lista = $this->fullordersmt->find_all($where,'fpdata');
  1902. $info_listb = $this->fullorder->find_all($where,'fpdata');
  1903. $info_list = array_merge($info_lista,$info_listb);
  1904. //格式化数据
  1905. $i = 0;$cpexcel = array();
  1906. foreach ($info_list as $key=>$value)
  1907. {
  1908. if(stripos($value['fpdata'],';') !== false)
  1909. {
  1910. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  1911. foreach ($fpdata as $ke=>$va)
  1912. {
  1913. $title = '';
  1914. $fg = explode('|',$va);
  1915. $fg[0] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$fg[0]);
  1916. $cp = explode('-',rtrim($fg[0],'-'));
  1917. $dj = $tc[$cp[2]];
  1918. if(!isset($cp[3]))
  1919. {
  1920. $ys = json_encode($cp);
  1921. }
  1922. else
  1923. {
  1924. $ys = $tc[$cp[3]];
  1925. }
  1926. unset($cp[0],$cp[1],$cp[2],$cp[3]);
  1927. foreach ($cp as $v)
  1928. {
  1929. $title .= $tc[$v].' ';
  1930. }
  1931. $cpexcel[$ke] = array($fg[5],$dj,$ys,$title,$fg[2]);//内容,尺寸,等级,颜色,数量
  1932. }
  1933. }
  1934. $i++;
  1935. }
  1936. $title = "统计信息";
  1937. $titlename = "<table border=1>
  1938. <tr>
  1939. <td>尺寸</td>
  1940. <td>等级</td>
  1941. <td>颜色</td>
  1942. <td>花型</td>
  1943. <td>数量</td>
  1944. </tr>
  1945. </table>";
  1946. $filename = $title.".xls";
  1947. $tail = "\n";
  1948. $this->excel->get_fz2($cpexcel,$titlename,$filename,$tail);
  1949. }
  1950. }
  1951. public function _orderyz()
  1952. {
  1953. $post = $this->input->post(NULL, TRUE);
  1954. if(isset($post['yz']))
  1955. {
  1956. $yz = $this->input->post('yz',true);
  1957. $number = $this->input->post('number',true);
  1958. $y = $this->fullorder->get_number($number);
  1959. if(!$y)
  1960. {
  1961. $y = $this->fullordersmt->get_number($number);
  1962. if(!$y)
  1963. {
  1964. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  1965. }
  1966. }
  1967. $whlabel = explode('|',trim($y['whlabel'],'|'));
  1968. foreach($whlabel as $k=>$v)
  1969. {
  1970. $w = explode('-',trim($v,'-'));
  1971. $wldata[$w[0]] = $w;
  1972. }
  1973. $whlabellabel = $this->whlabellabel->get_label($yz);
  1974. if(!$whlabellabel)
  1975. {
  1976. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  1977. }
  1978. else
  1979. {
  1980. if(isset($wldata[$whlabellabel['number']]))
  1981. {
  1982. if(!isset($wldata[$whlabellabel['number']][2]))
  1983. {
  1984. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  1985. }
  1986. else if($wldata[$whlabellabel['number']][2] == 0)
  1987. {
  1988. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  1989. }
  1990. }
  1991. else
  1992. {
  1993. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  1994. }
  1995. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  1996. }
  1997. }
  1998. if(isset($post['number']))
  1999. {
  2000. $number = $this->input->post('number',true);
  2001. $f = 'fullorder';
  2002. $y = $this->fullorder->get_number($number);
  2003. if(!$y)
  2004. {
  2005. $f = 'fullordersmt';
  2006. $y = $this->fullordersmt->get_number($number);
  2007. if(!$y)
  2008. {
  2009. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2010. }
  2011. }
  2012. if($y['librarytime'] > 0)
  2013. {
  2014. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  2015. }
  2016. $warehouse = $this->warehouse->read($y['type']);
  2017. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  2018. {
  2019. echo json_encode(array('msg'=>'pz','success'=>false));exit;
  2020. }
  2021. $data = explode('|',trim($y['whlabel'],'|'));
  2022. $fpdata = explode(';',trim($y['fpdata'],';'));
  2023. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  2024. foreach($fpdata as $val)
  2025. {
  2026. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2027. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2028. $fp = explode('|',$val);
  2029. $fp[0] = str_replace(',','-',$fp[0]);
  2030. $value = explode('-',$fp[0]);
  2031. foreach($value as $v)
  2032. {
  2033. $typeclass = $this->typeclass->read($v);
  2034. $zh = explode('|',trim($typeclass['zh'],'|'));
  2035. $pm[$typeclass['classid']] = $zh[0];
  2036. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2037. }
  2038. $scsku = implode("-",$scsku);
  2039. $zh = implode(" ",$pm);
  2040. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2041. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2042. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2043. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2044. $data[$i] = explode('-',$data[$i]);
  2045. for($j=0;$j<$data[$i][1];$j++)
  2046. {
  2047. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  2048. {
  2049. $znum++;//只计算现货
  2050. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  2051. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  2052. }
  2053. else
  2054. {
  2055. //$cp[999+$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#ccc">增加现货</sapn>','c'=>0,'color'=>'#999');//区别位置模式,暂不使用
  2056. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'','t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#e7ba08">增加现货</sapn>','c'=>0,'color'=>'#666');
  2057. }
  2058. $x++;//所有数量
  2059. }
  2060. $i++;
  2061. }
  2062. //ksort($cp);//区别位置模式,暂不使用
  2063. $cp = array_values($cp);
  2064. if($this->$f->save(array('yhs'=>1),$y['id']))
  2065. {
  2066. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  2067. }
  2068. else
  2069. {
  2070. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  2071. }
  2072. }
  2073. if(isset($post['tid']))
  2074. {
  2075. $typeclass = array();
  2076. $tc = $this->typeclass->find_all();
  2077. foreach($tc as $v)
  2078. {
  2079. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  2080. }
  2081. $tid = $this->input->post('tid',true);
  2082. $id = $this->input->post('id',true);
  2083. $number = $this->input->post('n',true);
  2084. $ful = 'fullorder';
  2085. $y = $this->fullorder->get_number($number);
  2086. if(!$y)
  2087. {
  2088. $ful = 'fullordersmt';
  2089. $y = $this->fullordersmt->get_number($number);
  2090. if(!$y)
  2091. {
  2092. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2093. }
  2094. }
  2095. $wtid = $this->whlabellabel->get_label($tid);
  2096. if(!$wtid)
  2097. {
  2098. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2099. }
  2100. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2101. $fpdata = explode(';',trim($y['fpdata'],';'));
  2102. $warehouse = $this->warehouse->read($y['type']);
  2103. $zdkc = $warehouse['bdck'];
  2104. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2105. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2106. if((count($ptc)+count($zsc)) < 1)
  2107. {
  2108. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2109. }
  2110. $this->db->trans_begin();
  2111. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2112. if($zsc)
  2113. {
  2114. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2115. $xrid = $zsc[0]['id'];
  2116. }
  2117. else if($ptc)
  2118. {
  2119. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2120. $xrid = $ptc[0]['id'];
  2121. }
  2122. $xr = $this->$zdkc->read($xrid);
  2123. $features = explode('-',trim($xr['features'],'-'));
  2124. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2125. foreach($features as $kk=>$v)
  2126. {
  2127. if($typeclass[$v]['classid'] == 14)
  2128. {
  2129. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2130. unset($kk);
  2131. }
  2132. }
  2133. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2134. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2135. $wldata = array();
  2136. $fdata = array();
  2137. foreach($whlabel as $k=>$v)
  2138. {
  2139. $w = explode('-',trim($v,'-'));
  2140. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2141. }
  2142. if(!isset($wldata[$id]))
  2143. {
  2144. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2145. }
  2146. if(isset($wldata[$wtid['number']]['sj']))
  2147. {
  2148. $tw = $wldata[$wtid['number']]['sj'];
  2149. if($wtid['number'] != $id)
  2150. {
  2151. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2152. }
  2153. else
  2154. {
  2155. if(isset($tw[2]) && $tw[2] != 0)
  2156. {
  2157. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2158. }
  2159. }
  2160. if($tw[1] > 1)
  2161. {
  2162. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2163. }
  2164. }
  2165. $thfpdata = $y['thfpdata'];
  2166. $w = $wldata[$id]['sj'];
  2167. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2168. $zdkc = $warehouse['bdck'];
  2169. if($w[1] > 1)
  2170. {
  2171. if(isset($w[2]) && $w[2] != 0)
  2172. {
  2173. $hz = explode('~',trim($w[2],'~'));
  2174. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2175. $zd = str_replace($hz[0],'',$w[2]);
  2176. $zd = trim($zd,'~');
  2177. $w[2] = $zd;
  2178. }
  2179. foreach($w as $kk=>$v)
  2180. {
  2181. if($kk == 1)
  2182. {
  2183. $v = $v-1;
  2184. }
  2185. $ww .= $v .'-';
  2186. }
  2187. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2188. foreach($f as $kk=>$v)
  2189. {
  2190. if($kk == 2)
  2191. {
  2192. $v = $v-1;
  2193. $thff .= '1|';
  2194. }
  2195. else
  2196. {
  2197. $thff .= $v .'|';
  2198. }
  2199. $ff .= $v .'|';
  2200. }
  2201. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2202. $thfpdata .= trim($thff,'|');
  2203. }
  2204. else
  2205. {
  2206. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2207. unset($whlabel[$wldata[$id]['wz']]);
  2208. unset($fpdata[$wldata[$id]['wz']]);
  2209. }
  2210. $thfpdata .= '~'.$dataf;
  2211. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2212. $fpdata = implode(";",$fpdata).';'.$dataf;
  2213. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2214. if ($this->db->trans_status() === TRUE)
  2215. {
  2216. $this->db->trans_commit();
  2217. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2218. }
  2219. else
  2220. {
  2221. $this->db->trans_rollback();
  2222. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2223. }
  2224. }
  2225. if(isset($post['yhs']))
  2226. {
  2227. $f = 'fullorder';
  2228. $number = $this->input->post('yhs',true);
  2229. $y = $this->fullorder->get_number($number);
  2230. if(!$y)
  2231. {
  2232. $f = 'fullordersmt';
  2233. $y = $this->fullordersmt->get_number($number);
  2234. }
  2235. if($this->$f->save(array('yhs'=>0),$y['id']))
  2236. {
  2237. echo json_encode(array('success'=>true));exit;
  2238. }
  2239. else
  2240. {
  2241. echo json_encode(array('success'=>false));exit;
  2242. }
  2243. }
  2244. $this->_Template('systemfout_orderyz',$this->data);
  2245. }
  2246. public function _hwyz()
  2247. {
  2248. $post = $this->input->post(NULL, TRUE);
  2249. if(isset($post['yz']))
  2250. {
  2251. $yz = $this->input->post('yz',true);
  2252. $number = $this->input->post('number',true);
  2253. $y = $this->fullorder->get_number($number);
  2254. if(!$y)
  2255. {
  2256. $y = $this->fullordersmt->get_number($number);
  2257. if(!$y)
  2258. {
  2259. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2260. }
  2261. }
  2262. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2263. foreach($whlabel as $k=>$v)
  2264. {
  2265. $w = explode('-',trim($v,'-'));
  2266. $wldata[$w[0]] = $w;
  2267. }
  2268. $whlabellabel = $this->whlabellabel->get_label($yz);
  2269. if(!$whlabellabel)
  2270. {
  2271. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2272. }
  2273. else
  2274. {
  2275. if(isset($wldata[$whlabellabel['number']]))
  2276. {
  2277. if(!isset($wldata[$whlabellabel['number']][2]))
  2278. {
  2279. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2280. }
  2281. else if($wldata[$whlabellabel['number']][2] == 0)
  2282. {
  2283. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2284. }
  2285. }
  2286. else
  2287. {
  2288. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  2289. }
  2290. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  2291. }
  2292. }
  2293. if(isset($post['number']))
  2294. {
  2295. $number = $this->input->post('number',true);
  2296. $f = 'fullorder';
  2297. $y = $this->fullorder->get_number($number);
  2298. if(!$y)
  2299. {
  2300. $f = 'fullordersmt';
  2301. $y = $this->fullordersmt->get_number($number);
  2302. if(!$y)
  2303. {
  2304. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2305. }
  2306. }
  2307. if($y['librarytime'] > 0)
  2308. {
  2309. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  2310. }
  2311. $warehouse = $this->warehouse->read($y['type']);
  2312. $data = explode('|',trim($y['whlabel'],'|'));
  2313. $fpdata = explode(';',trim($y['fpdata'],';'));
  2314. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  2315. foreach($fpdata as $val)
  2316. {
  2317. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2318. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2319. $fp = explode('|',$val);
  2320. $fp[0] = str_replace(',','-',$fp[0]);
  2321. $value = explode('-',$fp[0]);
  2322. foreach($value as $v)
  2323. {
  2324. $typeclass = $this->typeclass->read($v);
  2325. $zh = explode('|',trim($typeclass['zh'],'|'));
  2326. $pm[$typeclass['classid']] = $zh[0];
  2327. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2328. }
  2329. $scsku = implode("-",$scsku);
  2330. $zh = implode(" ",$pm);
  2331. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2332. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2333. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2334. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2335. $data[$i] = explode('-',$data[$i]);
  2336. for($j=0;$j<$data[$i][1];$j++)
  2337. {
  2338. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  2339. {
  2340. $znum++;//只计算现货
  2341. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  2342. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  2343. }
  2344. else
  2345. {
  2346. //$cp[999+$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#ccc">增加现货</sapn>','c'=>0,'color'=>'#999');//区别位置模式,暂不使用
  2347. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'','t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#e7ba08">增加现货</sapn>','c'=>0,'color'=>'#666');
  2348. }
  2349. $x++;//所有数量
  2350. }
  2351. $i++;
  2352. }
  2353. //ksort($cp);//区别位置模式,暂不使用
  2354. $cp = array_values($cp);
  2355. if($this->$f->save(array('yhs'=>1),$y['id']))
  2356. {
  2357. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  2358. {
  2359. echo json_encode(array('rows'=>$cp,'z'=>$znum,'msg'=>'pz','success'=>false));exit;
  2360. }
  2361. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  2362. }
  2363. else
  2364. {
  2365. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  2366. }
  2367. }
  2368. if(isset($post['tid']))
  2369. {
  2370. $typeclass = array();
  2371. $tc = $this->typeclass->find_all();
  2372. foreach($tc as $v)
  2373. {
  2374. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  2375. }
  2376. $tid = $this->input->post('tid',true);
  2377. $id = $this->input->post('id',true);
  2378. $number = $this->input->post('n',true);
  2379. $ful = 'fullorder';
  2380. $y = $this->fullorder->get_number($number);
  2381. if(!$y)
  2382. {
  2383. $ful = 'fullordersmt';
  2384. $y = $this->fullordersmt->get_number($number);
  2385. if(!$y)
  2386. {
  2387. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2388. }
  2389. }
  2390. $wtid = $this->whlabellabel->get_label($tid);
  2391. if(!$wtid)
  2392. {
  2393. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2394. }
  2395. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2396. $fpdata = explode(';',trim($y['fpdata'],';'));
  2397. $warehouse = $this->warehouse->read($y['type']);
  2398. $zdkc = $warehouse['bdck'];
  2399. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2400. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2401. if((count($ptc)+count($zsc)) < 1)
  2402. {
  2403. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2404. }
  2405. $this->db->trans_begin();
  2406. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2407. if($zsc)
  2408. {
  2409. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2410. $xrid = $zsc[0]['id'];
  2411. }
  2412. else if($ptc)
  2413. {
  2414. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2415. $xrid = $ptc[0]['id'];
  2416. }
  2417. $xr = $this->$zdkc->read($xrid);
  2418. $features = explode('-',trim($xr['features'],'-'));
  2419. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2420. foreach($features as $kk=>$v)
  2421. {
  2422. if($typeclass[$v]['classid'] == 14)
  2423. {
  2424. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2425. unset($kk);
  2426. }
  2427. }
  2428. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2429. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2430. $wldata = array();
  2431. $fdata = array();
  2432. foreach($whlabel as $k=>$v)
  2433. {
  2434. $w = explode('-',trim($v,'-'));
  2435. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2436. }
  2437. if(!isset($wldata[$id]))
  2438. {
  2439. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2440. }
  2441. if(isset($wldata[$wtid['number']]['sj']))
  2442. {
  2443. $tw = $wldata[$wtid['number']]['sj'];
  2444. if($wtid['number'] != $id)
  2445. {
  2446. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2447. }
  2448. else
  2449. {
  2450. if(isset($tw[2]) && $tw[2] != 0)
  2451. {
  2452. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2453. }
  2454. }
  2455. if($tw[1] > 1)
  2456. {
  2457. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2458. }
  2459. }
  2460. $thfpdata = $y['thfpdata'];
  2461. $w = $wldata[$id]['sj'];
  2462. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2463. $zdkc = $warehouse['bdck'];
  2464. if($w[1] > 1)
  2465. {
  2466. if(isset($w[2]) && $w[2] != 0)
  2467. {
  2468. $hz = explode('~',trim($w[2],'~'));
  2469. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2470. $zd = str_replace($hz[0],'',$w[2]);
  2471. $zd = trim($zd,'~');
  2472. $w[2] = $zd;
  2473. }
  2474. foreach($w as $kk=>$v)
  2475. {
  2476. if($kk == 1)
  2477. {
  2478. $v = $v-1;
  2479. }
  2480. $ww .= $v .'-';
  2481. }
  2482. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2483. foreach($f as $kk=>$v)
  2484. {
  2485. if($kk == 2)
  2486. {
  2487. $v = $v-1;
  2488. $thff .= '1|';
  2489. }
  2490. else
  2491. {
  2492. $thff .= $v .'|';
  2493. }
  2494. $ff .= $v .'|';
  2495. }
  2496. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2497. $thfpdata .= trim($thff,'|');
  2498. }
  2499. else
  2500. {
  2501. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2502. unset($whlabel[$wldata[$id]['wz']]);
  2503. unset($fpdata[$wldata[$id]['wz']]);
  2504. }
  2505. $thfpdata .= '~'.$dataf;
  2506. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2507. $fpdata = implode(";",$fpdata).';'.$dataf;
  2508. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2509. if ($this->db->trans_status() === TRUE)
  2510. {
  2511. $this->db->trans_commit();
  2512. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2513. }
  2514. else
  2515. {
  2516. $this->db->trans_rollback();
  2517. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2518. }
  2519. }
  2520. if(isset($post['yhs']))
  2521. {
  2522. $f = 'fullorder';
  2523. $number = $this->input->post('yhs',true);
  2524. $y = $this->fullorder->get_number($number);
  2525. if(!$y)
  2526. {
  2527. $f = 'fullordersmt';
  2528. $y = $this->fullordersmt->get_number($number);
  2529. }
  2530. if($this->$f->save(array('yhs'=>0),$y['id']))
  2531. {
  2532. echo json_encode(array('success'=>true));exit;
  2533. }
  2534. else
  2535. {
  2536. echo json_encode(array('success'=>false));exit;
  2537. }
  2538. }
  2539. $this->_Template('systemfout_hwyz',$this->data);
  2540. }
  2541. public function _fouthb()
  2542. {
  2543. $post = $this->input->post(NULL, TRUE);
  2544. $xw = '';
  2545. if(isset($_SESSION['api']))
  2546. {
  2547. $user = $this->user->get_api($_SESSION['api']);
  2548. $usp = $user;
  2549. $fgshop = "";$sid = "";$wid="";$wtype="";
  2550. $usersp = explode('|',trim($user['shop'],'|'));
  2551. $userwh = explode('|',trim($user['warehouse'],'|'));
  2552. foreach ($usersp as $value)
  2553. {
  2554. $fgshop .= " shop = ".$value." or";
  2555. $sid .= " id = ".$value." or";
  2556. }
  2557. foreach ($userwh as $value)
  2558. {
  2559. $wid .= " id = ".$value." or";
  2560. $wtype .= " type = ".$value." or";
  2561. }
  2562. if($user['userid'] == 'xw')
  2563. {
  2564. $xw = 1;
  2565. }
  2566. }
  2567. if(isset($post['page']))
  2568. {
  2569. $page = $this->input->post('page',true);
  2570. $perpage = $this->input->post('perpage',true);
  2571. $timetk = $this->input->post('timetk',true);
  2572. $timetj = $this->input->post('timetj',true);
  2573. $shop = $this->input->post('shop',true);
  2574. $type = $this->input->post('type',true);
  2575. $express = $this->input->post('express',true);
  2576. $number = $this->input->post('number',true);
  2577. $waybill = $this->input->post('waybill',true);
  2578. $librarytime = $this->input->post('librarytime',true);
  2579. $timetk = strtotime($timetk);
  2580. $timetj = strtotime($timetj);
  2581. $where = "mergeid = '1'";
  2582. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  2583. if($shop)
  2584. {
  2585. $where .= " and shop = '$shop'";
  2586. }
  2587. if($number)
  2588. {
  2589. $where .= " and number like '$number%'";
  2590. }
  2591. if($waybill)
  2592. {
  2593. $where .= " and waybill = '$waybill'";
  2594. }
  2595. if($type)
  2596. {
  2597. $where .= " and type = '$type'";
  2598. }
  2599. if($express)
  2600. {
  2601. $where .= " and express = '$express'";
  2602. }
  2603. //数据排序
  2604. $order_str = "librarytime desc";
  2605. if(empty($page))
  2606. {
  2607. $start = 0;
  2608. $perpage = 1;
  2609. }
  2610. else
  2611. {
  2612. $start = ($page - 1)*$perpage;
  2613. }
  2614. //取得信息列表
  2615. $info_list = $this->fullorder->find_all($where,'id,shop,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2616. //格式化数据
  2617. foreach ($info_list as $key=>$value)
  2618. {
  2619. $shop = $this->shop->read($value['shop']);
  2620. $info_list[$key]['shop'] = $shop['shopname'];
  2621. $express = $this->express->read($value['express']);
  2622. $info_list[$key]['express'] = $express['servicename'];
  2623. $warehouse = $this->warehouse->read($value['type']);
  2624. $info_list[$key]['type'] = $warehouse['title'];
  2625. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  2626. }
  2627. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  2628. //格式化数据
  2629. foreach ($info_listtt as $key=>$value)
  2630. {
  2631. $shop = $this->shop->read($value['shop']);
  2632. $info_listtt[$key]['shop'] = $shop['shopname'];
  2633. $express = $this->express->read($value['express']);
  2634. $info_listtt[$key]['express'] = $express['servicename'];
  2635. $warehouse = $this->warehouse->read($value['type']);
  2636. $info_listtt[$key]['type'] = $warehouse['title'];
  2637. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2638. }
  2639. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  2640. //格式化数据
  2641. foreach ($info_listxw as $key=>$value)
  2642. {
  2643. $shop = $this->shop->read($value['shop']);
  2644. $info_listxw[$key]['shop'] = $shop['shopname'];
  2645. $express = $this->express->read($value['express']);
  2646. $info_listxw[$key]['express'] = $express['servicename'];
  2647. $warehouse = $this->warehouse->read($value['type']);
  2648. $info_listxw[$key]['type'] = $warehouse['title'];
  2649. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2650. }
  2651. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  2652. //格式化数据
  2653. foreach ($info_listsmt as $key=>$value)
  2654. {
  2655. $shop = $this->shop->read($value['shop']);
  2656. $info_listsmt[$key]['shop'] = $shop['shopname'];
  2657. $express = $this->express->read($value['express']);
  2658. $info_listsmt[$key]['express'] = $express['servicename'];
  2659. $warehouse = $this->warehouse->read($value['type']);
  2660. $info_listsmt[$key]['type'] = $warehouse['title'];
  2661. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2662. }
  2663. $total = $this->fullorder->find_count($where);
  2664. $total += $this->fullordertt->find_count($where);
  2665. $total += $this->fullorderxw->find_count($where);
  2666. $total += $this->fullordersmt->find_count($where);
  2667. $pagenum = ceil($total/$perpage);
  2668. $over = $total-($start+$perpage);
  2669. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listtt,$info_listxw,$info_listsmt)));
  2670. echo json_encode($rows);exit;
  2671. }
  2672. if(isset($_SESSION['api']))
  2673. {
  2674. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2675. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  2676. $this->data['wlshop'] = $wlshop;
  2677. $this->data['warehouse'] = $warehouse;
  2678. }
  2679. $this->data['xw'] = $xw;
  2680. $this->_Template('systemfout_fouthb',$this->data);
  2681. }
  2682. public function _hb()
  2683. {
  2684. $post = $this->input->post(NULL, TRUE);
  2685. $xw = '';
  2686. if(isset($_SESSION['api']))
  2687. {
  2688. $user = $this->user->get_api($_SESSION['api']);
  2689. $usp = $user;
  2690. $fgshop = "";$sid = "";$wid="";$wtype="";
  2691. $usersp = explode('|',trim($user['shop'],'|'));
  2692. $userwh = explode('|',trim($user['warehouse'],'|'));
  2693. foreach ($usersp as $value)
  2694. {
  2695. $fgshop .= " shop = ".$value." or";
  2696. $sid .= " id = ".$value." or";
  2697. }
  2698. foreach ($userwh as $value)
  2699. {
  2700. $wid .= " id = ".$value." or";
  2701. $wtype .= " type = ".$value." or";
  2702. }
  2703. if($user['userid'] == 'xw')
  2704. {
  2705. $xw = 1;
  2706. }
  2707. }
  2708. if(isset($post['page']))
  2709. {
  2710. $page = $this->input->post('page',true);
  2711. $perpage = $this->input->post('perpage',true);
  2712. $timetk = $this->input->post('timetk',true);
  2713. $timetj = $this->input->post('timetj',true);
  2714. $shop = $this->input->post('shop',true);
  2715. $source = $this->input->post('source',true);
  2716. $orderinfo = $this->input->post('orderinfo',true);
  2717. $number = $this->input->post('number',true);
  2718. $library = $this->input->post('library',true);
  2719. $waybill = $this->input->post('waybill',true);
  2720. $express = $this->input->post('express',true);
  2721. $type = $this->input->post('type',true);
  2722. $lowe = $this->input->post('lowe',true);
  2723. $so = $this->input->post('so',true);
  2724. $librarytime = $this->input->post('librarytime',true);
  2725. $timetk = strtotime($timetk);
  2726. $timetj = strtotime($timetj);
  2727. $cxtime = 'id';
  2728. $where = (isset($_SESSION['api']))?"library!=3 and mergeid = 1 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0' and mergeid = 1";
  2729. if($timetk && $timetj && $library == 1)
  2730. {
  2731. //$cxtime = 'reviewtime';
  2732. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  2733. $where .= " and state != 217";
  2734. }
  2735. else if($timetk && $timetj && $library == 2)
  2736. {
  2737. $cxtime = 'librarytime';
  2738. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  2739. }
  2740. if($shop)
  2741. {
  2742. $where .= " and shop = '$shop'";
  2743. }
  2744. if($number)
  2745. {
  2746. $where .= " and number = '$number'";
  2747. }
  2748. if($library)
  2749. {
  2750. $where .= " and library = '$library'";
  2751. }
  2752. if($waybill)
  2753. {
  2754. $where .= " and waybill = '$waybill'";
  2755. }
  2756. if($express)
  2757. {
  2758. $where .= " and express = '$express'";
  2759. }
  2760. if($orderinfo)
  2761. {
  2762. $where .= " and orderinfo = '$orderinfo'";
  2763. }
  2764. if($type)
  2765. {
  2766. $where .= " and type = '$type'";
  2767. }
  2768. if($lowe)
  2769. {
  2770. $where .= " and shipremarks like '%$lowe%'";
  2771. }
  2772. if($so)
  2773. {
  2774. $where .= " and shipremarks like '%$so%'";
  2775. }
  2776. //数据排序
  2777. $order_str = $cxtime." desc";
  2778. if(empty($page))
  2779. {
  2780. $start = 0;
  2781. $perpage = 1;
  2782. }
  2783. else
  2784. {
  2785. $start = ($page - 1)*$perpage;
  2786. }
  2787. //取得信息列表
  2788. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  2789. //格式化数据
  2790. foreach ($info_list as $key=>$value)
  2791. {
  2792. $shop = $this->shop->read($value['shop']);
  2793. $info_list[$key]['shop'] = $shop['shopname'];
  2794. if($value['waybill'] == '0')
  2795. {
  2796. $info_list[$key]['waybill'] = "";
  2797. }
  2798. $express = $this->express->read($value['express']);
  2799. $info_list[$key]['express'] = $express['servicename'];
  2800. $warehouse = $this->warehouse->read($value['type']);
  2801. $info_list[$key]['type'] = $warehouse['title'];
  2802. if($value['print'] == 1)
  2803. {
  2804. $info_list[$key]['print'] = '不可打印';
  2805. }
  2806. else if($value['print'] == 2)
  2807. {
  2808. $info_list[$key]['print'] = '未打印';
  2809. }
  2810. else if($value['print'] == 3)
  2811. {
  2812. $info_list[$key]['print'] = '已打印';
  2813. }
  2814. if($value['library'] == 1)
  2815. {
  2816. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  2817. }
  2818. else if($value['library'] == 2)
  2819. {
  2820. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  2821. }
  2822. else if($value['library'] == 3)
  2823. {
  2824. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  2825. }
  2826. if($value['librarytime'] == '0')
  2827. {
  2828. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2829. }
  2830. else
  2831. {
  2832. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  2833. }
  2834. $info_list[$key]['orderremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['orderremarks']);
  2835. }
  2836. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  2837. //格式化数据
  2838. foreach ($info_listtt as $key=>$value)
  2839. {
  2840. $shop = $this->shop->read($value['shop']);
  2841. $info_listtt[$key]['shop'] = $shop['shopname'];
  2842. if($value['waybill'] == '0')
  2843. {
  2844. $info_listtt[$key]['waybill'] = "";
  2845. }
  2846. $express = $this->express->read($value['express']);
  2847. $info_listtt[$key]['express'] = $express['servicename'];
  2848. $warehouse = $this->warehouse->read($value['type']);
  2849. $info_listtt[$key]['type'] = $warehouse['title'];
  2850. if($value['print'] == 1)
  2851. {
  2852. $info_listtt[$key]['print'] = '不可打印';
  2853. }
  2854. else if($value['print'] == 2)
  2855. {
  2856. $info_listtt[$key]['print'] = '未打印';
  2857. }
  2858. else if($value['print'] == 3)
  2859. {
  2860. $info_listtt[$key]['print'] = '已打印';
  2861. }
  2862. if($value['library'] == 1)
  2863. {
  2864. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  2865. }
  2866. else if($value['library'] == 2)
  2867. {
  2868. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  2869. }
  2870. else if($value['library'] == 3)
  2871. {
  2872. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  2873. }
  2874. if($value['librarytime'] == '0')
  2875. {
  2876. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  2877. }
  2878. else
  2879. {
  2880. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2881. }
  2882. }
  2883. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  2884. //格式化数据
  2885. foreach ($info_listxw as $key=>$value)
  2886. {
  2887. $shop = $this->shop->read($value['shop']);
  2888. $info_listxw[$key]['shop'] = $shop['shopname'];
  2889. if($value['waybill'] == '0')
  2890. {
  2891. $info_listxw[$key]['waybill'] = "";
  2892. }
  2893. $express = $this->express->read($value['express']);
  2894. $info_listxw[$key]['express'] = $express['servicename'];
  2895. $warehouse = $this->warehouse->read($value['type']);
  2896. $info_listxw[$key]['type'] = $warehouse['title'];
  2897. if($value['print'] == 1)
  2898. {
  2899. $info_listxw[$key]['print'] = '不可打印';
  2900. }
  2901. else if($value['print'] == 2)
  2902. {
  2903. $info_listxw[$key]['print'] = '未打印';
  2904. }
  2905. else if($value['print'] == 3)
  2906. {
  2907. $info_listxw[$key]['print'] = '已打印';
  2908. }
  2909. if($value['library'] == 1)
  2910. {
  2911. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  2912. }
  2913. else if($value['library'] == 2)
  2914. {
  2915. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  2916. }
  2917. else if($value['library'] == 3)
  2918. {
  2919. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  2920. }
  2921. if($value['librarytime'] == '0')
  2922. {
  2923. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  2924. }
  2925. else
  2926. {
  2927. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2928. }
  2929. }
  2930. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  2931. //格式化数据
  2932. foreach ($info_listsmt as $key=>$value)
  2933. {
  2934. $shop = $this->shop->read($value['shop']);
  2935. $info_listsmt[$key]['shop'] = $shop['shopname'];
  2936. if($value['waybill'] == '0')
  2937. {
  2938. $info_listsmt[$key]['waybill'] = "";
  2939. }
  2940. $express = $this->express->read($value['express']);
  2941. $info_listsmt[$key]['express'] = $express['servicename'];
  2942. $warehouse = $this->warehouse->read($value['type']);
  2943. $info_listsmt[$key]['type'] = $warehouse['title'];
  2944. if($value['print'] == 1)
  2945. {
  2946. $info_listsmt[$key]['print'] = '不可打印';
  2947. }
  2948. else if($value['print'] == 2)
  2949. {
  2950. $info_listsmt[$key]['print'] = '未打印';
  2951. }
  2952. else if($value['print'] == 3)
  2953. {
  2954. $info_listsmt[$key]['print'] = '已打印';
  2955. }
  2956. if($value['library'] == 1)
  2957. {
  2958. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  2959. }
  2960. else if($value['library'] == 2)
  2961. {
  2962. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  2963. }
  2964. else if($value['library'] == 3)
  2965. {
  2966. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  2967. }
  2968. if($value['librarytime'] == '0')
  2969. {
  2970. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  2971. }
  2972. else
  2973. {
  2974. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2975. }
  2976. }
  2977. $total = $this->fullorder->find_count($where);
  2978. $total += $this->fullordertt->find_count($where);
  2979. $total += $this->fullorderxw->find_count($where);
  2980. $total += $this->fullordersmt->find_count($where);
  2981. $pagenum = ceil($total/$perpage);
  2982. $over = $total-($start+$perpage);
  2983. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listtt,$info_listxw,$info_listsmt)));
  2984. echo json_encode($rows);exit;
  2985. }
  2986. if(isset($_SESSION['api']))
  2987. {
  2988. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2989. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  2990. $this->data['wlshop'] = $wlshop;
  2991. $this->data['warehouse'] = $warehouse;
  2992. }
  2993. $this->data['xw'] = $xw;
  2994. $this->_Template('systemfout_hb',$this->data);
  2995. }
  2996. }