Fullorderexcel.php 131 KB

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