Fullorderexcelbak.php 126 KB

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