Fullorderexcel.php 130 KB

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