Systemfout.php 121 KB

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