Fullorderexcel.php 130 KB

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