Systemfout.php 123 KB

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