Systemfout.php 102 KB

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