Systemfout.php 117 KB

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