Fullorderexcel.php 125 KB

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