Systemfout.php 116 KB

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