Fullorderexcel.php 130 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Fullorderexcel extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_fullorder','fullorder');
  7. $this->load->_model('Model_fullordertt','fullordertt');
  8. $this->load->_model('Model_fullorderxw','fullorderxw');
  9. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  10. $this->load->_model('Model_fullordersmt','fullordersmt');
  11. $this->load->_model('Model_fullorderamz','fullorderamz');
  12. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  13. $this->load->_model('Model_fullorderexcelclassid','fullorderexcelclassid');
  14. $this->load->_model('Model_shop','shop');
  15. $this->load->_model('Model_country','country');
  16. $this->load->_model('Model_warehouse','warehouse');
  17. $this->load->_model('Model_excel','excel');
  18. $this->load->_model('Model_notice','notice');
  19. $this->load->_model('Model_express','express');
  20. $this->load->_model('Model_api','api');
  21. $this->load->_model('Model_apismt','apismt');
  22. $this->load->_model('Model_usps','usps');
  23. $this->load->_model('Model_typeclass','typeclass');
  24. $this->load->_model('Model_systemwigsout','systemwigsout');
  25. $this->load->_model('Model_setting','setting');
  26. $this->load->_model('Model_customer','customer');
  27. $this->load->_model('Model_customersmt','customersmt');
  28. $this->load->_model('Model_orderurl','orderurl');
  29. $this->load->_model('Model_whlabel','whlabel');
  30. $this->load->_model('Model_whlabel_bh','whlabel_bh');
  31. $this->load->_model('Model_apiyy','apiyy');
  32. $this->load->_model('Model_classid','classid');
  33. $this->load->_model('Model_systemtransfer','systemtransfer');
  34. $this->load->_model('Model_transfer','transfer');
  35. $this->load->_model('Model_classid','classid');
  36. $this->load->_model('Model_whlabel_type','whlabel_type');
  37. $this->load->_model('Model_power','power');
  38. $this->load->_model('Model_productdescribe','productdescribe');
  39. $this->load->_model('Model_shopsku','shopsku');
  40. $this->load->_model('Model_is','is');
  41. $this->load->_model('Model_whlabel_qh','whlabel_qh');
  42. $this->load->_model('Model_emaildata','emaildata');
  43. $this->load->_model('Model_afspaypal','afspaypal');
  44. $this->load->_model('Model_producttitle','producttitle');
  45. $this->load->_model('Model_message','message');
  46. $this->load->_model("Model_logic_ding","logic_ding");
  47. $this->load->_model('Model_excelxh','excelxh');
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg,$arg_array)
  51. {
  52. if($arg == 'excel')
  53. {
  54. $this->_excel();
  55. }
  56. else if($arg == 'excelhz')
  57. {
  58. $this->_excelhz();
  59. }
  60. else if($arg == 'add')
  61. {
  62. $this->_add();
  63. }
  64. else if($arg == 'edit')
  65. {
  66. $this->_edit($arg_array);
  67. }
  68. else if($arg == 'copy'){
  69. $this->_copy($arg_array);
  70. }
  71. else if($arg == 'del')
  72. {
  73. $this->_del();
  74. }
  75. else if($arg == 'rows')
  76. {
  77. $this->_rows();
  78. }
  79. else if($arg == 'waybill')
  80. {
  81. $this->_waybill($arg_array);
  82. }
  83. else if($arg == 'order')
  84. {
  85. $this->_order($arg_array);
  86. }
  87. else if($arg == 'xxpl')//线下批量导入
  88. {
  89. $this->_xxpl();
  90. }
  91. else if($arg == 'skuzh')//sku转中文
  92. {
  93. $this->_skuzh();
  94. }
  95. else if($arg == 'cs')
  96. {
  97. $this->_cs();
  98. }
  99. else if($arg == 'scwd')
  100. {
  101. $this->_scwd();
  102. }
  103. else if($arg == 'jmexcel')
  104. {
  105. $this->_jmexcel();
  106. }
  107. else if($arg == 'classid')
  108. {
  109. $this->_classid();
  110. }
  111. else if($arg == 'classidadd')
  112. {
  113. $this->_classidadd();
  114. }
  115. else if($arg == 'classidedit')
  116. {
  117. $this->_classidedit($arg_array);
  118. }
  119. else
  120. {
  121. $this->_index();
  122. }
  123. }
  124. //管理
  125. public function _index()
  126. {
  127. $post = $this->input->post(NULL, TRUE);
  128. if(isset($post['page']))
  129. {
  130. $page = $this->input->post('page',true);
  131. $perpage = $this->input->post('perpage',true);
  132. $type = $this->input->post('type',true);
  133. $must = $this->input->post('must',true);
  134. $where = "1=1 ";
  135. //数据排序
  136. $order_str = "id asc";
  137. if(empty($page))
  138. {
  139. $start = 0;
  140. $perpage = 1;
  141. }
  142. else
  143. {
  144. $start = ($page - 1)*$perpage;
  145. }
  146. if($type)
  147. {
  148. $where .= " and type = '$type'";
  149. }
  150. if($must)
  151. {
  152. $where .= " and title like '%".$must."%' ";
  153. }
  154. //取得信息列表
  155. $info_list = $this->fullorderexcel->find_all($where,'id,type,title',$order_str,$start,$perpage);
  156. foreach ($info_list as $k=>$v)
  157. {
  158. $classid = $this->fullorderexcelclassid->read($v['type']);
  159. $info_list[$k]['type'] = $classid['title'];
  160. $info_list[$k]['action'] = "<h9 class='window' data-h='/fullorderexcel/copy/".$v['id']."' style='color:#000'><span>复制表格</span></h9>";
  161. }
  162. $total = $this->fullorderexcel->find_count($where);
  163. $pagenum = ceil($total/$perpage);
  164. $over = $total-($start+$perpage);
  165. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  166. echo json_encode($rows);exit;
  167. }
  168. $classid = $this->fullorderexcelclassid->find_all();
  169. $this->data['classid'] = $classid;
  170. $this->_Template('fullorderexcel',$this->data);
  171. }
  172. //添加
  173. public function _add()
  174. {
  175. $post = $this->input->post(NULL, TRUE);
  176. if(isset($post['title']))
  177. {
  178. $post['title'] = $this->input->post('title',true);
  179. $post['type'] = $this->input->post('type',true);
  180. $post['content'] = $this->input->post('content',true);
  181. $post['contentzh'] = $this->input->post('contentzh',true);
  182. $addid = $this->fullorderexcel->insert($post);
  183. if($addid)
  184. {
  185. $adminid = $this->power->read(1);
  186. $this->power->save(array("excelid"=>$adminid['excelid'].$addid.'|',"exceltext"=>$adminid['exceltext'].$post['title'].'|'),$adminid['id']);
  187. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  188. }
  189. else
  190. {
  191. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  192. }
  193. }
  194. $classid = $this->fullorderexcelclassid->find_all();
  195. $this->data['classid'] = $classid;
  196. $this->_Template('fullorderexcel_add',$this->data);
  197. }
  198. //修改
  199. public function _edit($arg_array)
  200. {
  201. $post = $this->input->post(NULL, TRUE);
  202. if(isset($post['id']))
  203. {
  204. $id = $this->input->post('id',true);
  205. $post['title'] = $this->input->post('title',true);
  206. $post['type'] = $this->input->post('type',true);
  207. $post['content'] = $this->input->post('content',true);
  208. $post['contentzh'] = $this->input->post('contentzh',true);
  209. if($this->fullorderexcel->save($post,$id))
  210. {
  211. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  212. }
  213. else
  214. {
  215. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  216. }
  217. }
  218. $arg_array = $arg_array[0];
  219. $fullorderexcel = $this->fullorderexcel->read($arg_array);
  220. $this->data['fullorderexcel'] = $fullorderexcel;
  221. $classid = $this->fullorderexcelclassid->find_all();
  222. $this->data['classid'] = $classid;
  223. $this->_Template('fullorderexcel_edit',$this->data);
  224. }
  225. public function _copy($arg_array)
  226. {
  227. $post = $this->input->post(NULL, TRUE);
  228. if(isset($post['id']))
  229. {
  230. $post['title'] = $this->input->post('title',true);
  231. $post['type'] = $this->input->post('type',true);
  232. $post['content'] = $this->input->post('content',true);
  233. $post['contentzh'] = $this->input->post('contentzh',true);
  234. unset($post['id']);
  235. $addid =$this->fullorderexcel->insert($post);
  236. if($addid)
  237. {
  238. $adminid = $this->power->read(1);
  239. $this->power->save(array("excelid"=>$adminid['excelid'].$addid.'|',"exceltext"=>$adminid['exceltext'].$post['title'].'|'),$adminid['id']);
  240. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  241. }
  242. else
  243. {
  244. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  245. }
  246. }
  247. $arg_array = $arg_array[0];
  248. $fullorderexcel = $this->fullorderexcel->read($arg_array);
  249. $this->data['fullorderexcel'] = $fullorderexcel;
  250. $classid = $this->fullorderexcelclassid->find_all();
  251. $this->data['classid'] = $classid;
  252. $this->_Template('fullorderexcel_copy',$this->data);
  253. }
  254. //删除
  255. public function _del()
  256. {
  257. $post = $this->input->post(NULL, TRUE);
  258. if(isset($post['s']))
  259. {
  260. $id_arr = $this->input->post('s');
  261. $id_arr = explode(',',$id_arr);
  262. if(!$id_arr)
  263. {
  264. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  265. }
  266. //循环删除记录
  267. foreach ($id_arr as $v)
  268. {
  269. $this->fullorderexcel->remove($v);
  270. }
  271. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  272. }
  273. }
  274. //获取数据
  275. public function _rows()
  276. {
  277. $post = $this->input->post(NULL, TRUE);
  278. if(isset($post['id']))
  279. {
  280. $id = $this->input->post('id',true);
  281. $fullorderexcel = $this->fullorderexcel->read($id);
  282. $content = explode('|',rtrim($fullorderexcel['content'],'|'));
  283. $contentzh = explode('|',rtrim($fullorderexcel['contentzh'],'|'));
  284. $data = array();
  285. for($i=0;$i<count($content);$i++)
  286. {
  287. $a = explode('-',$content[$i]);
  288. $b = explode('-',$contentzh[$i]);
  289. $data[] = array(0=>$a[1],1=>$b[1]);
  290. }
  291. echo json_encode(array('rows'=>($data),'success'=>true));
  292. }
  293. }
  294. //导出订单excel
  295. public function _excel()
  296. {
  297. $fgshop = "";$sid = "";$excelshop="";
  298. if(isset($_SESSION['api']))
  299. {
  300. $user = $this->user->get_api($_SESSION['api']);
  301. $usp = $user;
  302. $usersp = explode('|',trim($user['shop'],'|'));
  303. foreach ($usersp as $value)
  304. {
  305. $fgshop .= " shop = ".$value." or";
  306. $sid .= " id = ".$value." or";
  307. }
  308. $userexcel = explode('|',trim($user['excelshop'],'|'));
  309. if($user['excelshop'] == '')
  310. {
  311. echo "没有下载权限";exit;
  312. }
  313. foreach ($userexcel as $value)
  314. {
  315. $excelshop .= " shop = ".$value." or";
  316. }
  317. if($excelshop != "")
  318. {
  319. $excelshop = "(".rtrim($excelshop,'or').")";
  320. }
  321. }
  322. if(isset($_GET['fexcel']))
  323. {
  324. $typeclass = array();
  325. $tclass = $this->typeclass->find_all();
  326. foreach ($tclass as $v)
  327. {
  328. $typeclass[$v['id']] = $v;
  329. }
  330. $dowid = $this->input->get('a');
  331. $wid = "";
  332. if($dowid != "")
  333. {
  334. $id_arr = explode(',',rtrim($dowid,','));
  335. $wid .= " id = 0 or";
  336. foreach ($id_arr as $v)
  337. {
  338. $wid .= " id = '$v' or";
  339. }
  340. $wid = " and".rtrim($wid,'or');
  341. }
  342. $fexcel = $this->input->get('fexcel',true);
  343. $page = $this->input->get('page',true);
  344. $perpage = $this->input->get('perpage',true);
  345. $warehouse = $this->input->get('warehouse',true);
  346. $timetk = $this->input->get('timetk',true);
  347. $timetj = $this->input->get('timetj',true);
  348. $shop = $this->input->get('shop',true);
  349. $source = $this->input->get('source',true);
  350. $state = $this->input->get('state',true);
  351. $review = $this->input->get('review',true);
  352. $type = $this->input->get('type',true);
  353. $express = $this->input->get('express',true);
  354. $orderinfo = $this->input->get('orderinfo',true);
  355. $user = $this->input->get('user',true);
  356. $client = $this->input->get('name',true);
  357. $waybill = $this->input->get('waybill',true);
  358. $number = $this->input->get('number',true);
  359. $email = $this->input->get('email',true);
  360. $dlz = $this->input->get('dlz',true);
  361. $library = $this->input->get('library',true);
  362. $libraryconfirm = $this->input->get('libraryconfirm',true);
  363. $print = $this->input->get('print',true);
  364. $timetkk = $this->input->get('timetkk',true);
  365. $timetjj = $this->input->get('timetjj',true);
  366. $xztime = $this->input->get('xztime',true);
  367. $country = $this->input->get('country',true);
  368. $zf = $this->input->get('zf',true);
  369. $pay = $this->input->get('pay',true);
  370. $phone = $this->input->get('phone',true);
  371. $so = $this->input->get('so',true);
  372. $sfxh = $this->input->get('sfxh',true);
  373. $xdcs = $this->input->get('xdcs',true);
  374. $xdcs = $this->input->get('xdcs',true);
  375. $dbapi = $this->input->get('dbapi',true);
  376. $dbapinocc = $this->input->get('dbapinocc',true);
  377. $orderurl = $this->input->get('orderurl',true);
  378. $timetk = strtotime($timetk);
  379. $timetj = strtotime($timetj);
  380. $timetkk = strtotime($timetkk);
  381. $timetjj = strtotime($timetjj);
  382. $productid = $this->input->get('productid',true);
  383. $px = $this->input->get('px',true);
  384. $fexcel = $this->fullorderexcel->read($fexcel);
  385. $classid = $this->fullorderexcelclassid->read($fexcel['type']);
  386. $where = "1 = 1 and (".rtrim($fgshop,'or').")";
  387. if($warehouse)
  388. {
  389. $where .= " and type = '$warehouse'";
  390. }
  391. if($xztime)
  392. {
  393. if($timetk && $timetj)
  394. {
  395. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  396. }
  397. if($timetkk && $timetjj)
  398. {
  399. $where .= " and ".$xztime." > '$timetkk' and ".$xztime." < '$timetjj'";
  400. }
  401. }
  402. else
  403. {
  404. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  405. }
  406. if($productid){
  407. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  408. }
  409. if($library)
  410. {
  411. $where .= " and library = '$library'";
  412. }
  413. if($print)
  414. {
  415. $where .= " and print = '$print'";
  416. }
  417. if($shop)
  418. {
  419. $where .= " and shop = '$shop'";
  420. }
  421. if($source)
  422. {
  423. if($source == '2d')
  424. {
  425. $where .= " and source >= '2'";
  426. }
  427. else
  428. {
  429. $where .= " and source = '$source'";
  430. }
  431. }
  432. if($state)
  433. {
  434. $where .= " and state = '$state'";
  435. }
  436. if($review)
  437. {
  438. $where .= " and review = '$review'";
  439. }
  440. if($type)
  441. {
  442. $where .= " and type = '$type'";
  443. }
  444. if($express)
  445. {
  446. $where .= " and express = '$express'";
  447. }
  448. if($orderinfo)
  449. {
  450. $where .= " and orderinfo = '$orderinfo'";
  451. }
  452. if($user)
  453. {
  454. $where .= " and user = '$user'";
  455. }
  456. if($client)
  457. {
  458. $where .= " and client like '%$client%'";
  459. }
  460. if($waybill)
  461. {
  462. $where .= " and waybill = '$waybill'";
  463. }
  464. if($number)
  465. {
  466. $where .= " and number = '$number'";
  467. }
  468. if($email)
  469. {
  470. $where .= " and email = '$email'";
  471. }
  472. if($country)
  473. {
  474. $where .= " and country = '$country'";
  475. }
  476. if($dlz)
  477. {
  478. $where .= " and waybill != '' and dlz = 0";
  479. }
  480. if($libraryconfirm)
  481. {
  482. $where .= " and libraryconfirm = '$libraryconfirm'";
  483. }
  484. if($so)
  485. {
  486. $where .= " and shipremarks like '%$so%'";
  487. }
  488. if($pay)
  489. {
  490. $where .= " and pay = '$pay'";
  491. }
  492. if($phone)
  493. {
  494. $where .= " and phone = '$phone'";
  495. }
  496. if($sfxh != '')
  497. {
  498. $where .= " and sfxh = '$sfxh'";
  499. }
  500. if($orderurl)
  501. {
  502. $url = $this->orderurl->read($orderurl);
  503. $where .= " and link like '%".$url['url']."%'";
  504. }
  505. if($zf)
  506. {
  507. if($zf == 1)
  508. {
  509. $where .= " and paypal not like '%-%-%-%'";
  510. }
  511. else
  512. {
  513. $where .= " and paypal like '%-%-%-%'";
  514. }
  515. }
  516. $sj = $this->input->get('sj',true);
  517. if($sj)
  518. {
  519. $sj = $this->input->get('sj',true);
  520. }
  521. else
  522. {
  523. $sj = $classid['type'];
  524. }
  525. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  526. foreach ($fexceleq as $k=>$v)
  527. {
  528. $fexceleq[$k] = explode('-',$v);
  529. $num[$k] = $fexceleq[$k][0];
  530. }
  531. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  532. $feq = "";$kong = array();$sku9610 = ''; $goods_sku_list = [];
  533. foreach ($fexceleq as $k=>$v)
  534. {
  535. if(isset($v[1]))
  536. {
  537. if($v[1] == 'klarnabill' || $v[1] == 'klarnaship' || $v[1] == 'PPname' || $v[1] == 'PPaddress' || $v[1] == 'PPemail' || $v[1] == 'afterpayship' || $v[1] == 'afterpaybill')
  538. {
  539. $feq .= 'klarnadata,';
  540. }
  541. if($v[1] == 'ccfpdata' || $v[1] == 'cpfpdata' || $v[1] == 'dbapi' || $v[1] == 'scapi')
  542. {
  543. $feq .= 'fpdata,';
  544. }
  545. if(in_array($v[1],['gradefpdata','colorfpdata','densityfpdata','hairnumberfpdata','lacetypefpdata','lowefpdata'])){
  546. $goods_sku_list[] = $v[1];
  547. continue;
  548. }
  549. if($v[1] != 'kong')//空值去除
  550. {
  551. if($v[1] == '9610sku' || $v[1] == 'issku' || $v[1] == 'sku')
  552. {
  553. if($v[1] == '9610sku')
  554. {
  555. $sku9610 = 1;
  556. }
  557. if($sj == 'fullordersmt')
  558. {
  559. $v[1] = 'sku';
  560. }
  561. else
  562. {
  563. $v[1] = 'issku';
  564. }
  565. }
  566. $feq .= $v[1].',';
  567. }
  568. else
  569. {
  570. $kong[$v[0]] = 1;
  571. }
  572. }
  573. }
  574. //处理额外加上的subtotal和rowtoal 但是不想在表中加太多字段 想着以后有关金额的都给怼到extra_price字段中
  575. if((strpos($feq,'subtotal')!= false)||(strpos($feq,'rowtotal')!= false) ||(strpos($feq,'product_id')!= false)){
  576. if(strpos($feq,'subtotal')!= false){
  577. $feq = str_replace('subtotal,',"extra_price as subtotal,",$feq);
  578. }
  579. if(strpos($feq,'rowtotal')!= false){
  580. $feq = str_replace('rowtotal,',"extra_price as rowtotal,",$feq);
  581. }
  582. if(strpos($feq,'product_id')!= false){
  583. $feq = str_replace('product_id,',"extra_price as product_id,",$feq);
  584. }
  585. }
  586. //添加订单前缀
  587. $shopqz_list = [];
  588. if(strpos($feq,'shopqz') !== false){
  589. $feq = str_replace('shopqz,',"shop as shopqz,",$feq);
  590. $shop_list = $this->shop->find_all("1 = 1","id,shortname");
  591. $shopqz_list = array_column($shop_list,'shortname','id');
  592. }
  593. $tt_cate_one = [];
  594. $tt_cate_two = [];
  595. if($sj == 'fullordertt'){
  596. if(strpos($feq,'ttcateone')!== false){
  597. $feq = str_replace('ttcateone,',"cate_one as ttcateone,",$feq);
  598. $tt_cate_one = $this->fullordertt->getCateOne();
  599. $tt_cate_two = $this->fullordertt->getCateTwo();
  600. }
  601. if(strpos($feq,'ttcatetwo')!== false){
  602. $feq = str_replace('ttcatetwo,',"cate_two as ttcatetwo,",$feq);
  603. }
  604. }
  605. //$dbapi_nocc
  606. if(strpos($feq,'dbapinocc')!= false){
  607. $feq = str_replace('dbapinocc,',"fpdata as dbapinocc,",$feq);
  608. }
  609. //商品的规格展示 如果前面没有fpdata 需要加上
  610. if(count($goods_sku_list) > 0){
  611. if(strpos($feq,'fpdata,') === false){
  612. $feq = "fpdata,".$feq;
  613. }
  614. }
  615. $typeclass_lpdl = [];
  616. //料品大类
  617. if(strpos($feq,'lpdl')!= false){
  618. $feq = str_replace('lpdl,',"fpdata as lpdl,",$feq);
  619. $tmp_typeclass_lpdl = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',16)->get()->result_array();
  620. $typeclass_lpdl = array_column($tmp_typeclass_lpdl,'zh','id');
  621. }
  622. $typeclass_lhdycc = [];
  623. //料号对应尺寸
  624. if(strpos($feq,'lhdycc')!= false){
  625. $feq = str_replace('lhdycc,',"fpdata as lhdycc,",$feq);
  626. $tmp_typeclass_lhdycc = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',14)->get()->result_array();
  627. $typeclass_lhdycc = array_column($tmp_typeclass_lhdycc,'zh','id');
  628. }
  629. $feq = rtrim($feq,',');
  630. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  631. foreach ($fexcelzhw as $k=>$v)
  632. {
  633. $fexcelzhw[$k] = explode('-',$v);
  634. $numb[$k] = $fexcelzhw[$k][0];
  635. }
  636. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  637. $fexcelzh = array();
  638. foreach ($fexcelzhw as $k=>$v)
  639. {
  640. $fexcelzh[] = $v[1];
  641. }
  642. if($px)
  643. {
  644. $order_str = $px." desc";
  645. }
  646. else
  647. {
  648. $order_str = "id desc";
  649. }
  650. // if($_GET['fexcel'] == '157'){
  651. // $this->logic_ding->sendToDing("excel导出的【".$where.$wid.' and '.$excelshop);
  652. // $this->logic_ding->sendToDing("excel导出的【".'id,'.$feq);
  653. // $this->logic_ding->sendToDing("excel导出的【".$order_str);
  654. // $this->logic_ding->sendToDing("excel导出的SJ【".$sj);
  655. // }
  656. //取得信息列表
  657. $info_list = $this->$sj->find_all($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str);
  658. //格式化数据
  659. $i = 1;$shouldmoney = 0;$hl=1;
  660. foreach ($info_list as $key=>$value)
  661. {
  662. $data = $this->$sj->read($value['id']);
  663. $data = str_replace(array("'"),array("’"),$data);
  664. if(isset($value['email']) && $usp['excelpass'] == '1')
  665. {
  666. $emailpass = $this->setting->get_excelpass($value['email']);
  667. $info_list[$key]['email'] = $emailpass;
  668. }
  669. if(isset($value['phone']) && $usp['excelpass'] == '1')
  670. {
  671. $phonepass = $this->setting->get_excelpass($value['phone']);
  672. $info_list[$key]['phone'] = $phonepass;
  673. }
  674. if(isset($value['currencytitle']))
  675. {
  676. if($value['currencytitle'] != "CNY")
  677. {
  678. $hl=$value['hl'];
  679. }
  680. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  681. $budget=$budget+($value['budget']*$hl);
  682. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  683. $refund=$refund+($value['refund']*$hl);
  684. }
  685. if(isset($value['shop']))
  686. {
  687. $shop = $this->shop->read($value['shop']);
  688. $info_list[$key]['shop'] = $shop['shopname'];
  689. }
  690. if(isset($value['dtime']))
  691. {
  692. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  693. }
  694. if(isset($value['printtime']))
  695. {
  696. if($value['printtime'] > 0)
  697. {
  698. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  699. }
  700. }
  701. if(isset($value['sku']))
  702. {
  703. if($sku9610 == '1')
  704. {
  705. $aesku = explode(';',$value['sku']);
  706. $aesku = $aesku[0];
  707. $aesku = explode(':',$aesku);
  708. if(count($aesku) > 1)
  709. {
  710. $aesku = $aesku[1];
  711. $aesku = str_replace('--','~',$aesku);
  712. $aesku = explode('-',$aesku);
  713. $aesku = $aesku[0];
  714. $aesku = str_replace('~','--',$aesku);
  715. $info_list[$key]['sku'] = $aesku;
  716. }
  717. else
  718. {
  719. $info_list[$key]['sku'] = '';
  720. }
  721. }
  722. else
  723. {
  724. $info_list[$key]['sku'] = $value['sku'];
  725. }
  726. }
  727. if(isset($value['issku']))
  728. {
  729. $value['issku'] = str_replace(array('&lt;','&gt;'),array('<','>'),$value['issku']);
  730. if($sku9610 == '1')
  731. {
  732. $aesku = explode(';',$value['issku']);
  733. $aesku = $aesku[0];
  734. $aesku = str_replace('--','~',$aesku);
  735. $aesku = explode('-',$aesku);
  736. $aesku = $aesku[0];
  737. $aesku = str_replace('~','--',$aesku);
  738. $aesku = str_replace(array('<','>'),array('&lt;','&gt;'),$aesku);
  739. $info_list[$key]['issku'] = $aesku;
  740. }
  741. else
  742. {
  743. $value['issku'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['issku']);
  744. $info_list[$key]['issku'] = $value['issku'];
  745. }
  746. }
  747. if(isset($value['subtotal'])){
  748. $tmp_sub_str = "";
  749. $subtotal_list = json_decode($value['subtotal'],true);
  750. foreach($subtotal_list as $v){
  751. if(isset($v['sub_total'])){
  752. $tmp_sub_str .= sprintf( "%.2f",$v['sub_total'])."<br>";
  753. }else{
  754. $tmp_sub_str .= "0<br>";
  755. }
  756. }
  757. $info_list[$key]['subtotal'] = $tmp_sub_str;
  758. }
  759. if(isset($value['rowtotal'])){
  760. $tmp_sub_str = "";
  761. $subtotal_list = json_decode($value['rowtotal'],true);
  762. foreach($subtotal_list as $v){
  763. if(isset($v['row_total'])){
  764. $tmp_sub_str .= sprintf( "%.2f",$v['row_total'])."<br>";
  765. }else{
  766. $tmp_sub_str .= "0<br>";
  767. }
  768. }
  769. $info_list[$key]['rowtotal'] = $tmp_sub_str;
  770. }
  771. if(isset($value['shopqz'])){
  772. $info_list[$key]['shopqz'] = isset($shopqz_list[$value['shopqz']])?$shopqz_list[$value['shopqz']]:'';
  773. }
  774. if(isset($value['dbapinocc'])){
  775. $jmlist_nocc = '';
  776. $classid = $this->classid->sku();
  777. $dbapi = explode(';',trim($value['dbapinocc'],';'));
  778. foreach ($dbapi as $va)
  779. {
  780. $jm_nocc = $classid;
  781. unset($jm_nocc[14]);
  782. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  783. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  784. $ts = explode('|',trim($features,'|'));
  785. if(stripos($ts[0],',') !== false)
  786. {
  787. $ft = explode(',',$ts[0]);
  788. $features = explode('-',trim($ft[1],'-'));
  789. $features[] = $ft[0];
  790. }
  791. else
  792. {
  793. $features = explode('-',trim($ts[0],'-'));
  794. }
  795. foreach($features as $k=>$v)
  796. {
  797. if($v != 0 && isset($typeclass[$v]))
  798. {
  799. if(isset($jm_nocc[$typeclass[$v]['classid']]))
  800. {
  801. if($typeclass[$v]['jm'])
  802. {
  803. $jm_nocc[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  804. }
  805. }
  806. }
  807. }
  808. $jm_nocc = array_filter($jm_nocc);//去除空值
  809. $jm_nocc = implode("-",$jm_nocc);
  810. $jmlist_nocc .= $jm_nocc.'<br>';
  811. }
  812. $info_list[$key]['dbapinocc'] = $jmlist_nocc ;
  813. }
  814. if(isset($value['lpdl'])){
  815. $tmp_lpdl_str ="";
  816. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  817. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  818. foreach($tmp_fpdata_arr as $v){
  819. if(empty($v)){
  820. continue;
  821. }
  822. $tmp_arr = explode('-',$v);
  823. if(isset($typeclass_lpdl[$tmp_arr[1]])){
  824. $tmp_lpdl_str .= $typeclass_lpdl[$tmp_arr[1]]."<br>";
  825. }else{
  826. $tmp_lpdl_str .= " ";
  827. }
  828. }
  829. $info_list[$key]['lpdl'] = trim($tmp_lpdl_str,"<br>") ;
  830. }
  831. if(isset($value['lhdycc'])){
  832. $tmp_lhdycc_str ="";
  833. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  834. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  835. foreach($tmp_fpdata_arr as $v){
  836. if(empty($v)){
  837. continue;
  838. }
  839. if(stripos($v,',') !== false){
  840. $tmp_arr = explode(',',$v);
  841. if(isset($typeclass_lhdycc[$tmp_arr[0]])){
  842. $tmp_lhdycc_str .= $typeclass_lhdycc[$tmp_arr[0]]."<br>";
  843. }else{
  844. $tmp_lhdycc_str .= "异常 <br>";
  845. }
  846. }else{
  847. $tmp_lhdycc_str .= "无 <br>";
  848. }
  849. }
  850. $info_list[$key]['lhdycc'] = trim($tmp_lhdycc_str,"<br>") ;
  851. }
  852. if(isset($value['product_id'])){
  853. $tmp_product_id = "";
  854. $product_ids = json_decode($value['product_id'],true);
  855. foreach($product_ids as $v){
  856. if(isset($v['product_id'])){
  857. $tmp_product_id .= $v['product_id']."<br>";
  858. }else{
  859. $tmp_product_id .= "<br>";
  860. }
  861. }
  862. $info_list[$key]['product_id'] = $tmp_product_id;
  863. }
  864. if(isset($value['librarytime']))
  865. {
  866. if($value['librarytime'] > 0)
  867. {
  868. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  869. }
  870. }
  871. if(isset($value['buytime']))
  872. {
  873. if($value['buytime'] > 0)
  874. {
  875. $info_list[$key]['buytime'] = date('Y-m-d H:i:s',$value['buytime']);
  876. }
  877. }
  878. if(isset($value['country']))
  879. {
  880. $country = $this->country->read($value['country']);
  881. $info_list[$key]['country'] = $country['name'];
  882. }
  883. if(isset($value['street']))//暂时用街道导出州二字码
  884. {
  885. if($data['country'] == 192)//如果是美国
  886. {
  887. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI');
  888. $data['province'] = preg_replace('/( | |\s)/',' ',$data['province']);
  889. $data['province'] = trim($data['province'],' ');
  890. if(isset($ToState[strtolower($data['province'])]))
  891. {
  892. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  893. }
  894. else
  895. {
  896. $dataprovince = '';
  897. }
  898. $info_list[$key]['street'] = $dataprovince;
  899. }
  900. else
  901. {
  902. $info_list[$key]['street'] = '';
  903. }
  904. }
  905. if(isset($value['pay']))
  906. {
  907. $pay = $this->typeclass->read($value['pay']);
  908. $info_list[$key]['pay'] = $pay['title'];
  909. }
  910. if(isset($value['type']))
  911. {
  912. $type = $this->warehouse->read($value['type']);
  913. $info_list[$key]['type'] = $type['title'];
  914. }
  915. if(isset($value['express']))
  916. {
  917. $express = $this->express->read($value['express']);
  918. if($express)
  919. {
  920. $info_list[$key]['express'] = $express['servicename'];
  921. }
  922. else
  923. {
  924. $info_list[$key]['express'] = '未选择';
  925. }
  926. }
  927. if(isset($value['ccfpdata']))
  928. {
  929. $ccfpdata = explode(';',$value['fpdata']);
  930. $inc = 0;
  931. foreach ($ccfpdata as $v)
  932. {
  933. if(stripos($v,',') !== false)
  934. {
  935. $cc = explode(',',$v);
  936. $inctype = $this->typeclass->read($cc[0]);
  937. if(is_numeric($inctype['spare']))
  938. {
  939. if($inctype['spare'] > $inc)
  940. {
  941. $inc = $inctype['spare'];
  942. }
  943. }
  944. }
  945. }
  946. $info_list[$key]['ccfpdata'] = $inc.'inch';
  947. }
  948. if(isset($value['printtype']))
  949. {
  950. if($value['printtype'] == 1)
  951. {
  952. $info_list[$key]['printtype'] = '运单';
  953. }
  954. else if($value['printtype'] == 2)
  955. {
  956. $info_list[$key]['printtype'] = '发货单';
  957. }
  958. else if($value['printtype'] == 3)
  959. {
  960. $info_list[$key]['printtype'] = '不打印单据';
  961. }
  962. else
  963. {
  964. $info_list[$key]['printtype'] = '未选择';
  965. }
  966. }
  967. if(isset($value['exstate']))
  968. {
  969. if($value['exstate'] == '99')
  970. {
  971. $info_list[$key]['exstate'] = '未获取到物流信息';
  972. }
  973. else if($value['exstate'] == '1')
  974. {
  975. $info_list[$key]['exstate'] = '已揽收';
  976. }
  977. else if($value['exstate'] == '2')
  978. {
  979. $info_list[$key]['exstate'] = '在途中';
  980. }
  981. else if($value['exstate'] == '3')
  982. {
  983. $info_list[$key]['exstate'] = '派送中';
  984. }
  985. else if($value['exstate'] == '4')
  986. {
  987. $info_list[$key]['exstate'] = '已签收';
  988. }
  989. else if($value['exstate'] == '5')
  990. {
  991. $info_list[$key]['exstate'] = '派送异常';
  992. }
  993. else
  994. {
  995. $info_list[$key]['exstate'] = '';
  996. }
  997. }
  998. if(isset($value['link']))
  999. {
  1000. if($value['link'] != '')
  1001. {
  1002. $link = explode(',',$value['link']);
  1003. $info_list[$key]['link'] = $link[0];
  1004. }
  1005. else
  1006. {
  1007. $info_list[$key]['link'] = '';
  1008. }
  1009. }
  1010. if(isset($value['klarnabill']))
  1011. {
  1012. $klarnadata = explode('|',$value['klarnadata']);
  1013. if(isset($klarnadata[2]))
  1014. {
  1015. $info_list[$key]['klarnabill'] = $klarnadata[2];
  1016. }
  1017. else
  1018. {
  1019. $info_list[$key]['klarnabill'] = '';
  1020. }
  1021. }
  1022. if(isset($value['klarnaship']))
  1023. {
  1024. $klarnadata = explode('|',$value['klarnadata']);
  1025. if(isset($klarnadata[3]))
  1026. {
  1027. $info_list[$key]['klarnaship'] = $klarnadata[3];
  1028. }
  1029. else
  1030. {
  1031. $info_list[$key]['klarnaship'] = '';
  1032. }
  1033. }
  1034. if(isset($value['afterpaybill']))
  1035. {
  1036. $klarnadata = explode('|',$value['klarnadata']);
  1037. if(isset($klarnadata[1]))
  1038. {
  1039. $info_list[$key]['afterpaybill'] = $klarnadata[1];
  1040. }
  1041. else
  1042. {
  1043. $info_list[$key]['afterpaybill'] = '';
  1044. }
  1045. }
  1046. if(isset($value['afterpayship']))
  1047. {
  1048. $klarnadata = explode('|',$value['klarnadata']);
  1049. if(isset($klarnadata[2]))
  1050. {
  1051. $info_list[$key]['afterpayship'] = $klarnadata[2];
  1052. }
  1053. else
  1054. {
  1055. $info_list[$key]['afterpayship'] = '';
  1056. }
  1057. }
  1058. if(isset($value['PPname']))
  1059. {
  1060. $info_list[$key]['PPname'] = '';
  1061. $klarnadata = explode('|',$value['klarnadata']);
  1062. if(isset($klarnadata[1]))
  1063. {
  1064. $klarnadata = json_decode($klarnadata[1],true);
  1065. if(isset($klarnadata['name']))
  1066. {
  1067. $info_list[$key]['PPname'] = $klarnadata['name'];
  1068. }
  1069. }
  1070. }
  1071. if(isset($value['PPemail']))
  1072. {
  1073. $info_list[$key]['PPemail'] = '';
  1074. $klarnadata = explode('|',$value['klarnadata']);
  1075. if(isset($klarnadata[1]))
  1076. {
  1077. $klarnadata = json_decode($klarnadata[1],true);
  1078. if(isset($klarnadata['email']))
  1079. {
  1080. if($usp['excelpass'] == '1')
  1081. {
  1082. $ppemailpass = $this->setting->get_excelpass($klarnadata['email']);
  1083. }
  1084. else
  1085. {
  1086. $ppemailpass = $klarnadata['email'];
  1087. }
  1088. $info_list[$key]['PPemail'] = $ppemailpass;
  1089. }
  1090. }
  1091. }
  1092. if(isset($value['PPaddress']))
  1093. {
  1094. $info_list[$key]['PPaddress'] = '';
  1095. $klarnadata = explode('|',$value['klarnadata']);
  1096. if(isset($klarnadata[1]))
  1097. {
  1098. $klarnadata = json_decode($klarnadata[1],true);
  1099. if(isset($klarnadata['address']))
  1100. {
  1101. $info_list[$key]['PPaddress'] = $klarnadata['address'];
  1102. }
  1103. }
  1104. }
  1105. if(isset($value['klarnadata']))
  1106. {
  1107. unset($info_list[$key]['klarnadata']);
  1108. }
  1109. if(isset($value['shippingmethod']))
  1110. {
  1111. $tax = explode('Tax:',$value['shippingmethod']);
  1112. $info_list[$key]['shippingmethod'] = (isset($tax[1]))?trim($tax[1],';'):'';
  1113. }
  1114. if(isset($value['systemwigsout']))
  1115. {
  1116. $out = $this->systemtransfer->find_all("number = '".$data['number']."'");
  1117. $outread = '';
  1118. if($out)
  1119. {
  1120. foreach ($out as $val)
  1121. {
  1122. $list = '';
  1123. $rk = explode('|',trim($val['rk'],'|'));
  1124. $rktime = explode('|',trim($val['rktime'],'|'));
  1125. $zw = array();
  1126. $t = $this->transfer->find_all("1=1");
  1127. foreach ($t as $v)
  1128. {
  1129. $zw[$v['id']] = $v['title'];
  1130. }
  1131. if($val['rk'] != '' && count($rk) > 0)
  1132. {
  1133. for($i=0;$i<count($rk);$i++)
  1134. {
  1135. if(!isset($rktime[$i]))
  1136. {
  1137. $list .= $zw[$cz[$i]];
  1138. }
  1139. else
  1140. {
  1141. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  1142. }
  1143. }
  1144. }
  1145. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  1146. }
  1147. }
  1148. else
  1149. {
  1150. $systemwigsout = $this->systemwigsout->find_all("number = '".$data['number']."'");
  1151. if($systemwigsout)
  1152. {
  1153. foreach ($systemwigsout as $v)
  1154. {
  1155. $outread = '';
  1156. if($v['czwarehouse'] == 37)
  1157. {
  1158. $outread .= '华荣厂';
  1159. }
  1160. else if($v['czwarehouse'] == 0)
  1161. {
  1162. $outread .= '龙盈厂';
  1163. }
  1164. $cz = explode('|',trim($v['cz'],'|'));
  1165. $cztime = explode('|',trim($v['cztime'],'|'));
  1166. $zw = $this->transfer->get_list();
  1167. if($v['cz'] != '' && count($cz) > 0)
  1168. {
  1169. for($i=0;$i<count($cz);$i++)
  1170. {
  1171. if(!isset($cztime[$i]))
  1172. {
  1173. $outread .= $zw[$cz[$i]].' -&gt; ';
  1174. }
  1175. else
  1176. {
  1177. $outread .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  1178. }
  1179. }
  1180. $outread .= '<br>';
  1181. }
  1182. }
  1183. }
  1184. }
  1185. $info_list[$key]['systemwigsout'] = $outread;
  1186. }
  1187. if(isset($value['sourcetype']))
  1188. {
  1189. if($value['sourcetype'] == '1')
  1190. {
  1191. $info_list[$key]['sourcetype'] = '网红单';
  1192. }
  1193. else if($value['sourcetype'] == '2')
  1194. {
  1195. $info_list[$key]['sourcetype'] = '批发单';
  1196. }
  1197. else if($value['sourcetype'] == '3')
  1198. {
  1199. $info_list[$key]['sourcetype'] = '线下单';
  1200. }
  1201. else if($value['sourcetype'] == '4')
  1202. {
  1203. $info_list[$key]['sourcetype'] = '售后单';
  1204. }
  1205. else if($value['sourcetype'] == '5')
  1206. {
  1207. $info_list[$key]['sourcetype'] = '其它';
  1208. }
  1209. else
  1210. {
  1211. $info_list[$key]['sourcetype'] = '';
  1212. }
  1213. }
  1214. if(isset($value['js']))
  1215. {
  1216. if($value['js'] == '0')
  1217. {
  1218. $info_list[$key]['js'] = 'Ground Advantage';
  1219. }
  1220. else if($value['js'] == '1')
  1221. {
  1222. $info_list[$key]['js'] = 'PRIORITY';
  1223. }
  1224. else if($value['js'] == '2')
  1225. {
  1226. $info_list[$key]['js'] = 'EXPRESS';
  1227. }
  1228. else if($value['js'] == '3')
  1229. {
  1230. $info_list[$key]['js'] = 'IP';
  1231. }
  1232. else if($value['js'] == '4')
  1233. {
  1234. $info_list[$key]['js'] = 'FICP';
  1235. }
  1236. }
  1237. if(isset($value['ttcateone'])){
  1238. $info_list[$key]['ttcateone'] = isset($tt_cate_one[$value['ttcateone']])?$tt_cate_one[$value['ttcateone']]:'';
  1239. }
  1240. if(isset($value['ttcatetwo'])){
  1241. $str = "";
  1242. if(isset($tt_cate_two[$value['ttcateone']])){
  1243. if(isset($tt_cate_two[$value['ttcateone']][$value['ttcatetwo']])){
  1244. $str = $tt_cate_two[$value['ttcateone']][$value['ttcatetwo']];
  1245. }
  1246. }
  1247. $info_list[$key]['ttcatetwo'] = $str;
  1248. }
  1249. if(isset($value['type']))
  1250. {
  1251. $type = $this->warehouse->read($value['type']);
  1252. $info_list[$key]['type'] = $type['title'];
  1253. }
  1254. if(isset($value['xdcs']))
  1255. {
  1256. if($sj == 'fullorder')
  1257. {
  1258. $xdcs = $this->customer->get_email($data['email'],$data['shop']);
  1259. }
  1260. else
  1261. {
  1262. $xdcs = $this->customersmt->get_shopdata($data['shop'],$data['name'],$data['address']);
  1263. }
  1264. $info_list[$key]['xdcs'] = (isset($xdcs['num']))?(($xdcs['num']==0)?1:$xdcs['num']):1;
  1265. }
  1266. if(isset($value['dbapi']) || isset($value['scapi']))
  1267. {
  1268. $jmlist = '';$shuliang = '';
  1269. $classid = $this->classid->sku();
  1270. $dbapi = explode(';',trim($value['fpdata'],';'));
  1271. foreach ($dbapi as $va)
  1272. {
  1273. $pm = $classid;
  1274. $jm = $classid;
  1275. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1276. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1277. $ts = explode('|',trim($features,'|'));
  1278. if(stripos($ts[0],',') !== false)
  1279. {
  1280. $ft = explode(',',$ts[0]);
  1281. $features = explode('-',trim($ft[1],'-'));
  1282. $features[] = $ft[0];
  1283. }
  1284. else
  1285. {
  1286. $features = explode('-',trim($ts[0],'-'));
  1287. }
  1288. foreach($features as $k=>$v)
  1289. {
  1290. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1291. {
  1292. if($typeclass[$v]['bm'] != '')
  1293. {
  1294. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1295. }
  1296. }
  1297. if($v != 0 && isset($typeclass[$v]))
  1298. {
  1299. if($typeclass[$v]['classid'] == 13)
  1300. {
  1301. $dj = $typeclass[$v]['title'];
  1302. }
  1303. if($typeclass[$v]['classid'] == 8)
  1304. {
  1305. $ys = $typeclass[$v]['title'];
  1306. }
  1307. if($typeclass[$v]['classid'] == 15)
  1308. {
  1309. $hx = $typeclass[$v]['title'];
  1310. }
  1311. if(isset($pm[$typeclass[$v]['classid']]))
  1312. {
  1313. if($typeclass[$v]['title'] == '9A')
  1314. {
  1315. $pm[$typeclass[$v]['classid']] = '9A';
  1316. }
  1317. else if($typeclass[$v]['title'] == '10A')
  1318. {
  1319. $pm[$typeclass[$v]['classid']] = '10A';
  1320. }
  1321. else
  1322. {
  1323. $clzh = $typeclass[$v]['zh'];
  1324. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1325. {
  1326. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1327. $clzh = $clzh[0];
  1328. }
  1329. $pm[$typeclass[$v]['classid']] = $clzh;
  1330. }
  1331. }
  1332. if(isset($jm[$typeclass[$v]['classid']]))
  1333. {
  1334. if($typeclass[$v]['jm'])
  1335. {
  1336. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1337. }
  1338. }
  1339. }
  1340. }
  1341. $jm = array_filter($jm);//去除空值
  1342. $jm = implode("-",$jm);
  1343. $jmlist .= $jm.'<br>';
  1344. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  1345. $pm = array_filter($pm);//去除空值
  1346. $zh = implode(" ",$pm);
  1347. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1348. }
  1349. if(isset($value['dbapi']))
  1350. {
  1351. $info_list[$key]['dbapi'] = $jmlist;
  1352. }
  1353. else
  1354. {
  1355. $info_list[$key]['scapi'] = $shuliang;
  1356. }
  1357. }
  1358. if(isset($value['dbapi']) && isset($value['scapi']))
  1359. {
  1360. $jmlist = '';$shuliang = '';
  1361. $classid = $this->classid->sku();
  1362. $dbapi = explode(';',trim($value['fpdata'],';'));
  1363. foreach ($dbapi as $va)
  1364. {
  1365. $pm = $classid;
  1366. $jm = $classid;
  1367. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1368. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1369. $ts = explode('|',trim($features,'|'));
  1370. if(stripos($ts[0],',') !== false)
  1371. {
  1372. $ft = explode(',',$ts[0]);
  1373. $features = explode('-',trim($ft[1],'-'));
  1374. $features[] = $ft[0];
  1375. }
  1376. else
  1377. {
  1378. $features = explode('-',trim($ts[0],'-'));
  1379. }
  1380. foreach($features as $k=>$v)
  1381. {
  1382. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1383. {
  1384. if($typeclass[$v]['bm'] != '')
  1385. {
  1386. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1387. }
  1388. }
  1389. if($v != 0 && isset($typeclass[$v]))
  1390. {
  1391. if($typeclass[$v]['classid'] == 13)
  1392. {
  1393. $dj = $typeclass[$v]['title'];
  1394. }
  1395. if($typeclass[$v]['classid'] == 8)
  1396. {
  1397. $ys = $typeclass[$v]['title'];
  1398. }
  1399. if($typeclass[$v]['classid'] == 15)
  1400. {
  1401. $hx = $typeclass[$v]['title'];
  1402. }
  1403. if(isset($pm[$typeclass[$v]['classid']]))
  1404. {
  1405. if($typeclass[$v]['title'] == '9A')
  1406. {
  1407. $pm[$typeclass[$v]['classid']] = '9A';
  1408. }
  1409. else if($typeclass[$v]['title'] == '10A')
  1410. {
  1411. $pm[$typeclass[$v]['classid']] = '10A';
  1412. }
  1413. else
  1414. {
  1415. $clzh = $typeclass[$v]['zh'];
  1416. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1417. {
  1418. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1419. $clzh = $clzh[0];
  1420. }
  1421. $pm[$typeclass[$v]['classid']] = $clzh;
  1422. }
  1423. }
  1424. if(isset($jm[$typeclass[$v]['classid']]))
  1425. {
  1426. if($typeclass[$v]['jm'])
  1427. {
  1428. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1429. }
  1430. }
  1431. }
  1432. }
  1433. $jm = array_filter($jm);//去除空值
  1434. $jm = implode("-",$jm);
  1435. $jmlist .= $jm.'<br>';
  1436. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  1437. $pm = array_filter($pm);//去除空值
  1438. $zh = implode(" ",$pm);
  1439. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1440. }
  1441. $info_list[$key]['dbapi'] = $jmlist;
  1442. $info_list[$key]['scapi'] = $shuliang;
  1443. }
  1444. if(isset($value['cpfpdata']))
  1445. {
  1446. $fpread = '';
  1447. $cpfpdata = explode(';',trim($value['fpdata'],';'));
  1448. foreach ($cpfpdata as $v)
  1449. {
  1450. $va = explode('|',trim($v,'|'));
  1451. if(isset($va[1])){
  1452. $fpread .= $va[1].'; ';
  1453. }else{
  1454. $fpread .="合并单没有产品异常标记";
  1455. }
  1456. }
  1457. $info_list[$key]['cpfpdata'] = $fpread;
  1458. }
  1459. if(count($goods_sku_list) > 0){
  1460. $ret_goods_sku = $this->_getGoodsInfo($value,$goods_sku_list,$typeclass);
  1461. if(in_array("gradefpdata",$goods_sku_list)){
  1462. $info_list[$key]['gradefpdata'] = trim($ret_goods_sku['gradefpdata'],"<br>");
  1463. }
  1464. if(in_array("colorfpdata",$goods_sku_list)){
  1465. $info_list[$key]['colorfpdata'] = trim($ret_goods_sku['colorfpdata'],"<br>");
  1466. }
  1467. if(in_array("densityfpdata",$goods_sku_list)){
  1468. $info_list[$key]['densityfpdata'] = trim($ret_goods_sku['densityfpdata'],"<br>");
  1469. }
  1470. if(in_array("hairnumberfpdata",$goods_sku_list)){
  1471. $info_list[$key]['hairnumberfpdata'] = trim($ret_goods_sku['hairnumberfpdata'],"<br>");
  1472. }
  1473. if(in_array("lacetypefpdata",$goods_sku_list)){
  1474. $info_list[$key]['lacetypefpdata'] = trim($ret_goods_sku['lacetypefpdata'],"<br>");
  1475. }
  1476. //lowefpdata
  1477. if(in_array("lowefpdata",$goods_sku_list)){
  1478. $info_list[$key]['lowefpdata'] = trim($ret_goods_sku['lowefpdata'],"<br>");
  1479. }
  1480. }
  1481. if(isset($value['jweight'])){
  1482. $info_list[$key]['jweight'] = empty($value['jweight'])?0:$value['jweight']*0.001;
  1483. }
  1484. unset($info_list[$key]['id']);
  1485. unset($info_list[$key]['fpdata']);
  1486. }
  1487. $fzh = "";
  1488. foreach ($fexcelzh as $v)
  1489. {
  1490. $fzh .= "<td>".$v."</td>";
  1491. }
  1492. $data = array($shouldmoney.' CNY');
  1493. $title = $fexcel['title'].'-'.date('Ymd',time());
  1494. $titlename = "<table border=1>
  1495. <tr>"
  1496. .$fzh.
  1497. "</tr>
  1498. </table>";
  1499. $tail = "\n";
  1500. $filename = $title.".xls";
  1501. $this->excelxh->get_fz5($info_list,$titlename,$filename,$tail,$kong);
  1502. }
  1503. }
  1504. //根据fpdata获取商品sku属性
  1505. private function _getGoodsInfo($value,$goods_sku_list,$typeclass){
  1506. $tmp_goods = explode(';',trim($value['fpdata'],';'));
  1507. $sku_gradefpdata_str = $sku_colorfpdata_str = $sku_densityfpdata_str = $sku_hairnumberfpdata_str = $sku_lacetypefpdata_str = $sku_lowefpdata_str = "";
  1508. foreach($tmp_goods as $tmp_goods_item){
  1509. $dq_goods_item = explode('|',trim($tmp_goods_item,'|'));
  1510. //'gradefpdata','colorfpdata','densityfpdata','hairnumberfpdata','lacetypefpdata'
  1511. $ddq_goods_item = explode('-',trim($dq_goods_item[0],'-'));
  1512. $now_good_sku_info = [];
  1513. foreach($ddq_goods_item as $ll){
  1514. if(!empty($typeclass[$ll])){
  1515. $now_good_sku_info[$typeclass[$ll]['classid']] = empty($typeclass[$ll]['jm'])? " --" : $typeclass[$ll]['jm'];
  1516. }
  1517. }
  1518. if(isset($now_good_sku_info[13])){
  1519. $sku_gradefpdata_str .= $now_good_sku_info[13]."<br/>";
  1520. }else{
  1521. $sku_gradefpdata_str .= " -- <br/>";
  1522. }
  1523. if(isset($now_good_sku_info[8])){
  1524. $sku_colorfpdata_str .= $now_good_sku_info[8]."<br/>";
  1525. }else{
  1526. $sku_colorfpdata_str .= " -- <br/>";
  1527. }
  1528. if(isset($now_good_sku_info[10])){
  1529. $sku_densityfpdata_str .= $now_good_sku_info[10]."<br/>";
  1530. }else{
  1531. $sku_densityfpdata_str .= " -- <br/>";
  1532. }
  1533. if(isset($now_good_sku_info[43])){
  1534. $sku_hairnumberfpdata_str .= $now_good_sku_info[43]."<br/>";
  1535. }else{
  1536. $sku_hairnumberfpdata_str .= " -- <br/>";
  1537. }
  1538. if(isset($now_good_sku_info[18])){
  1539. $sku_lacetypefpdata_str .= $now_good_sku_info[18]."<br/>";
  1540. }else{
  1541. $sku_lacetypefpdata_str .= " -- <br/>";
  1542. }
  1543. if(isset($now_good_sku_info[15])){
  1544. $sku_lowefpdata_str .= $now_good_sku_info[15]."<br/>";
  1545. }else{
  1546. $sku_lowefpdata_str .= " -- <br/>";
  1547. }
  1548. // if($typeclass[$ll]['classid'] == 13){
  1549. // //等级
  1550. // $sku_gradefpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1551. // }elseif($typeclass[$ll]['classid'] == 8){
  1552. // //颜色
  1553. // $sku_colorfpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1554. // }elseif($typeclass[$ll]['classid'] == 10){
  1555. // //密度
  1556. // $sku_densityfpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1557. // }elseif($typeclass[$ll]['classid'] == 43){
  1558. // //人发头套编码
  1559. // $sku_hairnumberfpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1560. // }elseif($typeclass[$ll]['classid'] == 18){
  1561. // //头套种类
  1562. // $sku_lacetypefpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1563. // }
  1564. }
  1565. return [
  1566. 'gradefpdata' => trim($sku_gradefpdata_str,"<br/>"),
  1567. 'colorfpdata' => trim($sku_colorfpdata_str,"<br/>"),
  1568. 'densityfpdata' => trim($sku_densityfpdata_str,"<br/>"),
  1569. 'hairnumberfpdata' => trim($sku_hairnumberfpdata_str,"<br/>"),
  1570. 'lacetypefpdata' => trim($sku_lacetypefpdata_str,"<br/>"),
  1571. 'lowefpdata'=>trim($sku_lowefpdata_str,"<br/>"),
  1572. ];
  1573. }
  1574. //导出订单excel
  1575. public function _excelhz()
  1576. {
  1577. $fgshop = "";$sid = "";$excelshop="";
  1578. if(isset($_SESSION['api']))
  1579. {
  1580. $user = $this->user->get_api($_SESSION['api']);
  1581. $usp = $user;
  1582. $usersp = explode('|',trim($user['shop'],'|'));
  1583. foreach ($usersp as $value)
  1584. {
  1585. $fgshop .= " shop = ".$value." or";
  1586. $sid .= " id = ".$value." or";
  1587. }
  1588. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1589. if($user['excelshop'] == '')
  1590. {
  1591. echo "没有下载权限";exit;
  1592. }
  1593. foreach ($userexcel as $value)
  1594. {
  1595. $excelshop .= " shop = ".$value." or";
  1596. }
  1597. if($excelshop != "")
  1598. {
  1599. $excelshop = "(".rtrim($excelshop,'or').")";
  1600. }
  1601. }
  1602. if(isset($_GET['fexcel']))
  1603. {
  1604. $typeclass = array();
  1605. $tclass = $this->typeclass->find_all();
  1606. foreach ($tclass as $v)
  1607. {
  1608. $typeclass[$v['id']] = $v;
  1609. }
  1610. $dowid = $this->input->get('a');
  1611. $wid = "";
  1612. if($dowid != "")
  1613. {
  1614. $id_arr = explode(',',rtrim($dowid,','));
  1615. $wid .= " id = 0 or";
  1616. foreach ($id_arr as $v)
  1617. {
  1618. $wid .= " id = '$v' or";
  1619. }
  1620. $wid = " and (".rtrim($wid,'or').") ";
  1621. }
  1622. $fexcel = $this->input->get('fexcel',true);
  1623. $page = $this->input->get('page',true);
  1624. $perpage = $this->input->get('perpage',true);
  1625. $warehouse = $this->input->get('warehouse',true);
  1626. $timetk = $this->input->get('timetk',true);
  1627. $timetj = $this->input->get('timetj',true);
  1628. $shop = $this->input->get('shop',true);
  1629. $source = $this->input->get('source',true);
  1630. $state = $this->input->get('state',true);
  1631. $review = $this->input->get('review',true);
  1632. $type = $this->input->get('type',true);
  1633. $express = $this->input->get('express',true);
  1634. $orderinfo = $this->input->get('orderinfo',true);
  1635. $user = $this->input->get('user',true);
  1636. $client = $this->input->get('name',true);
  1637. $waybill = $this->input->get('waybill',true);
  1638. $number = $this->input->get('number',true);
  1639. $email = $this->input->get('email',true);
  1640. $dlz = $this->input->get('dlz',true);
  1641. $library = $this->input->get('library',true);
  1642. $libraryconfirm = $this->input->get('libraryconfirm',true);
  1643. $print = $this->input->get('print',true);
  1644. $timetkk = $this->input->get('timetkk',true);
  1645. $timetjj = $this->input->get('timetjj',true);
  1646. $xztime = $this->input->get('xztime',true);
  1647. $country = $this->input->get('country',true);
  1648. $zf = $this->input->get('zf',true);
  1649. $pay = $this->input->get('pay',true);
  1650. $phone = $this->input->get('phone',true);
  1651. $so = $this->input->get('so',true);
  1652. $sfxh = $this->input->get('sfxh',true);
  1653. $xdcs = $this->input->get('xdcs',true);
  1654. $xdcs = $this->input->get('xdcs',true);
  1655. $dbapi = $this->input->get('dbapi',true);
  1656. $dbapinocc = $this->input->get('dbapinocc',true);
  1657. $orderurl = $this->input->get('orderurl',true);
  1658. $productid = $this->input->get('productid',true);
  1659. $timetk = strtotime($timetk);
  1660. $timetj = strtotime($timetj);
  1661. $timetkk = strtotime($timetkk);
  1662. $timetjj = strtotime($timetjj);
  1663. $px = $this->input->get('px',true);
  1664. $fexcel = $this->fullorderexcel->read($fexcel);
  1665. $classid = $this->fullorderexcelclassid->read($fexcel['type']);
  1666. $where = "1 = 1 and (".rtrim($fgshop,'or').")";
  1667. if($warehouse)
  1668. {
  1669. $where .= " and type = '$warehouse'";
  1670. }
  1671. if($xztime)
  1672. {
  1673. if($timetk && $timetj)
  1674. {
  1675. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  1676. }
  1677. if($timetkk && $timetjj)
  1678. {
  1679. $where .= " and ".$xztime." > '$timetkk' and ".$xztime." < '$timetjj'";
  1680. }
  1681. }
  1682. else
  1683. {
  1684. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  1685. }
  1686. if($productid){
  1687. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  1688. }
  1689. if($library)
  1690. {
  1691. $where .= " and library = '$library'";
  1692. }
  1693. if($print)
  1694. {
  1695. $where .= " and print = '$print'";
  1696. }
  1697. if($shop)
  1698. {
  1699. $where .= " and shop = '$shop'";
  1700. }
  1701. if($source)
  1702. {
  1703. if($source == '2d')
  1704. {
  1705. $where .= " and source >= '2'";
  1706. }
  1707. else
  1708. {
  1709. $where .= " and source = '$source'";
  1710. }
  1711. }
  1712. if($state)
  1713. {
  1714. $where .= " and state = '$state'";
  1715. }
  1716. if($review)
  1717. {
  1718. $where .= " and review = '$review'";
  1719. }
  1720. if($type)
  1721. {
  1722. $where .= " and type = '$type'";
  1723. }
  1724. if($express)
  1725. {
  1726. $where .= " and express = '$express'";
  1727. }
  1728. if($orderinfo)
  1729. {
  1730. $where .= " and orderinfo = '$orderinfo'";
  1731. }
  1732. if($user)
  1733. {
  1734. $where .= " and user = '$user'";
  1735. }
  1736. if($client)
  1737. {
  1738. $where .= " and client like '%$client%'";
  1739. }
  1740. if($waybill)
  1741. {
  1742. $where .= " and waybill = '$waybill'";
  1743. }
  1744. if($number)
  1745. {
  1746. $where .= " and number = '$number'";
  1747. }
  1748. if($email)
  1749. {
  1750. $where .= " and email = '$email'";
  1751. }
  1752. if($country)
  1753. {
  1754. $where .= " and country = '$country'";
  1755. }
  1756. if($dlz)
  1757. {
  1758. $where .= " and waybill != '' and dlz = 0";
  1759. }
  1760. if($libraryconfirm)
  1761. {
  1762. $where .= " and libraryconfirm = '$libraryconfirm'";
  1763. }
  1764. if($so)
  1765. {
  1766. $where .= " and shipremarks like '%$so%'";
  1767. }
  1768. if($pay)
  1769. {
  1770. $where .= " and pay = '$pay'";
  1771. }
  1772. if($phone)
  1773. {
  1774. $where .= " and phone = '$phone'";
  1775. }
  1776. if($sfxh != '')
  1777. {
  1778. $where .= " and sfxh = '$sfxh'";
  1779. }
  1780. if($orderurl)
  1781. {
  1782. $url = $this->orderurl->read($orderurl);
  1783. $where .= " and link like '%".$url['url']."%'";
  1784. }
  1785. if($zf)
  1786. {
  1787. if($zf == 1)
  1788. {
  1789. $where .= " and paypal not like '%-%-%-%'";
  1790. }
  1791. else
  1792. {
  1793. $where .= " and paypal like '%-%-%-%'";
  1794. }
  1795. }
  1796. $sj = $this->input->get('sj',true);
  1797. if($sj)
  1798. {
  1799. $sj = $this->input->get('sj',true);
  1800. }
  1801. else
  1802. {
  1803. $sj = $classid['type'];
  1804. }
  1805. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  1806. foreach ($fexceleq as $k=>$v)
  1807. {
  1808. $fexceleq[$k] = explode('-',$v);
  1809. $num[$k] = $fexceleq[$k][0];
  1810. }
  1811. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  1812. $feq = "";$kong = array();$sku9610 = '';$goods_sku_list = [];
  1813. foreach ($fexceleq as $k=>$v)
  1814. {
  1815. if(isset($v[1]))
  1816. {
  1817. if($v[1] == 'klarnabill' || $v[1] == 'klarnaship' || $v[1] == 'PPname' || $v[1] == 'PPaddress' || $v[1] == 'PPemail' || $v[1] == 'afterpayship' || $v[1] == 'afterpaybill')
  1818. {
  1819. $feq .= 'klarnadata,';
  1820. }
  1821. if($v[1] == 'ccfpdata' || $v[1] == 'cpfpdata' || $v[1] == 'dbapi' || $v[1] == 'scapi')
  1822. {
  1823. $feq .= 'fpdata,';
  1824. }
  1825. if(in_array($v[1],['gradefpdata','colorfpdata','densityfpdata','hairnumberfpdata','lacetypefpdata','lowefpdata'])){
  1826. $goods_sku_list[] = $v[1];
  1827. continue;
  1828. }
  1829. if($v[1] != 'kong')//空值去除
  1830. {
  1831. if($v[1] == '9610sku' || $v[1] == 'issku' || $v[1] == 'sku')
  1832. {
  1833. if($v[1] == '9610sku')
  1834. {
  1835. $sku9610 = 1;
  1836. }
  1837. if($sj == 'fullordersmt')
  1838. {
  1839. $v[1] = 'sku';
  1840. }
  1841. else
  1842. {
  1843. $v[1] = 'issku';
  1844. }
  1845. }
  1846. $feq .= $v[1].',';
  1847. }
  1848. else
  1849. {
  1850. $kong[$v[0]] = 1;
  1851. }
  1852. }
  1853. }
  1854. //处理额外加上的subtotal和rowtoal 但是不想在表中加太多字段 想着以后有关金额的都给怼到extra_price字段中
  1855. if((strpos($feq,'subtotal')!= false)||(strpos($feq,'rowtotal')!= false) ||(strpos($feq,'product_id')!= false)){
  1856. if(strpos($feq,'subtotal')!= false){
  1857. $feq = str_replace('subtotal,',"extra_price as subtotal,",$feq);
  1858. }
  1859. if(strpos($feq,'rowtotal')!= false){
  1860. $feq = str_replace('rowtotal,',"extra_price as rowtotal,",$feq);
  1861. }
  1862. if(strpos($feq,'product_id')!= false){
  1863. $feq = str_replace('product_id,',"extra_price as product_id,",$feq);
  1864. }
  1865. }
  1866. //添加订单前缀
  1867. $shopqz_list = [];
  1868. if(strpos($feq,'shopqz') !== false){
  1869. $feq = str_replace('shopqz,',"shop as shopqz,",$feq);
  1870. $shop_list = $this->shop->find_all("1 = 1","id,shortname");
  1871. $shopqz_list = array_column($shop_list,'shortname','id');
  1872. }
  1873. //$dbapi_nocc
  1874. if(strpos($feq,'dbapinocc')!= false){
  1875. $feq = str_replace('dbapinocc,',"fpdata as dbapinocc,",$feq);
  1876. }
  1877. $typeclass_lpdl = [];
  1878. //料品大类
  1879. if(strpos($feq,'lpdl')!= false){
  1880. $feq = str_replace('lpdl,',"fpdata as lpdl,",$feq);
  1881. $tmp_typeclass_lpdl = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',16)->get()->result_array();
  1882. $typeclass_lpdl = array_column($tmp_typeclass_lpdl,'zh','id');
  1883. }
  1884. $typeclass_lhdycc = [];
  1885. //料号对应尺寸
  1886. if(strpos($feq,'lhdycc')!= false){
  1887. $feq = str_replace('lhdycc,',"fpdata as lhdycc,",$feq);
  1888. $tmp_typeclass_lhdycc = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',14)->get()->result_array();
  1889. $typeclass_lhdycc = array_column($tmp_typeclass_lhdycc,'zh','id');
  1890. }
  1891. $feq = rtrim($feq,',');
  1892. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  1893. foreach ($fexcelzhw as $k=>$v)
  1894. {
  1895. $fexcelzhw[$k] = explode('-',$v);
  1896. $numb[$k] = $fexcelzhw[$k][0];
  1897. }
  1898. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  1899. $fexcelzh = array();
  1900. foreach ($fexcelzhw as $k=>$v)
  1901. {
  1902. $fexcelzh[] = $v[1];
  1903. }
  1904. if($px)
  1905. {
  1906. $order_str = $px." desc";
  1907. }
  1908. else
  1909. {
  1910. $order_str = "id desc";
  1911. }
  1912. // if($_GET['fexcel'] == '157'){
  1913. // $this->logic_ding->sendToDing("excel导出的【".$where.$wid.' and '.$excelshop);
  1914. // $this->logic_ding->sendToDing("excel导出的【".'id,'.$feq);
  1915. // $this->logic_ding->sendToDing("excel导出的【".$order_str);
  1916. // $this->logic_ding->sendToDing("excel导出的SJ【".$sj);
  1917. // }
  1918. $extra = [
  1919. 'usp'=>$usp,
  1920. 'sku9610'=>$sku9610,
  1921. 'typeclass_lpdl'=>$typeclass_lpdl,
  1922. 'typeclass_lhdycc'=>$typeclass_lhdycc,
  1923. 'goods_sku_list'=>$goods_sku_list,
  1924. 'typeclass'=>$typeclass,
  1925. ];
  1926. $dlz_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullorder',$extra);
  1927. $tt_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullordertt',$extra);
  1928. $smt_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullordersmt',$extra);
  1929. $amz_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullorderamz',$extra);
  1930. $info_list = array_merge( $dlz_ret['info_list'],$tt_ret['info_list'],$smt_ret['info_list'],$amz_ret['info_list']);
  1931. $shouldmoney = $dlz_ret['shouldmoney']+$tt_ret['shouldmoney']+$smt_ret['shouldmoney']+$amz_ret['shouldmoney'];
  1932. $fzh = "";
  1933. foreach ($fexcelzh as $v)
  1934. {
  1935. $fzh .= "<td>".$v."</td>";
  1936. }
  1937. $data = array($shouldmoney.' CNY');
  1938. $title = $fexcel['title'].'-'.date('Ymd',time());
  1939. $titlename = "<table border=1>
  1940. <tr>"
  1941. .$fzh.
  1942. "</tr>
  1943. </table>";
  1944. $tail = "\n";
  1945. $filename = $title.".xls";
  1946. $this->excel->get_fz5($info_list,$titlename,$filename,$tail,$kong);
  1947. }
  1948. }
  1949. public function _datahz($where,$field,$order_str,$sj,$extra){
  1950. $goods_sku_list = $extra['goods_sku_list'] ;
  1951. $typeclass = $extra['typeclass'];
  1952. //取得信息列表,防止SQL字段不存在导致程序崩溃
  1953. try {
  1954. $info_list = $this->$sj->find_all($where,$field,$order_str);
  1955. } catch (Throwable $e) {
  1956. $info_list = array();
  1957. }
  1958. //格式化数据
  1959. $i = 1;$shouldmoney = 0;$hl=1;
  1960. $usp = $extra['usp'];
  1961. $sku9610 = $extra['sku9610'];
  1962. $typeclass_lpdl = $extra['typeclass_lpdl'];
  1963. $typeclass_lhdycc = $extra['typeclass_lhdycc'];
  1964. foreach ($info_list as $key=>$value)
  1965. {
  1966. $data = $this->$sj->read($value['id']);
  1967. $data = str_replace(array("'"),array("’"),$data);
  1968. if(isset($value['email']) && $usp['excelpass'] == '1')
  1969. {
  1970. $emailpass = $this->setting->get_excelpass($value['email']);
  1971. $info_list[$key]['email'] = $emailpass;
  1972. }
  1973. if(isset($value['phone']) && $usp['excelpass'] == '1')
  1974. {
  1975. $phonepass = $this->setting->get_excelpass($value['phone']);
  1976. $info_list[$key]['phone'] = $phonepass;
  1977. }
  1978. if(isset($value['currencytitle']))
  1979. {
  1980. if($value['currencytitle'] != "CNY")
  1981. {
  1982. $hl=$value['hl'];
  1983. }
  1984. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  1985. }
  1986. if(isset($value['shop']))
  1987. {
  1988. $shop = $this->shop->read($value['shop']);
  1989. $info_list[$key]['shop'] = $shop['shopname'];
  1990. }
  1991. if(isset($value['dtime']))
  1992. {
  1993. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  1994. }
  1995. if(isset($value['printtime']))
  1996. {
  1997. if($value['printtime'] > 0)
  1998. {
  1999. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2000. }
  2001. }
  2002. if(isset($value['sku']))
  2003. {
  2004. if($sku9610 == '1')
  2005. {
  2006. $aesku = explode(';',$value['sku']);
  2007. $aesku = $aesku[0];
  2008. $aesku = explode(':',$aesku);
  2009. if(count($aesku) > 1)
  2010. {
  2011. $aesku = $aesku[1];
  2012. $aesku = str_replace('--','~',$aesku);
  2013. $aesku = explode('-',$aesku);
  2014. $aesku = $aesku[0];
  2015. $aesku = str_replace('~','--',$aesku);
  2016. $info_list[$key]['sku'] = $aesku;
  2017. }
  2018. else
  2019. {
  2020. $info_list[$key]['sku'] = '';
  2021. }
  2022. }
  2023. else
  2024. {
  2025. $info_list[$key]['sku'] = $value['sku'];
  2026. }
  2027. }
  2028. if(isset($value['issku']))
  2029. {
  2030. $value['issku'] = str_replace(array('&lt;','&gt;'),array('<','>'),$value['issku']);
  2031. if($sku9610 == '1')
  2032. {
  2033. $aesku = explode(';',$value['issku']);
  2034. $aesku = $aesku[0];
  2035. $aesku = str_replace('--','~',$aesku);
  2036. $aesku = explode('-',$aesku);
  2037. $aesku = $aesku[0];
  2038. $aesku = str_replace('~','--',$aesku);
  2039. $aesku = str_replace(array('<','>'),array('&lt;','&gt;'),$aesku);
  2040. $info_list[$key]['issku'] = $aesku;
  2041. }
  2042. else
  2043. {
  2044. $value['issku'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['issku']);
  2045. $info_list[$key]['issku'] = $value['issku'];
  2046. }
  2047. }
  2048. if(isset($value['subtotal'])){
  2049. $tmp_sub_str = "";
  2050. $subtotal_list = json_decode($value['subtotal'],true);
  2051. foreach($subtotal_list as $v){
  2052. if(isset($v['sub_total'])){
  2053. $tmp_sub_str .= sprintf( "%.2f",$v['sub_total'])."<br>";
  2054. }else{
  2055. $tmp_sub_str .= "0<br>";
  2056. }
  2057. }
  2058. $info_list[$key]['subtotal'] = $tmp_sub_str;
  2059. }
  2060. if(isset($value['rowtotal'])){
  2061. $tmp_sub_str = "";
  2062. $subtotal_list = json_decode($value['rowtotal'],true);
  2063. foreach($subtotal_list as $v){
  2064. if(isset($v['row_total'])){
  2065. $tmp_sub_str .= sprintf( "%.2f",$v['row_total'])."<br>";
  2066. }else{
  2067. $tmp_sub_str .= "0<br>";
  2068. }
  2069. }
  2070. $info_list[$key]['rowtotal'] = $tmp_sub_str;
  2071. }
  2072. if(isset($value['dbapinocc'])){
  2073. $jmlist_nocc = '';
  2074. $classid = $this->classid->sku();
  2075. $dbapi = explode(';',trim($value['dbapinocc'],';'));
  2076. foreach ($dbapi as $va)
  2077. {
  2078. $jm_nocc = $classid;
  2079. unset($jm_nocc[14]);
  2080. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2081. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2082. $ts = explode('|',trim($features,'|'));
  2083. if(stripos($ts[0],',') !== false)
  2084. {
  2085. $ft = explode(',',$ts[0]);
  2086. $features = explode('-',trim($ft[1],'-'));
  2087. $features[] = $ft[0];
  2088. }
  2089. else
  2090. {
  2091. $features = explode('-',trim($ts[0],'-'));
  2092. }
  2093. foreach($features as $k=>$v)
  2094. {
  2095. if($v != 0 && isset($typeclass[$v]))
  2096. {
  2097. if(isset($jm_nocc[$typeclass[$v]['classid']]))
  2098. {
  2099. if($typeclass[$v]['jm'])
  2100. {
  2101. $jm_nocc[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2102. }
  2103. }
  2104. }
  2105. }
  2106. $jm_nocc = array_filter($jm_nocc);//去除空值
  2107. $jm_nocc = implode("-",$jm_nocc);
  2108. $jmlist_nocc .= $jm_nocc.'<br>';
  2109. }
  2110. $info_list[$key]['dbapinocc'] = $jmlist_nocc ;
  2111. }
  2112. if(isset($value['lpdl'])){
  2113. $tmp_lpdl_str ="";
  2114. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  2115. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  2116. foreach($tmp_fpdata_arr as $v){
  2117. if(empty($v)){
  2118. continue;
  2119. }
  2120. $tmp_arr = explode('-',$v);
  2121. if(isset($typeclass_lpdl[$tmp_arr[1]])){
  2122. $tmp_lpdl_str .= $typeclass_lpdl[$tmp_arr[1]]."<br>";
  2123. }else{
  2124. $tmp_lpdl_str .= " ";
  2125. }
  2126. }
  2127. $info_list[$key]['lpdl'] = trim($tmp_lpdl_str,"<br>") ;
  2128. }
  2129. if(isset($value['lhdycc'])){
  2130. $tmp_lhdycc_str ="";
  2131. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  2132. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  2133. foreach($tmp_fpdata_arr as $v){
  2134. if(empty($v)){
  2135. continue;
  2136. }
  2137. if(stripos($v,',') !== false){
  2138. $tmp_arr = explode(',',$v);
  2139. if(isset($typeclass_lhdycc[$tmp_arr[0]])){
  2140. $tmp_lhdycc_str .= $typeclass_lhdycc[$tmp_arr[0]]."<br>";
  2141. }else{
  2142. $tmp_lhdycc_str .= "异常 <br>";
  2143. }
  2144. }else{
  2145. $tmp_lhdycc_str .= "无 <br>";
  2146. }
  2147. }
  2148. $info_list[$key]['lhdycc'] = trim($tmp_lhdycc_str,"<br>") ;
  2149. }
  2150. if(isset($value['shopqz'])){
  2151. $info_list[$key]['shopqz'] = isset($shopqz_list[$value['shopqz']])?$shopqz_list[$value['shopqz']]:'';
  2152. }
  2153. if(isset($value['product_id'])){
  2154. $tmp_product_id = "";
  2155. $product_ids = json_decode($value['product_id'],true);
  2156. foreach($product_ids as $v){
  2157. if(isset($v['product_id'])){
  2158. $tmp_product_id .= $v['product_id']."<br>";
  2159. }else{
  2160. $tmp_product_id .= "<br>";
  2161. }
  2162. }
  2163. $info_list[$key]['product_id'] = $tmp_product_id;
  2164. }
  2165. if(isset($value['librarytime']))
  2166. {
  2167. if($value['librarytime'] > 0)
  2168. {
  2169. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2170. }
  2171. }
  2172. if(isset($value['buytime']))
  2173. {
  2174. if($value['buytime'] > 0)
  2175. {
  2176. $info_list[$key]['buytime'] = date('Y-m-d H:i:s',$value['buytime']);
  2177. }
  2178. }
  2179. if(isset($value['country']))
  2180. {
  2181. $country = $this->country->read($value['country']);
  2182. $info_list[$key]['country'] = $country['name'];
  2183. }
  2184. if(isset($value['street']))//暂时用街道导出州二字码
  2185. {
  2186. if($data['country'] == 192)//如果是美国
  2187. {
  2188. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI');
  2189. $data['province'] = preg_replace('/( | |\s)/',' ',$data['province']);
  2190. $data['province'] = trim($data['province'],' ');
  2191. if(isset($ToState[strtolower($data['province'])]))
  2192. {
  2193. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  2194. }
  2195. else
  2196. {
  2197. $dataprovince = '';
  2198. }
  2199. $info_list[$key]['street'] = $dataprovince;
  2200. }
  2201. else
  2202. {
  2203. $info_list[$key]['street'] = '';
  2204. }
  2205. }
  2206. if(isset($value['pay']))
  2207. {
  2208. if(empty($value['pay'])){
  2209. $info_list[$key]['pay'] = "";
  2210. }else{
  2211. if($sj =='fullorder'){
  2212. $pay = $this->typeclass->read($value['pay']);
  2213. $info_list[$key]['pay'] = $pay['title'];
  2214. }
  2215. }
  2216. }
  2217. if(isset($value['type']))
  2218. {
  2219. $type = $this->warehouse->read($value['type']);
  2220. $info_list[$key]['type'] = $type['title'];
  2221. }
  2222. if(isset($value['express']))
  2223. {
  2224. $express = $this->express->read($value['express']);
  2225. if($express)
  2226. {
  2227. $info_list[$key]['express'] = $express['servicename'];
  2228. }
  2229. else
  2230. {
  2231. $info_list[$key]['express'] = '未选择';
  2232. }
  2233. }
  2234. if(isset($value['ccfpdata']))
  2235. {
  2236. $ccfpdata = explode(';',$value['fpdata']);
  2237. $inc = 0;
  2238. foreach ($ccfpdata as $v)
  2239. {
  2240. if(stripos($v,',') !== false)
  2241. {
  2242. $cc = explode(',',$v);
  2243. $inctype = $this->typeclass->read($cc[0]);
  2244. if(is_numeric($inctype['spare']))
  2245. {
  2246. if($inctype['spare'] > $inc)
  2247. {
  2248. $inc = $inctype['spare'];
  2249. }
  2250. }
  2251. }
  2252. }
  2253. $info_list[$key]['ccfpdata'] = $inc.'inch';
  2254. }
  2255. if(isset($value['printtype']))
  2256. {
  2257. if($value['printtype'] == 1)
  2258. {
  2259. $info_list[$key]['printtype'] = '运单';
  2260. }
  2261. else if($value['printtype'] == 2)
  2262. {
  2263. $info_list[$key]['printtype'] = '发货单';
  2264. }
  2265. else if($value['printtype'] == 3)
  2266. {
  2267. $info_list[$key]['printtype'] = '不打印单据';
  2268. }
  2269. else
  2270. {
  2271. $info_list[$key]['printtype'] = '未选择';
  2272. }
  2273. }
  2274. if(isset($value['exstate']))
  2275. {
  2276. if($value['exstate'] == '99')
  2277. {
  2278. $info_list[$key]['exstate'] = '未获取到物流信息';
  2279. }
  2280. else if($value['exstate'] == '1')
  2281. {
  2282. $info_list[$key]['exstate'] = '已揽收';
  2283. }
  2284. else if($value['exstate'] == '2')
  2285. {
  2286. $info_list[$key]['exstate'] = '在途中';
  2287. }
  2288. else if($value['exstate'] == '3')
  2289. {
  2290. $info_list[$key]['exstate'] = '派送中';
  2291. }
  2292. else if($value['exstate'] == '4')
  2293. {
  2294. $info_list[$key]['exstate'] = '已签收';
  2295. }
  2296. else if($value['exstate'] == '5')
  2297. {
  2298. $info_list[$key]['exstate'] = '派送异常';
  2299. }
  2300. else
  2301. {
  2302. $info_list[$key]['exstate'] = '';
  2303. }
  2304. }
  2305. if(isset($value['link']))
  2306. {
  2307. if($value['link'] != '')
  2308. {
  2309. $link = explode(',',$value['link']);
  2310. $info_list[$key]['link'] = $link[0];
  2311. }
  2312. else
  2313. {
  2314. $info_list[$key]['link'] = '';
  2315. }
  2316. }
  2317. if(isset($value['klarnabill']))
  2318. {
  2319. $klarnadata = explode('|',$value['klarnadata']);
  2320. if(isset($klarnadata[2]))
  2321. {
  2322. $info_list[$key]['klarnabill'] = $klarnadata[2];
  2323. }
  2324. else
  2325. {
  2326. $info_list[$key]['klarnabill'] = '';
  2327. }
  2328. }
  2329. if(isset($value['klarnaship']))
  2330. {
  2331. $klarnadata = explode('|',$value['klarnadata']);
  2332. if(isset($klarnadata[3]))
  2333. {
  2334. $info_list[$key]['klarnaship'] = $klarnadata[3];
  2335. }
  2336. else
  2337. {
  2338. $info_list[$key]['klarnaship'] = '';
  2339. }
  2340. }
  2341. if(isset($value['afterpaybill']))
  2342. {
  2343. $klarnadata = explode('|',$value['klarnadata']);
  2344. if(isset($klarnadata[1]))
  2345. {
  2346. $info_list[$key]['afterpaybill'] = $klarnadata[1];
  2347. }
  2348. else
  2349. {
  2350. $info_list[$key]['afterpaybill'] = '';
  2351. }
  2352. }
  2353. if(isset($value['afterpayship']))
  2354. {
  2355. $klarnadata = explode('|',$value['klarnadata']);
  2356. if(isset($klarnadata[2]))
  2357. {
  2358. $info_list[$key]['afterpayship'] = $klarnadata[2];
  2359. }
  2360. else
  2361. {
  2362. $info_list[$key]['afterpayship'] = '';
  2363. }
  2364. }
  2365. if(isset($value['PPname']))
  2366. {
  2367. $info_list[$key]['PPname'] = '';
  2368. $klarnadata = explode('|',$value['klarnadata']);
  2369. if(isset($klarnadata[1]))
  2370. {
  2371. $klarnadata = json_decode($klarnadata[1],true);
  2372. if(isset($klarnadata['name']))
  2373. {
  2374. $info_list[$key]['PPname'] = $klarnadata['name'];
  2375. }
  2376. }
  2377. }
  2378. if(isset($value['PPemail']))
  2379. {
  2380. $info_list[$key]['PPemail'] = '';
  2381. $klarnadata = explode('|',$value['klarnadata']);
  2382. if(isset($klarnadata[1]))
  2383. {
  2384. $klarnadata = json_decode($klarnadata[1],true);
  2385. if(isset($klarnadata['email']))
  2386. {
  2387. if($usp['excelpass'] == '1')
  2388. {
  2389. $ppemailpass = $this->setting->get_excelpass($klarnadata['email']);
  2390. }
  2391. else
  2392. {
  2393. $ppemailpass = $klarnadata['email'];
  2394. }
  2395. $info_list[$key]['PPemail'] = $ppemailpass;
  2396. }
  2397. }
  2398. }
  2399. if(isset($value['PPaddress']))
  2400. {
  2401. $info_list[$key]['PPaddress'] = '';
  2402. $klarnadata = explode('|',$value['klarnadata']);
  2403. if(isset($klarnadata[1]))
  2404. {
  2405. $klarnadata = json_decode($klarnadata[1],true);
  2406. if(isset($klarnadata['address']))
  2407. {
  2408. $info_list[$key]['PPaddress'] = $klarnadata['address'];
  2409. }
  2410. }
  2411. }
  2412. if(isset($value['klarnadata']))
  2413. {
  2414. unset($info_list[$key]['klarnadata']);
  2415. }
  2416. if(isset($value['shippingmethod']))
  2417. {
  2418. $tax = explode('Tax:',$value['shippingmethod']);
  2419. $info_list[$key]['shippingmethod'] = (isset($tax[1]))?trim($tax[1],';'):'';
  2420. }
  2421. if(isset($value['systemwigsout']))
  2422. {
  2423. $out = $this->systemtransfer->find_all("number = '".$data['number']."'");
  2424. $outread = '';
  2425. if($out)
  2426. {
  2427. foreach ($out as $val)
  2428. {
  2429. $list = '';
  2430. $rk = explode('|',trim($val['rk'],'|'));
  2431. $rktime = explode('|',trim($val['rktime'],'|'));
  2432. $zw = array();
  2433. $t = $this->transfer->find_all("1=1");
  2434. foreach ($t as $v)
  2435. {
  2436. $zw[$v['id']] = $v['title'];
  2437. }
  2438. if($val['rk'] != '' && count($rk) > 0)
  2439. {
  2440. for($i=0;$i<count($rk);$i++)
  2441. {
  2442. if(!isset($rktime[$i]))
  2443. {
  2444. $list .= $zw[$cz[$i]];
  2445. }
  2446. else
  2447. {
  2448. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  2449. }
  2450. }
  2451. }
  2452. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  2453. }
  2454. }
  2455. else
  2456. {
  2457. $systemwigsout = $this->systemwigsout->find_all("number = '".$data['number']."'");
  2458. if($systemwigsout)
  2459. {
  2460. foreach ($systemwigsout as $v)
  2461. {
  2462. $outread = '';
  2463. if($v['czwarehouse'] == 37)
  2464. {
  2465. $outread .= '华荣厂';
  2466. }
  2467. else if($v['czwarehouse'] == 0)
  2468. {
  2469. $outread .= '龙盈厂';
  2470. }
  2471. $cz = explode('|',trim($v['cz'],'|'));
  2472. $cztime = explode('|',trim($v['cztime'],'|'));
  2473. $zw = $this->transfer->get_list();
  2474. if($v['cz'] != '' && count($cz) > 0)
  2475. {
  2476. for($i=0;$i<count($cz);$i++)
  2477. {
  2478. if(!isset($cztime[$i]))
  2479. {
  2480. $outread .= $zw[$cz[$i]].' -&gt; ';
  2481. }
  2482. else
  2483. {
  2484. $outread .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  2485. }
  2486. }
  2487. $outread .= '<br>';
  2488. }
  2489. }
  2490. }
  2491. }
  2492. $info_list[$key]['systemwigsout'] = $outread;
  2493. }
  2494. if(isset($value['sourcetype']))
  2495. {
  2496. if($value['sourcetype'] == '1')
  2497. {
  2498. $info_list[$key]['sourcetype'] = '网红单';
  2499. }
  2500. else if($value['sourcetype'] == '2')
  2501. {
  2502. $info_list[$key]['sourcetype'] = '批发单';
  2503. }
  2504. else if($value['sourcetype'] == '3')
  2505. {
  2506. $info_list[$key]['sourcetype'] = '线下单';
  2507. }
  2508. else if($value['sourcetype'] == '4')
  2509. {
  2510. $info_list[$key]['sourcetype'] = '售后单';
  2511. }
  2512. else if($value['sourcetype'] == '5')
  2513. {
  2514. $info_list[$key]['sourcetype'] = '其它';
  2515. }
  2516. else
  2517. {
  2518. $info_list[$key]['sourcetype'] = '';
  2519. }
  2520. }
  2521. if(isset($value['js']))
  2522. {
  2523. if($value['js'] == '0')
  2524. {
  2525. $info_list[$key]['js'] = 'Ground Advantage';
  2526. }
  2527. else if($value['js'] == '1')
  2528. {
  2529. $info_list[$key]['js'] = 'PRIORITY';
  2530. }
  2531. else if($value['js'] == '2')
  2532. {
  2533. $info_list[$key]['js'] = 'EXPRESS';
  2534. }
  2535. else if($value['js'] == '3')
  2536. {
  2537. $info_list[$key]['js'] = 'IP';
  2538. }
  2539. else if($value['js'] == '4')
  2540. {
  2541. $info_list[$key]['js'] = 'FICP';
  2542. }
  2543. }
  2544. if(isset($value['type']))
  2545. {
  2546. $type = $this->warehouse->read($value['type']);
  2547. $info_list[$key]['type'] = $type['title'];
  2548. }
  2549. if(isset($value['xdcs']))
  2550. {
  2551. if($sj == 'fullorder')
  2552. {
  2553. $xdcs = $this->customer->get_email($data['email'],$data['shop']);
  2554. }
  2555. else
  2556. {
  2557. $xdcs = $this->customersmt->get_shopdata($data['shop'],$data['name'],$data['address']);
  2558. }
  2559. $info_list[$key]['xdcs'] = (isset($xdcs['num']))?(($xdcs['num']==0)?1:$xdcs['num']):1;
  2560. }
  2561. if(isset($value['dbapi']) || isset($value['scapi']))
  2562. {
  2563. $jmlist = '';$shuliang = '';
  2564. $classid = $this->classid->sku();
  2565. $dbapi = explode(';',trim($value['fpdata'],';'));
  2566. foreach ($dbapi as $va)
  2567. {
  2568. $pm = $classid;
  2569. $jm = $classid;
  2570. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2571. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2572. $ts = explode('|',trim($features,'|'));
  2573. if(stripos($ts[0],',') !== false)
  2574. {
  2575. $ft = explode(',',$ts[0]);
  2576. $features = explode('-',trim($ft[1],'-'));
  2577. $features[] = $ft[0];
  2578. }
  2579. else
  2580. {
  2581. $features = explode('-',trim($ts[0],'-'));
  2582. }
  2583. foreach($features as $k=>$v)
  2584. {
  2585. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2586. {
  2587. if($typeclass[$v]['bm'] != '')
  2588. {
  2589. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2590. }
  2591. }
  2592. if($v != 0 && isset($typeclass[$v]))
  2593. {
  2594. if($typeclass[$v]['classid'] == 13)
  2595. {
  2596. $dj = $typeclass[$v]['title'];
  2597. }
  2598. if($typeclass[$v]['classid'] == 8)
  2599. {
  2600. $ys = $typeclass[$v]['title'];
  2601. }
  2602. if($typeclass[$v]['classid'] == 15)
  2603. {
  2604. $hx = $typeclass[$v]['title'];
  2605. }
  2606. if(isset($pm[$typeclass[$v]['classid']]))
  2607. {
  2608. if($typeclass[$v]['title'] == '9A')
  2609. {
  2610. $pm[$typeclass[$v]['classid']] = '9A';
  2611. }
  2612. else if($typeclass[$v]['title'] == '10A')
  2613. {
  2614. $pm[$typeclass[$v]['classid']] = '10A';
  2615. }
  2616. else
  2617. {
  2618. $clzh = $typeclass[$v]['zh'];
  2619. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2620. {
  2621. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2622. $clzh = $clzh[0];
  2623. }
  2624. $pm[$typeclass[$v]['classid']] = $clzh;
  2625. }
  2626. }
  2627. if(isset($jm[$typeclass[$v]['classid']]))
  2628. {
  2629. if($typeclass[$v]['jm'])
  2630. {
  2631. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2632. }
  2633. }
  2634. }
  2635. }
  2636. $jm = array_filter($jm);//去除空值
  2637. $jm = implode("-",$jm);
  2638. $jmlist .= $jm.'<br>';
  2639. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  2640. $pm = array_filter($pm);//去除空值
  2641. $zh = implode(" ",$pm);
  2642. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2643. }
  2644. if(isset($value['dbapi']))
  2645. {
  2646. $info_list[$key]['dbapi'] = $jmlist;
  2647. }
  2648. else
  2649. {
  2650. $info_list[$key]['scapi'] = $shuliang;
  2651. }
  2652. }
  2653. if(isset($value['dbapi']) && isset($value['scapi']))
  2654. {
  2655. $jmlist = '';$shuliang = '';
  2656. $classid = $this->classid->sku();
  2657. $dbapi = explode(';',trim($value['fpdata'],';'));
  2658. foreach ($dbapi as $va)
  2659. {
  2660. $pm = $classid;
  2661. $jm = $classid;
  2662. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2663. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2664. $ts = explode('|',trim($features,'|'));
  2665. if(stripos($ts[0],',') !== false)
  2666. {
  2667. $ft = explode(',',$ts[0]);
  2668. $features = explode('-',trim($ft[1],'-'));
  2669. $features[] = $ft[0];
  2670. }
  2671. else
  2672. {
  2673. $features = explode('-',trim($ts[0],'-'));
  2674. }
  2675. foreach($features as $k=>$v)
  2676. {
  2677. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2678. {
  2679. if($typeclass[$v]['bm'] != '')
  2680. {
  2681. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2682. }
  2683. }
  2684. if($v != 0 && isset($typeclass[$v]))
  2685. {
  2686. if($typeclass[$v]['classid'] == 13)
  2687. {
  2688. $dj = $typeclass[$v]['title'];
  2689. }
  2690. if($typeclass[$v]['classid'] == 8)
  2691. {
  2692. $ys = $typeclass[$v]['title'];
  2693. }
  2694. if($typeclass[$v]['classid'] == 15)
  2695. {
  2696. $hx = $typeclass[$v]['title'];
  2697. }
  2698. if(isset($pm[$typeclass[$v]['classid']]))
  2699. {
  2700. if($typeclass[$v]['title'] == '9A')
  2701. {
  2702. $pm[$typeclass[$v]['classid']] = '9A';
  2703. }
  2704. else if($typeclass[$v]['title'] == '10A')
  2705. {
  2706. $pm[$typeclass[$v]['classid']] = '10A';
  2707. }
  2708. else
  2709. {
  2710. $clzh = $typeclass[$v]['zh'];
  2711. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2712. {
  2713. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2714. $clzh = $clzh[0];
  2715. }
  2716. $pm[$typeclass[$v]['classid']] = $clzh;
  2717. }
  2718. }
  2719. if(isset($jm[$typeclass[$v]['classid']]))
  2720. {
  2721. if($typeclass[$v]['jm'])
  2722. {
  2723. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2724. }
  2725. }
  2726. }
  2727. }
  2728. $jm = array_filter($jm);//去除空值
  2729. $jm = implode("-",$jm);
  2730. $jmlist .= $jm.'<br>';
  2731. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  2732. $pm = array_filter($pm);//去除空值
  2733. $zh = implode(" ",$pm);
  2734. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2735. }
  2736. $info_list[$key]['dbapi'] = $jmlist;
  2737. $info_list[$key]['scapi'] = $shuliang;
  2738. }
  2739. if(isset($value['cpfpdata']))
  2740. {
  2741. $fpread = '';
  2742. $cpfpdata = explode(';',trim($value['fpdata'],';'));
  2743. foreach ($cpfpdata as $v)
  2744. {
  2745. $va = explode('|',trim($v,'|'));
  2746. if(isset($va[1])){
  2747. $fpread .= $va[1].'; ';
  2748. }else{
  2749. $fpread .="合并单没有产品异常标记";
  2750. }
  2751. }
  2752. $info_list[$key]['cpfpdata'] = $fpread;
  2753. }
  2754. if(count($goods_sku_list) > 0){
  2755. $ret_goods_sku = $this->_getGoodsInfo($value,$goods_sku_list,$typeclass);
  2756. if(in_array("gradefpdata",$goods_sku_list)){
  2757. $info_list[$key]['gradefpdata'] = trim($ret_goods_sku['gradefpdata'],"<br>");
  2758. }
  2759. if(in_array("colorfpdata",$goods_sku_list)){
  2760. $info_list[$key]['colorfpdata'] = trim($ret_goods_sku['colorfpdata'],"<br>");
  2761. }
  2762. if(in_array("densityfpdata",$goods_sku_list)){
  2763. $info_list[$key]['densityfpdata'] = trim($ret_goods_sku['densityfpdata'],"<br>");
  2764. }
  2765. if(in_array("hairnumberfpdata",$goods_sku_list)){
  2766. $info_list[$key]['hairnumberfpdata'] = trim($ret_goods_sku['hairnumberfpdata'],"<br>");
  2767. }
  2768. if(in_array("lacetypefpdata",$goods_sku_list)){
  2769. $info_list[$key]['lacetypefpdata'] = trim($ret_goods_sku['lacetypefpdata'],"<br>");
  2770. }
  2771. //lowefpdata
  2772. if(in_array("lowefpdata",$goods_sku_list)){
  2773. $info_list[$key]['lowefpdata'] = trim($ret_goods_sku['lowefpdata'],"<br>");
  2774. }
  2775. }
  2776. if(isset($value['jweight'])){
  2777. $info_list[$key]['jweight'] = empty($value['jweight'])?0:$value['jweight']*0.001;
  2778. }
  2779. unset($info_list[$key]['id']);
  2780. unset($info_list[$key]['fpdata']);
  2781. }
  2782. return [
  2783. 'info_list'=>$info_list,
  2784. 'shouldmoney'=>$shouldmoney
  2785. ];
  2786. }
  2787. //上传运单
  2788. public function _waybill($arg_array)
  2789. {
  2790. $readid = $arg_array[0];
  2791. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  2792. /* 订单加入键值-k */
  2793. $fdata = $this->fullorder->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and dlz < 1 and state = 207');
  2794. foreach ($fdata as $v)
  2795. {
  2796. $dataorder[$v['orderinfo']] = $v;
  2797. }
  2798. $sdata = $this->fullordersmt->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and state = 207 and (dlz < 1 or dlz = 3)');
  2799. foreach ($sdata as $v)
  2800. {
  2801. $dataorder[$v['orderinfo']] = $v;
  2802. }
  2803. $tdata = $this->fullordertt->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and state = 207 and (dlz < 1 or dlz = 3)');
  2804. foreach ($tdata as $v)
  2805. {
  2806. $dataorder[$v['orderinfo']] = $v;
  2807. }
  2808. $xdata = $this->fullorderxw->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and state = 207 and (dlz < 1 or dlz = 3)');
  2809. foreach ($xdata as $v)
  2810. {
  2811. $dataorder[$v['orderinfo']] = $v;
  2812. }
  2813. /* 订单加入键值-j */
  2814. /* 店铺加入键值-j */
  2815. $fshop = $this->shop->find_all('1=1');
  2816. foreach ($fshop as $v)
  2817. {
  2818. $datashop[$v['id']] = $v;
  2819. }
  2820. /* 店铺加入键值-k */
  2821. /* 快递加入键值-j */
  2822. $fex = $this->express->find_all('1=1');
  2823. foreach ($fex as $v)
  2824. {
  2825. $dataex[$v['id']] = $v;
  2826. }
  2827. /* 快递加入键值-k */
  2828. /* 仓库加入键值-k */
  2829. $fwh = $this->warehouse->find_all('1=1');
  2830. foreach ($fwh as $v)
  2831. {
  2832. $datack[$v['id']] = $v;
  2833. }
  2834. /* 仓库加入键值-j */
  2835. $fs = $this->notice->get_ordertatus(216);//216成功状态
  2836. if(is_numeric($readid) == false || $readid < 1)
  2837. {
  2838. echo json_encode(array('msg'=>'店铺信息错误!','success'=>true));exit;
  2839. }
  2840. $dir = '/data/excel/'.date('Ymd',time()).'/';
  2841. $config['upload_path'] = '.'.$dir ;
  2842. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  2843. $config['allowed_types'] = 'xls|xlsx|csv';
  2844. $config['max_size'] = 10240;
  2845. $this->load->library('upload', $config);
  2846. $this->upload->initialize($config);
  2847. if ($this->upload->do_upload('userfile'))
  2848. {
  2849. $full_path = $dir.$this->upload->data('file_name');
  2850. $fileName = '.' . $full_path;
  2851. if (!file_exists($fileName))
  2852. {
  2853. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  2854. }
  2855. else
  2856. {
  2857. require_once "./data/excel/PHPExcel/IOFactory.php";
  2858. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  2859. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  2860. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  2861. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  2862. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  2863. ++$column;//如果列数大于26行
  2864. $list = array();
  2865. for ($i = 2; $i <= $row; $i++) // 行数循环
  2866. {
  2867. $data = array();
  2868. for ($c = 'A'; $c != $column; $c++) // 列数循环
  2869. {
  2870. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  2871. }
  2872. $list[] = $data;
  2873. }
  2874. }
  2875. $i = 0;$j = 0;$ed = array();$cscs = array();
  2876. $this->db->trans_begin();
  2877. foreach ($list as $key=>$value)
  2878. {
  2879. $ddh = preg_replace('/\D/s','',$value['0']);
  2880. $ydh = preg_replace('/\W/s','',$value['1']);
  2881. $shop = $datashop[$readid];
  2882. if($shop['type'] == '269')
  2883. {
  2884. $orid = $readid.$ddh;
  2885. }
  2886. else
  2887. {
  2888. $orid = $ddh;
  2889. }
  2890. if(isset($dataorder[$orid]))
  2891. {
  2892. if($shop['type'] == 269)//独立站前缀需要添加ID
  2893. {
  2894. $time = time();
  2895. $xg = $dataorder[$orid];
  2896. $oldw = $xg['waybill'];
  2897. $ex = $dataex[$xg['express']];
  2898. $warehouse = $datack[$xg['type']];
  2899. $msg = $ydh;
  2900. $xg['waybill'] = $ydh;
  2901. $fs = $this->notice->find_all("shop = '".$xg['shop']."' and message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");
  2902. if(isset($fs[0]))
  2903. {
  2904. $fs = $fs[0];
  2905. $fs['email'] = $this->emaildata->read($fs['email']);
  2906. if(($xg['dlzemail'] == 1 && $msg != $oldw) || $xg['dlzemail'] == 0)
  2907. {
  2908. $ck = $this->notice->get_god($xg,$shop,$ex,$fs);
  2909. if($ck == 1)
  2910. {
  2911. $ckemail = '邮件发送成功,';
  2912. $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$xg['id']);
  2913. }
  2914. }
  2915. }
  2916. if($msg != $oldw)
  2917. {
  2918. if($xg['source'] != 1)
  2919. {
  2920. $ms = $this->message->find_all("express like '%,".$xg['express'].",%'");
  2921. if(!isset($ms[0]))
  2922. {
  2923. $ms = $this->message->read(2);
  2924. }
  2925. else
  2926. {
  2927. $ms = $ms[0];
  2928. }
  2929. $ddh = substr($xg['orderinfo'],1);
  2930. $shopifyid = $xg['shopify'];
  2931. //独立站地址更新订单状态、物流信息
  2932. $shopname = $shop['brandname']; //店铺名
  2933. $buyername = $xg['bname']; //Bill Name
  2934. $email_call = $shop['shopid']; //发货人邮箱;
  2935. $phone = $shop['shopphone']; //发货人电话
  2936. $track_type = $ex['title']; //快递名称
  2937. $service = $ex['title']; //快递追踪名称
  2938. $track_link = $ex['url']; //快递查询网址
  2939. $logistics_number = $ydh; //运单号
  2940. $t= array('%buyername%','%email_call%','%track_type%','%service%','%track_link%','%logistics_number%','%shop%','%phone%','%jtime%');
  2941. $h= array($buyername,$email_call,$track_type,$service,$track_link,$logistics_number,$shopname,$phone,$ex['yjtime']);
  2942. $remark = str_replace($t,$h,$ms['content']);
  2943. @$gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$remark,$shopifyid);
  2944. }
  2945. else if($xg['source'] == 1)
  2946. {
  2947. $gx['res'] = 3;
  2948. $gx['state'] = 216;
  2949. }
  2950. }
  2951. else
  2952. {
  2953. $gx['res'] = $xg['dlz'];
  2954. $gx['state'] = $xg['state'];
  2955. }
  2956. $xg['iscode'] = $ex['title'];
  2957. $xg['url'] = $shop['shopname'];
  2958. @$chuanshu = $this->api->get_paypal($xg);
  2959. //$this->afspaypal->insert(array('number'=>$xg['number'],'cs'=>$chuanshu));
  2960. $this->fullorder->save(array('waybill'=>$msg,'state'=>$gx['state'],'dlz'=>$gx['res']),$xg['id']);
  2961. /**
  2962. $xg = $dataorder[$arg_array[0].$ddh];
  2963. $ex = $dataex[$xg['express']];
  2964. $warehouse = $datack[$xg['type']];
  2965. if($xg['source'] != 1 && $ex['iscode'] != 'Other' && $xg['state'] == '207')
  2966. {
  2967. //独立站地址更新订单状态、物流信息
  2968. $gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$xg['msg'],$xg['msg'],$dataorder[$orid]['shopify']);
  2969. if(!isset($gx['res']))
  2970. {
  2971. $ed[] = array($ddh.'-更新失败');
  2972. $j++;
  2973. continue;
  2974. }
  2975. $this->fullorder->save(array('waybill'=>$ydh,'dlz'=>$gx['res'],'state'=>$gx['state']),$xg['id']);
  2976. if($gx['res'] == 1 && $fs)
  2977. {
  2978. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  2979. }
  2980. }
  2981. else if($xg['source'] == 1 && $xg['state'] == '207')
  2982. {
  2983. $this->fullorder->save(array('waybill'=>$ydh,'dlz'=>3,'state'=>216),$xg['id']);
  2984. if($fs)
  2985. {
  2986. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  2987. }
  2988. }
  2989. else
  2990. {
  2991. $ed[] = array($ddh.'-状态错误');
  2992. $j++;
  2993. continue;
  2994. }
  2995. **/
  2996. }
  2997. else if($shop['type'] == 270)//速卖通对接发货声明
  2998. {
  2999. $xg = $dataorder[$ddh];
  3000. $ex = $dataex[$xg['express']];
  3001. $warehouse = $datack[$xg['type']];
  3002. if($xg['source'] != 1 && $ex['aecode'] != 'Other' && $xg['library'] == 2 && ($xg['dlz'] == '0' || $xg['dlz'] == '2'))
  3003. {
  3004. $result = $this->apismt->get_out($ydh,'all',$xg['orderinfo'],$ex['aecode'],$sp['code']);
  3005. if(isset($result['result_success']) && $result['result_success'] == "true")
  3006. {
  3007. $this->fullordersmt->save(array('waybill'=>$ydh,'state'=>209,'dlz'=>1),$xg['id']);
  3008. /** 合并信息处理开始-发货声明 **/
  3009. if($xg['merge'] != '0')
  3010. {
  3011. $hdata = $this->fullordersmt->find_all("merge = '".$xg['merge']."' and id != '".$xg['id']."' and dlz = '0' and source != 1");$l=0;
  3012. foreach ($hdata as $v)
  3013. {
  3014. $result = $this->apismt->get_out($ydh,'all',$v['orderinfo'],$ex['aecode'],$sp['code']);
  3015. if(isset($result['result_success']) && $result['result_success'] == "true")
  3016. {
  3017. $this->fullordersmt->save(array('waybill'=>$ydh,'state'=>209,'dlz'=>1),$v['id']);
  3018. }
  3019. else
  3020. {
  3021. $ed[] = array($v['orderinfo'].'-合并单发货声明失败,请在ERP上手动操作此单');
  3022. $j++;
  3023. continue;
  3024. }
  3025. $l++;
  3026. if($l > 10)
  3027. {
  3028. break;
  3029. }
  3030. }
  3031. }
  3032. /** 合并信息处理结束开始 **/
  3033. }
  3034. else
  3035. {
  3036. $ed[] = array($ddh.'-发货声明失败');
  3037. $j++;
  3038. continue;
  3039. }
  3040. }
  3041. else if($xg['source'] != 1 && $ex['aecode'] != 'Other' && $xg['dlz'] == '1' && $xg['library'] == 2)//修改声明
  3042. {
  3043. $obtain = $this->apismt->get_obtain($xg['orderinfo'],$sp['code']);//修改声明先查询之前物流信息
  3044. if(isset($obtain['logistics_no']))
  3045. {
  3046. $result = $this->apismt->get_editout($obtain['logistics_no'],$ydh,'all',$xg['orderinfo'],$obtain['service_name'],$ex['aecode'],$sp['code']);
  3047. }
  3048. if(isset($result['result_success']) && $result['result_success'] == "true")
  3049. {
  3050. $this->fullordersmt->save(array('waybill'=>$ydh),$xg['id']);
  3051. /** 合并信息处理开始-修改声明 **/
  3052. if($xg['merge'] != '0')
  3053. {
  3054. $hdata = $this->fullordersmt->find_all("merge = '".$xg['merge']."' and id != '".$xg['id']."' and dlz != 1 and source != 1");$l=0;
  3055. foreach ($hdata as $v)
  3056. {
  3057. $obtain = $this->apismt->get_obtain($v['orderinfo'],$sp['code']);//修改声明先查询之前物流信息
  3058. if(isset($obtain['logistics_no']))
  3059. {
  3060. $result = $this->apismt->get_editout($obtain['logistics_no'],$ydh,'all',$v['orderinfo'],$obtain['service_name'],$ex['aecode'],$sp['code']);
  3061. }
  3062. if(isset($result['result_success']) && $result['result_success'] == "true")
  3063. {
  3064. $this->fullordersmt->save(array('waybill'=>$ydh),$v['id']);
  3065. }
  3066. else
  3067. {
  3068. $ed[] = array($v['orderinfo'].'-合并单修改发货声明失败,请在ERP上手动操作此单');
  3069. $j++;
  3070. continue;
  3071. }
  3072. $l++;
  3073. if($l > 10)
  3074. {
  3075. break;
  3076. }
  3077. }
  3078. }
  3079. /** 合并信息处理结束开始 **/
  3080. }
  3081. else
  3082. {
  3083. $ed[] = array($ddh.'-修改发货声明失败');
  3084. $j++;
  3085. continue;
  3086. }
  3087. }
  3088. else if($xg['source'] == 1 && $xg['state'] == '207')
  3089. {
  3090. $this->fullordersmt->save(array('waybill'=>$ydh,'dlz'=>3,'state'=>216),$xg['id']);
  3091. }
  3092. else
  3093. {
  3094. $this->fullordersmt->save(array('waybill'=>$ydh),$xg['id']);
  3095. }
  3096. }
  3097. }
  3098. else
  3099. {
  3100. $ed[] = array($ddh.'-单号错误或重复操作');
  3101. $i++;
  3102. continue;
  3103. }
  3104. sleep(1);//停留1秒
  3105. }
  3106. if ($this->db->trans_status() === FALSE)
  3107. {
  3108. $this->db->trans_rollback();
  3109. }
  3110. else
  3111. {
  3112. $this->db->trans_commit();
  3113. }
  3114. if($i+$j > 0)
  3115. {
  3116. $time = date('Ymd',time());
  3117. $title = '错误信息-'.$time;
  3118. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3119. $tail = "\n";
  3120. $filename = $title.".xls";
  3121. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3122. $dir = '/data/excel/'.$time.'/';
  3123. $file_name = 'error_'.$time.rand(1000,9999);
  3124. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3125. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3126. fwrite($myfile,$ecl);
  3127. fclose($myfile);
  3128. $error = $dir.$file_name.'.xls';
  3129. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3130. }
  3131. else
  3132. {
  3133. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3134. }
  3135. }
  3136. else
  3137. {
  3138. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3139. }
  3140. }
  3141. //上传速卖通订单
  3142. public function _order($arg_array)
  3143. {
  3144. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  3145. /* 订单加入键值-k */
  3146. $fdata = $this->fullorder_smt->find_all('dtime >'.(time()-5*24*3600));
  3147. foreach ($fdata as $v)
  3148. {
  3149. $dataorder[$v['orderinfo']] = $v;
  3150. }
  3151. /* 订单加入键值-j */
  3152. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3153. $config['upload_path'] = '.'.$dir ;
  3154. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3155. $config['allowed_types'] = 'xls|xlsx|csv';
  3156. $config['max_size'] = 10240;
  3157. $this->load->library('upload', $config);
  3158. $this->upload->initialize($config);
  3159. if ($this->upload->do_upload('userfile'))
  3160. {
  3161. $full_path = $dir.$this->upload->data('file_name');
  3162. $fileName = '.' . $full_path;
  3163. if (!file_exists($fileName))
  3164. {
  3165. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3166. }
  3167. else
  3168. {
  3169. require_once "./data/excel/PHPExcel/IOFactory.php";
  3170. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3171. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3172. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3173. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3174. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3175. ++$column;//如果列数大于26行
  3176. $list = array();
  3177. for ($i = 2; $i <= $row; $i++) // 行数循环
  3178. {
  3179. $data = array();
  3180. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3181. {
  3182. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3183. }
  3184. $list[] = $data;
  3185. }
  3186. }
  3187. $i = 0;$j = 0;$ed = array();$tytime = time();
  3188. foreach ($list as $key=>$value)
  3189. {
  3190. $value['2'] = preg_replace('/\D/s','',$value['2']);
  3191. if($value['2'] && !isset($dataorder[$value['2']]))
  3192. {
  3193. $num = $this->fullorder_smt->find_count('gtime = "'.date('Ymd',time()).'"');
  3194. $post['source'] = 2;//订单类型:1.线下订单2.PC3.手机
  3195. $post['state'] = 207;//订单状态:207等待发货
  3196. $post['review'] = 6;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
  3197. $post['reviewtime'] = $tytime;//审核时间
  3198. $post['print'] = 2;//打印状态:1.不可打印2.未打印3.已打印
  3199. $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
  3200. $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
  3201. if($post['print'] != 3)
  3202. {
  3203. $post['librarynot'] = "订单未打印,未审核或未通过";//不能出库原因
  3204. }
  3205. $value['1'] = trim($value['1'],' ');
  3206. $shortname = explode('-',$value['1']);
  3207. $shortname = $this->shop->get_shortname($shortname[0]);
  3208. if(!$shortname)
  3209. {
  3210. $ed[] = array($value['1'].'-编码有问题');
  3211. $i++;
  3212. continue;
  3213. }
  3214. $post['shop'] = $shortname['id']?$shortname['id']:0;//速卖通
  3215. $post['user'] = '无';
  3216. $post['number'] = $value['1'];//编号
  3217. $post['orderinfo'] = $value['2'];//订单号
  3218. $post['client'] = preg_replace('/( | | |\s)/',' ',$value['3']);//客户名称
  3219. $post['buytime'] = $tytime;//时间转UX
  3220. $post['dtime'] = $tytime;//订单时间
  3221. $post['gtime'] = date('Ymd',$tytime);//格式化时间
  3222. //$post['pay'] = $this->input->post('pay',true);//支付方式
  3223. $post['capital'] = 3;//资金状态
  3224. $post['type'] = 5;//发货仓库
  3225. $post['currency'] = 219;//币种
  3226. $post['currencytitle'] = 'USD';//币种名称
  3227. $post['freight'] = 0;//运费
  3228. $post['expressmoney'] = 0;//物流金额
  3229. $post['shouldmoney'] = 0;//应收金额
  3230. $post['budget'] = 0;//应到金额*店铺到帐金额比
  3231. $orderremarks = '';//订单备注
  3232. $post['shipremarks'] = $value['12'];//仓库品名
  3233. $post['email'] = '';//邮箱
  3234. $post['name'] = preg_replace('/( | | |\s)/',' ',$value['3']);//名字
  3235. $post['phone'] = $value['10'];//电话
  3236. $post['country'] = 192;//国家
  3237. $ct = $this->country->get_ename($value['9']);//国家
  3238. $post['al'] = $ct['lb'];//国家二字码
  3239. $post['province'] = $value['8'];//省、州
  3240. $post['city'] = $value['6'];//城市
  3241. $post['zipcode'] = $value['7'];//邮编
  3242. $post['address'] = $value['4'];//地址1
  3243. $post['address2'] = $value['5']?$value['5']:'';//地址2
  3244. $post['express'] = 2;//快递
  3245. $post['printtype'] = 1;//打印类型
  3246. $post['fpdata'] = '';//购买产品内容
  3247. $post['sbpm'] = 'Hair Sample';//申报品名
  3248. $post['zwpm'] = '假发';//中文品名
  3249. $post['ts'] = $value['17'];//条数
  3250. $post['dtsbjz'] = 15;//单条申报价
  3251. $post['zsbjz'] = 15;//总申报价
  3252. $post['zzl'] = 0.5;//总重量
  3253. $post['zjs'] = 1;//总件数
  3254. $post['quantity'] = 1;//数量
  3255. $post['paypal'] = '';//支付号
  3256. $post['guarantee'] = '';//卖家保障
  3257. $post['zzl'] = $value['13'];//总重量
  3258. $post['bx'] = $value['14'];//总重量
  3259. $post['qm'] = $value['15'];//总重量
  3260. $post['js'] = $value['16'];//总重量
  3261. $barcode = $this->usps->get_address(array('address'=>$value['4'],'address2'=>$value['5'],'city'=>$value['6'],'province'=>$value['8'],'zipcode'=>$value['7']));
  3262. if(isset($barcode['Address']['Error']['Description']))
  3263. {
  3264. $ed[] = array($value['1'].'-'.$barcode['Address']['Error']['Description']);
  3265. $i++;
  3266. }
  3267. else
  3268. {
  3269. $this->fullorder_smt->insert($post);
  3270. }
  3271. }
  3272. else
  3273. {
  3274. $ed[] = array($value['1'].'-单号错误或重复操作');
  3275. $i++;
  3276. }
  3277. sleep(2);//停留2秒
  3278. }
  3279. if($i+$j > 0)
  3280. {
  3281. $time = date('Ymd',time());
  3282. $title = '错误信息-'.$time;
  3283. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3284. $tail = "\n";
  3285. $filename = $title.".xls";
  3286. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3287. $dir = '/data/excel/'.$time.'/';
  3288. $file_name = 'error_'.$time.rand(1000,9999);
  3289. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3290. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3291. fwrite($myfile,$ecl);
  3292. fclose($myfile);
  3293. $error = $dir.$file_name.'.xls';
  3294. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3295. }
  3296. else
  3297. {
  3298. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3299. }
  3300. }
  3301. else
  3302. {
  3303. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3304. }
  3305. }
  3306. public function _email($content,$data,$shopname)
  3307. {
  3308. $express = $this->express->read($data['express']);
  3309. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  3310. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  3311. $content = str_replace($t,$h,$content);
  3312. $this->load->library('email');
  3313. $config['protocol'] = 'smtp';
  3314. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  3315. $config['smtp_port'] = 465;
  3316. $config['smtp_user'] = 'service@email.supernovahair.com';
  3317. $config['smtp_pass'] = 'LONGyihair374';
  3318. $config['smtp_crypto'] = 'ssl';
  3319. $config['crlf'] = "\r\n";
  3320. $config['newline'] = "\r\n";
  3321. $this->email->initialize($config);
  3322. $this->email->from('service@email.supernovahair.com',$shopname);
  3323. $this->email->to($data['email']);//收件
  3324. $this->email->subject('The product you purchased has a new progress');//标题
  3325. $this->email->message($content);//内容
  3326. if ( ! $this->email->send())
  3327. {
  3328. return 2;
  3329. }
  3330. else
  3331. {
  3332. return 1;
  3333. }
  3334. }
  3335. //导出订单excel
  3336. public function _cs()
  3337. {
  3338. if(isset($_GET['fexcel']))
  3339. {
  3340. if(isset($_SESSION['api']))
  3341. {
  3342. $user = $this->user->get_api($_SESSION['api']);
  3343. $usp = $user;
  3344. $fgshop = "";$sid = "";
  3345. $user = explode('|',trim($user['shop'],'|'));
  3346. foreach ($user as $value)
  3347. {
  3348. $fgshop .= " shop = ".$value." or";
  3349. $sid .= " id = ".$value." or";
  3350. }
  3351. }
  3352. $dowid = $this->input->get('a');
  3353. $wid = "";
  3354. if($dowid != "")
  3355. {
  3356. $id_arr = explode(',',rtrim($dowid,','));
  3357. foreach ($id_arr as $v)
  3358. {
  3359. $wid .= " id = 0 or";
  3360. $wid .= " id = '$v' or";
  3361. }
  3362. $wid = " and".rtrim($wid,'or');
  3363. }
  3364. $fexcel = $this->input->get('fexcel',true);
  3365. $page = $this->input->get('page',true);
  3366. $perpage = $this->input->get('perpage',true);
  3367. $warehouse = $this->input->get('warehouse',true);
  3368. $timetk = $this->input->get('timetk',true);
  3369. $timetj = $this->input->get('timetj',true);
  3370. $shop = $this->input->get('shop',true);
  3371. $source = $this->input->get('source',true);
  3372. $state = $this->input->get('state',true);
  3373. $review = $this->input->get('review',true);
  3374. $type = $this->input->get('type',true);
  3375. $express = $this->input->get('express',true);
  3376. $orderinfo = $this->input->get('orderinfo',true);
  3377. $user = $this->input->get('user',true);
  3378. $client = $this->input->get('name',true);
  3379. $waybill = $this->input->get('waybill',true);
  3380. $number = $this->input->get('number',true);
  3381. $email = $this->input->get('email',true);
  3382. $dlz = $this->input->get('dlz',true);
  3383. $library = $this->input->get('library',true);
  3384. $libraryconfirm = $this->input->get('libraryconfirm',true);
  3385. $print = $this->input->get('print',true);
  3386. $timetkk = $this->input->get('timetkk',true);
  3387. $timetjj = $this->input->get('timetjj',true);
  3388. $timetk = strtotime($timetk);
  3389. $timetj = strtotime($timetj);
  3390. $timetkk = strtotime($timetkk);
  3391. $timetjj = strtotime($timetjj);
  3392. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  3393. if($warehouse)
  3394. {
  3395. $where .= " and type = '$warehouse'";
  3396. }
  3397. if($timetk && $timetj)
  3398. {
  3399. $timetj = $timetj+24*3600;
  3400. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3401. }
  3402. if($timetkk && $timetjj)
  3403. {
  3404. $where .= " and librarytime > '$timetkk' and librarytime < '$timetjj'";
  3405. }
  3406. if($library)
  3407. {
  3408. $where .= " and library = '$library'";
  3409. }
  3410. if($print)
  3411. {
  3412. $where .= " and print = '$print'";
  3413. }
  3414. if($shop)
  3415. {
  3416. $where .= " and shop = '$shop'";
  3417. }
  3418. if($source)
  3419. {
  3420. $where .= " and source = '$source'";
  3421. }
  3422. if($state)
  3423. {
  3424. $where .= " and state = '$state'";
  3425. }
  3426. if($review)
  3427. {
  3428. $where .= " and review = '$review'";
  3429. }
  3430. if($type)
  3431. {
  3432. $where .= " and type = '$type'";
  3433. }
  3434. if($express)
  3435. {
  3436. $where .= " and express = '$express'";
  3437. }
  3438. if($orderinfo)
  3439. {
  3440. $where .= " and orderinfo = '$orderinfo'";
  3441. }
  3442. if($user)
  3443. {
  3444. $where .= " and user = '$user'";
  3445. }
  3446. if($client)
  3447. {
  3448. $where .= " and client like '%$client%'";
  3449. }
  3450. if($waybill)
  3451. {
  3452. $where .= " and waybill = '$waybill'";
  3453. }
  3454. if($number)
  3455. {
  3456. $where .= " and number = '$number'";
  3457. }
  3458. if($email)
  3459. {
  3460. $where .= " and email = '$email'";
  3461. }
  3462. if($dlz)
  3463. {
  3464. $where .= " and waybill != '' and dlz = 0";
  3465. }
  3466. if($dlz)
  3467. {
  3468. $where .= " and libraryconfirm = '$libraryconfirm'";
  3469. }
  3470. $fexcel = $this->fullorderexcel->read($fexcel);
  3471. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  3472. foreach ($fexceleq as $k=>$v)
  3473. {
  3474. $fexceleq[$k] = explode('-',$v);
  3475. $num[$k] = $fexceleq[$k][0];
  3476. }
  3477. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  3478. $feq = "";
  3479. foreach ($fexceleq as $k=>$v)
  3480. {
  3481. $feq .= $v[1].',';
  3482. }
  3483. $feq = rtrim($feq,',');
  3484. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  3485. foreach ($fexcelzhw as $k=>$v)
  3486. {
  3487. $fexcelzhw[$k] = explode('-',$v);
  3488. $numb[$k] = $fexcelzhw[$k][0];
  3489. }
  3490. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  3491. $fexcelzh = array();
  3492. foreach ($fexcelzhw as $k=>$v)
  3493. {
  3494. $fexcelzh[] = $v[1];
  3495. }
  3496. //取得信息列表
  3497. $info_list = $this->fullorder->find_all($where.$wid,$feq,'id desc');
  3498. //格式化数据
  3499. $i = 1;$shouldmoney = 0;$hl=1;
  3500. foreach ($info_list as $key=>$value)
  3501. {
  3502. if(isset($value['currencytitle']))
  3503. {
  3504. if($value['currencytitle'] != "CNY")
  3505. {
  3506. $hl=$value['hl'];
  3507. }
  3508. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3509. $budget=$budget+($value['budget']*$hl);
  3510. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  3511. $refund=$refund+($value['refund']*$hl);
  3512. }
  3513. if(isset($value['shop']))
  3514. {
  3515. $shop = $this->shop->read($value['shop']);
  3516. $info_list[$key]['shop'] = $shop['shopname'];
  3517. }
  3518. if(isset($value['dtime']))
  3519. {
  3520. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3521. }
  3522. if(isset($value['country']))
  3523. {
  3524. $country = $this->country->read($value['country']);
  3525. $info_list[$key]['country'] = $country['name'];
  3526. }
  3527. if(isset($value['type']))
  3528. {
  3529. $type = $this->warehouse->read($value['type']);
  3530. $info_list[$key]['type'] = $type['title'];
  3531. }
  3532. if(isset($value['express']))
  3533. {
  3534. $express = $this->express->read($value['express']);
  3535. if($express)
  3536. {
  3537. $info_list[$key]['express'] = $express['servicename'];
  3538. }
  3539. else
  3540. {
  3541. $info_list[$key]['express'] = '未选择';
  3542. }
  3543. }
  3544. }
  3545. echo $timetkk;
  3546. }
  3547. }
  3548. public function _gggs($sku,$s,$j,$k)
  3549. {
  3550. $companytitle = array(9=>3,10=>2,11=>1,12=>4);
  3551. $this->load->database();
  3552. $this->db->select('id');
  3553. $this->db->from('crowd_whlabel');
  3554. $this->db->where('warehouse', '5');
  3555. $this->db->where('sku', $sku);
  3556. $this->db->where('state', '0');
  3557. $this->db->limit($s,$k);
  3558. $query = $this->db->get();
  3559. $ids = array_column($query->result_array(), 'id');
  3560. if (!empty($ids))
  3561. {
  3562. // 更新
  3563. $this->db->where_in('id', $ids);
  3564. $this->db->update('crowd_whlabel', array('companytitle' => $companytitle[$j]));
  3565. return $this->db->affected_rows();
  3566. }
  3567. }
  3568. public function _xxpl()
  3569. {
  3570. $this->load->database();
  3571. $data = ['type' => ''];
  3572. $this->db->update('crowd_whlabel', $data);
  3573. $wt = array();
  3574. $whlabel_type = $this->whlabel_type->find_all();
  3575. foreach ($whlabel_type as $v)
  3576. {
  3577. $wt[$v['title']] = $v['id'];
  3578. }
  3579. /* 订单加入键值-j */
  3580. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3581. $config['upload_path'] = '.'.$dir ;
  3582. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3583. $config['allowed_types'] = 'xls|xlsx|csv';
  3584. $config['max_size'] = 10240;
  3585. $this->load->library('upload', $config);
  3586. $this->upload->initialize($config);
  3587. if ($this->upload->do_upload('userfile'))
  3588. {
  3589. $full_path = $dir.$this->upload->data('file_name');
  3590. $fileName = '.' . $full_path;
  3591. if (!file_exists($fileName))
  3592. {
  3593. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3594. }
  3595. else
  3596. {
  3597. require_once "./data/excel/PHPExcel/IOFactory.php";
  3598. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3599. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3600. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3601. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3602. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3603. ++$column;//如果列数大于26行
  3604. $list = array();
  3605. for ($i = 2; $i <= $row; $i++) // 行数循环
  3606. {
  3607. $data = array();
  3608. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3609. {
  3610. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3611. }
  3612. $list[] = $data;
  3613. }
  3614. }
  3615. $wt = array();
  3616. $whlabel_type = $this->whlabel_type->find_all();
  3617. foreach ($whlabel_type as $v)
  3618. {
  3619. $wt[$v['title']] = $v['id'];
  3620. }
  3621. $j = 0;$ed = array();$e = 0;$c = 0;$cs = array();
  3622. foreach ($list as $v)
  3623. {
  3624. $this->load->database();
  3625. // 设置更新数据
  3626. $data = ['type' => $wt[$v[1]]];
  3627. // 添加条件:SKU 为 123456 且 warehouse 为 5
  3628. $this->db->where('SKU', $v[0]);
  3629. $this->db->where('warehouse', '5');
  3630. // 批量更新
  3631. $this->db->update('crowd_whlabel', $data);
  3632. }
  3633. /** 导入缺货
  3634. $time = time();
  3635. $whlabel = $this->whlabel->get_sku($v[0]);
  3636. if($whlabel)
  3637. {
  3638. $this->whlabel_qh->insert(array('sku'=>$whlabel['sku'],'features'=>$whlabel['features'],'num'=>$v['1'],'gtime'=>date('Ym',$time),'gxtime'=>date('Ymd',$time)));
  3639. }
  3640. else
  3641. {
  3642. $ed[] = $v['0'];
  3643. $j++;
  3644. }
  3645. }
  3646. **/
  3647. /**
  3648. 更换等级
  3649. $this->load->database();
  3650. // 设置更新数据
  3651. $data = ['type' => $wt[$v[1]]];
  3652. // 添加条件:SKU 为 123456 且 warehouse 为 5
  3653. $this->db->where('SKU', $v[0]);
  3654. $this->db->where('warehouse', '5');
  3655. // 批量更新
  3656. $this->db->update('crowd_whlabel', $data);
  3657. **/
  3658. /**
  3659. $whlabel_type = $this->whlabel_type->find_all();
  3660. foreach ($whlabel_type as $v)
  3661. {
  3662. $wt[$v['title']] = $v['id'];
  3663. }
  3664. foreach ($list as $v)
  3665. {
  3666. $w = $this->whlabel->find_all("sku = '".$v[0]."' and warehouse = 5");
  3667. if($w && isset($wt[$v[1]]))
  3668. {
  3669. foreach ($w as $val)
  3670. {
  3671. $this->whlabel->save(array('type'=>$wt[$v[1]]),$val['id']);
  3672. }
  3673. }
  3674. else
  3675. {
  3676. $ed[] = array($v[0],$v[1]);
  3677. $j++;
  3678. }
  3679. }
  3680. **/
  3681. if($e > 0)
  3682. {
  3683. $time = date('Ymd',time());
  3684. $title = '错误信息-'.$time;
  3685. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3686. $tail = "\n";
  3687. $filename = $title.".xls";
  3688. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3689. $dir = '/data/excel/'.$time.'/';
  3690. $file_name = 'error_'.$time.rand(1000,9999);
  3691. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3692. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3693. fwrite($myfile,$ecl);
  3694. fclose($myfile);
  3695. $error = $dir.$file_name.'.xls';
  3696. echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
  3697. }
  3698. else
  3699. {
  3700. echo json_encode(array('msg'=>'添加成功!'.$c,'success'=>true));exit;
  3701. }
  3702. }
  3703. else
  3704. {
  3705. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3706. }
  3707. }
  3708. public function _skuzh()
  3709. {
  3710. /* 订单加入键值-j */
  3711. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3712. $config['upload_path'] = '.'.$dir ;
  3713. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3714. $config['allowed_types'] = 'xls|xlsx|csv';
  3715. $config['max_size'] = 10240;
  3716. $this->load->library('upload', $config);
  3717. $this->upload->initialize($config);
  3718. if ($this->upload->do_upload('userfile'))
  3719. {
  3720. $full_path = $dir.$this->upload->data('file_name');
  3721. $fileName = '.' . $full_path;
  3722. if (!file_exists($fileName))
  3723. {
  3724. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3725. }
  3726. else
  3727. {
  3728. require_once "./data/excel/PHPExcel/IOFactory.php";
  3729. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3730. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3731. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3732. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3733. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3734. ++$column;//如果列数大于26行
  3735. $list = array();
  3736. for ($i = 2; $i <= $row; $i++) // 行数循环
  3737. {
  3738. $data = array();
  3739. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3740. {
  3741. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3742. }
  3743. $list[] = $data;
  3744. }
  3745. }
  3746. $dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32');
  3747. $dtc = array();
  3748. foreach ($dictionaries as $v)
  3749. {
  3750. if(stripos($v['spare'],'|') !== false)//如果有多个值
  3751. {
  3752. $v['spare'] = explode('|',$v['spare']);
  3753. foreach ($v['spare'] as $k=>$vs)
  3754. {
  3755. if(stripos($v['zh'],'|') !== false)
  3756. {
  3757. $vzh = explode('|',$v['zh']);
  3758. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  3759. }
  3760. else
  3761. {
  3762. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  3763. }
  3764. }
  3765. }
  3766. else
  3767. {
  3768. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  3769. }
  3770. }
  3771. $dictionaries2 = $this->typeclass->find_all();
  3772. foreach ($dictionaries2 as $v)
  3773. {
  3774. $dtctitle[$v['id']] = $v['title'];
  3775. }
  3776. /* 匹配结束 */
  3777. /* 价格加入 */
  3778. $money = array();
  3779. $productdescribe = $this->productdescribe->find_all('1=1');
  3780. foreach ($productdescribe as $v)
  3781. {
  3782. $money[$v['number']] = array();
  3783. }
  3784. /* 价格加入 */
  3785. /* 匹配ID加入 */
  3786. $int = array();
  3787. $intdata = $this->typeclass->find_all('classid=14','id,spare');
  3788. foreach ($intdata as $v)
  3789. {
  3790. $v['spare'] = explode('|',$v['spare']);
  3791. $int[$v['id']] = $v['spare'][0];
  3792. }
  3793. /* 匹配ID加入 */
  3794. $zjsku = array();
  3795. $shopsku = $this->shopsku->find_all();
  3796. foreach ($shopsku as $val)
  3797. {
  3798. $ss = explode(',',trim($val['shop'],','));
  3799. foreach ($ss as $v)
  3800. {
  3801. if(isset($zjsku[$v]))
  3802. {
  3803. $zjsku[$v] .= ','.trim($val['sku'],',');
  3804. }
  3805. else
  3806. {
  3807. $zjsku[$v] = trim($val['sku'],',');
  3808. }
  3809. }
  3810. }
  3811. /* 匹配ID结束 */
  3812. $q = '1;';
  3813. $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
  3814. $shop = $this->shop->read(19);
  3815. if(isset($zjsku[$shop['id']]))//判断是否找到店铺SKU
  3816. {
  3817. $sku = rtrim($sku,',').','.$zjsku[$shop['id']];
  3818. }
  3819. $ed = array();
  3820. foreach ($list as $v)
  3821. {
  3822. $r = $this->api->matching(trim($q,';'),$v['2'],$dtc,$money,$int,$dtctitle,$shop);
  3823. $p = '';
  3824. $product = explode(';',trim($r['product'],';'));
  3825. if($r['title'] != '' && $product)
  3826. {
  3827. foreach ($product as $val)
  3828. {
  3829. $vc = explode('|',$val);
  3830. if(isset($vc[1]))
  3831. {
  3832. $p .= $vc[1].'<br>';
  3833. }
  3834. }
  3835. $r['title'] = str_replace(array('<','>'),array('&lt;','&gt;'),$r['title']);
  3836. $ed[] = array($v['0'],$v['1'],$r['title'],$v['3'],$v['4'],$v['5']);
  3837. }
  3838. else
  3839. {
  3840. $ed[] = array($v['0'],$v['1'],$v['2'].' SKU错误',$v['3'],$v['4'],$v['5']);
  3841. }
  3842. }
  3843. $time = date('Ymd',time());
  3844. $title = 'sku转换'.$time;
  3845. $titlename = "<table border=1><tr><td>退款日期</td><td>订单号</td><td>SKU</td><td退款金额</td><td退款情况具体描述</td><可用/不可用</td></tr></table>";
  3846. $tail = "\n";
  3847. $filename = $title.".xls";
  3848. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3849. $dir = '/data/excel/'.$time.'/';
  3850. $file_name = 'sku转换 '.$time.rand(1000,9999);
  3851. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3852. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3853. fwrite($myfile,$ecl);
  3854. fclose($myfile);
  3855. $error = $dir.$file_name.'.xls';
  3856. echo json_encode(array('msg'=>'转换成功!','error'=>$error,'success'=>true));exit;
  3857. }
  3858. else
  3859. {
  3860. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3861. }
  3862. }
  3863. public function _xxpl_b()
  3864. {
  3865. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  3866. /* 订单加入键值-k */
  3867. $fdata = $this->fullordersmt->find_all('dtime >'.(time()-10*24*3600));
  3868. foreach ($fdata as $v)
  3869. {
  3870. $dataorder[$v['orderinfo']] = $v;
  3871. }
  3872. /* 订单加入键值-j */
  3873. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3874. $config['upload_path'] = '.'.$dir ;
  3875. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3876. $config['allowed_types'] = 'xls|xlsx|csv';
  3877. $config['max_size'] = 10240;
  3878. $this->load->library('upload', $config);
  3879. $this->upload->initialize($config);
  3880. if ($this->upload->do_upload('userfile'))
  3881. {
  3882. $full_path = $dir.$this->upload->data('file_name');
  3883. $fileName = '.' . $full_path;
  3884. if (!file_exists($fileName))
  3885. {
  3886. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3887. }
  3888. else
  3889. {
  3890. require_once "./data/excel/PHPExcel/IOFactory.php";
  3891. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3892. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3893. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3894. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3895. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3896. ++$column;//如果列数大于26行
  3897. $list = array();
  3898. for ($i = 2; $i <= $row; $i++) // 行数循环
  3899. {
  3900. $data = array();
  3901. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3902. {
  3903. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3904. }
  3905. $list[] = $data;
  3906. }
  3907. }
  3908. $i = 0;$j = 0;$ed = array();$time = time();
  3909. foreach ($list as $key=>$value)
  3910. {
  3911. $shop = $this->shop->get_shopname($value['2']);//通过店铺名称查找店铺
  3912. if(!$shop)
  3913. {
  3914. $ed[] = array($value['0'].'-无此店铺');
  3915. $i++;continue;
  3916. }
  3917. $post['buytime'] = strtotime($value['6']);//付款时间
  3918. $value['0'] = preg_replace('/\D/s','',$value['0']);
  3919. if($value['0'] && !isset($dataorder[$value['0']]))
  3920. {
  3921. $post['source'] = 2;//订单类型:1.线下订单2.PC3.手机
  3922. $post['state'] = 207;//订单状态:207等待发货
  3923. $post['review'] = 6;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
  3924. $post['reviewtime'] = $time;//审核时间
  3925. $post['print'] = 2;//打印状态:1.不可打印2.未打印3.已打印
  3926. $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
  3927. $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
  3928. $post['dtime'] = $time;//订单时间
  3929. $post['capital'] = 3;//资金状态
  3930. $post['currency'] = 219;//币种
  3931. $post['currencytitle'] = 'USD';//币种名称
  3932. $post['freight'] = 0;//运费
  3933. $post['expressmoney'] = 0;//物流金额
  3934. $post['shouldmoney'] = 0;//应收金额
  3935. if($post['print'] != 3)
  3936. {
  3937. $post['librarynot'] = "订单未打印";//不能出库原因
  3938. }
  3939. $post['gtime'] = date('Ymd',$post['buytime']);//格式化时间
  3940. $num = $this->fullordersmt->find_count('gtime = "'.date('Ymd',$post['buytime']).'" and shop = "'.$shop['id'].'"','id');
  3941. $post['number'] = $shop['shortname'].'-'.substr(date('ymd',$post['buytime']),1).'-'.(substr(strval($num+1+1000),1,3));//编号
  3942. $post['user'] = $shop['shopuser'];//店铺负责人
  3943. $post['orderinfo'] = $value['0'];//订单号
  3944. $post['type'] = $value['7'];//发货仓库
  3945. $post['shop'] = $shop['id'];//店铺
  3946. $post['shouldmoney'] = $value['3'];//订单金额
  3947. $post['product'] = $value['4']?$value['4']:'';//商品名称
  3948. $post['pay'] = $value['5'];//付款方式
  3949. $post['paypal'] = $value['1']?$value['1']:'';//交易号
  3950. $post['orderremarks'] = $value['8']?$value['8']:'';//订单备注
  3951. $post['shipremarks'] = $value['9'];//仓库品名
  3952. $post['client'] = preg_replace('/( | | | |\s)/',' ',$value['10']);//公司名
  3953. $post['name'] = preg_replace('/( | | | |\s)/',' ',$value['11']);//收货人
  3954. $post['phone'] = $value['12'];//电话
  3955. $ct = $this->country->get_ename(preg_replace('/( | | | |\s)/',' ',$value['13']));//国家
  3956. if(!$ct)
  3957. {
  3958. $ed[] = array($value['0'].'-无此国家');
  3959. $i++;continue;
  3960. }
  3961. $post['country'] = $ct['id'];//国家
  3962. $post['al'] = $ct['lb'];//国家二字码
  3963. $post['province'] = $value['14'];//省、州
  3964. $post['city'] = $value['15'];//城市
  3965. $post['zipcode'] = $value['16'];//邮编
  3966. $post['address'] = $value['17'];//地址1
  3967. $post['address2'] = $value['18']?$value['18']:'';//地址2
  3968. $yga = $value['3'];$ygb = $shop['estimaterate'];
  3969. $post['budget'] = eval("return $yga*1.$ygb;");//预估到帐金额
  3970. $post['sbpm'] = $value['19'];//申报品名
  3971. $post['zwpm'] = $value['20'];//中文品名
  3972. $post['ts'] = $value['21'];//条数
  3973. $post['dtsbjz'] = $value['22'];//单条申报价
  3974. $post['zsbjz'] = $value['23'];//总申报价
  3975. $post['zzl'] = $value['24'];//总重量
  3976. $post['zjs'] = $value['25'];//总件数
  3977. $express = $this->express->get_servicename(preg_replace('/( | | | |\s)/',' ',$value['26']));
  3978. if(!$express)
  3979. {
  3980. $ed[] = array($value['0'].'-无此快递方式');
  3981. $i++;continue;
  3982. }
  3983. $post['express'] = $express['id'];//快递
  3984. $post['printtype'] = 1;//打印类型 1.运单.2.发货单
  3985. $post['fpdata'] = '';//购买产品内容
  3986. $this->fullordersmt->insert($post);
  3987. }
  3988. else
  3989. {
  3990. $ed[] = array($value['0'].'-单号错误或重复操作');
  3991. $i++;
  3992. }
  3993. sleep(2);//停留2秒
  3994. }
  3995. if($i+$j > 0)
  3996. {
  3997. $time = date('Ymd',time());
  3998. $title = '错误信息-'.$time;
  3999. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4000. $tail = "\n";
  4001. $filename = $title.".xls";
  4002. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  4003. $dir = '/data/excel/'.$time.'/';
  4004. $file_name = 'error_'.$time.rand(1000,9999);
  4005. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  4006. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  4007. fwrite($myfile,$ecl);
  4008. fclose($myfile);
  4009. $error = $dir.$file_name.'.xls';
  4010. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  4011. }
  4012. else
  4013. {
  4014. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  4015. }
  4016. }
  4017. else
  4018. {
  4019. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  4020. }
  4021. }
  4022. public function _scwd()
  4023. {
  4024. $dir = '/data/excel/'.date('Ymd',time()).'/';
  4025. $config['upload_path'] = '.'.$dir ;
  4026. $config['allowed_types'] = '*';
  4027. $config['max_size'] = 102400;
  4028. $this->load->library('upload', $config);
  4029. $this->upload->initialize($config);
  4030. if ($this->upload->do_upload('userfile'))
  4031. {
  4032. $full_path = $dir.$this->upload->data('file_name');
  4033. echo json_encode(array('msg'=>'成功!','wdurl'=>$full_path,'success'=>true));exit;
  4034. }
  4035. else
  4036. {
  4037. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  4038. }
  4039. }
  4040. public function _jmexcel()
  4041. {
  4042. $setting = $this->setting->get_settings();
  4043. $excelpass = $setting['excelpass'];
  4044. $excelusernum = $setting['excelusernum'];
  4045. $exceljmnum = $setting['exceljmnum'];
  4046. $user = $this->user->get_api($_SESSION['api']);
  4047. if(!isset($user['exceltime']))
  4048. {
  4049. $this->session->sess_destroy();
  4050. header("Location:/");
  4051. }
  4052. $post = $this->input->post(NULL, TRUE);
  4053. if(isset($post['data']))
  4054. {
  4055. $data = $this->input->post('data',true);
  4056. $data = str_replace("\n",",",$data);;
  4057. $data = explode(',',trim($data,','));
  4058. $d = '';$i = 0;
  4059. foreach ($data as $v)
  4060. {
  4061. if($v == '')
  4062. {
  4063. continue;
  4064. }
  4065. $j = $this->setting->get_jmexcelpass($v);
  4066. if($j == '')
  4067. {
  4068. $j = $v.' 信息不正确';
  4069. }
  4070. $d .= $j."<br />";
  4071. $i++;
  4072. }
  4073. if($i > $exceljmnum)
  4074. {
  4075. echo json_encode(array('msg'=>'每次解密数量不可超出'.$exceljmnum.'条','success'=>false));exit;
  4076. }
  4077. if($user['exceltime'] != date('Ymd',time()))
  4078. {
  4079. $this->user->save(array('exceltime'=>date('Ymd',time()),'excelnum'=>1),$user['id']);
  4080. }
  4081. else
  4082. {
  4083. if($user['excelnum'] > $excelusernum)
  4084. {
  4085. echo json_encode(array('msg'=>'今日此账号解密次数已使用完毕','success'=>false));exit;
  4086. }
  4087. else
  4088. {
  4089. $this->user->save(array('excelnum'=>$user['excelnum']+1),$user['id']);
  4090. }
  4091. }
  4092. echo json_encode(array('msg'=>$d,'success'=>true));exit;
  4093. }
  4094. $this->data['excelpass'] = $excelpass;
  4095. $this->data['excelusernum'] = $excelusernum;
  4096. $this->data['exceljmnum'] = $exceljmnum;
  4097. $this->_Template('fullorderexcel_jmexcel',$this->data);
  4098. }
  4099. //管理
  4100. public function _classid()
  4101. {
  4102. $post = $this->input->post(NULL, TRUE);
  4103. if(isset($post['page']))
  4104. {
  4105. $page = $this->input->post('page',true);
  4106. $perpage = $this->input->post('perpage',true);
  4107. $type = $this->input->post('type',true);
  4108. $where = "1=1 ";
  4109. //数据排序
  4110. $order_str = "id asc";
  4111. if(empty($page))
  4112. {
  4113. $start = 0;
  4114. $perpage = 1;
  4115. }
  4116. else
  4117. {
  4118. $start = ($page - 1)*$perpage;
  4119. }
  4120. if($type)
  4121. {
  4122. $where .= " and type = '$type'";
  4123. }
  4124. //取得信息列表
  4125. $info_list = $this->fullorderexcelclassid->find_all($where,'id,title,type',$order_str,$start,$perpage);
  4126. $total = $this->fullorderexcelclassid->find_count($where);
  4127. $pagenum = ceil($total/$perpage);
  4128. $over = $total-($start+$perpage);
  4129. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4130. echo json_encode($rows);exit;
  4131. }
  4132. $this->_Template('fullorderexcel_classid',$this->data);
  4133. }
  4134. //添加
  4135. public function _classidadd()
  4136. {
  4137. $post = $this->input->post(NULL, TRUE);
  4138. if(isset($post['title']))
  4139. {
  4140. if($this->fullorderexcelclassid->insert($post))
  4141. {
  4142. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  4143. }
  4144. else
  4145. {
  4146. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  4147. }
  4148. }
  4149. $this->_Template('fullorderexcel_classidadd',$this->data);
  4150. }
  4151. //修改
  4152. public function _classidedit($arg_array)
  4153. {
  4154. $post = $this->input->post(NULL, TRUE);
  4155. if(isset($post['id']))
  4156. {
  4157. $id = $this->input->post('id',true);
  4158. if($this->fullorderexcelclassid->save($post,$id))
  4159. {
  4160. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  4161. }
  4162. else
  4163. {
  4164. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  4165. }
  4166. }
  4167. $arg_array = $arg_array[0];
  4168. $fullorderexcelclassid = $this->fullorderexcelclassid->read($arg_array);
  4169. $this->data['fullorderexcelclassid'] = $fullorderexcelclassid;
  4170. $this->_Template('fullorderexcel_classidedit',$this->data);
  4171. }
  4172. }