Systemfout.php 117 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517
  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 && $y['express'] != 78)
  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 && $y['express'] != 78)
  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 && $y['express'] != 2)
  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. $this->db->trans_rollback();
  758. echo json_encode(array('msg'=>'仓库设置错误!','success'=>false));exit;
  759. }
  760. $wh = $this->_fout_db($y,$warehouse,$bdck);
  761. if($wh['fh'] == 2)
  762. {
  763. $kcyz = $this->ck->get_kc($y['state'],$warehouse,$y['shop'],$y['number'],$y['whlabel'],$y['fpdata']);
  764. if($kcyz['t'] == '0')
  765. {
  766. if($kcyz['fpdata'] != '')
  767. {
  768. $x['whlabel'] = $kcyz['whlabel'];
  769. $x['fpdata'] = $kcyz['fpdata'];
  770. $y['whlabel'] = $x['whlabel'];
  771. $this->$fullorder_name->save($x,$y['id']);
  772. }
  773. }
  774. $wh = $this->_fout_db($y,$warehouse,$bdck);
  775. if($wh['fh'] == 2)
  776. {
  777. $this->db->trans_rollback();
  778. echo json_encode(array('msg'=>'库存占用量与实际出库量不符!','success'=>false));exit;
  779. }
  780. }
  781. foreach ($wh['sj'] as $v)
  782. {
  783. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  784. }
  785. }
  786. /**
  787. if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') === false)
  788. {
  789. $whlabel = $this->whlabel->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  790. $cpsl = 0;
  791. $pp = explode('|',trim($y['whlabel'],'|'));
  792. foreach ($pp as $va)
  793. {
  794. $num = explode('-',$va);
  795. $cpsl += $num[1];
  796. }
  797. if(count($whlabel) != $cpsl)
  798. {
  799. echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
  800. }
  801. foreach ($whlabel as $v)
  802. {
  803. $this->whlabel->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  804. }
  805. }
  806. if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') !== false)
  807. {
  808. $wh = $this->specialstock->find_all("zd = '".$y['number']."' and state = '0'");
  809. $cpsl = 0;
  810. $pp = explode('|',trim($y['whlabel'],'|'));
  811. foreach ($pp as $va)
  812. {
  813. $num = explode('-',$va);
  814. if(stripos($num[2],'z') !== false)//如果是特殊库存
  815. {
  816. $cpsl += $num[1];
  817. }
  818. }
  819. if(count($wh) != $cpsl)
  820. {
  821. echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
  822. }
  823. foreach ($wh as $v)
  824. {
  825. if(!$this->specialstock->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']))
  826. {
  827. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  828. }
  829. }
  830. }
  831. **/
  832. /**
  833. if($y['dbapi'] == 99 && $y['scapi'] == 99)
  834. {
  835. $d = $this->apiyy->get_chd($y);
  836. if($d['Data'][0]['m_isSucess'] != 1)
  837. {
  838. echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
  839. }
  840. }
  841. $systemtransfer = $this->systemtransfer->find_all("number = '".$y['number']."'");
  842. if(isset($systemtransfer[0]))
  843. {
  844. foreach ($systemtransfer as $v)
  845. {
  846. if($v['dbapi'] != 99)
  847. {
  848. echo json_encode(array('msg'=>'此订单货物:'.$v['pm'].'没有成功扫布标入库,无法出库!','success'=>false));exit;
  849. }
  850. }
  851. $y['ts'] = count($systemtransfer);
  852. $d = $this->apiyy->get_chd($y);
  853. if($d['Data'][0]['m_isSucess'] != 1)
  854. {
  855. echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
  856. }
  857. }
  858. **/
  859. $shop = $this->shop->read($y['shop']);
  860. if($express['printcode'] == "DHLUSA" && $y['waybill'] != '')
  861. {
  862. $type = $this->typeclass->read($shop['type']);
  863. $y['shoptype'] = $type['title'];
  864. $y['weight'] = $weight;
  865. $d = $this->dhl->get_data_9610($y);
  866. if($d != 1)
  867. {
  868. $this->db->trans_rollback();
  869. $this->allocation->insert(array('order'=>1,'title'=>$y['number'],'content'=>$d));
  870. echo json_encode(array('msg'=>'9610失败,'.$d,'success'=>false));exit;
  871. }
  872. $this->allocation->insert(array('order'=>9610,'title'=>$y['number']));
  873. }
  874. if($fullorder_name == 'fullordersmt')
  875. {
  876. $stt = ($y['waybill']!='')?209:$y['state'];
  877. $post = array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  878. /**
  879. if($this->$fullorder_name->save(array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  880. {
  881. echo json_encode(array('success'=>true));exit;
  882. }
  883. else
  884. {
  885. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  886. }
  887. **/
  888. }
  889. else if(($fullorder_name == 'fullordertt' || $fullorder_name == 'fullorderxw' || $fullorder_name == 'fullorder' || $fullorder_name = 'fullorderamz') && $y['source'] == 1)
  890. {
  891. /**
  892. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  893. {
  894. echo json_encode(array('success'=>true));exit;
  895. }
  896. else
  897. {
  898. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  899. }
  900. **/
  901. $post = array('library'=>2,'state'=>216,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  902. }
  903. else
  904. {
  905. /**
  906. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  907. {
  908. echo json_encode(array('success'=>true));exit;
  909. }
  910. else
  911. {
  912. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  913. }
  914. **/
  915. $post = array('library'=>2,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  916. }
  917. /**
  918. if($fullorder_name == 'fullorder')
  919. {
  920. $orderinfo = preg_replace('/^' . preg_quote($y['shop'], '/') . '/', '', $y['orderinfo']);
  921. $post['incrementId'] = $orderinfo;
  922. $post['trackingNumber'] = $y['waybill'];
  923. $ex = $this->express->read($y['express']);
  924. $post['carrier'] = $ex['iscode'];
  925. $url = 'https://www.romandhair.com/applepay/payment/addTrack';
  926. $ch = curl_init();
  927. curl_setopt($ch,CURLOPT_URL,$url);
  928. curl_setopt($ch, CURLOPT_POST, 1);
  929. curl_setopt($ch, CURLOPT_HEADER, 0);
  930. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  931. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  932. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  933. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  934. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  935. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1800000);
  936. $res = curl_exec($ch);
  937. curl_close($ch);
  938. $res = json_decode($res,true);
  939. if($res['success'] == 0)
  940. {
  941. $this->fullorderpaypal->insert(array('orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'time'=>$time,'cw'=>$res['msg']));//失败
  942. }
  943. else
  944. {
  945. $this->fullorderpaypal->insert(array('orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'time'=>$time,'type'=>1));
  946. }
  947. }
  948. **/
  949. //开始录入执行u9队列的数据
  950. $queue_u9_list = [];
  951. $queue_u9_list[] = [
  952. 'platform'=>$fullorder_name,
  953. 'warehouse'=>$y['type'],
  954. 'type'=>($y['type'] == 5)?11:10, //5代表美仓
  955. 'order_no'=>$y['number'],
  956. 'status'=>0,
  957. 'create_time'=>time(),
  958. 'update_time'=>time(),
  959. ];
  960. //将要执行的队列数据添加进去
  961. foreach($queue_u9_list as $item){
  962. if($item['platform'] != 'fullorderxw'){
  963. // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
  964. // $this->zzquque_u9->insert($item);
  965. // }
  966. if( !in_array($item['warehouse'],[5,7,8,9]) ){
  967. $this->zzquque_u9->insert($item);
  968. }
  969. }
  970. }
  971. $this->logic_ding->sendToDing("u9小单队列监听数据".json_encode($queue_u9_list,JSON_UNESCAPED_UNICODE));
  972. if($outtype == 2 && $y['printnumber'] > 1)
  973. {
  974. $p = json_encode($post);
  975. $this->db->trans_rollback();
  976. echo json_encode(array('msg'=>'该单共打印过'.$y['printnumber'].'次,请注意核对当前发货单是否是最新发货单!','outnumber'=>$y['id'],'post'=>$p,'fullorder_name'=>$fullorder_name,'success'=>false));exit;
  977. }
  978. $this->$fullorder_name->save($post,$y['id']);
  979. //合并订单自动发货
  980. $hb = $this->$fullorder_name->find_all("merge = '".$y['id']."' and id != '".$y['id']."'");
  981. $post['waybill'] = $y['waybill'];
  982. $post['express'] = $y['express'];
  983. $post['printtype'] = $y['printtype'];
  984. $post['ioss'] = $y['ioss'];
  985. $post['review'] = 6;
  986. $post['bx'] = $y['bx'];
  987. $post['qm'] = $y['qm'];
  988. $post['js'] = $y['js'];
  989. //$post['state'] = 216;
  990. $post['print'] = $y['print'];
  991. $post['printtime'] = $y['printtime'];
  992. $post['library'] = 2;
  993. $post['librarytime'] = $time;
  994. $post['libraryconfirm'] = 2;
  995. $post['librarynot'] = '';
  996. foreach ($hb as $v)
  997. {
  998. $post['state'] = $v['state'];
  999. $vshop = $this->shop->read($v['shop']);
  1000. $vwarehouse = $this->warehouse->read($v['type']);
  1001. $this->$fullorder_name->save($post,$v['id']);
  1002. //2025年1月25日发现翔文合并订单发现此问题
  1003. if($warehouse['zd'] == '1'){
  1004. $wh = $this->_fout_db($v,$warehouse,$bdck);
  1005. foreach ($wh['sj'] as $vv)
  1006. {
  1007. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$v['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$vv['id']);
  1008. }
  1009. }
  1010. }
  1011. if ($this->db->trans_status() === TRUE)
  1012. {
  1013. $this->db->trans_commit();
  1014. echo json_encode(array('success'=>true));
  1015. }
  1016. else
  1017. {
  1018. $this->db->trans_rollback();
  1019. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));
  1020. }
  1021. }
  1022. }
  1023. //之所以用订单已占的库存,就循环更新 为什么不用全部检索是因为牵扯到可能是工厂有可能直接生产后 带到成品库 不入成品库 可能会直接发走,所以只检索已占库存的订单 然后更新
  1024. public function _outnumber()//对比占单是否正确
  1025. {
  1026. $post = $this->input->post(NULL, TRUE);
  1027. if(isset($post['outnumber']))
  1028. {
  1029. $post = $this->input->post('post',true);
  1030. $fullorder_name = $this->input->post('fullorder_name',true);
  1031. $outnumber = $this->input->post('outnumber',true);
  1032. $post = json_decode($post,true);
  1033. $y = $this->$fullorder_name->read($outnumber);
  1034. if(empty($y)){
  1035. echo json_encode(array('msg'=>'订单异常不能出库','success'=>false));exit;
  1036. }
  1037. $warehouse = $this->warehouse->read($y['type']);
  1038. if(empty($warehouse)){
  1039. echo json_encode(array('msg'=>'仓库异常不能出库','success'=>false));exit;
  1040. }
  1041. if($y['library']== 2){
  1042. echo json_encode(array('msg'=>'订单已出库,请勿重复出库','success'=>false));exit;
  1043. }
  1044. if($y['library']== 3){
  1045. echo json_encode(array('msg'=>'订单已退库,请勿重复出库','success'=>false));exit;
  1046. }
  1047. $bdck = $warehouse['bdck'];
  1048. if(!empty($bdck)){
  1049. // $warehouse = $this->warehouse->read($y['type']);
  1050. $list = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  1051. $this->db->trans_begin();
  1052. foreach ($list as $v)
  1053. {
  1054. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$post['librarytime'],'time'=>$post['librarytime']),$v['id']);
  1055. }
  1056. $this->$fullorder_name->save($post,$y['id']);
  1057. if ($this->db->trans_status() === TRUE)
  1058. {
  1059. $this->db->trans_commit();
  1060. if($fullorder_name != 'fullorderxw'){
  1061. // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
  1062. // $this->zzquque_u9->insert($item);
  1063. // }
  1064. $y = $this->$fullorder_name->read($outnumber);
  1065. if( !in_array($y['type'],[5,7,8,9]) ){
  1066. $data = [
  1067. 'platform'=>$fullorder_name,
  1068. 'warehouse'=>$y['type'],
  1069. 'type'=>($y['type'] == 5)?11:10, //5代表美仓
  1070. 'order_no'=>$y['number'],
  1071. 'status'=>0,
  1072. 'create_time'=>time(),
  1073. 'update_time'=>time(),
  1074. ];
  1075. $this->zzquque_u9->insert($data);
  1076. }
  1077. }
  1078. echo json_encode(array('success'=>true));
  1079. die;
  1080. }
  1081. else
  1082. {
  1083. $this->db->trans_rollback();
  1084. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));
  1085. die;
  1086. }
  1087. }else{
  1088. $this->$fullorder_name->save($post,$y['id']);
  1089. if($fullorder_name != 'fullorderxw'){
  1090. // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
  1091. // $this->zzquque_u9->insert($item);
  1092. // }
  1093. $y = $this->$fullorder_name->read($outnumber);
  1094. if( !in_array($y['type'],[5,7,8,9]) ){
  1095. $data = [
  1096. 'platform'=>$fullorder_name,
  1097. 'warehouse'=>$y['type'],
  1098. 'type'=>($y['type'] == 5)?11:10, //5代表美仓
  1099. 'order_no'=>$y['number'],
  1100. 'status'=>0,
  1101. 'create_time'=>time(),
  1102. 'update_time'=>time(),
  1103. ];
  1104. $this->zzquque_u9->insert($data);
  1105. }
  1106. }
  1107. echo json_encode(array('success'=>true));
  1108. die;
  1109. }
  1110. }else{
  1111. echo json_encode(array('msg'=>'传参异常,请重试','success'=>false));
  1112. die;
  1113. }
  1114. }
  1115. public function _fout_db($y,$warehouse,$bdck)//对比占单是否正确
  1116. {
  1117. $wh = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  1118. $cpsl = 0;
  1119. $pp = explode('|',trim($y['whlabel'],'|'));
  1120. foreach ($pp as $va)
  1121. {
  1122. $num = explode('-',$va);
  1123. if(isset($num[2]))
  1124. {
  1125. if(stripos($num[2],$warehouse['hz']) !== false)
  1126. {
  1127. $cpsl += $num[1];
  1128. }
  1129. }
  1130. }
  1131. if(count($wh) == $cpsl)
  1132. {
  1133. return array('fh'=>1,'sj'=>$wh);
  1134. }
  1135. else
  1136. {
  1137. return array('fh'=>2);
  1138. }
  1139. }
  1140. public function _fedexhz()
  1141. {
  1142. $post = $this->input->post(NULL, TRUE);
  1143. if(isset($post['id']))
  1144. {
  1145. $id = $this->input->post('id',true);
  1146. $fullorder_name = $this->input->post('name',true);
  1147. $express = $this->input->post('express',true);
  1148. $express = $this->express->read($express);
  1149. $fullorder = $this->$fullorder_name->read($id);
  1150. if($fullorder['type'] == '2')
  1151. {
  1152. $fullorder['type'] = 1;
  1153. }
  1154. $time = time();
  1155. $fullorder = $this->_text($fullorder);//获取所需信息
  1156. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  1157. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  1158. $time = time();
  1159. if($express['printcode'] == "FEDEXGF")
  1160. {
  1161. //$barcode = $this->fedex->get_data($fullorder);//获取联邦快递信息
  1162. //升级的api
  1163. $barcode = $this->fedexv1->get_data($fullorder);//获取联邦快递信息
  1164. if($barcode['x'] == 1)
  1165. {
  1166. $bctime = date('Ymd',$time);
  1167. $Hwaybill = $barcode['waybill'];
  1168. // $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  1169. // $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  1170. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1171. $Hfp = $this->_pdfurl($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  1172. if(isset($barcode['label']) && isset($Hwaybill))
  1173. {
  1174. if($fullorder['waybill'] != "")
  1175. {
  1176. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1177. }
  1178. else
  1179. {
  1180. $oldwaybill = $fullorder['oldwaybill'];
  1181. }
  1182. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1183. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1184. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  1185. {
  1186. $warehouse = $this->warehouse->read($fullorder['type']);
  1187. $text = array();
  1188. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  1189. $text['number'] = $fullorder['number'];
  1190. $text['mode'] = '95';
  1191. $text['pdfnum'] = 1;
  1192. $rows = array('text'=>$text);
  1193. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1194. }
  1195. else
  1196. {
  1197. echo json_encode(array($fullorder['number'].'msg'=>'打印错误,请联系店员','cw'=>'写入数据库错误','success'=>false));exit;
  1198. }
  1199. }
  1200. }
  1201. else
  1202. {
  1203. echo json_encode(array('msg'=>'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  1204. }
  1205. }
  1206. else if($express['printcode'] == "UPS")//接口UPS暂时不打
  1207. {
  1208. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会处理','success'=>false));exit;
  1209. $barcode = $this->ups->get_data($fullorder);//获取快递信息
  1210. if($barcode['x'] == 1)
  1211. {
  1212. $bctime = date('Ymd',$time);
  1213. $Hwaybill = $barcode['waybill'];
  1214. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1215. if(isset($barcode['label']) && isset($Hwaybill))
  1216. {
  1217. if($fullorder['waybill'] != "")
  1218. {
  1219. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1220. }
  1221. else
  1222. {
  1223. $oldwaybill = $fullorder['oldwaybill'];
  1224. }
  1225. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1226. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1227. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1228. {
  1229. $type = 1;
  1230. $text = array('yd'=>'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','data'=>$fullorder,'id'=>$fullorder['id'],'pt'=>$fullorder_name);
  1231. }
  1232. }
  1233. }
  1234. else
  1235. {
  1236. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  1237. }
  1238. }
  1239. else if($express['printcode'] == "DHLHZ")//如果打印过那么重新获取运单
  1240. {
  1241. $barcode = $this->dhlhz->get_data($fullorder);//获取DHL快递信息
  1242. if($barcode['c'] == 1)
  1243. {
  1244. $bctime = date('Ymd',$time);
  1245. $Hwaybill = $barcode['data']['waybill'];
  1246. $Hfp = $this->_pdf($barcode['data']['fp'],'f-'.$Hwaybill,$bctime);
  1247. $Hyd = $this->_pdf($barcode['data']['yd'],'y-'.$Hwaybill,$bctime);
  1248. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  1249. {
  1250. if($fullorder['waybill'] != "")
  1251. {
  1252. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1253. }
  1254. else
  1255. {
  1256. $oldwaybill = $fullorder['oldwaybill'];
  1257. }
  1258. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1259. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删d
  1260. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  1261. {
  1262. $warehouse = $this->warehouse->read($fullorder['type']);
  1263. $text = array();
  1264. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  1265. $text['number'] = $fullorder['number'];
  1266. $text['mode'] = '95';
  1267. $text['pdfnum'] = 1;
  1268. $rows = array('text'=>$text);
  1269. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1270. }
  1271. }
  1272. }
  1273. else
  1274. {
  1275. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  1276. }
  1277. }
  1278. else
  1279. {
  1280. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会或者梦体处理','success'=>false));exit;
  1281. }
  1282. }
  1283. }
  1284. public function _text($fullorder)
  1285. {
  1286. /** 发票地址信息暂时无用
  1287. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1288. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1289. $fullorder['baddress'][1] = $country['ename'];
  1290. **/
  1291. //获取所用相关信息
  1292. $warehouse = $this->warehouse->read($fullorder['type']);
  1293. $country = $this->country->read($fullorder['country']);//订单国家信息
  1294. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1295. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1296. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1297. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1298. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1299. $fullorder['country'] = $country['ename'];//订单国家名
  1300. $fullorder['zhou'] = $country['continent'];//所属州
  1301. $express = $this->express->read($fullorder['express']);
  1302. $fullorder['express'] = $express['servicename'];
  1303. $fullorder['account'] = $express['account'];
  1304. $fullorder['printcode'] = $express['printcode'];
  1305. $fullorder['time'] = date('Y-m-d',time());
  1306. $fullorder['times'] = date('Y-m-d H:i',time());
  1307. //$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1308. // 修复报关编码问题
  1309. $declara_info = $this->customsdeclaration->find("ename like '%".trim($fullorder['sbpm'])."%' ","*");
  1310. $sbbm = "";
  1311. if(empty($declara_info)){
  1312. $sbbm = "";
  1313. }else{
  1314. $sbbm = $declara_info['bname'];
  1315. }
  1316. $fullorder['sbbm']= $sbbm;
  1317. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1318. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1319. $shop = $this->shop->read($fullorder['shop']);
  1320. $fullorder['shop'] = $shop['shopname'];
  1321. return $fullorder;
  1322. }
  1323. public function _lowe()
  1324. {
  1325. $post = $this->input->post(NULL, TRUE);
  1326. if(isset($post['lowe']))
  1327. {
  1328. $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');
  1329. echo json_encode(array('msg'=>$lowe));exit;
  1330. }
  1331. }
  1332. public function _pdf($pdf,$title,$bctime)
  1333. {
  1334. $pdf_path = './data/pdf/'.$bctime.'/';
  1335. $file_base64 = $pdf;
  1336. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  1337. $file_base64 = base64_decode($file_base64);
  1338. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1339. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  1340. return $bctime;
  1341. }
  1342. public function _pdfurl($pdf,$title,$bctime)
  1343. {
  1344. $pdf_path = './data/pdf/'.$bctime.'/';
  1345. $pdf = fopen($pdf,"r");
  1346. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1347. file_put_contents($pdf_path.$title.'.pdf',$pdf);
  1348. return $bctime;
  1349. }
  1350. public function _excel()
  1351. {
  1352. $xw = '';
  1353. if(isset($_SESSION['api']))
  1354. {
  1355. $user = $this->user->get_api($_SESSION['api']);
  1356. $usp = $user;
  1357. $fgshop = "";$sid = "";$wid="";$wtype="";
  1358. $usersp = explode('|',trim($user['shop'],'|'));
  1359. $userwh = explode('|',trim($user['warehouse'],'|'));
  1360. foreach ($usersp as $value)
  1361. {
  1362. $fgshop .= " shop = ".$value." or";
  1363. $sid .= " id = ".$value." or";
  1364. }
  1365. foreach ($userwh as $value)
  1366. {
  1367. $wid .= " id = ".$value." or";
  1368. $wtype .= " type = ".$value." or";
  1369. }
  1370. if($user['userid'] == 'xw')
  1371. {
  1372. $xw = 1;
  1373. }
  1374. }
  1375. if(isset($_GET['fexcel']))
  1376. {
  1377. $dowid = $this->input->get('a');
  1378. $wid = "";
  1379. if($dowid != "")
  1380. {
  1381. $id_arr = explode(',',rtrim($dowid,','));
  1382. foreach ($id_arr as $v)
  1383. {
  1384. $wid .= " id = '$v' or";
  1385. }
  1386. $wid = " and".rtrim($wid,'or');
  1387. }
  1388. $t = $this->input->get('t',true);
  1389. $timetk = $this->input->get('timetk',true);
  1390. $timetj = $this->input->get('timetj',true);
  1391. $shop = $this->input->get('shop',true);
  1392. $source = $this->input->get('source',true);
  1393. $orderinfo = $this->input->get('orderinfo',true);
  1394. $number = $this->input->get('number',true);
  1395. $library = $this->input->get('library',true);
  1396. $waybill = $this->input->get('waybill',true);
  1397. $express = $this->input->get('express',true);
  1398. $type = $this->input->get('type',true);
  1399. $so = $this->input->get('so',true);
  1400. $timetk = strtotime($timetk);
  1401. $timetj = strtotime($timetj);
  1402. $where = (isset($_SESSION['api']))?"library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0'";
  1403. if($timetk && $timetj && $library == 1)
  1404. {
  1405. //$cxtime = 'reviewtime';
  1406. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  1407. $where .= " and state != 217";
  1408. }
  1409. else if($timetk && $timetj && $library == 2)
  1410. {
  1411. $cxtime = 'librarytime';
  1412. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1413. }
  1414. /**
  1415. $where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
  1416. if($timetk && $timetj && $library == 1)
  1417. {
  1418. //$cxtime = 'reviewtime';
  1419. //$where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1420. }
  1421. else if($timetk && $timetj && $library == 2)
  1422. {
  1423. $cxtime = 'librarytime';
  1424. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1425. }
  1426. **/
  1427. if(isset($_SESSION['api']))
  1428. {
  1429. if($type)
  1430. {
  1431. $where .= " and type = '$type'";
  1432. }
  1433. else
  1434. {
  1435. $uw = '';
  1436. $u = $this->user->get_api($_SESSION['api']);
  1437. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1438. foreach ($u['warehouse'] as $v)
  1439. {
  1440. $uw .= " type = '$v' or";
  1441. }
  1442. $uw = rtrim($uw,'or');
  1443. $uw = " and (".ltrim($uw,' ').")";
  1444. $where .= $uw;
  1445. }
  1446. }
  1447. else
  1448. {
  1449. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  1450. }
  1451. if($shop)
  1452. {
  1453. $where .= " and shop = '$shop'";
  1454. }
  1455. if($number)
  1456. {
  1457. $where .= " and number = '$number'";
  1458. }
  1459. if($library)
  1460. {
  1461. $where .= " and library = '$library'";
  1462. }
  1463. if($waybill)
  1464. {
  1465. $where .= " and waybill = '$waybill'";
  1466. }
  1467. if($express)
  1468. {
  1469. $where .= " and express = '$express'";
  1470. }
  1471. if($orderinfo)
  1472. {
  1473. $where .= " and orderinfo = '$orderinfo'";
  1474. }
  1475. if($so)
  1476. {
  1477. $where .= " and shipremarks like '%$so%'";
  1478. }
  1479. //数据排序
  1480. //$order_str = ($print != 3)?"id desc":"librarytime desc";
  1481. $order_str = "librarytime desc";
  1482. if(empty($page))
  1483. {
  1484. $start = 0;
  1485. $perpage = 1;
  1486. }
  1487. else
  1488. {
  1489. $start = ($page - 1)*$perpage;
  1490. }
  1491. $typeclass = array();
  1492. $tclass = $this->typeclass->find_all();
  1493. foreach ($tclass as $v)
  1494. {
  1495. $typeclass[$v['id']] = $v;
  1496. }
  1497. //取得信息列表
  1498. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1499. //格式化数据
  1500. foreach ($info_list as $key=>$value)
  1501. {
  1502. $shop = $this->shop->read($value['shop']);
  1503. $info_list[$key]['shop'] = $shop['shopname'];
  1504. if($value['waybill'] == '0')
  1505. {
  1506. $info_list[$key]['waybill'] = "";
  1507. }
  1508. $express = $this->express->read($value['express']);
  1509. $info_list[$key]['express'] = $express['servicename'];
  1510. $warehouse = $this->warehouse->read($value['type']);
  1511. $info_list[$key]['type'] = $warehouse['title'];
  1512. if($value['print'] == 1)
  1513. {
  1514. $info_list[$key]['print'] = '不可打印';
  1515. }
  1516. else if($value['print'] == 2)
  1517. {
  1518. $info_list[$key]['print'] = '未打印';
  1519. }
  1520. else if($value['print'] == 3)
  1521. {
  1522. $info_list[$key]['print'] = '已打印';
  1523. }
  1524. if($value['library'] == 1)
  1525. {
  1526. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  1527. }
  1528. else if($value['library'] == 2)
  1529. {
  1530. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  1531. }
  1532. else if($value['library'] == 3)
  1533. {
  1534. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  1535. }
  1536. if($value['librarytime'] == '0')
  1537. {
  1538. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  1539. }
  1540. else
  1541. {
  1542. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1543. }
  1544. $classid = $classid = $this->classid->sku();
  1545. $dbapi = explode(';',trim($value['fpdata'],';'));
  1546. $tmp_jm = "";
  1547. $tmp_zh = "";
  1548. foreach ($dbapi as $va)
  1549. {
  1550. $pm = $classid;
  1551. $jm = $classid;
  1552. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1553. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1554. $ts = explode('|',trim($features,'|'));
  1555. if(stripos($ts[0],',') !== false)
  1556. {
  1557. $ft = explode(',',$ts[0]);
  1558. $features = explode('-',trim($ft[1],'-'));
  1559. $features[] = $ft[0];
  1560. }
  1561. else
  1562. {
  1563. $features = explode('-',trim($ts[0],'-'));
  1564. }
  1565. foreach($features as $k=>$v)
  1566. {
  1567. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1568. {
  1569. if($typeclass[$v]['bm'] != '')
  1570. {
  1571. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1572. }
  1573. }
  1574. if($v != 0 && isset($typeclass[$v]))
  1575. {
  1576. if($typeclass[$v]['classid'] == 13)
  1577. {
  1578. $dj = $typeclass[$v]['title'];
  1579. }
  1580. if($typeclass[$v]['classid'] == 8)
  1581. {
  1582. $ys = $typeclass[$v]['title'];
  1583. }
  1584. if($typeclass[$v]['classid'] == 15)
  1585. {
  1586. $hx = $typeclass[$v]['title'];
  1587. }
  1588. if(isset($pm[$typeclass[$v]['classid']]))
  1589. {
  1590. if($typeclass[$v]['title'] == '9A')
  1591. {
  1592. $pm[$typeclass[$v]['classid']] = '9A';
  1593. }
  1594. else if($typeclass[$v]['title'] == '10A')
  1595. {
  1596. $pm[$typeclass[$v]['classid']] = '10A';
  1597. }
  1598. else
  1599. {
  1600. $clzh = $typeclass[$v]['zh'];
  1601. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1602. {
  1603. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1604. $clzh = $clzh[0];
  1605. }
  1606. $pm[$typeclass[$v]['classid']] = $clzh;
  1607. }
  1608. }
  1609. if(isset($jm[$typeclass[$v]['classid']]))
  1610. {
  1611. if($typeclass[$v]['jm'])
  1612. {
  1613. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1614. }
  1615. }
  1616. }
  1617. }
  1618. $jm = array_filter($jm);//去除空值
  1619. $jm = implode("-",$jm);
  1620. $tmp_jm .= $jm.";";
  1621. $pm = array_filter($pm);//去除空值
  1622. $zh = implode(" ",$pm);
  1623. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1624. $tmp_zh .= $zh.";";
  1625. }
  1626. $info_list[$key]['jm'] = trim($tmp_jm,';');
  1627. $info_list[$key]['zh'] = trim($tmp_zh,';');
  1628. }
  1629. //取得信息列表
  1630. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1631. //格式化数据
  1632. foreach ($info_listsmt as $key=>$value)
  1633. {
  1634. $shop = $this->shop->read($value['shop']);
  1635. $info_listsmt[$key]['shop'] = $shop['shopname'];
  1636. if($value['waybill'] == '0')
  1637. {
  1638. $info_listsmt[$key]['waybill'] = "";
  1639. }
  1640. $express = $this->express->read($value['express']);
  1641. $info_listsmt[$key]['express'] = $express['servicename'];
  1642. $warehouse = $this->warehouse->read($value['type']);
  1643. $info_listsmt[$key]['type'] = $warehouse['title'];
  1644. if($value['print'] == 1)
  1645. {
  1646. $info_listsmt[$key]['print'] = '不可打印';
  1647. }
  1648. else if($value['print'] == 2)
  1649. {
  1650. $info_listsmt[$key]['print'] = '未打印';
  1651. }
  1652. else if($value['print'] == 3)
  1653. {
  1654. $info_listsmt[$key]['print'] = '已打印';
  1655. }
  1656. if($value['library'] == 1)
  1657. {
  1658. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  1659. }
  1660. else if($value['library'] == 2)
  1661. {
  1662. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  1663. }
  1664. else if($value['library'] == 3)
  1665. {
  1666. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  1667. }
  1668. if($value['librarytime'] == '0')
  1669. {
  1670. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  1671. }
  1672. else
  1673. {
  1674. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1675. }
  1676. $classid = $classid = $this->classid->sku();
  1677. $dbapi = explode(';',trim($value['fpdata'],';'));
  1678. $tmp_jm = "";
  1679. $tmp_zh = "";
  1680. foreach ($dbapi as $va)
  1681. {
  1682. $pm = $classid;
  1683. $jm = $classid;
  1684. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1685. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1686. $ts = explode('|',trim($features,'|'));
  1687. if(stripos($ts[0],',') !== false)
  1688. {
  1689. $ft = explode(',',$ts[0]);
  1690. $features = explode('-',trim($ft[1],'-'));
  1691. $features[] = $ft[0];
  1692. }
  1693. else
  1694. {
  1695. $features = explode('-',trim($ts[0],'-'));
  1696. }
  1697. foreach($features as $k=>$v)
  1698. {
  1699. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1700. {
  1701. if($typeclass[$v]['bm'] != '')
  1702. {
  1703. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1704. }
  1705. }
  1706. if($v != 0 && isset($typeclass[$v]))
  1707. {
  1708. if($typeclass[$v]['classid'] == 13)
  1709. {
  1710. $dj = $typeclass[$v]['title'];
  1711. }
  1712. if($typeclass[$v]['classid'] == 8)
  1713. {
  1714. $ys = $typeclass[$v]['title'];
  1715. }
  1716. if($typeclass[$v]['classid'] == 15)
  1717. {
  1718. $hx = $typeclass[$v]['title'];
  1719. }
  1720. if(isset($pm[$typeclass[$v]['classid']]))
  1721. {
  1722. if($typeclass[$v]['title'] == '9A')
  1723. {
  1724. $pm[$typeclass[$v]['classid']] = '9A';
  1725. }
  1726. else if($typeclass[$v]['title'] == '10A')
  1727. {
  1728. $pm[$typeclass[$v]['classid']] = '10A';
  1729. }
  1730. else
  1731. {
  1732. $clzh = $typeclass[$v]['zh'];
  1733. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1734. {
  1735. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1736. $clzh = $clzh[0];
  1737. }
  1738. $pm[$typeclass[$v]['classid']] = $clzh;
  1739. }
  1740. }
  1741. if(isset($jm[$typeclass[$v]['classid']]))
  1742. {
  1743. if($typeclass[$v]['jm'])
  1744. {
  1745. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1746. }
  1747. }
  1748. }
  1749. }
  1750. $jm = array_filter($jm);//去除空值
  1751. $jm = implode("-",$jm);
  1752. $pm = array_filter($pm);//去除空值
  1753. $zh = implode(" ",$pm);
  1754. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1755. $tmp_jm .= $jm.";";
  1756. $tmp_zh .= $zh.";";
  1757. }
  1758. $info_listsmt[$key]['jm'] = trim($tmp_jm,';');
  1759. $info_listsmt[$key]['zh'] = trim($tmp_zh,';');
  1760. }
  1761. //取得信息列表
  1762. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1763. //格式化数据
  1764. foreach ($info_listtt as $key=>$value)
  1765. {
  1766. $shop = $this->shop->read($value['shop']);
  1767. $info_listtt[$key]['shop'] = $shop['shopname'];
  1768. if($value['waybill'] == '0')
  1769. {
  1770. $info_listtt[$key]['waybill'] = "";
  1771. }
  1772. $express = $this->express->read($value['express']);
  1773. $info_listtt[$key]['express'] = $express['servicename'];
  1774. $warehouse = $this->warehouse->read($value['type']);
  1775. $info_listtt[$key]['type'] = $warehouse['title'];
  1776. if($value['print'] == 1)
  1777. {
  1778. $info_listtt[$key]['print'] = '不可打印';
  1779. }
  1780. else if($value['print'] == 2)
  1781. {
  1782. $info_listtt[$key]['print'] = '未打印';
  1783. }
  1784. else if($value['print'] == 3)
  1785. {
  1786. $info_listtt[$key]['print'] = '已打印';
  1787. }
  1788. if($value['library'] == 1)
  1789. {
  1790. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  1791. }
  1792. else if($value['library'] == 2)
  1793. {
  1794. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  1795. }
  1796. else if($value['library'] == 3)
  1797. {
  1798. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  1799. }
  1800. if($value['librarytime'] == '0')
  1801. {
  1802. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  1803. }
  1804. else
  1805. {
  1806. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1807. }
  1808. $classid = $classid = $this->classid->sku();
  1809. $tmp_jm = "";
  1810. $tmp_zh = "";
  1811. $dbapi = explode(';',trim($value['fpdata'],';'));
  1812. foreach ($dbapi as $va)
  1813. {
  1814. $pm = $classid;
  1815. $jm = $classid;
  1816. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1817. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1818. $ts = explode('|',trim($features,'|'));
  1819. if(stripos($ts[0],',') !== false)
  1820. {
  1821. $ft = explode(',',$ts[0]);
  1822. $features = explode('-',trim($ft[1],'-'));
  1823. $features[] = $ft[0];
  1824. }
  1825. else
  1826. {
  1827. $features = explode('-',trim($ts[0],'-'));
  1828. }
  1829. foreach($features as $k=>$v)
  1830. {
  1831. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1832. {
  1833. if($typeclass[$v]['bm'] != '')
  1834. {
  1835. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1836. }
  1837. }
  1838. if($v != 0 && isset($typeclass[$v]))
  1839. {
  1840. if($typeclass[$v]['classid'] == 13)
  1841. {
  1842. $dj = $typeclass[$v]['title'];
  1843. }
  1844. if($typeclass[$v]['classid'] == 8)
  1845. {
  1846. $ys = $typeclass[$v]['title'];
  1847. }
  1848. if($typeclass[$v]['classid'] == 15)
  1849. {
  1850. $hx = $typeclass[$v]['title'];
  1851. }
  1852. if(isset($pm[$typeclass[$v]['classid']]))
  1853. {
  1854. if($typeclass[$v]['title'] == '9A')
  1855. {
  1856. $pm[$typeclass[$v]['classid']] = '9A';
  1857. }
  1858. else if($typeclass[$v]['title'] == '10A')
  1859. {
  1860. $pm[$typeclass[$v]['classid']] = '10A';
  1861. }
  1862. else
  1863. {
  1864. $clzh = $typeclass[$v]['zh'];
  1865. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1866. {
  1867. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1868. $clzh = $clzh[0];
  1869. }
  1870. $pm[$typeclass[$v]['classid']] = $clzh;
  1871. }
  1872. }
  1873. if(isset($jm[$typeclass[$v]['classid']]))
  1874. {
  1875. if($typeclass[$v]['jm'])
  1876. {
  1877. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1878. }
  1879. }
  1880. }
  1881. }
  1882. $jm = array_filter($jm);//去除空值
  1883. $jm = implode("-",$jm);
  1884. $pm = array_filter($pm);//去除空值
  1885. $zh = implode(" ",$pm);
  1886. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1887. $tmp_jm .= $jm.";";
  1888. $tmp_zh .= $zh.";";
  1889. }
  1890. $info_listtt[$key]['jm'] = trim($tmp_jm,';');
  1891. $info_listtt[$key]['zh'] = trim($tmp_zh,';');
  1892. }
  1893. //取得信息列表
  1894. $info_listamz = $this->fullorderamz->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1895. //格式化数据
  1896. foreach ($info_listamz as $key=>$value)
  1897. {
  1898. $shop = $this->shop->read($value['shop']);
  1899. $info_listamz[$key]['shop'] = $shop['shopname'];
  1900. if($value['waybill'] == '0')
  1901. {
  1902. $info_listamz[$key]['waybill'] = "";
  1903. }
  1904. $express = $this->express->read($value['express']);
  1905. $info_listamz[$key]['express'] = $express['servicename'];
  1906. $warehouse = $this->warehouse->read($value['type']);
  1907. $info_listamz[$key]['type'] = $warehouse['title'];
  1908. if($value['print'] == 1)
  1909. {
  1910. $info_listamz[$key]['print'] = '不可打印';
  1911. }
  1912. else if($value['print'] == 2)
  1913. {
  1914. $info_listamz[$key]['print'] = '未打印';
  1915. }
  1916. else if($value['print'] == 3)
  1917. {
  1918. $info_listamz[$key]['print'] = '已打印';
  1919. }
  1920. if($value['library'] == 1)
  1921. {
  1922. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  1923. }
  1924. else if($value['library'] == 2)
  1925. {
  1926. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  1927. }
  1928. else if($value['library'] == 3)
  1929. {
  1930. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  1931. }
  1932. if($value['librarytime'] == '0')
  1933. {
  1934. $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
  1935. }
  1936. else
  1937. {
  1938. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1939. }
  1940. $classid = $classid = $this->classid->sku();
  1941. $dbapi = explode(';',trim($value['fpdata'],';'));
  1942. $tmp_jm = "";
  1943. $tmp_zh = "";
  1944. foreach ($dbapi as $va)
  1945. {
  1946. $pm = $classid;
  1947. $jm = $classid;
  1948. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1949. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1950. $ts = explode('|',trim($features,'|'));
  1951. if(stripos($ts[0],',') !== false)
  1952. {
  1953. $ft = explode(',',$ts[0]);
  1954. $features = explode('-',trim($ft[1],'-'));
  1955. $features[] = $ft[0];
  1956. }
  1957. else
  1958. {
  1959. $features = explode('-',trim($ts[0],'-'));
  1960. }
  1961. foreach($features as $k=>$v)
  1962. {
  1963. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1964. {
  1965. if($typeclass[$v]['bm'] != '')
  1966. {
  1967. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1968. }
  1969. }
  1970. if($v != 0 && isset($typeclass[$v]))
  1971. {
  1972. if($typeclass[$v]['classid'] == 13)
  1973. {
  1974. $dj = $typeclass[$v]['title'];
  1975. }
  1976. if($typeclass[$v]['classid'] == 8)
  1977. {
  1978. $ys = $typeclass[$v]['title'];
  1979. }
  1980. if($typeclass[$v]['classid'] == 15)
  1981. {
  1982. $hx = $typeclass[$v]['title'];
  1983. }
  1984. if(isset($pm[$typeclass[$v]['classid']]))
  1985. {
  1986. if($typeclass[$v]['title'] == '9A')
  1987. {
  1988. $pm[$typeclass[$v]['classid']] = '9A';
  1989. }
  1990. else if($typeclass[$v]['title'] == '10A')
  1991. {
  1992. $pm[$typeclass[$v]['classid']] = '10A';
  1993. }
  1994. else
  1995. {
  1996. $clzh = $typeclass[$v]['zh'];
  1997. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1998. {
  1999. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2000. $clzh = $clzh[0];
  2001. }
  2002. $pm[$typeclass[$v]['classid']] = $clzh;
  2003. }
  2004. }
  2005. if(isset($jm[$typeclass[$v]['classid']]))
  2006. {
  2007. if($typeclass[$v]['jm'])
  2008. {
  2009. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2010. }
  2011. }
  2012. }
  2013. }
  2014. $jm = array_filter($jm);//去除空值
  2015. $jm = implode("-",$jm);
  2016. $pm = array_filter($pm);//去除空值
  2017. $zh = implode(" ",$pm);
  2018. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2019. $tmp_jm .= $jm.";";
  2020. $tmp_zh .= $zh.";";
  2021. }
  2022. $info_listamz[$key]['jm'] = trim($tmp_jm,';');
  2023. $info_listamz[$key]['zh'] = trim($tmp_zh,';');
  2024. }
  2025. //取得信息列表
  2026. $info_listxw = $this->fullorderxw->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  2027. //格式化数据
  2028. foreach ($info_listxw as $key=>$value)
  2029. {
  2030. $shop = $this->shop->read($value['shop']);
  2031. $info_listxw[$key]['shop'] = $shop['shopname'];
  2032. if($value['waybill'] == '0')
  2033. {
  2034. $info_listxw[$key]['waybill'] = "";
  2035. }
  2036. $express = $this->express->read($value['express']);
  2037. $info_listxw[$key]['express'] = $express['servicename'];
  2038. $warehouse = $this->warehouse->read($value['type']);
  2039. $info_listxw[$key]['type'] = $warehouse['title'];
  2040. if($value['print'] == 1)
  2041. {
  2042. $info_listxw[$key]['print'] = '不可打印';
  2043. }
  2044. else if($value['print'] == 2)
  2045. {
  2046. $info_listxw[$key]['print'] = '未打印';
  2047. }
  2048. else if($value['print'] == 3)
  2049. {
  2050. $info_listxw[$key]['print'] = '已打印';
  2051. }
  2052. if($value['library'] == 1)
  2053. {
  2054. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  2055. }
  2056. else if($value['library'] == 2)
  2057. {
  2058. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  2059. }
  2060. else if($value['library'] == 3)
  2061. {
  2062. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  2063. }
  2064. if($value['librarytime'] == '0')
  2065. {
  2066. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  2067. }
  2068. else
  2069. {
  2070. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2071. }
  2072. $classid = $classid = $this->classid->sku();
  2073. $dbapi = explode(';',trim($value['fpdata'],';'));
  2074. foreach ($dbapi as $va)
  2075. {
  2076. $pm = $classid;
  2077. $jm = $classid;
  2078. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2079. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2080. $ts = explode('|',trim($features,'|'));
  2081. if(stripos($ts[0],',') !== false)
  2082. {
  2083. $ft = explode(',',$ts[0]);
  2084. $features = explode('-',trim($ft[1],'-'));
  2085. $features[] = $ft[0];
  2086. }
  2087. else
  2088. {
  2089. $features = explode('-',trim($ts[0],'-'));
  2090. }
  2091. foreach($features as $k=>$v)
  2092. {
  2093. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2094. {
  2095. if($typeclass[$v]['bm'] != '')
  2096. {
  2097. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2098. }
  2099. }
  2100. if($v != 0 && isset($typeclass[$v]))
  2101. {
  2102. if($typeclass[$v]['classid'] == 13)
  2103. {
  2104. $dj = $typeclass[$v]['title'];
  2105. }
  2106. if($typeclass[$v]['classid'] == 8)
  2107. {
  2108. $ys = $typeclass[$v]['title'];
  2109. }
  2110. if($typeclass[$v]['classid'] == 15)
  2111. {
  2112. $hx = $typeclass[$v]['title'];
  2113. }
  2114. if(isset($pm[$typeclass[$v]['classid']]))
  2115. {
  2116. if($typeclass[$v]['title'] == '9A')
  2117. {
  2118. $pm[$typeclass[$v]['classid']] = '9A';
  2119. }
  2120. else if($typeclass[$v]['title'] == '10A')
  2121. {
  2122. $pm[$typeclass[$v]['classid']] = '10A';
  2123. }
  2124. else
  2125. {
  2126. $clzh = $typeclass[$v]['zh'];
  2127. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2128. {
  2129. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2130. $clzh = $clzh[0];
  2131. }
  2132. $pm[$typeclass[$v]['classid']] = $clzh;
  2133. }
  2134. }
  2135. if(isset($jm[$typeclass[$v]['classid']]))
  2136. {
  2137. if($typeclass[$v]['jm'])
  2138. {
  2139. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2140. }
  2141. }
  2142. }
  2143. }
  2144. $jm = array_filter($jm);//去除空值
  2145. $jm = implode("-",$jm);
  2146. $pm = array_filter($pm);//去除空值
  2147. $zh = implode(" ",$pm);
  2148. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2149. }
  2150. $info_listxw[$key]['jm'] = $jm;
  2151. $info_listxw[$key]['zh'] = $zh;
  2152. }
  2153. $title = '订单出库-'.date('Ymd',time());
  2154. $t = str_replace("<td>运单号</td>","<td>运单号</td><td>转单号</td>",$t);
  2155. $titlename = "<table border=1>".$t."<td>条数</td><td>料品</td><td>品名</td></table>";
  2156. $tail = "\n";
  2157. $filename = $title.".xls";
  2158. $this->excel->get_fz2(array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt),$titlename,$filename,$tail);
  2159. }
  2160. }
  2161. public function _cpexcel()
  2162. {
  2163. if(isset($_SESSION['api']))
  2164. {
  2165. $user = $this->user->get_api($_SESSION['api']);
  2166. $usp = $user;
  2167. $fgshop = "";$sid = "";$excelshop="";
  2168. $usersp = explode('|',trim($user['shop'],'|'));
  2169. foreach ($usersp as $value)
  2170. {
  2171. $fgshop .= " shop = ".$value." or";
  2172. $sid .= " id = ".$value." or";
  2173. }
  2174. $userexcel = explode('|',trim($user['excelshop'],'|'));
  2175. foreach ($userexcel as $value)
  2176. {
  2177. $excelshop .= " shop = ".$value." or";
  2178. }
  2179. if($excelshop != "")
  2180. {
  2181. $excelshop = "(".rtrim($excelshop,'or').")";
  2182. }
  2183. }
  2184. if(isset($_GET['excel']))
  2185. {
  2186. $timetk = $this->input->get('timetk',true);
  2187. $timetj = $this->input->get('timetj',true);
  2188. $shop = $this->input->get('shop',true);
  2189. $library = $this->input->get('library',true);
  2190. $type = $this->input->get('type',true);
  2191. $number = $this->input->get('number',true);
  2192. $orderinfo = $this->input->get('orderinfo',true);
  2193. $so = $this->input->get('so',true);
  2194. $number = $this->input->get('number',true);
  2195. $express = $this->input->get('express',true);
  2196. $timetk = strtotime($timetk);
  2197. $timetj = strtotime($timetj);
  2198. $where = "mergeid = 0";
  2199. if($timetk && $timetj && $library == 2)
  2200. {
  2201. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  2202. }
  2203. else
  2204. {
  2205. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  2206. }
  2207. if(isset($_SESSION['api']))
  2208. {
  2209. if($type)
  2210. {
  2211. $where .= " and type = '$type'";
  2212. }
  2213. else
  2214. {
  2215. $uw = '';
  2216. $u = $this->user->get_api($_SESSION['api']);
  2217. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  2218. foreach ($u['warehouse'] as $v)
  2219. {
  2220. $uw .= " type = '$v' or";
  2221. }
  2222. $uw = rtrim($uw,'or');
  2223. $uw = " and (".ltrim($uw,' ').")";
  2224. $where .= $uw;
  2225. }
  2226. }
  2227. else
  2228. {
  2229. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  2230. }
  2231. if($shop)
  2232. {
  2233. $where .= " and shop = '$shop'";
  2234. }
  2235. else
  2236. {
  2237. $where .= " and ".$excelshop;
  2238. }
  2239. if($library)
  2240. {
  2241. $where .= " and library = '$library'";
  2242. }
  2243. if($number)
  2244. {
  2245. $where .= " and number = '$number'";
  2246. }
  2247. if($orderinfo)
  2248. {
  2249. $where .= " and orderinfo = '$orderinfo'";
  2250. }
  2251. if($so)
  2252. {
  2253. $where .= " and shipremarks like '%$so%'";
  2254. }
  2255. if($express)
  2256. {
  2257. $where .= " and express = '$express'";
  2258. }
  2259. /* 匹配ID加入 */
  2260. $tc = array();
  2261. $typeclass = $this->typeclass->find_all();
  2262. foreach ($typeclass as $v)
  2263. {
  2264. $tc[$v['id']] = $v['title'];
  2265. }
  2266. $shouldmoney=0;$expressmoney=0;$budget=0;$refundj=0;$refundj=0;$cost=0;$lr=0;
  2267. //取得信息列表
  2268. $info_lista = $this->fullordersmt->find_all($where,'fpdata');
  2269. $info_listb = $this->fullorder->find_all($where,'fpdata');
  2270. $info_list = array_merge($info_lista,$info_listb);
  2271. //格式化数据
  2272. $i = 0;$cpexcel = array();
  2273. foreach ($info_list as $key=>$value)
  2274. {
  2275. if(stripos($value['fpdata'],';') !== false)
  2276. {
  2277. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  2278. foreach ($fpdata as $ke=>$va)
  2279. {
  2280. $title = '';
  2281. $fg = explode('|',$va);
  2282. $fg[0] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$fg[0]);
  2283. $cp = explode('-',rtrim($fg[0],'-'));
  2284. $dj = $tc[$cp[2]];
  2285. if(!isset($cp[3]))
  2286. {
  2287. $ys = json_encode($cp);
  2288. }
  2289. else
  2290. {
  2291. $ys = $tc[$cp[3]];
  2292. }
  2293. unset($cp[0],$cp[1],$cp[2],$cp[3]);
  2294. foreach ($cp as $v)
  2295. {
  2296. $title .= $tc[$v].' ';
  2297. }
  2298. $cpexcel[$ke] = array($fg[5],$dj,$ys,$title,$fg[2]);//内容,尺寸,等级,颜色,数量
  2299. }
  2300. }
  2301. $i++;
  2302. }
  2303. $title = "统计信息";
  2304. $titlename = "<table border=1>
  2305. <tr>
  2306. <td>尺寸</td>
  2307. <td>等级</td>
  2308. <td>颜色</td>
  2309. <td>花型</td>
  2310. <td>数量</td>
  2311. </tr>
  2312. </table>";
  2313. $filename = $title.".xls";
  2314. $tail = "\n";
  2315. $this->excel->get_fz2($cpexcel,$titlename,$filename,$tail);
  2316. }
  2317. }
  2318. public function _orderyz()
  2319. {
  2320. $post = $this->input->post(NULL, TRUE);
  2321. if(isset($post['yz']))
  2322. {
  2323. $yz = $this->input->post('yz',true);
  2324. $number = $this->input->post('number',true);
  2325. $y = $this->fullorder->get_number($number);
  2326. if(!$y)
  2327. {
  2328. $y = $this->fullordersmt->get_number($number);
  2329. if(!$y)
  2330. {
  2331. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2332. }
  2333. }
  2334. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2335. foreach($whlabel as $k=>$v)
  2336. {
  2337. $w = explode('-',trim($v,'-'));
  2338. $wldata[$w[0]] = $w;
  2339. }
  2340. $whlabellabel = $this->whlabellabel->get_label($yz);
  2341. if(!$whlabellabel)
  2342. {
  2343. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2344. }
  2345. else
  2346. {
  2347. if(isset($wldata[$whlabellabel['number']]))
  2348. {
  2349. if(!isset($wldata[$whlabellabel['number']][2]))
  2350. {
  2351. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2352. }
  2353. else if($wldata[$whlabellabel['number']][2] == 0)
  2354. {
  2355. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2356. }
  2357. }
  2358. else
  2359. {
  2360. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  2361. }
  2362. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  2363. }
  2364. }
  2365. if(isset($post['number']))
  2366. {
  2367. $number = $this->input->post('number',true);
  2368. $f = 'fullorder';
  2369. $y = $this->fullorder->get_number($number);
  2370. if(!$y)
  2371. {
  2372. $f = 'fullordersmt';
  2373. $y = $this->fullordersmt->get_number($number);
  2374. if(!$y)
  2375. {
  2376. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2377. }
  2378. }
  2379. if($y['librarytime'] > 0)
  2380. {
  2381. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  2382. }
  2383. $warehouse = $this->warehouse->read($y['type']);
  2384. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  2385. {
  2386. echo json_encode(array('msg'=>'pz','success'=>false));exit;
  2387. }
  2388. $data = explode('|',trim($y['whlabel'],'|'));
  2389. $fpdata = explode(';',trim($y['fpdata'],';'));
  2390. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  2391. foreach($fpdata as $val)
  2392. {
  2393. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2394. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2395. $fp = explode('|',$val);
  2396. $fp[0] = str_replace(',','-',$fp[0]);
  2397. $value = explode('-',$fp[0]);
  2398. foreach($value as $v)
  2399. {
  2400. $typeclass = $this->typeclass->read($v);
  2401. $zh = explode('|',trim($typeclass['zh'],'|'));
  2402. $pm[$typeclass['classid']] = $zh[0];
  2403. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2404. }
  2405. $scsku = implode("-",$scsku);
  2406. $zh = implode(" ",$pm);
  2407. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2408. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2409. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2410. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2411. $data[$i] = explode('-',$data[$i]);
  2412. for($j=0;$j<$data[$i][1];$j++)
  2413. {
  2414. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  2415. {
  2416. $znum++;//只计算现货
  2417. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  2418. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  2419. }
  2420. else
  2421. {
  2422. //$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');//区别位置模式,暂不使用
  2423. $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');
  2424. }
  2425. $x++;//所有数量
  2426. }
  2427. $i++;
  2428. }
  2429. //ksort($cp);//区别位置模式,暂不使用
  2430. $cp = array_values($cp);
  2431. if($this->$f->save(array('yhs'=>1),$y['id']))
  2432. {
  2433. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  2434. }
  2435. else
  2436. {
  2437. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  2438. }
  2439. }
  2440. if(isset($post['tid']))
  2441. {
  2442. $typeclass = array();
  2443. $tc = $this->typeclass->find_all();
  2444. foreach($tc as $v)
  2445. {
  2446. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  2447. }
  2448. $tid = $this->input->post('tid',true);
  2449. $id = $this->input->post('id',true);
  2450. $number = $this->input->post('n',true);
  2451. $ful = 'fullorder';
  2452. $y = $this->fullorder->get_number($number);
  2453. if(!$y)
  2454. {
  2455. $ful = 'fullordersmt';
  2456. $y = $this->fullordersmt->get_number($number);
  2457. if(!$y)
  2458. {
  2459. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2460. }
  2461. }
  2462. $wtid = $this->whlabellabel->get_label($tid);
  2463. if(!$wtid)
  2464. {
  2465. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2466. }
  2467. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2468. $fpdata = explode(';',trim($y['fpdata'],';'));
  2469. $warehouse = $this->warehouse->read($y['type']);
  2470. $zdkc = $warehouse['bdck'];
  2471. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2472. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2473. if((count($ptc)+count($zsc)) < 1)
  2474. {
  2475. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2476. }
  2477. $this->db->trans_begin();
  2478. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2479. if($zsc)
  2480. {
  2481. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2482. $xrid = $zsc[0]['id'];
  2483. }
  2484. else if($ptc)
  2485. {
  2486. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2487. $xrid = $ptc[0]['id'];
  2488. }
  2489. $xr = $this->$zdkc->read($xrid);
  2490. $features = explode('-',trim($xr['features'],'-'));
  2491. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2492. foreach($features as $kk=>$v)
  2493. {
  2494. if($typeclass[$v]['classid'] == 14)
  2495. {
  2496. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2497. unset($kk);
  2498. }
  2499. }
  2500. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2501. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2502. $wldata = array();
  2503. $fdata = array();
  2504. foreach($whlabel as $k=>$v)
  2505. {
  2506. $w = explode('-',trim($v,'-'));
  2507. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2508. }
  2509. if(!isset($wldata[$id]))
  2510. {
  2511. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2512. }
  2513. if(isset($wldata[$wtid['number']]['sj']))
  2514. {
  2515. $tw = $wldata[$wtid['number']]['sj'];
  2516. if($wtid['number'] != $id)
  2517. {
  2518. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2519. }
  2520. else
  2521. {
  2522. if(isset($tw[2]) && $tw[2] != 0)
  2523. {
  2524. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2525. }
  2526. }
  2527. if($tw[1] > 1)
  2528. {
  2529. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2530. }
  2531. }
  2532. $thfpdata = $y['thfpdata'];
  2533. $w = $wldata[$id]['sj'];
  2534. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2535. $zdkc = $warehouse['bdck'];
  2536. if($w[1] > 1)
  2537. {
  2538. if(isset($w[2]) && $w[2] != 0)
  2539. {
  2540. $hz = explode('~',trim($w[2],'~'));
  2541. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2542. $zd = str_replace($hz[0],'',$w[2]);
  2543. $zd = trim($zd,'~');
  2544. $w[2] = $zd;
  2545. }
  2546. foreach($w as $kk=>$v)
  2547. {
  2548. if($kk == 1)
  2549. {
  2550. $v = $v-1;
  2551. }
  2552. $ww .= $v .'-';
  2553. }
  2554. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2555. foreach($f as $kk=>$v)
  2556. {
  2557. if($kk == 2)
  2558. {
  2559. $v = $v-1;
  2560. $thff .= '1|';
  2561. }
  2562. else
  2563. {
  2564. $thff .= $v .'|';
  2565. }
  2566. $ff .= $v .'|';
  2567. }
  2568. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2569. $thfpdata .= trim($thff,'|');
  2570. }
  2571. else
  2572. {
  2573. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2574. unset($whlabel[$wldata[$id]['wz']]);
  2575. unset($fpdata[$wldata[$id]['wz']]);
  2576. }
  2577. $thfpdata .= '~'.$dataf;
  2578. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2579. $fpdata = implode(";",$fpdata).';'.$dataf;
  2580. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2581. if ($this->db->trans_status() === TRUE)
  2582. {
  2583. $this->db->trans_commit();
  2584. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2585. }
  2586. else
  2587. {
  2588. $this->db->trans_rollback();
  2589. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2590. }
  2591. }
  2592. if(isset($post['yhs']))
  2593. {
  2594. $f = 'fullorder';
  2595. $number = $this->input->post('yhs',true);
  2596. $y = $this->fullorder->get_number($number);
  2597. if(!$y)
  2598. {
  2599. $f = 'fullordersmt';
  2600. $y = $this->fullordersmt->get_number($number);
  2601. }
  2602. if($this->$f->save(array('yhs'=>0),$y['id']))
  2603. {
  2604. echo json_encode(array('success'=>true));exit;
  2605. }
  2606. else
  2607. {
  2608. echo json_encode(array('success'=>false));exit;
  2609. }
  2610. }
  2611. $this->_Template('systemfout_orderyz',$this->data);
  2612. }
  2613. public function _hwyz()
  2614. {
  2615. $post = $this->input->post(NULL, TRUE);
  2616. if(isset($post['yz']))
  2617. {
  2618. $yz = $this->input->post('yz',true);
  2619. $number = $this->input->post('number',true);
  2620. $y = $this->fullorder->get_number($number);
  2621. if(!$y)
  2622. {
  2623. $y = $this->fullordersmt->get_number($number);
  2624. if(!$y)
  2625. {
  2626. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2627. }
  2628. }
  2629. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2630. foreach($whlabel as $k=>$v)
  2631. {
  2632. $w = explode('-',trim($v,'-'));
  2633. $wldata[$w[0]] = $w;
  2634. }
  2635. $whlabellabel = $this->whlabellabel->get_label($yz);
  2636. if(!$whlabellabel)
  2637. {
  2638. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2639. }
  2640. else
  2641. {
  2642. if(isset($wldata[$whlabellabel['number']]))
  2643. {
  2644. if(!isset($wldata[$whlabellabel['number']][2]))
  2645. {
  2646. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2647. }
  2648. else if($wldata[$whlabellabel['number']][2] == 0)
  2649. {
  2650. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2651. }
  2652. }
  2653. else
  2654. {
  2655. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  2656. }
  2657. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  2658. }
  2659. }
  2660. if(isset($post['number']))
  2661. {
  2662. $number = $this->input->post('number',true);
  2663. $f = 'fullorder';
  2664. $y = $this->fullorder->get_number($number);
  2665. if(!$y)
  2666. {
  2667. $f = 'fullordersmt';
  2668. $y = $this->fullordersmt->get_number($number);
  2669. if(!$y)
  2670. {
  2671. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2672. }
  2673. }
  2674. if($y['librarytime'] > 0)
  2675. {
  2676. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  2677. }
  2678. $warehouse = $this->warehouse->read($y['type']);
  2679. $data = explode('|',trim($y['whlabel'],'|'));
  2680. $fpdata = explode(';',trim($y['fpdata'],';'));
  2681. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  2682. foreach($fpdata as $val)
  2683. {
  2684. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2685. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2686. $fp = explode('|',$val);
  2687. $fp[0] = str_replace(',','-',$fp[0]);
  2688. $value = explode('-',$fp[0]);
  2689. foreach($value as $v)
  2690. {
  2691. $typeclass = $this->typeclass->read($v);
  2692. $zh = explode('|',trim($typeclass['zh'],'|'));
  2693. $pm[$typeclass['classid']] = $zh[0];
  2694. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2695. }
  2696. $scsku = implode("-",$scsku);
  2697. $zh = implode(" ",$pm);
  2698. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2699. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2700. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2701. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2702. $data[$i] = explode('-',$data[$i]);
  2703. for($j=0;$j<$data[$i][1];$j++)
  2704. {
  2705. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  2706. {
  2707. $znum++;//只计算现货
  2708. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  2709. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  2710. }
  2711. else
  2712. {
  2713. //$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');//区别位置模式,暂不使用
  2714. $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');
  2715. }
  2716. $x++;//所有数量
  2717. }
  2718. $i++;
  2719. }
  2720. //ksort($cp);//区别位置模式,暂不使用
  2721. $cp = array_values($cp);
  2722. if($this->$f->save(array('yhs'=>1),$y['id']))
  2723. {
  2724. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  2725. {
  2726. echo json_encode(array('rows'=>$cp,'z'=>$znum,'msg'=>'pz','success'=>false));exit;
  2727. }
  2728. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  2729. }
  2730. else
  2731. {
  2732. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  2733. }
  2734. }
  2735. if(isset($post['tid']))
  2736. {
  2737. $typeclass = array();
  2738. $tc = $this->typeclass->find_all();
  2739. foreach($tc as $v)
  2740. {
  2741. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  2742. }
  2743. $tid = $this->input->post('tid',true);
  2744. $id = $this->input->post('id',true);
  2745. $number = $this->input->post('n',true);
  2746. $ful = 'fullorder';
  2747. $y = $this->fullorder->get_number($number);
  2748. if(!$y)
  2749. {
  2750. $ful = 'fullordersmt';
  2751. $y = $this->fullordersmt->get_number($number);
  2752. if(!$y)
  2753. {
  2754. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2755. }
  2756. }
  2757. $wtid = $this->whlabellabel->get_label($tid);
  2758. if(!$wtid)
  2759. {
  2760. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2761. }
  2762. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2763. $fpdata = explode(';',trim($y['fpdata'],';'));
  2764. $warehouse = $this->warehouse->read($y['type']);
  2765. $zdkc = $warehouse['bdck'];
  2766. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2767. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2768. if((count($ptc)+count($zsc)) < 1)
  2769. {
  2770. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2771. }
  2772. $this->db->trans_begin();
  2773. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2774. if($zsc)
  2775. {
  2776. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2777. $xrid = $zsc[0]['id'];
  2778. }
  2779. else if($ptc)
  2780. {
  2781. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2782. $xrid = $ptc[0]['id'];
  2783. }
  2784. $xr = $this->$zdkc->read($xrid);
  2785. $features = explode('-',trim($xr['features'],'-'));
  2786. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2787. foreach($features as $kk=>$v)
  2788. {
  2789. if($typeclass[$v]['classid'] == 14)
  2790. {
  2791. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2792. unset($kk);
  2793. }
  2794. }
  2795. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2796. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2797. $wldata = array();
  2798. $fdata = array();
  2799. foreach($whlabel as $k=>$v)
  2800. {
  2801. $w = explode('-',trim($v,'-'));
  2802. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2803. }
  2804. if(!isset($wldata[$id]))
  2805. {
  2806. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2807. }
  2808. if(isset($wldata[$wtid['number']]['sj']))
  2809. {
  2810. $tw = $wldata[$wtid['number']]['sj'];
  2811. if($wtid['number'] != $id)
  2812. {
  2813. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2814. }
  2815. else
  2816. {
  2817. if(isset($tw[2]) && $tw[2] != 0)
  2818. {
  2819. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2820. }
  2821. }
  2822. if($tw[1] > 1)
  2823. {
  2824. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2825. }
  2826. }
  2827. $thfpdata = $y['thfpdata'];
  2828. $w = $wldata[$id]['sj'];
  2829. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2830. $zdkc = $warehouse['bdck'];
  2831. if($w[1] > 1)
  2832. {
  2833. if(isset($w[2]) && $w[2] != 0)
  2834. {
  2835. $hz = explode('~',trim($w[2],'~'));
  2836. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2837. $zd = str_replace($hz[0],'',$w[2]);
  2838. $zd = trim($zd,'~');
  2839. $w[2] = $zd;
  2840. }
  2841. foreach($w as $kk=>$v)
  2842. {
  2843. if($kk == 1)
  2844. {
  2845. $v = $v-1;
  2846. }
  2847. $ww .= $v .'-';
  2848. }
  2849. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2850. foreach($f as $kk=>$v)
  2851. {
  2852. if($kk == 2)
  2853. {
  2854. $v = $v-1;
  2855. $thff .= '1|';
  2856. }
  2857. else
  2858. {
  2859. $thff .= $v .'|';
  2860. }
  2861. $ff .= $v .'|';
  2862. }
  2863. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2864. $thfpdata .= trim($thff,'|');
  2865. }
  2866. else
  2867. {
  2868. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2869. unset($whlabel[$wldata[$id]['wz']]);
  2870. unset($fpdata[$wldata[$id]['wz']]);
  2871. }
  2872. $thfpdata .= '~'.$dataf;
  2873. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2874. $fpdata = implode(";",$fpdata).';'.$dataf;
  2875. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2876. if ($this->db->trans_status() === TRUE)
  2877. {
  2878. $this->db->trans_commit();
  2879. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2880. }
  2881. else
  2882. {
  2883. $this->db->trans_rollback();
  2884. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2885. }
  2886. }
  2887. if(isset($post['yhs']))
  2888. {
  2889. $f = 'fullorder';
  2890. $number = $this->input->post('yhs',true);
  2891. $y = $this->fullorder->get_number($number);
  2892. if(!$y)
  2893. {
  2894. $f = 'fullordersmt';
  2895. $y = $this->fullordersmt->get_number($number);
  2896. }
  2897. if($this->$f->save(array('yhs'=>0),$y['id']))
  2898. {
  2899. echo json_encode(array('success'=>true));exit;
  2900. }
  2901. else
  2902. {
  2903. echo json_encode(array('success'=>false));exit;
  2904. }
  2905. }
  2906. $this->_Template('systemfout_hwyz',$this->data);
  2907. }
  2908. public function _fouthb()
  2909. {
  2910. $post = $this->input->post(NULL, TRUE);
  2911. $xw = '';
  2912. if(isset($_SESSION['api']))
  2913. {
  2914. $user = $this->user->get_api($_SESSION['api']);
  2915. $usp = $user;
  2916. $fgshop = "";$sid = "";$wid="";$wtype="";
  2917. $usersp = explode('|',trim($user['shop'],'|'));
  2918. $userwh = explode('|',trim($user['warehouse'],'|'));
  2919. foreach ($usersp as $value)
  2920. {
  2921. $fgshop .= " shop = ".$value." or";
  2922. $sid .= " id = ".$value." or";
  2923. }
  2924. foreach ($userwh as $value)
  2925. {
  2926. $wid .= " id = ".$value." or";
  2927. $wtype .= " type = ".$value." or";
  2928. }
  2929. if($user['userid'] == 'xw')
  2930. {
  2931. $xw = 1;
  2932. }
  2933. }
  2934. if(isset($post['page']))
  2935. {
  2936. $page = $this->input->post('page',true);
  2937. $perpage = $this->input->post('perpage',true);
  2938. $timetk = $this->input->post('timetk',true);
  2939. $timetj = $this->input->post('timetj',true);
  2940. $shop = $this->input->post('shop',true);
  2941. $type = $this->input->post('type',true);
  2942. $express = $this->input->post('express',true);
  2943. $number = $this->input->post('number',true);
  2944. $waybill = $this->input->post('waybill',true);
  2945. $librarytime = $this->input->post('librarytime',true);
  2946. $timetk = strtotime($timetk);
  2947. $timetj = strtotime($timetj);
  2948. $where = "mergeid = '1'";
  2949. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  2950. if($shop)
  2951. {
  2952. $where .= " and shop = '$shop'";
  2953. }
  2954. if($number)
  2955. {
  2956. $where .= " and number like '$number%'";
  2957. }
  2958. if($waybill)
  2959. {
  2960. $where .= " and waybill = '$waybill'";
  2961. }
  2962. if($type)
  2963. {
  2964. $where .= " and type = '$type'";
  2965. }
  2966. if($express)
  2967. {
  2968. $where .= " and express = '$express'";
  2969. }
  2970. //数据排序
  2971. $order_str = "librarytime desc";
  2972. if(empty($page))
  2973. {
  2974. $start = 0;
  2975. $perpage = 1;
  2976. }
  2977. else
  2978. {
  2979. $start = ($page - 1)*$perpage;
  2980. }
  2981. //取得信息列表
  2982. $info_list = $this->fullorder->find_all($where,'id,shop,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2983. //格式化数据
  2984. foreach ($info_list as $key=>$value)
  2985. {
  2986. $shop = $this->shop->read($value['shop']);
  2987. $info_list[$key]['shop'] = $shop['shopname'];
  2988. $express = $this->express->read($value['express']);
  2989. $info_list[$key]['express'] = $express['servicename'];
  2990. $warehouse = $this->warehouse->read($value['type']);
  2991. $info_list[$key]['type'] = $warehouse['title'];
  2992. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  2993. }
  2994. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  2995. //格式化数据
  2996. foreach ($info_listtt as $key=>$value)
  2997. {
  2998. $shop = $this->shop->read($value['shop']);
  2999. $info_listtt[$key]['shop'] = $shop['shopname'];
  3000. $express = $this->express->read($value['express']);
  3001. $info_listtt[$key]['express'] = $express['servicename'];
  3002. $warehouse = $this->warehouse->read($value['type']);
  3003. $info_listtt[$key]['type'] = $warehouse['title'];
  3004. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3005. }
  3006. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  3007. //格式化数据
  3008. foreach ($info_listamz as $key=>$value)
  3009. {
  3010. $shop = $this->shop->read($value['shop']);
  3011. $info_listamz[$key]['shop'] = $shop['shopname'];
  3012. $express = $this->express->read($value['express']);
  3013. $info_listamz[$key]['express'] = $express['servicename'];
  3014. $warehouse = $this->warehouse->read($value['type']);
  3015. $info_listamz[$key]['type'] = $warehouse['title'];
  3016. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3017. }
  3018. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  3019. //格式化数据
  3020. foreach ($info_listxw as $key=>$value)
  3021. {
  3022. $shop = $this->shop->read($value['shop']);
  3023. $info_listxw[$key]['shop'] = $shop['shopname'];
  3024. $express = $this->express->read($value['express']);
  3025. $info_listxw[$key]['express'] = $express['servicename'];
  3026. $warehouse = $this->warehouse->read($value['type']);
  3027. $info_listxw[$key]['type'] = $warehouse['title'];
  3028. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3029. }
  3030. $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);
  3031. //格式化数据
  3032. foreach ($info_listsmt as $key=>$value)
  3033. {
  3034. $shop = $this->shop->read($value['shop']);
  3035. $info_listsmt[$key]['shop'] = $shop['shopname'];
  3036. $express = $this->express->read($value['express']);
  3037. $info_listsmt[$key]['express'] = $express['servicename'];
  3038. $warehouse = $this->warehouse->read($value['type']);
  3039. $info_listsmt[$key]['type'] = $warehouse['title'];
  3040. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3041. }
  3042. $total = $this->fullorder->find_count($where);
  3043. $total += $this->fullordertt->find_count($where);
  3044. $total += $this->fullorderamz->find_count($where);
  3045. $total += $this->fullorderxw->find_count($where);
  3046. $total += $this->fullordersmt->find_count($where);
  3047. $pagenum = ceil($total/$perpage);
  3048. $over = $total-($start+$perpage);
  3049. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listamz,$info_listtt,$info_listxw,$info_listsmt)));
  3050. echo json_encode($rows);exit;
  3051. }
  3052. if(isset($_SESSION['api']))
  3053. {
  3054. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3055. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  3056. $this->data['wlshop'] = $wlshop;
  3057. $this->data['warehouse'] = $warehouse;
  3058. }
  3059. $this->data['xw'] = $xw;
  3060. $this->_Template('systemfout_fouthb',$this->data);
  3061. }
  3062. public function _hb()
  3063. {
  3064. $post = $this->input->post(NULL, TRUE);
  3065. $xw = '';
  3066. if(isset($_SESSION['api']))
  3067. {
  3068. $user = $this->user->get_api($_SESSION['api']);
  3069. $usp = $user;
  3070. $fgshop = "";$sid = "";$wid="";$wtype="";
  3071. $usersp = explode('|',trim($user['shop'],'|'));
  3072. $userwh = explode('|',trim($user['warehouse'],'|'));
  3073. foreach ($usersp as $value)
  3074. {
  3075. $fgshop .= " shop = ".$value." or";
  3076. $sid .= " id = ".$value." or";
  3077. }
  3078. foreach ($userwh as $value)
  3079. {
  3080. $wid .= " id = ".$value." or";
  3081. $wtype .= " type = ".$value." or";
  3082. }
  3083. if($user['userid'] == 'xw')
  3084. {
  3085. $xw = 1;
  3086. }
  3087. }
  3088. if(isset($post['page']))
  3089. {
  3090. $page = $this->input->post('page',true);
  3091. $perpage = $this->input->post('perpage',true);
  3092. $timetk = $this->input->post('timetk',true);
  3093. $timetj = $this->input->post('timetj',true);
  3094. $shop = $this->input->post('shop',true);
  3095. $source = $this->input->post('source',true);
  3096. $orderinfo = $this->input->post('orderinfo',true);
  3097. $number = $this->input->post('number',true);
  3098. $library = $this->input->post('library',true);
  3099. $waybill = $this->input->post('waybill',true);
  3100. $express = $this->input->post('express',true);
  3101. $type = $this->input->post('type',true);
  3102. $lowe = $this->input->post('lowe',true);
  3103. $so = $this->input->post('so',true);
  3104. $librarytime = $this->input->post('librarytime',true);
  3105. $timetk = strtotime($timetk);
  3106. $timetj = strtotime($timetj);
  3107. $cxtime = 'id';
  3108. $where = (isset($_SESSION['api']))?"library!=3 and mergeid = 1 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0' and mergeid = 1";
  3109. if($timetk && $timetj && $library == 1)
  3110. {
  3111. //$cxtime = 'reviewtime';
  3112. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  3113. $where .= " and state != 217";
  3114. }
  3115. else if($timetk && $timetj && $library == 2)
  3116. {
  3117. $cxtime = 'librarytime';
  3118. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  3119. }
  3120. if($shop)
  3121. {
  3122. $where .= " and shop = '$shop'";
  3123. }
  3124. if($number)
  3125. {
  3126. $where .= " and number = '$number'";
  3127. }
  3128. if($library)
  3129. {
  3130. $where .= " and library = '$library'";
  3131. }
  3132. if($waybill)
  3133. {
  3134. $where .= " and waybill = '$waybill'";
  3135. }
  3136. if($express)
  3137. {
  3138. $where .= " and express = '$express'";
  3139. }
  3140. if($orderinfo)
  3141. {
  3142. $where .= " and orderinfo = '$orderinfo'";
  3143. }
  3144. if($type)
  3145. {
  3146. $where .= " and type = '$type'";
  3147. }
  3148. if($lowe)
  3149. {
  3150. $where .= " and shipremarks like '%$lowe%'";
  3151. }
  3152. if($so)
  3153. {
  3154. $where .= " and shipremarks like '%$so%'";
  3155. }
  3156. //数据排序
  3157. $order_str = $cxtime." desc";
  3158. if(empty($page))
  3159. {
  3160. $start = 0;
  3161. $perpage = 1;
  3162. }
  3163. else
  3164. {
  3165. $start = ($page - 1)*$perpage;
  3166. }
  3167. //取得信息列表
  3168. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  3169. //格式化数据
  3170. foreach ($info_list as $key=>$value)
  3171. {
  3172. $shop = $this->shop->read($value['shop']);
  3173. $info_list[$key]['shop'] = $shop['shopname'];
  3174. if($value['waybill'] == '0')
  3175. {
  3176. $info_list[$key]['waybill'] = "";
  3177. }
  3178. $express = $this->express->read($value['express']);
  3179. $info_list[$key]['express'] = $express['servicename'];
  3180. $warehouse = $this->warehouse->read($value['type']);
  3181. $info_list[$key]['type'] = $warehouse['title'];
  3182. if($value['print'] == 1)
  3183. {
  3184. $info_list[$key]['print'] = '不可打印';
  3185. }
  3186. else if($value['print'] == 2)
  3187. {
  3188. $info_list[$key]['print'] = '未打印';
  3189. }
  3190. else if($value['print'] == 3)
  3191. {
  3192. $info_list[$key]['print'] = '已打印';
  3193. }
  3194. if($value['library'] == 1)
  3195. {
  3196. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  3197. }
  3198. else if($value['library'] == 2)
  3199. {
  3200. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  3201. }
  3202. else if($value['library'] == 3)
  3203. {
  3204. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  3205. }
  3206. if($value['librarytime'] == '0')
  3207. {
  3208. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3209. }
  3210. else
  3211. {
  3212. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  3213. }
  3214. $info_list[$key]['orderremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['orderremarks']);
  3215. }
  3216. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  3217. //格式化数据
  3218. foreach ($info_listtt as $key=>$value)
  3219. {
  3220. $shop = $this->shop->read($value['shop']);
  3221. $info_listtt[$key]['shop'] = $shop['shopname'];
  3222. if($value['waybill'] == '0')
  3223. {
  3224. $info_listtt[$key]['waybill'] = "";
  3225. }
  3226. $express = $this->express->read($value['express']);
  3227. $info_listtt[$key]['express'] = $express['servicename'];
  3228. $warehouse = $this->warehouse->read($value['type']);
  3229. $info_listtt[$key]['type'] = $warehouse['title'];
  3230. if($value['print'] == 1)
  3231. {
  3232. $info_listtt[$key]['print'] = '不可打印';
  3233. }
  3234. else if($value['print'] == 2)
  3235. {
  3236. $info_listtt[$key]['print'] = '未打印';
  3237. }
  3238. else if($value['print'] == 3)
  3239. {
  3240. $info_listtt[$key]['print'] = '已打印';
  3241. }
  3242. if($value['library'] == 1)
  3243. {
  3244. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  3245. }
  3246. else if($value['library'] == 2)
  3247. {
  3248. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  3249. }
  3250. else if($value['library'] == 3)
  3251. {
  3252. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  3253. }
  3254. if($value['librarytime'] == '0')
  3255. {
  3256. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  3257. }
  3258. else
  3259. {
  3260. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3261. }
  3262. }
  3263. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  3264. //格式化数据
  3265. foreach ($info_listamz as $key=>$value)
  3266. {
  3267. $shop = $this->shop->read($value['shop']);
  3268. $info_listamz[$key]['shop'] = $shop['shopname'];
  3269. if($value['waybill'] == '0')
  3270. {
  3271. $info_listamz[$key]['waybill'] = "";
  3272. }
  3273. $express = $this->express->read($value['express']);
  3274. $info_listamz[$key]['express'] = $express['servicename'];
  3275. $warehouse = $this->warehouse->read($value['type']);
  3276. $info_listamz[$key]['type'] = $warehouse['title'];
  3277. if($value['print'] == 1)
  3278. {
  3279. $info_listamz[$key]['print'] = '不可打印';
  3280. }
  3281. else if($value['print'] == 2)
  3282. {
  3283. $info_listamz[$key]['print'] = '未打印';
  3284. }
  3285. else if($value['print'] == 3)
  3286. {
  3287. $info_listamz[$key]['print'] = '已打印';
  3288. }
  3289. if($value['library'] == 1)
  3290. {
  3291. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  3292. }
  3293. else if($value['library'] == 2)
  3294. {
  3295. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  3296. }
  3297. else if($value['library'] == 3)
  3298. {
  3299. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  3300. }
  3301. if($value['librarytime'] == '0')
  3302. {
  3303. $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
  3304. }
  3305. else
  3306. {
  3307. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3308. }
  3309. }
  3310. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  3311. //格式化数据
  3312. foreach ($info_listxw as $key=>$value)
  3313. {
  3314. $shop = $this->shop->read($value['shop']);
  3315. $info_listxw[$key]['shop'] = $shop['shopname'];
  3316. if($value['waybill'] == '0')
  3317. {
  3318. $info_listxw[$key]['waybill'] = "";
  3319. }
  3320. $express = $this->express->read($value['express']);
  3321. $info_listxw[$key]['express'] = $express['servicename'];
  3322. $warehouse = $this->warehouse->read($value['type']);
  3323. $info_listxw[$key]['type'] = $warehouse['title'];
  3324. if($value['print'] == 1)
  3325. {
  3326. $info_listxw[$key]['print'] = '不可打印';
  3327. }
  3328. else if($value['print'] == 2)
  3329. {
  3330. $info_listxw[$key]['print'] = '未打印';
  3331. }
  3332. else if($value['print'] == 3)
  3333. {
  3334. $info_listxw[$key]['print'] = '已打印';
  3335. }
  3336. if($value['library'] == 1)
  3337. {
  3338. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  3339. }
  3340. else if($value['library'] == 2)
  3341. {
  3342. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  3343. }
  3344. else if($value['library'] == 3)
  3345. {
  3346. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  3347. }
  3348. if($value['librarytime'] == '0')
  3349. {
  3350. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  3351. }
  3352. else
  3353. {
  3354. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3355. }
  3356. }
  3357. $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);
  3358. //格式化数据
  3359. foreach ($info_listsmt as $key=>$value)
  3360. {
  3361. $shop = $this->shop->read($value['shop']);
  3362. $info_listsmt[$key]['shop'] = $shop['shopname'];
  3363. if($value['waybill'] == '0')
  3364. {
  3365. $info_listsmt[$key]['waybill'] = "";
  3366. }
  3367. $express = $this->express->read($value['express']);
  3368. $info_listsmt[$key]['express'] = $express['servicename'];
  3369. $warehouse = $this->warehouse->read($value['type']);
  3370. $info_listsmt[$key]['type'] = $warehouse['title'];
  3371. if($value['print'] == 1)
  3372. {
  3373. $info_listsmt[$key]['print'] = '不可打印';
  3374. }
  3375. else if($value['print'] == 2)
  3376. {
  3377. $info_listsmt[$key]['print'] = '未打印';
  3378. }
  3379. else if($value['print'] == 3)
  3380. {
  3381. $info_listsmt[$key]['print'] = '已打印';
  3382. }
  3383. if($value['library'] == 1)
  3384. {
  3385. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  3386. }
  3387. else if($value['library'] == 2)
  3388. {
  3389. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  3390. }
  3391. else if($value['library'] == 3)
  3392. {
  3393. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  3394. }
  3395. if($value['librarytime'] == '0')
  3396. {
  3397. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  3398. }
  3399. else
  3400. {
  3401. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3402. }
  3403. }
  3404. $total = $this->fullorder->find_count($where);
  3405. $total += $this->fullordertt->find_count($where);
  3406. $total += $this->fullorderamz->find_count($where);
  3407. $total += $this->fullorderxw->find_count($where);
  3408. $total += $this->fullordersmt->find_count($where);
  3409. $pagenum = ceil($total/$perpage);
  3410. $over = $total-($start+$perpage);
  3411. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt)));
  3412. echo json_encode($rows);exit;
  3413. }
  3414. if(isset($_SESSION['api']))
  3415. {
  3416. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3417. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  3418. $this->data['wlshop'] = $wlshop;
  3419. $this->data['warehouse'] = $warehouse;
  3420. }
  3421. $this->data['xw'] = $xw;
  3422. $this->_Template('systemfout_hb',$this->data);
  3423. }
  3424. }