Fullorderexcel.php 124 KB

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