Systemfout.php 101 KB

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