Fullorderexcel.php 130 KB

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