Fullorderexcel.php 127 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185
  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. unset($info_list[$key]['id']);
  1477. unset($info_list[$key]['fpdata']);
  1478. }
  1479. $fzh = "";
  1480. foreach ($fexcelzh as $v)
  1481. {
  1482. $fzh .= "<td>".$v."</td>";
  1483. }
  1484. $data = array($shouldmoney.' CNY');
  1485. $title = $fexcel['title'].'-'.date('Ymd',time());
  1486. $titlename = "<table border=1>
  1487. <tr>"
  1488. .$fzh.
  1489. "</tr>
  1490. </table>";
  1491. $tail = "\n";
  1492. $filename = $title.".xls";
  1493. $this->excelxh->get_fz5($info_list,$titlename,$filename,$tail,$kong);
  1494. }
  1495. }
  1496. //根据fpdata获取商品sku属性
  1497. private function _getGoodsInfo($value,$goods_sku_list,$typeclass){
  1498. $tmp_goods = explode(';',trim($value['fpdata'],';'));
  1499. $sku_gradefpdata_str = $sku_colorfpdata_str = $sku_densityfpdata_str = $sku_hairnumberfpdata_str = $sku_lacetypefpdata_str = $sku_lowefpdata_str = "";
  1500. foreach($tmp_goods as $tmp_goods_item){
  1501. $dq_goods_item = explode('|',trim($tmp_goods_item,'|'));
  1502. //'gradefpdata','colorfpdata','densityfpdata','hairnumberfpdata','lacetypefpdata'
  1503. $ddq_goods_item = explode('-',trim($dq_goods_item[0],'-'));
  1504. $now_good_sku_info = [];
  1505. foreach($ddq_goods_item as $ll){
  1506. if(!empty($typeclass[$ll])){
  1507. $now_good_sku_info[$typeclass[$ll]['classid']] = empty($typeclass[$ll]['jm'])? " --" : $typeclass[$ll]['jm'];
  1508. }
  1509. }
  1510. if(isset($now_good_sku_info[13])){
  1511. $sku_gradefpdata_str .= $now_good_sku_info[13]."<br/>";
  1512. }else{
  1513. $sku_gradefpdata_str .= " -- <br/>";
  1514. }
  1515. if(isset($now_good_sku_info[8])){
  1516. $sku_colorfpdata_str .= $now_good_sku_info[8]."<br/>";
  1517. }else{
  1518. $sku_colorfpdata_str .= " -- <br/>";
  1519. }
  1520. if(isset($now_good_sku_info[10])){
  1521. $sku_densityfpdata_str .= $now_good_sku_info[10]."<br/>";
  1522. }else{
  1523. $sku_densityfpdata_str .= " -- <br/>";
  1524. }
  1525. if(isset($now_good_sku_info[43])){
  1526. $sku_hairnumberfpdata_str .= $now_good_sku_info[43]."<br/>";
  1527. }else{
  1528. $sku_hairnumberfpdata_str .= " -- <br/>";
  1529. }
  1530. if(isset($now_good_sku_info[18])){
  1531. $sku_lacetypefpdata_str .= $now_good_sku_info[18]."<br/>";
  1532. }else{
  1533. $sku_lacetypefpdata_str .= " -- <br/>";
  1534. }
  1535. if(isset($now_good_sku_info[15])){
  1536. $sku_lowefpdata_str .= $now_good_sku_info[15]."<br/>";
  1537. }else{
  1538. $sku_lowefpdata_str .= " -- <br/>";
  1539. }
  1540. // if($typeclass[$ll]['classid'] == 13){
  1541. // //等级
  1542. // $sku_gradefpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1543. // }elseif($typeclass[$ll]['classid'] == 8){
  1544. // //颜色
  1545. // $sku_colorfpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1546. // }elseif($typeclass[$ll]['classid'] == 10){
  1547. // //密度
  1548. // $sku_densityfpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1549. // }elseif($typeclass[$ll]['classid'] == 43){
  1550. // //人发头套编码
  1551. // $sku_hairnumberfpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1552. // }elseif($typeclass[$ll]['classid'] == 18){
  1553. // //头套种类
  1554. // $sku_lacetypefpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1555. // }
  1556. }
  1557. return [
  1558. 'gradefpdata' => trim($sku_gradefpdata_str,"<br/>"),
  1559. 'colorfpdata' => trim($sku_colorfpdata_str,"<br/>"),
  1560. 'densityfpdata' => trim($sku_densityfpdata_str,"<br/>"),
  1561. 'hairnumberfpdata' => trim($sku_hairnumberfpdata_str,"<br/>"),
  1562. 'lacetypefpdata' => trim($sku_lacetypefpdata_str,"<br/>"),
  1563. 'lowefpdata'=>trim($sku_lowefpdata_str,"<br/>"),
  1564. ];
  1565. }
  1566. //导出订单excel
  1567. public function _excelhz()
  1568. {
  1569. $fgshop = "";$sid = "";$excelshop="";
  1570. if(isset($_SESSION['api']))
  1571. {
  1572. $user = $this->user->get_api($_SESSION['api']);
  1573. $usp = $user;
  1574. $usersp = explode('|',trim($user['shop'],'|'));
  1575. foreach ($usersp as $value)
  1576. {
  1577. $fgshop .= " shop = ".$value." or";
  1578. $sid .= " id = ".$value." or";
  1579. }
  1580. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1581. if($user['excelshop'] == '')
  1582. {
  1583. echo "没有下载权限";exit;
  1584. }
  1585. foreach ($userexcel as $value)
  1586. {
  1587. $excelshop .= " shop = ".$value." or";
  1588. }
  1589. if($excelshop != "")
  1590. {
  1591. $excelshop = "(".rtrim($excelshop,'or').")";
  1592. }
  1593. }
  1594. if(isset($_GET['fexcel']))
  1595. {
  1596. $typeclass = array();
  1597. $tclass = $this->typeclass->find_all();
  1598. foreach ($tclass as $v)
  1599. {
  1600. $typeclass[$v['id']] = $v;
  1601. }
  1602. $dowid = $this->input->get('a');
  1603. $wid = "";
  1604. if($dowid != "")
  1605. {
  1606. $id_arr = explode(',',rtrim($dowid,','));
  1607. $wid .= " id = 0 or";
  1608. foreach ($id_arr as $v)
  1609. {
  1610. $wid .= " id = '$v' or";
  1611. }
  1612. $wid = " and (".rtrim($wid,'or').") ";
  1613. }
  1614. $fexcel = $this->input->get('fexcel',true);
  1615. $page = $this->input->get('page',true);
  1616. $perpage = $this->input->get('perpage',true);
  1617. $warehouse = $this->input->get('warehouse',true);
  1618. $timetk = $this->input->get('timetk',true);
  1619. $timetj = $this->input->get('timetj',true);
  1620. $shop = $this->input->get('shop',true);
  1621. $source = $this->input->get('source',true);
  1622. $state = $this->input->get('state',true);
  1623. $review = $this->input->get('review',true);
  1624. $type = $this->input->get('type',true);
  1625. $express = $this->input->get('express',true);
  1626. $orderinfo = $this->input->get('orderinfo',true);
  1627. $user = $this->input->get('user',true);
  1628. $client = $this->input->get('name',true);
  1629. $waybill = $this->input->get('waybill',true);
  1630. $number = $this->input->get('number',true);
  1631. $email = $this->input->get('email',true);
  1632. $dlz = $this->input->get('dlz',true);
  1633. $library = $this->input->get('library',true);
  1634. $libraryconfirm = $this->input->get('libraryconfirm',true);
  1635. $print = $this->input->get('print',true);
  1636. $timetkk = $this->input->get('timetkk',true);
  1637. $timetjj = $this->input->get('timetjj',true);
  1638. $xztime = $this->input->get('xztime',true);
  1639. $country = $this->input->get('country',true);
  1640. $zf = $this->input->get('zf',true);
  1641. $pay = $this->input->get('pay',true);
  1642. $phone = $this->input->get('phone',true);
  1643. $so = $this->input->get('so',true);
  1644. $sfxh = $this->input->get('sfxh',true);
  1645. $xdcs = $this->input->get('xdcs',true);
  1646. $xdcs = $this->input->get('xdcs',true);
  1647. $dbapi = $this->input->get('dbapi',true);
  1648. $orderurl = $this->input->get('orderurl',true);
  1649. $timetk = strtotime($timetk);
  1650. $timetj = strtotime($timetj);
  1651. $timetkk = strtotime($timetkk);
  1652. $timetjj = strtotime($timetjj);
  1653. $px = $this->input->get('px',true);
  1654. $fexcel = $this->fullorderexcel->read($fexcel);
  1655. $classid = $this->fullorderexcelclassid->read($fexcel['type']);
  1656. $where = "1 = 1 and (".rtrim($fgshop,'or').")";
  1657. if($warehouse)
  1658. {
  1659. $where .= " and type = '$warehouse'";
  1660. }
  1661. if($xztime)
  1662. {
  1663. if($timetk && $timetj)
  1664. {
  1665. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  1666. }
  1667. if($timetkk && $timetjj)
  1668. {
  1669. $where .= " and ".$xztime." > '$timetkk' and ".$xztime." < '$timetjj'";
  1670. }
  1671. }
  1672. else
  1673. {
  1674. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  1675. }
  1676. if($library)
  1677. {
  1678. $where .= " and library = '$library'";
  1679. }
  1680. if($print)
  1681. {
  1682. $where .= " and print = '$print'";
  1683. }
  1684. if($shop)
  1685. {
  1686. $where .= " and shop = '$shop'";
  1687. }
  1688. if($source)
  1689. {
  1690. if($source == '2d')
  1691. {
  1692. $where .= " and source >= '2'";
  1693. }
  1694. else
  1695. {
  1696. $where .= " and source = '$source'";
  1697. }
  1698. }
  1699. if($state)
  1700. {
  1701. $where .= " and state = '$state'";
  1702. }
  1703. if($review)
  1704. {
  1705. $where .= " and review = '$review'";
  1706. }
  1707. if($type)
  1708. {
  1709. $where .= " and type = '$type'";
  1710. }
  1711. if($express)
  1712. {
  1713. $where .= " and express = '$express'";
  1714. }
  1715. if($orderinfo)
  1716. {
  1717. $where .= " and orderinfo = '$orderinfo'";
  1718. }
  1719. if($user)
  1720. {
  1721. $where .= " and user = '$user'";
  1722. }
  1723. if($client)
  1724. {
  1725. $where .= " and client like '%$client%'";
  1726. }
  1727. if($waybill)
  1728. {
  1729. $where .= " and waybill = '$waybill'";
  1730. }
  1731. if($number)
  1732. {
  1733. $where .= " and number = '$number'";
  1734. }
  1735. if($email)
  1736. {
  1737. $where .= " and email = '$email'";
  1738. }
  1739. if($country)
  1740. {
  1741. $where .= " and country = '$country'";
  1742. }
  1743. if($dlz)
  1744. {
  1745. $where .= " and waybill != '' and dlz = 0";
  1746. }
  1747. if($libraryconfirm)
  1748. {
  1749. $where .= " and libraryconfirm = '$libraryconfirm'";
  1750. }
  1751. if($so)
  1752. {
  1753. $where .= " and shipremarks like '%$so%'";
  1754. }
  1755. if($pay)
  1756. {
  1757. $where .= " and pay = '$pay'";
  1758. }
  1759. if($phone)
  1760. {
  1761. $where .= " and phone = '$phone'";
  1762. }
  1763. if($sfxh != '')
  1764. {
  1765. $where .= " and sfxh = '$sfxh'";
  1766. }
  1767. if($orderurl)
  1768. {
  1769. $url = $this->orderurl->read($orderurl);
  1770. $where .= " and link like '%".$url['url']."%'";
  1771. }
  1772. if($zf)
  1773. {
  1774. if($zf == 1)
  1775. {
  1776. $where .= " and paypal not like '%-%-%-%'";
  1777. }
  1778. else
  1779. {
  1780. $where .= " and paypal like '%-%-%-%'";
  1781. }
  1782. }
  1783. $sj = $this->input->get('sj',true);
  1784. if($sj)
  1785. {
  1786. $sj = $this->input->get('sj',true);
  1787. }
  1788. else
  1789. {
  1790. $sj = $classid['type'];
  1791. }
  1792. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  1793. foreach ($fexceleq as $k=>$v)
  1794. {
  1795. $fexceleq[$k] = explode('-',$v);
  1796. $num[$k] = $fexceleq[$k][0];
  1797. }
  1798. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  1799. $feq = "";$kong = array();$sku9610 = '';
  1800. foreach ($fexceleq as $k=>$v)
  1801. {
  1802. if(isset($v[1]))
  1803. {
  1804. if($v[1] == 'klarnabill' || $v[1] == 'klarnaship' || $v[1] == 'PPname' || $v[1] == 'PPaddress' || $v[1] == 'PPemail' || $v[1] == 'afterpayship' || $v[1] == 'afterpaybill')
  1805. {
  1806. $feq .= 'klarnadata,';
  1807. }
  1808. if($v[1] == 'ccfpdata' || $v[1] == 'cpfpdata' || $v[1] == 'dbapi' || $v[1] == 'scapi')
  1809. {
  1810. $feq .= 'fpdata,';
  1811. }
  1812. if($v[1] != 'kong')//空值去除
  1813. {
  1814. if($v[1] == '9610sku' || $v[1] == 'issku' || $v[1] == 'sku')
  1815. {
  1816. if($v[1] == '9610sku')
  1817. {
  1818. $sku9610 = 1;
  1819. }
  1820. if($sj == 'fullordersmt')
  1821. {
  1822. $v[1] = 'sku';
  1823. }
  1824. else
  1825. {
  1826. $v[1] = 'issku';
  1827. }
  1828. }
  1829. $feq .= $v[1].',';
  1830. }
  1831. else
  1832. {
  1833. $kong[$v[0]] = 1;
  1834. }
  1835. }
  1836. }
  1837. //处理额外加上的subtotal和rowtoal 但是不想在表中加太多字段 想着以后有关金额的都给怼到extra_price字段中
  1838. if((strpos($feq,'subtotal')!= false)||(strpos($feq,'rowtotal')!= false) ||(strpos($feq,'product_id')!= false)){
  1839. if(strpos($feq,'subtotal')!= false){
  1840. $feq = str_replace('subtotal,',"extra_price as subtotal,",$feq);
  1841. }
  1842. if(strpos($feq,'rowtotal')!= false){
  1843. $feq = str_replace('rowtotal,',"extra_price as rowtotal,",$feq);
  1844. }
  1845. if(strpos($feq,'product_id')!= false){
  1846. $feq = str_replace('product_id,',"extra_price as product_id,",$feq);
  1847. }
  1848. }
  1849. //添加订单前缀
  1850. $shopqz_list = [];
  1851. if(strpos($feq,'shopqz') !== false){
  1852. $feq = str_replace('shopqz,',"shop as shopqz,",$feq);
  1853. $shop_list = $this->shop->find_all("1 = 1","id,shortname");
  1854. $shopqz_list = array_column($shop_list,'shortname','id');
  1855. }
  1856. $typeclass_lpdl = [];
  1857. //料品大类
  1858. if(strpos($feq,'lpdl')!= false){
  1859. $feq = str_replace('lpdl,',"fpdata as lpdl,",$feq);
  1860. $tmp_typeclass_lpdl = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',16)->get()->result_array();
  1861. $typeclass_lpdl = array_column($tmp_typeclass_lpdl,'zh','id');
  1862. }
  1863. $typeclass_lhdycc = [];
  1864. //料号对应尺寸
  1865. if(strpos($feq,'lhdycc')!= false){
  1866. $feq = str_replace('lhdycc,',"fpdata as lhdycc,",$feq);
  1867. $tmp_typeclass_lhdycc = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',14)->get()->result_array();
  1868. $typeclass_lhdycc = array_column($tmp_typeclass_lhdycc,'zh','id');
  1869. }
  1870. $feq = rtrim($feq,',');
  1871. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  1872. foreach ($fexcelzhw as $k=>$v)
  1873. {
  1874. $fexcelzhw[$k] = explode('-',$v);
  1875. $numb[$k] = $fexcelzhw[$k][0];
  1876. }
  1877. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  1878. $fexcelzh = array();
  1879. foreach ($fexcelzhw as $k=>$v)
  1880. {
  1881. $fexcelzh[] = $v[1];
  1882. }
  1883. if($px)
  1884. {
  1885. $order_str = $px." desc";
  1886. }
  1887. else
  1888. {
  1889. $order_str = "id desc";
  1890. }
  1891. // if($_GET['fexcel'] == '157'){
  1892. // $this->logic_ding->sendToDing("excel导出的【".$where.$wid.' and '.$excelshop);
  1893. // $this->logic_ding->sendToDing("excel导出的【".'id,'.$feq);
  1894. // $this->logic_ding->sendToDing("excel导出的【".$order_str);
  1895. // $this->logic_ding->sendToDing("excel导出的SJ【".$sj);
  1896. // }
  1897. $extra = [
  1898. 'usp'=>$usp,
  1899. 'sku9610'=>$sku9610,
  1900. 'typeclass_lpdl'=>$typeclass_lpdl,
  1901. 'typeclass_lhdycc'=>$typeclass_lhdycc
  1902. ];
  1903. $dlz_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullorder',$extra);
  1904. $tt_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullordertt',$extra);
  1905. $smt_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullordersmt',$extra);
  1906. $amz_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullorderamz',$extra);
  1907. $info_list = array_merge( $dlz_ret['info_list'],$tt_ret['info_list'],$smt_ret['info_list'],$amz_ret['info_list']);
  1908. $shouldmoney = $dlz_ret['shouldmoney']+$tt_ret['shouldmoney']+$smt_ret['shouldmoney']+$amz_ret['shouldmoney'];
  1909. $fzh = "";
  1910. foreach ($fexcelzh as $v)
  1911. {
  1912. $fzh .= "<td>".$v."</td>";
  1913. }
  1914. $data = array($shouldmoney.' CNY');
  1915. $title = $fexcel['title'].'-'.date('Ymd',time());
  1916. $titlename = "<table border=1>
  1917. <tr>"
  1918. .$fzh.
  1919. "</tr>
  1920. </table>";
  1921. $tail = "\n";
  1922. $filename = $title.".xls";
  1923. $this->excel->get_fz5($info_list,$titlename,$filename,$tail,$kong);
  1924. }
  1925. }
  1926. public function _datahz($where,$field,$order_str,$sj,$extra){
  1927. //取得信息列表
  1928. $info_list = $this->$sj->find_all($where,$field,$order_str);
  1929. //格式化数据
  1930. $i = 1;$shouldmoney = 0;$hl=1;
  1931. $usp = $extra['usp'];
  1932. $sku9610 = $extra['sku9610'];
  1933. $typeclass_lpdl = $extra['typeclass_lpdl'];
  1934. $typeclass_lhdycc = $extra['typeclass_lhdycc'];
  1935. foreach ($info_list as $key=>$value)
  1936. {
  1937. $data = $this->$sj->read($value['id']);
  1938. $data = str_replace(array("'"),array("’"),$data);
  1939. if(isset($value['email']) && $usp['excelpass'] == '1')
  1940. {
  1941. $emailpass = $this->setting->get_excelpass($value['email']);
  1942. $info_list[$key]['email'] = $emailpass;
  1943. }
  1944. if(isset($value['phone']) && $usp['excelpass'] == '1')
  1945. {
  1946. $phonepass = $this->setting->get_excelpass($value['phone']);
  1947. $info_list[$key]['phone'] = $phonepass;
  1948. }
  1949. if(isset($value['currencytitle']))
  1950. {
  1951. if($value['currencytitle'] != "CNY")
  1952. {
  1953. $hl=$value['hl'];
  1954. }
  1955. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  1956. }
  1957. if(isset($value['shop']))
  1958. {
  1959. $shop = $this->shop->read($value['shop']);
  1960. $info_list[$key]['shop'] = $shop['shopname'];
  1961. }
  1962. if(isset($value['dtime']))
  1963. {
  1964. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  1965. }
  1966. if(isset($value['printtime']))
  1967. {
  1968. if($value['printtime'] > 0)
  1969. {
  1970. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1971. }
  1972. }
  1973. if(isset($value['sku']))
  1974. {
  1975. if($sku9610 == '1')
  1976. {
  1977. $aesku = explode(';',$value['sku']);
  1978. $aesku = $aesku[0];
  1979. $aesku = explode(':',$aesku);
  1980. if(count($aesku) > 1)
  1981. {
  1982. $aesku = $aesku[1];
  1983. $aesku = str_replace('--','~',$aesku);
  1984. $aesku = explode('-',$aesku);
  1985. $aesku = $aesku[0];
  1986. $aesku = str_replace('~','--',$aesku);
  1987. $info_list[$key]['sku'] = $aesku;
  1988. }
  1989. else
  1990. {
  1991. $info_list[$key]['sku'] = '';
  1992. }
  1993. }
  1994. else
  1995. {
  1996. $info_list[$key]['sku'] = $value['sku'];
  1997. }
  1998. }
  1999. if(isset($value['issku']))
  2000. {
  2001. $value['issku'] = str_replace(array('&lt;','&gt;'),array('<','>'),$value['issku']);
  2002. if($sku9610 == '1')
  2003. {
  2004. $aesku = explode(';',$value['issku']);
  2005. $aesku = $aesku[0];
  2006. $aesku = str_replace('--','~',$aesku);
  2007. $aesku = explode('-',$aesku);
  2008. $aesku = $aesku[0];
  2009. $aesku = str_replace('~','--',$aesku);
  2010. $aesku = str_replace(array('<','>'),array('&lt;','&gt;'),$aesku);
  2011. $info_list[$key]['issku'] = $aesku;
  2012. }
  2013. else
  2014. {
  2015. $value['issku'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['issku']);
  2016. $info_list[$key]['issku'] = $value['issku'];
  2017. }
  2018. }
  2019. if(isset($value['subtotal'])){
  2020. $tmp_sub_str = "";
  2021. $subtotal_list = json_decode($value['subtotal'],true);
  2022. foreach($subtotal_list as $v){
  2023. if(isset($v['sub_total'])){
  2024. $tmp_sub_str .= sprintf( "%.2f",$v['sub_total'])."<br>";
  2025. }else{
  2026. $tmp_sub_str .= "0<br>";
  2027. }
  2028. }
  2029. $info_list[$key]['subtotal'] = $tmp_sub_str;
  2030. }
  2031. if(isset($value['rowtotal'])){
  2032. $tmp_sub_str = "";
  2033. $subtotal_list = json_decode($value['rowtotal'],true);
  2034. foreach($subtotal_list as $v){
  2035. if(isset($v['row_total'])){
  2036. $tmp_sub_str .= sprintf( "%.2f",$v['row_total'])."<br>";
  2037. }else{
  2038. $tmp_sub_str .= "0<br>";
  2039. }
  2040. }
  2041. $info_list[$key]['rowtotal'] = $tmp_sub_str;
  2042. }
  2043. if(isset($value['lpdl'])){
  2044. $tmp_lpdl_str ="";
  2045. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  2046. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  2047. foreach($tmp_fpdata_arr as $v){
  2048. if(empty($v)){
  2049. continue;
  2050. }
  2051. $tmp_arr = explode('-',$v);
  2052. if(isset($typeclass_lpdl[$tmp_arr[1]])){
  2053. $tmp_lpdl_str .= $typeclass_lpdl[$tmp_arr[1]]."<br>";
  2054. }else{
  2055. $tmp_lpdl_str .= " ";
  2056. }
  2057. }
  2058. $info_list[$key]['lpdl'] = trim($tmp_lpdl_str,"<br>") ;
  2059. }
  2060. if(isset($value['lhdycc'])){
  2061. $tmp_lhdycc_str ="";
  2062. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  2063. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  2064. foreach($tmp_fpdata_arr as $v){
  2065. if(empty($v)){
  2066. continue;
  2067. }
  2068. if(stripos($v,',') !== false){
  2069. $tmp_arr = explode(',',$v);
  2070. if(isset($typeclass_lhdycc[$tmp_arr[0]])){
  2071. $tmp_lhdycc_str .= $typeclass_lhdycc[$tmp_arr[0]]."<br>";
  2072. }else{
  2073. $tmp_lhdycc_str .= "异常 <br>";
  2074. }
  2075. }else{
  2076. $tmp_lhdycc_str .= "无 <br>";
  2077. }
  2078. }
  2079. $info_list[$key]['lhdycc'] = trim($tmp_lhdycc_str,"<br>") ;
  2080. }
  2081. if(isset($value['shopqz'])){
  2082. $info_list[$key]['shopqz'] = isset($shopqz_list[$value['shopqz']])?$shopqz_list[$value['shopqz']]:'';
  2083. }
  2084. if(isset($value['product_id'])){
  2085. $tmp_product_id = "";
  2086. $product_ids = json_decode($value['product_id'],true);
  2087. foreach($product_ids as $v){
  2088. if(isset($v['product_id'])){
  2089. $tmp_product_id .= $v['product_id']."<br>";
  2090. }else{
  2091. $tmp_product_id .= "<br>";
  2092. }
  2093. }
  2094. $info_list[$key]['product_id'] = $tmp_product_id;
  2095. }
  2096. if(isset($value['librarytime']))
  2097. {
  2098. if($value['librarytime'] > 0)
  2099. {
  2100. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2101. }
  2102. }
  2103. if(isset($value['buytime']))
  2104. {
  2105. if($value['buytime'] > 0)
  2106. {
  2107. $info_list[$key]['buytime'] = date('Y-m-d H:i:s',$value['buytime']);
  2108. }
  2109. }
  2110. if(isset($value['country']))
  2111. {
  2112. $country = $this->country->read($value['country']);
  2113. $info_list[$key]['country'] = $country['name'];
  2114. }
  2115. if(isset($value['street']))//暂时用街道导出州二字码
  2116. {
  2117. if($data['country'] == 192)//如果是美国
  2118. {
  2119. $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');
  2120. $data['province'] = preg_replace('/( | |\s)/',' ',$data['province']);
  2121. $data['province'] = trim($data['province'],' ');
  2122. if(isset($ToState[strtolower($data['province'])]))
  2123. {
  2124. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  2125. }
  2126. else
  2127. {
  2128. $dataprovince = '';
  2129. }
  2130. $info_list[$key]['street'] = $dataprovince;
  2131. }
  2132. else
  2133. {
  2134. $info_list[$key]['street'] = '';
  2135. }
  2136. }
  2137. if(isset($value['pay']))
  2138. {
  2139. if(empty($value['pay'])){
  2140. $info_list[$key]['pay'] = "";
  2141. }else{
  2142. if($sj =='fullorder'){
  2143. $pay = $this->typeclass->read($value['pay']);
  2144. $info_list[$key]['pay'] = $pay['title'];
  2145. }
  2146. }
  2147. }
  2148. if(isset($value['type']))
  2149. {
  2150. $type = $this->warehouse->read($value['type']);
  2151. $info_list[$key]['type'] = $type['title'];
  2152. }
  2153. if(isset($value['express']))
  2154. {
  2155. $express = $this->express->read($value['express']);
  2156. if($express)
  2157. {
  2158. $info_list[$key]['express'] = $express['servicename'];
  2159. }
  2160. else
  2161. {
  2162. $info_list[$key]['express'] = '未选择';
  2163. }
  2164. }
  2165. if(isset($value['ccfpdata']))
  2166. {
  2167. $ccfpdata = explode(';',$value['fpdata']);
  2168. $inc = 0;
  2169. foreach ($ccfpdata as $v)
  2170. {
  2171. if(stripos($v,',') !== false)
  2172. {
  2173. $cc = explode(',',$v);
  2174. $inctype = $this->typeclass->read($cc[0]);
  2175. if(is_numeric($inctype['spare']))
  2176. {
  2177. if($inctype['spare'] > $inc)
  2178. {
  2179. $inc = $inctype['spare'];
  2180. }
  2181. }
  2182. }
  2183. }
  2184. $info_list[$key]['ccfpdata'] = $inc.'inch';
  2185. }
  2186. if(isset($value['printtype']))
  2187. {
  2188. if($value['printtype'] == 1)
  2189. {
  2190. $info_list[$key]['printtype'] = '运单';
  2191. }
  2192. else if($value['printtype'] == 2)
  2193. {
  2194. $info_list[$key]['printtype'] = '发货单';
  2195. }
  2196. else if($value['printtype'] == 3)
  2197. {
  2198. $info_list[$key]['printtype'] = '不打印单据';
  2199. }
  2200. else
  2201. {
  2202. $info_list[$key]['printtype'] = '未选择';
  2203. }
  2204. }
  2205. if(isset($value['exstate']))
  2206. {
  2207. if($value['exstate'] == '99')
  2208. {
  2209. $info_list[$key]['exstate'] = '未获取到物流信息';
  2210. }
  2211. else if($value['exstate'] == '1')
  2212. {
  2213. $info_list[$key]['exstate'] = '已揽收';
  2214. }
  2215. else if($value['exstate'] == '2')
  2216. {
  2217. $info_list[$key]['exstate'] = '在途中';
  2218. }
  2219. else if($value['exstate'] == '3')
  2220. {
  2221. $info_list[$key]['exstate'] = '派送中';
  2222. }
  2223. else if($value['exstate'] == '4')
  2224. {
  2225. $info_list[$key]['exstate'] = '已签收';
  2226. }
  2227. else if($value['exstate'] == '5')
  2228. {
  2229. $info_list[$key]['exstate'] = '派送异常';
  2230. }
  2231. else
  2232. {
  2233. $info_list[$key]['exstate'] = '';
  2234. }
  2235. }
  2236. if(isset($value['link']))
  2237. {
  2238. if($value['link'] != '')
  2239. {
  2240. $link = explode(',',$value['link']);
  2241. $info_list[$key]['link'] = $link[0];
  2242. }
  2243. else
  2244. {
  2245. $info_list[$key]['link'] = '';
  2246. }
  2247. }
  2248. if(isset($value['klarnabill']))
  2249. {
  2250. $klarnadata = explode('|',$value['klarnadata']);
  2251. if(isset($klarnadata[2]))
  2252. {
  2253. $info_list[$key]['klarnabill'] = $klarnadata[2];
  2254. }
  2255. else
  2256. {
  2257. $info_list[$key]['klarnabill'] = '';
  2258. }
  2259. }
  2260. if(isset($value['klarnaship']))
  2261. {
  2262. $klarnadata = explode('|',$value['klarnadata']);
  2263. if(isset($klarnadata[3]))
  2264. {
  2265. $info_list[$key]['klarnaship'] = $klarnadata[3];
  2266. }
  2267. else
  2268. {
  2269. $info_list[$key]['klarnaship'] = '';
  2270. }
  2271. }
  2272. if(isset($value['afterpaybill']))
  2273. {
  2274. $klarnadata = explode('|',$value['klarnadata']);
  2275. if(isset($klarnadata[1]))
  2276. {
  2277. $info_list[$key]['afterpaybill'] = $klarnadata[1];
  2278. }
  2279. else
  2280. {
  2281. $info_list[$key]['afterpaybill'] = '';
  2282. }
  2283. }
  2284. if(isset($value['afterpayship']))
  2285. {
  2286. $klarnadata = explode('|',$value['klarnadata']);
  2287. if(isset($klarnadata[2]))
  2288. {
  2289. $info_list[$key]['afterpayship'] = $klarnadata[2];
  2290. }
  2291. else
  2292. {
  2293. $info_list[$key]['afterpayship'] = '';
  2294. }
  2295. }
  2296. if(isset($value['PPname']))
  2297. {
  2298. $info_list[$key]['PPname'] = '';
  2299. $klarnadata = explode('|',$value['klarnadata']);
  2300. if(isset($klarnadata[1]))
  2301. {
  2302. $klarnadata = json_decode($klarnadata[1],true);
  2303. if(isset($klarnadata['name']))
  2304. {
  2305. $info_list[$key]['PPname'] = $klarnadata['name'];
  2306. }
  2307. }
  2308. }
  2309. if(isset($value['PPemail']))
  2310. {
  2311. $info_list[$key]['PPemail'] = '';
  2312. $klarnadata = explode('|',$value['klarnadata']);
  2313. if(isset($klarnadata[1]))
  2314. {
  2315. $klarnadata = json_decode($klarnadata[1],true);
  2316. if(isset($klarnadata['email']))
  2317. {
  2318. if($usp['excelpass'] == '1')
  2319. {
  2320. $ppemailpass = $this->setting->get_excelpass($klarnadata['email']);
  2321. }
  2322. else
  2323. {
  2324. $ppemailpass = $klarnadata['email'];
  2325. }
  2326. $info_list[$key]['PPemail'] = $ppemailpass;
  2327. }
  2328. }
  2329. }
  2330. if(isset($value['PPaddress']))
  2331. {
  2332. $info_list[$key]['PPaddress'] = '';
  2333. $klarnadata = explode('|',$value['klarnadata']);
  2334. if(isset($klarnadata[1]))
  2335. {
  2336. $klarnadata = json_decode($klarnadata[1],true);
  2337. if(isset($klarnadata['address']))
  2338. {
  2339. $info_list[$key]['PPaddress'] = $klarnadata['address'];
  2340. }
  2341. }
  2342. }
  2343. if(isset($value['klarnadata']))
  2344. {
  2345. unset($info_list[$key]['klarnadata']);
  2346. }
  2347. if(isset($value['shippingmethod']))
  2348. {
  2349. $tax = explode('Tax:',$value['shippingmethod']);
  2350. $info_list[$key]['shippingmethod'] = (isset($tax[1]))?trim($tax[1],';'):'';
  2351. }
  2352. if(isset($value['systemwigsout']))
  2353. {
  2354. $out = $this->systemtransfer->find_all("number = '".$data['number']."'");
  2355. $outread = '';
  2356. if($out)
  2357. {
  2358. foreach ($out as $val)
  2359. {
  2360. $list = '';
  2361. $rk = explode('|',trim($val['rk'],'|'));
  2362. $rktime = explode('|',trim($val['rktime'],'|'));
  2363. $zw = array();
  2364. $t = $this->transfer->find_all("1=1");
  2365. foreach ($t as $v)
  2366. {
  2367. $zw[$v['id']] = $v['title'];
  2368. }
  2369. if($val['rk'] != '' && count($rk) > 0)
  2370. {
  2371. for($i=0;$i<count($rk);$i++)
  2372. {
  2373. if(!isset($rktime[$i]))
  2374. {
  2375. $list .= $zw[$cz[$i]];
  2376. }
  2377. else
  2378. {
  2379. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  2380. }
  2381. }
  2382. }
  2383. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  2384. }
  2385. }
  2386. else
  2387. {
  2388. $systemwigsout = $this->systemwigsout->find_all("number = '".$data['number']."'");
  2389. if($systemwigsout)
  2390. {
  2391. foreach ($systemwigsout as $v)
  2392. {
  2393. $outread = '';
  2394. if($v['czwarehouse'] == 37)
  2395. {
  2396. $outread .= '华荣厂';
  2397. }
  2398. else if($v['czwarehouse'] == 0)
  2399. {
  2400. $outread .= '龙盈厂';
  2401. }
  2402. $cz = explode('|',trim($v['cz'],'|'));
  2403. $cztime = explode('|',trim($v['cztime'],'|'));
  2404. $zw = $this->transfer->get_list();
  2405. if($v['cz'] != '' && count($cz) > 0)
  2406. {
  2407. for($i=0;$i<count($cz);$i++)
  2408. {
  2409. if(!isset($cztime[$i]))
  2410. {
  2411. $outread .= $zw[$cz[$i]].' -&gt; ';
  2412. }
  2413. else
  2414. {
  2415. $outread .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  2416. }
  2417. }
  2418. $outread .= '<br>';
  2419. }
  2420. }
  2421. }
  2422. }
  2423. $info_list[$key]['systemwigsout'] = $outread;
  2424. }
  2425. if(isset($value['sourcetype']))
  2426. {
  2427. if($value['sourcetype'] == '1')
  2428. {
  2429. $info_list[$key]['sourcetype'] = '网红单';
  2430. }
  2431. else if($value['sourcetype'] == '2')
  2432. {
  2433. $info_list[$key]['sourcetype'] = '批发单';
  2434. }
  2435. else if($value['sourcetype'] == '3')
  2436. {
  2437. $info_list[$key]['sourcetype'] = '线下单';
  2438. }
  2439. else if($value['sourcetype'] == '4')
  2440. {
  2441. $info_list[$key]['sourcetype'] = '售后单';
  2442. }
  2443. else if($value['sourcetype'] == '5')
  2444. {
  2445. $info_list[$key]['sourcetype'] = '其它';
  2446. }
  2447. else
  2448. {
  2449. $info_list[$key]['sourcetype'] = '';
  2450. }
  2451. }
  2452. if(isset($value['js']))
  2453. {
  2454. if($value['js'] == '0')
  2455. {
  2456. $info_list[$key]['js'] = 'Ground Advantage';
  2457. }
  2458. else if($value['js'] == '1')
  2459. {
  2460. $info_list[$key]['js'] = 'PRIORITY';
  2461. }
  2462. else if($value['js'] == '2')
  2463. {
  2464. $info_list[$key]['js'] = 'EXPRESS';
  2465. }
  2466. else if($value['js'] == '3')
  2467. {
  2468. $info_list[$key]['js'] = 'IP';
  2469. }
  2470. else if($value['js'] == '4')
  2471. {
  2472. $info_list[$key]['js'] = 'FICP';
  2473. }
  2474. }
  2475. if(isset($value['type']))
  2476. {
  2477. $type = $this->warehouse->read($value['type']);
  2478. $info_list[$key]['type'] = $type['title'];
  2479. }
  2480. if(isset($value['xdcs']))
  2481. {
  2482. if($sj == 'fullorder')
  2483. {
  2484. $xdcs = $this->customer->get_email($data['email'],$data['shop']);
  2485. }
  2486. else
  2487. {
  2488. $xdcs = $this->customersmt->get_shopdata($data['shop'],$data['name'],$data['address']);
  2489. }
  2490. $info_list[$key]['xdcs'] = (isset($xdcs['num']))?(($xdcs['num']==0)?1:$xdcs['num']):1;
  2491. }
  2492. if(isset($value['dbapi']) || isset($value['scapi']))
  2493. {
  2494. $jmlist = '';$shuliang = '';
  2495. $classid = $this->classid->sku();
  2496. $dbapi = explode(';',trim($value['fpdata'],';'));
  2497. foreach ($dbapi as $va)
  2498. {
  2499. $pm = $classid;
  2500. $jm = $classid;
  2501. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2502. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2503. $ts = explode('|',trim($features,'|'));
  2504. if(stripos($ts[0],',') !== false)
  2505. {
  2506. $ft = explode(',',$ts[0]);
  2507. $features = explode('-',trim($ft[1],'-'));
  2508. $features[] = $ft[0];
  2509. }
  2510. else
  2511. {
  2512. $features = explode('-',trim($ts[0],'-'));
  2513. }
  2514. foreach($features as $k=>$v)
  2515. {
  2516. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2517. {
  2518. if($typeclass[$v]['bm'] != '')
  2519. {
  2520. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2521. }
  2522. }
  2523. if($v != 0 && isset($typeclass[$v]))
  2524. {
  2525. if($typeclass[$v]['classid'] == 13)
  2526. {
  2527. $dj = $typeclass[$v]['title'];
  2528. }
  2529. if($typeclass[$v]['classid'] == 8)
  2530. {
  2531. $ys = $typeclass[$v]['title'];
  2532. }
  2533. if($typeclass[$v]['classid'] == 15)
  2534. {
  2535. $hx = $typeclass[$v]['title'];
  2536. }
  2537. if(isset($pm[$typeclass[$v]['classid']]))
  2538. {
  2539. if($typeclass[$v]['title'] == '9A')
  2540. {
  2541. $pm[$typeclass[$v]['classid']] = '9A';
  2542. }
  2543. else if($typeclass[$v]['title'] == '10A')
  2544. {
  2545. $pm[$typeclass[$v]['classid']] = '10A';
  2546. }
  2547. else
  2548. {
  2549. $clzh = $typeclass[$v]['zh'];
  2550. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2551. {
  2552. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2553. $clzh = $clzh[0];
  2554. }
  2555. $pm[$typeclass[$v]['classid']] = $clzh;
  2556. }
  2557. }
  2558. if(isset($jm[$typeclass[$v]['classid']]))
  2559. {
  2560. if($typeclass[$v]['jm'])
  2561. {
  2562. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2563. }
  2564. }
  2565. }
  2566. }
  2567. $jm = array_filter($jm);//去除空值
  2568. $jm = implode("-",$jm);
  2569. $jmlist .= $jm.'<br>';
  2570. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  2571. $pm = array_filter($pm);//去除空值
  2572. $zh = implode(" ",$pm);
  2573. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2574. }
  2575. if(isset($value['dbapi']))
  2576. {
  2577. $info_list[$key]['dbapi'] = $jmlist;
  2578. }
  2579. else
  2580. {
  2581. $info_list[$key]['scapi'] = $shuliang;
  2582. }
  2583. }
  2584. if(isset($value['dbapi']) && isset($value['scapi']))
  2585. {
  2586. $jmlist = '';$shuliang = '';
  2587. $classid = $this->classid->sku();
  2588. $dbapi = explode(';',trim($value['fpdata'],';'));
  2589. foreach ($dbapi as $va)
  2590. {
  2591. $pm = $classid;
  2592. $jm = $classid;
  2593. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2594. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2595. $ts = explode('|',trim($features,'|'));
  2596. if(stripos($ts[0],',') !== false)
  2597. {
  2598. $ft = explode(',',$ts[0]);
  2599. $features = explode('-',trim($ft[1],'-'));
  2600. $features[] = $ft[0];
  2601. }
  2602. else
  2603. {
  2604. $features = explode('-',trim($ts[0],'-'));
  2605. }
  2606. foreach($features as $k=>$v)
  2607. {
  2608. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2609. {
  2610. if($typeclass[$v]['bm'] != '')
  2611. {
  2612. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2613. }
  2614. }
  2615. if($v != 0 && isset($typeclass[$v]))
  2616. {
  2617. if($typeclass[$v]['classid'] == 13)
  2618. {
  2619. $dj = $typeclass[$v]['title'];
  2620. }
  2621. if($typeclass[$v]['classid'] == 8)
  2622. {
  2623. $ys = $typeclass[$v]['title'];
  2624. }
  2625. if($typeclass[$v]['classid'] == 15)
  2626. {
  2627. $hx = $typeclass[$v]['title'];
  2628. }
  2629. if(isset($pm[$typeclass[$v]['classid']]))
  2630. {
  2631. if($typeclass[$v]['title'] == '9A')
  2632. {
  2633. $pm[$typeclass[$v]['classid']] = '9A';
  2634. }
  2635. else if($typeclass[$v]['title'] == '10A')
  2636. {
  2637. $pm[$typeclass[$v]['classid']] = '10A';
  2638. }
  2639. else
  2640. {
  2641. $clzh = $typeclass[$v]['zh'];
  2642. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2643. {
  2644. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2645. $clzh = $clzh[0];
  2646. }
  2647. $pm[$typeclass[$v]['classid']] = $clzh;
  2648. }
  2649. }
  2650. if(isset($jm[$typeclass[$v]['classid']]))
  2651. {
  2652. if($typeclass[$v]['jm'])
  2653. {
  2654. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2655. }
  2656. }
  2657. }
  2658. }
  2659. $jm = array_filter($jm);//去除空值
  2660. $jm = implode("-",$jm);
  2661. $jmlist .= $jm.'<br>';
  2662. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  2663. $pm = array_filter($pm);//去除空值
  2664. $zh = implode(" ",$pm);
  2665. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2666. }
  2667. $info_list[$key]['dbapi'] = $jmlist;
  2668. $info_list[$key]['scapi'] = $shuliang;
  2669. }
  2670. if(isset($value['cpfpdata']))
  2671. {
  2672. $fpread = '';
  2673. $cpfpdata = explode(';',trim($value['fpdata'],';'));
  2674. foreach ($cpfpdata as $v)
  2675. {
  2676. $va = explode('|',trim($v,'|'));
  2677. if(isset($va[1])){
  2678. $fpread .= $va[1].'; ';
  2679. }else{
  2680. $fpread .="合并单没有产品异常标记";
  2681. }
  2682. }
  2683. $info_list[$key]['cpfpdata'] = $fpread;
  2684. }
  2685. unset($info_list[$key]['id']);
  2686. unset($info_list[$key]['fpdata']);
  2687. }
  2688. return [
  2689. 'info_list'=>$info_list,
  2690. 'shouldmoney'=>$shouldmoney
  2691. ];
  2692. }
  2693. //上传运单
  2694. public function _waybill($arg_array)
  2695. {
  2696. $readid = $arg_array[0];
  2697. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  2698. /* 订单加入键值-k */
  2699. $fdata = $this->fullorder->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and dlz < 1 and state = 207');
  2700. foreach ($fdata as $v)
  2701. {
  2702. $dataorder[$v['orderinfo']] = $v;
  2703. }
  2704. $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)');
  2705. foreach ($sdata as $v)
  2706. {
  2707. $dataorder[$v['orderinfo']] = $v;
  2708. }
  2709. $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)');
  2710. foreach ($tdata as $v)
  2711. {
  2712. $dataorder[$v['orderinfo']] = $v;
  2713. }
  2714. $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)');
  2715. foreach ($xdata as $v)
  2716. {
  2717. $dataorder[$v['orderinfo']] = $v;
  2718. }
  2719. /* 订单加入键值-j */
  2720. /* 店铺加入键值-j */
  2721. $fshop = $this->shop->find_all('1=1');
  2722. foreach ($fshop as $v)
  2723. {
  2724. $datashop[$v['id']] = $v;
  2725. }
  2726. /* 店铺加入键值-k */
  2727. /* 快递加入键值-j */
  2728. $fex = $this->express->find_all('1=1');
  2729. foreach ($fex as $v)
  2730. {
  2731. $dataex[$v['id']] = $v;
  2732. }
  2733. /* 快递加入键值-k */
  2734. /* 仓库加入键值-k */
  2735. $fwh = $this->warehouse->find_all('1=1');
  2736. foreach ($fwh as $v)
  2737. {
  2738. $datack[$v['id']] = $v;
  2739. }
  2740. /* 仓库加入键值-j */
  2741. $fs = $this->notice->get_ordertatus(216);//216成功状态
  2742. if(is_numeric($readid) == false || $readid < 1)
  2743. {
  2744. echo json_encode(array('msg'=>'店铺信息错误!','success'=>true));exit;
  2745. }
  2746. $dir = '/data/excel/'.date('Ymd',time()).'/';
  2747. $config['upload_path'] = '.'.$dir ;
  2748. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  2749. $config['allowed_types'] = 'xls|xlsx|csv';
  2750. $config['max_size'] = 10240;
  2751. $this->load->library('upload', $config);
  2752. $this->upload->initialize($config);
  2753. if ($this->upload->do_upload('userfile'))
  2754. {
  2755. $full_path = $dir.$this->upload->data('file_name');
  2756. $fileName = '.' . $full_path;
  2757. if (!file_exists($fileName))
  2758. {
  2759. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  2760. }
  2761. else
  2762. {
  2763. require_once "./data/excel/PHPExcel/IOFactory.php";
  2764. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  2765. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  2766. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  2767. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  2768. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  2769. ++$column;//如果列数大于26行
  2770. $list = array();
  2771. for ($i = 2; $i <= $row; $i++) // 行数循环
  2772. {
  2773. $data = array();
  2774. for ($c = 'A'; $c != $column; $c++) // 列数循环
  2775. {
  2776. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  2777. }
  2778. $list[] = $data;
  2779. }
  2780. }
  2781. $i = 0;$j = 0;$ed = array();$cscs = array();
  2782. $this->db->trans_begin();
  2783. foreach ($list as $key=>$value)
  2784. {
  2785. $ddh = preg_replace('/\D/s','',$value['0']);
  2786. $ydh = preg_replace('/\W/s','',$value['1']);
  2787. $shop = $datashop[$readid];
  2788. if($shop['type'] == '269')
  2789. {
  2790. $orid = $readid.$ddh;
  2791. }
  2792. else
  2793. {
  2794. $orid = $ddh;
  2795. }
  2796. if(isset($dataorder[$orid]))
  2797. {
  2798. if($shop['type'] == 269)//独立站前缀需要添加ID
  2799. {
  2800. $time = time();
  2801. $xg = $dataorder[$orid];
  2802. $oldw = $xg['waybill'];
  2803. $ex = $dataex[$xg['express']];
  2804. $warehouse = $datack[$xg['type']];
  2805. $msg = $ydh;
  2806. $xg['waybill'] = $ydh;
  2807. $fs = $this->notice->find_all("shop = '".$xg['shop']."' and message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");
  2808. if(isset($fs[0]))
  2809. {
  2810. $fs = $fs[0];
  2811. $fs['email'] = $this->emaildata->read($fs['email']);
  2812. if(($xg['dlzemail'] == 1 && $msg != $oldw) || $xg['dlzemail'] == 0)
  2813. {
  2814. $ck = $this->notice->get_god($xg,$shop,$ex,$fs);
  2815. if($ck == 1)
  2816. {
  2817. $ckemail = '邮件发送成功,';
  2818. $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$xg['id']);
  2819. }
  2820. }
  2821. }
  2822. if($msg != $oldw)
  2823. {
  2824. if($xg['source'] != 1)
  2825. {
  2826. $ms = $this->message->find_all("express like '%,".$xg['express'].",%'");
  2827. if(!isset($ms[0]))
  2828. {
  2829. $ms = $this->message->read(2);
  2830. }
  2831. else
  2832. {
  2833. $ms = $ms[0];
  2834. }
  2835. $ddh = substr($xg['orderinfo'],1);
  2836. $shopifyid = $xg['shopify'];
  2837. //独立站地址更新订单状态、物流信息
  2838. $shopname = $shop['brandname']; //店铺名
  2839. $buyername = $xg['bname']; //Bill Name
  2840. $email_call = $shop['shopid']; //发货人邮箱;
  2841. $phone = $shop['shopphone']; //发货人电话
  2842. $track_type = $ex['title']; //快递名称
  2843. $service = $ex['title']; //快递追踪名称
  2844. $track_link = $ex['url']; //快递查询网址
  2845. $logistics_number = $ydh; //运单号
  2846. $t= array('%buyername%','%email_call%','%track_type%','%service%','%track_link%','%logistics_number%','%shop%','%phone%','%jtime%');
  2847. $h= array($buyername,$email_call,$track_type,$service,$track_link,$logistics_number,$shopname,$phone,$ex['yjtime']);
  2848. $remark = str_replace($t,$h,$ms['content']);
  2849. @$gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$remark,$shopifyid);
  2850. }
  2851. else if($xg['source'] == 1)
  2852. {
  2853. $gx['res'] = 3;
  2854. $gx['state'] = 216;
  2855. }
  2856. }
  2857. else
  2858. {
  2859. $gx['res'] = $xg['dlz'];
  2860. $gx['state'] = $xg['state'];
  2861. }
  2862. $xg['iscode'] = $ex['title'];
  2863. $xg['url'] = $shop['shopname'];
  2864. @$chuanshu = $this->api->get_paypal($xg);
  2865. //$this->afspaypal->insert(array('number'=>$xg['number'],'cs'=>$chuanshu));
  2866. $this->fullorder->save(array('waybill'=>$msg,'state'=>$gx['state'],'dlz'=>$gx['res']),$xg['id']);
  2867. /**
  2868. $xg = $dataorder[$arg_array[0].$ddh];
  2869. $ex = $dataex[$xg['express']];
  2870. $warehouse = $datack[$xg['type']];
  2871. if($xg['source'] != 1 && $ex['iscode'] != 'Other' && $xg['state'] == '207')
  2872. {
  2873. //独立站地址更新订单状态、物流信息
  2874. $gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$xg['msg'],$xg['msg'],$dataorder[$orid]['shopify']);
  2875. if(!isset($gx['res']))
  2876. {
  2877. $ed[] = array($ddh.'-更新失败');
  2878. $j++;
  2879. continue;
  2880. }
  2881. $this->fullorder->save(array('waybill'=>$ydh,'dlz'=>$gx['res'],'state'=>$gx['state']),$xg['id']);
  2882. if($gx['res'] == 1 && $fs)
  2883. {
  2884. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  2885. }
  2886. }
  2887. else if($xg['source'] == 1 && $xg['state'] == '207')
  2888. {
  2889. $this->fullorder->save(array('waybill'=>$ydh,'dlz'=>3,'state'=>216),$xg['id']);
  2890. if($fs)
  2891. {
  2892. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  2893. }
  2894. }
  2895. else
  2896. {
  2897. $ed[] = array($ddh.'-状态错误');
  2898. $j++;
  2899. continue;
  2900. }
  2901. **/
  2902. }
  2903. else if($shop['type'] == 270)//速卖通对接发货声明
  2904. {
  2905. $xg = $dataorder[$ddh];
  2906. $ex = $dataex[$xg['express']];
  2907. $warehouse = $datack[$xg['type']];
  2908. if($xg['source'] != 1 && $ex['aecode'] != 'Other' && $xg['library'] == 2 && ($xg['dlz'] == '0' || $xg['dlz'] == '2'))
  2909. {
  2910. $result = $this->apismt->get_out($ydh,'all',$xg['orderinfo'],$ex['aecode'],$sp['code']);
  2911. if(isset($result['result_success']) && $result['result_success'] == "true")
  2912. {
  2913. $this->fullordersmt->save(array('waybill'=>$ydh,'state'=>209,'dlz'=>1),$xg['id']);
  2914. /** 合并信息处理开始-发货声明 **/
  2915. if($xg['merge'] != '0')
  2916. {
  2917. $hdata = $this->fullordersmt->find_all("merge = '".$xg['merge']."' and id != '".$xg['id']."' and dlz = '0' and source != 1");$l=0;
  2918. foreach ($hdata as $v)
  2919. {
  2920. $result = $this->apismt->get_out($ydh,'all',$v['orderinfo'],$ex['aecode'],$sp['code']);
  2921. if(isset($result['result_success']) && $result['result_success'] == "true")
  2922. {
  2923. $this->fullordersmt->save(array('waybill'=>$ydh,'state'=>209,'dlz'=>1),$v['id']);
  2924. }
  2925. else
  2926. {
  2927. $ed[] = array($v['orderinfo'].'-合并单发货声明失败,请在ERP上手动操作此单');
  2928. $j++;
  2929. continue;
  2930. }
  2931. $l++;
  2932. if($l > 10)
  2933. {
  2934. break;
  2935. }
  2936. }
  2937. }
  2938. /** 合并信息处理结束开始 **/
  2939. }
  2940. else
  2941. {
  2942. $ed[] = array($ddh.'-发货声明失败');
  2943. $j++;
  2944. continue;
  2945. }
  2946. }
  2947. else if($xg['source'] != 1 && $ex['aecode'] != 'Other' && $xg['dlz'] == '1' && $xg['library'] == 2)//修改声明
  2948. {
  2949. $obtain = $this->apismt->get_obtain($xg['orderinfo'],$sp['code']);//修改声明先查询之前物流信息
  2950. if(isset($obtain['logistics_no']))
  2951. {
  2952. $result = $this->apismt->get_editout($obtain['logistics_no'],$ydh,'all',$xg['orderinfo'],$obtain['service_name'],$ex['aecode'],$sp['code']);
  2953. }
  2954. if(isset($result['result_success']) && $result['result_success'] == "true")
  2955. {
  2956. $this->fullordersmt->save(array('waybill'=>$ydh),$xg['id']);
  2957. /** 合并信息处理开始-修改声明 **/
  2958. if($xg['merge'] != '0')
  2959. {
  2960. $hdata = $this->fullordersmt->find_all("merge = '".$xg['merge']."' and id != '".$xg['id']."' and dlz != 1 and source != 1");$l=0;
  2961. foreach ($hdata as $v)
  2962. {
  2963. $obtain = $this->apismt->get_obtain($v['orderinfo'],$sp['code']);//修改声明先查询之前物流信息
  2964. if(isset($obtain['logistics_no']))
  2965. {
  2966. $result = $this->apismt->get_editout($obtain['logistics_no'],$ydh,'all',$v['orderinfo'],$obtain['service_name'],$ex['aecode'],$sp['code']);
  2967. }
  2968. if(isset($result['result_success']) && $result['result_success'] == "true")
  2969. {
  2970. $this->fullordersmt->save(array('waybill'=>$ydh),$v['id']);
  2971. }
  2972. else
  2973. {
  2974. $ed[] = array($v['orderinfo'].'-合并单修改发货声明失败,请在ERP上手动操作此单');
  2975. $j++;
  2976. continue;
  2977. }
  2978. $l++;
  2979. if($l > 10)
  2980. {
  2981. break;
  2982. }
  2983. }
  2984. }
  2985. /** 合并信息处理结束开始 **/
  2986. }
  2987. else
  2988. {
  2989. $ed[] = array($ddh.'-修改发货声明失败');
  2990. $j++;
  2991. continue;
  2992. }
  2993. }
  2994. else if($xg['source'] == 1 && $xg['state'] == '207')
  2995. {
  2996. $this->fullordersmt->save(array('waybill'=>$ydh,'dlz'=>3,'state'=>216),$xg['id']);
  2997. }
  2998. else
  2999. {
  3000. $this->fullordersmt->save(array('waybill'=>$ydh),$xg['id']);
  3001. }
  3002. }
  3003. }
  3004. else
  3005. {
  3006. $ed[] = array($ddh.'-单号错误或重复操作');
  3007. $i++;
  3008. continue;
  3009. }
  3010. sleep(1);//停留1秒
  3011. }
  3012. if ($this->db->trans_status() === FALSE)
  3013. {
  3014. $this->db->trans_rollback();
  3015. }
  3016. else
  3017. {
  3018. $this->db->trans_commit();
  3019. }
  3020. if($i+$j > 0)
  3021. {
  3022. $time = date('Ymd',time());
  3023. $title = '错误信息-'.$time;
  3024. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3025. $tail = "\n";
  3026. $filename = $title.".xls";
  3027. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3028. $dir = '/data/excel/'.$time.'/';
  3029. $file_name = 'error_'.$time.rand(1000,9999);
  3030. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3031. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3032. fwrite($myfile,$ecl);
  3033. fclose($myfile);
  3034. $error = $dir.$file_name.'.xls';
  3035. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3036. }
  3037. else
  3038. {
  3039. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3040. }
  3041. }
  3042. else
  3043. {
  3044. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3045. }
  3046. }
  3047. //上传速卖通订单
  3048. public function _order($arg_array)
  3049. {
  3050. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  3051. /* 订单加入键值-k */
  3052. $fdata = $this->fullorder_smt->find_all('dtime >'.(time()-5*24*3600));
  3053. foreach ($fdata as $v)
  3054. {
  3055. $dataorder[$v['orderinfo']] = $v;
  3056. }
  3057. /* 订单加入键值-j */
  3058. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3059. $config['upload_path'] = '.'.$dir ;
  3060. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3061. $config['allowed_types'] = 'xls|xlsx|csv';
  3062. $config['max_size'] = 10240;
  3063. $this->load->library('upload', $config);
  3064. $this->upload->initialize($config);
  3065. if ($this->upload->do_upload('userfile'))
  3066. {
  3067. $full_path = $dir.$this->upload->data('file_name');
  3068. $fileName = '.' . $full_path;
  3069. if (!file_exists($fileName))
  3070. {
  3071. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3072. }
  3073. else
  3074. {
  3075. require_once "./data/excel/PHPExcel/IOFactory.php";
  3076. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3077. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3078. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3079. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3080. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3081. ++$column;//如果列数大于26行
  3082. $list = array();
  3083. for ($i = 2; $i <= $row; $i++) // 行数循环
  3084. {
  3085. $data = array();
  3086. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3087. {
  3088. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3089. }
  3090. $list[] = $data;
  3091. }
  3092. }
  3093. $i = 0;$j = 0;$ed = array();$tytime = time();
  3094. foreach ($list as $key=>$value)
  3095. {
  3096. $value['2'] = preg_replace('/\D/s','',$value['2']);
  3097. if($value['2'] && !isset($dataorder[$value['2']]))
  3098. {
  3099. $num = $this->fullorder_smt->find_count('gtime = "'.date('Ymd',time()).'"');
  3100. $post['source'] = 2;//订单类型:1.线下订单2.PC3.手机
  3101. $post['state'] = 207;//订单状态:207等待发货
  3102. $post['review'] = 6;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
  3103. $post['reviewtime'] = $tytime;//审核时间
  3104. $post['print'] = 2;//打印状态:1.不可打印2.未打印3.已打印
  3105. $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
  3106. $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
  3107. if($post['print'] != 3)
  3108. {
  3109. $post['librarynot'] = "订单未打印,未审核或未通过";//不能出库原因
  3110. }
  3111. $value['1'] = trim($value['1'],' ');
  3112. $shortname = explode('-',$value['1']);
  3113. $shortname = $this->shop->get_shortname($shortname[0]);
  3114. if(!$shortname)
  3115. {
  3116. $ed[] = array($value['1'].'-编码有问题');
  3117. $i++;
  3118. continue;
  3119. }
  3120. $post['shop'] = $shortname['id']?$shortname['id']:0;//速卖通
  3121. $post['user'] = '无';
  3122. $post['number'] = $value['1'];//编号
  3123. $post['orderinfo'] = $value['2'];//订单号
  3124. $post['client'] = preg_replace('/( | | |\s)/',' ',$value['3']);//客户名称
  3125. $post['buytime'] = $tytime;//时间转UX
  3126. $post['dtime'] = $tytime;//订单时间
  3127. $post['gtime'] = date('Ymd',$tytime);//格式化时间
  3128. //$post['pay'] = $this->input->post('pay',true);//支付方式
  3129. $post['capital'] = 3;//资金状态
  3130. $post['type'] = 5;//发货仓库
  3131. $post['currency'] = 219;//币种
  3132. $post['currencytitle'] = 'USD';//币种名称
  3133. $post['freight'] = 0;//运费
  3134. $post['expressmoney'] = 0;//物流金额
  3135. $post['shouldmoney'] = 0;//应收金额
  3136. $post['budget'] = 0;//应到金额*店铺到帐金额比
  3137. $orderremarks = '';//订单备注
  3138. $post['shipremarks'] = $value['12'];//仓库品名
  3139. $post['email'] = '';//邮箱
  3140. $post['name'] = preg_replace('/( | | |\s)/',' ',$value['3']);//名字
  3141. $post['phone'] = $value['10'];//电话
  3142. $post['country'] = 192;//国家
  3143. $ct = $this->country->get_ename($value['9']);//国家
  3144. $post['al'] = $ct['lb'];//国家二字码
  3145. $post['province'] = $value['8'];//省、州
  3146. $post['city'] = $value['6'];//城市
  3147. $post['zipcode'] = $value['7'];//邮编
  3148. $post['address'] = $value['4'];//地址1
  3149. $post['address2'] = $value['5']?$value['5']:'';//地址2
  3150. $post['express'] = 2;//快递
  3151. $post['printtype'] = 1;//打印类型
  3152. $post['fpdata'] = '';//购买产品内容
  3153. $post['sbpm'] = 'Hair Sample';//申报品名
  3154. $post['zwpm'] = '假发';//中文品名
  3155. $post['ts'] = $value['17'];//条数
  3156. $post['dtsbjz'] = 15;//单条申报价
  3157. $post['zsbjz'] = 15;//总申报价
  3158. $post['zzl'] = 0.5;//总重量
  3159. $post['zjs'] = 1;//总件数
  3160. $post['quantity'] = 1;//数量
  3161. $post['paypal'] = '';//支付号
  3162. $post['guarantee'] = '';//卖家保障
  3163. $post['zzl'] = $value['13'];//总重量
  3164. $post['bx'] = $value['14'];//总重量
  3165. $post['qm'] = $value['15'];//总重量
  3166. $post['js'] = $value['16'];//总重量
  3167. $barcode = $this->usps->get_address(array('address'=>$value['4'],'address2'=>$value['5'],'city'=>$value['6'],'province'=>$value['8'],'zipcode'=>$value['7']));
  3168. if(isset($barcode['Address']['Error']['Description']))
  3169. {
  3170. $ed[] = array($value['1'].'-'.$barcode['Address']['Error']['Description']);
  3171. $i++;
  3172. }
  3173. else
  3174. {
  3175. $this->fullorder_smt->insert($post);
  3176. }
  3177. }
  3178. else
  3179. {
  3180. $ed[] = array($value['1'].'-单号错误或重复操作');
  3181. $i++;
  3182. }
  3183. sleep(2);//停留2秒
  3184. }
  3185. if($i+$j > 0)
  3186. {
  3187. $time = date('Ymd',time());
  3188. $title = '错误信息-'.$time;
  3189. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3190. $tail = "\n";
  3191. $filename = $title.".xls";
  3192. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3193. $dir = '/data/excel/'.$time.'/';
  3194. $file_name = 'error_'.$time.rand(1000,9999);
  3195. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3196. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3197. fwrite($myfile,$ecl);
  3198. fclose($myfile);
  3199. $error = $dir.$file_name.'.xls';
  3200. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3201. }
  3202. else
  3203. {
  3204. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3205. }
  3206. }
  3207. else
  3208. {
  3209. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3210. }
  3211. }
  3212. public function _email($content,$data,$shopname)
  3213. {
  3214. $express = $this->express->read($data['express']);
  3215. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  3216. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  3217. $content = str_replace($t,$h,$content);
  3218. $this->load->library('email');
  3219. $config['protocol'] = 'smtp';
  3220. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  3221. $config['smtp_port'] = 465;
  3222. $config['smtp_user'] = 'service@email.supernovahair.com';
  3223. $config['smtp_pass'] = 'LONGyihair374';
  3224. $config['smtp_crypto'] = 'ssl';
  3225. $config['crlf'] = "\r\n";
  3226. $config['newline'] = "\r\n";
  3227. $this->email->initialize($config);
  3228. $this->email->from('service@email.supernovahair.com',$shopname);
  3229. $this->email->to($data['email']);//收件
  3230. $this->email->subject('The product you purchased has a new progress');//标题
  3231. $this->email->message($content);//内容
  3232. if ( ! $this->email->send())
  3233. {
  3234. return 2;
  3235. }
  3236. else
  3237. {
  3238. return 1;
  3239. }
  3240. }
  3241. //导出订单excel
  3242. public function _cs()
  3243. {
  3244. if(isset($_GET['fexcel']))
  3245. {
  3246. if(isset($_SESSION['api']))
  3247. {
  3248. $user = $this->user->get_api($_SESSION['api']);
  3249. $usp = $user;
  3250. $fgshop = "";$sid = "";
  3251. $user = explode('|',trim($user['shop'],'|'));
  3252. foreach ($user as $value)
  3253. {
  3254. $fgshop .= " shop = ".$value." or";
  3255. $sid .= " id = ".$value." or";
  3256. }
  3257. }
  3258. $dowid = $this->input->get('a');
  3259. $wid = "";
  3260. if($dowid != "")
  3261. {
  3262. $id_arr = explode(',',rtrim($dowid,','));
  3263. foreach ($id_arr as $v)
  3264. {
  3265. $wid .= " id = 0 or";
  3266. $wid .= " id = '$v' or";
  3267. }
  3268. $wid = " and".rtrim($wid,'or');
  3269. }
  3270. $fexcel = $this->input->get('fexcel',true);
  3271. $page = $this->input->get('page',true);
  3272. $perpage = $this->input->get('perpage',true);
  3273. $warehouse = $this->input->get('warehouse',true);
  3274. $timetk = $this->input->get('timetk',true);
  3275. $timetj = $this->input->get('timetj',true);
  3276. $shop = $this->input->get('shop',true);
  3277. $source = $this->input->get('source',true);
  3278. $state = $this->input->get('state',true);
  3279. $review = $this->input->get('review',true);
  3280. $type = $this->input->get('type',true);
  3281. $express = $this->input->get('express',true);
  3282. $orderinfo = $this->input->get('orderinfo',true);
  3283. $user = $this->input->get('user',true);
  3284. $client = $this->input->get('name',true);
  3285. $waybill = $this->input->get('waybill',true);
  3286. $number = $this->input->get('number',true);
  3287. $email = $this->input->get('email',true);
  3288. $dlz = $this->input->get('dlz',true);
  3289. $library = $this->input->get('library',true);
  3290. $libraryconfirm = $this->input->get('libraryconfirm',true);
  3291. $print = $this->input->get('print',true);
  3292. $timetkk = $this->input->get('timetkk',true);
  3293. $timetjj = $this->input->get('timetjj',true);
  3294. $timetk = strtotime($timetk);
  3295. $timetj = strtotime($timetj);
  3296. $timetkk = strtotime($timetkk);
  3297. $timetjj = strtotime($timetjj);
  3298. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  3299. if($warehouse)
  3300. {
  3301. $where .= " and type = '$warehouse'";
  3302. }
  3303. if($timetk && $timetj)
  3304. {
  3305. $timetj = $timetj+24*3600;
  3306. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3307. }
  3308. if($timetkk && $timetjj)
  3309. {
  3310. $where .= " and librarytime > '$timetkk' and librarytime < '$timetjj'";
  3311. }
  3312. if($library)
  3313. {
  3314. $where .= " and library = '$library'";
  3315. }
  3316. if($print)
  3317. {
  3318. $where .= " and print = '$print'";
  3319. }
  3320. if($shop)
  3321. {
  3322. $where .= " and shop = '$shop'";
  3323. }
  3324. if($source)
  3325. {
  3326. $where .= " and source = '$source'";
  3327. }
  3328. if($state)
  3329. {
  3330. $where .= " and state = '$state'";
  3331. }
  3332. if($review)
  3333. {
  3334. $where .= " and review = '$review'";
  3335. }
  3336. if($type)
  3337. {
  3338. $where .= " and type = '$type'";
  3339. }
  3340. if($express)
  3341. {
  3342. $where .= " and express = '$express'";
  3343. }
  3344. if($orderinfo)
  3345. {
  3346. $where .= " and orderinfo = '$orderinfo'";
  3347. }
  3348. if($user)
  3349. {
  3350. $where .= " and user = '$user'";
  3351. }
  3352. if($client)
  3353. {
  3354. $where .= " and client like '%$client%'";
  3355. }
  3356. if($waybill)
  3357. {
  3358. $where .= " and waybill = '$waybill'";
  3359. }
  3360. if($number)
  3361. {
  3362. $where .= " and number = '$number'";
  3363. }
  3364. if($email)
  3365. {
  3366. $where .= " and email = '$email'";
  3367. }
  3368. if($dlz)
  3369. {
  3370. $where .= " and waybill != '' and dlz = 0";
  3371. }
  3372. if($dlz)
  3373. {
  3374. $where .= " and libraryconfirm = '$libraryconfirm'";
  3375. }
  3376. $fexcel = $this->fullorderexcel->read($fexcel);
  3377. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  3378. foreach ($fexceleq as $k=>$v)
  3379. {
  3380. $fexceleq[$k] = explode('-',$v);
  3381. $num[$k] = $fexceleq[$k][0];
  3382. }
  3383. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  3384. $feq = "";
  3385. foreach ($fexceleq as $k=>$v)
  3386. {
  3387. $feq .= $v[1].',';
  3388. }
  3389. $feq = rtrim($feq,',');
  3390. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  3391. foreach ($fexcelzhw as $k=>$v)
  3392. {
  3393. $fexcelzhw[$k] = explode('-',$v);
  3394. $numb[$k] = $fexcelzhw[$k][0];
  3395. }
  3396. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  3397. $fexcelzh = array();
  3398. foreach ($fexcelzhw as $k=>$v)
  3399. {
  3400. $fexcelzh[] = $v[1];
  3401. }
  3402. //取得信息列表
  3403. $info_list = $this->fullorder->find_all($where.$wid,$feq,'id desc');
  3404. //格式化数据
  3405. $i = 1;$shouldmoney = 0;$hl=1;
  3406. foreach ($info_list as $key=>$value)
  3407. {
  3408. if(isset($value['currencytitle']))
  3409. {
  3410. if($value['currencytitle'] != "CNY")
  3411. {
  3412. $hl=$value['hl'];
  3413. }
  3414. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3415. $budget=$budget+($value['budget']*$hl);
  3416. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  3417. $refund=$refund+($value['refund']*$hl);
  3418. }
  3419. if(isset($value['shop']))
  3420. {
  3421. $shop = $this->shop->read($value['shop']);
  3422. $info_list[$key]['shop'] = $shop['shopname'];
  3423. }
  3424. if(isset($value['dtime']))
  3425. {
  3426. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3427. }
  3428. if(isset($value['country']))
  3429. {
  3430. $country = $this->country->read($value['country']);
  3431. $info_list[$key]['country'] = $country['name'];
  3432. }
  3433. if(isset($value['type']))
  3434. {
  3435. $type = $this->warehouse->read($value['type']);
  3436. $info_list[$key]['type'] = $type['title'];
  3437. }
  3438. if(isset($value['express']))
  3439. {
  3440. $express = $this->express->read($value['express']);
  3441. if($express)
  3442. {
  3443. $info_list[$key]['express'] = $express['servicename'];
  3444. }
  3445. else
  3446. {
  3447. $info_list[$key]['express'] = '未选择';
  3448. }
  3449. }
  3450. }
  3451. echo $timetkk;
  3452. }
  3453. }
  3454. public function _gggs($sku,$s,$j,$k)
  3455. {
  3456. $companytitle = array(9=>3,10=>2,11=>1,12=>4);
  3457. $this->load->database();
  3458. $this->db->select('id');
  3459. $this->db->from('crowd_whlabel');
  3460. $this->db->where('warehouse', '5');
  3461. $this->db->where('sku', $sku);
  3462. $this->db->where('state', '0');
  3463. $this->db->limit($s,$k);
  3464. $query = $this->db->get();
  3465. $ids = array_column($query->result_array(), 'id');
  3466. if (!empty($ids))
  3467. {
  3468. // 更新
  3469. $this->db->where_in('id', $ids);
  3470. $this->db->update('crowd_whlabel', array('companytitle' => $companytitle[$j]));
  3471. return $this->db->affected_rows();
  3472. }
  3473. }
  3474. public function _xxpl()
  3475. {
  3476. $this->load->database();
  3477. $data = ['type' => ''];
  3478. $this->db->update('crowd_whlabel', $data);
  3479. $wt = array();
  3480. $whlabel_type = $this->whlabel_type->find_all();
  3481. foreach ($whlabel_type as $v)
  3482. {
  3483. $wt[$v['title']] = $v['id'];
  3484. }
  3485. /* 订单加入键值-j */
  3486. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3487. $config['upload_path'] = '.'.$dir ;
  3488. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3489. $config['allowed_types'] = 'xls|xlsx|csv';
  3490. $config['max_size'] = 10240;
  3491. $this->load->library('upload', $config);
  3492. $this->upload->initialize($config);
  3493. if ($this->upload->do_upload('userfile'))
  3494. {
  3495. $full_path = $dir.$this->upload->data('file_name');
  3496. $fileName = '.' . $full_path;
  3497. if (!file_exists($fileName))
  3498. {
  3499. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3500. }
  3501. else
  3502. {
  3503. require_once "./data/excel/PHPExcel/IOFactory.php";
  3504. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3505. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3506. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3507. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3508. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3509. ++$column;//如果列数大于26行
  3510. $list = array();
  3511. for ($i = 2; $i <= $row; $i++) // 行数循环
  3512. {
  3513. $data = array();
  3514. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3515. {
  3516. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3517. }
  3518. $list[] = $data;
  3519. }
  3520. }
  3521. $wt = array();
  3522. $whlabel_type = $this->whlabel_type->find_all();
  3523. foreach ($whlabel_type as $v)
  3524. {
  3525. $wt[$v['title']] = $v['id'];
  3526. }
  3527. $j = 0;$ed = array();$e = 0;$c = 0;$cs = array();
  3528. foreach ($list as $v)
  3529. {
  3530. $this->load->database();
  3531. // 设置更新数据
  3532. $data = ['type' => $wt[$v[1]]];
  3533. // 添加条件:SKU 为 123456 且 warehouse 为 5
  3534. $this->db->where('SKU', $v[0]);
  3535. $this->db->where('warehouse', '5');
  3536. // 批量更新
  3537. $this->db->update('crowd_whlabel', $data);
  3538. }
  3539. /** 导入缺货
  3540. $time = time();
  3541. $whlabel = $this->whlabel->get_sku($v[0]);
  3542. if($whlabel)
  3543. {
  3544. $this->whlabel_qh->insert(array('sku'=>$whlabel['sku'],'features'=>$whlabel['features'],'num'=>$v['1'],'gtime'=>date('Ym',$time),'gxtime'=>date('Ymd',$time)));
  3545. }
  3546. else
  3547. {
  3548. $ed[] = $v['0'];
  3549. $j++;
  3550. }
  3551. }
  3552. **/
  3553. /**
  3554. 更换等级
  3555. $this->load->database();
  3556. // 设置更新数据
  3557. $data = ['type' => $wt[$v[1]]];
  3558. // 添加条件:SKU 为 123456 且 warehouse 为 5
  3559. $this->db->where('SKU', $v[0]);
  3560. $this->db->where('warehouse', '5');
  3561. // 批量更新
  3562. $this->db->update('crowd_whlabel', $data);
  3563. **/
  3564. /**
  3565. $whlabel_type = $this->whlabel_type->find_all();
  3566. foreach ($whlabel_type as $v)
  3567. {
  3568. $wt[$v['title']] = $v['id'];
  3569. }
  3570. foreach ($list as $v)
  3571. {
  3572. $w = $this->whlabel->find_all("sku = '".$v[0]."' and warehouse = 5");
  3573. if($w && isset($wt[$v[1]]))
  3574. {
  3575. foreach ($w as $val)
  3576. {
  3577. $this->whlabel->save(array('type'=>$wt[$v[1]]),$val['id']);
  3578. }
  3579. }
  3580. else
  3581. {
  3582. $ed[] = array($v[0],$v[1]);
  3583. $j++;
  3584. }
  3585. }
  3586. **/
  3587. if($e > 0)
  3588. {
  3589. $time = date('Ymd',time());
  3590. $title = '错误信息-'.$time;
  3591. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3592. $tail = "\n";
  3593. $filename = $title.".xls";
  3594. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3595. $dir = '/data/excel/'.$time.'/';
  3596. $file_name = 'error_'.$time.rand(1000,9999);
  3597. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3598. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3599. fwrite($myfile,$ecl);
  3600. fclose($myfile);
  3601. $error = $dir.$file_name.'.xls';
  3602. echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
  3603. }
  3604. else
  3605. {
  3606. echo json_encode(array('msg'=>'添加成功!'.$c,'success'=>true));exit;
  3607. }
  3608. }
  3609. else
  3610. {
  3611. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3612. }
  3613. }
  3614. public function _skuzh()
  3615. {
  3616. /* 订单加入键值-j */
  3617. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3618. $config['upload_path'] = '.'.$dir ;
  3619. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3620. $config['allowed_types'] = 'xls|xlsx|csv';
  3621. $config['max_size'] = 10240;
  3622. $this->load->library('upload', $config);
  3623. $this->upload->initialize($config);
  3624. if ($this->upload->do_upload('userfile'))
  3625. {
  3626. $full_path = $dir.$this->upload->data('file_name');
  3627. $fileName = '.' . $full_path;
  3628. if (!file_exists($fileName))
  3629. {
  3630. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3631. }
  3632. else
  3633. {
  3634. require_once "./data/excel/PHPExcel/IOFactory.php";
  3635. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3636. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3637. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3638. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3639. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3640. ++$column;//如果列数大于26行
  3641. $list = array();
  3642. for ($i = 2; $i <= $row; $i++) // 行数循环
  3643. {
  3644. $data = array();
  3645. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3646. {
  3647. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3648. }
  3649. $list[] = $data;
  3650. }
  3651. }
  3652. $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');
  3653. $dtc = array();
  3654. foreach ($dictionaries as $v)
  3655. {
  3656. if(stripos($v['spare'],'|') !== false)//如果有多个值
  3657. {
  3658. $v['spare'] = explode('|',$v['spare']);
  3659. foreach ($v['spare'] as $k=>$vs)
  3660. {
  3661. if(stripos($v['zh'],'|') !== false)
  3662. {
  3663. $vzh = explode('|',$v['zh']);
  3664. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  3665. }
  3666. else
  3667. {
  3668. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  3669. }
  3670. }
  3671. }
  3672. else
  3673. {
  3674. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  3675. }
  3676. }
  3677. $dictionaries2 = $this->typeclass->find_all();
  3678. foreach ($dictionaries2 as $v)
  3679. {
  3680. $dtctitle[$v['id']] = $v['title'];
  3681. }
  3682. /* 匹配结束 */
  3683. /* 价格加入 */
  3684. $money = array();
  3685. $productdescribe = $this->productdescribe->find_all('1=1');
  3686. foreach ($productdescribe as $v)
  3687. {
  3688. $money[$v['number']] = array();
  3689. }
  3690. /* 价格加入 */
  3691. /* 匹配ID加入 */
  3692. $int = array();
  3693. $intdata = $this->typeclass->find_all('classid=14','id,spare');
  3694. foreach ($intdata as $v)
  3695. {
  3696. $v['spare'] = explode('|',$v['spare']);
  3697. $int[$v['id']] = $v['spare'][0];
  3698. }
  3699. /* 匹配ID加入 */
  3700. $zjsku = array();
  3701. $shopsku = $this->shopsku->find_all();
  3702. foreach ($shopsku as $val)
  3703. {
  3704. $ss = explode(',',trim($val['shop'],','));
  3705. foreach ($ss as $v)
  3706. {
  3707. if(isset($zjsku[$v]))
  3708. {
  3709. $zjsku[$v] .= ','.trim($val['sku'],',');
  3710. }
  3711. else
  3712. {
  3713. $zjsku[$v] = trim($val['sku'],',');
  3714. }
  3715. }
  3716. }
  3717. /* 匹配ID结束 */
  3718. $q = '1;';
  3719. $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
  3720. $shop = $this->shop->read(19);
  3721. if(isset($zjsku[$shop['id']]))//判断是否找到店铺SKU
  3722. {
  3723. $sku = rtrim($sku,',').','.$zjsku[$shop['id']];
  3724. }
  3725. $ed = array();
  3726. foreach ($list as $v)
  3727. {
  3728. $r = $this->api->matching(trim($q,';'),$v['2'],$dtc,$money,$int,$dtctitle,$shop);
  3729. $p = '';
  3730. $product = explode(';',trim($r['product'],';'));
  3731. if($r['title'] != '' && $product)
  3732. {
  3733. foreach ($product as $val)
  3734. {
  3735. $vc = explode('|',$val);
  3736. if(isset($vc[1]))
  3737. {
  3738. $p .= $vc[1].'<br>';
  3739. }
  3740. }
  3741. $r['title'] = str_replace(array('<','>'),array('&lt;','&gt;'),$r['title']);
  3742. $ed[] = array($v['0'],$v['1'],$r['title'],$v['3'],$v['4'],$v['5']);
  3743. }
  3744. else
  3745. {
  3746. $ed[] = array($v['0'],$v['1'],$v['2'].' SKU错误',$v['3'],$v['4'],$v['5']);
  3747. }
  3748. }
  3749. $time = date('Ymd',time());
  3750. $title = 'sku转换'.$time;
  3751. $titlename = "<table border=1><tr><td>退款日期</td><td>订单号</td><td>SKU</td><td退款金额</td><td退款情况具体描述</td><可用/不可用</td></tr></table>";
  3752. $tail = "\n";
  3753. $filename = $title.".xls";
  3754. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3755. $dir = '/data/excel/'.$time.'/';
  3756. $file_name = 'sku转换 '.$time.rand(1000,9999);
  3757. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3758. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3759. fwrite($myfile,$ecl);
  3760. fclose($myfile);
  3761. $error = $dir.$file_name.'.xls';
  3762. echo json_encode(array('msg'=>'转换成功!','error'=>$error,'success'=>true));exit;
  3763. }
  3764. else
  3765. {
  3766. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3767. }
  3768. }
  3769. public function _xxpl_b()
  3770. {
  3771. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  3772. /* 订单加入键值-k */
  3773. $fdata = $this->fullordersmt->find_all('dtime >'.(time()-10*24*3600));
  3774. foreach ($fdata as $v)
  3775. {
  3776. $dataorder[$v['orderinfo']] = $v;
  3777. }
  3778. /* 订单加入键值-j */
  3779. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3780. $config['upload_path'] = '.'.$dir ;
  3781. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3782. $config['allowed_types'] = 'xls|xlsx|csv';
  3783. $config['max_size'] = 10240;
  3784. $this->load->library('upload', $config);
  3785. $this->upload->initialize($config);
  3786. if ($this->upload->do_upload('userfile'))
  3787. {
  3788. $full_path = $dir.$this->upload->data('file_name');
  3789. $fileName = '.' . $full_path;
  3790. if (!file_exists($fileName))
  3791. {
  3792. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3793. }
  3794. else
  3795. {
  3796. require_once "./data/excel/PHPExcel/IOFactory.php";
  3797. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3798. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3799. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3800. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3801. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3802. ++$column;//如果列数大于26行
  3803. $list = array();
  3804. for ($i = 2; $i <= $row; $i++) // 行数循环
  3805. {
  3806. $data = array();
  3807. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3808. {
  3809. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3810. }
  3811. $list[] = $data;
  3812. }
  3813. }
  3814. $i = 0;$j = 0;$ed = array();$time = time();
  3815. foreach ($list as $key=>$value)
  3816. {
  3817. $shop = $this->shop->get_shopname($value['2']);//通过店铺名称查找店铺
  3818. if(!$shop)
  3819. {
  3820. $ed[] = array($value['0'].'-无此店铺');
  3821. $i++;continue;
  3822. }
  3823. $post['buytime'] = strtotime($value['6']);//付款时间
  3824. $value['0'] = preg_replace('/\D/s','',$value['0']);
  3825. if($value['0'] && !isset($dataorder[$value['0']]))
  3826. {
  3827. $post['source'] = 2;//订单类型:1.线下订单2.PC3.手机
  3828. $post['state'] = 207;//订单状态:207等待发货
  3829. $post['review'] = 6;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
  3830. $post['reviewtime'] = $time;//审核时间
  3831. $post['print'] = 2;//打印状态:1.不可打印2.未打印3.已打印
  3832. $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
  3833. $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
  3834. $post['dtime'] = $time;//订单时间
  3835. $post['capital'] = 3;//资金状态
  3836. $post['currency'] = 219;//币种
  3837. $post['currencytitle'] = 'USD';//币种名称
  3838. $post['freight'] = 0;//运费
  3839. $post['expressmoney'] = 0;//物流金额
  3840. $post['shouldmoney'] = 0;//应收金额
  3841. if($post['print'] != 3)
  3842. {
  3843. $post['librarynot'] = "订单未打印";//不能出库原因
  3844. }
  3845. $post['gtime'] = date('Ymd',$post['buytime']);//格式化时间
  3846. $num = $this->fullordersmt->find_count('gtime = "'.date('Ymd',$post['buytime']).'" and shop = "'.$shop['id'].'"','id');
  3847. $post['number'] = $shop['shortname'].'-'.substr(date('ymd',$post['buytime']),1).'-'.(substr(strval($num+1+1000),1,3));//编号
  3848. $post['user'] = $shop['shopuser'];//店铺负责人
  3849. $post['orderinfo'] = $value['0'];//订单号
  3850. $post['type'] = $value['7'];//发货仓库
  3851. $post['shop'] = $shop['id'];//店铺
  3852. $post['shouldmoney'] = $value['3'];//订单金额
  3853. $post['product'] = $value['4']?$value['4']:'';//商品名称
  3854. $post['pay'] = $value['5'];//付款方式
  3855. $post['paypal'] = $value['1']?$value['1']:'';//交易号
  3856. $post['orderremarks'] = $value['8']?$value['8']:'';//订单备注
  3857. $post['shipremarks'] = $value['9'];//仓库品名
  3858. $post['client'] = preg_replace('/( | | | |\s)/',' ',$value['10']);//公司名
  3859. $post['name'] = preg_replace('/( | | | |\s)/',' ',$value['11']);//收货人
  3860. $post['phone'] = $value['12'];//电话
  3861. $ct = $this->country->get_ename(preg_replace('/( | | | |\s)/',' ',$value['13']));//国家
  3862. if(!$ct)
  3863. {
  3864. $ed[] = array($value['0'].'-无此国家');
  3865. $i++;continue;
  3866. }
  3867. $post['country'] = $ct['id'];//国家
  3868. $post['al'] = $ct['lb'];//国家二字码
  3869. $post['province'] = $value['14'];//省、州
  3870. $post['city'] = $value['15'];//城市
  3871. $post['zipcode'] = $value['16'];//邮编
  3872. $post['address'] = $value['17'];//地址1
  3873. $post['address2'] = $value['18']?$value['18']:'';//地址2
  3874. $yga = $value['3'];$ygb = $shop['estimaterate'];
  3875. $post['budget'] = eval("return $yga*1.$ygb;");//预估到帐金额
  3876. $post['sbpm'] = $value['19'];//申报品名
  3877. $post['zwpm'] = $value['20'];//中文品名
  3878. $post['ts'] = $value['21'];//条数
  3879. $post['dtsbjz'] = $value['22'];//单条申报价
  3880. $post['zsbjz'] = $value['23'];//总申报价
  3881. $post['zzl'] = $value['24'];//总重量
  3882. $post['zjs'] = $value['25'];//总件数
  3883. $express = $this->express->get_servicename(preg_replace('/( | | | |\s)/',' ',$value['26']));
  3884. if(!$express)
  3885. {
  3886. $ed[] = array($value['0'].'-无此快递方式');
  3887. $i++;continue;
  3888. }
  3889. $post['express'] = $express['id'];//快递
  3890. $post['printtype'] = 1;//打印类型 1.运单.2.发货单
  3891. $post['fpdata'] = '';//购买产品内容
  3892. $this->fullordersmt->insert($post);
  3893. }
  3894. else
  3895. {
  3896. $ed[] = array($value['0'].'-单号错误或重复操作');
  3897. $i++;
  3898. }
  3899. sleep(2);//停留2秒
  3900. }
  3901. if($i+$j > 0)
  3902. {
  3903. $time = date('Ymd',time());
  3904. $title = '错误信息-'.$time;
  3905. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3906. $tail = "\n";
  3907. $filename = $title.".xls";
  3908. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3909. $dir = '/data/excel/'.$time.'/';
  3910. $file_name = 'error_'.$time.rand(1000,9999);
  3911. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3912. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3913. fwrite($myfile,$ecl);
  3914. fclose($myfile);
  3915. $error = $dir.$file_name.'.xls';
  3916. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3917. }
  3918. else
  3919. {
  3920. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3921. }
  3922. }
  3923. else
  3924. {
  3925. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3926. }
  3927. }
  3928. public function _scwd()
  3929. {
  3930. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3931. $config['upload_path'] = '.'.$dir ;
  3932. $config['allowed_types'] = '*';
  3933. $config['max_size'] = 102400;
  3934. $this->load->library('upload', $config);
  3935. $this->upload->initialize($config);
  3936. if ($this->upload->do_upload('userfile'))
  3937. {
  3938. $full_path = $dir.$this->upload->data('file_name');
  3939. echo json_encode(array('msg'=>'成功!','wdurl'=>$full_path,'success'=>true));exit;
  3940. }
  3941. else
  3942. {
  3943. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3944. }
  3945. }
  3946. public function _jmexcel()
  3947. {
  3948. $setting = $this->setting->get_settings();
  3949. $excelpass = $setting['excelpass'];
  3950. $excelusernum = $setting['excelusernum'];
  3951. $exceljmnum = $setting['exceljmnum'];
  3952. $user = $this->user->get_api($_SESSION['api']);
  3953. if(!isset($user['exceltime']))
  3954. {
  3955. $this->session->sess_destroy();
  3956. header("Location:/");
  3957. }
  3958. $post = $this->input->post(NULL, TRUE);
  3959. if(isset($post['data']))
  3960. {
  3961. $data = $this->input->post('data',true);
  3962. $data = str_replace("\n",",",$data);;
  3963. $data = explode(',',trim($data,','));
  3964. $d = '';$i = 0;
  3965. foreach ($data as $v)
  3966. {
  3967. if($v == '')
  3968. {
  3969. continue;
  3970. }
  3971. $j = $this->setting->get_jmexcelpass($v);
  3972. if($j == '')
  3973. {
  3974. $j = $v.' 信息不正确';
  3975. }
  3976. $d .= $j."<br />";
  3977. $i++;
  3978. }
  3979. if($i > $exceljmnum)
  3980. {
  3981. echo json_encode(array('msg'=>'每次解密数量不可超出'.$exceljmnum.'条','success'=>false));exit;
  3982. }
  3983. if($user['exceltime'] != date('Ymd',time()))
  3984. {
  3985. $this->user->save(array('exceltime'=>date('Ymd',time()),'excelnum'=>1),$user['id']);
  3986. }
  3987. else
  3988. {
  3989. if($user['excelnum'] > $excelusernum)
  3990. {
  3991. echo json_encode(array('msg'=>'今日此账号解密次数已使用完毕','success'=>false));exit;
  3992. }
  3993. else
  3994. {
  3995. $this->user->save(array('excelnum'=>$user['excelnum']+1),$user['id']);
  3996. }
  3997. }
  3998. echo json_encode(array('msg'=>$d,'success'=>true));exit;
  3999. }
  4000. $this->data['excelpass'] = $excelpass;
  4001. $this->data['excelusernum'] = $excelusernum;
  4002. $this->data['exceljmnum'] = $exceljmnum;
  4003. $this->_Template('fullorderexcel_jmexcel',$this->data);
  4004. }
  4005. //管理
  4006. public function _classid()
  4007. {
  4008. $post = $this->input->post(NULL, TRUE);
  4009. if(isset($post['page']))
  4010. {
  4011. $page = $this->input->post('page',true);
  4012. $perpage = $this->input->post('perpage',true);
  4013. $type = $this->input->post('type',true);
  4014. $where = "1=1 ";
  4015. //数据排序
  4016. $order_str = "id asc";
  4017. if(empty($page))
  4018. {
  4019. $start = 0;
  4020. $perpage = 1;
  4021. }
  4022. else
  4023. {
  4024. $start = ($page - 1)*$perpage;
  4025. }
  4026. if($type)
  4027. {
  4028. $where .= " and type = '$type'";
  4029. }
  4030. //取得信息列表
  4031. $info_list = $this->fullorderexcelclassid->find_all($where,'id,title,type',$order_str,$start,$perpage);
  4032. $total = $this->fullorderexcelclassid->find_count($where);
  4033. $pagenum = ceil($total/$perpage);
  4034. $over = $total-($start+$perpage);
  4035. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4036. echo json_encode($rows);exit;
  4037. }
  4038. $this->_Template('fullorderexcel_classid',$this->data);
  4039. }
  4040. //添加
  4041. public function _classidadd()
  4042. {
  4043. $post = $this->input->post(NULL, TRUE);
  4044. if(isset($post['title']))
  4045. {
  4046. if($this->fullorderexcelclassid->insert($post))
  4047. {
  4048. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  4049. }
  4050. else
  4051. {
  4052. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  4053. }
  4054. }
  4055. $this->_Template('fullorderexcel_classidadd',$this->data);
  4056. }
  4057. //修改
  4058. public function _classidedit($arg_array)
  4059. {
  4060. $post = $this->input->post(NULL, TRUE);
  4061. if(isset($post['id']))
  4062. {
  4063. $id = $this->input->post('id',true);
  4064. if($this->fullorderexcelclassid->save($post,$id))
  4065. {
  4066. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  4067. }
  4068. else
  4069. {
  4070. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  4071. }
  4072. }
  4073. $arg_array = $arg_array[0];
  4074. $fullorderexcelclassid = $this->fullorderexcelclassid->read($arg_array);
  4075. $this->data['fullorderexcelclassid'] = $fullorderexcelclassid;
  4076. $this->_Template('fullorderexcel_classidedit',$this->data);
  4077. }
  4078. }