Fullorderexcel.php 125 KB

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